- 平台门店调价价格包实现初始版本
This commit is contained in:
@@ -183,7 +183,6 @@ func GetStoreMapByStoreID(db *DaoDB, storeID, vendorID int) (storeMap *model.Sto
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
storeMap.PricePercentagePackObj = PricePercentagePack2Obj(storeMap.PricePercentagePack)
|
||||
return storeMap, nil
|
||||
}
|
||||
|
||||
|
||||
38
business/model/dao/new_config.go
Normal file
38
business/model/dao/new_config.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
func QueryConfigs(db *DaoDB, key, configType, keyword string) (configList []*model.NewConfig, err error) {
|
||||
sql := `
|
||||
SELECT
|
||||
t1.*
|
||||
FROM new_config t1
|
||||
WHERE t1.deleted_at = ?`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if key != "" {
|
||||
sql += " AND t1.key = ?"
|
||||
sqlParams = append(sqlParams, key)
|
||||
}
|
||||
if configType != "" {
|
||||
sql += " AND t1.type = ?"
|
||||
sqlParams = append(sqlParams, configType)
|
||||
}
|
||||
if keyword != "" {
|
||||
keywordLike := "%" + keyword + "%"
|
||||
sql += " AND (t1.type LIKE ? OR t1.key LIKE ? OR value LIKE ?)"
|
||||
sqlParams = append(sqlParams, keywordLike, keywordLike, keywordLike)
|
||||
}
|
||||
|
||||
err = GetRows(db, &configList, sql, sqlParams...)
|
||||
if err == nil && len(configList) == 0 {
|
||||
err = fmt.Errorf("条件:key:%s,type:%s,keyword:%s不能找到配置", key, configType, keyword)
|
||||
}
|
||||
return configList, err
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
20
business/model/new_config.go
Normal file
20
business/model/new_config.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package model
|
||||
|
||||
const (
|
||||
ConfigTypeSys = "Sys"
|
||||
ConfigTypePricePack = "PricePack"
|
||||
)
|
||||
|
||||
type NewConfig struct {
|
||||
ModelIDCULD
|
||||
|
||||
Type string `orm:"size(16)" json:"type"`
|
||||
Key string `orm:"size(32)" json:"key"`
|
||||
Value string `orm:"size(4096)" json:"value"`
|
||||
}
|
||||
|
||||
func (*NewConfig) TableUnique() [][]string {
|
||||
return [][]string{
|
||||
[]string{"Key", "Type", "DeletedAt"},
|
||||
}
|
||||
}
|
||||
@@ -227,9 +227,8 @@ type StoreMap struct {
|
||||
VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"`
|
||||
Status int `json:"status"` // 取值同Store.Status
|
||||
|
||||
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
|
||||
PricePercentagePack string `orm:"size(4096)" json:"pricePercentagePack"` //
|
||||
PricePercentagePackObj PricePercentagePack `orm:"-" json:"-"`
|
||||
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
|
||||
PricePercentagePack string `orm:"size(32)" json:"pricePercentagePack"` //
|
||||
|
||||
AutoPickup int8 `orm:"default(1)" json:"autoPickup"` // 是否自动拣货
|
||||
DeliveryType int8 `orm:"default(0)" json:"deliveryType"` // 配送类型
|
||||
|
||||
Reference in New Issue
Block a user