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.
82 lines
2.8 KiB
82 lines
2.8 KiB
package model
|
|
|
|
import (
|
|
"pure-admin/global"
|
|
)
|
|
|
|
type SellerStore struct { // 店铺
|
|
StoreNo string `gorm:"unique;type:varchar(60);" json:"store_no"` // 店铺编号
|
|
Type int `gorm:"type:tinyint(1)" json:"type"` // 1:个人店铺
|
|
CreateBy string `gorm:"type:varchar(60);" json:"create_by"` // 创建人
|
|
Email string `gorm:"type:varchar(100);" json:"email"` // 店铺联系email(注册账号email)
|
|
global.MG_MODEL
|
|
Phone string `gorm:"type:varchar(60);" json:"phone"`
|
|
}
|
|
|
|
type SellerStoreInfo struct {
|
|
ID uint `gorm:"AUTO_INCREMENT;PRIMARY_KEY;" json:"id"` // 主键ID
|
|
StoreNo string `json:"store_no"` // 店铺编号
|
|
Type int `json:"type"` // 1:个人店铺
|
|
Email string `json:"email"` // 店铺联系email(注册账号email)
|
|
Phone string `json:"phone"`
|
|
ReleaseMissionNum int64 `gorm:"-" json:"release_mission_nums"` // 发布任务数
|
|
ValidMissionNum int64 `gorm:"-" json:"valid_mission_num"` // 有效任务数
|
|
GoodsNum int64 `gorm:"-" json:"goods_num"`
|
|
CreatedAt string `gorm:"created_at" json:"created_at"`
|
|
CreateBy string `gorm:"type:varchar(60);" json:"create_by"` // 创建人
|
|
}
|
|
|
|
type StoreInfo struct {
|
|
StoreNo string `json:"store_no"` // 店铺编号
|
|
Email string `json:"email"` // 联系方式
|
|
}
|
|
|
|
func (SellerStore) TableName() string {
|
|
return "seller_store"
|
|
}
|
|
|
|
func (SellerStoreInfo) TableName() string {
|
|
return "seller_store"
|
|
}
|
|
|
|
type Sum struct {
|
|
TotalCount int64 `gorm:"column:total_count" json:"total_count"`
|
|
CreateBy string `gorm:"column:create_by" json:"create_by"`
|
|
StoreNo string `gorm:"column:store_no" json:"store_no"`
|
|
}
|
|
|
|
func GetMissionCount(ids []string) (m map[string]int64, err error) {
|
|
result := make([]*Sum, 0)
|
|
m = make(map[string]int64)
|
|
err = global.MG_DB.Model(&Mission{}).Select("store_no,count(1) as total_count").Where("store_no in (?)", ids).
|
|
Group("store_no").Scan(&result).Error
|
|
for _, v := range result {
|
|
m[v.StoreNo] = v.TotalCount
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func GetGoodsCount(ids []string) (m map[string]int64, err error) {
|
|
result := make([]*Sum, 0)
|
|
m = make(map[string]int64)
|
|
err = global.MG_DB.Model(&TbGoods{}).Select("store_no,count(1) as total_count").Where("store_no in (?)", ids).
|
|
Group("store_no").Scan(&result).Error
|
|
for _, v := range result {
|
|
m[v.StoreNo] = v.TotalCount
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func GetBusinessEmail(ids []string) (m map[string]string, err error) {
|
|
result := make([]*StoreInfo, 0)
|
|
m = make(map[string]string)
|
|
err = global.MG_DB.Model(&SellerStore{}).Select("store_no,email").Where("store_no in (?)", ids).
|
|
Scan(&result).Error
|
|
for _, v := range result {
|
|
m[v.StoreNo] = v.Email
|
|
}
|
|
|
|
return
|
|
}
|
|
|