Commit 19a43cc8 by 王昆

gsb

parent 228891f9
...@@ -745,6 +745,74 @@ class BpoSDPJApi { ...@@ -745,6 +745,74 @@ class BpoSDPJApi {
// return cashInfo; // return cashInfo;
// } // }
async testCashAmtTaskMoreIds(obj, req) {
let lessId = Number(obj.lessId || 0);
let mchtId = obj.mchtId || "";
let limit = Number(obj.limit || 0);
let ids = await this.ccashinfoSve.moreIds(lessId, mchtId, limit);
if (!ids || ids.length == 0) {
return "";
}
for (let id of ids) {
try {
this.syncOneCashAmt(id.id);
} catch (e) {
console.log('------------testCashAmtTaskByIds------------error', e);
}
}
return "生成中";
}
async testCashAmtTaskByIds(obj, req) {
let ids = obj.ids;
if (!ids || ids.length == 0) {
return "";
}
for (let id of ids) {
try {
await this.syncOneCashAmt(id);
} catch (e) {
console.log('------------testCashAmtTaskByIds------------error', e);
}
}
return "生成中";
}
async syncOneCashAmt(id) {
try {
console.log('------------syncOneCashAmt------------ id = ', id);
let cashInfo = await this.ccashinfoSve.findById(id);
let api = await this.ecompanybusiSve.findOne({
appId: cashInfo.app_id,
etemplate_id: cashInfo.ecid,
mchtId: cashInfo.mchtId,
});
await this.syncCashAmt(cashInfo, api);
return cashInfo;
} catch (e) {
console.log('------------syncOneCashAmt------------error', e);
}
}
async syncCashAmt(cashInfo, api) {
try {
let item = await this.getActualAmt(cashInfo, api);
console.log(item);
if (!item || !item.amt) {
return;
}
cashInfo.deduct_amt = item.deductAmt;
cashInfo.income_tax = item.incomeTax;
cashInfo.service_tax = item.serviceTax;
cashInfo.added_value_tax = item.addedValueTax;
await cashInfo.save();
} catch (e) {
console.log('------------syncCashAmt------------error', e);
}
}
async getActualAmt(cashInfo, api) { async getActualAmt(cashInfo, api) {
let params = { let params = {
"appId": cashInfo.app_id, "appId": cashInfo.app_id,
...@@ -835,7 +903,7 @@ class BpoSDPJApi { ...@@ -835,7 +903,7 @@ class BpoSDPJApi {
console.log("------------- wx-sdpj转账回调 签名错误 --------------"); console.log("------------- wx-sdpj转账回调 签名错误 --------------");
return {code: ""}; return {code: ""};
} }
cashInfo.trade_notify_time = new Date();
// 回调逻辑判断 // 回调逻辑判断
let respTradeStatus = this.trim(obj.tradeStatus); let respTradeStatus = this.trim(obj.tradeStatus);
if (respTradeStatus == "00") { if (respTradeStatus == "00") {
...@@ -851,6 +919,7 @@ class BpoSDPJApi { ...@@ -851,6 +919,7 @@ class BpoSDPJApi {
this.notifyCash(cashInfo.id); this.notifyCash(cashInfo.id);
} else { } else {
} }
this.syncOneCashAmt(cashInfo.id);
return {code: ""}; return {code: ""};
} catch (e) { } catch (e) {
console.log(e); console.log(e);
......
...@@ -13,5 +13,11 @@ class CcashinfoDao extends Dao{ ...@@ -13,5 +13,11 @@ class CcashinfoDao extends Dao{
return list; return list;
} }
async moreIds(id, mchtId, limit) {
let sql = "SELECT id FROM `c_cash_info` WHERE id >= :id AND deduct_amt = 0 AND mchtId = :mchtId LIMIT :limit";
let list = await this.customQuery(sql, {id: id, mchtId: mchtId, limit: limit});
return list;
}
} }
module.exports=CcashinfoDao; module.exports=CcashinfoDao;
...@@ -27,6 +27,26 @@ module.exports = (db, DataTypes) => { ...@@ -27,6 +27,26 @@ module.exports = (db, DataTypes) => {
type: DataTypes.BIGINT, type: DataTypes.BIGINT,
allowNull: true, allowNull: true,
}, },
actual_amt:{
type:DataTypes.BIGINT,
allowNull: true,
},
deduct_amt:{
type:DataTypes.BIGINT,
allowNull: true,
},
income_tax:{
type:DataTypes.BIGINT,
allowNull: true,
},
service_tax:{
type:DataTypes.BIGINT,
allowNull: true,
},
added_value_tax:{
type:DataTypes.BIGINT,
allowNull: true,
},
sign_url:{ sign_url:{
type:DataTypes.STRING, type:DataTypes.STRING,
allowNull: true, allowNull: true,
...@@ -71,8 +91,9 @@ module.exports = (db, DataTypes) => { ...@@ -71,8 +91,9 @@ module.exports = (db, DataTypes) => {
type:DataTypes.STRING, type:DataTypes.STRING,
allowNull: true, allowNull: true,
}, },
actual_amt:{
type:DataTypes.BIGINT, trade_notify_time: {
type:DataTypes.DATE,
allowNull: true, allowNull: true,
}, },
notify_rs: { notify_rs: {
......
...@@ -11,6 +11,10 @@ class CcashinfoService extends ServiceBase { ...@@ -11,6 +11,10 @@ class CcashinfoService extends ServiceBase {
return await this.dao.findUnNotifyIds(); return await this.dao.findUnNotifyIds();
} }
async moreIds(id, mchtId, limit) {
return await this.dao.moreIds(id, mchtId, limit);
}
/** /**
* fn:根据条件获取对象 * fn:根据条件获取对象
* @param params * @param params
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment