Commit 1fbf5bd2 by linboxuan

优客拉取订单/免登

parent 21839639
......@@ -29,8 +29,8 @@ class ProductAPI extends WEBBase {
opResult = await this.utilsUcommuneSve.orderTotalSum(pobj, pobj.actionBody);
case "orderConfirm":// 点击确认支付后返回拼接字符串
opResult = await this.utilsUcommuneSve.orderConfirm(pobj, pobj.actionBody);
case "UcommuneGetOrderList":// 优客调取订单列表用
opResult = await this.utilsUcommuneSve.UcommuneGetOrderList(pobj, pobj.actionBody);
case "ucommuneGetOrderList":// 优客调取订单列表用
opResult = await this.utilsUcommuneSve.ucommuneGetOrderList(pobj, pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
......
......@@ -560,5 +560,12 @@ class UtilsOrderService extends AppServiceBase {
}
}
async aliPayNotify(pobj) { // 微信支付回调
return {
code:0,
msg:"success"
}
}
}
module.exports = UtilsOrderService;
......@@ -6,7 +6,9 @@ class UtilsUcommuneService extends AppServiceBase {
constructor() {
super();
this.centerOrderUrl = settings.centerOrderUrl();
this.centerChannelUrl = settings.centerChannelUrl();
this.utilsAuthSve = system.getObject("service.utilsSve.utilsAuthSve");
// this.alipay = settings.alipay();
}
//--------------------------------优客工厂相关接口-start-----------------------------------------------------
......@@ -43,8 +45,8 @@ class UtilsUcommuneService extends AppServiceBase {
* @param {*} pobj
* @param {*} actionBody
*/
async UcommuneGetOrderList(pobj, actionBody) {
var reqUrl = this.centerOrderUrl + "action/order/springBoard";
async ucommuneGetOrderList(pobj, actionBody) {
var reqUrl = this.centerOrderUrl + "action/ucommuneOrder/springBoard";
var result = await this.restPostUrl(pobj, reqUrl);
return result;
}
......@@ -71,8 +73,20 @@ class UtilsUcommuneService extends AppServiceBase {
pobj.actionType = "getOrderDetails" // 获取订单详细信息 用来拼接字符串 totalsum为总金额,返回给前端
var reqUrl = this.centerOrderUrl + "action/order/springBoard";
var orderResult = await this.restPostUrl(pobj, reqUrl);
console.log(orderResult)
if(actionBody.payWay == 1) { // 支付宝
const params = {
bizContent: {
out_trade_no: '12312312321212', // 商户网站唯一订单号
subject: encodeURIComponent('苹果电脑'),//商品的标题/交易标题/订单标题/订单关键字等
total_amount: 0.2,//实际付款金额
body: encodeURIComponent('Mac Pro1'),//对一笔交易的具体描述信息。如果是多种商品,请将商品描述字符串累加传给body
product_code: 'QUICK_MSECURITY_PAY',
notifyUrl:this.centerChannelUrl + "orderNotify/aliPayNotify"
}
}
let alipayResponse = await this.alipay.exec('alipay.trade.app.pay', params);
console.log(alipayResponse);
}
if(actionBody.payWay == 3) { // 微信
......
......@@ -415,5 +415,19 @@ module.exports = function (app) {
p.then(r => {
res.end(JSON.stringify(r));
});
});
});
// 支付回调通知
app.post('/orderNotify/aliPayNotify', async function (req, res) {
var client_ip = system.get_client_ip(req);
var result = await utilsOrderSve.aliPayNotify(req.body);
logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "aliPayNotify记录回调处理结果,method=notify",
op: "app/config/routes/api.js/orderNotify/aliPayNotify",
content: "回调参数:" + JSON.stringify(req.body) + "回调结果:" + JSON.stringify(result),
clientIp: client_ip || ""
});
var returnObj = JSON.stringify(result);
return res.end(returnObj);
});
};
var path = require('path');
var AlipaySdk = require('alipay-sdk').default;
var ENVINPUT = {
DB_HOST: process.env.DB_HOST,
DB_PORT: process.env.DB_PORT,
......@@ -69,6 +70,13 @@ var settings = {
return "http://center-app-service/";
}
},
centerChannelUrl: function () {
if (this.env == "dev") {
return "http://60.205.209.94:4012/"
} else {
return "channel的正式环境"
}
},
gatewayUrl: function () {
if (this.env == "dev") {
return "http://192.168.0.106:4005/";
......@@ -190,6 +198,17 @@ var settings = {
},
};
}
},
alipay: function() {
return new AlipaySdk({
// appId: payConfig.ali.appId,
// privateKey: payConfig.ali.privateKey,
// alipayPublicKey: payConfig.ali.publicKey,
});
}
};
module.exports = settings;
......@@ -14,6 +14,7 @@
"MD5": "^1.3.0",
"after": "^0.8.2",
"ali-oss": "^4.12.2",
"alipay-sdk": "^3.1.1",
"aliyun-api-gateway": "^1.1.6",
"babel-polyfill": "^6.26.0",
"base64id": "^1.0.0",
......@@ -57,4 +58,4 @@
"element-theme": "^2.0.1",
"element-theme-chalk": "^2.4.0"
}
}
\ No newline at end of file
}
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