- 平台门店调价价格包实现初始版本

This commit is contained in:
gazebo
2019-07-16 11:36:28 +08:00
parent bdee4269d5
commit f133ccb290
13 changed files with 292 additions and 22 deletions

View File

@@ -16,8 +16,8 @@ type StoreDetail struct {
DeliveryFee int `json:"deliveryFee"`
SyncStatus int8 `orm:"default(2)" json:"syncStatus"`
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
PricePercentagePack string `orm:"size(4096)" json:"pricePercentagePack"` //
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
PricePercentagePackStr string `orm:"size(4096)" json:"-"` //
PricePercentagePackObj model.PricePercentagePack `orm:"-" json:"-"`
AutoPickup int8 `orm:"default(1)" json:"autoPickup"` // 是否自动拣货
@@ -47,7 +47,7 @@ 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, t2.price_percentage_pack, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync,
t2.price_percentage, t3.value price_percentage_pack_str, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync,
district.code, district.name district_name, district.parent_code, district.level, district.tel_code,
district.jd_code, district.ebai_code, district.enabled, district.mtps_price,
city.name city_name
@@ -55,12 +55,15 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto
JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND t2.deleted_at = ?
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 = ?
WHERE t1.deleted_at = ?
`
sqlParams := []interface{}{
vendorID,
utils.DefaultTimeValue,
utils.DefaultTimeValue,
model.ConfigTypePricePack,
utils.DefaultTimeValue,
}
if storeID > 0 {
sql += " AND t1.id = ?"
@@ -73,7 +76,7 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto
storeDetail = &StoreDetail{}
if err = GetRow(db, storeDetail, sql, sqlParams...); err == nil {
storeDetail.Place.Name = storeDetail.DistrictName
storeDetail.PricePercentagePackObj = PricePercentagePack2Obj(storeDetail.PricePercentagePack)
storeDetail.PricePercentagePackObj = PricePercentagePack2Obj(storeDetail.PricePercentagePackStr)
return storeDetail, nil
}
return nil, err
@@ -199,7 +202,7 @@ func GetStoreCourierList(db *DaoDB, storeID, status int) (courierStoreList []*mo
return nil, err
}
func GetStoresMapList(db *DaoDB, vendorIDs, storeIDs []int, status, isSync int) (storeMapList []*model.StoreMap, err error) {
func GetStoresMapList(db *DaoDB, vendorIDs, storeIDs []int, status, isSync int, pricePack string) (storeMapList []*model.StoreMap, err error) {
sql := `
SELECT t1.*
FROM store_map t1
@@ -224,11 +227,12 @@ func GetStoresMapList(db *DaoDB, vendorIDs, storeIDs []int, status, isSync int)
sql += " AND t1.is_sync = ?"
sqlParams = append(sqlParams, isSync)
}
if pricePack != "" {
sql += " AND t1.price_percentage_pack = ?"
sqlParams = append(sqlParams, pricePack)
}
sql += " ORDER BY t1.store_id, t1.vendor_id"
if err = GetRows(db, &storeMapList, sql, sqlParams...); err == nil {
for _, v := range storeMapList {
v.PricePercentagePackObj = PricePercentagePack2Obj(v.PricePercentagePack)
}
return storeMapList, nil
}
return nil, err
@@ -318,6 +322,11 @@ func GetRebindPrinterStoreList(db *DaoDB) (storeList []*model.Store, err error)
func PricePercentagePack2Obj(packStr string) (obj model.PricePercentagePack) {
if packStr != "" {
if err := utils.UnmarshalUseNumber([]byte(packStr), &obj); err == nil {
for _, v := range obj {
if v.PricePercentage >= 500 || v.PricePercentage <= 80 {
return nil
}
}
sort.Sort(obj)
}
}