|
|
|
@ -2,11 +2,17 @@ package public
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"errors"
|
|
|
|
|
"fmt"
|
|
|
|
|
"git.oa00.com/go/mysql"
|
|
|
|
|
gorm2 "gorm.io/gorm"
|
|
|
|
|
"recook/internal/model/goods"
|
|
|
|
|
"recook/internal/model/order"
|
|
|
|
|
"recook/internal/model/user"
|
|
|
|
|
"recook/internal/service/app/shop"
|
|
|
|
|
jpush2 "recook/internal/v2/lib/jpush"
|
|
|
|
|
order2 "recook/internal/v2/logic/manage/order"
|
|
|
|
|
"recook/internal/v2/model/jpush"
|
|
|
|
|
"recook/internal/v2/model/jyy"
|
|
|
|
|
manage "recook/internal/v2/model/recook/order"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
@ -86,13 +92,55 @@ func PaySuccessCallback(tx *gorm.DB, orderInfo order.Information, completeTime f
|
|
|
|
|
} else {
|
|
|
|
|
// 虚拟订单用户升级
|
|
|
|
|
if orderInfo.SharerID != 0 && orderInfo.SharerID != orderInfo.UserID {
|
|
|
|
|
if err := tx.Create(order.CreateProfit(
|
|
|
|
|
profit := order.CreateProfit(
|
|
|
|
|
orderInfo.SharerID,
|
|
|
|
|
order.Card,
|
|
|
|
|
orderInfo.ActualTotalAmount,
|
|
|
|
|
orderInfo.ID, 2)).Error; err != nil {
|
|
|
|
|
orderInfo.ID, 2)
|
|
|
|
|
if err := tx.Create(&profit).Error; err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
if row := tx.Model(&user.Wallet{}).Where("user_id = ?", orderInfo.SharerID).Updates(map[string]interface{}{
|
|
|
|
|
"balance": gorm2.Expr("balance + ?", profit.Income),
|
|
|
|
|
"version": gorm2.Expr("version + 1"),
|
|
|
|
|
}).RowsAffected; row == 0 {
|
|
|
|
|
e := fmt.Errorf("网络异常")
|
|
|
|
|
return e
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
r1 := user.WalletBalanceList{
|
|
|
|
|
UserID: orderInfo.SharerID,
|
|
|
|
|
IncomeType: uint(10 + order.Card),
|
|
|
|
|
Amount: profit.Income,
|
|
|
|
|
Title: orderInfo.Title,
|
|
|
|
|
Comment: order.Card.GetStr(),
|
|
|
|
|
OrderID: orderInfo.ID,
|
|
|
|
|
OrderTime: orderInfo.CreatedAt,
|
|
|
|
|
CreatedAt: formatime.NewSecondNow(),
|
|
|
|
|
ProfitID: uint(profit.ID),
|
|
|
|
|
}
|
|
|
|
|
if e := tx.Create(&r1).Error; e != nil {
|
|
|
|
|
return e
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加收益记录
|
|
|
|
|
message := fmt.Sprintf("您的%s已到账", order.Card.GetStr())
|
|
|
|
|
if e := tx.Create(&jyy.AppUserMessage{
|
|
|
|
|
UserID: int(orderInfo.SharerID),
|
|
|
|
|
Message: message,
|
|
|
|
|
Kind: jyy.Profit,
|
|
|
|
|
IsRead: false,
|
|
|
|
|
SubID: uint64(profit.ID),
|
|
|
|
|
}).Error; e != nil {
|
|
|
|
|
return e
|
|
|
|
|
}
|
|
|
|
|
var ju jpush.JPush
|
|
|
|
|
mysql.Db.First(&ju, "user_id = ?", orderInfo.SharerID)
|
|
|
|
|
if ju.RegistrationId != "" {
|
|
|
|
|
client := jpush2.GetClient()
|
|
|
|
|
client.PushMsgWithRegister(ju.RegistrationId, "收益到账", message)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var u1 user.Information
|
|
|
|
|
if err := tx.First(&u1, "id = ?", orderInfo.UserID).Error; err != nil {
|
|
|
|
|