Authored by 陈峰

Merge branch 'feature/cart' into 'release/5.4.1'

结算部分日志添加



See merge request !265
... ... @@ -9,6 +9,7 @@ const addressModel = require('../../serverAPI/user/address');
const orderModel = require('../models/order');
const crypto = global.yoho.crypto;
const authcode = require(global.utils + '/authcode');
const logger = global.yoho.logger;
// cookie 参数
const actCkOpthn = {
... ... @@ -31,6 +32,7 @@ exports.orderEnsure = (req, res, next) => {
try {
orderInfo = JSON.parse(req.cookies['order-info']);
} catch (e) {
logger.info(`orderEnsure: get orderInfo from cookie error:${JSON.stringify(e)}`);
orderInfo = {};
res.cookie('order-info', null, actCkOpthn);
}
... ... @@ -68,11 +70,13 @@ exports.orderEnsure = (req, res, next) => {
let userProfile = result[1];
let address = result[2];
if (order.cartUrl) { // TODO? 普通或者预售商品为空时, BUT WHEN AJAX?
if (order.cartUrl) {
logger.info(`orderEnsure: order cartUrl has value:${order.cartUrl}, order data is null`);
return res.redirect(order.cartUrl);
}
if (req.xhr) {
logger.info(`orderEnsure: ajax request, return json:${JSON.stringify(order)}`);
return res.json(order);
}
... ... @@ -183,7 +187,6 @@ exports.orderSub = (req, res, next) => {
let userAgent = null;
let unionKey = '';
let unionInfo = {};
let testQyhUnion = {};
if (req.cookies.mkt_code || req.cookies._QYH_UNION) {
/*
... ... @@ -198,8 +201,10 @@ exports.orderSub = (req, res, next) => {
if (!unionKey) {
let encryData = crypto.decrypt('', decodeURIComponent(req.cookies._QYH_UNION));
encryData = encryData.substr(0, encryData.lastIndexOf('}') + 1);
encryData = encryData.substr(0, encryData.lastIndexOf('}') + 1);
let testQyhUnion = JSON.parse(encryData);
unionKey = testQyhUnion.client_id ? encryData : '';
}
} else {
... ... @@ -232,6 +237,8 @@ exports.orderSub = (req, res, next) => {
if (unionInfo && result.data) {
result.data.unionCookie = unionInfo;
} else {
logger.info(`orderEnsure: unionInfo:${JSON.stringify(unionInfo)}, result data:${JSON.stringify(result.data)}`);
}
// 提交成功清除Cookie
... ...
... ... @@ -3,7 +3,7 @@
* @Author: Targaryen
* @Date: 2017-01-04 15:17:51
* @Last Modified by: Targaryen
* @Last Modified time: 2017-02-17 09:52:57
* @Last Modified time: 2017-02-20 10:43:10
*/
'use strict';
... ... @@ -17,6 +17,7 @@ const helpers = global.yoho.helpers;
const Payment = require('../helpers/payment');
const WxPay = require('../helpers/pay/wechat');
const common = require('../helpers/pay/common');
const logger = global.yoho.logger;
/**
* 支付中心
... ... @@ -32,11 +33,14 @@ const payCenter = (req, res, next) => {
let hasWxShare = Boolean(userAgent.match(/MicroMessenger/i) && userAgent.match(/MicroMessenger/i).length > 0);
if (!orderCode || !uid) {
logger.info(`payCenter:no orderCode or uid:orderCode ${orderCode}, uid ${uid}`);
res.redirect('/');
}
if (sessionKey) {
sessionKey = sessionKey.substr(0, sessionKey.length - 8);
} else {
logger.info(`payCenter: orderCode-${orderCode} no sessionKey`);
}
co(function* () {
... ... @@ -48,6 +52,7 @@ const payCenter = (req, res, next) => {
/* 判断订单是否已付款, 已付款跳到订单详情页 */
if (orderDetail.isPay) {
logger.info(`payCenter: orderCode-${orderCode} already paied`);
return res.redirect(helpers.urlFormat('/cart/shopping/pay/payZero', {order_code: orderCode}));
}
... ... @@ -110,7 +115,7 @@ const pay = (req, res, next) => {
let paymentCode = common.getPaymentCode(payment);
let openId = req.cookies['weixinOpenId' + orderCode];
if (!orderCode || !uid || !sessionKey) {
if (!orderCode || !uid) {
return res.redirect('/');
}
... ...
... ... @@ -2,6 +2,7 @@
* 秒杀结算
*/
'use strict';
const _ = require('lodash');
const crypto = global.yoho.crypto;
const co = require('bluebird').coroutine;
const seckillModel = require('../models/seckill');
... ... @@ -55,8 +56,18 @@ exports.ensure = (req, res, next) => {
paymentOption.activity_id = activityId = skillData.activityId;
let orderComputerData;
if (orderInfo) {
orderComputerData = yield seckillModel.compute(_.assign(paymentOption, {
delivery_way: orderInfo.deliveryId,
payment_type: orderInfo.paymentType,
use_yoho_coin: orderInfo.yohoCoin
}));
}
// 获取结算 数据
let paymentInfo = yield seckillModel.payment(paymentOption, orderInfo);
let paymentInfo = yield seckillModel.payment(paymentOption, orderInfo, orderComputerData.data);
let view;
if (paymentInfo.code !== 200) {
... ... @@ -158,8 +169,8 @@ exports.submit = (req, res, next) => {
}
if ([uid, sku, activityId, addressId, deliveryTime,
deliveryWay, paymentId, paymentType
].some(field => !field)) {
deliveryWay, paymentId, paymentType
].some(field => !field)) {
return res.status(400).json({
code: 400,
message: BAD_REQUEST
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2017-01-03 17:42:41
* @Last Modified by: Targaryen
* @Last Modified time: 2017-01-09 17:53:16
* @Last Modified time: 2017-02-20 10:15:03
*/
'use strict';
... ... @@ -146,6 +146,7 @@ const Wechat = {
let baseUrl = 'http://m.yohobuy.com' + originalUrl;
let redirectUrl = tools.createOauthUrlForCode(baseUrl);
logger.info('payCenter: wechat pay no code');
return Promise.resolve({ redirectUrl: redirectUrl });
} else {
return tools.getOpenidFromMp(code).then(openid => {
... ... @@ -187,6 +188,7 @@ const Wechat = {
}
};
} else {
logger.info('payCenter: wechat pay no unifiedOrderResult');
return {};
}
... ...
... ... @@ -49,6 +49,7 @@ const Payment = {
let method = common.getPaymentCode(payType);
if (!method) {
logger.info('payCenter: payment no method params');
return result;
}
... ...
... ... @@ -4,6 +4,7 @@ const _ = require('lodash');
const helpers = global.yoho.helpers;
const paymentProcess = require(global.utils + '/payment-process');
const shoppingAPI = require('../../serverAPI/order/shopping');
const logger = global.yoho.logger;
/**
* 转换价格
... ... @@ -62,7 +63,7 @@ exports.cartPay = (uid, cartType, orderInfo, limitProductCode, sku, skn, buyNumb
}
// cookie保存的数据
if (!_.isEmpty(orderInfo)) {
if (orderInfo) {
orderInfo.paymentType = orderInfo.paymentType ? orderInfo.paymentType : '';
orderComputeAPI = shoppingAPI.orderComputeAPI(
uid,
... ... @@ -95,6 +96,7 @@ exports.cartPay = (uid, cartType, orderInfo, limitProductCode, sku, skn, buyNumb
let goodsList = _.get(pay, 'data.goods_list', []);
if (_.isEmpty(goodsList)) {
logger.info(`orderEnsure: goodsList is empty, isLimitGoods: ${isLimitGoods}`);
if (isLimitGoods) {
result.error = true;
result.message = pay.message;
... ...
... ... @@ -17,7 +17,7 @@ exports.skillData = product_skn => {
};
exports.payment = (options, orderInfo) => {
exports.payment = (options, orderInfo, orderComputerData) => {
let queryData = Object.assign({
method: 'app.Seckill.payment',
}, options);
... ... @@ -26,7 +26,7 @@ exports.payment = (options, orderInfo) => {
.then(result => {
// TODO 数据处理
if (result.code === 200 && result.data) {
result.data = paymentProcess.tranformPayment(result.data, orderInfo);
result.data = paymentProcess.tranformPayment(result.data, orderInfo, null, null, orderComputerData);
}
return result;
});
... ...
... ... @@ -19,6 +19,10 @@ const orderDetailData = (req, res, next) => {
'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info=';
orderDetailModel.orderDetailData(uid, orderCode).then(result => {
if (!result || _.isEmpty(result)) {
return next(404);
}
result.serviceUrl = serviceUrl;
res.render('orderDetail', {
module: 'home',
... ...
... ... @@ -104,6 +104,6 @@ $buyNowBtn.on('click', function() {
activity_id: bundleId
}), actCkOpthn);
window.location.href = '/cart/index/orderEnsure?cartType=bundle&activityType=bundle';
window.location.href = '/cart/index/new/orderEnsure?cartType=bundle&activityType=bundle';
}
});
... ...
/**
* 购物车选择尺寸、颜色和数量面板
* 套餐购物车选择尺寸、颜色和数量面板
* 显示时构造当前商品信息的HTML插入yoho-page;消失则是直接清除HTML
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/21
... ... @@ -416,7 +416,7 @@ $yohoPage.on('touchstart', '.btn-minus', function () {
function () {
var sizeChose = $('.size-list').find('.chosed'),
productSku = sizeChose.data('skuid'),
color = $('.color-list').find('.chosed').html(),
color = $('.color-list').find('.chosed').html().substring(0,4) + '...',
size = sizeChose.html();
choseEnsure(productSkn, productSku, color, size);
hide();
... ...
... ... @@ -159,7 +159,7 @@
background: #fff;
padding: 0.5rem 0.75rem;
height: 1.5rem;
line-height: 1.5rem;
line-height: 0.5rem;
font-size: 0.7rem;
.bg-dollar {
... ...
... ... @@ -333,7 +333,7 @@
.price-wrap {
position: absolute;
top: 50px;
top: 0;
right: 30px;
text-align: right;
}
... ...
... ... @@ -183,7 +183,7 @@ function tranformPayment(data, orderInfo, cartType, skuList, orderComputeData) {
});
result.goods = goods;
result.goodsPrice = goodsPrice;
result.goodsPrice = goodsPrice.toFixed(2);
}
// 支付方式
... ...