- 修复UpdateOrCreateCourierStores中快递门店不存在时的BUG
This commit is contained in:
@@ -1074,7 +1074,7 @@ func updateCourierStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (
|
||||
|
||||
if handlerInfo := partner.GetDeliveryPlatformFromVendorID(storeDetail.VendorID); handlerInfo != nil && handlerInfo.Use4CreateWaybill {
|
||||
if updateHandler, ok := handlerInfo.Handler.(partner.IDeliveryUpdateStoreHandler); ok {
|
||||
storeDetail.CourierStoreName = composeDadaStoreName(storeDetail)
|
||||
storeDetail.CourierStoreName = composeCourierStoreName(storeDetail)
|
||||
err = updateHandler.UpdateStore(ctx, storeDetail)
|
||||
}
|
||||
}
|
||||
@@ -1110,9 +1110,9 @@ func updateOrCreateCourierStore(ctx *jxcontext.Context, storeDetail *dao.StoreDe
|
||||
if storeDetail.CityName == "" {
|
||||
return false, fmt.Errorf("门店的城市码有问题,请检查")
|
||||
}
|
||||
storeDetail.CourierStoreName = composeDadaStoreName(storeDetail)
|
||||
storeDetail.CourierStoreName = composeCourierStoreName(storeDetail)
|
||||
if _, err = handlerInfo.Handler.GetStore(ctx, 0, storeDetail.VendorStoreID); err != nil {
|
||||
if !handlerInfo.Handler.IsErrStoreNotExist(err) {
|
||||
if handlerInfo.Handler.IsErrStoreNotExist(err) {
|
||||
storeDetail.VendorStoreID, storeDetail.AuditStatus, err = handlerInfo.Handler.CreateStore(ctx, storeDetail)
|
||||
isCreated = true
|
||||
}
|
||||
@@ -1125,7 +1125,7 @@ func updateOrCreateCourierStore(ctx *jxcontext.Context, storeDetail *dao.StoreDe
|
||||
}
|
||||
if err != nil {
|
||||
err = fmt.Errorf("门店ID:%d,门店名:%s,错误描述:%s", storeDetail.Store.ID, storeDetail.Name, err.Error())
|
||||
globals.SugarLogger.Debugf("updateOrCreateDadaStore storeID:%d failed with error:%v", storeDetail.ID, err)
|
||||
globals.SugarLogger.Debugf("updateOrCreateCourierStore storeID:%d failed with error:%v", storeDetail.ID, err)
|
||||
}
|
||||
}
|
||||
return isCreated, err
|
||||
@@ -1153,15 +1153,17 @@ func UpdateOrCreateCourierStores(ctx *jxcontext.Context, storeID int, isForceUpd
|
||||
storeID := batchItemList[0].(int)
|
||||
errList := errlist.New()
|
||||
db := dao.GetDB()
|
||||
for k, v := range partner.DeliveryPlatformHandlers {
|
||||
for vendorID, v := range partner.DeliveryPlatformHandlers {
|
||||
if v.Use4CreateWaybill {
|
||||
if _, ok := v.Handler.(partner.IDeliveryUpdateStoreHandler); ok {
|
||||
storeDetail, err2 := dao.GetStoreDetail2(db, storeID, "", k)
|
||||
storeDetail, err2 := dao.GetStoreDetail2(db, storeID, "", vendorID)
|
||||
if err = err2; err2 == nil {
|
||||
isStoreExist := storeDetail.VendorStoreID != ""
|
||||
storeDetail.VendorStoreID = utils.Int2Str(storeDetail.ID)
|
||||
if isForceUpdate || !isStoreExist {
|
||||
if isForceUpdate || storeDetail.VendorStoreID == "" {
|
||||
var isCreated bool
|
||||
if storeDetail.VendorStoreID == "" {
|
||||
storeDetail.VendorID = vendorID
|
||||
storeDetail.VendorStoreID = utils.Int2Str(storeDetail.ID)
|
||||
}
|
||||
if isCreated, err = updateOrCreateCourierStore(ctx, storeDetail); err == nil && isCreated {
|
||||
storeCourier := &model.StoreCourierMap{
|
||||
VendorStoreID: storeDetail.VendorStoreID,
|
||||
@@ -1195,7 +1197,7 @@ func UpdateOrCreateCourierStores(ctx *jxcontext.Context, storeID int, isForceUpd
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func composeDadaStoreName(storeDetail *dao.StoreDetail2) (storeName string) {
|
||||
func composeCourierStoreName(storeDetail *dao.StoreDetail2) (storeName string) {
|
||||
return storeDetail.Name + "-" + storeDetail.VendorStoreID
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user