package models import ( "github.com/ouxuanserver/osmanthuswine/src/core" "github.com/ouxuanserver/osmanthuswine/src/helper" ) const AreaStoreTableName = TableNamePrefix + "area_store" //店铺地区 type AreaStore struct { Model `xorm:"extends"` //Id int `json:"id" xorm:"not null pk autoincr INT(11)"` //IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('软删除') TINYINT(1)"` //CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"` //UpdatedAt time.Time `json:"updated_at" xorm:"not null updated comment('更新时间') DATETIME"` // Name string `json:"name" xorm:"not null default('') comment('名字') VARCHAR(255)"` Type string `json:"type" xorm:"not null default('') comment('地区类型') VARCHAR(255)"` Address string `json:"address" xorm:"not null default('') comment('地址') VARCHAR(255)"` ActivityId int `json:"activity_id" xorm:"not null comment('主活动id') BIGINT(20)"` CustomerId int `json:"customer_id" xorm:"not null default 0 comment('客户id') INT(11)"` IsMainArea int `json:"is_main_area" xorm:"not null default(0) comment('是否主地区1是') TINYINT(1)"` AreaServicePhone string `json:"area_service_phone" xorm:"not null default '' comment('地区客服电话') VARCHAR(128)"` AdminName string `json:"admin_name" xorm:"not null default '' comment('地区管理员名称') VARCHAR(128)"` Phone string `json:"phone" xorm:"not null default '' comment('地区管理员账号即手机号') VARCHAR(128)"` Password string `json:"password" xorm:"not null default '' comment('密码') VARCHAR(255)"` RawPassword string `json:"raw_password" xorm:"not null default '' comment('密码') VARCHAR(255)"` IsImport int `json:"is_import" xorm:"not null default 0 comment('是否导入的数据') TINYINT(1)"` AreaGoodsRuleSwitch int `json:"area_goods_rule_switch" xorm:"not null default 0 comment('地区专属商品规则1开启(用自己地区的商品)0关闭(共用主会场的商品)') TINYINT(1)"` UserId int `json:"user_id" xorm:"not null default 0 comment('用户id') INT(11)"` } func (t *AreaStore) TableName() string { return AreaStoreTableName } func (t *AreaStore) Login(activityId int, username, password string) (bool, error) { password = helper.Md5("hdzj==" + password) return core.GetXormAuto().NoAutoCondition().Where("activity_id=? and phone=? and password=?", activityId, username, password).Get(t) } func (t *AreaStore) GetByUserId(activityId, userId int) (bool, error) { return core.GetXormAuto().Where("user_id=? and activity_id=?", userId, activityId).Get(t) } func (t *AreaStore) GetByCustomerId(customerId, activityId interface{}) (bool, error) { return core.GetXormAuto().Where("is_delete=0 and customer_id=? and activity_id=?", customerId, activityId).Get(t) } func (t *AreaStore) GetAreaStoreById(id int) (bool, error) { return core.GetXormAuto().Where("id=? and is_delete=0", id).Get(t) } func (t *AreaStore) GetMainAreaById(aid int) (bool, error) { return core.GetXormAuto().NoAutoCondition().Where("activity_id=? and is_main_area=1 and is_delete=0", aid).Get(t) } func GetAreaStoresByActivityId(aid int) ([]*AreaStore, error) { list := make([]*AreaStore, 0) err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", aid).Find(&list) return list, err }