配送和发消息品牌余额限制
This commit is contained in:
@@ -166,9 +166,10 @@ func (c *BaseScheduler) CreateWaybill(platformVendorID int, order *model.GoodsOr
|
||||
// }
|
||||
// }
|
||||
storeDetail, _ := dao.GetStoreDetail(dao.GetDB(), jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, order.VendorOrgCode)
|
||||
balance, _ := partner.CurStoreAcctManager.GetBrandBalance(storeDetail.BrandID)
|
||||
handlerInfo := partner.GetDeliveryPlatformFromVendorID(platformVendorID)
|
||||
if handlerInfo != nil && handlerInfo.Use4CreateWaybill {
|
||||
if model.DeliveryBrandMarkMap[platformVendorID]&storeDetail.BrandIsOpen != 0 {
|
||||
if model.DeliveryBrandMarkMap[platformVendorID]&storeDetail.BrandIsOpen != 0 && balance >= model.BrandBalanceLimit {
|
||||
if c.IsReallyCallPlatformAPI {
|
||||
bill, err = handlerInfo.Handler.CreateWaybill(order, maxDeliveryFee)
|
||||
if err != nil {
|
||||
|
||||
@@ -1371,7 +1371,7 @@ func (s *DefScheduler) updateStoreAccount(order *model.GoodsOrder, bill *model.W
|
||||
func (s *DefScheduler) updateBrandAccount(store *dao.StoreDetail, bill *model.Waybill) {
|
||||
realDesiredFee := bill.DesiredFee
|
||||
if balance, err := partner.CurStoreAcctManager.GetBrandBalance(store.BrandID); err == nil {
|
||||
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, store.BrandID, balance-int(realDesiredFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, bill.VendorOrderID, "")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ func (s *StoreAcctManager) InsertBrandBill(ctx *jxcontext.Context, brandID, pric
|
||||
OrderID: orderID,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(brandBill, ctx.GetUserName())
|
||||
dao.CreateEntity(db, brandBill)
|
||||
err = dao.CreateEntity(db, brandBill)
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package smsmsg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
aliyunsmsclient "github.com/KenmyZhang/aliyun-communicate"
|
||||
dyvmsapiclient "github.com/alibabacloud-go/dyvmsapi-20170525-2.0.2/client"
|
||||
@@ -125,14 +126,21 @@ func NotifyPickOrder(order *model.GoodsOrder) (err error) {
|
||||
if store.Tel2 != "" {
|
||||
mobileList = append(mobileList, store.Tel2)
|
||||
}
|
||||
updateSth := func(order *model.GoodsOrder, store *dao.StoreDetail, feeType int) (err error) {
|
||||
order.NotifyType = int(store.SMSNotify)
|
||||
err = partner.CurOrderManager.UpdateOrderFields(order, []string{"NotifyType"})
|
||||
//品牌余额, 一条5分
|
||||
err = partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, store.BrandID, 5, model.BrandBillTypeExpend, feeType, order.VendorOrderID, "")
|
||||
return err
|
||||
}
|
||||
balance, _ := partner.CurStoreAcctManager.GetBrandBalance(store.BrandID)
|
||||
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:
|
||||
if store.BrandIsOpen&model.BrandOpenSMS != 0 {
|
||||
if store.BrandIsOpen&model.BrandOpenSMS != 0 && balance >= model.BrandBalanceLimit {
|
||||
if err = SendSMSMsg(mobileList, globals.SMSSignName, globals.SMSPickOrderTemplate, nil, order); err == nil {
|
||||
order.NotifyType = int(store.SMSNotify)
|
||||
partner.CurOrderManager.UpdateOrderFields(order, []string{"NotifyType"})
|
||||
err = updateSth(order, store, model.BrandBillFeeTypeSms)
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Debugf("NotifyPickOrder sms brand is close , orderID: %s ,isOpen: %d", order.VendorOrderID, store.BrandIsOpen)
|
||||
@@ -141,12 +149,11 @@ func NotifyPickOrder(order *model.GoodsOrder) (err error) {
|
||||
if store.MarketManPhone == "" {
|
||||
store.MarketManPhone = "18048531223"
|
||||
}
|
||||
if store.BrandIsOpen&model.BrandOpenVoice != 0 {
|
||||
if store.BrandIsOpen&model.BrandOpenVoice != 0 && balance >= model.BrandBalanceLimit {
|
||||
if err = SendVoiceMsg(mobileList, map[string]interface{}{
|
||||
"tel": store.MarketManPhone,
|
||||
}); err == nil {
|
||||
order.NotifyType = int(store.SMSNotify)
|
||||
partner.CurOrderManager.UpdateOrderFields(order, []string{"NotifyType"})
|
||||
err = updateSth(order, store, model.BrandBillFeeTypeVoice)
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Debugf("NotifyPickOrder voice brand is close , orderID: %s ,isOpen: %d", order.VendorOrderID, store.BrandIsOpen)
|
||||
|
||||
@@ -1353,7 +1353,7 @@ func GetBrandBalance(db *DaoDB, brandID int) (result int, err error) {
|
||||
sql := `
|
||||
SELECT a.balance - b.balance balance
|
||||
FROM (
|
||||
SELECT SUM(price) balance
|
||||
SELECT IFNULL(SUM(price),0) balance
|
||||
FROM brand_bill
|
||||
WHERE brand_id = ?
|
||||
AND bill_type = ?
|
||||
|
||||
@@ -33,6 +33,8 @@ const (
|
||||
BrandOpenFN = 4 //蜂鸟
|
||||
BrandOpenSMS = 8 //短信
|
||||
BrandOpenVoice = 16 //语音
|
||||
|
||||
BrandBalanceLimit = 1000
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -45,4 +45,5 @@ type IStoreAcctManager interface {
|
||||
|
||||
//品牌账户
|
||||
GetBrandBalance(brandID int) (balance int, err error)
|
||||
InsertBrandBill(ctx *jxcontext.Context, brandID, price, billType, feeType int, vendorOrderID string, orderID string) (err error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user