package model import ( "time" "git.rosy.net.cn/baseapi/utils" ) const ( StoreStatusAll = -9 StoreStatusDisabled = -2 StoreStatusClosed = -1 StoreStatusHaveRest = 0 StoreStatusOpened = 1 StoreIsSyncAll = -1 StoreIsSyncNo = 0 StoreIsSyncYes = 1 ) const ( MainSubStoreName = "本店" MainSubStoreAddress = "本店" ) // 配送范围类型,此定义与京东到家相同,除非特殊说明,本系统中的坐标都是火星坐标 const ( DeliveryRangeTypePolygon = 2 DeliveryRangeTypeRadius = 3 ) const ( StoreDeliveryTypeCrowdSourcing = 0 //缺省,平台众包配送,可转自送 StoreDeliveryTypeByPlatform = 1 //平台专送 StoreDeliveryTypeByStore = 2 //完全门店自送 ) const ( StoreChangePriceTypeDirect = 0 StoreChangePriceTypeNeedApprove = 1 ) var ( StoreStatusName = map[int]string{ StoreStatusDisabled: "禁用", StoreStatusClosed: "长期休息", StoreStatusHaveRest: "临时休息", StoreStatusOpened: "营业中", } DeliveryRangeTypeName = map[int]string{ DeliveryRangeTypePolygon: "多边形", DeliveryRangeTypeRadius: "圆", } DeliveryTypeName = map[int]string{ StoreDeliveryTypeCrowdSourcing: "平台众包", StoreDeliveryTypeByPlatform: "平台专送", StoreDeliveryTypeByStore: "门店自送", } BankName = map[string]string{ "ICB": "工商银行", "CCB": "建设银行", "ABC": "农业银行", "BOC": "中国银行", "PSBC": "邮储银行", "CITIC": "中信银行", "CEB": "光大银行", "HXB": "华夏银行", "CMBC": "民生银行", "CMB": "招商银行", "SHB": "上海银行", "BJB": "北京银行", "BEA": "东亚银行", "CIB": "兴业银行", "NBB": "宁波银行", "SPDB": "浦发银行", "GDB": "广发银行", "BOCOM": "交通银行", "SPAB": "平安银行", "BSB": "包商银行", "CSCB": "长沙银行", "CDB": "承德银行", "CDRCB": "成都农商银行", "CRCB": "重庆农村商业银行", "CQB": "重庆银行", "DLB": "大连银行", "DYCCB": "东营市商业银行", "ORBANK": "鄂尔多斯银行", "FJNXB": "福建省农村信用社", "GYB": "贵阳银行", "GCB": "广州银行", "GRCB": "广州农村商业银行", "HEBB": "哈尔滨银行", "HNNXB": "湖南省农村信用社", "HSB": "徽商银行", "BHB": "河北银行", "HZCB": "杭州银行", "BOJZ": "锦州银行", "CSRCB": "江苏常熟农村商业银行", "JSB": "江苏银行", "JRCB": "江阴农村商业银行", "JJCCB": "九江银行", "LZB": "兰州银行", "DAQINGB": "龙江银行", "QHB": "青海银行", "SHRCB": "上海农商银行", "SRB": "上饶银行", "SDEB": "顺德农村商业银行", "TZCB": "台州银行", "WHSHB": "威海市商业银行", "WFCCB": "潍坊银行", "WZCB": "温州银行", "URMQCCB": "乌鲁木齐商业银行", "WRCB": "无锡农村商业银行", "YCCB": "宜昌市商业银行", "YZB": "鄞州银行", "CZCB": "浙江稠州商业银行", "ZJTLCB": "浙江泰隆商业银行", "MTBANK": "浙江民泰商业银行", "NJCB": "南京银行", "NCB": "南昌银行", "QLBANK": "齐鲁银行", "YDRCB": "尧都农村商业银行", } ) type Store struct { ModelIDCULD OriginalName string `orm:"-" json:"originalName"` Name string `orm:"size(255)" json:"name"` CityCode int `orm:"default(0);null" json:"cityCode"` // todo ? DistrictCode int `orm:"default(0);null" json:"districtCode"` // todo ? Address string `orm:"size(255)" json:"address"` Tel1 string `orm:"size(32);index" json:"tel1"` Tel2 string `orm:"size(32);index" json:"tel2"` OpenTime1 int16 `json:"openTime1"` // 930就表示9点半,用两个的原因是为了支持中午休息,1与2的时间段不能交叉,为0表示没有 CloseTime1 int16 `json:"closeTime1"` // 格式同上 OpenTime2 int16 `json:"openTime2"` // 格式同上 CloseTime2 int16 `json:"closeTime2"` // 格式同上 Lng int `json:"-"` // 乘了10的6次方 Lat int `json:"-"` // 乘了10的6次方 DeliveryRangeType int8 `json:"deliveryRangeType"` // 参见相关常量定义 DeliveryRange string `orm:"type(text)" json:"deliveryRange"` // 如果DeliveryRangeType为DeliveryRangeTypePolygon,则为逗号分隔坐标,分号分隔的坐标点(坐标与Lng和Lat一样,都是整数),比如 121361504,31189308;121420555,31150238。否则为半径,单位为米 Status int `json:"status"` ChangePriceType int8 `json:"changePriceType"` // 修改价格类型,即是否需要审核 DeliveryType int8 `orm:"-" json:"deliveryType"` // 仅用于传值 PrinterVendorID int `orm:"column(printer_vendor_id);" json:"printerVendorID"` PrinterSN string `orm:"size(32);column(printer_sn);index" json:"printerSN"` PrinterKey string `orm:"size(32)" json:"printerKey"` IDCardFront string `orm:"size(255);column(id_card_front)" json:"idCardFront"` IDCardBack string `orm:"size(255);column(id_card_back)" json:"idCardBack"` IDCardHand string `orm:"size(255);column(id_card_hand)" json:"idCardHand"` Licence string `orm:"size(255)" json:"licence"` // 营业执照图片 LicenceCode string `orm:"size(32)" json:"licenceCode"` LicenceType int8 `json:"licenceType"` // 营业执照类型,0:个人,1:公司 LicenceCorpName string `orm:"size(64)" json:"licenceCorpName"` // 营业执照公司名称 LicenceOwnerName string `orm:"size(8)" json:"licenceOwnerName"` // 法人姓名 LicenceAddress string `orm:"size(255)" json:"licenceAddress"` // 地址 LicenceValid string `orm:"size(32)" json:"licenceValid"` // 有效期开始 LicenceExpire string `orm:"size(32)" json:"licenceExpire"` // 有效期结束 IDName string `orm:"size(8);column(id_name)" json:"idName"` // 身份证姓名 IDCode string `orm:"size(32);column(id_code)" json:"idCode"` // 身份证号 IDValid string `orm:"column(id_valid);size(32)" json:"idValid"` // 有效期开始 IDExpire string `orm:"column(id_expire);size(32)" json:"idExpire"` // 有效期结束 Licence2Image string `orm:"size(255)" json:"licence2Image"` // 食品经营许可证 Licence2Code string `orm:"size(32)" json:"licence2Code"` // 食品经营许可证编号 Licence2Valid string `orm:"size(32)" json:"licence2Valid"` // 有效期开始 Licence2Expire string `orm:"size(32)" json:"licence2Expire"` // 有效期结束 MarketManName string `orm:"size(8)" json:"marketManName"` // 市场负责人姓名 MarketManPhone string `orm:"size(16)" json:"marketManPhone"` // 市场负责人电话 JxBrandFeeFactor int `json:"jxBrandFeeFactor"` // 京西品牌费因子 MarketAddFeeFactor int `json:"marketAddFeeFactor"` // 市场附加费因子 PayeeName string `orm:"size(8)" json:"payeeName"` // 收款人姓名 PayeeAccountNo string `orm:"size(255)" json:"payeeAccountNo"` // 收款账号 PayeeBankBranchName string `orm:"size(255)" json:"payeeBankBranchName"` // 开户银行 PayeeBankName string `orm:"size(255)" json:"payeeBankName"` // 开户支行 PayPercentage int `json:"payPercentage"` OperatorName string `orm:"size(8)" json:"operatorName"` // 运营人姓名 OperatorPhone string `orm:"size(16)" json:"operatorPhone"` // 运营人电话 } func (*Store) TableUnique() [][]string { return [][]string{ []string{"Name", "DeletedAt"}, } } type StoreSub struct { ModelIDCULD StoreID int `orm:"column(store_id)"` Index int // 子店序号,为0表示主店 Name string `orm:"size(255);index"` Address string `orm:"size(255)"` Status int // 取值同Store.Status Mobile1 string `orm:"size(32)"` Mobile2 string `orm:"size(32)"` Mobile3 string `orm:"size(32)"` } func (*StoreSub) TableUnique() [][]string { return [][]string{ []string{"StoreID", "Index", "DeletedAt"}, } } type StoreMap struct { ModelIDCULD StoreID int `orm:"column(store_id)" json:"storeID"` VendorID int `orm:"column(vendor_id)" json:"vendorID"` VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"` Status int `json:"status"` // 取值同Store.Status PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格 AutoPickup int8 `orm:"default(1)" json:"autoPickup"` // 是否自动拣货 DeliveryType int8 `orm:"default(0)" json:"deliveryType"` // 配送类型 DeliveryFee int `json:"deliveryFee"` DeliveryCompetition int8 `orm:"default(1)" json:"deliveryCompetition"` // 是否支持配送竞争 SyncStatus int8 `orm:"default(2)" json:"syncStatus"` IsSync int8 `orm:"default(1)" json:"isSync"` // 是否同步 } func (*StoreMap) TableUnique() [][]string { return [][]string{ []string{"StoreID", "VendorID", "DeletedAt"}, []string{"VendorStoreID", "VendorID", "DeletedAt"}, } } type StoreCourierMap struct { ModelIDCULD StoreID int `orm:"column(store_id)" json:"storeID"` VendorID int `orm:"column(vendor_id)" json:"vendorID"` VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"` Status int `json:"status"` } func (*StoreCourierMap) TableUnique() [][]string { return [][]string{ []string{"StoreID", "VendorID", "DeletedAt"}, []string{"VendorStoreID", "VendorID", "DeletedAt"}, } } type VendorStoreSnapshot struct { ModelIDCULD StoreID int `orm:"column(store_id)" json:"storeID"` VendorID int `orm:"column(vendor_id)" json:"vendorID"` VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"` SnapshotAt time.Time `orm:"type(datetime)" json:"snapshotAt"` // 这个不同于CreatedAt,SnapshotAt是逻辑上的时间,CreatedAt是实际存储的时间 Status int `json:"status"` // 取值同Store.Status OpenTime1 int16 `json:"openTime1"` // 930就表示9点半,用两个的原因是为了支持中午休息,1与2的时间段不能交叉,为0表示没有 CloseTime1 int16 `json:"closeTime1"` // 格式同上 OpenTime2 int16 `json:"openTime2"` // 格式同上 CloseTime2 int16 `json:"closeTime2"` // 格式同上 } func (*VendorStoreSnapshot) TableUnique() [][]string { return [][]string{ []string{"VendorStoreID", "VendorID", "SnapshotAt"}, } } func (*VendorStoreSnapshot) TableIndex() [][]string { return [][]string{ []string{"SnapshotAt"}, } } func (v *VendorStoreSnapshot) GenMapKey() string { return v.VendorStoreID + utils.Int2Str(v.VendorID) } func (v *VendorStoreSnapshot) CompareOperationTime(s2 *VendorStoreSnapshot) int { if s2 == nil { return 1 } if v.OpenTime1 == s2.OpenTime1 && v.CloseTime1 == s2.CloseTime1 && v.OpenTime2 == s2.OpenTime2 && v.CloseTime2 == s2.CloseTime2 { return 0 } else if v.OpenTime1 > s2.OpenTime1 || v.CloseTime1 < s2.CloseTime2 { return -1 } return 1 }