返利:修改返利逻辑
This commit is contained in:
@@ -32,7 +32,7 @@ import { makeTaskPass } from './activity/taskPassService';
|
||||
import { addGuildPay } from './activity/guildPayService';
|
||||
import { sendMessageToUserWithSuc } from './pushService';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { checkParamPrice } from '../pubUtils/sdkUtil';
|
||||
import { checkParamPrice, needRebate } from '../pubUtils/sdkUtil';
|
||||
import { checkShopCanBuyInOrder, makeShopOrder } from './shopService';
|
||||
import { UserModel } from '../db/User';
|
||||
import { HistoryOrderModel } from '../db/HistoryOrder';
|
||||
@@ -359,18 +359,22 @@ export async function refundOrderFromRedisPub(message: string) {
|
||||
export async function rebateHistoryOrder(roleId: string, uid: number) {
|
||||
let user = await UserModel.findUserByUid(uid);
|
||||
if(user) {
|
||||
let historyOrder = await HistoryOrderModel.findByChannelId(user.channelId);
|
||||
if(historyOrder && !historyOrder.isReceived) {
|
||||
let totalPay = historyOrder.totalPay;
|
||||
if(totalPay > 0) {
|
||||
let gold = 0;
|
||||
let goods = parseGoodStr(RECHARGE.RECHARGE_RMB_RETURN_RATIO).map(({ id, count }) => {
|
||||
let result = Math.floor(count * totalPay)
|
||||
gold += result;
|
||||
return { id, count: result }
|
||||
});
|
||||
await sendMailByContent(MAIL_TYPE.REBATE, roleId, { goods, params: [`${totalPay}`, `${gold}`] });
|
||||
await HistoryOrderModel.receive(user.channelId, roleId);
|
||||
let historyOrders = await HistoryOrderModel.findByChannelId(user.channelId);
|
||||
if(needRebate() && historyOrders.length > 0) {
|
||||
for(let historyOrder of historyOrders) {
|
||||
if(!historyOrder.isReceived) {
|
||||
let totalPay = historyOrder.totalPay;
|
||||
if(totalPay > 0) {
|
||||
let gold = 0;
|
||||
let goods = parseGoodStr(RECHARGE.RECHARGE_RMB_RETURN_RATIO).map(({ id, count }) => {
|
||||
let result = Math.floor(count * totalPay)
|
||||
gold += result;
|
||||
return { id, count: result }
|
||||
});
|
||||
await sendMailByContent(MAIL_TYPE.REBATE, roleId, { goods, params: [`${totalPay}`, `${gold}`] });
|
||||
await HistoryOrderModel.receive(user.channelId, roleId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user