aa
This commit is contained in:
@@ -5119,3 +5119,48 @@ func UpdateBrandUser(ctx *jxcontext.Context, brandID int, userID string, isDel b
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func UpdateOrCreateCourierStoresByBrand(ctx *jxcontext.Context, brandID, vendorID int) (hint string, err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
stores, _ := dao.GetStoreList(db, nil, nil, nil, []int{brandID}, nil, "")
|
||||
task := tasksch.NewParallelTask("UpdateOrCreateCourierStoresByBrand", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
var resultList []interface{}
|
||||
store := batchItemList[0].(*model.Store)
|
||||
errList := errlist.New()
|
||||
v := partner.GetDeliveryPlatformFromVendorID(vendorID)
|
||||
if v.Use4CreateWaybill {
|
||||
if _, ok := v.Handler.(partner.IDeliveryUpdateStoreHandler); ok {
|
||||
storeDetail, err2 := dao.GetStoreDetail2(db, store.ID, "", vendorID)
|
||||
if err = err2; err2 == nil {
|
||||
isNeedAdd := storeDetail.VendorStoreID == ""
|
||||
if isNeedAdd {
|
||||
storeDetail.VendorID = vendorID
|
||||
storeDetail.VendorStoreID = utils.Int2Str(storeDetail.ID)
|
||||
}
|
||||
if _, err = updateOrCreateCourierStore(ctx, storeDetail); err == nil && isNeedAdd {
|
||||
storeCourier := &model.StoreCourierMap{
|
||||
VendorStoreID: storeDetail.VendorStoreID,
|
||||
Status: model.StoreStatusOpened,
|
||||
AuditStatus: storeDetail.AuditStatus,
|
||||
VendorStoreName: storeDetail.Name,
|
||||
}
|
||||
if storeDetail.AuditStatus != model.StoreAuditStatusOnline {
|
||||
storeCourier.Status = model.StoreStatusDisabled
|
||||
}
|
||||
if _, err = addStoreCourierMap(ctx, db, storeDetail.ID, storeDetail.VendorID, storeCourier, false); err == nil {
|
||||
resultList = append(resultList, 1)
|
||||
}
|
||||
}
|
||||
errList.AddErr(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultList, errList.GetErrListAsOne()
|
||||
}, stores)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
hint = task.ID
|
||||
return hint, err
|
||||
}
|
||||
|
||||
@@ -126,23 +126,33 @@ func NotifyPickOrder(order *model.GoodsOrder) (err error) {
|
||||
mobileList = append(mobileList, store.Tel2)
|
||||
}
|
||||
if order.NotifyType == 0 && store.SMSNotify != 0 && store.IsOrder == model.NO && store.ID != model.MatterStoreID && store.ID != model.JdShopMainStoreID && len(mobileList) > 0 {
|
||||
globals.SugarLogger.Debugf("NotifyPickOrder orderID: %s , smsNotify :%d", order.VendorOrderID, store.SMSNotify)
|
||||
switch store.SMSNotify {
|
||||
case model.NotifyTypeSMS:
|
||||
err = SendSMSMsg(mobileList, globals.SMSSignName, globals.SMSPickOrderTemplate, nil, order)
|
||||
if store.BrandIsOpen&model.BrandOpenSMS != 0 {
|
||||
if err = SendSMSMsg(mobileList, globals.SMSSignName, globals.SMSPickOrderTemplate, nil, order); err == nil {
|
||||
order.NotifyType = int(store.SMSNotify)
|
||||
partner.CurOrderManager.UpdateOrderFields(order, []string{"NotifyType"})
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Debugf("NotifyPickOrder sms brand is close , orderID: %s ,isOpen: %d", order.VendorOrderID, store.BrandIsOpen)
|
||||
}
|
||||
case model.NotifyTypeVoice:
|
||||
globals.SugarLogger.Debugf("NotifyPickOrder orderID: %s , smsNotify :%d", order.VendorOrderID, store.SMSNotify)
|
||||
if store.MarketManPhone == "" {
|
||||
store.MarketManPhone = "18048531223"
|
||||
}
|
||||
err = SendVoiceMsg(mobileList, map[string]interface{}{
|
||||
"tel": store.MarketManPhone,
|
||||
})
|
||||
if store.BrandIsOpen&model.BrandOpenVoice != 0 {
|
||||
if err = SendVoiceMsg(mobileList, map[string]interface{}{
|
||||
"tel": store.MarketManPhone,
|
||||
}); err == nil {
|
||||
order.NotifyType = int(store.SMSNotify)
|
||||
partner.CurOrderManager.UpdateOrderFields(order, []string{"NotifyType"})
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Debugf("NotifyPickOrder voice brand is close , orderID: %s ,isOpen: %d", order.VendorOrderID, store.BrandIsOpen)
|
||||
}
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
order.NotifyType = int(store.SMSNotify)
|
||||
partner.CurOrderManager.UpdateOrderFields(order, []string{"NotifyType"})
|
||||
}
|
||||
//}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -27,6 +27,12 @@ const (
|
||||
BrandBillFeeTypeSms = 3 //短信费用
|
||||
BrandBillFeeTypeVoice = 4 //语音费用
|
||||
BrandBillFeeTypeDelivery = 5 //三方配送费
|
||||
|
||||
BrandOpenMTPS = 1 //品牌开关标志, 美团配送
|
||||
BrandOpenDaDa = 2 //达达
|
||||
BrandOpenFN = 4 //蜂鸟
|
||||
BrandOpenSMS = 8 //短信
|
||||
BrandOpenVoice = 16 //语音
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -1195,3 +1195,18 @@ func (c *StoreController) UpdateBrandUser() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 根据品牌自动创建或更新快递门店
|
||||
// @Description 根据品牌自动创建或更新快递门店
|
||||
// @Param token header string true "认证token"
|
||||
// @Param brandID formData int true "品牌ID"
|
||||
// @Param vendorID formData int true "平台ID"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /UpdateOrCreateCourierStoresByBrand [post]
|
||||
func (c *StoreController) UpdateOrCreateCourierStoresByBrand() {
|
||||
c.callUpdateOrCreateCourierStoresByBrand(func(params *tStoreUpdateOrCreateCourierStoresByBrandParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = cms.UpdateOrCreateCourierStoresByBrand(params.Ctx, params.BrandID, params.VendorID)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2178,6 +2178,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||
web.ControllerComments{
|
||||
Method: "UpdateOrCreateCourierStoresByBrand",
|
||||
Router: `/UpdateOrCreateCourierStoresByBrand`,
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||
web.ControllerComments{
|
||||
Method: "AddStoreCategoryMap",
|
||||
|
||||
Reference in New Issue
Block a user