配送和发消息品牌余额限制
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)
|
storeDetail, _ := dao.GetStoreDetail(dao.GetDB(), jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, order.VendorOrgCode)
|
||||||
|
balance, _ := partner.CurStoreAcctManager.GetBrandBalance(storeDetail.BrandID)
|
||||||
handlerInfo := partner.GetDeliveryPlatformFromVendorID(platformVendorID)
|
handlerInfo := partner.GetDeliveryPlatformFromVendorID(platformVendorID)
|
||||||
if handlerInfo != nil && handlerInfo.Use4CreateWaybill {
|
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 {
|
if c.IsReallyCallPlatformAPI {
|
||||||
bill, err = handlerInfo.Handler.CreateWaybill(order, maxDeliveryFee)
|
bill, err = handlerInfo.Handler.CreateWaybill(order, maxDeliveryFee)
|
||||||
if err != nil {
|
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) {
|
func (s *DefScheduler) updateBrandAccount(store *dao.StoreDetail, bill *model.Waybill) {
|
||||||
realDesiredFee := bill.DesiredFee
|
realDesiredFee := bill.DesiredFee
|
||||||
if balance, err := partner.CurStoreAcctManager.GetBrandBalance(store.BrandID); err == nil {
|
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,
|
OrderID: orderID,
|
||||||
}
|
}
|
||||||
dao.WrapAddIDCULEntity(brandBill, ctx.GetUserName())
|
dao.WrapAddIDCULEntity(brandBill, ctx.GetUserName())
|
||||||
dao.CreateEntity(db, brandBill)
|
err = dao.CreateEntity(db, brandBill)
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package smsmsg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/partner"
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
aliyunsmsclient "github.com/KenmyZhang/aliyun-communicate"
|
aliyunsmsclient "github.com/KenmyZhang/aliyun-communicate"
|
||||||
dyvmsapiclient "github.com/alibabacloud-go/dyvmsapi-20170525-2.0.2/client"
|
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 != "" {
|
if store.Tel2 != "" {
|
||||||
mobileList = append(mobileList, 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 {
|
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)
|
globals.SugarLogger.Debugf("NotifyPickOrder orderID: %s , smsNotify :%d", order.VendorOrderID, store.SMSNotify)
|
||||||
switch store.SMSNotify {
|
switch store.SMSNotify {
|
||||||
case model.NotifyTypeSMS:
|
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 {
|
if err = SendSMSMsg(mobileList, globals.SMSSignName, globals.SMSPickOrderTemplate, nil, order); err == nil {
|
||||||
order.NotifyType = int(store.SMSNotify)
|
err = updateSth(order, store, model.BrandBillFeeTypeSms)
|
||||||
partner.CurOrderManager.UpdateOrderFields(order, []string{"NotifyType"})
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
globals.SugarLogger.Debugf("NotifyPickOrder sms brand is close , orderID: %s ,isOpen: %d", order.VendorOrderID, store.BrandIsOpen)
|
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 == "" {
|
if store.MarketManPhone == "" {
|
||||||
store.MarketManPhone = "18048531223"
|
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{}{
|
if err = SendVoiceMsg(mobileList, map[string]interface{}{
|
||||||
"tel": store.MarketManPhone,
|
"tel": store.MarketManPhone,
|
||||||
}); err == nil {
|
}); err == nil {
|
||||||
order.NotifyType = int(store.SMSNotify)
|
err = updateSth(order, store, model.BrandBillFeeTypeVoice)
|
||||||
partner.CurOrderManager.UpdateOrderFields(order, []string{"NotifyType"})
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
globals.SugarLogger.Debugf("NotifyPickOrder voice brand is close , orderID: %s ,isOpen: %d", order.VendorOrderID, store.BrandIsOpen)
|
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 := `
|
sql := `
|
||||||
SELECT a.balance - b.balance balance
|
SELECT a.balance - b.balance balance
|
||||||
FROM (
|
FROM (
|
||||||
SELECT SUM(price) balance
|
SELECT IFNULL(SUM(price),0) balance
|
||||||
FROM brand_bill
|
FROM brand_bill
|
||||||
WHERE brand_id = ?
|
WHERE brand_id = ?
|
||||||
AND bill_type = ?
|
AND bill_type = ?
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ const (
|
|||||||
BrandOpenFN = 4 //蜂鸟
|
BrandOpenFN = 4 //蜂鸟
|
||||||
BrandOpenSMS = 8 //短信
|
BrandOpenSMS = 8 //短信
|
||||||
BrandOpenVoice = 16 //语音
|
BrandOpenVoice = 16 //语音
|
||||||
|
|
||||||
|
BrandBalanceLimit = 1000
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -45,4 +45,5 @@ type IStoreAcctManager interface {
|
|||||||
|
|
||||||
//品牌账户
|
//品牌账户
|
||||||
GetBrandBalance(brandID int) (balance int, err error)
|
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