🐞 fix(充值): 英杰券使用字段修改
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||||
import { genCode, resResult } from '../../../pubUtils/util';
|
import { genCode, resResult } from '../../../pubUtils/util';
|
||||||
import { ACTIVITY_TYPE, DEBUG_MAGIC_WORD, DEBUG_PRICE, ITEM_CHANGE_REASON, ORDER_STATE, PAY_TYPE, STATUS, TASK_TYPE, TA_EVENT } from '../../../consts';
|
import { ACTIVITY_TYPE, CURRENCY, DEBUG_MAGIC_WORD, DEBUG_PRICE, ITEM_CHANGE_REASON, ORDER_STATE, PAY_TYPE, STATUS, TASK_TYPE, TA_EVENT } from '../../../consts';
|
||||||
import { dicRMB } from '../../../pubUtils/dictionary/DicRMB';
|
import { dicRMB } from '../../../pubUtils/dictionary/DicRMB';
|
||||||
import { UserOrderModel } from '../../../db/UserOrder';
|
import { UserOrderModel } from '../../../db/UserOrder';
|
||||||
import _ = require('underscore');
|
import _ = require('underscore');
|
||||||
@@ -12,7 +12,7 @@ import { getActivityById } from '../../../services/activity/activityService';
|
|||||||
import { reportTAEvent } from '../../../services/sdkService';
|
import { reportTAEvent } from '../../../services/sdkService';
|
||||||
import { canPay, isDebugPay } from '../../../pubUtils/sdkUtil';
|
import { canPay, isDebugPay } from '../../../pubUtils/sdkUtil';
|
||||||
import { isDevelopEnv } from '../../../services/utilService';
|
import { isDevelopEnv } from '../../../services/utilService';
|
||||||
import { getVoucherCoinObject, getVoucherObject, handleCost } from '../../../services/role/rewardService';
|
import { checkVoucherId, getVoucherCoinObject, getVoucherObject, handleCost } from '../../../services/role/rewardService';
|
||||||
import { CheckMeterial } from '../../../services/role/checkMaterial';
|
import { CheckMeterial } from '../../../services/role/checkMaterial';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
@@ -32,7 +32,7 @@ export class orderHandler {
|
|||||||
* @param {BackendSession} session
|
* @param {BackendSession} session
|
||||||
* @memberof orderHandler
|
* @memberof orderHandler
|
||||||
*/
|
*/
|
||||||
async applyOrder(msg: { productID: string, payType: number, activityId: number, paramStr: string, useVoucher: boolean }, session: BackendSession) {
|
async applyOrder(msg: { productID: string, payType: number, activityId: number, paramStr: string, useVoucher: number }, session: BackendSession) {
|
||||||
const { productID, payType, activityId, paramStr, useVoucher } = msg;
|
const { productID, payType, activityId, paramStr, useVoucher } = msg;
|
||||||
const roleId = session.get('roleId');
|
const roleId = session.get('roleId');
|
||||||
const serverId = session.get('serverId');
|
const serverId = session.get('serverId');
|
||||||
@@ -60,22 +60,12 @@ export class orderHandler {
|
|||||||
let localOrderID = genCode(32);//本地订单号
|
let localOrderID = genCode(32);//本地订单号
|
||||||
let orderID = '';//平台订单号
|
let orderID = '';//平台订单号
|
||||||
let sdkOrderInfo = null;//客户端需要的平台订单信息
|
let sdkOrderInfo = null;//客户端需要的平台订单信息
|
||||||
let voucherId = 0;
|
|
||||||
|
|
||||||
if(useVoucher) {
|
if(useVoucher) {
|
||||||
let voucher = getVoucherObject(price);
|
if(!checkVoucherId(useVoucher)) return resResult(STATUS.WRONG_PARMS);
|
||||||
let check = new CheckMeterial(roleId);
|
let check = new CheckMeterial(roleId);
|
||||||
let isEnough = await check.decrease([voucher]);
|
let isEnough = await check.decrease([{ id: useVoucher, count: price}]);
|
||||||
if (!isEnough) {
|
if (!isEnough) return resResult(STATUS.VOUCHER_NOT_ENOUGH);
|
||||||
let voucher = getVoucherCoinObject(price);
|
|
||||||
let check = new CheckMeterial(roleId);
|
|
||||||
let isEnough = await check.decrease([voucher]);
|
|
||||||
if (!isEnough) return resResult(STATUS.VOUCHER_NOT_ENOUGH);
|
|
||||||
voucherId = voucher.id;
|
|
||||||
} else {
|
|
||||||
voucherId = voucher.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
switch (payType) {
|
switch (payType) {
|
||||||
case PAY_TYPE.THREE_SEVEN:
|
case PAY_TYPE.THREE_SEVEN:
|
||||||
@@ -138,7 +128,7 @@ export class orderHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
await UserOrderModel.applyOrder(serverId, roleId, productID, localOrderID, orderID, price, payType, activityId, paramStr, message, useVoucher, voucherId);
|
await UserOrderModel.applyOrder(serverId, roleId, productID, localOrderID, orderID, price, payType, activityId, paramStr, message, !!useVoucher, useVoucher);
|
||||||
reportTAEvent(roleId, TA_EVENT.RECHARGE, {
|
reportTAEvent(roleId, TA_EVENT.RECHARGE, {
|
||||||
pay_id: localOrderID, chargeId: productID, pay_name: message, pay_amount: price, pay_channel: payType
|
pay_id: localOrderID, chargeId: productID, pay_name: message, pay_amount: price, pay_channel: payType
|
||||||
}, ip)
|
}, ip)
|
||||||
|
|||||||
@@ -1605,10 +1605,9 @@ export function checkRouteParam(route: string, msg: any) {
|
|||||||
case "order.orderHandler.applyOrder":
|
case "order.orderHandler.applyOrder":
|
||||||
{
|
{
|
||||||
let { productID, payType, activityId, paramStr, useVoucher } = msg;
|
let { productID, payType, activityId, paramStr, useVoucher } = msg;
|
||||||
if(!checkNaturalNumbers(payType, activityId)) return false;
|
if(!checkNaturalNumbers(payType, activityId, useVoucher)) return false;
|
||||||
if(!checkNaturalStrings(productID)) return false;
|
if(!checkNaturalStrings(productID)) return false;
|
||||||
if(!checkStringIfExist(paramStr)) return false;
|
if(!checkStringIfExist(paramStr)) return false;
|
||||||
if(!checkBoolean(useVoucher)) return false;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "order.orderHandler.checkOrder":
|
case "order.orderHandler.checkOrder":
|
||||||
|
|||||||
@@ -616,6 +616,12 @@ export function getVoucherCoinObject(count: number) {
|
|||||||
return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.VOUCHER_COIN), count };
|
return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.VOUCHER_COIN), count };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function checkVoucherId(id: number) {
|
||||||
|
let voucher = CURRENCY_BY_TYPE.get(CURRENCY_TYPE.VOUCHER);
|
||||||
|
let voucherCoin = CURRENCY_BY_TYPE.get(CURRENCY_TYPE.VOUCHER_COIN);
|
||||||
|
return id == voucher || id == voucherCoin;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回 解锁头像/相框
|
* 返回 解锁头像/相框
|
||||||
* @param conditions 解锁条件
|
* @param conditions 解锁条件
|
||||||
|
|||||||
Reference in New Issue
Block a user