init: web_hgdjc_server
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package rechargeser
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/srvdef"
|
||||
"videoweb/pub/payCenter"
|
||||
"videoweb/pub/pubdef"
|
||||
)
|
||||
|
||||
// PayDeviceID 支付中心要求 deviceId 非空。本次请求带了设备号就用本次的,否则用用户资料里保存的设备号。
|
||||
func PayDeviceID(requestDeviceID, savedDeviceID, backupDeviceID string) string {
|
||||
for _, value := range []string{requestDeviceID, savedDeviceID, backupDeviceID} {
|
||||
if deviceID := strings.TrimSpace(value); deviceID != "" {
|
||||
return deviceID
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// SubmitPayOrder 向新支付中心下单。会员和金币订单共用同一协议,本地订单仍由调用方入库。
|
||||
func SubmitPayOrder(ctx context.Context, userId int64, userName, tradeNo string, amount int64, payMode, sysType, devType, deviceID, ip string) (*pubdef.SubmitVipOrderInfo, *srvdef.SrvErr) {
|
||||
deviceType := devType
|
||||
if deviceType == "" {
|
||||
deviceType = sysType
|
||||
}
|
||||
response, err := (&payCenter.Recharge{
|
||||
Ctx: ctx,
|
||||
TradeNo: tradeNo,
|
||||
Money: payCenter.FenToYuan(amount),
|
||||
Type: payMode,
|
||||
Info: payCenter.PayInfo{
|
||||
PlayerId: strconv.FormatInt(userId, 10),
|
||||
PlayerIp: ip,
|
||||
DeviceType: deviceType,
|
||||
DeviceId: strings.TrimSpace(deviceID),
|
||||
Name: userName,
|
||||
},
|
||||
}).ToPayNew()
|
||||
if err != nil {
|
||||
log.Error("新支付中心下单失败", log.Any("tradeNo", tradeNo), log.Any("userId", userId), log.E(err))
|
||||
return nil, srvdef.New(srvdef.Err, "充值失败", err.Error())
|
||||
}
|
||||
return &pubdef.SubmitVipOrderInfo{
|
||||
TradeNo: tradeNo,
|
||||
Oid: response.OID,
|
||||
PayUrl: response.PayUrl,
|
||||
PayUrlMode: response.Mode,
|
||||
PayRate: response.Rebate,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user