diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index d11e87be3..23e37331c 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -562,9 +562,9 @@ func getMapCenter(storeList []*StoreExt) (lng, lat float64) { return getMapCenter(newStoreList) } -func GetVendorStore(ctx *jxcontext.Context, vendorStoreID string, vendorID int) (retVal *StoreExt, err error) { +func GetVendorStore(ctx *jxcontext.Context, vendorID int, vendorOrgCode, vendorStoreID string) (retVal *StoreExt, err error) { if handler := CurVendorSync.GetStoreHandler(vendorID); handler != nil { - result, err2 := handler.ReadStore(ctx, vendorStoreID) + result, err2 := handler.ReadStore(ctx, vendorOrgCode, vendorStoreID) if err = err2; err == nil { retVal = &StoreExt{ Store: result.Store, @@ -961,7 +961,7 @@ func GetStoreVendorMaps(ctx *jxcontext.Context, db *dao.DaoDB, storeID int, vend } // todo 需要对字段做有效性检查 -func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID int, storeMap *model.StoreMap) (outStoreMap *model.StoreMap, err error) { +func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, vendorID int, vendorOrgCode string, storeID int, storeMap *model.StoreMap) (outStoreMap *model.StoreMap, err error) { if storeID == 0 { return nil, fmt.Errorf("storeID不能为0") } @@ -970,7 +970,7 @@ func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID } userName := ctx.GetUserName() if handler := CurVendorSync.GetStoreHandler(vendorID); handler != nil { - store, err2 := handler.ReadStore(ctx, storeMap.VendorStoreID) + store, err2 := handler.ReadStore(ctx, vendorOrgCode, storeMap.VendorStoreID) if err = err2; err == nil || storeMap.IsSync == 0 { dao.WrapAddIDCULDEntity(storeMap, userName) storeMap.StoreID = storeID @@ -1020,7 +1020,7 @@ func DeleteStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor storeMap.DeletedAt = utils.DefaultTimeValue if err = dao.GetEntity(db, storeMap, model.FieldStoreID, model.FieldVendorID, model.FieldDeletedAt); err == nil { if handler := partner.GetPurchasePlatformFromVendorID(vendorID); handler != nil { - handler.UpdateStoreCustomID(ctx, storeMap.VendorStoreID, utils.Str2Int64WithDefault(storeMap.VendorStoreID, 0)) + handler.UpdateStoreCustomID(ctx, storeMap.VendorOrgCode, storeMap.VendorStoreID, utils.Str2Int64WithDefault(storeMap.VendorStoreID, 0)) } num, err = dao.DeleteEntityLogically(db, storeMap, map[string]interface{}{ model.FieldStatus: model.StoreStatusDisabled, @@ -1076,7 +1076,7 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor } if vendorStoreID := utils.Interface2String(valid["vendorStoreID"]); vendorStoreID != "" { - vendorStoreInfo, err2 := storeHandler.ReadStore(ctx, vendorStoreID) + vendorStoreInfo, err2 := storeHandler.ReadStore(ctx, storeMap.VendorOrgCode, vendorStoreID) if err = err2; err == nil { valid["deliveryType"] = vendorStoreInfo.DeliveryType } @@ -1591,7 +1591,7 @@ func GetStoresVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, v storeMap := batchItemList[0].(*model.StoreMap) if model.IsVendorRemote(storeMap.VendorID) { if handler := partner.GetPurchasePlatformFromVendorID(storeMap.VendorID); handler != nil { - store, err2 := handler.ReadStore(ctx, storeMap.VendorStoreID) + store, err2 := handler.ReadStore(ctx, storeMap.VendorOrgCode, storeMap.VendorStoreID) if err = err2; err == nil { retVal = []interface{}{&model.VendorStoreSnapshot{ StoreID: storeMap.StoreID, @@ -1664,7 +1664,7 @@ func updateVendorStoreStatusBySnapshot(db *dao.DaoDB, curSnapshotList []*model.V if snapshot := snapshotMap[jxutils.Combine2Int(v.StoreID, v.VendorID)]; snapshot != nil { if snapshot.IsAutoOrder == 1 { if handler, ok := partner.GetPurchasePlatformFromVendorID(snapshot.VendorID).(partner.IStoreHandler); ok { - handler.EnableAutoAcceptOrder(jxcontext.AdminCtx, v.StoreID, v.VendorStoreID, false) + handler.EnableAutoAcceptOrder(jxcontext.AdminCtx, v.VendorOrgCode, v.StoreID, v.VendorStoreID, false) } } } @@ -2296,7 +2296,7 @@ func GetVendorStoreInfo(ctx *jxcontext.Context, vendorIDList []int, isAsync, isC case 0: for _, vendorID := range vendorIDList { iStoreHandler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IStoreHandler) - storeIDs, err := iStoreHandler.GetAllStoresVendorID(ctx) + storeIDs, err := iStoreHandler.GetAllStoresVendorID(ctx, "") // TODO if err != nil { return "", err } @@ -2305,13 +2305,13 @@ func GetVendorStoreInfo(ctx *jxcontext.Context, vendorIDList []int, isAsync, isC storeID := batchItemList[0].(string) if partner.IsMultiStore(vendorID) { multiHandler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IMultipleStoresHandler) - storeDetail, err = multiHandler.ReadStore(ctx, storeID) + storeDetail, err = multiHandler.ReadStore(ctx, "", storeID) if err != nil { return retVal, err } } else { singleHandler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreHandler) - storeDetail, err = singleHandler.ReadStore(ctx, storeID) + storeDetail, err = singleHandler.ReadStore(ctx, "", storeID) if err != nil { return retVal, err } diff --git a/business/jxstore/cms/sync_store.go b/business/jxstore/cms/sync_store.go index 8aac73b73..311b34ed3 100644 --- a/business/jxstore/cms/sync_store.go +++ b/business/jxstore/cms/sync_store.go @@ -36,7 +36,7 @@ func OpenRemoteStoreByJxStatus(ctx *jxcontext.Context, vendorIDs, storeIDs []int if handler, _ := partner.GetPurchasePlatformFromVendorID(storeMap.VendorID).(partner.IStoreHandler); handler != nil { storeDetail, err := dao.GetStoreDetail(db, storeMap.StoreID, storeMap.VendorID) if err == nil && storeDetail.Status == model.StoreStatusOpened { - if err = handler.UpdateStoreStatus(ctx, storeMap.StoreID, storeMap.VendorStoreID, model.StoreStatusOpened); err == nil { + if err = handler.UpdateStoreStatus(ctx, storeMap.VendorOrgCode, storeMap.StoreID, storeMap.VendorStoreID, model.StoreStatusOpened); err == nil { storeMap.Status = model.StoreStatusOpened dao.UpdateEntity(db, storeMap, model.FieldStatus) retVal = []int{1} diff --git a/business/jxstore/misc/misc2.go b/business/jxstore/misc/misc2.go index ed90d0ca4..92ebd3255 100644 --- a/business/jxstore/misc/misc2.go +++ b/business/jxstore/misc/misc2.go @@ -109,7 +109,7 @@ func AddOrDelExtraStoreOptime(ctx *jxcontext.Context, vendorID, storeID int, ven opTimeList = []int16{startOpStoreTime, endOpStoreTime} } handler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IStoreHandler) - return handler.UpdateStoreOpTime(ctx, storeID, vendorStoreID, opTimeList) == nil + return handler.UpdateStoreOpTime(ctx, "", storeID, vendorStoreID, opTimeList) == nil // TODO vendorOrgCode应该用传入的值 } func GetStockValue(isStart bool) int { diff --git a/business/jxstore/tempop/tempop.go b/business/jxstore/tempop/tempop.go index de9df59ec..43af63543 100644 --- a/business/jxstore/tempop/tempop.go +++ b/business/jxstore/tempop/tempop.go @@ -1202,7 +1202,7 @@ func FixMtwmCategory(ctx *jxcontext.Context, mtwmStoreIDs []int, isAsync, isCont name2CatMap[v.Name] = v } case 1: - storeIDs, err := mtwm.CurPurchaseHandler.GetAllStoresVendorID(ctx) + storeIDs, err := mtwm.CurPurchaseHandler.GetAllStoresVendorID(ctx, "") if err != nil { return nil, err } diff --git a/business/model/dao/store.go b/business/model/dao/store.go index 18ec8da5a..9398250b3 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -12,6 +12,8 @@ import ( type StoreDetail struct { model.Store + VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空 + VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"` VendorStatus int `json:"vendor_status"` // 取值同Store.Status DeliveryFee int `json:"deliveryFee"` diff --git a/business/model/store.go b/business/model/store.go index 58ab96a50..22ea83a38 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -373,6 +373,8 @@ type StoreMap struct { StoreID int `orm:"column(store_id)" json:"storeID"` VendorID int `orm:"column(vendor_id)" json:"vendorID"` + VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空 + VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"` Status int `json:"status"` // 取值同Store.Status StoreName string `orm:"size(255)" json:"storeName"` // 平台门店的名字 @@ -466,6 +468,7 @@ func (*PriceReferSnapshot) TableIndex() [][]string { type VendorStoreSnapshot struct { ModelIDCULD + VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空 StoreID int `orm:"column(store_id)" json:"storeID"` VendorID int `orm:"column(vendor_id)" json:"vendorID"` VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"` diff --git a/business/partner/partner.go b/business/partner/partner.go index 524c5b93c..54ce8ad9e 100644 --- a/business/partner/partner.go +++ b/business/partner/partner.go @@ -141,13 +141,14 @@ type IPurchasePlatformHandler interface { //////// // Store - ReadStore(ctx *jxcontext.Context, vendorStoreID string) (store *dao.StoreDetail, err error) + ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string) (store *dao.StoreDetail, err error) UpdateStore(db *dao.DaoDB, storeID int, userName string) (err error) - GetStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeStatus int, err error) - UpdateStoreCustomID(ctx *jxcontext.Context, vendorStoreID string, storeID int64) (err error) + GetStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string) (storeStatus int, err error) + UpdateStoreCustomID(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string, storeID int64) (err error) RefreshAllStoresID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error) + // TODO 此函数也需要加vendorOrgCode UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string, imgType int) (imgHint string, err error) } diff --git a/business/partner/partner_store.go b/business/partner/partner_store.go index 2a0b3b994..f7292476c 100644 --- a/business/partner/partner_store.go +++ b/business/partner/partner_store.go @@ -6,12 +6,12 @@ import ( ) type IStoreHandler interface { - GetAllStoresVendorID(ctx *jxcontext.Context) (vendorStoreIDs []string, err error) + GetAllStoresVendorID(ctx *jxcontext.Context, vendorOrgCode string) (vendorStoreIDs []string, err error) - EnableAutoAcceptOrder(ctx *jxcontext.Context, storeID int, vendorStoreID string, isSetEnable bool) (err error) - UpdateStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, status int) (err error) + EnableAutoAcceptOrder(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, isSetEnable bool) (err error) + UpdateStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, status int) (err error) // opTime格式为整数1130代表11:30 - UpdateStoreOpTime(ctx *jxcontext.Context, storeID int, vendorStoreID string, opTimeList []int16) (err error) + UpdateStoreOpTime(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, opTimeList []int16) (err error) } // 同步资质信息至平台 diff --git a/business/partner/purchase/ebai/order.go b/business/partner/purchase/ebai/order.go index e891e83fa..76d530a34 100644 --- a/business/partner/purchase/ebai/order.go +++ b/business/partner/purchase/ebai/order.go @@ -620,7 +620,7 @@ func (c *PurchaseHandler) ListOrders(ctx *jxcontext.Context, parentTask tasksch. toDate := fromDate.Add(24*time.Hour - 1) var vendorStoreIDs []string if vendorStoreID == "" { - vendorStoreIDs, err = c.GetAllStoresVendorID(ctx) + vendorStoreIDs, err = c.GetAllStoresVendorID(ctx, "") if err != nil { return nil, err } diff --git a/business/partner/purchase/ebai/store.go b/business/partner/purchase/ebai/store.go index d76a5c13e..e5b39a2dc 100644 --- a/business/partner/purchase/ebai/store.go +++ b/business/partner/purchase/ebai/store.go @@ -24,6 +24,7 @@ const ( type tEbaiStoreInfo struct { model.Store + VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空 VendorStoreID string `orm:"column(vendor_store_id)"` RealLastOperator string EbaiStoreStatus int @@ -79,7 +80,7 @@ func getCoordintate(data interface{}) float64 { return utils.MustInterface2Float64(data) } -func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (*dao.StoreDetail, error) { +func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string) (*dao.StoreDetail, error) { baiduShopID := utils.Str2Int64WithDefault(vendorStoreID, 0) if baiduShopID == 0 { return nil, fmt.Errorf("饿百门店ID:%s非法,应该是一个整数", vendorStoreID) @@ -150,7 +151,9 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin var stores []*tEbaiStoreInfo sql := ` - SELECT t1.*, t2.status ebai_store_status, t2.vendor_store_id, + SELECT + t1.*, + t2.status ebai_store_status, t2.vendor_store_id, t2.vendor_org_code, IF(t1.updated_at > t2.updated_at, t1.last_operator, t2.last_operator) real_last_operator, t2.sync_status FROM store t1 JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND (t2.deleted_at = ?) @@ -165,7 +168,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin if store.SyncStatus&model.SyncFlagDeletedMask == 0 { shopID = store.ID } - store2, err2 := p.ReadStore(jxcontext.AdminCtx, store.VendorStoreID) + store2, err2 := p.ReadStore(jxcontext.AdminCtx, store.VendorOrgCode, store.VendorStoreID) // globals.SugarLogger.Debugf("ebai UpdateStore2 store2:%s, err2:%v", utils.Format4Output(store2, true), err2) if err = err2; err == nil { if store2.ID == store.ID { @@ -174,7 +177,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin } if err == nil { if shopID > 0 { - err = p.UpdateStoreCustomID(jxcontext.AdminCtx, store.VendorStoreID, int64(shopID)) + err = p.UpdateStoreCustomID(jxcontext.AdminCtx, "", store.VendorStoreID, int64(shopID)) } else if shopID == 0 { // todo remove out shop id } @@ -410,7 +413,7 @@ func genStoreMapFromStore(store *tEbaiStoreInfo) map[string]interface{} { return params } -func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeStatus int, err error) { +func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string) (storeStatus int, err error) { ebaiStatus, err := api.EbaiAPI.ShopBusStatusGet("", utils.Str2Int64(vendorStoreID), ebaiapi.PlatformFlagElm) if err == nil { storeStatus = EbaiBusStatus2JxStatus(ebaiStatus) @@ -425,7 +428,7 @@ func (c *PurchaseHandler) onShopMsgPush(msg *ebaiapi.CallbackMsg) (response *eba storeStatus := model.StoreStatusOpened switch utils.Interface2String(msg.Body["msg_type"]) { case "online", "offline": - storeStatus, err = c.GetStoreStatus(jxcontext.AdminCtx, storeID, vendorStoreID) + storeStatus, err = c.GetStoreStatus(jxcontext.AdminCtx, "", storeID, vendorStoreID) case "shop_open", "shop_pause", "shop_close": if int(utils.ForceInterface2Int64(msg.Body["business_ele"])) == 1 { storeStatus = model.StoreStatusOpened @@ -447,12 +450,12 @@ func (c *PurchaseHandler) GetShopHealthInfo(vendorShopID string) (shopHealthInfo return shopHealthInfo, err } -func (p *PurchaseHandler) EnableAutoAcceptOrder(ctx *jxcontext.Context, storeID int, vendorStoreID string, isSetEnable bool) (err error) { +func (p *PurchaseHandler) EnableAutoAcceptOrder(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, isSetEnable bool) (err error) { return err } -func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, status int) (err error) { - store, err := c.ReadStore(ctx, vendorStoreID) +func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, status int) (err error) { + store, err := c.ReadStore(ctx, vendorOrgCode, vendorStoreID) if err != nil { return err } @@ -478,7 +481,7 @@ func (c *PurchaseHandler) updateStoreStatus(userName string, storeID int, vendor return err } -func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, storeID int, vendorStoreID string, opTimeList []int16) (err error) { +func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, opTimeList []int16) (err error) { params := map[string]interface{}{ ebaiapi.KeyBaiduShopID: vendorStoreID, } @@ -489,7 +492,7 @@ func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, storeID int, return err } -func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context) (vendorStoreIDs []string, err error) { +func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context, vendorOrgCode string) (vendorStoreIDs []string, err error) { shopList, err := api.EbaiAPI.ShopList(ebaiapi.SysStatusAll) if err == nil && len(shopList) > 0 { vendorStoreIDs = make([]string, len(shopList)) @@ -500,7 +503,7 @@ func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context) (vendorSt return vendorStoreIDs, err } -func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorStoreID string, storeID int64) (err error) { +func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorOrgCode string, vendorStoreID string, storeID int64) (err error) { if globals.EnableJdStoreWrite { err = api.EbaiAPI.ShopIDBatchUpdate([]string{vendorStoreID}, []string{utils.Int64ToStr(storeID)}) } diff --git a/business/partner/purchase/ebai/store_test.go b/business/partner/purchase/ebai/store_test.go index c26fc7088..c24f5ba3b 100644 --- a/business/partner/purchase/ebai/store_test.go +++ b/business/partner/purchase/ebai/store_test.go @@ -10,7 +10,7 @@ import ( ) func TestReadStore(t *testing.T) { - result, err := CurPurchaseHandler.ReadStore(jxcontext.AdminCtx, testShopBaiduID) + result, err := CurPurchaseHandler.ReadStore(jxcontext.AdminCtx, "", testShopBaiduID) if err != nil { t.Fatal(err.Error()) } diff --git a/business/partner/purchase/elm/store.go b/business/partner/purchase/elm/store.go index 7ee357328..ff863d62a 100644 --- a/business/partner/purchase/elm/store.go +++ b/business/partner/purchase/elm/store.go @@ -8,7 +8,7 @@ import ( "git.rosy.net.cn/jx-callback/business/model/dao" ) -func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (*dao.StoreDetail, error) { +func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode string, vendorStoreID string) (*dao.StoreDetail, error) { return nil, errors.New("饿了么还没实现") } @@ -20,6 +20,6 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask return hint, err } -func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeStatus int, err error) { +func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string) (storeStatus int, err error) { return storeStatus, err } diff --git a/business/partner/purchase/jd/sku.go b/business/partner/purchase/jd/sku.go index 3f39b0ed9..46a23c1eb 100644 --- a/business/partner/purchase/jd/sku.go +++ b/business/partner/purchase/jd/sku.go @@ -291,57 +291,57 @@ func (p *PurchaseHandler) DeleteSku(db *dao.DaoDB, sku *model.Sku, userName stri return err } -func (p *PurchaseHandler) RefreshAllSkusID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error) { - globals.SugarLogger.Debugf("jd RefreshAllSkusID") +// func (p *PurchaseHandler) RefreshAllSkusID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error) { +// globals.SugarLogger.Debugf("jd RefreshAllSkusID") - db := dao.GetDB() - var skuPairs []*jdapi.SkuIDPair - const stepCount = 2 +// db := dao.GetDB() +// var skuPairs []*jdapi.SkuIDPair +// const stepCount = 2 - rootTask := tasksch.NewSeqTask("jd RefreshAllSkusID", ctx, - func(rootTask *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) { - switch step { - case 0: - err = dao.GetRows(db, &skuPairs, ` - SELECT t1.id out_sku_id, t1.jd_id sku_id - FROM sku t1 - WHERE t1.deleted_at = ? - `, utils.DefaultTimeValue) - default: - taskName := "RefreshAllSkusID update id" - if step != stepCount-1 { - taskName = "RefreshAllSkusID update uuid" - } - task1 := tasksch.NewParallelTask(taskName, tasksch.NewParallelConfig().SetIsContinueWhenError(true).SetBatchSize(jdapi.MaxBatchSize4BatchUpdateOutSkuId), ctx, - func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { - skuPairs := make([]*jdapi.SkuIDPair, len(batchItemList)) - for k, v := range batchItemList { - pair := v.(*jdapi.SkuIDPair) - skuPairs[k] = &jdapi.SkuIDPair{ - SkuId: pair.SkuId, - OutSkuId: pair.OutSkuId, - } - if step != stepCount-1 { - skuPairs[k].OutSkuId = utils.GetUUID() - } - } - globals.SugarLogger.Debug(utils.Format4Output(skuPairs, false)) - if globals.EnableJdStoreWrite { - _, err = getAPI("").BatchUpdateOutSkuId(skuPairs) - } - return nil, err - }, skuPairs) - rootTask.AddChild(task1).Run() - _, err = task1.GetResult(0) - } - return nil, err - }, stepCount) - tasksch.HandleTask(rootTask, parentTask, false).Run() - if !isAsync { - _, err = rootTask.GetResult(0) - } - return rootTask.ID, err -} +// rootTask := tasksch.NewSeqTask("jd RefreshAllSkusID", ctx, +// func(rootTask *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) { +// switch step { +// case 0: +// err = dao.GetRows(db, &skuPairs, ` +// SELECT t1.id out_sku_id, t1.jd_id sku_id +// FROM sku t1 +// WHERE t1.deleted_at = ? +// `, utils.DefaultTimeValue) +// default: +// taskName := "RefreshAllSkusID update id" +// if step != stepCount-1 { +// taskName = "RefreshAllSkusID update uuid" +// } +// task1 := tasksch.NewParallelTask(taskName, tasksch.NewParallelConfig().SetIsContinueWhenError(true).SetBatchSize(jdapi.MaxBatchSize4BatchUpdateOutSkuId), ctx, +// func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { +// skuPairs := make([]*jdapi.SkuIDPair, len(batchItemList)) +// for k, v := range batchItemList { +// pair := v.(*jdapi.SkuIDPair) +// skuPairs[k] = &jdapi.SkuIDPair{ +// SkuId: pair.SkuId, +// OutSkuId: pair.OutSkuId, +// } +// if step != stepCount-1 { +// skuPairs[k].OutSkuId = utils.GetUUID() +// } +// } +// globals.SugarLogger.Debug(utils.Format4Output(skuPairs, false)) +// if globals.EnableJdStoreWrite { +// _, err = getAPI("").BatchUpdateOutSkuId(skuPairs) +// } +// return nil, err +// }, skuPairs) +// rootTask.AddChild(task1).Run() +// _, err = task1.GetResult(0) +// } +// return nil, err +// }, stepCount) +// tasksch.HandleTask(rootTask, parentTask, false).Run() +// if !isAsync { +// _, err = rootTask.GetResult(0) +// } +// return rootTask.ID, err +// } func splitAddParams(addParams map[string]interface{}) (spuAddParams, skuAddParams map[string]interface{}) { if addParams != nil { diff --git a/business/partner/purchase/jd/store.go b/business/partner/purchase/jd/store.go index 43c54fa2c..651fbc30b 100644 --- a/business/partner/purchase/jd/store.go +++ b/business/partner/purchase/jd/store.go @@ -26,6 +26,7 @@ const ( type tJdStoreInfo struct { model.Store + VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空 FreightDeductionPack string `orm:"size(32)" json:"freightDeductionPack"` // @@ -37,8 +38,9 @@ type tJdStoreInfo struct { SyncStatus int } -func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (*dao.StoreDetail, error) { - result, err := getAPI("").GetStoreInfoByStationNo2(vendorStoreID) +func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string) (*dao.StoreDetail, error) { + a := getAPI(vendorOrgCode) + result, err := a.GetStoreInfoByStationNo2(vendorStoreID) if err == nil { retVal := &dao.StoreDetail{ Store: model.Store{ @@ -92,7 +94,7 @@ func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string } retVal.ID = int(utils.Str2Int64WithDefault(result.OutSystemID, 0)) - deliveryRange, err2 := getAPI("").GetDeliveryRangeByStationNo2(vendorStoreID) + deliveryRange, err2 := a.GetDeliveryRangeByStationNo2(vendorStoreID) if err = err2; err == nil { retVal.DeliveryRangeType = int8(deliveryRange.DeliveryRangeType) if retVal.DeliveryRangeType == model.DeliveryRangeTypePolygon { @@ -110,9 +112,11 @@ func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName string) (err error) { var stores []*tJdStoreInfo sql := ` - SELECT t1.*, city.jd_code jd_city_code, district.jd_code jd_district_code, - t2.status jd_store_status, t2.vendor_store_id, IF(t1.updated_at > t2.updated_at, t1.last_operator, t2.last_operator) real_last_operator, - t2.sync_status, t2.freight_deduction_pack + SELECT + t1.*, city.jd_code jd_city_code, district.jd_code jd_district_code, + t2.status jd_store_status, t2.vendor_store_id, IF(t1.updated_at > t2.updated_at, t1.last_operator, + t2.last_operator) real_last_operator, + t2.sync_status, t2.freight_deduction_pack, t2.vendor_org_code FROM store t1 JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND (t2.deleted_at = ?) LEFT JOIN place city ON t1.city_code = city.code @@ -122,6 +126,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin ` if err = dao.GetRows(db, &stores, sql, model.VendorIDJD, utils.DefaultTimeValue, storeID); err == nil { for _, store := range stores { + a := getAPI(store.VendorOrgCode) storeParams := &jdapi.OpStoreParams{ StationNo: store.VendorStoreID, Operator: userName, @@ -163,7 +168,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin globals.SugarLogger.Debug(utils.Format4Output(storeParams, false)) errList := errlist.New() if globals.EnableJdStoreWrite { - errList.AddErr(getAPI("").UpdateStoreInfo4Open2(storeParams, modifyCloseStatus)) + errList.AddErr(a.UpdateStoreInfo4Open2(storeParams, modifyCloseStatus)) } if store.FreightDeductionPack != "" { storeDetail, err2 := dao.GetStoreDetail(db, store.ID, model.VendorIDJD) @@ -196,7 +201,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin freightParams.IsFullFree = len(freightParams.FreeFreightInfoList) > 0 globals.SugarLogger.Debug(utils.Format4Output(freightParams, false)) if globals.EnableJdStoreWrite { - errList.AddErr(getAPI("").UpdateStoreFreightConfigNew(freightParams)) + errList.AddErr(a.UpdateStoreFreightConfigNew(freightParams)) } } } @@ -239,7 +244,7 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask storeParams.OutSystemID = store.VendorStoreID } if globals.EnableJdStoreWrite { - err = getAPI("").UpdateStoreInfo4Open2(storeParams, false) + err = getAPI(store.VendorOrgCode).UpdateStoreInfo4Open2(storeParams, false) } return nil, err }, stores) @@ -265,8 +270,8 @@ func JdDeliveryType2Jx(deliveryType int) int8 { return scheduler.StoreDeliveryTypeByPlatform } -func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeStatus int, err error) { - result, err := getAPI("").GetStoreInfoByStationNo2(vendorStoreID) +func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string) (storeStatus int, err error) { + result, err := getAPI(vendorOrgCode).GetStoreInfoByStationNo2(vendorStoreID) if err == nil { storeStatus = JdStoreStatus2JxStatus(int(result.Yn), result.CloseStatus) } @@ -291,15 +296,15 @@ func (c *PurchaseHandler) OnStoreMsg(msg *jdapi.CallbackOrderMsg) (response *jda return jdapi.Err2CallbackResponse(err, "") } -func (p *PurchaseHandler) EnableAutoAcceptOrder(ctx *jxcontext.Context, storeID int, vendorStoreID string, isSetEnable bool) (err error) { - _, err = getAPI("").UpdateStoreConfig4Open(vendorStoreID, isSetEnable) +func (p *PurchaseHandler) EnableAutoAcceptOrder(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, isSetEnable bool) (err error) { + _, err = getAPI(vendorOrgCode).UpdateStoreConfig4Open(vendorStoreID, isSetEnable) return err } -func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, status int) (err error) { +func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, status int) (err error) { _, closeStatus := JxStoreStatus2JdStatus(status) if globals.EnableJdStoreWrite { - err = getAPI("").UpdateStoreInfo4Open2(&jdapi.OpStoreParams{ + err = getAPI(vendorOrgCode).UpdateStoreInfo4Open2(&jdapi.OpStoreParams{ StationNo: vendorStoreID, Operator: ctx.GetUserName(), CloseStatus: closeStatus, @@ -331,20 +336,20 @@ func fillOpTimeParams(params *jdapi.OpStoreParams, opTimeList []int16) { } } -func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, storeID int, vendorStoreID string, opTimeList []int16) (err error) { +func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, opTimeList []int16) (err error) { params := &jdapi.OpStoreParams{ StationNo: vendorStoreID, Operator: ctx.GetUserName(), } fillOpTimeParams(params, opTimeList) if globals.EnableJdStoreWrite { - err = getAPI("").UpdateStoreInfo4Open2(params, false) + err = getAPI(vendorOrgCode).UpdateStoreInfo4Open2(params, false) } return err } -func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context) (vendorStoreIDs []string, err error) { - vendorStoreIDs, err = getAPI("").GetStationsByVenderId() +func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context, vendorOrgCode string) (vendorStoreIDs []string, err error) { + vendorStoreIDs, err = getAPI(vendorOrgCode).GetStationsByVenderId() return vendorStoreIDs, err } @@ -453,9 +458,9 @@ func (c *PurchaseHandler) SyncQualify(ctx *jxcontext.Context, storeDetail *dao.S return addStoreInfo2Err(err, storeDetail.ID) } -func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorStoreID string, storeID int64) (err error) { +func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string, storeID int64) (err error) { if globals.EnableJdStoreWrite { - err = getAPI("").UpdateStoreInfo4Open2( + err = getAPI(vendorOrgCode).UpdateStoreInfo4Open2( &jdapi.OpStoreParams{ StationNo: vendorStoreID, Operator: ctx.GetUserName(), diff --git a/business/partner/purchase/jd/store_test.go b/business/partner/purchase/jd/store_test.go index ae173c9c2..255a03d90 100644 --- a/business/partner/purchase/jd/store_test.go +++ b/business/partner/purchase/jd/store_test.go @@ -17,7 +17,7 @@ const ( ) func TestReadStore(t *testing.T) { - result, err := new(PurchaseHandler).ReadStore(jxcontext.AdminCtx, TestJdStoreNo) + result, err := new(PurchaseHandler).ReadStore(jxcontext.AdminCtx, "", TestJdStoreNo) if err != nil { t.Fatal(err.Error()) } @@ -26,7 +26,7 @@ func TestReadStore(t *testing.T) { func TestUpdateStore(t *testing.T) { handler := new(PurchaseHandler) - result, err := handler.ReadStore(jxcontext.AdminCtx, TestJdStoreNo) + result, err := handler.ReadStore(jxcontext.AdminCtx, "", TestJdStoreNo) // result := &model.Store{} // result.ID = 100164 @@ -43,7 +43,7 @@ func TestUpdateStore(t *testing.T) { } // same - result, err = handler.ReadStore(jxcontext.AdminCtx, TestJdStoreNo) + result, err = handler.ReadStore(jxcontext.AdminCtx, "", TestJdStoreNo) if result.Name != newName { t.Fatalf("result is not same, desired newName:%s, newName:%s", newName, result.Name) } diff --git a/business/partner/purchase/jx/sku.go b/business/partner/purchase/jx/sku.go index cb8fcbdad..2aa38e5b3 100644 --- a/business/partner/purchase/jx/sku.go +++ b/business/partner/purchase/jx/sku.go @@ -4,7 +4,6 @@ package jx import ( "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" - "git.rosy.net.cn/jx-callback/business/jxutils/tasksch" "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/model/dao" "git.rosy.net.cn/jx-callback/business/partner" @@ -74,10 +73,6 @@ func (p *PurchaseHandler) DeleteSku2(ctx *jxcontext.Context, sku *dao.StoreSkuSy return err } -func (p *PurchaseHandler) RefreshAllSkusID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error) { - return hint, err -} - func (p *PurchaseHandler) GetVendorCategories(ctx *jxcontext.Context) (vendorCats []*model.SkuVendorCategory, err error) { return vendorCats, err } diff --git a/business/partner/purchase/jx/store.go b/business/partner/purchase/jx/store.go index 9b75beae0..c5b1c17d5 100644 --- a/business/partner/purchase/jx/store.go +++ b/business/partner/purchase/jx/store.go @@ -6,7 +6,7 @@ import ( "git.rosy.net.cn/jx-callback/business/model/dao" ) -func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (storeDetail *dao.StoreDetail, err error) { +func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string) (storeDetail *dao.StoreDetail, err error) { return storeDetail, err } @@ -19,26 +19,26 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask return hint, err } -func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeStatus int, err error) { +func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string) (storeStatus int, err error) { return storeStatus, err } -func (p *PurchaseHandler) EnableAutoAcceptOrder(ctx *jxcontext.Context, storeID int, vendorStoreID string, isSetEnable bool) (err error) { +func (p *PurchaseHandler) EnableAutoAcceptOrder(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, isSetEnable bool) (err error) { return err } -func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, status int) (err error) { +func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, status int) (err error) { return err } -func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, storeID int, vendorStoreID string, opTimeList []int16) (err error) { +func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, opTimeList []int16) (err error) { return err } -func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context) (vendorStoreIDs []string, err error) { +func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context, vendorOrgCode string) (vendorStoreIDs []string, err error) { return vendorStoreIDs, err } -func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorStoreID string, storeID int64) (err error) { +func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string, storeID int64) (err error) { return err } diff --git a/business/partner/purchase/mtwm/order.go b/business/partner/purchase/mtwm/order.go index f55f8be1b..09ace7634 100644 --- a/business/partner/purchase/mtwm/order.go +++ b/business/partner/purchase/mtwm/order.go @@ -576,7 +576,7 @@ func (c *PurchaseHandler) ListOrders(ctx *jxcontext.Context, parentTask tasksch. var vendorStoreIDs []string if vendorStoreID == "" { - vendorStoreIDs, err = c.GetAllStoresVendorID(ctx) + vendorStoreIDs, err = c.GetAllStoresVendorID(ctx, "") if err != nil { return nil, err } diff --git a/business/partner/purchase/mtwm/store.go b/business/partner/purchase/mtwm/store.go index 7f43095f0..ab86a2343 100644 --- a/business/partner/purchase/mtwm/store.go +++ b/business/partner/purchase/mtwm/store.go @@ -40,7 +40,7 @@ type tEbaiStoreInfo struct { DistrictID int `orm:"column(district_id)"` } -func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (retVal *dao.StoreDetail, err error) { +func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string) (retVal *dao.StoreDetail, err error) { result, err := api.MtwmAPI.PoiGet(vendorStoreID) if err == nil { // globals.SugarLogger.Debug(utils.Format4Output(result, false)) @@ -135,7 +135,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin // if utils.IsErrMatch(err, utils.Int2Str(mtwmapi.ErrCodeCanNotModifyStoreDeliveryInfo), nil) { // globals.SugarLogger.Infof("mtwm UpdateStore vendorStoreID:%s, params:%s failed with err:%v", storeDetail.VendorStoreID, utils.Format4Output(params, true), err) // if storeDetail.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreStatus) != 0 { - // err = p.UpdateStoreStatus(jxcontext.AdminCtx, storeID, storeDetail.VendorStoreID, mergedStoreStatus) + // err = p.UpdateStoreStatus(jxcontext.AdminCtx, storeDetail.VendorOrgCode, storeID, storeDetail.VendorStoreID, mergedStoreStatus) // } else { // err = nil // } @@ -143,9 +143,9 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin // errList.AddErr(err) // } if storeDetail.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreStatus) != 0 { - errList.AddErr(p.UpdateStoreStatus(jxcontext.AdminCtx, storeID, storeDetail.VendorStoreID, mergedStoreStatus)) + errList.AddErr(p.UpdateStoreStatus(jxcontext.AdminCtx, storeDetail.VendorOrgCode, storeID, storeDetail.VendorStoreID, mergedStoreStatus)) } - errList.AddErr(p.UpdateStoreOpTime(jxcontext.AdminCtx, storeID, storeDetail.VendorStoreID, storeDetail.GetOpTimeList())) + errList.AddErr(p.UpdateStoreOpTime(jxcontext.AdminCtx, storeDetail.VendorOrgCode, storeID, storeDetail.VendorStoreID, storeDetail.GetOpTimeList())) return errList.GetErrListAsOne() } @@ -165,7 +165,7 @@ func (p *PurchaseHandler) onStoreStatusChanged(msg *mtwmapi.CallbackMsg) (respon } else if poiStatus == mtwmapi.MsgPoiStatusOffline { storeStatus = model.StoreStatusDisabled } else { - storeStatus, err = p.GetStoreStatus(jxcontext.AdminCtx, 0, vendorStoreID) + storeStatus, err = p.GetStoreStatus(jxcontext.AdminCtx, "", 0, vendorStoreID) } if err == nil { err = partner.CurStoreManager.OnStoreStatusChanged(vendorStoreID, model.VendorIDMTWM, storeStatus) @@ -174,7 +174,7 @@ func (p *PurchaseHandler) onStoreStatusChanged(msg *mtwmapi.CallbackMsg) (respon return response } -func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeStatus int, err error) { +func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string) (storeStatus int, err error) { result, err := api.MtwmAPI.PoiGet(vendorStoreID) if err == nil { return bizStatusMtwm2JX(result.OpenLevel, result.IsOnline), nil @@ -182,11 +182,11 @@ func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, storeID int, ve return 0, err } -func (p *PurchaseHandler) EnableAutoAcceptOrder(ctx *jxcontext.Context, storeID int, vendorStoreID string, isSetEnable bool) (err error) { +func (p *PurchaseHandler) EnableAutoAcceptOrder(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, isSetEnable bool) (err error) { return err } -func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, status int) (err error) { +func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, status int) (err error) { openLevel, isOnline := bizStatusJX2Mtwm(status) if globals.EnableMtwmStoreWrite { if isOnline != mtwmapi.PoiStatusOnline { @@ -255,7 +255,7 @@ func constrainOpTimeList(opTimeList, validOpTimeList []int16) (newOpTimeList []i return newOpTimeList } -func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, storeID int, vendorStoreID string, opTimeList []int16) (err error) { +func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, opTimeList []int16) (err error) { shippingTime := openTimeJX2Mtwm(opTimeList) if globals.EnableMtwmStoreWrite { err = api.MtwmAPI.PoiShipTimeUpdate(vendorStoreID, shippingTime) @@ -272,11 +272,11 @@ func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, storeID int, return err } -func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context) (vendorStoreIDs []string, err error) { +func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context, vendorOrgCode string) (vendorStoreIDs []string, err error) { vendorStoreIDs, err = api.MtwmAPI.PoiGetIDs() return vendorStoreIDs, err } -func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorStoreID string, storeID int64) (err error) { +func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string, storeID int64) (err error) { return err } diff --git a/business/partner/purchase/mtwm/store_test.go b/business/partner/purchase/mtwm/store_test.go index 9ae1e40aa..daecbef8f 100644 --- a/business/partner/purchase/mtwm/store_test.go +++ b/business/partner/purchase/mtwm/store_test.go @@ -11,7 +11,7 @@ import ( ) func TestReadStore(t *testing.T) { - store, err := CurPurchaseHandler.ReadStore(jxcontext.AdminCtx, "4351018") + store, err := CurPurchaseHandler.ReadStore(jxcontext.AdminCtx, "", "4351018") if err != nil { t.Fatal(err) } diff --git a/business/partner/purchase/weimob/wsc/store.go b/business/partner/purchase/weimob/wsc/store.go index df548f76d..28bf44197 100644 --- a/business/partner/purchase/weimob/wsc/store.go +++ b/business/partner/purchase/weimob/wsc/store.go @@ -8,7 +8,7 @@ import ( "git.rosy.net.cn/jx-callback/business/model/dao" ) -func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (*dao.StoreDetail, error) { +func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string) (*dao.StoreDetail, error) { return nil, errors.New("微盟微商城还没实现") } @@ -20,6 +20,6 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask return hint, err } -func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeStatus int, err error) { +func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string) (storeStatus int, err error) { return 0, err } diff --git a/conf/app.conf b/conf/app.conf index c347eea59..864677882 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -98,17 +98,17 @@ getWeixinTokenKey = "c928ed0d-87a3-441a-8517-f92f0167296f" storeName = "京西菜市" [dev] -jdToken = "df97f334-f7d8-4b36-9664-5784d8ae0baf" -jdAppKey = "06692746f7224695ad4788ce340bc854" -jdSecret = "d6b42a35a7414a5490d811654d745c84" +jdToken = "77e703b7-7997-441b-a12a-2e522efb117a" +jdAppKey = "1dba76d40cac446ca500c0391a0b6c9d" +jdSecret = "a88d031a1e7b462cb1579f12e97fe7f4" elmIsProd = false elmToken = "2d2b583447b04b6bba5a6f3faed3559b" elmAppKey = "RwT214gAsS" elmSecret = "56afff4b9ebd8a7eb532d18fa33f17be57f9b9db" -ebaiSource = "62923" -ebaiSecret = "aa4cdc6c1108486b" +ebaiSource = "34665" +ebaiSecret = "c3db75b754ea2d89" mtpsAppKey = "25e816550bc9484480642f19a95f13fd" mtpsSecret = "r4$HqrKx9~=7?2Jfo,$Z~a7%~k!Au&pEdI2)oPJvSbH2ao@2N0[8wSIvtuumh_J^" diff --git a/controllers/cms_sku.go b/controllers/cms_sku.go index 03d1d09c4..55a4756d5 100644 --- a/controllers/cms_sku.go +++ b/controllers/cms_sku.go @@ -296,7 +296,7 @@ func (c *SkuController) DeleteSkuNamePlace() { // @Param token header string true "认证token" // @Param vendorSkuID query string true "sku ID" // @Param vendorID query int true "门店所属的厂商ID" -// @Param vendorOrgCode query string true "厂商内组织代码" +// @Param vendorOrgCode query string false "厂商内组织代码" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetVendorSku [get] diff --git a/controllers/cms_store.go b/controllers/cms_store.go index edfac4245..0275bfffa 100644 --- a/controllers/cms_store.go +++ b/controllers/cms_store.go @@ -60,12 +60,13 @@ func (c *StoreController) GetStores() { // @Param token header string true "认证token" // @Param vendorStoreID query string true "门店ID" // @Param vendorID query int true "门店所属的厂商ID" +// @Param vendorOrgCode query string false "厂商内组织代码" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetVendorStore [get] func (c *StoreController) GetVendorStore() { c.callGetVendorStore(func(params *tStoreGetVendorStoreParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetVendorStore(params.Ctx, params.VendorStoreID, params.VendorID) + retVal, err = cms.GetVendorStore(params.Ctx, params.VendorID, params.VendorOrgCode, params.VendorStoreID) return retVal, "", err }) } @@ -176,6 +177,7 @@ func (c *StoreController) UpdateStoreVendorMap() { // @Param token header string true "认证token" // @Param storeID formData int true "门店ID,payload中的相应字段会被忽略" // @Param vendorID formData int true "厂商ID,payload中的相应字段会被忽略" +// @Param vendorOrgCode formData string false "厂商内组织代码" // @Param payload formData string true "json数据,storeMap对象({'vendorStoreID':'11732425','autoPickup':1,'deliveryCompetition':1, 'pricePercentage':100})" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult @@ -184,7 +186,7 @@ func (c *StoreController) AddStoreVendorMap() { c.callAddStoreVendorMap(func(params *tStoreAddStoreVendorMapParams) (retVal interface{}, errCode string, err error) { storeMap := &model.StoreMap{} if err = utils.UnmarshalUseNumber([]byte(params.Payload), storeMap); err == nil { - retVal, err = cms.AddStoreVendorMap(params.Ctx, nil, params.StoreID, params.VendorID, storeMap) + retVal, err = cms.AddStoreVendorMap(params.Ctx, nil, params.VendorID, params.VendorOrgCode, params.StoreID, storeMap) } return retVal, "", err }) diff --git a/controllers/cms_sync.go b/controllers/cms_sync.go index c64fa2390..a7f06c3bb 100644 --- a/controllers/cms_sync.go +++ b/controllers/cms_sync.go @@ -87,16 +87,16 @@ func (c *SyncController) RefreshAllStoresID() { // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /RefreshAllSkusID [put] -func (c *SyncController) RefreshAllSkusID() { - // c.callRefreshAllSkusID(func(params *tSyncRefreshAllSkusIDParams) (retVal interface{}, errCode string, err error) { - // var vendorIDs, storeIDs []int - // if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil { - // return retVal, "", err - // } - // retVal, err = cms.CurVendorSync.RefreshAllSkusID(params.Ctx, params.IsAsync, vendorIDs, storeIDs) - // return retVal, "", err - // }) -} +// func (c *SyncController) RefreshAllSkusID() { +// c.callRefreshAllSkusID(func(params *tSyncRefreshAllSkusIDParams) (retVal interface{}, errCode string, err error) { +// var vendorIDs, storeIDs []int +// if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil { +// return retVal, "", err +// } +// retVal, err = cms.CurVendorSync.RefreshAllSkusID(params.Ctx, params.IsAsync, vendorIDs, storeIDs) +// return retVal, "", err +// }) +// } // @Title 全新初始化商家商品信息 // @Description 全新初始化商家商品信息(!!!此操作会先清除平台上已有的商品及分类信息),此操作只适用于单门店模式平台 diff --git a/globals/api/apimanager/apimanager.go b/globals/api/apimanager/apimanager.go index 6e62c34b6..52bd3c317 100644 --- a/globals/api/apimanager/apimanager.go +++ b/globals/api/apimanager/apimanager.go @@ -38,6 +38,7 @@ func (a *APIManager) GetAPI(vendorID int, appOrgCode string) (pfAPI interface{}) return pfAPI } +// TODO func (a *APIManager) GetAppOrgCodeList(vendorID int) (appOrgCodeList []string) { switch vendorID { case model.VendorIDJD: diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 56edc6b6c..d933bbb22 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -1746,15 +1746,6 @@ 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: "RefreshAllSkusID", - Router: `/RefreshAllSkusID`, - AllowHTTPMethods: []string{"put"}, - 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: "RefreshAllStoresID",