Commit 4c409c10 by zhaoxiqing

gsb

parent cffe9c82
......@@ -11,9 +11,10 @@ class ChannelApi {
this.esettleSve = system.getObject("service.esettleSve");
this.restClient = system.getObject("util.restClient");
this.esettleofflineitemSve = system.getObject("service.esettleofflineitemSve");
this.FQURL = settings.FQYF().pushOrderApi;
this.pushfqlogSve = system.getObject("service.pushfqlogSve")
this.esettleofflineSve = system.getObject("service.esettleofflineSve")
this.FQURL = settings.FQYF();
this.pushfqlogSve = system.getObject("service.pushfqlogSve");
this.esettleofflineSve = system.getObject("service.esettleofflineSve");
this.busistatSve = system.getObject("service.busistatSve");
}
//渠道绑定
......@@ -33,7 +34,7 @@ class ChannelApi {
//绑定渠道推送(弃用)
async pushbindingchannel(queryobj, qobj, req) {
if(queryobj.day) {
if (queryobj.day) {
queryobj.begin = queryobj.day + ' 00:00:00'; /* 自定义时间 */
queryobj.end = queryobj.day + ' 23:59:59'; /* 自定义时间 */
} else {
......@@ -51,7 +52,7 @@ class ChannelApi {
var pushData = this.getBusiData(busiData[j], data[i]);
var rc = system.getObject("util.aliyunClient");
var rtn = null;
rtn = await rc.post(this.FQURL, pushData);
rtn = await rc.post(this.FQURL.pushOrderApi, pushData);
console.log(pushData)
console.log(rtn)
var result = JSON.parse(system.decryption(decodeURIComponent(pushData.param)));
......@@ -75,7 +76,7 @@ class ChannelApi {
var pushData = this.getBusiDatas(esettleoffline.dataValues, data[i]);
var rc = system.getObject("util.aliyunClient");
var rtn = null;
rtn = await rc.post(this.FQURL, pushData);
rtn = await rc.post(this.FQURL.pushOrderApi, pushData);
console.log(pushData)
console.log(rtn)
var result = JSON.parse(system.decryption(decodeURIComponent(pushData.param)));
......@@ -105,40 +106,40 @@ class ChannelApi {
async pushAddChannel(queryobj, qobj, req) {
try {
if(!queryobj.platform_id){
if (!queryobj.platform_id) {
return system.getResultFail(-1, "platform_id不能为空");
}
if(!queryobj.ctype){
if (!queryobj.ctype) {
return system.getResultFail(-1, "ctype不能为空");
}
if(!queryobj.name){
if (!queryobj.name) {
return system.getResultFail(-1, "name不能为空");
}
if(!queryobj.idcode){
if (!queryobj.idcode) {
return system.getResultFail(-1, "idcode不能为空");
}
if(queryobj.ctype == 1){
if(!queryobj.business_license){
if (queryobj.ctype == 1) {
if (!queryobj.business_license) {
return system.getResultFail(-1, "business_license不能为空");
}
}else {
if(!queryobj.idcard_front){
} else {
if (!queryobj.idcard_front) {
return system.getResultFail(-1, "idcard_front不能为空");
}
if(!queryobj.idcard_back){
if (!queryobj.idcard_back) {
return system.getResultFail(-1, "idcard_back不能为空");
}
}
if(!queryobj.contact_man){
if (!queryobj.contact_man) {
return system.getResultFail(-1, "contact_man不能为空");
}
if(!queryobj.contact_mobile){
if (!queryobj.contact_mobile) {
return system.getResultFail(-1, "contact_mobile不能为空");
}
if(!queryobj.contact_email){
if (!queryobj.contact_email) {
return system.getResultFail(-1, "contact_email不能为空");
}
if(!queryobj.contact_addr){
if (!queryobj.contact_addr) {
return system.getResultFail(-1, "contact_addr不能为空");
}
......@@ -147,7 +148,7 @@ class ChannelApi {
var bind = {
platform_id: queryobj.platform_id,
channel_id: da.data.id,
platform_channel_id:10000
platform_channel_id: 10000
}
var result = this.channelSve.bindPlatform(bind);
console.log(result);
......@@ -160,34 +161,37 @@ class ChannelApi {
}
//商户添加
async pushAddMerchant(queryobj, qobj, req){
async pushAddMerchant(queryobj, qobj, req) {
try {
if(!queryobj.channel_id){
if (!queryobj.channel_id) {
return system.getResultFail(-1, "channel_id不能为空");
}
// if(!queryobj.origin_id){
// return system.getResultFail(-1, "origin_id不能为空");
// }
if(!queryobj.merchant_name){
if (!queryobj.merchant_name) {
return system.getResultFail(-1, "merchant_name不能为空");
}
if(!queryobj.contact_man){
if (!queryobj.contact_man) {
return system.getResultFail(-1, "contact_man不能为空");
}
if(!queryobj.contact_mobile){
if (!queryobj.contact_mobile) {
return system.getResultFail(-1, "contact_mobile不能为空");
}
if(!queryobj.contact_email){
if (!queryobj.contact_email) {
return system.getResultFail(-1, "contact_email不能为空");
}
if(!queryobj.contact_addr){
if (!queryobj.contact_addr) {
return system.getResultFail(-1, "contact_addr不能为空");
}
if(queryobj.id){
if(!queryobj.origin_merchant_id){
if (!queryobj.merchanmt_id) {
return system.getResultFail(-1, "merchanmt_id不能为空");
}
if (queryobj.id) {
if (!queryobj.origin_merchant_id) {
return system.getResultFail(-1, "origin_merchant_id不能为空");
}
if(!queryobj.origin_merchant_name){
if (!queryobj.origin_merchant_name) {
return system.getResultFail(-1, "origin_merchant_name不能为空");
}
}
......@@ -287,7 +291,7 @@ class ChannelApi {
async pushChannels(queryobj, qobj, req) {
let begin;
let end;
if(queryobj.day) {
if (queryobj.day) {
begin = queryobj.day + ' 00:00:00'; /* 自定义时间 */
end = queryobj.day + ' 23:59:59'; /* 自定义时间 */
} else {
......@@ -296,11 +300,11 @@ class ChannelApi {
}
var merchantIds = await this.channelSve.getPushMerchantIds() || [];
if(merchantIds.length == 0) {
if (merchantIds.length == 0) {
return system.getErrResult2("暂无绑定渠道");
}
for(let merchantId of merchantIds) {
for (let merchantId of merchantIds) {
console.log(merchantId, "----------------------------");
// 查渠道商户id
let merchant = (await this.channelSve.merchantInfo({id: merchantId}) || {}).data;
......@@ -315,10 +319,10 @@ class ChannelApi {
async pushOnlineOrder(merchant, begin, end) {
let orders = await this.esettleSve.findPushInfos(merchant.origin_merchant_id, begin, end) || [];
if(orders.length == 0) {
if (orders.length == 0) {
return;
}
for(let order of orders) {
for (let order of orders) {
// 获取推送数据
let pushData = this.getPushData(merchant, order);
......@@ -327,7 +331,7 @@ class ChannelApi {
// 推送数据
var rc = system.getObject("util.aliyunClient");
let rtn = await rc.post(this.FQURL, pushData.data);
let rtn = await rc.post(this.FQURL.pushOrderApi, pushData.data);
// 返回结果都保存到toPush中吧
log.topush = JSON.stringify(rtn);
......@@ -337,10 +341,10 @@ class ChannelApi {
async pushOfflineOrder(merchant, begin, end) {
let orders = await this.esettleofflineSve.findPushInfos(merchant.origin_merchant_id, begin, end) || [];
if(orders.length == 0) {
if (orders.length == 0) {
return;
}
for(let order of orders) {
for (let order of orders) {
// 获取推送数据
let pushData = this.getPushData(merchant, order);
......@@ -349,7 +353,7 @@ class ChannelApi {
// 推送数据
var rc = system.getObject("util.aliyunClient");
let rtn = await rc.post(this.FQURL, pushData.data);
let rtn = await rc.post(this.FQURL.pushOrderApi, pushData.data);
// 返回结果都保存到toPush中吧
log.topush = JSON.stringify({rtn});
......@@ -407,7 +411,7 @@ class ChannelApi {
if (!param.data_id) {
return system.getErrResult2("参数错误, 订单不存在");
}
let merchant = await this.channelSve.merchantInfo({ id: param.channel_merchant_id }) || {};
let merchant = await this.channelSve.merchantInfo({id: param.channel_merchant_id}) || {};
merchant = merchant.data;
if (!merchant) {
return system.getErrResult2(`渠道商户${param.channel_merchant_id}不存在`);
......@@ -457,7 +461,7 @@ class ChannelApi {
if (!param.data_id) {
return system.getErrResult2("参数错误, 订单不存在");
}
let merchant = await this.channelSve.merchantInfo({ id: param.channel_merchant_id }) || {};
let merchant = await this.channelSve.merchantInfo({id: param.channel_merchant_id}) || {};
merchant = merchant.data;
if (!merchant) {
return system.getErrResult2(`渠道商户${param.channel_merchant_id}不存在`);
......@@ -468,15 +472,15 @@ class ChannelApi {
page = await this.esettleSve.pageByOrderId(param.data_id, currentPage, pageSize);
} else {
page = await this.esettleofflineitemSve.pageByByOrderId(param.data_id, currentPage, pageSize);
if(page.rows) {
for(let row of page.rows) {
if (page.rows) {
for (let row of page.rows) {
row.deduct_amt = row.amt;
row.trade_status = "02";
}
}
}
if(page && page.rows) {
for(let row of page.rows) {
if (page && page.rows) {
for (let row of page.rows) {
row.actual_amt = system.f2y(row.actual_amt);
row.income_tax = system.f2y(row.income_tax);
row.service_tax = system.f2y(row.service_tax);
......@@ -486,6 +490,89 @@ class ChannelApi {
return system.getResult2(page);
}
//------------------------------------------------财务中心对账 begin------------------------------------------------------------\\
async pushReconciliation(queryobj, qobj, req) {
let begin;
let end;
let month;
if (queryobj.num) {
//自定义时间
month = moment().add().month(moment().month() - queryobj.num).startOf('month').format("YYYYMM");
begin = moment().add().month(moment().month() - queryobj.num).startOf('month').format("YYYYMMDD");
end = moment().add().month(moment().month() - queryobj.num).endOf('month').format("YYYYMMDD");
} else {
month = moment().add().month(moment().month() - queryobj.num).startOf('month').format("YYYYMM");
begin = moment().add().month(moment().month() - 1).startOf('month').format("YYYYMMDD");
end = moment().add().month(moment().month() - 1).endOf('month').format("YYYYMMDD");
}
var merchantIds = await this.channelSve.getchannelIds() || [];
if (merchantIds.length == 0) {
return system.getErrResult2("暂无绑定渠道");
}
for (let merchantId of merchantIds) {
console.log(merchantId, "----------------------------");
// 查渠道所有商户
let merchant = await this.channelSve.getchannelmerchantIds({channel_id: merchantId.channel_id}) || {};
if (merchant.length > 0) {
let busiId = [];
for (let mer of merchant) {
busiId.push(mer.origin_merchant_id);
}
if (busiId) {
var list = await this.busistatSve.gettomonthList(busiId, begin, end);
if (list) {
let pushData = this.gettopushdata(merchantId, list, month, merchant);
var rtn = null;
var rc = system.getObject("util.aliyunClient");
rtn = await rc.post(this.FQURL.pushOrderSum, pushData);
// console.log(pushData);
console.log(rtn);
}
}
}
}
}
gettopushdata(merchantId, list, month, merchant) {
var data = {
channel_id: merchantId.platform_id, //蜂擎云服渠道id,
channel_name: merchantId.name || " ",//渠道上名称,
month: month, //月份(202006YYYYMM)channel_name: 渠道上名称,
trans_amt_total: 0, //本月充值总额额,
deduct_amt: 0, //扣除金额,
amt: 0, //申请发薪金额,
actual_amt: 0, //实发金额,
income_tax: 0,//个税,
service_tax: 0,//服务费金额,
added_value_tax: 0, //增值税,
items: list
}
for (let item of list) {
for (let i = 0; i < merchant.length; i++) {
if (merchant[i].origin_merchant_id == item.busi_id) {
item.merchant_id = merchant[i].merchant_id;
break;
}
}
item.user_department_name = "渠道销售中心";
data.trans_amt_total = data.trans_amt_total + item.trans_amt;
data.deduct_amt = data.deduct_amt + item.deduct_amt;
data.amt = data.amt + item.amt;
data.actual_amt = data.actual_amt + item.actual_amt;
data.income_tax = data.income_tax + item.income_tax;
data.service_tax = data.service_tax + item.service_tax;
data.added_value_tax = data.added_value_tax + item.added_value_tax;
}
return data;
}
//------------------------------------------------财务中心对账 end------------------------------------------------------------\\
trim(o) {
if (!o) {
return "";
......
......@@ -63,6 +63,26 @@ class BusistatDao extends Dao {
return await this.customQuery(sql.join(" "), params);
}
async gettomonthList(param){
let sql = [];
sql.push("SELECT");
sql.push("*");
sql.push("FROM `c_busi_stat`");
sql.push("WHERE 1 = 1");
if(param.busiId){
sql.push("AND busi_id IN (:busiId)");
}
if(param.begin) {
sql.push("AND stat_day >= :begin");
}
if(param.end) {
sql.push("AND stat_day <= :end");
}
return await this.customQuery(sql.join(" "), param);
}
async setCondition(sql, params) {
if (!sql || !params) {
return;
......
......@@ -50,6 +50,12 @@ class BusistatService extends ServiceBase {
item.added_value_tax = system.f2y(item.added_value_tax);
}
}
async gettomonthList(busiId, begin, end) {
return await this.dao.gettomonthList({busiId: busiId, begin: begin, end: end});
}
}
module.exports = BusistatService;
......@@ -39,7 +39,10 @@ class ChannelService extends microService {
}
async bindPlatform(params){
return await this.callms("channel" , "bindPlatform", params);
}
async getchannelIds(params){
return await this.callms("channel" , "channelIds", params);
}
async pushbindingchannel(params){
......@@ -50,6 +53,9 @@ class ChannelService extends microService {
async merchantInfo(params) {
return await this.callms("channel", "merchantInfo", params);
}
async getchannelmerchantIds(params) {
return await this.callms("channel", "getchannelmerchantIds", params);
}
async merchantSave(params) {
return await this.callms("channel", "merchantSave", params);
}
......@@ -63,5 +69,7 @@ class ChannelService extends microService {
async getPushMerchantIds(params){
return await this.callms("channel" , "getPushMerchantIds", params);
}
}
module.exports = ChannelService;
......@@ -9,7 +9,7 @@ var settings = {
// dbname : "bpo",
// user : "write",
// password : "write",
dbname: "bpo2",
dbname: "bpo",
user: "write",
password: "write",
config: {
......
......@@ -36,6 +36,7 @@ var settings = {
v: "crkyej0xlmqa6bmvqijun6ltxparllyn",
productId: "5e6b02cc3290c3000a3a63dc",// 云服产品id
pushOrderApi: "http://yunfuapi-dev.gongsibao.com/crm/order/submit",// 云服产品id
pushOrderSum : "http://yunfuapi-dev.gongsibao.com/cloudapi/bpo/pushBill",
};
} else {
return {
......@@ -43,6 +44,7 @@ var settings = {
v: "e5e2ytnn6nrkr9qnqk4w5e6z0xlhkznu",
productId: "5e6c89d54c52bf000a750bc5",// 云服产品id (生产环境)
pushOrderApi: "http://yunfuapi.gongsibao.com/crm/order/submit",// 云服产品id (生产环境)
pushOrderSum :"http://yunfuapi.gongsibao.com/cloudapi/bpo/pushBill",
};
}
},
......
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