feat(37需求): 修改返利逻辑

This commit is contained in:
luying
2023-04-07 17:57:15 +08:00
parent b84e89dff0
commit f0a5809104
10 changed files with 275 additions and 46 deletions

View File

@@ -31,10 +31,6 @@ import { addGuildPay } from './activity/guildPayService';
import { sendMessageToUserWithSuc } from './pushService';
import { checkParamPrice, needRebate } from '../pubUtils/sdkUtil';
import { checkShopCanBuyInOrder, makeShopOrder } from './shopService';
import { UserModel } from '../db/User';
import { HistoryOrderModel } from '../db/HistoryOrder';
import { sendMailByContent } from './mailService';
import { RECHARGE } from '../pubUtils/dicParam';
import { checkWeeklyFund, makeWeeklyFund } from './activity/weeklyFundService';
import { checkMonthlyFund, makeMonthlyFund } from './activity/monthlyFundService';
@@ -424,28 +420,4 @@ export async function refundOrderFromRedisPub(message: string) {
await UserOrderModel.refund(order.roleId, order.localOrderID, message);
return true
}
export async function rebateHistoryOrder(roleId: string, uid: number) {
let user = await UserModel.findUserByUid(uid);
if(user) {
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(historyOrder._id, roleId);
}
}
}
}
}
}