|
|
@@ -139,22 +139,28 @@ func OrderPaySuccess(orderId int64, userId int64) error {
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- configs.Engine.Table("goods_order").ID(orderId).Cols("state").Update(map[string]any{"state": 1})
|
|
|
+ update, err := configs.Engine.Table("goods_order").Where("id = ?", orderId).Update(map[string]any{"state": 1})
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(update, err)
|
|
|
+ }
|
|
|
|
|
|
//获取价格
|
|
|
var price = order.TotalPrice
|
|
|
//给推荐人分成
|
|
|
user, err := manage.GetUserById(userId)
|
|
|
- wallet := domain.UserWallet{UserId: user.InviterBy}
|
|
|
- list, err := manage.GetUserWalletList(wallet, 0, 1)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- userWallet, ok := list.List[0].(domain.UserWallet)
|
|
|
- if ok {
|
|
|
- //userWallet.Balance = userWallet.Balance + (price * 0.1)
|
|
|
- userWallet.PromotionAmount = userWallet.PromotionAmount + (price * 0.1)
|
|
|
- configs.Engine.Table("user_wallet").ID(userWallet.Id).Cols("balance").Update(map[string]any{"promotion_amount": userWallet.PromotionAmount})
|
|
|
+ if user.InviterBy != 0 {
|
|
|
+ wallet := domain.UserWallet{UserId: user.InviterBy}
|
|
|
+ list, err := manage.GetUserWalletList(wallet, 0, 1)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ userWallet, ok := list.List[0].(domain.UserWallet)
|
|
|
+ if ok {
|
|
|
+ //userWallet.Balance = userWallet.Balance + (price * 0.1)
|
|
|
+ userWallet.PromotionAmount = userWallet.PromotionAmount + (price * 0.1)
|
|
|
+ configs.Engine.Table("user_wallet").ID(userWallet.Id).Cols("balance").
|
|
|
+ Update(map[string]any{"promotion_amount": userWallet.PromotionAmount})
|
|
|
+ }
|
|
|
}
|
|
|
return nil
|
|
|
}
|