aa
This commit is contained in:
@@ -27,12 +27,12 @@ func InitStoreAcctManager(curStoreManager IStoreAcctManager) {
|
||||
|
||||
type IStoreAcctManager interface {
|
||||
//增加一条收入流水
|
||||
InsertStoreAcctIncome(ctx *jxcontext.Context, db *dao.DaoDB, storeID, price, acctType int) (err error)
|
||||
InsertStoreAcctIncome(ctx *jxcontext.Context, db *dao.DaoDB, storeID, price, acctType int, vendorOrderID string) (err error)
|
||||
//增加一条支出流水
|
||||
InsertStoreAcctExpend(ctx *jxcontext.Context, db *dao.DaoDB, storeID, price, acctType int, vendorOrderID string) (err error)
|
||||
//更新门店账户
|
||||
UpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price int, isIncome bool) (err error)
|
||||
InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string) (err error)
|
||||
InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int) (err error)
|
||||
InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string) (err error)
|
||||
CheckStoreAcctExpendExist(storeID, acctType int, vendorOrderID string) (result bool, err error)
|
||||
}
|
||||
|
||||
@@ -388,6 +388,21 @@ func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType
|
||||
dao.UpdateEntity(db, userMemberOrigin, "EndAt")
|
||||
}
|
||||
}
|
||||
case model.PayTypeTL_StoreAcctPay:
|
||||
storeOrder := &model.StoreAcctOrder{
|
||||
VendorOrderID: vendorOrderID,
|
||||
}
|
||||
if err = dao.GetEntity(db, storeOrder, "VendorOrderID"); err == nil && storeOrder.ID != 0 {
|
||||
order = &model.GoodsOrder{
|
||||
VendorOrderID: vendorOrderID,
|
||||
ActualPayPrice: int64(storeOrder.ActualPayPrice),
|
||||
VendorID: model.VendorIDJX,
|
||||
}
|
||||
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType); err == nil && orderPay != nil {
|
||||
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
|
||||
err = dao.CreateEntity(dao.GetDB(), orderPay)
|
||||
}
|
||||
}
|
||||
default:
|
||||
err = fmt.Errorf("支付方式:%d当前不支持", payType)
|
||||
}
|
||||
@@ -543,6 +558,17 @@ func OnPayFinished(orderPay *model.OrderPay) (err error) {
|
||||
dao.UpdateEntity(dao.GetDB(), userMembers[0], "IsPay")
|
||||
err = nil
|
||||
}
|
||||
case model.PayTypeTL_StoreAcctPay: //门店账户充值完成后直接入账
|
||||
storeOrder := &model.StoreAcctOrder{
|
||||
VendorOrderID: orderPay.VendorOrderID,
|
||||
}
|
||||
if err = dao.GetEntity(dao.GetDB(), storeOrder, "VendorOrderID"); err == nil && storeOrder.ID != 0 {
|
||||
storeOrder.OrderFinishedAt = time.Now()
|
||||
storeOrder.Status = model.OrderStatusFinished
|
||||
if _, err = dao.UpdateEntity(dao.GetDB(), storeOrder, "OrderFinishedAt", "Status"); err == nil {
|
||||
partner.CurStoreAcctManager.InsertStoreAcctIncomeAndUpdateStoreAcctBalance(nil, storeOrder.StoreID, storeOrder.ActualPayPrice, partner.StoreAcctTypeIncomePay, 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 {
|
||||
@@ -2443,16 +2469,16 @@ func CreateStoreAcctOrder(ctx *jxcontext.Context, orderType, storeID, price int)
|
||||
dao.CreateEntity(db, storeAcct)
|
||||
}
|
||||
|
||||
order := &model.GoodsOrder{
|
||||
order := &model.StoreAcctOrder{
|
||||
VendorOrderID: utils.Int64ToStr(jxutils.GenOrderNo()),
|
||||
UserID: ctx.GetUserID(),
|
||||
StoreID: storeID,
|
||||
OrderType: orderType,
|
||||
Status: model.OrderStatusWait4Pay,
|
||||
ActualPayPrice: int64(price),
|
||||
OrderCreatedAt: time.Now(),
|
||||
ActualPayPrice: price,
|
||||
VendorID: model.VendorIDJX,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(order, ctx.GetUserName())
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
|
||||
Reference in New Issue
Block a user