活动:结算奖励

This commit is contained in:
qiaoxin
2021-05-12 19:55:04 +08:00
parent 547bf964b7
commit 098cfe0949
2 changed files with 48 additions and 19 deletions

View File

@@ -8,6 +8,7 @@ import { UserOrderModel } from '../../../db/UserOrder';
import _ = require('underscore');
import { applyOrderWX, checkOrderWX } from '../../../services/pay/weixinPay';
import { applyOrderALI, checkOrderALI } from '../../../services/pay/aliPay';
import { makeOrder } from '../../../services/orderService';
export default function (app: Application) {
return new orderHandler(app);
@@ -45,8 +46,6 @@ export class orderHandler {
let message = productInfo.message;//商品信息
let localOrderID = genCode(32);//本地订单号
let orderID = '';//平台订单号
let sdkOrderInfo = null;//客户端需要的平台订单信息
switch (payType) {
case PAY_TYPE.WX:
@@ -81,14 +80,10 @@ export class orderHandler {
console.log('未知支付类型');
return resResult(STATUS.NO_PAY_TYPE);
}
await UserOrderModel.applyOrder(serverId, roleId, productID, localOrderID, orderID, price, payType);
return resResult(STATUS.SUCCESS, { orderInfo: sdkOrderInfo, productInfo, localOrderID });
}
/**
* @description 查询订单,结算奖励
* @param {{ localOrderID: string}} msg
@@ -105,7 +100,6 @@ export class orderHandler {
if (!localOrderID || !_.isString(localOrderID)) {
return resResult(STATUS.WRONG_PARMS);
}
let orderInfo = await UserOrderModel.findOrder(localOrderID);
if (!orderInfo) {
return resResult(STATUS.NO_ORDER);
@@ -125,17 +119,6 @@ export class orderHandler {
let payType = orderInfo.payType;//支付类型
let roleId = orderInfo.roleId;//角色
switch (productType) {
case ACTIVITY_TYPE.NEW_PLAYER_LIMIT_PACKAGE:
{
break;
}
default:
console.log('未知错误类型');
return resResult(STATUS.NO_PRODUCT_ID);
}
orderInfo = await UserOrderModel.check(roleId, localOrderID);
if (!orderInfo) {
return resResult(STATUS.DUPLICATE_ORDER);
@@ -191,8 +174,9 @@ export class orderHandler {
orderInfo = await UserOrderModel.success(roleId, localOrderID);
if (orderInfo) {
//结算奖励
let result = await makeOrder(localOrderID);
console.log('结算完成', localOrderID)
return resResult(STATUS.SUCCESS, Object.assign({}));
return resResult(STATUS.SUCCESS, result);
}
return resResult(STATUS.DUPLICATE_ORDER);