Merge branch 'feature/cart' into 'release/5.4.1'
购物车跳转,微信支付 See merge request !268
Showing
5 changed files
with
27 additions
and
9 deletions
@@ -260,7 +260,7 @@ exports.selectCoupon = (req, res) => { | @@ -260,7 +260,7 @@ exports.selectCoupon = (req, res) => { | ||
260 | 260 | ||
261 | let headerData = headerModel.setNav({ | 261 | let headerData = headerModel.setNav({ |
262 | navTitle: '选择优惠券', | 262 | navTitle: '选择优惠券', |
263 | - backUrl: helpers.urlFormat('/cart/index/new/orderEnsure'), | 263 | + backUrl: helpers.urlFormat('/cart/index/new/orderEnsure', {cartType: req.cookies._cartType}), |
264 | navBtn: false | 264 | navBtn: false |
265 | }); | 265 | }); |
266 | 266 | ||
@@ -320,7 +320,7 @@ exports.selectAddress = (req, res, next) => { | @@ -320,7 +320,7 @@ exports.selectAddress = (req, res, next) => { | ||
320 | 320 | ||
321 | let moreUrl = (req.get('Referer') && !/\/home\/addressAct/.test(req.get('Referer')) && | 321 | let moreUrl = (req.get('Referer') && !/\/home\/addressAct/.test(req.get('Referer')) && |
322 | !/selectAddress/.test(req.get('Referer'))) ? | 322 | !/selectAddress/.test(req.get('Referer'))) ? |
323 | - req.get('Referer') : helpers.urlFormat('/cart/index/new/orderEnsure'); // 取跳过来的url | 323 | + req.get('Referer') : helpers.urlFormat('/cart/index/new/orderEnsure', {cartType: req.cookies._cartType}); // 取跳过来的url |
324 | 324 | ||
325 | address = address.data; | 325 | address = address.data; |
326 | 326 |
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | * @Author: Targaryen | 3 | * @Author: Targaryen |
4 | * @Date: 2017-01-04 15:17:51 | 4 | * @Date: 2017-01-04 15:17:51 |
5 | * @Last Modified by: Targaryen | 5 | * @Last Modified by: Targaryen |
6 | - * @Last Modified time: 2017-02-20 15:20:23 | 6 | + * @Last Modified time: 2017-02-20 17:47:03 |
7 | */ | 7 | */ |
8 | 8 | ||
9 | 'use strict'; | 9 | 'use strict'; |
@@ -114,6 +114,11 @@ const pay = (req, res, next) => { | @@ -114,6 +114,11 @@ const pay = (req, res, next) => { | ||
114 | let payment = req.query.payment; | 114 | let payment = req.query.payment; |
115 | let paymentCode = common.getPaymentCode(payment); | 115 | let paymentCode = common.getPaymentCode(payment); |
116 | let openId = req.cookies['weixinOpenId' + orderCode]; | 116 | let openId = req.cookies['weixinOpenId' + orderCode]; |
117 | + let ip = req.ip; | ||
118 | + | ||
119 | + if (ip.substr(0, 7) === '::ffff:') { | ||
120 | + ip = ip.substr(7); | ||
121 | + } | ||
117 | 122 | ||
118 | if (!orderCode || !uid) { | 123 | if (!orderCode || !uid) { |
119 | return res.redirect('/'); | 124 | return res.redirect('/'); |
@@ -144,7 +149,8 @@ const pay = (req, res, next) => { | @@ -144,7 +149,8 @@ const pay = (req, res, next) => { | ||
144 | 149 | ||
145 | Payment.pay(user, orderDetail.data, payment, { | 150 | Payment.pay(user, orderDetail.data, payment, { |
146 | protocol: req.protocol, | 151 | protocol: req.protocol, |
147 | - openId: openId | 152 | + openId: openId, |
153 | + ip: ip | ||
148 | }).then(result => { | 154 | }).then(result => { |
149 | if (result && paymentCode === payModel.payments.wechat) { | 155 | if (result && paymentCode === payModel.payments.wechat) { |
150 | return res.json(result); | 156 | return res.json(result); |
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | * @Author: Targaryen | 2 | * @Author: Targaryen |
3 | * @Date: 2017-01-03 17:42:41 | 3 | * @Date: 2017-01-03 17:42:41 |
4 | * @Last Modified by: Targaryen | 4 | * @Last Modified by: Targaryen |
5 | - * @Last Modified time: 2017-02-20 10:15:03 | 5 | + * @Last Modified time: 2017-02-20 17:46:16 |
6 | */ | 6 | */ |
7 | 7 | ||
8 | 'use strict'; | 8 | 'use strict'; |
@@ -15,6 +15,7 @@ const Promise = require('bluebird'); | @@ -15,6 +15,7 @@ const Promise = require('bluebird'); | ||
15 | const co = Promise.coroutine; | 15 | const co = Promise.coroutine; |
16 | const sign = require('./sign'); | 16 | const sign = require('./sign'); |
17 | const md5 = require('md5'); | 17 | const md5 = require('md5'); |
18 | +const moment = require('moment'); | ||
18 | const common = require('./common'); | 19 | const common = require('./common'); |
19 | 20 | ||
20 | /** | 21 | /** |
@@ -108,9 +109,13 @@ const tools = { | @@ -108,9 +109,13 @@ const tools = { | ||
108 | out_trade_no: 'YOHOBuy_' + params.orderCode, | 109 | out_trade_no: 'YOHOBuy_' + params.orderCode, |
109 | total_fee: params.totalFee * 100, | 110 | total_fee: params.totalFee * 100, |
110 | trade_type: 'JSAPI', | 111 | trade_type: 'JSAPI', |
112 | + time_start: moment().format('YYYYMMDDHHmmss'), | ||
113 | + time_expire: moment().add(2, 'hours').format('YYYYMMDDHHmmss'), | ||
114 | + spbill_create_ip: params.ip, | ||
111 | openid: params.openId, | 115 | openid: params.openId, |
112 | sign_type: 'MD5' | 116 | sign_type: 'MD5' |
113 | }; | 117 | }; |
118 | + | ||
114 | let signStr = md5(sign.raw(unifiedParams) + '&key=' + WxPayConfig.key).toUpperCase(); | 119 | let signStr = md5(sign.raw(unifiedParams) + '&key=' + WxPayConfig.key).toUpperCase(); |
115 | 120 | ||
116 | _.assign(unifiedParams, { sign: signStr }); | 121 | _.assign(unifiedParams, { sign: signStr }); |
@@ -158,13 +163,14 @@ const Wechat = { | @@ -158,13 +163,14 @@ const Wechat = { | ||
158 | /** | 163 | /** |
159 | * 异步拉起微信支付相关处理 | 164 | * 异步拉起微信支付相关处理 |
160 | */ | 165 | */ |
161 | - pay(user, order, openId) { | 166 | + pay(user, order, openId, ip) { |
162 | 167 | ||
163 | return co(function* () { | 168 | return co(function* () { |
164 | let unifiedOrderResult = yield tools.unifiedOrder({ | 169 | let unifiedOrderResult = yield tools.unifiedOrder({ |
165 | orderCode: order.order_code, | 170 | orderCode: order.order_code, |
166 | totalFee: parseFloat(order.payment_amount), | 171 | totalFee: parseFloat(order.payment_amount), |
167 | - openId: openId | 172 | + openId: openId, |
173 | + ip: ip | ||
168 | }); | 174 | }); |
169 | 175 | ||
170 | if (unifiedOrderResult) { | 176 | if (unifiedOrderResult) { |
@@ -20,7 +20,7 @@ const Payment = { | @@ -20,7 +20,7 @@ const Payment = { | ||
20 | 20 | ||
21 | /** | 21 | /** |
22 | * 统一支付入口 | 22 | * 统一支付入口 |
23 | - * reqParams: 需要从 controller 传递的参数,支付宝需要 req.protocol,微信需要 openId | 23 | + * reqParams: 需要从 controller 传递的参数,支付宝需要 req.protocol,微信需要 openId、ip |
24 | */ | 24 | */ |
25 | pay(user, order, payType, reqParams) { | 25 | pay(user, order, payType, reqParams) { |
26 | return co(function*() { | 26 | return co(function*() { |
@@ -54,7 +54,7 @@ const Payment = { | @@ -54,7 +54,7 @@ const Payment = { | ||
54 | } | 54 | } |
55 | 55 | ||
56 | if (method === PayModel.payments.wechat) { | 56 | if (method === PayModel.payments.wechat) { |
57 | - result = yield Wechat.pay(user, order, reqParams.openId); | 57 | + result = yield Wechat.pay(user, order, reqParams.openId, reqParams.ip); |
58 | } else { | 58 | } else { |
59 | payInfo = yield PayModel.getPaymentInfo(method); | 59 | payInfo = yield PayModel.getPaymentInfo(method); |
60 | 60 |
@@ -10,6 +10,7 @@ const helpers = global.yoho.helpers; | @@ -10,6 +10,7 @@ const helpers = global.yoho.helpers; | ||
10 | const _ = require('lodash'); | 10 | const _ = require('lodash'); |
11 | const headerModel = require('../../../doraemon/models/header'); // 头部model | 11 | const headerModel = require('../../../doraemon/models/header'); // 头部model |
12 | const orderDetailModel = require('../models/orderDetail'); | 12 | const orderDetailModel = require('../models/orderDetail'); |
13 | +const payModel = require('../models/pay'); | ||
13 | 14 | ||
14 | const orderDetailData = (req, res, next) => { | 15 | const orderDetailData = (req, res, next) => { |
15 | let uid = req.user.uid; | 16 | let uid = req.user.uid; |
@@ -18,6 +19,11 @@ const orderDetailData = (req, res, next) => { | @@ -18,6 +19,11 @@ const orderDetailData = (req, res, next) => { | ||
18 | helpers.urlFormat('/service/im') : | 19 | helpers.urlFormat('/service/im') : |
19 | 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info='; | 20 | 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info='; |
20 | 21 | ||
22 | + if (req.query.openId) { | ||
23 | + // 微信支付成功,发送支付确认接口 | ||
24 | + payModel.sendPayConfirm(orderCode, 22, uid); | ||
25 | + } | ||
26 | + | ||
21 | orderDetailModel.orderDetailData(uid, orderCode).then(result => { | 27 | orderDetailModel.orderDetailData(uid, orderCode).then(result => { |
22 | if (!result || _.isEmpty(result)) { | 28 | if (!result || _.isEmpty(result)) { |
23 | return next(404); | 29 | return next(404); |
-
Please register or login to post a comment