✨ feat(充值): 添加英杰币
This commit is contained in:
@@ -102,7 +102,7 @@ export class GmOrderHandler {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let paramStr = await getParamStr(activityData, productID, role);
|
let paramStr = await getParamStr(activityData, productID, role);
|
||||||
let orderInfo = await UserOrderModel.applyOrder(serverId, roleId, productID, localOrderID, orderID, price, payType, activityId, paramStr, message, false);
|
let orderInfo = await UserOrderModel.applyOrder(serverId, roleId, productID, localOrderID, orderID, price, payType, activityId, paramStr, message, false, 0);
|
||||||
|
|
||||||
//订单成功
|
//订单成功
|
||||||
if(!orderInfo) {
|
if(!orderInfo) {
|
||||||
|
|||||||
@@ -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 { getVoucherObject, handleCost } from '../../../services/role/rewardService';
|
import { 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) {
|
||||||
@@ -60,12 +60,22 @@ 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);
|
let voucher = getVoucherObject(price);
|
||||||
let check = new CheckMeterial(roleId);
|
let check = new CheckMeterial(roleId);
|
||||||
let isEnough = await check.decrease([voucher]);
|
let isEnough = await check.decrease([voucher]);
|
||||||
if (!isEnough) return resResult(STATUS.VOUCHER_NOT_ENOUGH);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
switch (payType) {
|
switch (payType) {
|
||||||
case PAY_TYPE.THREE_SEVEN:
|
case PAY_TYPE.THREE_SEVEN:
|
||||||
@@ -128,7 +138,7 @@ export class orderHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
await UserOrderModel.applyOrder(serverId, roleId, productID, localOrderID, orderID, price, payType, activityId, paramStr, message, useVoucher);
|
await UserOrderModel.applyOrder(serverId, roleId, productID, localOrderID, orderID, price, payType, activityId, paramStr, message, useVoucher, voucherId);
|
||||||
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)
|
||||||
@@ -171,8 +181,9 @@ export class orderHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(orderInfo.useVoucher) {
|
if(orderInfo.useVoucher) {
|
||||||
let voucher = getVoucherObject(productInfo.price);
|
let voucherId = orderInfo.voucherId;
|
||||||
let result = await handleCost(roleId, sid, [voucher], ITEM_CHANGE_REASON.USE_VOUCHER);
|
let voucher = [{ id: voucherId, count: productInfo.price }];
|
||||||
|
let result = await handleCost(roleId, sid, voucher, ITEM_CHANGE_REASON.USE_VOUCHER);
|
||||||
if(!result) return resResult(STATUS.VOUCHER_NOT_ENOUGH);
|
if(!result) return resResult(STATUS.VOUCHER_NOT_ENOUGH);
|
||||||
|
|
||||||
let res = await settleOrderFromHandler(localOrderID, roleId, serverId, sid);
|
let res = await settleOrderFromHandler(localOrderID, roleId, serverId, sid);
|
||||||
@@ -291,7 +302,7 @@ export class orderHandler {
|
|||||||
let check = await checkOrderCanBuy(roleId, serverId, activityData, productID, paramStr);
|
let check = await checkOrderCanBuy(roleId, serverId, activityData, productID, paramStr);
|
||||||
if(!check) return resResult(STATUS.ORDER_CANNOT_BUY)
|
if(!check) return resResult(STATUS.ORDER_CANNOT_BUY)
|
||||||
|
|
||||||
let orderInfo = await UserOrderModel.applyOrder(serverId, roleId, productID, localOrderID, orderID, price, payType, activityId, paramStr, message, false);
|
let orderInfo = await UserOrderModel.applyOrder(serverId, roleId, productID, localOrderID, orderID, price, payType, activityId, paramStr, message, false, 0);
|
||||||
|
|
||||||
//订单成功
|
//订单成功
|
||||||
if(!orderInfo) {
|
if(!orderInfo) {
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import { checkParamPrice, needRebate } from '../pubUtils/sdkUtil';
|
|||||||
import { checkShopCanBuyInOrder, makeShopOrder } from './shopService';
|
import { checkShopCanBuyInOrder, makeShopOrder } from './shopService';
|
||||||
import { checkWeeklyFund, makeWeeklyFund } from './activity/weeklyFundService';
|
import { checkWeeklyFund, makeWeeklyFund } from './activity/weeklyFundService';
|
||||||
import { checkMonthlyFund, makeMonthlyFund } from './activity/monthlyFundService';
|
import { checkMonthlyFund, makeMonthlyFund } from './activity/monthlyFundService';
|
||||||
|
import { gameData } from '../pubUtils/data';
|
||||||
|
|
||||||
export async function checkOrderCanBuy(roleId: string, serverId: number, activityData: ActivityModelType, productID: string, paramStr: string) {
|
export async function checkOrderCanBuy(roleId: string, serverId: number, activityData: ActivityModelType, productID: string, paramStr: string) {
|
||||||
let activityId = activityData.activityId;
|
let activityId = activityData.activityId;
|
||||||
@@ -270,7 +271,7 @@ export async function settleOrder(order: UserOrderModelType, serverId: number, s
|
|||||||
//成长任务
|
//成长任务
|
||||||
checkTask(serverId, order.roleId, null, TASK_TYPE.ACTIVITY_RMB, { count: order.price });
|
checkTask(serverId, order.roleId, null, TASK_TYPE.ACTIVITY_RMB, { count: order.price });
|
||||||
if(order.payType != PAY_TYPE.TEST) {
|
if(order.payType != PAY_TYPE.TEST) {
|
||||||
reportTAEvent(order.roleId, TA_EVENT.RECHARGE_SUCCESS, { pay_id: order.localOrderID, charge_id: order.productID, pay_name: order.message, pay_amount: order.price, pay_channel: order.payType, pay_type: order.useVoucher? "现金": "代金券" })
|
reportTAEvent(order.roleId, TA_EVENT.RECHARGE_SUCCESS, { pay_id: order.localOrderID, charge_id: order.productID, pay_name: order.message, pay_amount: order.price, pay_channel: order.payType, pay_type: getVoucherType(order.useVoucher, order.voucherId) })
|
||||||
reportTAUserSet(TA_USERSET_TYPE.SET_ONCE, order.roleId, { first_pay_time: new Date() });
|
reportTAUserSet(TA_USERSET_TYPE.SET_ONCE, order.roleId, { first_pay_time: new Date() });
|
||||||
reportTAUserSet(TA_USERSET_TYPE.SET, order.roleId, { last_pay_time: new Date() });
|
reportTAUserSet(TA_USERSET_TYPE.SET, order.roleId, { last_pay_time: new Date() });
|
||||||
reportTAUserSet(TA_USERSET_TYPE.ADD, order.roleId, { total_revenue: order.price });
|
reportTAUserSet(TA_USERSET_TYPE.ADD, order.roleId, { total_revenue: order.price });
|
||||||
@@ -286,6 +287,15 @@ export async function settleOrder(order: UserOrderModelType, serverId: number, s
|
|||||||
return result.data;
|
return result.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getVoucherType(useVoucher: boolean, voucherId: number) {
|
||||||
|
if(useVoucher) {
|
||||||
|
let dicGood = gameData.goods.get(voucherId);
|
||||||
|
if(!dicGood) return '未知';
|
||||||
|
return dicGood.name;
|
||||||
|
}
|
||||||
|
return '现金'
|
||||||
|
}
|
||||||
|
|
||||||
export async function settleOrderWx(order: UserOrderModelType, serverId: number, sid: string) {
|
export async function settleOrderWx(order: UserOrderModelType, serverId: number, sid: string) {
|
||||||
|
|
||||||
if (order.state == ORDER_STATE.RESULT_SUCCESS) {
|
if (order.state == ORDER_STATE.RESULT_SUCCESS) {
|
||||||
|
|||||||
@@ -612,6 +612,9 @@ export function getHonourObject(count: number) {
|
|||||||
return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.VOUCHER), count };
|
return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.VOUCHER), count };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getVoucherCoinObject(count: number) {
|
||||||
|
return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.VOUCHER_COIN), count };
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回 解锁头像/相框
|
* 返回 解锁头像/相框
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ export const CURRENCY_TYPE = {
|
|||||||
SPECIAL_DICE: "specialDice",
|
SPECIAL_DICE: "specialDice",
|
||||||
KING_EXP: 'kingExp',
|
KING_EXP: 'kingExp',
|
||||||
VOUCHER: 'voucher',
|
VOUCHER: 'voucher',
|
||||||
|
VOUCHER_COIN: 'voucherCoin',
|
||||||
}
|
}
|
||||||
|
|
||||||
const currencyArr = [
|
const currencyArr = [
|
||||||
@@ -193,7 +194,8 @@ const currencyArr = [
|
|||||||
{ "gid": 72011, "name": "普通骰子", "type": CURRENCY_TYPE.NORMAL_DICE },
|
{ "gid": 72011, "name": "普通骰子", "type": CURRENCY_TYPE.NORMAL_DICE },
|
||||||
{ "gid": 72021, "name": "天机骰子", "type": CURRENCY_TYPE.SPECIAL_DICE },
|
{ "gid": 72021, "name": "天机骰子", "type": CURRENCY_TYPE.SPECIAL_DICE },
|
||||||
{ "gid": 72030, "name": "主公经验", "type": CURRENCY_TYPE.KING_EXP },
|
{ "gid": 72030, "name": "主公经验", "type": CURRENCY_TYPE.KING_EXP },
|
||||||
{ "gid": 81000, "name": "代金券", "type": CURRENCY_TYPE.VOUCHER}
|
{ "gid": 81000, "name": "英杰券", "type": CURRENCY_TYPE.VOUCHER},
|
||||||
|
{ "gid": 81001, "name": "英杰币", "type": CURRENCY_TYPE.VOUCHER_COIN},
|
||||||
];
|
];
|
||||||
export const CURRENCY = new Map<number, { gid: number, name: string, type: string }>();
|
export const CURRENCY = new Map<number, { gid: number, name: string, type: string }>();
|
||||||
export const CURRENCY_BY_TYPE = new Map<string, number>();
|
export const CURRENCY_BY_TYPE = new Map<string, number>();
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ export default class UserOrder extends BaseModel {
|
|||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
useVoucher: boolean; // 使用代金券
|
useVoucher: boolean; // 使用代金券
|
||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
|
voucherId: number; // 代金券类型
|
||||||
|
@prop({ required: true })
|
||||||
callbackMsg: string; // 信息
|
callbackMsg: string; // 信息
|
||||||
|
|
||||||
|
|
||||||
@@ -126,9 +128,9 @@ export default class UserOrder extends BaseModel {
|
|||||||
|
|
||||||
|
|
||||||
//新增订单
|
//新增订单
|
||||||
public static async applyOrder(serverId: number, roleId: string, productID: string, localOrderID: string, orderID: string, price: number, payType: number, activityId: number, paramStr: string, message: string, useVoucher: boolean) {
|
public static async applyOrder(serverId: number, roleId: string, productID: string, localOrderID: string, orderID: string, price: number, payType: number, activityId: number, paramStr: string, message: string, useVoucher: boolean, voucherId: number) {
|
||||||
let result: UserOrderModelType = await UserOrderModel.findOneAndUpdate({ serverId, roleId, productID, localOrderID, orderID, payType, activityId },
|
let result: UserOrderModelType = await UserOrderModel.findOneAndUpdate({ serverId, roleId, productID, localOrderID, orderID, payType, activityId },
|
||||||
{ $set: { price, state: ORDER_STATE.APPLY, message, paramStr: paramStr ? paramStr : '', useVoucher } },
|
{ $set: { price, state: ORDER_STATE.APPLY, message, paramStr: paramStr ? paramStr : '', useVoucher, voucherId } },
|
||||||
{ upsert: true, new: true }).lean(true);
|
{ upsert: true, new: true }).lean(true);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14466,6 +14466,29 @@
|
|||||||
"activityType": 0,
|
"activityType": 0,
|
||||||
"info": "传说中给予英杰的契据,可用来兑换游戏内的等价礼包"
|
"info": "传说中给予英杰的契据,可用来兑换游戏内的等价礼包"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"good_id": 81001,
|
||||||
|
"name": "英杰币",
|
||||||
|
"quality": 4,
|
||||||
|
"image_id": "yingjiebi",
|
||||||
|
"itid": 63,
|
||||||
|
"goodType": 2,
|
||||||
|
"urType": 0,
|
||||||
|
"redPoint": 0,
|
||||||
|
"decomposeItem": "&",
|
||||||
|
"hid": 0,
|
||||||
|
"getWays": "&",
|
||||||
|
"addGetWay": "&",
|
||||||
|
"useWays": "23&",
|
||||||
|
"value": 0,
|
||||||
|
"condition": 0,
|
||||||
|
"timelimit": 0,
|
||||||
|
"gift": 0,
|
||||||
|
"randomShow": 0,
|
||||||
|
"seasonNum": 0,
|
||||||
|
"activityType": 0,
|
||||||
|
"info": "传说中给予英杰的珍贵货币,可用来兑换游戏内的等价礼包(不可与英杰券同时使用)"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"good_id": 82000,
|
"good_id": 82000,
|
||||||
"name": "下品宝物精华",
|
"name": "下品宝物精华",
|
||||||
|
|||||||
Reference in New Issue
Block a user