Commit 03f09f5f by zhaoxiqing

gsb

parent 3edcab1d
...@@ -2,24 +2,27 @@ var system = require("../../system") ...@@ -2,24 +2,27 @@ var system = require("../../system")
const md5 = require("MD5"); const md5 = require("MD5");
const logCtl = system.getObject("web.oplogCtl"); const logCtl = system.getObject("web.oplogCtl");
const moment = require("moment"); const moment = require("moment");
class ChannelApi { class ChannelApi {
constructor() { constructor() {
this.channelSve = system.getObject("service.channelSve"); this.channelSve = system.getObject("service.channelSve");
this.esettleSve = system.getObject("service.esettleSve"); this.esettleSve = system.getObject("service.esettleSve");
this.restClient = system.getObject("util.restClient"); this.restClient = system.getObject("util.restClient");
this.esettleofflineitemSve = system.getObject("service.esettleofflineitemSve" ); this.esettleofflineitemSve = system.getObject("service.esettleofflineitemSve");
this.FQURL = "http://yunfuapi-dev.gongsibao.com/crm/order/submit" this.FQURL = "http://yunfuapi-dev.gongsibao.com/crm/order/submit";
this.pushfqlogSve = system.getObject("service.pushfqlogSve")
this.esettleofflineSve = system.getObject("service.esettleofflineSve")
} }
//渠道绑定 //渠道绑定
async bindPlatform(queryobj, qobj, req) { async bindPlatform(queryobj, qobj, req) {
if(!this.trim(queryobj.platform_id)){ if (!this.trim(queryobj.platform_id)) {
return system.getErrResult2("platform_id不能为空") return system.getErrResult2("platform_id不能为空")
} }
if(!this.trim(queryobj.channel_id)){ if (!this.trim(queryobj.channel_id)) {
return system.getErrResult2("channel_id不能为空") return system.getErrResult2("channel_id不能为空")
} }
if(!this.trim(queryobj.platform_channel_id)){ if (!this.trim(queryobj.platform_channel_id)) {
return system.getErrResult2("platform_channel_id不能为空") return system.getErrResult2("platform_channel_id不能为空")
} }
var result = await this.channelSve.bindPlatform(queryobj); var result = await this.channelSve.bindPlatform(queryobj);
...@@ -27,112 +30,132 @@ class ChannelApi { ...@@ -27,112 +30,132 @@ class ChannelApi {
} }
//绑定渠道推送 //绑定渠道推送
async pushbindingchannel(queryobj, qobj, req){ async pushbindingchannel(queryobj, qobj, req) {
queryobj.begin = moment().subtract(1, 'days').format('YYYY-MM-DD 00:00:00'); /*前一天的时间*/ queryobj.begin = moment().subtract(1, 'days').format('YYYY-MM-DD 00:00:00'); /*前一天的时间*/
queryobj.end = moment().subtract(1, 'days').format('YYYY-MM-DD 23:59:59'); /*前一天的时间*/ queryobj.end = moment().subtract(1, 'days').format('YYYY-MM-DD 23:59:59'); /*前一天的时间*/
var result = await this.channelSve.pushbindingchannel(queryobj); var result = await this.channelSve.pushbindingchannel(queryobj);
var data = result.data; var data = result.data;
if(data.length > 0){ if (data.length > 0) {
for (let i= 0 ; i<data.length; i++){ for (let i = 0; i < data.length; i++) {
if(data[i].channel_id == '10000' && data[i].origin_merchant_id != ''){ if (data[i].channel_id == '10000' && data[i].origin_merchant_id != '') {
var busiData =await this.esettleSve.findBybusiId(data[i].origin_merchant_id); var busiData = await this.esettleSve.findBybusiId(data[i].origin_merchant_id);
if(busiData.length > 0){ if (busiData.length > 0) {
for (let j=0;j < busiData.length; j++){ for (let j = 0; j < busiData.length; j++) {
var pushData = this.getBusiData(busiData[j],data[i]); var pushData = this.getBusiData(busiData[j], data[i]);
var rc = system.getObject("util.aliyunClient");
var rtn = null;
rtn = await rc.post(this.FQURL, pushData);
console.log(pushData)
console.log(rtn)
}
}
}else {
if(data[i].origin_merchant_id != ''){
var esettleoffline = await this.esettleofflineSve.findOne({"ecompany_id":data[i].origin_merchant_id});
if(esettleoffline != null){
var pushData = this.getBusiDatas(esettleoffline.dataValues,data[i]);
var rc = system.getObject("util.aliyunClient"); var rc = system.getObject("util.aliyunClient");
var rtn = null; var rtn = null;
rtn = await rc.post(this.FQURL, pushData); rtn = await rc.post(this.FQURL, pushData);
console.log(pushData) if (rtn.success == true) {
console.log(rtn) result.contractNo = rtn.data.contractNo;
result.topush = "0";
result.param = pushData.param;
this.pushfqlogSve.create(result)
} else {
result.topush = "-1";
result.errorMsg = rtn.errorMsg;
result.param = pushData.param;
this.pushfqlogSve.create(result)
}
} }
} }
} else {
if (data[i].origin_merchant_id != '') {
var esettleoffline = await this.esettleofflineSve.findOne({"ecompany_id": data[i].origin_merchant_id});
if (esettleoffline != null) {
var pushData = this.getBusiDatas(esettleoffline.dataValues, data[i]);
var rc = system.getObject("util.aliyunClient");
var rtn = null;
rtn = await rc.post(this.FQURL, pushData);
var result = JSON.parse(system.decryption(pushData.param));
if (rtn.success == true) {
result.contractNo = rtn.data.contractNo;
result.topush = "0";
result.param = pushData.param;
this.pushfqlogSve.create(result)
} else {
result.topush = "-1";
result.errorMsg = rtn.errorMsg;
result.param = pushData.param;
this.pushfqlogSve.create(result)
}
}
} }
}
} }
} }
} }
async paydayCount(queryobj, qobj, req){ async paydayCount(queryobj, qobj, req) {
var data = await this.separateGet(queryobj); var data = await this.separateGet(queryobj);
console.log(data.dataValues) console.log(data.dataValues)
} }
async paydayDetails(queryobj, qobj, req){ async paydayDetails(queryobj, qobj, req) {
var data = await this.separateGet(queryobj); var data = await this.separateGet(queryobj);
} }
async separateGet(queryobj){ async separateGet(queryobj) {
let encry = system.decryption(queryobj.param); let encry = system.decryption(queryobj.param);
encry = JSON.parse(encry); encry = JSON.parse(encry);
if(encry.channel_id == 10000){ if (encry.channel_id == 10000) {
var busiData =await this.esettleSve.findByIdList(encry.data_id); var busiData = await this.esettleSve.findByIdList(encry.data_id);
return busiData; return busiData;
} }
var esettleoffline = await this.esettleofflineitemSve.find({"esettleoffline_id":encry.data_id}); var esettleoffline = await this.esettleofflineitemSve.find({"esettleoffline_id": encry.data_id});
return esettleoffline; return esettleoffline;
} }
getBusiData (da,chnanel){ getBusiData(da, chnanel) {
var resultData = { var resultData = {
"idempotentId":da.out_trade_no,// 业务编号(订单id) "idempotentId": da.id.toString(),// 业务编号(订单id)
"idempotentSource":"bpo_xbg",// 来源编号,写死:bpo_xbg "idempotentSource": "bpo_xbg",// 来源编号,写死:bpo_xbg
"idempotentSourceName":"BPO",// 来源编号,写死:BPO薪必果 "idempotentSourceName": "BPO",// 来源编号,写死:BPO薪必果
"thirdPartyChannelId":"10000",// 渠道id "thirdPartyChannelId": chnanel.channel_id.toString(),// 渠道id
"thirdPartyCustomerId":da.busi_id,// 第三方客户id "thirdPartyCustomerId": da.id.toString(),// 第三方客户id
"productId":"5e6b02cc3290c3000a3a63dc",// 云服产品id (测试环境) "productId": "5e6b02cc3290c3000a3a63dc",// 云服产品id (测试环境)
"allotRatio":"50",// 分润比例(百分比的数字部分(如:50代表50%)) // "allotRatio":"50",// 分润比例(百分比的数字部分(如:50代表50%))
"orderPrice":da.deduct_amt,// 订单金额 "orderPrice": da.deduct_amt,// 订单金额
"productQuantity":"1",// 产品数量 "productQuantity": "1",// 产品数量
"companyName":chnanel.merchant_name,// 公司名称 "companyName": chnanel.merchant_name,// 公司名称
"phone":"13722223333" "phone": chnanel.contact_mobile
}; };
var str = { var str = {
"data_id":da.id,// 发薪批次id tbl_order.id 或者 c_esettle_offline.id "data_id": da.id,// 发薪批次id tbl_order.id 或者 c_esettle_offline.id
"channel_id":chnanel.channel_id,//渠道id "channel_id": chnanel.channel_id,//渠道id
"channel_merchant_id":da.busi_id,//渠道商户id "channel_merchant_id": chnanel.id,//渠道商户id
"origin_merchant_id":chnanel.origin_merchant_id,//来源商户id "origin_merchant_id": chnanel.origin_merchant_id,//来源商户id
"pushplatform_channel_id":chnanel.platform_id,//对方渠道id "platform_channel_id": chnanel.platform_id,//对方渠道id
}; };
let encry = System.encryption(JSON.stringify(str)); let encry = System.encryption(JSON.stringify(str));
resultData.param =system.encryption(encry); resultData.param = system.encryption(encry);
return resultData; return resultData;
} }
getBusiDatas (da,chnanel){
var resultData = { getBusiDatas(da, chnanel) {
"idempotentId":da.id,// 业务编号(订单id) var resultData = {
"idempotentSource":"bpo_xbg",// 来源编号,写死:bpo_xbg "idempotentId": da.id.toString(),// 业务编号(订单id)
"idempotentSourceName":"BPO",// 来源编号,写死:BPO薪必果 "idempotentSource": "bpo_xbg",// 来源编号,写死:bpo_xbg
"thirdPartyChannelId":"10000",// 渠道id "idempotentSourceName": "BPO",// 来源编号,写死:BPO薪必果
"thirdPartyCustomerId":da.busi_id,// 第三方客户id "thirdPartyChannelId": chnanel.channel_id.toString(),// 渠道id
"productId":"5e6b02cc3290c3000a3a63dc",// 云服产品id (测试环境) "thirdPartyCustomerId": da.id.toString(),// 第三方客户id
"allotRatio":"50",// 分润比例(百分比的数字部分(如:50代表50%)) "productId": "5e6b02cc3290c3000a3a63dc",// 云服产品id (测试环境)
"orderPrice":da.amt,// 订单金额 // "allotRatio":"50",// 分润比例(百分比的数字部分(如:50代表50%))
"productQuantity":"1",// 产品数量 "orderPrice": da.amt,// 订单金额
"companyName":da.ecompanyName,// 公司名称 "productQuantity": "1",// 产品数量
"phone":"13722223333" "companyName": da.ecompanyName,// 公司名称
"phone": chnanel.contact_mobile
}; };
var str = { var str = {
"data_id":da.id,// 发薪批次id tbl_order.id 或者 c_esettle_offline.id "data_id": da.id,// 发薪批次id tbl_order.id 或者 c_esettle_offline.id
"channel_id":chnanel.channel_id,//渠道id "channel_id": chnanel.channel_id,//渠道id
"channel_merchant_id":da.busi_id,//渠道商户id "channel_merchant_id": chnanel.id,//渠道商户id
"origin_merchant_id":chnanel.origin_merchant_id,//来源商户id "origin_merchant_id": chnanel.origin_merchant_id,//来源商户id
"pushplatform_channel_id":chnanel.platform_id,//对方渠道id "platform_channel_id": chnanel.platform_id,//对方渠道id
}; };
resultData.param =system.encryption(JSON.stringify(str)); resultData.param = system.encryption(JSON.stringify(str));
return resultData; return resultData;
} }
...@@ -144,4 +167,5 @@ class ChannelApi { ...@@ -144,4 +167,5 @@ class ChannelApi {
return o.toString().trim(); return o.toString().trim();
} }
} }
module.exports = ChannelApi; module.exports = ChannelApi;
const system = require("../../system");
const Dao = require("../dao.base");
class pushfqlogDao extends Dao {
constructor() {
super(Dao.getModelName(pushfqlogDao));
}
}
module.exports = pushfqlogDao;
const system=require("../../system");
const settings=require("../../../config/settings");
const uiconfig=system.getUiConfig2(settings.wxconfig.appId);
module.exports = (db, DataTypes) => {
return db.define("pushfqlog", {
data_id:DataTypes.STRING,
channel_id:DataTypes.STRING,
channel_merchant_id:DataTypes.STRING,
platform_channel_id:DataTypes.STRING,
origin_merchant_id:DataTypes.STRING,
topush:DataTypes.STRING,
contractNo:DataTypes.STRING,
param:DataTypes.STRING,
errorMsg:DataTypes.STRING,
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'c_pushfq_log',
validate: {},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
const system = require("../../system");
const ServiceBase = require("../sve.base")
const settings = require("../../../config/settings")
class pushfqlogService extends ServiceBase {
constructor() {
super(ServiceBase.getDaoName(pushfqlogService));
}
}
module.exports = pushfqlogService;
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
"MD5": "^1.3.0", "MD5": "^1.3.0",
"after": "^0.8.2", "after": "^0.8.2",
"ali-oss": "^4.12.2", "ali-oss": "^4.12.2",
"aliyun-api-gateway": "^1.1.6",
"axios": "^0.19.2", "axios": "^0.19.2",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"base64id": "^1.0.0", "base64id": "^1.0.0",
......
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