aa
This commit is contained in:
@@ -20,27 +20,57 @@ func init() {
|
||||
partner.InitStoreAcctManager(FixedStoreAcctManager)
|
||||
}
|
||||
|
||||
func (s *StoreAcctManager) InsertStoreAcctIncome(ctx *jxcontext.Context, db *dao.DaoDB, storeID, price, acctType int) (err error) {
|
||||
func (s *StoreAcctManager) InsertStoreAcctIncome(ctx *jxcontext.Context, db *dao.DaoDB, storeID, price, acctType int, vendorOrderID string) (err error) {
|
||||
var (
|
||||
userID, userName string
|
||||
)
|
||||
if ctx != nil {
|
||||
userID = ctx.GetUserID()
|
||||
userName = ctx.GetUserName()
|
||||
} else {
|
||||
storeOrder := &model.StoreAcctOrder{
|
||||
VendorOrderID: vendorOrderID,
|
||||
}
|
||||
if err = dao.GetEntity(db, storeOrder, "VendorOrderID"); err == nil && storeOrder.ID != 0 {
|
||||
userID = storeOrder.UserID
|
||||
userName = storeOrder.LastOperator
|
||||
}
|
||||
}
|
||||
storeAcctIncome := &model.StoreAcctIncome{
|
||||
StoreID: storeID,
|
||||
IncomePrice: price,
|
||||
Type: acctType,
|
||||
UserID: ctx.GetUserID(),
|
||||
UserID: userID,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(storeAcctIncome, ctx.GetUserName())
|
||||
dao.WrapAddIDCULEntity(storeAcctIncome, userName)
|
||||
err = dao.CreateEntity(db, storeAcctIncome)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *StoreAcctManager) InsertStoreAcctExpend(ctx *jxcontext.Context, db *dao.DaoDB, storeID, price, acctType int, vendorOrderID string) (err error) {
|
||||
var (
|
||||
userID, userName string
|
||||
)
|
||||
if ctx != nil {
|
||||
userID = ctx.GetUserID()
|
||||
userName = ctx.GetUserName()
|
||||
} else {
|
||||
storeOrder := &model.StoreAcctOrder{
|
||||
VendorOrderID: vendorOrderID,
|
||||
}
|
||||
if err = dao.GetEntity(db, storeOrder, "VendorOrderID"); err == nil && storeOrder.ID != 0 {
|
||||
userID = storeOrder.UserID
|
||||
userName = storeOrder.LastOperator
|
||||
}
|
||||
}
|
||||
storeAcctExpend := &model.StoreAcctExpend{
|
||||
StoreID: storeID,
|
||||
ExpendPrice: price,
|
||||
Type: acctType,
|
||||
UserID: ctx.GetUserID(),
|
||||
UserID: userID,
|
||||
VendorOrderID: vendorOrderID,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(storeAcctExpend, ctx.GetUserName())
|
||||
dao.WrapAddIDCULEntity(storeAcctExpend, userName)
|
||||
err = dao.CreateEntity(db, storeAcctExpend)
|
||||
return err
|
||||
}
|
||||
@@ -49,6 +79,9 @@ func (s *StoreAcctManager) UpdateStoreAcctBalance(ctx *jxcontext.Context, storeI
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
if ctx == nil {
|
||||
ctx = jxcontext.AdminCtx
|
||||
}
|
||||
storeAcct := &model.StoreAcct{
|
||||
StoreID: storeID,
|
||||
}
|
||||
@@ -95,12 +128,12 @@ func (s *StoreAcctManager) InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx *j
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *StoreAcctManager) InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int) (err error) {
|
||||
func (s *StoreAcctManager) InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
utils.CallFuncAsync(func() {
|
||||
if err = s.InsertStoreAcctIncome(ctx, db, storeID, price, acctType); err == nil {
|
||||
if err = s.InsertStoreAcctIncome(ctx, db, storeID, price, acctType, vendorOrderID); err == nil {
|
||||
s.UpdateStoreAcctBalance(ctx, storeID, price, true)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user