|
@@ -55,26 +55,27 @@ func DealUserCoin(session *xorm.Session, req md.DealUserCoinReq) (err error) { |
|
|
} else if req.Kind == "sub" { |
|
|
} else if req.Kind == "sub" { |
|
|
userVirtualCoinFlow.Direction = 2 |
|
|
userVirtualCoinFlow.Direction = 2 |
|
|
userVirtualCoinFlow.AfterAmout = coinAmountValue.Sub(amountValue).RoundFloor(4).String() |
|
|
userVirtualCoinFlow.AfterAmout = coinAmountValue.Sub(amountValue).RoundFloor(4).String() |
|
|
|
|
|
if zhios_order_relate_utils.StrToFloat64(userVirtualCoinFlow.AfterAmout) < 0 { |
|
|
|
|
|
var coin model.VirtualCoin |
|
|
|
|
|
_, err = session.Where("id = ?", req.CoinId).Get(&coin) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
zhios_order_relate_utils.FilePutContents("virtual_coin_not", zhios_order_relate_utils.SerializeStr(map[string]interface{}{ |
|
|
|
|
|
"uid": userVirtualCoinFlow.Uid, |
|
|
|
|
|
"amount": userVirtualCoinFlow.Amout, |
|
|
|
|
|
"before_amount": userVirtualCoinFlow.BeforeAmout, |
|
|
|
|
|
"after_amount": userVirtualCoinFlow.AfterAmout, |
|
|
|
|
|
"coin_id": userVirtualCoinFlow.CoinId, |
|
|
|
|
|
})) |
|
|
|
|
|
return errors.New("用户" + zhios_order_relate_utils.IntToStr(userVirtualCoinFlow.Uid) + "的" + coin.Name + "不足") |
|
|
|
|
|
//userVirtualCoinFlow.AfterAmout = "0" |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
err = errors.New("错误的kind类型") |
|
|
err = errors.New("错误的kind类型") |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
if zhios_order_relate_utils.StrToFloat64(userVirtualCoinFlow.AfterAmout) < 0 { |
|
|
|
|
|
var coin model.VirtualCoin |
|
|
|
|
|
_, err = session.Where("id = ?", req.CoinId).Get(&coin) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
zhios_order_relate_utils.FilePutContents("virtual_coin_not", zhios_order_relate_utils.SerializeStr(map[string]interface{}{ |
|
|
|
|
|
"uid": userVirtualCoinFlow.Uid, |
|
|
|
|
|
"amount": userVirtualCoinFlow.Amout, |
|
|
|
|
|
"before_amount": userVirtualCoinFlow.BeforeAmout, |
|
|
|
|
|
"after_amount": userVirtualCoinFlow.AfterAmout, |
|
|
|
|
|
"coin_id": userVirtualCoinFlow.CoinId, |
|
|
|
|
|
})) |
|
|
|
|
|
return errors.New("用户" + zhios_order_relate_utils.IntToStr(userVirtualCoinFlow.Uid) + "的" + coin.Name + "不足") |
|
|
|
|
|
//userVirtualCoinFlow.AfterAmout = "0" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//3、插入 `user_virtual_coin_flow` 记录 |
|
|
//3、插入 `user_virtual_coin_flow` 记录 |
|
|
_, err = db.UserVirtualCoinFlowInsert(session, &userVirtualCoinFlow) |
|
|
_, err = db.UserVirtualCoinFlowInsert(session, &userVirtualCoinFlow) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|