Authored by 郭成尧

merge

... ... @@ -260,7 +260,7 @@ exports.selectCoupon = (req, res) => {
let headerData = headerModel.setNav({
navTitle: '选择优惠券',
backUrl: helpers.urlFormat('/cart/index/new/orderEnsure'),
backUrl: helpers.urlFormat('/cart/index/new/orderEnsure', {cartType: req.cookies._cartType}),
navBtn: false
});
... ... @@ -320,7 +320,7 @@ exports.selectAddress = (req, res, next) => {
let moreUrl = (req.get('Referer') && !/\/home\/addressAct/.test(req.get('Referer')) &&
!/selectAddress/.test(req.get('Referer'))) ?
req.get('Referer') : helpers.urlFormat('/cart/index/new/orderEnsure'); // 取跳过来的url
req.get('Referer') : helpers.urlFormat('/cart/index/new/orderEnsure', {cartType: req.cookies._cartType}); // 取跳过来的url
address = address.data;
... ...
... ... @@ -3,7 +3,7 @@
* @Author: Targaryen
* @Date: 2017-01-04 15:17:51
* @Last Modified by: Targaryen
* @Last Modified time: 2017-02-20 15:20:23
* @Last Modified time: 2017-02-20 18:15:05
*/
'use strict';
... ... @@ -114,6 +114,11 @@ const pay = (req, res, next) => {
let payment = req.query.payment;
let paymentCode = common.getPaymentCode(payment);
let openId = req.cookies['weixinOpenId' + orderCode];
let ip = req.ip;
if (ip.substr(0, 7) === '::ffff:') {
ip = ip.substr(7);
}
if (!orderCode || !uid) {
return res.redirect('/');
... ... @@ -144,7 +149,8 @@ const pay = (req, res, next) => {
Payment.pay(user, orderDetail.data, payment, {
protocol: req.protocol,
openId: openId
openId: openId,
ip: ip
}).then(result => {
if (result && paymentCode === payModel.payments.wechat) {
return res.json(result);
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2017-01-03 17:42:41
* @Last Modified by: Targaryen
* @Last Modified time: 2017-02-20 10:15:03
* @Last Modified time: 2017-02-20 17:46:16
*/
'use strict';
... ... @@ -15,6 +15,7 @@ const Promise = require('bluebird');
const co = Promise.coroutine;
const sign = require('./sign');
const md5 = require('md5');
const moment = require('moment');
const common = require('./common');
/**
... ... @@ -108,9 +109,13 @@ const tools = {
out_trade_no: 'YOHOBuy_' + params.orderCode,
total_fee: params.totalFee * 100,
trade_type: 'JSAPI',
time_start: moment().format('YYYYMMDDHHmmss'),
time_expire: moment().add(2, 'hours').format('YYYYMMDDHHmmss'),
spbill_create_ip: params.ip,
openid: params.openId,
sign_type: 'MD5'
};
let signStr = md5(sign.raw(unifiedParams) + '&key=' + WxPayConfig.key).toUpperCase();
_.assign(unifiedParams, { sign: signStr });
... ... @@ -158,13 +163,14 @@ const Wechat = {
/**
* 异步拉起微信支付相关处理
*/
pay(user, order, openId) {
pay(user, order, openId, ip) {
return co(function* () {
let unifiedOrderResult = yield tools.unifiedOrder({
orderCode: order.order_code,
totalFee: parseFloat(order.payment_amount),
openId: openId
openId: openId,
ip: ip
});
if (unifiedOrderResult) {
... ...
... ... @@ -20,7 +20,7 @@ const Payment = {
/**
* 统一支付入口
* reqParams: 需要从 controller 传递的参数,支付宝需要 req.protocol,微信需要 openId
* reqParams: 需要从 controller 传递的参数,支付宝需要 req.protocol,微信需要 openId、ip
*/
pay(user, order, payType, reqParams) {
return co(function*() {
... ... @@ -54,7 +54,7 @@ const Payment = {
}
if (method === PayModel.payments.wechat) {
result = yield Wechat.pay(user, order, reqParams.openId);
result = yield Wechat.pay(user, order, reqParams.openId, reqParams.ip);
} else {
payInfo = yield PayModel.getPaymentInfo(method);
... ...
... ... @@ -10,6 +10,7 @@ const helpers = global.yoho.helpers;
const _ = require('lodash');
const headerModel = require('../../../doraemon/models/header'); // 头部model
const orderDetailModel = require('../models/orderDetail');
const payModel = require('../../cart/models/pay');
const orderDetailData = (req, res, next) => {
let uid = req.user.uid;
... ... @@ -18,6 +19,11 @@ const orderDetailData = (req, res, next) => {
helpers.urlFormat('/service/im') :
'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info=';
if (req.query.openId) {
// 微信支付成功,发送支付确认接口
payModel.sendPayConfirm(orderCode, 22, uid);
}
orderDetailModel.orderDetailData(uid, orderCode).then(result => {
if (!result || _.isEmpty(result)) {
return next(404);
... ...
... ... @@ -271,7 +271,7 @@ function tranformPayment(data, orderInfo, cartType, skuList, orderComputeData) {
result.cartPayData = cartData.promotion_formula_list;
result.num = cartData.goods_count;
result.goodsPrice = cartData.str_order_amount;
result.price = cartData.last_order_amount;
result.price = orderComputeData ? orderComputeData.last_order_amount : cartData.last_order_amount;
if (cartData.gain_yoho_coin > 0) {
result.yohoCoinNum = cartData.gain_yoho_coin;
... ...