From d2c1998dc8c1772c860fcdded4b7f12913669976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Tue, 23 Feb 2021 16:06:15 +0800 Subject: [PATCH] aa --- business/jxstore/cms/store.go | 16 +++++++++++---- business/jxstore/cms/storeman.go | 9 +++++++-- business/model/store.go | 2 ++ business/partner/delivery/mtps/store.go | 27 +++++++++++++++++-------- business/partner/partner.go | 2 +- 5 files changed, 41 insertions(+), 15 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 16f76fba7..c61562893 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -1638,6 +1638,13 @@ func GetStoreCourierMaps(ctx *jxcontext.Context, db *dao.DaoDB, storeID int, ven } } } + handler := partner.GetDeliveryPlatformFromVendorID(vendorID).Handler + storeDetail, _ := handler.GetStore(ctx, storeID, "") + for _, v := range storeCourierMaps { + if v.VendorStoreName == "" { + v.VendorStoreName = storeDetail.Name + } + } return storeCourierMaps, err } @@ -1853,9 +1860,10 @@ func UpdateOrCreateCourierStores(ctx *jxcontext.Context, storeID int, isForceUpd } if _, err = updateOrCreateCourierStore(ctx, storeDetail); err == nil && isNeedAdd { storeCourier := &model.StoreCourierMap{ - VendorStoreID: storeDetail.VendorStoreID, - Status: model.StoreStatusOpened, - AuditStatus: storeDetail.AuditStatus, + VendorStoreID: storeDetail.VendorStoreID, + Status: model.StoreStatusOpened, + AuditStatus: storeDetail.AuditStatus, + VendorStoreName: storeDetail.Name, } if storeDetail.AuditStatus != model.StoreAuditStatusOnline { storeCourier.Status = model.StoreStatusDisabled @@ -2506,7 +2514,7 @@ func SyncStoresCourierInfo(ctx *jxcontext.Context, storeIDs []int, isAsync, isCo storeCourier, err2 := handler.Handler.GetStore(ctx, store.ID, storeDetail2.VendorStoreID) if err = err2; err == nil { if storeDetail2.AuditStatus == model.StoreAuditStatusCreated { // 如果已经通过审核,更新本地状态 - partner.CurStoreManager.OnCourierStoreStatusChanged(ctx, storeCourier.VendorStoreID, vendorID, storeCourier.AuditStatus) + partner.CurStoreManager.OnCourierStoreStatusChanged(ctx, storeCourier.VendorStoreID, vendorID, storeCourier.AuditStatus, storeCourier.Comment) } distance := jxutils.EarthDistance(jxutils.IntCoordinate2Standard(store.Lng), jxutils.IntCoordinate2Standard(store.Lat), jxutils.IntCoordinate2Standard(storeCourier.Lng), jxutils.IntCoordinate2Standard(storeCourier.Lat)) diff --git a/business/jxstore/cms/storeman.go b/business/jxstore/cms/storeman.go index 4a527d374..ee78ab8de 100644 --- a/business/jxstore/cms/storeman.go +++ b/business/jxstore/cms/storeman.go @@ -102,18 +102,23 @@ func (s *StoreManager) OnStoreStatusChanged(vendorStoreID string, vendorID int, return err } -func (s *StoreManager) OnCourierStoreStatusChanged(ctx *jxcontext.Context, vendorStoreID string, vendorID int, auditStatus int) (err error) { +func (s *StoreManager) OnCourierStoreStatusChanged(ctx *jxcontext.Context, vendorStoreID string, vendorID int, auditStatus int, message string) (err error) { if vendorStoreID != "" { db := dao.GetDB() _, err2 := dao.GetStoreDetail2(db, 0, vendorStoreID, vendorID) if err = err2; err == nil { status := model.StoreStatusOpened - if auditStatus != model.StoreAuditStatusOnline { + if auditStatus != model.StoreAuditStatusOnline && auditStatus != model.StoreAuditStatusUpdated { status = model.StoreStatusDisabled } + comment := "" + if auditStatus == model.StoreAuditStatusRejected { + comment = message + } _, err = dao.UpdateEntityLogically(db, &model.StoreCourierMap{}, map[string]interface{}{ model.FieldStatus: status, "AuditStatus": auditStatus, + "Comment": comment, }, ctx.GetUserName(), map[string]interface{}{ model.FieldVendorStoreID: vendorStoreID, model.FieldVendorID: vendorID, diff --git a/business/model/store.go b/business/model/store.go index 0c68e82f3..bcc5f3371 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -22,6 +22,7 @@ const ( StoreAuditStatusCreated = 1 StoreAuditStatusOnline = 0 StoreAuditStatusRejected = -1 + StoreAuditStatusUpdated = 2 StoreAuditStatusAll = -9 ) @@ -475,6 +476,7 @@ type StoreCourierMap struct { AuditStatus int `json:"auditStatus"` VendorStatus int `json:"vendorStatus"` VendorStoreName string `orm:"size(255)" json:"vendorStoreName"` //平台门店名,由京西到平台 + Comment string `orm:"size(255)" json:"comment"` // 以下数据仅用于同步使用 Lng int `json:"-"` // 乘了10的6次方 diff --git a/business/partner/delivery/mtps/store.go b/business/partner/delivery/mtps/store.go index 9664c736e..b3cf9aed1 100644 --- a/business/partner/delivery/mtps/store.go +++ b/business/partner/delivery/mtps/store.go @@ -18,10 +18,12 @@ const ( var ( auditStatusMap = map[int]int{ - mtpsapi.ShopStatusAuditCreated: model.StoreAuditStatusCreated, - mtpsapi.ShopStatusAuditRejected: model.StoreAuditStatusRejected, - mtpsapi.ShopStatusAuditPassed: model.StoreAuditStatusCreated, - mtpsapi.ShopStatusAuditOnline: model.StoreAuditStatusOnline, + mtpsapi.ShopStatusAuditCreated: model.StoreAuditStatusCreated, + mtpsapi.ShopStatusAuditRejected: model.StoreAuditStatusRejected, + mtpsapi.ShopStatusAuditPassed: model.StoreAuditStatusCreated, + mtpsapi.ShopStatusAuditOnline: model.StoreAuditStatusOnline, + mtpsapi.ShopStatusAuditUpdatePassed: model.StoreAuditStatusUpdated, + mtpsapi.ShopStatusAuditUpdateRejected: model.StoreAuditStatusRejected, } ) @@ -38,7 +40,7 @@ func OnStoreStatus(msg *mtpsapi.CallbackShopStatusMsg) (retVal *mtpsapi.Callback func (c *DeliveryHandler) OnStoreStatus(msg *mtpsapi.CallbackShopStatusMsg) (retVal *mtpsapi.CallbackResponse) { globals.SugarLogger.Debugf("mtps OnStoreStatus, msg:%s", utils.Format4Output(msg, true)) - err := partner.CurStoreManager.OnCourierStoreStatusChanged(jxcontext.AdminCtx, msg.ShopID, model.VendorIDMTPS, getAuditStatus(msg.Status)) + err := partner.CurStoreManager.OnCourierStoreStatusChanged(jxcontext.AdminCtx, msg.ShopID, model.VendorIDMTPS, getAuditStatus(msg.Status), msg.RejectMessage) retVal = mtpsapi.Err2CallbackResponse(err, "mtps OnStoreStatus") return retVal } @@ -134,8 +136,17 @@ func (c *DeliveryHandler) IsErrStoreExist(err error) bool { } func (c *DeliveryHandler) UpdateStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (err error) { - // if globals.EnableStoreWrite { - // err = api.MtpsAPI.PagePoiUpdate(storeDetail.VendorStoreID, storeDetail.PayeeName, storeDetail.Tel1, fakeContactEmail) - // } + if globals.EnableStoreWrite { + // err = api.MtpsAPI.PagePoiUpdate(storeDetail.VendorStoreID, storeDetail.PayeeName, storeDetail.Tel1, fakeContactEmail) + shopInfo := &mtpsapi.ShopInfo{ + ShopID: utils.Int2Str(storeDetail.ID), + ContactName: storeDetail.PayeeName, + ContactPhone: storeDetail.Tel1, + ShopAddress: storeDetail.Address, + ShopLat: storeDetail.Lat, + ShopLng: storeDetail.Lng, + } + _, err = api.MtpsAPI.ShopUpdate(shopInfo) + } return err } diff --git a/business/partner/partner.go b/business/partner/partner.go index e0677d85c..8106abe66 100644 --- a/business/partner/partner.go +++ b/business/partner/partner.go @@ -129,7 +129,7 @@ type IOrderManager interface { type IStoreManager interface { OnStoreStatusChanged(vendorStoreID string, vendorID int, storeStatus int) (err error) - OnCourierStoreStatusChanged(ctx *jxcontext.Context, vendorStoreID string, vendorID int, auditStatus int) (err error) + OnCourierStoreStatusChanged(ctx *jxcontext.Context, vendorStoreID string, vendorID int, auditStatus int, message string) (err error) } // purchase handler中