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