添加平台门店免运配置,当前只有京东实现了

This commit is contained in:
gazebo
2019-10-14 14:41:40 +08:00
parent dd7eea1a02
commit 11526da5db
6 changed files with 146 additions and 20 deletions

View File

@@ -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
}