pc充值品牌余额

This commit is contained in:
suyl
2021-08-31 15:23:10 +08:00
parent 5a658dd646
commit 48125eeb41
9 changed files with 109 additions and 12 deletions

View File

@@ -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
}

View File

@@ -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()
}