添加平台门店免运配置,当前只有京东实现了
This commit is contained in:
@@ -23,6 +23,9 @@ type StoreDetail struct {
|
||||
PricePercentagePackStr string `orm:"size(4096)" json:"-"` //
|
||||
PricePercentagePackObj model.PricePercentagePack `orm:"-" json:"-"`
|
||||
|
||||
FreightDeductionPackStr string `orm:"size(4096)" json:"-"` //
|
||||
FreightDeductionPackObj *model.FreightDeductionPack `orm:"-" json:"-"`
|
||||
|
||||
AutoPickup int8 `orm:"default(1)" json:"autoPickup"` // 是否自动拣货
|
||||
DeliveryType int8 `orm:"default(0)" json:"deliveryType"` // 配送类型
|
||||
DeliveryCompetition int8 `orm:"default(1)" json:"deliveryCompetition"` // 是否支持配送竞争
|
||||
@@ -61,7 +64,9 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto
|
||||
sql := `
|
||||
SELECT t1.*,
|
||||
t2.vendor_store_id, t2.status vendor_status, t2.delivery_fee, t2.sync_status,
|
||||
t2.price_percentage, t3.value price_percentage_pack_str, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync,
|
||||
t2.price_percentage, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync,
|
||||
t3.value price_percentage_pack_str,
|
||||
t4.value freight_deduction_pack_str,
|
||||
district.name district_name,
|
||||
city.name city_name
|
||||
FROM store t1
|
||||
@@ -69,6 +74,7 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto
|
||||
LEFT JOIN place city ON city.code = t1.city_code
|
||||
LEFT JOIN place district ON district.code = t1.district_code
|
||||
LEFT JOIN new_config t3 ON t3.key = t2.price_percentage_pack AND t3.type = ? AND t3.deleted_at = ?
|
||||
LEFT JOIN new_config t4 ON t4.key = t2.freight_deduction_pack AND t4.type = ? AND t4.deleted_at = ?
|
||||
WHERE t1.deleted_at = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
@@ -76,6 +82,8 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto
|
||||
utils.DefaultTimeValue,
|
||||
model.ConfigTypePricePack,
|
||||
utils.DefaultTimeValue,
|
||||
model.ConfigTypeFreightPack,
|
||||
utils.DefaultTimeValue,
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if vendorID != model.VendorIDJX {
|
||||
@@ -92,6 +100,7 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto
|
||||
storeDetail = &StoreDetail{}
|
||||
if err = GetRow(db, storeDetail, sql, sqlParams...); err == nil {
|
||||
storeDetail.PricePercentagePackObj = PricePercentagePack2Obj(storeDetail.PricePercentagePackStr)
|
||||
storeDetail.FreightDeductionPackObj = FreightDeductionPack2Obj(storeDetail.FreightDeductionPackStr)
|
||||
return storeDetail, nil
|
||||
}
|
||||
return nil, err
|
||||
@@ -517,3 +526,12 @@ func GetCityBankBranches(db *DaoDB, cityCode int, bankCode string) (list []*City
|
||||
err = GetRows(db, &list, sql, sqlParams...)
|
||||
return list, err
|
||||
}
|
||||
|
||||
func FreightDeductionPack2Obj(packStr string) (obj *model.FreightDeductionPack) {
|
||||
if packStr != "" {
|
||||
if err := utils.UnmarshalUseNumber([]byte(packStr), &obj); err == nil {
|
||||
sort.Sort(obj)
|
||||
}
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package model
|
||||
|
||||
const (
|
||||
ConfigTypeSys = "Sys"
|
||||
ConfigTypePricePack = "PricePack"
|
||||
ConfigTypeBank = "Bank"
|
||||
ConfigTypeRole = "Role"
|
||||
ConfigTypeSys = "Sys"
|
||||
ConfigTypePricePack = "PricePack"
|
||||
ConfigTypeFreightPack = "FreightPack"
|
||||
ConfigTypeBank = "Bank"
|
||||
ConfigTypeRole = "Role"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -13,10 +14,11 @@ const (
|
||||
|
||||
var (
|
||||
ConfigTypeName = map[string]string{
|
||||
ConfigTypeSys: "系统",
|
||||
ConfigTypePricePack: "价格包",
|
||||
ConfigTypeBank: "银行",
|
||||
ConfigTypeRole: "角色",
|
||||
ConfigTypeSys: "系统",
|
||||
ConfigTypePricePack: "价格包",
|
||||
ConfigTypeFreightPack: "免运包",
|
||||
ConfigTypeBank: "银行",
|
||||
ConfigTypeRole: "角色",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -366,6 +366,8 @@ type StoreMap struct {
|
||||
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
|
||||
PricePercentagePack string `orm:"size(32)" json:"pricePercentagePack"` //
|
||||
|
||||
FreightDeductionPack string `orm:"size(32)" json:"freightDeductionPack"` //
|
||||
|
||||
AutoPickup int8 `orm:"default(1)" json:"autoPickup"` // 是否自动拣货
|
||||
DeliveryType int8 `orm:"default(0)" json:"deliveryType"` // 配送类型
|
||||
DeliveryFee int `json:"deliveryFee"`
|
||||
@@ -454,7 +456,7 @@ func (v *VendorStoreSnapshot) CompareOperationTime(s2 *VendorStoreSnapshot) int
|
||||
}
|
||||
|
||||
type PricePercentageItem struct {
|
||||
BeginPrice int `json:"beginPrice"` // 启始价格区间(包括)
|
||||
BeginPrice int `json:"beginPrice"` // 起始价格区间(包括)
|
||||
PricePercentage int `json:"pricePercentage"` // 调价比例
|
||||
}
|
||||
|
||||
@@ -476,3 +478,31 @@ func (l PricePercentagePack) Swap(i, j int) {
|
||||
l[i] = l[j]
|
||||
l[j] = tmp
|
||||
}
|
||||
|
||||
type FreightDeductionItem struct {
|
||||
BeginPrice int `json:"beginPrice"` // 起始价格区间(包括)
|
||||
DeductFreight int `json:"deductFreight"` // 减免运费
|
||||
}
|
||||
|
||||
type FreightDeductionPack struct {
|
||||
StartPrice int `json:"startPrice"` // 起送价
|
||||
FreightDeductionList []*FreightDeductionItem `json:"freightDeductionList"`
|
||||
}
|
||||
|
||||
func (l *FreightDeductionPack) Len() int {
|
||||
return len(l.FreightDeductionList)
|
||||
}
|
||||
|
||||
// Less reports whether the element with
|
||||
// index i should sort before the element with index j.
|
||||
func (l *FreightDeductionPack) Less(i, j int) bool {
|
||||
return l.FreightDeductionList[i].BeginPrice < l.FreightDeductionList[j].BeginPrice
|
||||
}
|
||||
|
||||
// Swap swaps the elements with indexes i and j.
|
||||
func (l *FreightDeductionPack) Swap(i, j int) {
|
||||
l2 := l.FreightDeductionList
|
||||
tmp := l2[i]
|
||||
l2[i] = l2[j]
|
||||
l2[j] = tmp
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user