互动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
3.4 KiB

5 years ago
5 years ago
5 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
  1. package models
  2. import (
  3. "github.com/ouxuanserver/osmanthuswine/src/core"
  4. "github.com/ouxuanserver/osmanthuswine/src/helper"
  5. )
  6. const AreaStoreTableName = TableNamePrefix + "area_store"
  7. //店铺地区
  8. type AreaStore struct {
  9. Model `xorm:"extends"`
  10. //Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
  11. //IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('软删除') TINYINT(1)"`
  12. //CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"`
  13. //UpdatedAt time.Time `json:"updated_at" xorm:"not null updated comment('更新时间') DATETIME"`
  14. //
  15. Name string `json:"name" xorm:"not null default('') comment('名字') VARCHAR(255)"`
  16. Type string `json:"type" xorm:"not null default('') comment('地区类型') VARCHAR(255)"`
  17. Address string `json:"address" xorm:"not null default('') comment('地址') VARCHAR(255)"`
  18. ActivityId int `json:"activity_id" xorm:"not null comment('主活动id') BIGINT(20)"`
  19. CustomerId int `json:"customer_id" xorm:"not null default 0 comment('客户id') INT(11)"`
  20. IsMainArea int `json:"is_main_area" xorm:"not null default(0) comment('是否主地区1是') TINYINT(1)"`
  21. AreaServicePhone string `json:"area_service_phone" xorm:"not null default '' comment('地区客服电话') VARCHAR(128)"`
  22. AdminName string `json:"admin_name" xorm:"not null default '' comment('地区管理员名称') VARCHAR(128)"`
  23. Phone string `json:"phone" xorm:"not null default '' comment('地区管理员账号即手机号') VARCHAR(128)"`
  24. Password string `json:"password" xorm:"not null default '' comment('密码') VARCHAR(255)"`
  25. RawPassword string `json:"raw_password" xorm:"not null default '' comment('密码') VARCHAR(255)"`
  26. IsImport int `json:"is_import" xorm:"not null default 0 comment('是否导入的数据') TINYINT(1)"`
  27. AreaGoodsRuleSwitch int `json:"area_goods_rule_switch" xorm:"not null default 0 comment('地区专属商品规则1开启(用自己地区的商品)0关闭(共用主会场的商品)') TINYINT(1)"`
  28. UserId int `json:"user_id" xorm:"not null default 0 comment('用户id') INT(11)"`
  29. }
  30. func (t *AreaStore) TableName() string {
  31. return AreaStoreTableName
  32. }
  33. func (t *AreaStore) Login(activityId int, username, password string) (bool, error) {
  34. password = helper.Md5("hdzj==" + password)
  35. return core.GetXormAuto().NoAutoCondition().Where("activity_id=? and phone=? and password=?", activityId, username, password).Get(t)
  36. }
  37. func (t *AreaStore) GetByUserId(activityId, userId int) (bool, error) {
  38. return core.GetXormAuto().Where("user_id=? and activity_id=?", userId, activityId).Get(t)
  39. }
  40. func (t *AreaStore) GetByCustomerId(customerId, activityId interface{}) (bool, error) {
  41. return core.GetXormAuto().Where("is_delete=0 and customer_id=? and activity_id=?", customerId, activityId).Get(t)
  42. }
  43. func (t *AreaStore) GetAreaStoreById(id int) (bool, error) {
  44. return core.GetXormAuto().Where("id=? and is_delete=0", id).Get(t)
  45. }
  46. func (t *AreaStore) GetMainAreaById(aid int) (bool, error) {
  47. return core.GetXormAuto().NoAutoCondition().Where("activity_id=? and is_main_area=1 and is_delete=0", aid).Get(t)
  48. }
  49. func GetAreaStoresByActivityId(aid int) ([]*AreaStore, error) {
  50. list := make([]*AreaStore, 0)
  51. err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", aid).Find(&list)
  52. return list, err
  53. }