1
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner/delivery/mtps"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
@@ -2215,6 +2216,24 @@ func updateCourierStores(ctx *jxcontext.Context, storeID int) (err error) {
|
|||||||
return errList.GetErrListAsOne()
|
return errList.GetErrListAsOne()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UpdateStoreName() error {
|
||||||
|
var db = dao.GetDB()
|
||||||
|
sql := ` SELECT * FROM store_courier_map WHERE vendor_id = ? AND deleted_at = ?`
|
||||||
|
data := make([]*model.StoreCourierMap, 0, 0)
|
||||||
|
if err := dao.GetRows(db, data, sql, []interface{}{model.VendorIDMTPS, utils.DefaultTimeValue}...); err != nil {
|
||||||
|
globals.SugarLogger.Debugf("query Order err := %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, v := range data {
|
||||||
|
storeDetail, _ := dao.GetStoreDetail2(db, v.StoreID, v.VendorStoreID, model.VendorIDMTPS)
|
||||||
|
formalizeStore4Courier(storeDetail)
|
||||||
|
err := mtps.UpdateStoreName(storeDetail.VendorStoreID, storeDetail.Name)
|
||||||
|
globals.SugarLogger.Debug("err := %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// ====================================第三方店铺创建=============================
|
// ====================================第三方店铺创建=============================
|
||||||
func updateOrCreateCourierStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (isCreated bool, err error) {
|
func updateOrCreateCourierStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (isCreated bool, err error) {
|
||||||
globals.SugarLogger.Debugf("updateOrCreateCourierStore %s, storeID:%d, vendorStoreID:%s", model.VendorChineseNames[storeDetail.VendorID], storeDetail.ID, storeDetail.VendorStoreID)
|
globals.SugarLogger.Debugf("updateOrCreateCourierStore %s, storeID:%d, vendorStoreID:%s", model.VendorChineseNames[storeDetail.VendorID], storeDetail.ID, storeDetail.VendorStoreID)
|
||||||
@@ -2329,7 +2348,13 @@ func UpdateOrCreateCourierStores(ctx *jxcontext.Context, storeID int, isForceUpd
|
|||||||
}
|
}
|
||||||
|
|
||||||
func formalizeStore4Courier(storeDetail *dao.StoreDetail2) *dao.StoreDetail2 {
|
func formalizeStore4Courier(storeDetail *dao.StoreDetail2) *dao.StoreDetail2 {
|
||||||
storeDetail.Name = fmt.Sprintf("%s-%s-%s", model.ShopChineseNames[model.VendorIDJD], storeDetail.CityName, storeDetail.Name)
|
// 获取品牌名称
|
||||||
|
brandInfo, err := dao.GetBrands(dao.GetDB(), "", storeDetail.BrandID, "", false, "")
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
storeDetail.Name = fmt.Sprintf("%s-%s-%s", brandInfo[0].Name, storeDetail.CityName, storeDetail.Name)
|
||||||
if storeDetail.PayeeName == "" {
|
if storeDetail.PayeeName == "" {
|
||||||
storeDetail.PayeeName = "店主"
|
storeDetail.PayeeName = "店主"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -221,13 +221,19 @@ func Init() {
|
|||||||
"04:00:00",
|
"04:00:00",
|
||||||
})
|
})
|
||||||
|
|
||||||
// 每天更新美团门当的结算信息和配送费等等
|
// 每天更新美团-门店结算方式[结算给企业/结算给个人]
|
||||||
ScheduleTimerFunc("LoadingStoreOrderSettleAmount", func() {
|
ScheduleTimerFunc("LoadingStoreOrderSettleAmount", func() {
|
||||||
delivery.LoadingStoreOrderSettleAmount(0, 0, nil)
|
delivery.LoadingStoreOrderSettleAmount(0, 0, nil)
|
||||||
}, []string{
|
}, []string{
|
||||||
"19:50:00",
|
"19:50:00",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ScheduleTimerFunc("UpdateStoreName ", func() {
|
||||||
|
cms.UpdateStoreName()
|
||||||
|
}, []string{
|
||||||
|
"16:12:00",
|
||||||
|
})
|
||||||
|
|
||||||
// 定时任务更新昨天的都要商品和本地商品id的映射关系
|
// 定时任务更新昨天的都要商品和本地商品id的映射关系
|
||||||
//ScheduleTimerFunc("RefreshStoreOperator", func() {
|
//ScheduleTimerFunc("RefreshStoreOperator", func() {
|
||||||
// t := time.Now()
|
// t := time.Now()
|
||||||
|
|||||||
@@ -71,12 +71,7 @@ func (c *DeliveryHandler) CreateStore(ctx *jxcontext.Context, storeDetail *dao.S
|
|||||||
if shopInfo.ShopLat <= 9999999 {
|
if shopInfo.ShopLat <= 9999999 {
|
||||||
shopInfo.ShopLat *= 10
|
shopInfo.ShopLat *= 10
|
||||||
}
|
}
|
||||||
// 获取品牌名称
|
|
||||||
brandInfo, err := dao.GetBrands(dao.GetDB(), "", storeDetail.BrandID, "", false, "")
|
|
||||||
if err != nil {
|
|
||||||
return "", -1, err
|
|
||||||
}
|
|
||||||
shopInfo.ShopName = brandInfo[0].Name + "-" + storeDetail.Name
|
|
||||||
if globals.EnableStoreWrite {
|
if globals.EnableStoreWrite {
|
||||||
shopStatus, err = api.MtpsAPI.ShopCreate(shopInfo)
|
shopStatus, err = api.MtpsAPI.ShopCreate(shopInfo)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -187,3 +182,13 @@ func (c *DeliveryHandler) UpdateStore(ctx *jxcontext.Context, storeDetail *dao.S
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 美团配送,修改门店名称
|
||||||
|
func UpdateStoreName(storeId, name string) (err error) {
|
||||||
|
shopInfo := &mtpsapi.ShopInfo{
|
||||||
|
ShopID: storeId,
|
||||||
|
ShopName: name,
|
||||||
|
}
|
||||||
|
_, err = api.MtpsAPI.ShopUpdate(shopInfo)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
@@ -86,6 +86,17 @@ func (c *DeliveryHandler) OnWaybillExcept(msg *mtpsapi.CallbackOrderExceptionMsg
|
|||||||
|
|
||||||
func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *mtpsapi.CallbackResponse) {
|
func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *mtpsapi.CallbackResponse) {
|
||||||
order := c.callbackMsg2Waybill(msg)
|
order := c.callbackMsg2Waybill(msg)
|
||||||
|
// 多次取消,只处理第一次
|
||||||
|
if msg.Status == mtpsapi.OrderStatusCanceled {
|
||||||
|
bill, err := partner.CurOrderManager.LoadWaybill(msg.MtPeisongID, model.VendorIDMTPS)
|
||||||
|
if err != nil {
|
||||||
|
return mtpsapi.Err2CallbackResponse(err, fmt.Sprintf("%s", "获取订单状态错误"))
|
||||||
|
}
|
||||||
|
if bill.Status == model.OrderStatusCanceled {
|
||||||
|
return mtpsapi.SuccessResponse
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch msg.Status {
|
switch msg.Status {
|
||||||
case mtpsapi.OrderStatusWaitingForSchedule:
|
case mtpsapi.OrderStatusWaitingForSchedule:
|
||||||
data, err := api.MtpsAPI.QueryOrderStatus(msg.DeliveryID, msg.MtPeisongID)
|
data, err := api.MtpsAPI.QueryOrderStatus(msg.DeliveryID, msg.MtPeisongID)
|
||||||
|
|||||||
Reference in New Issue
Block a user