虚拟充值
This commit is contained in:
@@ -7,8 +7,11 @@ import { dicRMB } from '../../../pubUtils/dictionary/DicRMB';
|
||||
import { getActivityById } from '../../../services/activity/activityService';
|
||||
import { UserOrderModel } from '../../../db/UserOrder';
|
||||
import { makeOrder, settleOrder, settleOrderAli, settleOrderWx } from '../../../services/orderService';
|
||||
import { getActivityProducts } from '../../../services/gmService';
|
||||
import { getActivityProducts, getParamStr } from '../../../services/gmService';
|
||||
import { ActivityGroupModel } from '../../../db/ActivityGroup';
|
||||
import { Receiver } from '../../../db/GMMail';
|
||||
import { getRoleOnlineInfo } from '../../../services/redisService';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
|
||||
export interface Cascader {
|
||||
value: number|string;
|
||||
@@ -57,31 +60,15 @@ export class GmOrderHandler {
|
||||
return resResult(STATUS.SUCCESS, result);
|
||||
}
|
||||
|
||||
getParamStr(beginTimeStamp: number, monopolyActivityId: number) {
|
||||
let param = {};
|
||||
if(beginTimeStamp) {
|
||||
param['beginTimeStamp'] = beginTimeStamp;
|
||||
}
|
||||
if(monopolyActivityId) {
|
||||
param['monopolyActivityId'] = monopolyActivityId;
|
||||
}
|
||||
return JSON.stringify(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 虚拟充值
|
||||
* @param {{productID:string, magicWord:string, paramStr: string }} msg
|
||||
* @param {BackendSession} session
|
||||
* @memberof orderHandler
|
||||
*/
|
||||
async applyOrder(msg: { productID: string, activityId: number, beginTimeStamp: number, monopolyActivityId: number }, session: BackendSession) {
|
||||
const { productID, activityId, beginTimeStamp, monopolyActivityId } = msg;
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
const sid = session.get('sid');
|
||||
const roleName = session.get('roleName');
|
||||
|
||||
async applyOrder(msg: { serverId: number, activityId: (number|string)[], receiver: Receiver[] }, session: BackendSession) {
|
||||
const { activityId: activityIds, receiver } = msg;
|
||||
let activityId = <number>activityIds[1];
|
||||
let productID = <string>activityIds[2];
|
||||
|
||||
let payType = PAY_TYPE.TEST
|
||||
//如果有特殊情况,activityId可为0
|
||||
@@ -105,15 +92,34 @@ export class GmOrderHandler {
|
||||
|
||||
let activityData = await getActivityById(activityId);
|
||||
if (!activityData) return resResult(STATUS.ACTIVITY_MISSING);
|
||||
let orderInfo = await UserOrderModel.applyOrder(serverId, roleId, productID, localOrderID, orderID, price, payType, activityId, this.getParamStr(beginTimeStamp, monopolyActivityId), message);
|
||||
|
||||
//订单成功
|
||||
if(!orderInfo) {
|
||||
return resResult(STATUS.NO_ORDER);
|
||||
let results = [];
|
||||
for(let { roleId, serverId } of receiver) {
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
if(!role && role.serverId != serverId) {
|
||||
results.push(resResult(STATUS.ROLE_NOT_FOUND));
|
||||
continue;
|
||||
}
|
||||
let paramStr = await getParamStr(activityData, productID, role);
|
||||
let orderInfo = await UserOrderModel.applyOrder(serverId, roleId, productID, localOrderID, orderID, price, payType, activityId, paramStr, message);
|
||||
|
||||
//订单成功
|
||||
if(!orderInfo) {
|
||||
results.push(resResult(STATUS.NO_ORDER));
|
||||
continue;
|
||||
}
|
||||
let onlineUser = await getRoleOnlineInfo(roleId);
|
||||
let result = await settleOrder(orderInfo, serverId, onlineUser?.sid);
|
||||
orderInfo = await UserOrderModel.success(roleId, localOrderID, JSON.stringify(result));
|
||||
console.log(`测试支付完成!!!!!!!!!!!!! serverId:${serverId}, productID:${productID}, productType:${productType}, roleId:${roleId}, localOrderID:${localOrderID}, payType:${payType}`)
|
||||
results.push(resResult(STATUS.SUCCESS));
|
||||
}
|
||||
|
||||
let findResultErrCode = results.find(cur => cur.code != 0);
|
||||
if(!findResultErrCode) {
|
||||
return resResult(STATUS.SUCCESS);
|
||||
} else {
|
||||
return findResultErrCode;
|
||||
}
|
||||
let result = await settleOrder(orderInfo, serverId, sid);
|
||||
orderInfo = await UserOrderModel.success(roleId, localOrderID, JSON.stringify(result));
|
||||
console.log(`测试支付完成!!!!!!!!!!!!! serverId:${serverId}, productID:${productID}, productType:${productType}, roleId:${roleId}, localOrderID:${localOrderID}, payType:${payType}`)
|
||||
return resResult(STATUS.SUCCESS, result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user