|
@@ -3,6 +3,7 @@ package shanghu
|
|
|
import (
|
|
|
orm "duoduo/database"
|
|
|
"errors"
|
|
|
+ "fmt"
|
|
|
"github.com/shopspring/decimal"
|
|
|
"time"
|
|
|
)
|
|
@@ -56,6 +57,21 @@ func (m *MerchantAccount) ActiveCancelSettle(log []ActiveCancelLog, merchantAcco
|
|
|
var err error
|
|
|
var merchantAccountLog MerchantAccountLog
|
|
|
var clientAccountLog ActiveClientAccountLog
|
|
|
+ fmt.Println("merchantAccount =", merchantAccount)
|
|
|
+ fmt.Println("activeClientAccount =", activeClientAccount)
|
|
|
+
|
|
|
+ err = orm.ShMysql.Table("merchant_account").Select("*").Where("merchant_open_id = ?", merchantAccount.MerchantOpenID).First(&merchantAccount).Error
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+
|
|
|
+ err = orm.ShMysql.Table("active_client_account").Select("*").Where("client_open_id = ?", activeClientAccount.ClientOpenID).First(&activeClientAccount).Error
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+
|
|
|
+ fmt.Println("merchantAccount =", merchantAccount)
|
|
|
+ fmt.Println("activeClientAccount =", activeClientAccount)
|
|
|
|
|
|
tx := orm.ShMysql.Begin()
|
|
|
defer func() {
|
|
@@ -112,9 +128,9 @@ func (m *MerchantAccount) ActiveCancelSettle(log []ActiveCancelLog, merchantAcco
|
|
|
//}
|
|
|
|
|
|
// 客户加款
|
|
|
- if activeClientAccount.ID > 0 {
|
|
|
+ if payTrans.InvitationCode != YuanShiMa && payTrans.InvitationCode != "" {
|
|
|
clientAmountAdd := activeClientAccount.Amount.Add(payTrans.ClientAmount)
|
|
|
- clientResult := tx.Table("active_client_account").Model(&activeClientAccount).Where("client_open_id = ? and version = ?", merchantAccount.MerchantOpenID, merchantAccount.Version).Updates(
|
|
|
+ clientResult := tx.Table("active_client_account").Model(&activeClientAccount).Where("client_open_id = ? and version = ?", activeClientAccount.ClientOpenID, activeClientAccount.Version).Updates(
|
|
|
map[string]interface{}{
|
|
|
"amount": clientAmountAdd,
|
|
|
"version": activeClientAccount.Version + 1,
|
|
@@ -138,7 +154,7 @@ func (m *MerchantAccount) ActiveCancelSettle(log []ActiveCancelLog, merchantAcco
|
|
|
clientAccountLog.Amount = payTrans.ClientAmount
|
|
|
clientAccountLog.PayTransID = payTrans.ID
|
|
|
clientAccountLog.TransType = ActiveClientAccountLogTransTypeGroupBuy
|
|
|
- err = tx.Table("merchant_account_log").Create(&merchantAccountLog).Error
|
|
|
+ err = tx.Table("active_client_account_log").Create(&clientAccountLog).Error
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|