Compare commits
3 Commits
1212d9dd1e
...
b817b7fd40
Author | SHA1 | Date | |
---|---|---|---|
b817b7fd40 | |||
5ed025bb22 | |||
596fd1dc44 |
|
@ -521,6 +521,44 @@ func (m *ErpCommodityListReq) List() (*ErpCommodityListResp, error) {
|
|||
return resp, nil
|
||||
}
|
||||
|
||||
// SortByErpSupplierId 对商品数组进行排序,先按供应商ID排序,如果相同则按商品编号排序(升序)
|
||||
func SortByErpSupplierId(commodities []ErpCommodity, supplierIDDesc bool) {
|
||||
// 定义排序函数
|
||||
less := func(i, j int) bool {
|
||||
// 按照供应商ID排序
|
||||
if commodities[i].ErpSupplierId != commodities[j].ErpSupplierId {
|
||||
if supplierIDDesc { // 降序 DESC
|
||||
return commodities[i].ErpSupplierId > commodities[j].ErpSupplierId
|
||||
}
|
||||
return commodities[i].ErpSupplierId < commodities[j].ErpSupplierId // 升序 ASC
|
||||
}
|
||||
|
||||
// 解析商品编号,提取分类编号和商品编号的数字部分
|
||||
catNumI, subCatNumI, threeSubCatNumI, itemNumI := parseSerialNumber(commodities[i].SerialNumber)
|
||||
catNumJ, subCatNumJ, threeSubCatNumJ, itemNumJ := parseSerialNumber(commodities[j].SerialNumber)
|
||||
|
||||
// 按照分类编号从小到大排序
|
||||
if catNumI != catNumJ {
|
||||
return catNumI < catNumJ
|
||||
}
|
||||
|
||||
// 如果分类编号相同,按照具体分类下的商品编号递增排序
|
||||
if subCatNumI != subCatNumJ {
|
||||
return subCatNumI < subCatNumJ
|
||||
}
|
||||
|
||||
if threeSubCatNumI != threeSubCatNumJ {
|
||||
return threeSubCatNumI < threeSubCatNumJ
|
||||
}
|
||||
|
||||
// 如果具体分类编号也相同,按照商品编号递增排序
|
||||
return itemNumI < itemNumJ
|
||||
}
|
||||
|
||||
// 调用排序函数进行排序
|
||||
sort.SliceStable(commodities, less)
|
||||
}
|
||||
|
||||
// SortStockCommodities 对库存商品数组进行排序
|
||||
func SortStockCommodities(commodities []ErpStock) {
|
||||
// 定义排序函数
|
||||
|
|
|
@ -12,18 +12,19 @@ const (
|
|||
type Coupon struct {
|
||||
Model
|
||||
|
||||
Name string `json:"name"`
|
||||
Describe string `json:"describe" gorm:"type:text;"` // 描述
|
||||
CouponType string `json:"coupon_type"`
|
||||
ActivityType uint32 `json:"activity_type"` // 活动类型 1-会员续费
|
||||
ActivityId uint32 `json:"activity_id" gorm:"index"`
|
||||
Value uint32 `json:"value"`
|
||||
OutCount uint32 `json:"out_count"` // 用户已领取数量
|
||||
UsedCount uint32 `json:"used_count"` // 用户已使用数量
|
||||
ActiveStart time.Time `json:"active_start"` // 有效期开始
|
||||
ActiveEnd time.Time `json:"active_end"` // 有效期结束 零值永不结束
|
||||
MemberLevel uint32 `json:"member_level"` // 会员等级 1-用户 2-会员
|
||||
IsDraw bool `json:"is_draw" gorm:"-"`
|
||||
Name string `json:"name"` // 优惠券名称
|
||||
Describe string `json:"describe" gorm:"type:text"` // 优惠券简介
|
||||
Rule string `json:"rule" gorm:"type:text"` // 优惠券使用规则
|
||||
CouponType string `json:"coupon_type"` //
|
||||
ActivityType uint32 `json:"activity_type"` // 活动类型 1-会员续费
|
||||
ActivityId uint32 `json:"activity_id" gorm:"index"` //
|
||||
Value uint32 `json:"value"` //
|
||||
OutCount uint32 `json:"out_count"` // 用户已领取数量
|
||||
UsedCount uint32 `json:"used_count"` // 用户已使用数量
|
||||
ActiveStart time.Time `json:"active_start"` // 有效期开始
|
||||
ActiveEnd time.Time `json:"active_end"` // 有效期结束 零值永不结束
|
||||
MemberLevel uint32 `json:"member_level"` // 会员等级 1-用户 2-会员
|
||||
IsDraw bool `json:"is_draw" gorm:"-"` //
|
||||
}
|
||||
|
||||
// gen:qs
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user