Showing
5 changed files
with
212 additions
and
1 deletions
apps/cart/controllers/EasyPayController.js
0 → 100644
1 | +/* | ||
2 | + * @Author: Targaryen | ||
3 | + * @Date: 2017-06-21 10:15:38 | ||
4 | + * @Last Modified by: Targaryen | ||
5 | + * @Last Modified time: 2017-06-21 11:51:51 | ||
6 | + */ | ||
7 | +const headerModel = require('../../../doraemon/models/header'); | ||
8 | +const EasyPayModel = require('../models/EasyPayModel'); | ||
9 | + | ||
10 | +class EasyPayController { | ||
11 | + /** | ||
12 | + * 确认订单页面 | ||
13 | + * @param {*} req | ||
14 | + * @param {*} res | ||
15 | + * @param {*} next | ||
16 | + */ | ||
17 | + orderEnsure(req, res, next) { | ||
18 | + req.ctx(EasyPayModel).easyPayment({ | ||
19 | + uid: req.user.uid, | ||
20 | + cart_type: req.query.cart_type, | ||
21 | + product_sku_list: req.query.product_sku_list || '[{"goods_type":"ordinary","selected":"N","product_sku":2026740,"promotion_id":"","buy_number":"1"}]' // eslint-disable-line | ||
22 | + }).then(result => { | ||
23 | + let headerData = headerModel.setNav({ | ||
24 | + navTitle: '确认订单', | ||
25 | + navBtn: false | ||
26 | + }); | ||
27 | + | ||
28 | + return res.render('order-ensure', { | ||
29 | + pageHeader: headerData, | ||
30 | + module: 'easypay', | ||
31 | + page: 'order-ensure', | ||
32 | + orderEnsure: result | ||
33 | + }); | ||
34 | + }).catch(next); | ||
35 | + } | ||
36 | + | ||
37 | + /** | ||
38 | + * 参数更改,重新运算结算数据 | ||
39 | + * @param {*} req | ||
40 | + * @param {*} res | ||
41 | + * @param {*} next | ||
42 | + */ | ||
43 | + orderCompute(req, res, next) { | ||
44 | + req.ctx(EasyPayModel).easyCompute({ | ||
45 | + uid: req.user.uid, | ||
46 | + cart_type: req.body.cart_type, | ||
47 | + delivery_way: req.body.delivery_way, | ||
48 | + payment_type: req.body.payment_type, | ||
49 | + product_sku_list: req.body.product_sku_list, | ||
50 | + coupon_code: req.body.coupon_code, | ||
51 | + use_yoho_coin: req.body.use_yoho_coin, | ||
52 | + }).then(result => { | ||
53 | + return res.json(result); | ||
54 | + }).catch(next); | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * 提交订单 | ||
59 | + * @param {*} req | ||
60 | + * @param {*} res | ||
61 | + * @param {*} next | ||
62 | + */ | ||
63 | + orderSub(req, res, next) { | ||
64 | + let qhy_union = ''; // TODO | ||
65 | + | ||
66 | + req.ctx(EasyPayModel).easySubmit({ | ||
67 | + uid: req.user.uid, | ||
68 | + cart_type: req.body.cart_type, | ||
69 | + address_id: req.body.address_id, | ||
70 | + delivery_time: req.body.delivery_time, | ||
71 | + delivery_way: req.body.delivery_way, | ||
72 | + use_yoho_coin: req.body.use_yoho_coin, | ||
73 | + use_red_envelopes: req.body.use_red_envelopes, | ||
74 | + payment_id: req.body.payment_id, | ||
75 | + payment_type: req.body.payment_type, | ||
76 | + product_sku_list: req.body.product_sku_list, | ||
77 | + is_print_price: req.body.is_print_price, | ||
78 | + qhy_union: qhy_union, | ||
79 | + invoices_title: req.body.invoices_title, | ||
80 | + invoices_type_id: req.body.invoices_type_id, | ||
81 | + remark: req.body.remark, | ||
82 | + activity_id: req.body.activity_id | ||
83 | + }).then(result => { | ||
84 | + return res.json(result); | ||
85 | + }).catch(next); | ||
86 | + } | ||
87 | +} | ||
88 | + | ||
89 | +module.exports = new EasyPayController(); |
apps/cart/models/EasyPayModel.js
0 → 100644
1 | +/* | ||
2 | + * @Author: Targaryen | ||
3 | + * @Date: 2017-06-21 10:15:45 | ||
4 | + * @Last Modified by: Targaryen | ||
5 | + * @Last Modified time: 2017-06-21 11:38:49 | ||
6 | + */ | ||
7 | +const api = global.yoho.API; | ||
8 | + | ||
9 | +class EasyPayModel extends global.yoho.BaseModel { | ||
10 | + constructor(ctx) { | ||
11 | + super(ctx); | ||
12 | + } | ||
13 | + | ||
14 | + /** | ||
15 | + * 结算页面数据渲染 | ||
16 | + * @param {*} params | ||
17 | + */ | ||
18 | + easyPayment(params) { | ||
19 | + let finalParams = { | ||
20 | + method: 'app.Shopping.easyPayment', | ||
21 | + uid: params.uid, | ||
22 | + enable_red_envelopes: 0, // h5不返回红包 | ||
23 | + cart_type: params.cart_type || 'ordinary', | ||
24 | + yoho_coin_mode: params.yoho_coin_mode || 0, // 是否使用有货币 | ||
25 | + product_sku_list: JSON.stringify(params.product_sku_list), | ||
26 | + is_support_apple_pay: 'N' | ||
27 | + }; | ||
28 | + | ||
29 | + if (params.activity_id) { | ||
30 | + finalParams.activity_id = params.activity_id; | ||
31 | + } | ||
32 | + | ||
33 | + return api.get('', finalParams, { cache: false }); | ||
34 | + } | ||
35 | + | ||
36 | + /** | ||
37 | + * 数据改变,重新计算结算数据 | ||
38 | + * @param {*} params | ||
39 | + */ | ||
40 | + easyCompute(params) { | ||
41 | + let finalParams = { | ||
42 | + method: 'app.Shopping.easyCompute', | ||
43 | + uid: params.uid, | ||
44 | + cart_type: params.cart_type, | ||
45 | + delivery_way: params.delivery_way, | ||
46 | + payment_type: params.payment_type, | ||
47 | + product_sku_list: params.product_sku_list | ||
48 | + }; | ||
49 | + | ||
50 | + if (params.coupon_code) { | ||
51 | + finalParams.coupon_code = params.coupon_code; | ||
52 | + } | ||
53 | + | ||
54 | + if (params.use_yoho_coin) { | ||
55 | + finalParams.use_yoho_coin = params.use_yoho_coin; | ||
56 | + } | ||
57 | + | ||
58 | + return api.get('', finalParams, {cache: false}); | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * 提交订单 | ||
63 | + * @param {*} params | ||
64 | + */ | ||
65 | + easySubmit(params) { | ||
66 | + let finalParams = { | ||
67 | + method: 'app.Shopping.easySubmit', | ||
68 | + uid: params.uid, | ||
69 | + cart_type: params.cart_type, | ||
70 | + address_id: params.address_id, | ||
71 | + delivery_time: params.delivery_time, | ||
72 | + delivery_way: params.delivery_way, | ||
73 | + use_yoho_coin: params.use_yoho_coin || 0, | ||
74 | + use_red_envelopes: params.use_red_envelopes || 0, | ||
75 | + payment_id: params.payment_id, | ||
76 | + payment_type: params.payment_type || 1, | ||
77 | + product_sku_list: JSON.stringify(params.product_sku_list), | ||
78 | + is_print_price: params.is_print_price || 'N', | ||
79 | + qhy_union: params.qhy_union | ||
80 | + }; | ||
81 | + | ||
82 | + if (params.invoices_title) { | ||
83 | + finalParams.invoices_title = params.invoices_title; | ||
84 | + } | ||
85 | + | ||
86 | + if (params.invoices_type_id) { | ||
87 | + finalParams.invoices_type_id = params.invoices_type_id; | ||
88 | + } | ||
89 | + | ||
90 | + if (params.remark) { | ||
91 | + finalParams.remark = params.remark; | ||
92 | + } | ||
93 | + | ||
94 | + if (params.activity_id) { | ||
95 | + finalParams.activity_id = params.activity_id; | ||
96 | + } | ||
97 | + | ||
98 | + return api.get('', finalParams, {cache: false}); | ||
99 | + } | ||
100 | +} | ||
101 | + | ||
102 | +module.exports = EasyPayModel; |
@@ -16,6 +16,7 @@ const countController = require(`${cRoot}/count`); | @@ -16,6 +16,7 @@ const countController = require(`${cRoot}/count`); | ||
16 | const payController = require(`${cRoot}/pay`); | 16 | const payController = require(`${cRoot}/pay`); |
17 | const indexController = require(`${cRoot}/index`); | 17 | const indexController = require(`${cRoot}/index`); |
18 | const ticketsConfirmController = require(`${cRoot}/ticketsConfirm`); | 18 | const ticketsConfirmController = require(`${cRoot}/ticketsConfirm`); |
19 | +const EasyPayController = require(`${cRoot}/EasyPayController`); | ||
19 | 20 | ||
20 | // Your controller here | 21 | // Your controller here |
21 | router.all('/index/seckill/', authMW); | 22 | router.all('/index/seckill/', authMW); |
@@ -34,7 +35,7 @@ router.get('/index/new/pay/alipayresult', authMW, payController.payAli);// 支 | @@ -34,7 +35,7 @@ router.get('/index/new/pay/alipayresult', authMW, payController.payAli);// 支 | ||
34 | 35 | ||
35 | router.get('/index/new/orderEnsure', authMW, order.orderEnsure); // 订单结算 | 36 | router.get('/index/new/orderEnsure', authMW, order.orderEnsure); // 订单结算 |
36 | router.post('/index/new/orderCompute', authMW, order.orderCompute); // 结算页参数改变,重新运算 | 37 | router.post('/index/new/orderCompute', authMW, order.orderCompute); // 结算页参数改变,重新运算 |
37 | -router.post('/index/new/orderSub', authMW, order.orderSub); // 结算页参数改变,重新运算 | 38 | +router.post('/index/new/orderSub', authMW, order.orderSub); // 订单提交 |
38 | router.get('/index/new/selectCoupon', authMW, order.selectCoupon); // 选择优惠券 页面 | 39 | router.get('/index/new/selectCoupon', authMW, order.selectCoupon); // 选择优惠券 页面 |
39 | router.get('/index/new/couponList', order.couponList); // [ajax]获取优惠券列表 | 40 | router.get('/index/new/couponList', order.couponList); // [ajax]获取优惠券列表 |
40 | router.post('/index/new/couponSearch', order.couponSearch); // [ajax]购物车输入优惠券码使用优惠券 | 41 | router.post('/index/new/couponSearch', order.couponSearch); // [ajax]购物车输入优惠券码使用优惠券 |
@@ -61,6 +62,9 @@ router.post('/index/new/giftinfo', indexController.giftinfo); // 获取购物车 | @@ -61,6 +62,9 @@ router.post('/index/new/giftinfo', indexController.giftinfo); // 获取购物车 | ||
61 | router.post('/index/new/incrbundle', indexController.incrBundle); // 购物车增加套餐数量 | 62 | router.post('/index/new/incrbundle', indexController.incrBundle); // 购物车增加套餐数量 |
62 | router.post('/index/new/decrbundle', indexController.decrBundle); // 购物车减少加套餐数量 | 63 | router.post('/index/new/decrbundle', indexController.decrBundle); // 购物车减少加套餐数量 |
63 | 64 | ||
65 | +router.get('/easypay/orderensure', authMW, EasyPayController.orderEnsure); // 立即购买订单确认页面 | ||
66 | +router.post('/easypay/ordercompute', authMW, EasyPayController.orderCompute); // 立即购买订单重新计算 | ||
67 | +router.post('/easypay/ordersub', authMW, EasyPayController.orderSub); // 立即购买订单提交 | ||
64 | 68 | ||
65 | // 支付中心 URL,由于微信安全限制,在现有 URL 后追加 new ,通过 subDomain 中间件转发到此 | 69 | // 支付中心 URL,由于微信安全限制,在现有 URL 后追加 new ,通过 subDomain 中间件转发到此 |
66 | router.get('/home/orders/paynew', authMW, payController.payCenter); | 70 | router.get('/home/orders/paynew', authMW, payController.payCenter); |
public/js/easypay/order-ensure.page.js
0 → 100644
-
Please register or login to post a comment