pc充值品牌余额
This commit is contained in:
@@ -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, "")
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, store.BrandID, balance-int(realDesiredFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, bill.VendorOrderID)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ func (s *StoreAcctManager) GetBrandBalance(brandID int) (balance int, err error)
|
||||
return dao.GetBrandBalance(dao.GetDB(), brandID)
|
||||
}
|
||||
|
||||
func (s *StoreAcctManager) InsertBrandBill(ctx *jxcontext.Context, brandID, price, billType, feeType int, vendorOrderID string, orderID string) (err error) {
|
||||
func (s *StoreAcctManager) InsertBrandBill(ctx *jxcontext.Context, brandID, price, billType, feeType int, vendorOrderID string) (err error) {
|
||||
utils.CallFuncAsync(func() {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
@@ -197,7 +197,6 @@ func (s *StoreAcctManager) InsertBrandBill(ctx *jxcontext.Context, brandID, pric
|
||||
BillType: billType,
|
||||
FeeType: feeType,
|
||||
VendorOrderID: vendorOrderID,
|
||||
OrderID: orderID,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(brandBill, ctx.GetUserName())
|
||||
//扣除后,如果余额小于10元要发消息通知 ,每天通知一次
|
||||
|
||||
@@ -131,7 +131,7 @@ func NotifyPickOrder(order *model.GoodsOrder) (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, "")
|
||||
err = partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, store.BrandID, 5, model.BrandBillTypeExpend, feeType, order.VendorOrderID)
|
||||
return err
|
||||
}
|
||||
balance, _ := partner.CurStoreAcctManager.GetBrandBalance(store.BrandID)
|
||||
@@ -338,7 +338,7 @@ func NotifyBrandBalance(brandID int) (err error) {
|
||||
err = api.Cacher.Set("brandID"+utils.Int2Str(brandID), 1, utils.Str2Time(time.Now().AddDate(0, 0, 1).Format("2006-01-02")+"00:00:00").Sub(time.Now()))
|
||||
}
|
||||
if count > 0 {
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, brandID, 5*count, model.BrandBillTypeExpend, model.BrandBillFeeTypeSys, "", "")
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, brandID, 5*count, model.BrandBillTypeExpend, model.BrandBillFeeTypeSys, "")
|
||||
}
|
||||
}
|
||||
return err
|
||||
|
||||
@@ -14,8 +14,9 @@ const (
|
||||
PayTypeWX = 1 // 微信支付
|
||||
PayTypeTL = 2 // 通联宝支付
|
||||
|
||||
PayTypeTL_DiscountCard = 3 // 通联宝支付(会员折扣卡)
|
||||
PayTypeTL_StoreAcctPay = 4 // 通联宝支付(门店账户充值)
|
||||
PayTypeTL_DiscountCard = 3 // 通联宝支付(会员折扣卡)
|
||||
PayTypeTL_StoreAcctPay = 4 // 通联宝支付(门店账户充值)
|
||||
PayTypeTL_BrandBillCharge = 5 //品牌账户充值(pc扫码支付)
|
||||
|
||||
PayStatusNo = 0
|
||||
PayStatusYes = 1
|
||||
@@ -41,6 +42,7 @@ const (
|
||||
OrderTypeSupplyGoods = 2 //进货订单
|
||||
OrderTypeDefendPrice = 3 //守价订单
|
||||
OrderTypeStoreAcct = 4 //门店账户订单
|
||||
OrderTypeBrand = 5 //品牌账户订单
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -513,6 +515,25 @@ func (v *StoreAcctOrder) TableUnique() [][]string {
|
||||
}
|
||||
}
|
||||
|
||||
type BrandOrder struct {
|
||||
ModelIDCUL
|
||||
|
||||
VendorOrderID string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"`
|
||||
BrandID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||
ActualPayPrice int `json:"actualPayPrice"` // 单位为分 顾客实际支付
|
||||
UserID string `orm:"column(user_id);size(48);index" json:"userID"`
|
||||
OrderType int `json:"orderType"`
|
||||
Status int `json:"status"` // 参见OrderStatus*相关的常量定义
|
||||
OrderFinishedAt time.Time `orm:"type(datetime)" json:"orderFinishedAt"`
|
||||
}
|
||||
|
||||
func (v *BrandOrder) TableIndex() [][]string {
|
||||
return [][]string{
|
||||
[]string{"VendorOrderID", "BrandID"},
|
||||
[]string{"CreatedAt"},
|
||||
}
|
||||
}
|
||||
|
||||
// 判断是否是购买平台自有物流
|
||||
// 对于京东,饿百来说,就是其自有的物流,对于微商城来说,是达达
|
||||
func IsWaybillPlatformOwn(bill *Waybill) bool {
|
||||
|
||||
@@ -45,5 +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)
|
||||
InsertBrandBill(ctx *jxcontext.Context, brandID, price, billType, feeType int, vendorOrderID string) (err error)
|
||||
}
|
||||
|
||||
@@ -406,6 +406,21 @@ func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType
|
||||
err = dao.CreateEntity(dao.GetDB(), orderPay)
|
||||
}
|
||||
}
|
||||
case model.PayTypeTL_BrandBillCharge:
|
||||
brandOrder := &model.BrandOrder{
|
||||
VendorOrderID: vendorOrderID,
|
||||
}
|
||||
if err = dao.GetEntity(db, brandOrder, "VendorOrderID"); err == nil && brandOrder.ID != 0 {
|
||||
order = &model.GoodsOrder{
|
||||
VendorOrderID: vendorOrderID,
|
||||
ActualPayPrice: int64(brandOrder.ActualPayPrice),
|
||||
VendorID: model.VendorIDJX,
|
||||
}
|
||||
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
|
||||
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
|
||||
err = dao.CreateEntity(dao.GetDB(), orderPay)
|
||||
}
|
||||
}
|
||||
default:
|
||||
err = fmt.Errorf("支付方式:%d当前不支持", payType)
|
||||
}
|
||||
@@ -572,6 +587,17 @@ func OnPayFinished(orderPay *model.OrderPay) (err error) {
|
||||
partner.CurStoreAcctManager.InsertStoreAcctIncomeAndUpdateStoreAcctBalance(nil, storeOrder.StoreID, storeOrder.ActualPayPrice, partner.StoreAcctTypeIncomePay, orderPay.VendorOrderID, 0)
|
||||
}
|
||||
}
|
||||
case model.PayTypeTL_BrandBillCharge:
|
||||
brandOrder := &model.BrandOrder{
|
||||
VendorOrderID: orderPay.VendorOrderID,
|
||||
}
|
||||
if err = dao.GetEntity(dao.GetDB(), brandOrder, "VendorOrderID"); err == nil && brandOrder.ID != 0 {
|
||||
brandOrder.OrderFinishedAt = time.Now()
|
||||
brandOrder.Status = model.OrderStatusFinished
|
||||
if _, err = dao.UpdateEntity(dao.GetDB(), brandOrder, "OrderFinishedAt", "Status"); err == nil {
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, brandOrder.BrandID, brandOrder.ActualPayPrice, model.BrandBillTypeIncome, model.BrandBillFeeTypeCharge, orderPay.VendorOrderID)
|
||||
}
|
||||
}
|
||||
default:
|
||||
priceDefendOrders, _ := dao.GetPriceDefendOrder(dao.GetDB(), orderPay.VendorOrderID, nil, nil, []int{jxutils.GetDefendPriceIssue()}, 0, -1, -1, 0, "", utils.ZeroTimeValue, utils.ZeroTimeValue, false)
|
||||
if len(priceDefendOrders) > 0 {
|
||||
@@ -2497,3 +2523,30 @@ func CreateStoreAcctOrder(ctx *jxcontext.Context, orderType, storeID, price int,
|
||||
dao.Commit(db, txDB)
|
||||
return order.VendorOrderID, err
|
||||
}
|
||||
|
||||
func CreateBrandOrder(ctx *jxcontext.Context, brandID, price int) (vendorOrderID string, err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
brandOrder := &model.BrandOrder{
|
||||
VendorOrderID: utils.Int64ToStr(jxutils.GenOrderNo()),
|
||||
UserID: ctx.GetUserID(),
|
||||
BrandID: brandID,
|
||||
OrderType: model.OrderTypeBrand,
|
||||
Status: model.OrderStatusWait4Pay,
|
||||
ActualPayPrice: price,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(brandOrder, ctx.GetUserName())
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
if err = dao.CreateEntity(db, brandOrder); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
}
|
||||
dao.Commit(db, txDB)
|
||||
return brandOrder.VendorOrderID, err
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, payType int,
|
||||
param.Acct = authInfo.GetAuthID()
|
||||
}
|
||||
}
|
||||
if vendorPayType == tonglianpayapi.PayTypeZfbJS || vendorPayType == tonglianpayapi.PayTypeZfbApp || vendorPayType == tonglianpayapi.PayTypeZfbQrcode {
|
||||
if vendorPayType == tonglianpayapi.PayTypeZfbJS || vendorPayType == tonglianpayapi.PayTypeZfbApp {
|
||||
if authInfo, err := ctx.GetV2AuthInfo(); err == nil {
|
||||
param.Acct = authInfo.GetAuthID()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user