- 在创建快递门店时,处理PayeeName为空的情况
This commit is contained in:
@@ -989,7 +989,6 @@ func AddStoreCourierMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID
|
|||||||
func addStoreCourierMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID int, storeCourierMap *model.StoreCourierMap, isNeedUpdateRemote bool) (outStoreCourierMap *model.StoreCourierMap, err error) {
|
func addStoreCourierMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID int, storeCourierMap *model.StoreCourierMap, isNeedUpdateRemote bool) (outStoreCourierMap *model.StoreCourierMap, err error) {
|
||||||
globals.SugarLogger.Debugf("addStoreCourierMap %s, storeID:%d, isNeedUpdateRemote:%t", model.VendorChineseNames[vendorID], storeCourierMap, isNeedUpdateRemote)
|
globals.SugarLogger.Debugf("addStoreCourierMap %s, storeID:%d, isNeedUpdateRemote:%t", model.VendorChineseNames[vendorID], storeCourierMap, isNeedUpdateRemote)
|
||||||
|
|
||||||
userName := ctx.GetUserName()
|
|
||||||
if handler := partner.GetDeliveryPlatformFromVendorID(vendorID); handler != nil {
|
if handler := partner.GetDeliveryPlatformFromVendorID(vendorID); handler != nil {
|
||||||
if db == nil {
|
if db == nil {
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
@@ -999,31 +998,21 @@ func addStoreCourierMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID
|
|||||||
if err = err2; err != nil {
|
if err = err2; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if storeDetail.VendorStoreID != "" && storeDetail.VendorStoreID != storeCourierMap.VendorStoreID {
|
if storeDetail.VendorStoreID != "" {
|
||||||
return nil, fmt.Errorf("门店已经绑定了%s, ID:%s, 如需重新绑定, 请先解绑", model.VendorChineseNames[vendorID], storeDetail.VendorStoreID)
|
return nil, fmt.Errorf("门店已经绑定了%s, ID:%s, 如需重新绑定, 请先解绑", model.VendorChineseNames[vendorID], storeDetail.VendorStoreID)
|
||||||
}
|
}
|
||||||
dao.WrapAddIDCULDEntity(storeCourierMap, userName)
|
|
||||||
storeCourierMap.StoreID = storeID
|
|
||||||
storeCourierMap.VendorID = vendorID
|
|
||||||
storeDetail.VendorStoreID = storeCourierMap.VendorStoreID
|
storeDetail.VendorStoreID = storeCourierMap.VendorStoreID
|
||||||
if err = updateCourierStore(ctx, storeDetail); err != nil {
|
if err = updateCourierStore(ctx, storeDetail); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dao.Begin(db)
|
dao.WrapAddIDCULDEntity(storeCourierMap, ctx.GetUserName())
|
||||||
defer func() {
|
storeCourierMap.StoreID = storeID
|
||||||
if r := recover(); r != nil || err != nil {
|
storeCourierMap.VendorID = vendorID
|
||||||
dao.Rollback(db)
|
|
||||||
if r != nil {
|
|
||||||
panic(r)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
if err = dao.CreateEntity(db, storeCourierMap); err != nil {
|
if err = dao.CreateEntity(db, storeCourierMap); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
outStoreCourierMap = storeCourierMap
|
outStoreCourierMap = storeCourierMap
|
||||||
dao.Commit(db)
|
|
||||||
} else {
|
} else {
|
||||||
err = ErrCanNotFindVendor
|
err = ErrCanNotFindVendor
|
||||||
}
|
}
|
||||||
@@ -1074,8 +1063,7 @@ func updateCourierStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (
|
|||||||
|
|
||||||
if handlerInfo := partner.GetDeliveryPlatformFromVendorID(storeDetail.VendorID); handlerInfo != nil && handlerInfo.Use4CreateWaybill {
|
if handlerInfo := partner.GetDeliveryPlatformFromVendorID(storeDetail.VendorID); handlerInfo != nil && handlerInfo.Use4CreateWaybill {
|
||||||
if updateHandler, ok := handlerInfo.Handler.(partner.IDeliveryUpdateStoreHandler); ok {
|
if updateHandler, ok := handlerInfo.Handler.(partner.IDeliveryUpdateStoreHandler); ok {
|
||||||
storeDetail.CourierStoreName = composeCourierStoreName(storeDetail)
|
err = updateHandler.UpdateStore(ctx, formalizeStore4Courier(storeDetail))
|
||||||
err = updateHandler.UpdateStore(ctx, storeDetail)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
@@ -1110,12 +1098,14 @@ func updateOrCreateCourierStore(ctx *jxcontext.Context, storeDetail *dao.StoreDe
|
|||||||
if storeDetail.CityName == "" {
|
if storeDetail.CityName == "" {
|
||||||
return false, fmt.Errorf("门店的城市码有问题,请检查")
|
return false, fmt.Errorf("门店的城市码有问题,请检查")
|
||||||
}
|
}
|
||||||
storeDetail.CourierStoreName = composeCourierStoreName(storeDetail)
|
storeDetail = formalizeStore4Courier(storeDetail)
|
||||||
if _, err = handlerInfo.Handler.GetStore(ctx, 0, storeDetail.VendorStoreID); err != nil {
|
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)
|
storeDetail.VendorStoreID, storeDetail.AuditStatus, err = handlerInfo.Handler.CreateStore(ctx, storeDetail)
|
||||||
|
if err == nil {
|
||||||
isCreated = true
|
isCreated = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if updateHandler, _ := handlerInfo.Handler.(partner.IDeliveryUpdateStoreHandler); updateHandler != nil {
|
if updateHandler, _ := handlerInfo.Handler.(partner.IDeliveryUpdateStoreHandler); updateHandler != nil {
|
||||||
err = updateHandler.UpdateStore(ctx, storeDetail)
|
err = updateHandler.UpdateStore(ctx, storeDetail)
|
||||||
@@ -1183,7 +1173,7 @@ func UpdateOrCreateCourierStores(ctx *jxcontext.Context, storeID int, isForceUpd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resultList, err
|
return resultList, errList.GetErrListAsOne()
|
||||||
}, storeIDs)
|
}, storeIDs)
|
||||||
tasksch.HandleTask(task, nil, len(storeIDs) > 1).Run()
|
tasksch.HandleTask(task, nil, len(storeIDs) > 1).Run()
|
||||||
if !isAsync {
|
if !isAsync {
|
||||||
@@ -1197,8 +1187,14 @@ func UpdateOrCreateCourierStores(ctx *jxcontext.Context, storeID int, isForceUpd
|
|||||||
return hint, err
|
return hint, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func composeCourierStoreName(storeDetail *dao.StoreDetail2) (storeName string) {
|
func formalizeStore4Courier(storeDetail *dao.StoreDetail2) (newStoreDetail *dao.StoreDetail2) {
|
||||||
return storeDetail.Name + "-" + storeDetail.VendorStoreID
|
tmp := *storeDetail
|
||||||
|
newStoreDetail = &tmp
|
||||||
|
newStoreDetail.Name = storeDetail.Name + "-" + storeDetail.VendorStoreID
|
||||||
|
if newStoreDetail.PayeeName == "" {
|
||||||
|
newStoreDetail.PayeeName = "店主"
|
||||||
|
}
|
||||||
|
return newStoreDetail
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExportShopsHealthInfo(ctx *jxcontext.Context, vendorIDs, storeIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func ExportShopsHealthInfo(ctx *jxcontext.Context, vendorIDs, storeIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ type StoreDetail2 struct {
|
|||||||
CourierStatus int `json:"courierStatus"`
|
CourierStatus int `json:"courierStatus"`
|
||||||
AuditStatus int `json:"auditStatus"`
|
AuditStatus int `json:"auditStatus"`
|
||||||
|
|
||||||
CourierStoreName string `json:"courierStoreName"`
|
|
||||||
DistrictName string `json:"districtName"`
|
DistrictName string `json:"districtName"`
|
||||||
CityName string `json:"cityName"`
|
CityName string `json:"cityName"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,7 +131,8 @@ func StoreDetail2ShopInfo(storeDetail *dao.StoreDetail2) (shopInfo *dadaapi.Shop
|
|||||||
}
|
}
|
||||||
shopInfo = &dadaapi.ShopInfo{
|
shopInfo = &dadaapi.ShopInfo{
|
||||||
OriginShopID: storeDetail.VendorStoreID,
|
OriginShopID: storeDetail.VendorStoreID,
|
||||||
StationName: storeDetail.CourierStoreName,
|
StationName: storeDetail.Name,
|
||||||
|
Business: dadaapi.BusinessTypeConvStore, // 故意设置成这个的
|
||||||
CityName: cityName,
|
CityName: cityName,
|
||||||
AreaName: districtName,
|
AreaName: districtName,
|
||||||
StationAddress: storeDetail.Address,
|
StationAddress: storeDetail.Address,
|
||||||
@@ -165,6 +166,7 @@ func (c *DeliveryHandler) GetStore(ctx *jxcontext.Context, storeID int, vendorSt
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
storeDetail = &dao.StoreDetail2{
|
storeDetail = &dao.StoreDetail2{
|
||||||
Store: model.Store{
|
Store: model.Store{
|
||||||
|
Name: shopInfo.StationName,
|
||||||
Address: shopInfo.StationAddress,
|
Address: shopInfo.StationAddress,
|
||||||
Lng: jxutils.StandardCoordinate2Int(shopInfo.Lng),
|
Lng: jxutils.StandardCoordinate2Int(shopInfo.Lng),
|
||||||
Lat: jxutils.StandardCoordinate2Int(shopInfo.Lat),
|
Lat: jxutils.StandardCoordinate2Int(shopInfo.Lat),
|
||||||
@@ -173,7 +175,6 @@ func (c *DeliveryHandler) GetStore(ctx *jxcontext.Context, storeID int, vendorSt
|
|||||||
},
|
},
|
||||||
VendorID: model.VendorIDDada,
|
VendorID: model.VendorIDDada,
|
||||||
VendorStoreID: shopInfo.OriginShopID,
|
VendorStoreID: shopInfo.OriginShopID,
|
||||||
CourierStoreName: shopInfo.StationName,
|
|
||||||
CityName: shopInfo.CityName,
|
CityName: shopInfo.CityName,
|
||||||
DistrictName: shopInfo.AreaName,
|
DistrictName: shopInfo.AreaName,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func (c *DeliveryHandler) CreateStore(ctx *jxcontext.Context, storeDetail *dao.S
|
|||||||
}
|
}
|
||||||
shopInfo := &mtpsapi.ShopInfo{
|
shopInfo := &mtpsapi.ShopInfo{
|
||||||
ShopID: storeDetail.VendorStoreID,
|
ShopID: storeDetail.VendorStoreID,
|
||||||
ShopName: storeDetail.CourierStoreName,
|
ShopName: storeDetail.Name,
|
||||||
Category: mtpsapi.ShopCategoryFruit,
|
Category: mtpsapi.ShopCategoryFruit,
|
||||||
SecondCategory: mtpsapi.ShopCategoryFruitFruit,
|
SecondCategory: mtpsapi.ShopCategoryFruitFruit,
|
||||||
ContactName: storeDetail.PayeeName,
|
ContactName: storeDetail.PayeeName,
|
||||||
@@ -67,6 +67,7 @@ func (c *DeliveryHandler) GetStore(ctx *jxcontext.Context, storeID int, vendorSt
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
storeDetail = &dao.StoreDetail2{
|
storeDetail = &dao.StoreDetail2{
|
||||||
Store: model.Store{
|
Store: model.Store{
|
||||||
|
Name: shopInfo.ShopName,
|
||||||
CityCode: shopInfo.City,
|
CityCode: shopInfo.City,
|
||||||
PayeeName: shopInfo.ContactName,
|
PayeeName: shopInfo.ContactName,
|
||||||
Tel1: shopInfo.ContactPhone,
|
Tel1: shopInfo.ContactPhone,
|
||||||
@@ -76,7 +77,6 @@ func (c *DeliveryHandler) GetStore(ctx *jxcontext.Context, storeID int, vendorSt
|
|||||||
},
|
},
|
||||||
VendorID: model.VendorIDMTPS,
|
VendorID: model.VendorIDMTPS,
|
||||||
VendorStoreID: shopInfo.ShopID,
|
VendorStoreID: shopInfo.ShopID,
|
||||||
CourierStoreName: shopInfo.ShopName,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return storeDetail, err
|
return storeDetail, err
|
||||||
|
|||||||
Reference in New Issue
Block a user