This commit is contained in:
邹宗楠
2023-09-21 14:30:05 +08:00
parent aaaf465fd6
commit 2c2dc5402b
7 changed files with 17 additions and 23 deletions

View File

@@ -1369,7 +1369,7 @@ func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (i
Status: model.StoreStatusOpened,
PricePercentagePack: "无",
VendorID: model.VendorIDJX,
})
}, false)
//尝试把平台负责人加到他自己的权限里
if store.MarketManPhone != "" {
user, _ := dao.GetUserByID(db, "mobile", store.MarketManPhone)
@@ -1489,7 +1489,7 @@ func CreateStore2JX(ctx *jxcontext.Context, storeExt *StoreExt, userName string)
PricePercentagePack: "无",
CreateDeliveryType: model.YES, // 菜市门店默认门店发单
VendorID: model.VendorIDJX,
})
}, false)
//尝试把平台负责人加到他自己的权限里
if store.MarketManPhone != "" {
user, _ := dao.GetUserByID(db, "mobile", store.MarketManPhone)
@@ -1570,7 +1570,7 @@ func GetStoreVendorMaps(ctx *jxcontext.Context, db *dao.DaoDB, storeID int, vend
}
// todo 需要对字段做有效性检查
func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, vendorID int, vendorOrgCode string, storeID 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, isAdd bool) (outStoreMap *model.StoreMap, err error) {
errList := errlist.ErrList{}
if storeID == 0 {
return nil, fmt.Errorf("storeID不能为0")
@@ -1687,7 +1687,7 @@ func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, vendorID int, vend
err = AddEventDetail(db, ctx, model.OperateAdd, vendorID, model.ThingTypeStore, storeID, "", `{"VendorID":`+utils.Int2Str(vendorID)+`}`)
}
_, err = CurVendorSync.SyncStore(ctx, db, storeMap.VendorID, storeID, false, userName)
_, err = CurVendorSync.FullSyncStoresSkus(ctx, db, []int{vendorID}, []int{storeID}, true, nil, true, true)
_, err = CurVendorSync.FullSyncStoresSkus(ctx, db, []int{vendorID}, []int{storeID}, true, nil, true, true, isAdd)
if utils.IsNil(errList) && err == nil {
return outStoreMap, nil
} else {
@@ -1924,7 +1924,7 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
case 1:
if singleStoreHandler != nil {
// 直接同步商品
err = syncStoreSkuNew(ctx, task, 0, false, vendorID, storeID, "", nil, nil, nil, false, true)
err = syncStoreSkuNew(ctx, task, 0, true, vendorID, storeID, "", nil, nil, nil, false, true)
}
}
return retVal, err
@@ -5541,7 +5541,7 @@ func AuditStoreMap(ctx *jxcontext.Context, ID int, vendorOrgCode, vendorStoreID
DeliveryCompetition: 1,
PricePercentage: 100,
}
_, err = AddStoreVendorMap(ctx, db, storeMapAudit.VendorID, vendorOrgCode, storeMapAudit.StoreID, storeMap)
_, err = AddStoreVendorMap(ctx, db, storeMapAudit.VendorID, vendorOrgCode, storeMapAudit.StoreID, storeMap, false)
} else {
if comment == "" {
fmt.Errorf("审核不通过请输入原因!")

View File

@@ -555,7 +555,7 @@ func (v *VendorSync) SyncStoresSkus(ctx *jxcontext.Context, parentTask tasksch.I
func (c *ComparePlatform) CompareStoreWithOperator(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, syncDisabled bool, excludeSkuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
return hint, makeSyncError(err)
}
func (v *VendorSync) FullSyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, syncDisabled bool, excludeSkuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
func (v *VendorSync) FullSyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, syncDisabled bool, excludeSkuIDs []int, isAsync, isContinueWhenError, isAdd bool) (hint string, err error) {
hint, err = v.LoopStoresMap(ctx, db, fmt.Sprintf("初始化门店商品信息:%v", storeIDs), isAsync, true, vendorIDs, storeIDs,
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
loopMapInfo := batchItemList[0].(*LoopStoreMapInfo)
@@ -569,7 +569,7 @@ func (v *VendorSync) FullSyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, v
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
storeMap := batchItemList[0].(*model.StoreMap)
if syncDisabled || storeMap.Status > model.StoreStatusDisabled {
if _, err = FullSyncStoreSkuNew(ctx, task, storeMap.VendorID, storeMap.StoreID, storeMap.VendorStoreID, excludeSkuIDs, false, isContinueWhenError); err != nil {
if _, err = FullSyncStoreSkuNew(ctx, task, storeMap.VendorID, storeMap.StoreID, storeMap.VendorStoreID, excludeSkuIDs, false, isContinueWhenError, isAdd); err != nil {
globals.SugarLogger.Debugf("FullSyncStoresSkus failed2 store:%d failed with error:%v", storeMap.StoreID, err)
}
}

View File

@@ -219,7 +219,8 @@ func SyncStoreSkuNew2(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFla
return hint, err
}
func FullSyncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorID, storeID int, vendorStoreID string, excludeSkuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
// FullSyncStoreSkuNew isAdd 这个参数是因为在绑定门店映射是会删除门店商品和分类,才使用这个字段限制
func FullSyncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorID, storeID int, vendorStoreID string, excludeSkuIDs []int, isAsync, isContinueWhenError, isAdd bool) (hint string, err error) {
singleStoreHandler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
task := tasksch.NewParallelTask("FullSyncStoreSkuNew", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError), ctx,
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
@@ -227,8 +228,10 @@ func FullSyncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, vendo
switch step {
case 0:
if singleStoreHandler != nil {
// _, err = ClearRemoteStoreStuffAndSetNew(ctx, task, vendorID, storeID, vendorStoreID, false, isContinueWhenError)
_, err = amendAndPruneStoreStuff(ctx, parentTask, vendorID, storeID, vendorStoreID, false, isContinueWhenError, AmendPruneAll, false)
//_, err = ClearRemoteStoreStuffAndSetNew(ctx, task, vendorID, storeID, vendorStoreID, false, isContinueWhenError)
if !isAdd {
_, err = amendAndPruneStoreStuff(ctx, parentTask, vendorID, storeID, vendorStoreID, false, isContinueWhenError, AmendPruneAll, false)
}
} else {
_, err = dao.SetStoreSkuSyncStatus(dao.GetDB(), vendorID, []int{storeID}, nil, model.SyncFlagStoreSkuOnlyMask)
}
@@ -540,7 +543,6 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
}
var bareSku *partner.StoreSkuInfo
isNeedReorder := false
globals.SugarLogger.Debugf("==========sku := %s", utils.Format4Output(sku, false))
if isStoreSkuSyncNeedDelete(sku) {
if !dao.IsVendorThingIDEmpty(sku.VendorSkuID) {
bareSku = storeSkuSyncInfo2Bare(sku)
@@ -548,7 +550,6 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
bareSku.Stock = 0
stockList = append(stockList, bareSku)
} else {
globals.SugarLogger.Debugf("==========deleteList := %s", utils.Format4Output(deleteList, false))
deleteList = append(deleteList, bareSku)
}
} else {
@@ -719,7 +720,6 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
switch step {
case 0:
if len(deleteList) > 0 {
globals.SugarLogger.Debugf("deleteList == := %s", utils.Format4Output(deleteList, false))
_, err = putils.FreeBatchStoreSkuInfo("删除门店商品", func(task tasksch.ITask, batchedStoreSkuList []*partner.StoreSkuInfo) (result interface{}, successCount int, err error) {
var failedList []*partner.StoreSkuInfoWithErr
if failedList, err = singleStoreHandler.DeleteStoreSkus(ctx, storeID, vendorStoreID, batchedStoreSkuList); err != nil {
@@ -1013,8 +1013,7 @@ func amendAndPruneStoreStuff(ctx *jxcontext.Context, parentTask tasksch.ITask, v
remoteSkuMap := make(map[string]int)
for _, v := range remoteSkuList {
if vendorSkuID := v.SkuList[0].VendorSkuID; vendorSkuID != "" {
if localSkuMap[vendorSkuID] == nil ||
remoteSkuMap[vendorSkuID] == 1 /*skuID在平台重复典型的是美团可能会出现此类情况*/ {
if localSkuMap[vendorSkuID] == nil || remoteSkuMap[vendorSkuID] == 1 /*skuID在平台重复典型的是美团可能会出现此类情况*/ {
sku2Delete = append(sku2Delete, &partner.StoreSkuInfo{
SkuID: v.SkuList[0].SkuID,
VendorSkuID: vendorSkuID,

View File

@@ -66,8 +66,6 @@ func (c *PurchaseHandler) OnAfsOrderMsg(msg *mtwmapi.CallbackMsg) (retVal *mtwma
func (c *PurchaseHandler) onAfsOrderMsg(msg *mtwmapi.CallbackMsg) (retVal *mtwmapi.CallbackResponse) {
var err error
orderStatus := c.callbackAfsMsg2Status(msg)
globals.SugarLogger.Debugf("=================msg := %s", utils.Format4Output(msg, false))
globals.SugarLogger.Debugf("=================orderStatus := %s", utils.Format4Output(orderStatus, false))
needCallNew := orderStatus.Status == model.AfsOrderStatusWait4Approve || orderStatus.Status == model.AfsOrderStatusNew
if !needCallNew {
_, err := partner.CurOrderManager.LoadAfsOrder(orderStatus.VendorOrderID, orderStatus.VendorID)
@@ -148,8 +146,6 @@ func (c *PurchaseHandler) onAfsOrderMsg(msg *mtwmapi.CallbackMsg) (retVal *mtwma
if orderStatus.Status == model.AfsOrderStatusFinished {
afsOrder.AfsFinishedAt = afsOrder.AfsCreatedAt
}
globals.SugarLogger.Debugf("afsOrder=============== : %s", utils.Format4Output(afsOrder, false))
globals.SugarLogger.Debugf("orderStatus=============== : %s", utils.Format4Output(orderStatus, false))
err = partner.CurOrderManager.OnAfsOrderNew(afsOrder, orderStatus)
}
} else {

View File

@@ -460,7 +460,6 @@ func getAppFoodCodeList(l []*mtwmapi.AppFoodResult) (vendorSkuIDs []string) {
}
func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
globals.SugarLogger.Debugf("deleteList == := %s", utils.Format4Output(storeSkuList, false))
if globals.EnableMtwmStoreWrite {
if len(storeSkuList) == 1 {
err = getAPI(storeSkuList[0].VendorOrgCode, storeID, vendorStoreID).RetailDelete(ctx.GetTrackInfo(), vendorStoreID, storeSkuList[0].VendorSkuID)

View File

@@ -239,7 +239,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.VendorID, params.VendorOrgCode, params.StoreID, storeMap)
retVal, err = cms.AddStoreVendorMap(params.Ctx, nil, params.VendorID, params.VendorOrgCode, params.StoreID, storeMap, true)
}
return retVal, "", err
})

View File

@@ -122,7 +122,7 @@ func (c *SyncController) FullSyncStoresSkus() {
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil {
return retVal, "", err
}
retVal, err = cms.CurVendorSync.FullSyncStoresSkus(params.Ctx, db, vendorIDs, storeIDs, true, nil, params.IsAsync, params.IsContinueWhenError)
retVal, err = cms.CurVendorSync.FullSyncStoresSkus(params.Ctx, db, vendorIDs, storeIDs, true, nil, params.IsAsync, params.IsContinueWhenError, false)
return retVal, "", err
})
}