Commit afdfafe3 by 任晓松

360

parent a771d3bb
...@@ -26,7 +26,7 @@ class ProductAPI extends WEBBase { ...@@ -26,7 +26,7 @@ class ProductAPI extends WEBBase {
pobj.requestId = req.requestId; pobj.requestId = req.requestId;
var opResult = null; var opResult = null;
switch (action_type) { switch (action_type) {
case "getParamsFor360"://创建订单 case "getParamsFor360":
opResult = await this.utils360Sve.getParamsFor360(pobj, pobj.actionBody); opResult = await this.utils360Sve.getParamsFor360(pobj, pobj.actionBody);
break; break;
default: default:
......
...@@ -205,14 +205,31 @@ class QcCenterOrderService extends AppServiceBase { ...@@ -205,14 +205,31 @@ class QcCenterOrderService extends AppServiceBase {
async serviceProviderNotification(pobj) { async serviceProviderNotification(pobj) {
var res = await this.reqCenterOrderApi(pobj, "action/qcapi/springBoard"); var res = await this.reqCenterOrderApi(pobj, "action/qcapi/springBoard");
if (res && res.status == 0 && res.data) { if (res && res.status == 0 && res.data) {
pobj.actionType = "getPayOrderInfo";
let orderUrl = settings.centerOrderUrl() + "action/order/springBoard";
let orderResult = await this.restPostUrl(pobj, orderUrl);
if(orderResult.status !=0){
return system.getResultFail(-1,'查询订单失败')
}
let uapp_id = orderResult.data.receiptVoucher.uapp_id;
pobj.appInfo = {uapp_id : uapp_id};
pobj.actionType = "getAppInterface";
var reqUrl = settings.centerAppUrl() + "action/opProduct/springBoard";
var productItemInterfaceResult = await this.restPostUrl(pobj, reqUrl);
if(productItemInterfaceResult.status != 0){
system.getResultFail(-1,'获取接口参数失败')
}
pobj.interface_info = productItemInterfaceResult.data;
pobj.pushObj = res.data;
this.utilsPushSve.pushBusInfo(pobj,'pushStatus',1);
//推送数据至阿里 //推送数据至阿里
var pushObj = { // var pushObj = {
BizId: res.data.BizId, // BizId: res.data.BizId,
OfficialFileURL: res.data.OfficialFileURL, // OfficialFileURL: res.data.OfficialFileURL,
ApplicationStatus: res.data.ApplicationStatus // ApplicationStatus: res.data.ApplicationStatus
}; // };
//推送状态变更 // //推送状态变更
this.aliclient.reqbyget({ action: "AcceptPartnerNotification", reqbody: pushObj, apiVersion: "2019-05-08" }); // this.aliclient.reqbyget({ action: "AcceptPartnerNotification", reqbody: pushObj, apiVersion: "2019-05-08" });
return system.getResultSuccess(); return system.getResultSuccess();
} }
return res; return res;
...@@ -635,6 +652,29 @@ async foodRecordLogList(pobj) { ...@@ -635,6 +652,29 @@ async foodRecordLogList(pobj) {
return system.getResultSuccess(res); return system.getResultSuccess(res);
} }
//推送订单状态
async pushOrderStatus(pobj){
if (!pobj.interface_params) {
return system.getResult(null, "interface_params can not be empty,100400");
}
let interface_params_info = JSON.parse(pobj.interface_params);
if (!interface_params_info || !interface_params_info.pushUrl || !interface_params_info.action || interface_params_info.apiVersion) {
return system.getResult(null, "interface_params(pushUrl、action、apiVersion) can not be empty,100430");
}
let pushObj = {
BizId: pobj.pushObj.BizId,
OfficialFileURL: pobj.pushObj.OfficialFileURL,
ApplicationStatus: pobj.pushObj.ApplicationStatus
};
let obj = {
action:interface_params_info.action,
reqbody:pushObj,
apiVersion:interface_params_info.apiVersion
}
let result = await this.aliclient.reqbyget(obj);
return result;
}
// //推送ICP方案 // //推送ICP方案
// async pushIcpSolution1(pushObj, solutionNo, appInfo, self) { // async pushIcpSolution1(pushObj, solutionNo, appInfo, self) {
// //推送方案确认信息 // //推送方案确认信息
......
...@@ -2,56 +2,153 @@ var system = require("../../../system"); ...@@ -2,56 +2,153 @@ var system = require("../../../system");
var settings = require("../../../../config/settings"); var settings = require("../../../../config/settings");
const AppServiceBase = require("../../app.base"); const AppServiceBase = require("../../app.base");
const md5 = require('md5') const md5 = require('md5')
const logCtl = system.getObject("service.common.oplogSve");
//阿里支付类 //阿里支付类
class utils360Sve extends AppServiceBase { class utils360Sve extends AppServiceBase {
constructor() { constructor() {
super(); super();
this.centerAppUrl = settings.centerAppUrl(); this.centerAppUrl = settings.centerAppUrl();
} this.utilsAuthSve = system.getObject("service.utilsSve.utilsAuthSve")
//-------------------------------------------钉钉h5支付-----------------开始 this.pushlogSve = system.getObject("service.common.pushlogSve");
}
async getParamsFor360(pobj, actionBody) { //组合参数,由前端传到360
if (!actionBody.orderNo) { async getParamsFor360(pobj, actionBody) {
return system.getResult(null, "actionBody.orderNo can not be empty,100110"); if (!actionBody.orderNo) {
} return system.getResult(null, "actionBody.orderNo can not be empty,100110");
pobj.actionType = "getPayOrderInfo"; }
var orderUrl = settings.centerOrderUrl() + "action/order/springBoard"; let seaUrl = this.centerOrderUrl + 'opaction/opPayOrder/getOrderListByOrderServiceNo';
var orderResult = await this.restPostUrl(pobj, orderUrl); let seaRet = await this.restPostUrl(pobj, seaUrl);
if (orderResult.status != 0) { if (seaRet.status != 0) {
return orderResult; return system.getResultFail(-1, '获取订单信息失败')
} }
pobj.actionType ="getOrderDeliveryInfo"; let totalSum = 0;
var deliveryResult = await this.restPostUrl(pobj,orderUrl); let sku_id = '';
if (deliveryResult.status != 0) { let amount = 0;
return deliveryResult; let consignee = "";
let mobile = "";
let email = "";
for (let i = 0; i < seaRet.data.length; i++) {
let item = seaRet.data[i];
if(!mobile){
pobj.actionType.orderNo = item.orderNo;
pobj.actionType = "getOrderDeliveryInfo";
let deliveryResult = await this.restPostUrl(pobj, orderUrl);
consignee = deliveryResult.data.orderContact.contactName;
mobile = deliveryResult.data.orderContact.mobile;
email = deliveryResult.data.orderContact.email
}
sku_id = item.itemCode;
totalSum += Number(item.totalSum);
amount += Number(item.payTotalSum);
}
// let sku_id = orderResult.data.orderProduct.itemCode;
// let price = Number(orderResult.data.orderProduct.price)*100;
let price = totalSum * 100;
// let quantity = seaRet.data.length;
// let amount = Number(orderResult.data.receiptVoucher.totalSum)*100;
amount = amount * 100;
let order_id = pobj.actionBody.orderNo;
// let consignee = deliveryResult.data.orderContact.contactName;
// let mobile = deliveryResult.data.orderContact.mobile;
// let email = deliveryResult.data.orderContact.email;
let singStr = sku_id + price + order_id + pobj.appInfo.uapp_secret;
let sign = md5(singStr).toUpperCase();
// 推送参数
let result = {
sku_id: sku_id,
price: price,
quantity: seaRet.data.length,
amount: amount,
order_id: order_id,
consignee: consignee,
mobile: mobile,
email: email,
sign: sign
}
return system.getResult(result);
} }
let sku_id = orderResult.data.orderProduct.itemCode;
let price = Number(orderResult.data.orderProduct.price)*100; //更新订单状态到360
let quantity = orderResult.data.orderProduct.quantity; async pushOrderStatus(pobj) {
let amount = Number(orderResult.data.receiptVoucher.totalSum)*100; try {
let order_id = orderResult.data.receiptVoucher.sourceOrderNo; var verifyResult = await this.verifyParam(pobj);
let consignee = deliveryResult.data.orderContact.contactName; if (verifyResult.status != 0) {
let mobile = deliveryResult.data.orderContact.mobile; return await this.disposePushResultFail(pobj, verifyResult, "status->pushOrderStatus->verifyResult", this.pushlogFailType.FAILLOG);
let email = deliveryResult.data.orderContact.email; }
let singStr = sku_id + price + order_id + pobj.appInfo.uapp_secret; var interface_params_info = verifyResult.data;
let sign = md5(singStr).toUpperCase(); let token = await this.utilsAuthSve.get360Token();
let result ={ let url = interface_params_info.opUrl + '?token=' + token;
sku_id, //合同号,还是订单号
price, pobj.actionType = 'getOrderServiceNoByOrderNo'
quantity, let orderUrl = settings.centerOrderUrl() + 'action/order/springBoard'
amount, let orderItem = await this.restPostUrl(pobj,orderUrl);
order_id, if(orderItem.status !=0){
consignee, return orderItem;
mobile, }
email, let order_id = orderItem.data.orderServiceNo;
sign let ApplicationStatus = pobj.pushObj.ApplicationStatus;
let status = 0;
if (Number(ApplicationStatus) < 508) {
status = 30
} else {
status = 40;
}
let pushObj = {
order_id, status
}
let result = await this.restPostUrl(pushObj, url);
if(result.status ==0){
this.pushlogSve.createDb({
op: "360-pushOrderStatus",
content: JSON.stringify(pushObj),//推送的参数信息
resultInfo: JSON.stringify(result),
returnType: '1',
logLevel: '1',
opTitle: "推送360信息返回成功"
});
}else{
this.logCtl.error({
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
requestId: pobj.requestId || "",
op: "utilsSve/utils360Sve/pushOrderStatus",
content: "error:" + e.stack,
// clientIp: pobj.clientIp,
optitle: pobj.opType + "推送操作异常status->pushOrderStatus",
});
}
console.log(result,'-------------push360-----------------')
return result;
} catch (e) {
this.logCtl.error({
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
requestId: pobj.requestId || "",
op: "utilsSve/utils360Sve/pushOrderStatus",
content: "error:" + e.stack,
// clientIp: pobj.clientIp,
optitle: pobj.opType + "推送操作异常status->pushOrderStatus",
});
}
} }
return system.getResult(result);
}
//-------------------------------------------钉钉h5支付-----------------结束 // 参数信息验证
async verifyParam(pobj) {
var verify = system.getResultSuccess();
if (!pobj.interface_params) {
verify = system.getResult(null, "interface_params can not be empty,100400");
}
var interface_params_info = JSON.parse(pobj.interface_params);
if (!interface_params_info || !interface_params_info.opUrl) {
verify = system.getResult(null, "interface_params(pushUrl) can not be empty,100430");
}
verify.data = interface_params_info;
return verify;
}
} }
module.exports = utils360Sve; module.exports = utils360Sve;
...@@ -963,7 +963,7 @@ class UtilsOrderService extends AppServiceBase { ...@@ -963,7 +963,7 @@ class UtilsOrderService extends AppServiceBase {
} }
async channelPayNotify360(params, client_ip) {//渠道订单支付通知 async channelOrdersPayNotify(params, client_ip) {//渠道订单支付通知
try { try {
this.logCtl.info({ this.logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "渠道订单支付回调参数信息", optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "渠道订单支付回调参数信息",
...@@ -1004,47 +1004,57 @@ class UtilsOrderService extends AppServiceBase { ...@@ -1004,47 +1004,57 @@ class UtilsOrderService extends AppServiceBase {
params.appInfo = { uapp_id: appInfo.uapp_id }; params.appInfo = { uapp_id: appInfo.uapp_id };
params.pay_type = params.payType; params.pay_type = params.payType;
params.time_end = params.payTime; params.time_end = params.payTime;
//修改并返回订单支付状态,创建收款单 // 修改并返回订单支付状 态,创建收款单
// 这里修改了order_info的状态(status/paytime等) // 根据合同号获取所有订单 循环修改order_info 信息
var orderUrl = this.centerOrderUrl + "opaction/opPayOrder/receivePayCallBackNotifyByChannel"; let seaUrl = this.centerOrderUrl + 'opaction/opPayOrder/getOrderListByOrderServiceNo';
var opOrderResult = await this.restPostUrl(params, orderUrl); let seaRet = await this.restPostUrl(params,seaUrl);
if (opOrderResult.status != 0) { if(seaRet.status!=0){
opOrderResult.data = null; seaRet.data= null;
return opOrderResult; return seaRet;
} }
if(!opOrderResult.data){ let orderList = seaRet.data;
return opOrderResult; for(let i=0;i<orderList.length;i++){
} params.orderNo = orderList[i].orderNo;
opOrderResult.data.appInfo = { // 这里修改了order_info的状态(status/paytime等)
uapp_id: appInfo.uapp_id, var orderUrl = this.centerOrderUrl + "opaction/opPayOrder/receivePayCallBackNotifyByChannel";
uapp_key: appInfo.uapp_key, var opOrderResult = await this.restPostUrl(params, orderUrl);
app_code: appInfo.app_code, if (opOrderResult.status != 0) {
app_name: appInfo.app_name opOrderResult.data = null;
}; continue;
opOrderResult.data.userInfo = { }
channel_userid: opOrderResult.data.order_info.channelUserId, if(!opOrderResult.data){
channel_username: opOrderResult.data.order_info.channelUserId, // return opOrderResult;
channel_nickname: opOrderResult.data.order_info.channelUserId continue;
}; }
opOrderResult.data.orderNo = params.orderNo; opOrderResult.data.appInfo = {
opOrderResult.data.order_info.pay_flow_no = params.trade_no || "";// 2020 0704 lin 新增 推送fq必填字段 uapp_id: appInfo.uapp_id,
opOrderResult.data.order_info.pay_channel = params.payType ||"";//付款方式 uapp_key: appInfo.uapp_key,
opOrderResult.data.order_info.pay_time = params.payTime;//付款时间 app_code: appInfo.app_code,
opOrderResult.data.order_info.pay_payer_bank_no = params.buyer_email || "";//付款账号 app_name: appInfo.app_name
opOrderResult.data.order_contact = opOrderResult.data.delivery_content.orderContact; };
opOrderResult.data.userInfo = {
channel_userid: opOrderResult.data.order_info.channelUserId,
channel_username: opOrderResult.data.order_info.channelUserId,
channel_nickname: opOrderResult.data.order_info.channelUserId
};
opOrderResult.data.orderNo = params.orderNo;
opOrderResult.data.order_info.pay_flow_no = params.trade_no || "";// 2020 0704 lin 新增 推送fq必填字段
opOrderResult.data.order_info.pay_channel = params.payType ||"";//付款方式
opOrderResult.data.order_info.pay_time = params.payTime;//付款时间
opOrderResult.data.order_info.pay_payer_bank_no = params.buyer_email || "";//付款账号
opOrderResult.data.order_contact = opOrderResult.data.delivery_content.orderContact;
var pobj = { var pobj = {
appInfo: opOrderResult.data.appInfo, appInfo: opOrderResult.data.appInfo,
actionBody: opOrderResult.data actionBody: opOrderResult.data
} }
// 推送 // 推送
this.utilsPushSve.pushBusInfo(pobj, "pushOrder", 0); this.utilsPushSve.pushBusInfo(pobj, "pushOrder", 0);
if(['icpsq','edisq'].includes(opOrderResult.data.product_info.channel_item_code)){ // opOrderResult.data = null;
this.utilsPushSve.aliBusiness2Delivery(pobj, "pushDeliveryOrder"); // return opOrderResult;
} }
opOrderResult.data = null; return system.getResultSuccess();
return opOrderResult;
} catch (e) { } catch (e) {
// await this.cacheManager["TlPayLocker"].release(params.orderNo); // await this.cacheManager["TlPayLocker"].release(params.orderNo);
this.logCtl.error({ this.logCtl.error({
......
...@@ -203,7 +203,11 @@ module.exports = function (app) { ...@@ -203,7 +203,11 @@ module.exports = function (app) {
app.use('/orderNotify/channelPayNotify', async function (req, res) { app.use('/orderNotify/channelPayNotify', async function (req, res) {
try { try {
var client_ip = system.get_client_ip(req); var client_ip = system.get_client_ip(req);
var result = await utilsOrderSve.channelPayNotify(req.body, client_ip); if(req.body.orderNo.startWith('CN')){
var result = await utilsOrderSve.channelOrdersPayNotify(req.body,client_ip);
}else{
var result = await utilsOrderSve.channelPayNotify(req.body, client_ip);
}
logCtl.info({ logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "渠道支付订单通知 api层", optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "渠道支付订单通知 api层",
op: "center-channel/orderNotify/channelPayNotify", op: "center-channel/orderNotify/channelPayNotify",
......
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