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
|
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 对库存商品数组进行排序
|
// SortStockCommodities 对库存商品数组进行排序
|
||||||
func SortStockCommodities(commodities []ErpStock) {
|
func SortStockCommodities(commodities []ErpStock) {
|
||||||
// 定义排序函数
|
// 定义排序函数
|
||||||
|
|
|
@ -12,18 +12,19 @@ const (
|
||||||
type Coupon struct {
|
type Coupon struct {
|
||||||
Model
|
Model
|
||||||
|
|
||||||
Name string `json:"name"`
|
Name string `json:"name"` // 优惠券名称
|
||||||
Describe string `json:"describe" gorm:"type:text;"` // 描述
|
Describe string `json:"describe" gorm:"type:text"` // 优惠券简介
|
||||||
CouponType string `json:"coupon_type"`
|
Rule string `json:"rule" gorm:"type:text"` // 优惠券使用规则
|
||||||
ActivityType uint32 `json:"activity_type"` // 活动类型 1-会员续费
|
CouponType string `json:"coupon_type"` //
|
||||||
ActivityId uint32 `json:"activity_id" gorm:"index"`
|
ActivityType uint32 `json:"activity_type"` // 活动类型 1-会员续费
|
||||||
Value uint32 `json:"value"`
|
ActivityId uint32 `json:"activity_id" gorm:"index"` //
|
||||||
OutCount uint32 `json:"out_count"` // 用户已领取数量
|
Value uint32 `json:"value"` //
|
||||||
UsedCount uint32 `json:"used_count"` // 用户已使用数量
|
OutCount uint32 `json:"out_count"` // 用户已领取数量
|
||||||
ActiveStart time.Time `json:"active_start"` // 有效期开始
|
UsedCount uint32 `json:"used_count"` // 用户已使用数量
|
||||||
ActiveEnd time.Time `json:"active_end"` // 有效期结束 零值永不结束
|
ActiveStart time.Time `json:"active_start"` // 有效期开始
|
||||||
MemberLevel uint32 `json:"member_level"` // 会员等级 1-用户 2-会员
|
ActiveEnd time.Time `json:"active_end"` // 有效期结束 零值永不结束
|
||||||
IsDraw bool `json:"is_draw" gorm:"-"`
|
MemberLevel uint32 `json:"member_level"` // 会员等级 1-用户 2-会员
|
||||||
|
IsDraw bool `json:"is_draw" gorm:"-"` //
|
||||||
}
|
}
|
||||||
|
|
||||||
// gen:qs
|
// gen:qs
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user