|
@@ -31,9 +31,9 @@ class CashBackService extends CrudService {
|
|
|
// 上面总价包含了提现金额
|
|
|
// 下面计算的金额是可以提现的金额 提现总金额 - 提现金额
|
|
|
let canGet = 0;
|
|
|
- const inBill = res.filter(f => parseInt(f.source) >= 0);
|
|
|
- const outBill = res.filter(f => parseInt(f.source) < 0);
|
|
|
- const getOutBill = res.filter(f => f.source === '-1');
|
|
|
+ const inBill = res.filter((f) => parseInt(f.source) >= 0);
|
|
|
+ const outBill = res.filter((f) => parseInt(f.source) < 0);
|
|
|
+ const getOutBill = res.filter((f) => f.source === '-1');
|
|
|
const outBillMoney = getOutBill.reduce((p, n) => this.ctx.plus(p, n.money), 0);
|
|
|
for (const i of inBill) {
|
|
|
const cAt = _.get(i, 'time');
|
|
@@ -42,7 +42,7 @@ class CashBackService extends CrudService {
|
|
|
// 已经过了提款时间,那就再找下,是否有该记录相应的退款
|
|
|
const { money, source_id } = i;
|
|
|
let cg = money;
|
|
|
- const os = outBill.filter(f => f.source_id === source_id);
|
|
|
+ const os = outBill.filter((f) => f.source_id === source_id);
|
|
|
for (const o of os) {
|
|
|
cg = this.ctx.minus(cg, o.money);
|
|
|
}
|
|
@@ -78,6 +78,8 @@ class CashBackService extends CrudService {
|
|
|
const type = _.get(cb_config, 'back_type');
|
|
|
if (!type) continue;
|
|
|
const money = _.get(cb_config, 'money');
|
|
|
+ // 返现/比例小于等于 0则不需要进行
|
|
|
+ if (this.ctx.minus(money, 0) <= 0) continue;
|
|
|
if (type === 'fixed') rmoney = this.ctx.plus(rmoney, money);
|
|
|
else if (type === 'percent') {
|
|
|
const specId = _.get(gs, '_id');
|