🐞 fix(充值): 英杰券使用字段修改
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
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 { UserOrderModel } from '../../../db/UserOrder';
|
||||
import _ = require('underscore');
|
||||
@@ -12,7 +12,7 @@ import { getActivityById } from '../../../services/activity/activityService';
|
||||
import { reportTAEvent } from '../../../services/sdkService';
|
||||
import { canPay, isDebugPay } from '../../../pubUtils/sdkUtil';
|
||||
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';
|
||||
|
||||
export default function (app: Application) {
|
||||
@@ -32,7 +32,7 @@ export class orderHandler {
|
||||
* @param {BackendSession} session
|
||||
* @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 roleId = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
@@ -60,22 +60,12 @@ export class orderHandler {
|
||||
let localOrderID = genCode(32);//本地订单号
|
||||
let orderID = '';//平台订单号
|
||||
let sdkOrderInfo = null;//客户端需要的平台订单信息
|
||||
let voucherId = 0;
|
||||
|
||||
if(useVoucher) {
|
||||
let voucher = getVoucherObject(price);
|
||||
if(!checkVoucherId(useVoucher)) return resResult(STATUS.WRONG_PARMS);
|
||||
let check = new CheckMeterial(roleId);
|
||||
let isEnough = await check.decrease([voucher]);
|
||||
if (!isEnough) {
|
||||
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;
|
||||
}
|
||||
|
||||
let isEnough = await check.decrease([{ id: useVoucher, count: price}]);
|
||||
if (!isEnough) return resResult(STATUS.VOUCHER_NOT_ENOUGH);
|
||||
} else {
|
||||
switch (payType) {
|
||||
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, {
|
||||
pay_id: localOrderID, chargeId: productID, pay_name: message, pay_amount: price, pay_channel: payType
|
||||
}, ip)
|
||||
|
||||
Reference in New Issue
Block a user