Authored by 郭成尧

tickets-seckill-giftcard

... ... @@ -8,6 +8,8 @@ const co = Promise.coroutine;
const seckillModel = require('../models/seckill');
const headerModel = require('../../../doraemon/models/header'); // 头部model
const orderModel = require('../models/order');
const shoppingModel = require('../models/shopping');
const paymentProcess = require(global.utils + '/payment-process');
const BAD_REQUEST = '非法请求';
const SLAT = 'yohobuyseckill98';
... ... @@ -77,13 +79,17 @@ exports.ensure = (req, res, next) => {
orderComputerData = yield req.ctx(seckillModel).compute(_.assign(paymentOption, {
delivery_way: orderInfo.deliveryId || 1,
payment_type: orderInfo.paymentType || 1,
use_yoho_coin: orderInfo.yohoCoin || 0
use_yoho_coin: orderInfo.yohoCoin || 0,
gift_card_code: orderInfo.body.gift_card_code || null
}));
}
// 获取结算 数据
let paymentInfo =
yield req.ctx(seckillModel).payment(paymentOption, orderInfo, _.get(orderComputerData, 'data'));
let [paymentInfo, validGiftCardCountData] = yield Promise.all([
req.ctx(seckillModel).payment(paymentOption, orderInfo, _.get(orderComputerData, 'data')),
req.ctx(shoppingModel).countUsableGiftCard(uid) // 可用礼品卡数量
]);
let validGiftCardCount = _.get(validGiftCardCountData, 'data.count', 0);
if (paymentInfo.code !== 200) {
view = {
... ... @@ -97,11 +103,16 @@ exports.ensure = (req, res, next) => {
}
} else {
// 渲染
view = Object.assign({
view = _.assign({
seckill: skillData,
orderEnsure: true,
sku,
}, paymentInfo.data);
}, paymentInfo.data, {
giftCards: paymentProcess.handleGiftCards({
validGiftCardCount: validGiftCardCount,
orderCompute: orderComputerData
})
});
}
res.locals.title = '确认订单';
... ... @@ -147,6 +158,7 @@ exports.compute = (req, res, next) => {
product_sku: sku,
delivery_way: req.body.deliveryId || 1,
use_yoho_coin: req.body.yohoCoin || 0,
gift_card_code: req.body.gift_card_code,
activity_id: activityId
};
... ...
'use strict';
const _ = require('lodash');
const co = Promise.coroutine;
const headerModel = require('../../../doraemon/models/header'); // 头部model
const ticketsConfirmModel = require('../models/ticketsConfirm');
const shoppingModel = require('../models/shopping');
const paymentProcess = require(global.utils + '/payment-process');
// cookie 参数
const actCkOpthn = {
path: '/cart/index'
};
const ticketsConfirm = (req, res) => {
const ticketsConfirm = (req, res, next) => {
let headerData = headerModel.setNav({
navTitle: '确认订单',
navBtn: false
... ... @@ -19,8 +22,6 @@ const ticketsConfirm = (req, res) => {
module: 'cart',
page: 'tickets-confirm',
title: '确认订单',
// pageFooter: true,
localCss: true,
navBtn: false,
width750: true
... ... @@ -40,12 +41,24 @@ const ticketsConfirm = (req, res) => {
productSku: req.body.productSku,
buyNumber: req.body.buyNumber,
useYohoCoin: orderInfo ? orderInfo.yohoCoin : 0,
gift_card_code: orderInfo.body.gift_card_code || null,
yohoCoinMode: true
};
req.ctx(ticketsConfirmModel).ticketsConfirm(params).then(result => {
res.render('ticketsConfirm', Object.assign(responseData, result));
});
co(function* () {
let [result, validGiftCardCountData] = yield Promise.all([
req.ctx(ticketsConfirmModel).ticketsConfirm(params),
req.ctx(shoppingModel).countUsableGiftCard(req.user.uid) // 可用礼品卡数量
]);
let validGiftCardCount = _.get(validGiftCardCountData, 'data.count', 0);
res.render('ticketsConfirm', _.assign(responseData, result, {
giftCards: paymentProcess.handleGiftCards({
validGiftCardCount: validGiftCardCount,
orderCompute: result
})
}));
})().catch(next);
};
const submitTicket = (req, res) => {
... ... @@ -54,7 +67,8 @@ const submitTicket = (req, res) => {
productSku: req.body.productSku,
buyNumber: req.body.buyNumber,
mobile: req.body.mobile,
useYohoCoin: req.body.useYohoCoin
useYohoCoin: req.body.useYohoCoin,
gift_card_code: req.body.gift_card_code
};
req.ctx(ticketsConfirmModel).submitTicket(params).then(result => {
... ...
... ... @@ -18,6 +18,7 @@ class ticketsConfirmModel extends global.yoho.BaseModel {
product_sku: param.productSku,
buy_number: param.buyNumber,
use_yoho_coin: param.useYohoCoin || 0,
gift_card_code: param.gift_card_code || null,
yoho_coin_mode: param.yohoCoinMode ? param.yohoCoinMode : 0
}}).then((result) => {
return result;
... ... @@ -108,6 +109,7 @@ class ticketsConfirmModel extends global.yoho.BaseModel {
buy_number: param.buyNumber,
mobile: param.mobile,
use_yoho_coin: param.useYohoCoin,
gift_card_code: param.gift_card_code || null,
qhy_union: ''
}}).then((result) => {
return result;
... ...
... ... @@ -483,7 +483,8 @@ function ticketsConfirm() {
productSku: productSku,
buyNumber: buyNumber,
mobile: $ticketsMobile.val(),
useYohoCoin: orderInfo('yohoCoin')
useYohoCoin: orderInfo('yohoCoin'),
gift_card_code: orderInfo('gift_card_code')
};
if (!$ticketsMobile.val()) {
... ...
... ... @@ -154,6 +154,7 @@ function orderCompute() {
deliveryId: deliverId, // 配送方式id
paymentType: orderInfo('paymentType'),
yohoCoin: yohoCoin,
gift_card_code: orderInfo('gift_card_code'),
sku: productSku,
activityId: activityId
};
... ...