diff --git a/business/jxstore/cms/cms.go b/business/jxstore/cms/cms.go index 68258f6cb..506e8ee62 100644 --- a/business/jxstore/cms/cms.go +++ b/business/jxstore/cms/cms.go @@ -2,6 +2,7 @@ package cms import ( "fmt" + "reflect" "strconv" "strings" "time" @@ -31,6 +32,13 @@ const ( SendMsgTypeSuggestRequest = "suggestRequest" ) +type SysConfigLimit struct { + ValueType reflect.Kind + MinValue int64 + MaxValue int64 + AfterChanged func() error +} + var ( serviceInfo map[string]interface{} allowUpdatePlaceFieldsMap = map[string]bool{ @@ -54,6 +62,36 @@ var ( needConfirmRequestMap = map[string]int{ SendMsgTypeOpenStoreRequest: 1, } + + SysConfigLimitMap = map[string]*SysConfigLimit{ + model.ConfigSysEbaiBoxFee: &SysConfigLimit{ + ValueType: reflect.Int, + MinValue: 0, + MaxValue: 500, + AfterChanged: func() (err error) { + _, err = dao.SetStoreMapSyncStatus(dao.GetDB(), []int{model.VendorIDEBAI}, nil, model.SyncFlagModifiedMask) + return err + }, + }, + model.ConfigSysMtwmBoxFee: &SysConfigLimit{ + ValueType: reflect.Int, + MinValue: 0, + MaxValue: 500, + AfterChanged: func() (err error) { + _, err = dao.SetStoreMapSyncStatus(dao.GetDB(), []int{model.VendorIDMTWM}, nil, model.SyncFlagModifiedMask) + return err + }, + }, + model.ConfigSysMtwmSkuBoxFee: &SysConfigLimit{ + ValueType: reflect.Int, + MinValue: 0, + MaxValue: 50, + AfterChanged: func() (err error) { + _, err = dao.SetStoreSkuSyncStatus(dao.GetDB(), model.VendorIDMTWM, nil, nil, model.SyncFlagModifiedMask) + return err + }, + }, + } ) func InitServiceInfo(version string, buildTime time.Time, gitCommit string) { @@ -193,6 +231,27 @@ func SendMsg2Somebody(ctx *jxcontext.Context, mobileNum, verifyCode, msgType, ms return err } +func checkSysConfig(key, value string) (err error) { + if limit := SysConfigLimitMap[key]; limit != nil { + if limit.ValueType == reflect.Int { + int64Value, err2 := strconv.ParseInt(value, 10, 64) + if err = err2; err == nil { + if int64Value < limit.MinValue || int64Value > limit.MaxValue { + err = fmt.Errorf("配置%s,值%s超范围[%d,%d]", key, value, limit.MinValue, limit.MaxValue) + } + } + } + } + return err +} + +func onSysConfigChanged(key, value string) (err error) { + if limit := SysConfigLimitMap[key]; limit != nil && limit.AfterChanged != nil { + err = limit.AfterChanged() + } + return err +} + func checkConfig(opFlag int, configType, key, value string) (err error) { switch configType { case model.ConfigTypePricePack: @@ -228,8 +287,10 @@ func checkConfig(opFlag int, configType, key, value string) (err error) { } case model.ConfigTypeRole: case model.ConfigTypeSys: - if opFlag&(model.SyncFlagNewMask|model.SyncFlagDeletedMask) != 0 { - err = fmt.Errorf("系统参数只支持修改,不支持自由添加") + if opFlag&( /*model.SyncFlagNewMask|*/ model.SyncFlagDeletedMask) != 0 { + err = fmt.Errorf("系统参数只支持修改或添加,不支持删除") + } else { + err = checkSysConfig(key, value) } default: err = fmt.Errorf("当前只支持配置:%s, 传入的配置类型:%s", utils.Format4Output(model.ConfigTypeName, true), configType) @@ -249,7 +310,11 @@ func AddConfig(ctx *jxcontext.Context, key, configType, value string) (err error Value: value, } dao.WrapAddIDCULDEntity(conf, ctx.GetUserName()) - return dao.CreateEntity(db, conf) + err = dao.CreateEntity(db, conf) + if configType == model.ConfigTypeSys && err == nil { + err = onSysConfigChanged(key, value) + } + return err } func DeleteConfig(ctx *jxcontext.Context, key, configType string) (err error) { @@ -314,6 +379,9 @@ func DeleteConfig(ctx *jxcontext.Context, key, configType string) (err error) { "Type": configType, }) } + if configType == model.ConfigTypeSys && err == nil { + err = onSysConfigChanged(key, "") + } return err } @@ -393,6 +461,9 @@ func UpdateConfig(ctx *jxcontext.Context, key, configType, value string) (hint s default: dao.Commit(db) } + if configType == model.ConfigTypeSys && err == nil { + err = onSysConfigChanged(key, value) + } return hint, err } diff --git a/business/jxstore/cms/sync.go b/business/jxstore/cms/sync.go index e94a43141..98991ff67 100644 --- a/business/jxstore/cms/sync.go +++ b/business/jxstore/cms/sync.go @@ -185,15 +185,10 @@ func (v *VendorSync) SyncReorderCategories(ctx *jxcontext.Context, db *dao.DaoDB // return "", err // } -func (v *VendorSync) SyncStore(ctx *jxcontext.Context, db *dao.DaoDB, vendorID, storeID int, isAsync bool, userName string) (hint string, err error) { - globals.SugarLogger.Debugf("SyncStore, storeID:%d", storeID) - var vendorIDs []int - if vendorID != -1 { - vendorIDs = []int{ - vendorID, - } - } - hint, err = v.LoopStoresMap(ctx, db, fmt.Sprintf("同步门店信息:%d", storeID), isAsync, false, vendorIDs, []int{storeID}, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (resultList interface{}, err error) { +func (v *VendorSync) SyncStore2(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs, storeIDs []int, mustDirty, isAsync bool) (hint string, err error) { + globals.SugarLogger.Debugf("SyncStore2, storeIDs:%d", storeIDs) + userName := ctx.GetUserName() + _, hint, err = v.LoopStoresMap2(ctx, db, fmt.Sprintf("同步门店信息:%v", storeIDs), isAsync, false, vendorIDs, storeIDs, mustDirty, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (resultList interface{}, err error) { loopMapInfo := batchItemList[0].(*LoopStoreMapInfo) handler := v.GetStoreHandler(loopMapInfo.VendorID) if handler != nil { @@ -232,6 +227,16 @@ func (v *VendorSync) SyncStore(ctx *jxcontext.Context, db *dao.DaoDB, vendorID, return hint, makeSyncError(err) } +func (v *VendorSync) SyncStore(ctx *jxcontext.Context, db *dao.DaoDB, vendorID, storeID int, isAsync bool, userName string) (hint string, err error) { + var vendorIDs []int + if vendorID != -1 { + vendorIDs = []int{ + vendorID, + } + } + return v.SyncStore2(ctx, db, vendorIDs, []int{storeID}, false, isAsync) +} + func (v *VendorSync) SyncSku(ctx *jxcontext.Context, db *dao.DaoDB, nameID, skuID int, isAsync, isContinueWhenError bool, userName string) (hint string, err error) { var ( nameIDs []int @@ -384,7 +389,7 @@ func (v *VendorSync) SyncStoresCategory(ctx *jxcontext.Context, db *dao.DaoDB, v func (v *VendorSync) SyncStoresSkus2(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, syncDisabled bool, skuIDs, excludeSkuIDs []int, setSyncStatus int, isAsync, isContinueWhenError bool) (hint string, err error) { globals.SugarLogger.Debug("SyncStoresSkus2") isManageIt := len(storeIDs) != 1 || len(skuIDs) == 0 || len(skuIDs) > 8 - task, hint, err := v.LoopStoresMap2(ctx, db, fmt.Sprintf("同步门店商品信息:%v", storeIDs), isAsync, isManageIt, vendorIDs, storeIDs, + task, hint, err := v.LoopStoresMap2(ctx, db, fmt.Sprintf("同步门店商品信息:%v", storeIDs), isAsync, isManageIt, vendorIDs, storeIDs, false, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) { loopMapInfo := batchItemList[0].(*LoopStoreMapInfo) if handler := v.GetStoreHandler(loopMapInfo.VendorID); handler != nil { @@ -561,9 +566,9 @@ func (v *VendorSync) AmendAndPruneStoreStuff(ctx *jxcontext.Context, vendorIDs [ return hint, makeSyncError(err) } -func (v *VendorSync) LoopStoresMap2(ctx *jxcontext.Context, db *dao.DaoDB, taskName string, isAsync, isManageIt bool, vendorIDs []int, storeIDs []int, handler tasksch.WorkFunc, isContinueWhenError bool) (task tasksch.ITask, hint string, err error) { +func (v *VendorSync) LoopStoresMap2(ctx *jxcontext.Context, db *dao.DaoDB, taskName string, isAsync, isManageIt bool, vendorIDs []int, storeIDs []int, mustDirty bool, handler tasksch.WorkFunc, isContinueWhenError bool) (task tasksch.ITask, hint string, err error) { var storeMapList []*model.StoreMap - if storeMapList, err = dao.GetStoresMapList(db, vendorIDs, storeIDs, model.StoreStatusAll, model.StoreIsSyncYes, ""); err != nil { + if storeMapList, err = dao.GetStoresMapList2(db, vendorIDs, storeIDs, model.StoreStatusAll, model.StoreIsSyncYes, "", mustDirty); err != nil { return nil, "", err } if len(storeMapList) == 0 { @@ -585,7 +590,6 @@ func (v *VendorSync) LoopStoresMap2(ctx *jxcontext.Context, db *dao.DaoDB, taskN if len(loopInfoList) == 1 { taskName = fmt.Sprintf("%s,处理平台%s", taskName, model.VendorChineseNames[loopInfoList[0].VendorID]) } - // globals.SugarLogger.Debugf("LoopStoresMap2 loopInfoList:%s", utils.Format4Output(loopInfoList, false)) task = tasksch.NewParallelTask(taskName, tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx, handler, loopInfoList) tasksch.HandleTask(task, nil, isManageIt).Run() if !isAsync { @@ -604,7 +608,7 @@ func (v *VendorSync) LoopStoresMap2(ctx *jxcontext.Context, db *dao.DaoDB, taskN } func (v *VendorSync) LoopStoresMap(ctx *jxcontext.Context, db *dao.DaoDB, taskName string, isAsync, isManageIt bool, vendorIDs []int, storeIDs []int, handler tasksch.WorkFunc, isContinueWhenError bool) (hint string, err error) { - _, hint, err = v.LoopStoresMap2(ctx, db, taskName, isAsync, isManageIt, vendorIDs, storeIDs, handler, isContinueWhenError) + _, hint, err = v.LoopStoresMap2(ctx, db, taskName, isAsync, isManageIt, vendorIDs, storeIDs, false, handler, isContinueWhenError) return hint, err } diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index f808d311f..9e88aa013 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -225,10 +225,23 @@ func calVendorPrice4StoreSku(inSku *dao.StoreSkuSyncInfo, pricePercentagePack mo return inSku } +func getSkuBoxFee(vendorID int) (boxFee int64) { + if vendorID == model.VendorIDMTWM { + boxFee, _ = dao.GetSysConfigAsInt64(dao.GetDB(), model.ConfigSysMtwmSkuBoxFee) + } + return boxFee +} + func formalizeStoreSkuList(inSkuList []*dao.StoreSkuSyncInfo) []*dao.StoreSkuSyncInfo { - for _, skuItem := range inSkuList { - skuItem.MergedStatus = jxutils.MergeSkuStatus(skuItem.Status, skuItem.StoreSkuStatus) - skuItem.SkuName = jxutils.ComposeSkuNameSync(skuItem.Prefix, skuItem.Name, skuItem.Comment, skuItem.Unit, skuItem.SpecQuality, skuItem.SpecUnit, 0, skuItem.ExPrefix, skuItem.ExPrefixBegin, skuItem.ExPrefixEnd) + if len(inSkuList) > 0 { + boxFee := getSkuBoxFee(inSkuList[0].VendorID) + for _, skuItem := range inSkuList { + if skuItem.VendorPrice > skuItem.BoxFee { + skuItem.BoxFee = boxFee + } + skuItem.MergedStatus = jxutils.MergeSkuStatus(skuItem.Status, skuItem.StoreSkuStatus) + skuItem.SkuName = jxutils.ComposeSkuNameSync(skuItem.Prefix, skuItem.Name, skuItem.Comment, skuItem.Unit, skuItem.SpecQuality, skuItem.SpecUnit, 0, skuItem.ExPrefix, skuItem.ExPrefixBegin, skuItem.ExPrefixEnd) + } } return inSkuList } diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 8f1b302cf..769bed0d4 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -208,6 +208,8 @@ func doDailyWork() { cms.SyncStoresCourierInfo(jxcontext.AdminCtx, nil, false, true) netprinter.RebindAllPrinters(jxcontext.AdminCtx, false, true) + cms.CurVendorSync.SyncStore2(jxcontext.AdminCtx, dao.GetDB(), nil, nil, true, true) + syncStoreSku() InitEx() diff --git a/business/model/dao/new_config.go b/business/model/dao/new_config.go index 36ccb70ec..60261137f 100644 --- a/business/model/dao/new_config.go +++ b/business/model/dao/new_config.go @@ -49,3 +49,13 @@ func ValidateRoles(db *DaoDB, roles ...string) (err error) { } return errList.GetErrListAsOne() } + +func GetSysConfigAsInt64(db *DaoDB, key string) (value int64, err error) { + configList, err := QueryConfigs(db, key, model.ConfigTypeSys, "") + if err == nil && len(configList) > 0 { + value = utils.Str2Int64WithDefault(configList[0].Value, 0) + } else if IsNoRowsError(err) { + err = nil + } + return value, err +} diff --git a/business/model/dao/store.go b/business/model/dao/store.go index 3fca98344..dd1f14c98 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -6,6 +6,7 @@ import ( "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/model" + "git.rosy.net.cn/jx-callback/globals" ) // 带购物平台信息的 @@ -26,7 +27,6 @@ type StoreDetail struct { FreightDeductionPackStr string `orm:"size(4096)" json:"-"` // FreightDeductionPackObj *model.FreightDeductionPack `orm:"-" json:"-"` - BoxFee int `orm:"default(1)" json:"boxFee"` // 打包费 AutoPickup int8 `orm:"default(1)" json:"autoPickup"` // 是否自动拣货 DeliveryType int8 `orm:"default(0)" json:"deliveryType"` // 配送类型 @@ -85,7 +85,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.vendor_org_code, - t2.price_percentage, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync, t2.vendor_store_name, t2.box_fee, + t2.price_percentage, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync, t2.vendor_store_name, t3.value price_percentage_pack_str, t4.value freight_deduction_pack_str, district.name district_name, @@ -211,7 +211,7 @@ func GetStoreCourierList(db *DaoDB, storeIDs []int, status, auditStatus int) (co return nil, err } -func GetStoresMapList(db *DaoDB, vendorIDs, storeIDs []int, status, isSync int, pricePack string) (storeMapList []*model.StoreMap, err error) { +func GetStoresMapList2(db *DaoDB, vendorIDs, storeIDs []int, status, isSync int, pricePack string, mustDirty bool) (storeMapList []*model.StoreMap, err error) { sql := ` SELECT t1.* FROM store_map t1 @@ -242,6 +242,10 @@ func GetStoresMapList(db *DaoDB, vendorIDs, storeIDs []int, status, isSync int, sql += " AND t1.price_percentage_pack = ?" sqlParams = append(sqlParams, pricePack) } + if mustDirty { + sql += " AND t1.sync_status <> 0" + sqlParams = append(sqlParams, pricePack) + } sql += " ORDER BY t1.store_id DESC, t1.vendor_id" if err = GetRows(db, &storeMapList, sql, sqlParams...); err == nil { return storeMapList, nil @@ -249,6 +253,10 @@ func GetStoresMapList(db *DaoDB, vendorIDs, storeIDs []int, status, isSync int, return nil, err } +func GetStoresMapList(db *DaoDB, vendorIDs, storeIDs []int, status, isSync int, pricePack string) (storeMapList []*model.StoreMap, err error) { + return GetStoresMapList2(db, vendorIDs, storeIDs, status, isSync, pricePack, false) +} + // 此函数在检测到一个门店的所有平台状态一样,且不为StoreStatusOpened时, // 将平台门店状态全部改为StoreStatusOpened,则把京西门店状态改为之前那个统一的平台门店状态 func FormalizeStoreStatus(db *DaoDB, storeID, storeStatus int) (err error) { @@ -580,3 +588,26 @@ func GetStorePriceScoreSnapshot(db *DaoDB, snapDate time.Time) (storePriceScoreS err = GetRows(db, &storePriceScoreSnapshot, sql, sqlParams...) return storePriceScoreSnapshot, err } + +func SetStoreMapSyncStatus(db *DaoDB, vendorIDs, storeIDs []int, syncStatus int) (num int64, err error) { + globals.SugarLogger.Debugf("SetStoreMapSyncStatus, vendorIDs:%v, storeIDs:%v", vendorIDs, storeIDs) + + sql := ` + UPDATE store_map t1 + SET t1.sync_status = t1.sync_status | ? + ` + sqlParams := []interface{}{ + syncStatus, + } + sql += " WHERE t1.is_sync <> 0 AND t1.deleted_at = ? AND t1.sync_status & ? = 0" + sqlParams = append(sqlParams, utils.DefaultTimeValue, model.SyncFlagDeletedMask) + if len(vendorIDs) > 0 { + sql += " AND t1.vendor_id IN (" + GenQuestionMarks(len(vendorIDs)) + ")" + sqlParams = append(sqlParams, vendorIDs) + } + if len(storeIDs) > 0 { + sql += " AND t1.store_id IN (" + GenQuestionMarks(len(storeIDs)) + ")" + sqlParams = append(sqlParams, storeIDs) + } + return ExecuteSQL(db, sql, sqlParams...) +} diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index 07e10f364..78fa7de6b 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -45,6 +45,8 @@ type StoreSkuSyncInfo struct { StoreID int `orm:"column(store_id)"` SkuID int `orm:"column(sku_id)"` // 这个与Sku.ID的区别是SkuID是必然存在的 + BoxFee int64 + Price int64 UnitPrice int64 diff --git a/business/model/new_config.go b/business/model/new_config.go index bf0b26cea..a3805bac0 100644 --- a/business/model/new_config.go +++ b/business/model/new_config.go @@ -10,6 +10,9 @@ const ( const ( ConfigSysFakeOrderMobiles = "FakeOrderMobiles" // 假订单手机 + ConfigSysEbaiBoxFee = "EbaiBoxFee" // 饿百打包费 + ConfigSysMtwmBoxFee = "MtwmBoxFee" // 美团外卖打包费 + ConfigSysMtwmSkuBoxFee = "MtwmSkuBoxFee" // 美团外卖单商品打包费 ) var ( diff --git a/business/model/store.go b/business/model/store.go index 5b4429ed2..553f564b9 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -398,8 +398,6 @@ type StoreMap struct { FreightDeductionPack string `orm:"size(32)" json:"freightDeductionPack"` // - BoxFee int `orm:"default(0)" json:"boxFee"` // 打包费 - AutoPickup int8 `orm:"default(1)" json:"autoPickup"` // 是否自动拣货 DeliveryType int8 `orm:"default(0)" json:"deliveryType"` // 配送类型 DeliveryFee int `json:"deliveryFee"` diff --git a/business/partner/purchase/ebai/order.go b/business/partner/purchase/ebai/order.go index 7f13d3ec8..2efea8782 100644 --- a/business/partner/purchase/ebai/order.go +++ b/business/partner/purchase/ebai/order.go @@ -88,11 +88,18 @@ func (p *PurchaseHandler) GetOrderStatus(vendorOrgCode, vendorOrderID string) (s } func (p *PurchaseHandler) getOrder(vendorOrderID string) (order *model.GoodsOrder, orderMap map[string]interface{}, err error) { - result, err := api.EbaiAPI.OrderGet(vendorOrderID) - if err == nil { - order = p.Map2Order(result) + for i := 0; i < 2; i++ { + orderMap, err = api.EbaiAPI.OrderGet(vendorOrderID) + if err == nil { + order = p.Map2Order(orderMap) + // 饿百订单有时会出现取不到baidu_shop_id的情况,重试 + if order.VendorStoreID != "" { + break + } + } + time.Sleep(100 * time.Millisecond) } - return order, result, err + return order, orderMap, err } func (p *PurchaseHandler) GetOrder4PartRefund(vendorOrderID string) (order *model.GoodsOrder, err error) { @@ -187,15 +194,15 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo vendorOrderID := orderMap["order_id"].(string) order = &model.GoodsOrder{ VendorOrderID: vendorOrderID, - VendorOrderID2: orderMap["eleme_order_id"].(string), + VendorOrderID2: utils.Interface2String(orderMap["eleme_order_id"]), VendorID: model.VendorIDEBAI, - VendorStoreID: shopMap["baidu_shop_id"].(string), + VendorStoreID: utils.Interface2String(shopMap["baidu_shop_id"]), StoreID: int(utils.Str2Int64WithDefault(utils.Interface2String(shopMap["id"]), 0)), - StoreName: shopMap["name"].(string), + StoreName: utils.Interface2String(shopMap["name"]), VendorUserID: utils.Interface2String(userMap["user_id"]), - ConsigneeName: userMap["name"].(string), - ConsigneeMobile: jxutils.FormalizeMobile(userMap["phone"].(string)), - ConsigneeAddress: userMap["address"].(string), + ConsigneeName: utils.Interface2String(userMap["name"]), + ConsigneeMobile: jxutils.FormalizeMobile(utils.Interface2String(userMap["phone"])), + ConsigneeAddress: utils.Interface2String(userMap["address"]), CoordinateType: model.CoordinateTypeBaiDu, BuyerComment: utils.TrimBlankChar(utils.Interface2String(orderMap["remark"])), ExpectedDeliveredTime: getTimeFromInterface(orderMap["send_time"]), @@ -453,6 +460,10 @@ func (c *PurchaseHandler) onOrderNew(msg *ebaiapi.CallbackMsg, orderStatus *mode vendorOrderID := GetOrderIDFromMsg(msg) order, orderMap, err := c.getOrder(vendorOrderID) if err == nil { + // 饿百订单有时会出现取不到baidu_shop_id的情况,返回错误让服务器重试 + if order.VendorStoreID == "" { + return api.EbaiAPI.Err2CallbackResponse(msg.Cmd, fmt.Errorf("订单%s的baidu_shop_id为空", order.VendorOrderID), "") + } if err = partner.CurOrderManager.OnOrderNew(order, orderStatus); err == nil { utils.CallFuncAsync(func() { c.OnOrderDetail(orderMap, partner.CreatedPeration) diff --git a/business/partner/purchase/ebai/store.go b/business/partner/purchase/ebai/store.go index 3d36ed191..808c8b8ad 100644 --- a/business/partner/purchase/ebai/store.go +++ b/business/partner/purchase/ebai/store.go @@ -400,6 +400,9 @@ func genStoreMapFromStore(store *tEbaiStoreInfo) map[string]interface{} { params["name"] = jxutils.ComposeStoreName(store.Name, model.VendorIDEBAI) } } + // boxFee, _ := dao.GetSysConfigAsInt64(dao.GetDB(), model.ConfigSysEbaiBoxFee) + // params["package_box_price"] = boxFee + params["address"] = store.Address // todo 饿百 开店审核通过后不允许修改商户信息 if store.SyncStatus&(model.SyncFlagNewMask /*|model.SyncFlagStoreAddress*/) != 0 { diff --git a/business/partner/purchase/mtwm/store.go b/business/partner/purchase/mtwm/store.go index 75d35c49b..de23fa33d 100644 --- a/business/partner/purchase/mtwm/store.go +++ b/business/partner/purchase/mtwm/store.go @@ -156,7 +156,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin errList.AddErr(p.UpdateStoreStatus(jxcontext.AdminCtx, storeDetail.VendorOrgCode, storeID, storeDetail.VendorStoreID, mergedStoreStatus)) } errList.AddErr(p.UpdateStoreOpTime(jxcontext.AdminCtx, storeDetail.VendorOrgCode, storeID, storeDetail.VendorStoreID, storeDetail.GetOpTimeList())) - errList.AddErr(p.UpdateStoreBoxFee(jxcontext.AdminCtx, storeDetail.VendorOrgCode, storeID, storeDetail.VendorStoreID, storeDetail.BoxFee)) + errList.AddErr(p.UpdateStoreBoxFee(jxcontext.AdminCtx, storeDetail.VendorOrgCode, storeID, storeDetail.VendorStoreID)) return errList.GetErrListAsOne() } @@ -292,7 +292,10 @@ func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorOrgC return err } -func (c *PurchaseHandler) UpdateStoreBoxFee(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, boxFee int) (err error) { - err = api.MtwmAPI.PackagePriceUpdate(vendorStoreID, 1, boxFee) +func (c *PurchaseHandler) UpdateStoreBoxFee(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string) (err error) { + // boxFee, err := dao.GetSysConfigAsInt64(dao.GetDB(), model.ConfigSysMtwmBoxFee) + // if err == nil { + // err = api.MtwmAPI.PackagePriceUpdate(vendorStoreID, 1, int(boxFee)) + // } return err } diff --git a/business/partner/purchase/mtwm/store_sku2.go b/business/partner/purchase/mtwm/store_sku2.go index 6266bbbcd..ec63fe9ae 100644 --- a/business/partner/purchase/mtwm/store_sku2.go +++ b/business/partner/purchase/mtwm/store_sku2.go @@ -28,7 +28,6 @@ const ( specialStoreID = "8171010" // specialStoreID = "2523687" - fixBoxFee = 10 ) var ( @@ -254,7 +253,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI foodData["min_order_count"] = 1 foodData["unit"] = storeSku.Unit foodData["box_num"] = 1 - foodData["box_price"] = jxutils.IntPrice2Standard(fixBoxFee) + foodData["box_price"] = jxutils.IntPrice2Standard(storeSku.BoxFee) catCode := tryCatName2Code(storeSku.VendorCatID) if catCode != "" { foodData["category_code"] = catCode diff --git a/controllers/cms_sync.go b/controllers/cms_sync.go index 238f4e07a..926c3537f 100644 --- a/controllers/cms_sync.go +++ b/controllers/cms_sync.go @@ -144,6 +144,33 @@ func (c *SyncController) DeleteRemoteStoreSkus() { }) } +// @Title 同步门店 +// @Description 同步门店 +// @Param token header string true "认证token" +// @Param vendorIDs formData string false "平台ID(京东0 美团1 饿百3)列表" +// @Param vendorOrgCodes formData string false "平台账号列表" +// @Param storeIDs formData string false "门店ID列表" +// @Param isForce formData bool false "是否强制(设置修改标志)" +// @Param isAsync formData bool false "是否异步" +// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /SyncStores [post] +func (c *SyncController) SyncStores() { + c.callSyncStores(func(params *tSyncSyncStoresParams) (retVal interface{}, errCode string, err error) { + var vendorIDs, storeIDs []int + var vendorOrgCodes []string + if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDs, params.StoreIDs, &storeIDs, params.VendorOrgCodes, &vendorOrgCodes); err == nil { + db := dao.GetDB() + if params.IsForce { + dao.SetStoreMapSyncStatus(db, vendorIDs, storeIDs, model.SyncFlagModifiedMask) + } + retVal, err = cms.CurVendorSync.SyncStore2(params.Ctx, db, vendorIDs, storeIDs, true, params.IsAsync) + } + return retVal, "", err + }) +} + // @Title 同步商家分类(多门店平台) // @Description 同步商家分类(多门店平台) // @Param token header string true "认证token" diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index aebca060f..ba4e36796 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -1944,6 +1944,15 @@ func init() { Filters: nil, Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SyncController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SyncController"], + beego.ControllerComments{ + Method: "SyncStores", + Router: `/SyncStores`, + AllowHTTPMethods: []string{"post"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SyncController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SyncController"], beego.ControllerComments{ Method: "SyncStoresCategory",