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")
this.pushlogSve = system.getObject("service.common.pushlogSve");
} }
//-------------------------------------------钉钉h5支付-----------------开始
//组合参数,由前端传到360
async getParamsFor360(pobj, actionBody) { async getParamsFor360(pobj, actionBody) {
if (!actionBody.orderNo) { if (!actionBody.orderNo) {
return system.getResult(null, "actionBody.orderNo can not be empty,100110"); return system.getResult(null, "actionBody.orderNo can not be empty,100110");
} }
pobj.actionType = "getPayOrderInfo"; let seaUrl = this.centerOrderUrl + 'opaction/opPayOrder/getOrderListByOrderServiceNo';
var orderUrl = settings.centerOrderUrl() + "action/order/springBoard"; let seaRet = await this.restPostUrl(pobj, seaUrl);
var orderResult = await this.restPostUrl(pobj, orderUrl); if (seaRet.status != 0) {
if (orderResult.status != 0) { return system.getResultFail(-1, '获取订单信息失败')
return orderResult; }
} let totalSum = 0;
pobj.actionType ="getOrderDeliveryInfo"; let sku_id = '';
var deliveryResult = await this.restPostUrl(pobj,orderUrl); let amount = 0;
if (deliveryResult.status != 0) { let consignee = "";
return deliveryResult; let mobile = "";
} let email = "";
let sku_id = orderResult.data.orderProduct.itemCode; for (let i = 0; i < seaRet.data.length; i++) {
let price = Number(orderResult.data.orderProduct.price)*100; let item = seaRet.data[i];
let quantity = orderResult.data.orderProduct.quantity; if(!mobile){
let amount = Number(orderResult.data.receiptVoucher.totalSum)*100; pobj.actionType.orderNo = item.orderNo;
let order_id = orderResult.data.receiptVoucher.sourceOrderNo; pobj.actionType = "getOrderDeliveryInfo";
let consignee = deliveryResult.data.orderContact.contactName; let deliveryResult = await this.restPostUrl(pobj, orderUrl);
let mobile = deliveryResult.data.orderContact.mobile; consignee = deliveryResult.data.orderContact.contactName;
let email = deliveryResult.data.orderContact.email; 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 singStr = sku_id + price + order_id + pobj.appInfo.uapp_secret;
let sign = md5(singStr).toUpperCase(); let sign = md5(singStr).toUpperCase();
let result ={ // 推送参数
sku_id, let result = {
price, sku_id: sku_id,
quantity, price: price,
amount, quantity: seaRet.data.length,
order_id, amount: amount,
consignee, order_id: order_id,
mobile, consignee: consignee,
email, mobile: mobile,
sign email: email,
sign: sign
} }
return system.getResult(result); return system.getResult(result);
} }
//-------------------------------------------钉钉h5支付-----------------结束 //更新订单状态到360
async pushOrderStatus(pobj) {
try {
var verifyResult = await this.verifyParam(pobj);
if (verifyResult.status != 0) {
return await this.disposePushResultFail(pobj, verifyResult, "status->pushOrderStatus->verifyResult", this.pushlogFailType.FAILLOG);
}
var interface_params_info = verifyResult.data;
let token = await this.utilsAuthSve.get360Token();
let url = interface_params_info.opUrl + '?token=' + token;
//合同号,还是订单号
pobj.actionType = 'getOrderServiceNoByOrderNo'
let orderUrl = settings.centerOrderUrl() + 'action/order/springBoard'
let orderItem = await this.restPostUrl(pobj,orderUrl);
if(orderItem.status !=0){
return orderItem;
}
let order_id = orderItem.data.orderServiceNo;
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",
});
}
}
// 参数信息验证
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,16 +1004,27 @@ class UtilsOrderService extends AppServiceBase { ...@@ -1004,16 +1004,27 @@ 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 信息
let seaUrl = this.centerOrderUrl + 'opaction/opPayOrder/getOrderListByOrderServiceNo';
let seaRet = await this.restPostUrl(params,seaUrl);
if(seaRet.status!=0){
seaRet.data= null;
return seaRet;
}
let orderList = seaRet.data;
for(let i=0;i<orderList.length;i++){
params.orderNo = orderList[i].orderNo;
// 这里修改了order_info的状态(status/paytime等) // 这里修改了order_info的状态(status/paytime等)
var orderUrl = this.centerOrderUrl + "opaction/opPayOrder/receivePayCallBackNotifyByChannel"; var orderUrl = this.centerOrderUrl + "opaction/opPayOrder/receivePayCallBackNotifyByChannel";
var opOrderResult = await this.restPostUrl(params, orderUrl); var opOrderResult = await this.restPostUrl(params, orderUrl);
if (opOrderResult.status != 0) { if (opOrderResult.status != 0) {
opOrderResult.data = null; opOrderResult.data = null;
return opOrderResult; continue;
} }
if(!opOrderResult.data){ if(!opOrderResult.data){
return opOrderResult; // return opOrderResult;
continue;
} }
opOrderResult.data.appInfo = { opOrderResult.data.appInfo = {
uapp_id: appInfo.uapp_id, uapp_id: appInfo.uapp_id,
...@@ -1040,11 +1051,10 @@ class UtilsOrderService extends AppServiceBase { ...@@ -1040,11 +1051,10 @@ class UtilsOrderService extends AppServiceBase {
// 推送 // 推送
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);
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); 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