|
@@ -25,6 +25,7 @@ module.exports = app => {
|
|
|
async getContractList(fpid, needCheck = false) {
|
|
|
const list = await this.getAllDataByCondition({ where: { fpid }, orders: [['id', 'asc']] });
|
|
|
const updateData = [];
|
|
|
+ const needCheckKeys = ['c_code', 'name', 'total_price', 'entity', 'bank', 'bank_account'];
|
|
|
for (const l of list) {
|
|
|
const allList = l.cid ? await this.getAllDataByCondition({ where: { spid: l.spid, cid: l.cid } }) : [];
|
|
|
l.accumulate_pay_price = this._.sumBy(allList, 'pay_price');
|
|
@@ -34,29 +35,11 @@ module.exports = app => {
|
|
|
const contractInfo = await this.ctx.service.contract.getDataById(l.cid);
|
|
|
if (contractInfo) {
|
|
|
const condition = {};
|
|
|
- if (l.c_code !== contractInfo.c_code) {
|
|
|
- condition.c_code = contractInfo.c_code;
|
|
|
- l.c_code = contractInfo.c_code;
|
|
|
- }
|
|
|
- if (l.name !== contractInfo.name) {
|
|
|
- condition.name = contractInfo.name;
|
|
|
- l.name = contractInfo.name;
|
|
|
- }
|
|
|
- if (l.total_price !== contractInfo.total_price) {
|
|
|
- condition.total_price = contractInfo.total_price;
|
|
|
- l.total_price = contractInfo.total_price;
|
|
|
- }
|
|
|
- if (l.entity !== contractInfo.entity) {
|
|
|
- condition.entity = contractInfo.entity;
|
|
|
- l.entity = contractInfo.entity;
|
|
|
- }
|
|
|
- if (l.bank !== contractInfo.bank) {
|
|
|
- condition.bank = contractInfo.bank;
|
|
|
- l.bank = contractInfo.bank;
|
|
|
- }
|
|
|
- if (l.bank_account !== contractInfo.bank_account) {
|
|
|
- condition.bank_account = contractInfo.bank_account;
|
|
|
- l.bank_account = contractInfo.bank_account;
|
|
|
+ for (const key of needCheckKeys) {
|
|
|
+ if (l[key] !== contractInfo[key]) {
|
|
|
+ condition[key] = contractInfo[key];
|
|
|
+ l[key] = contractInfo[key];
|
|
|
+ }
|
|
|
}
|
|
|
if (Object.keys(condition).length > 0) {
|
|
|
updateData.push({ id: l.id, ...condition });
|