|
@@ -52,7 +52,7 @@ class ShopInBillService extends CrudService {
|
|
|
const obj = { shop: _.get(afterSale, 'shop') };
|
|
|
obj.time = moment().format('YYYY-MM-DD HH:mm:ss');
|
|
|
obj.source = '-3';
|
|
|
- obj.source_id = _.get(afterSale, '_id');
|
|
|
+ obj.source_id = _.get(afterSale, 'order_detail');
|
|
|
const limit = _.get(inBill, 'receipts');
|
|
|
if (this.ctx.minus(limit, returnMoney) >= 0) obj.receipts = returnMoney;
|
|
|
else obj.receipts = limit;
|
|
@@ -75,17 +75,22 @@ class ShopInBillService extends CrudService {
|
|
|
const inBill = list.filter(f => parseInt(f.source) >= 0);
|
|
|
const outBill = list.filter(f => parseInt(f.source) < 0);
|
|
|
const getOutBill = list.filter(f => f.source === '-1');
|
|
|
- const outBillMoney = getOutBill.reduce((p, n) => this.ctx.plus(p, n.money), 0);
|
|
|
+ const outBillMoney = getOutBill.reduce((p, n) => this.ctx.plus(p, n.receipts), 0);
|
|
|
+ const canGetIds = [];
|
|
|
+ const shouldOutIds = [];
|
|
|
for (const i of inBill) {
|
|
|
const cAt = _.get(i, 'time');
|
|
|
const m = moment().diff(cAt, 'm');
|
|
|
if (m >= min) {
|
|
|
// 已经过了提款时间,那就再找下,是否有该记录相应的退款
|
|
|
const { receipts: money, source_id } = i;
|
|
|
+ canGetIds.push(source_id);
|
|
|
let cg = money;
|
|
|
const os = outBill.filter(f => f.source_id === source_id);
|
|
|
+ console.log(`${source_id} 退款数: ${os.length}`);
|
|
|
for (const o of os) {
|
|
|
cg = this.ctx.minus(cg, o.receipts);
|
|
|
+ shouldOutIds.push(o.source_id);
|
|
|
}
|
|
|
canGet = this.ctx.plus(canGet, cg);
|
|
|
}
|