|
@@ -2,7 +2,6 @@
|
|
const Base = require('./base.js');
|
|
const Base = require('./base.js');
|
|
|
|
|
|
module.exports = class extends Base {
|
|
module.exports = class extends Base {
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 获取支付的请求参数
|
|
* 获取支付的请求参数
|
|
* @returns {Promise<PreventPromise|void|Promise>}
|
|
* @returns {Promise<PreventPromise|void|Promise>}
|
|
@@ -10,14 +9,14 @@ module.exports = class extends Base {
|
|
async prepayAction() {
|
|
async prepayAction() {
|
|
const orderId = this.get('orderId');
|
|
const orderId = this.get('orderId');
|
|
|
|
|
|
- const orderInfo = await this.model('order').where({id: orderId}).find();
|
|
|
|
|
|
+ const orderInfo = await this.model('order').where({ id: orderId }).find();
|
|
if (think.isEmpty(orderInfo)) {
|
|
if (think.isEmpty(orderInfo)) {
|
|
return this.fail(400, '订单已取消');
|
|
return this.fail(400, '订单已取消');
|
|
}
|
|
}
|
|
if (parseInt(orderInfo.pay_status) !== 0) {
|
|
if (parseInt(orderInfo.pay_status) !== 0) {
|
|
return this.fail(400, '订单已支付,请不要重复操作');
|
|
return this.fail(400, '订单已支付,请不要重复操作');
|
|
}
|
|
}
|
|
- const openid = await this.model('user').where({id: orderInfo.user_id}).getField('weixin_openid', true);
|
|
|
|
|
|
+ const openid = await this.model('user').where({ id: orderInfo.user_id }).getField('weixin_openid', true);
|
|
if (think.isEmpty(openid)) {
|
|
if (think.isEmpty(openid)) {
|
|
return this.fail('微信支付失败');
|
|
return this.fail('微信支付失败');
|
|
}
|
|
}
|
|
@@ -39,7 +38,6 @@ module.exports = class extends Base {
|
|
async notifyAction() {
|
|
async notifyAction() {
|
|
const WeixinSerivce = this.service('weixin', 'api');
|
|
const WeixinSerivce = this.service('weixin', 'api');
|
|
const result = WeixinSerivce.payNotify(this.post('xml'));
|
|
const result = WeixinSerivce.payNotify(this.post('xml'));
|
|
- console.log('WeixinSerivce.payNotify ' + result);
|
|
|
|
if (!result) {
|
|
if (!result) {
|
|
return `<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[支付失败]]></return_msg></xml>`;
|
|
return `<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[支付失败]]></return_msg></xml>`;
|
|
}
|
|
}
|