Authored by lijing

支付成功页

  1 +/**
  2 + * 支付成功页
  3 + * @author: jing.li<jing.li@yoho.cn>
  4 + * @date: 2016/10/25
  5 + */
  6 +
  7 +'use strict';
  8 +
  9 +const mRoot = '../models';
  10 +const payModel = require(`${mRoot}/pay`);
  11 +const headerModel = require('../../../doraemon/models/header'); // 头部model
  12 +
  13 +// 货到付款
  14 +const payCod = (req, res, next) => {
  15 + let headerData = headerModel.setNav({
  16 + navTitle: '支付完成'
  17 + });
  18 +
  19 + let responseData = {
  20 + pageHeader: headerData,
  21 + module: 'cart',
  22 + page: 'pay',
  23 + title: '支付中心 | Yoho!Buy有货 | 潮流购物逛不停'
  24 + };
  25 +
  26 + let param = {
  27 + uid: req.user.uid,
  28 + udid: req.sessionID || require('md5')(req.ip) || 'yoho',
  29 + orderCode: req.query.order_code,
  30 + contentCode: '05afedf76886d732573f10f7451a1703'
  31 + };
  32 +
  33 + // 如果没有uid,跳转到首页
  34 + if (!param.uid) {
  35 + res.redirect('/');
  36 + return;
  37 + }
  38 +
  39 + payModel.getPayCod(param).then(result => {
  40 + if (result.match === true) {
  41 + res.render('pay/pay-cod', Object.assign(responseData, result));
  42 + } else {
  43 + res.redirect('/');
  44 + }
  45 +
  46 + }).catch(next);
  47 +};
  48 +
  49 +// 支付宝支付
  50 +const payAli = (req, res, next) => {
  51 + let headerData = headerModel.setNav({
  52 + navTitle: '支付完成'
  53 + });
  54 +
  55 + let responseData = {
  56 + pageHeader: headerData,
  57 + module: 'cart',
  58 + page: 'pay',
  59 + title: '支付中心 | Yoho!Buy有货 | 潮流购物逛不停'
  60 + };
  61 +
  62 + let param = {
  63 + uid: req.user.uid,
  64 + udid: req.sessionID || require('md5')(req.ip) || 'yoho',
  65 + orderCode: req.query.out_trade_no,
  66 + contentCode: '05afedf76886d732573f10f7451a1703'
  67 + };
  68 +
  69 + // 如果没有uid,跳转到首页
  70 + if (!param.uid) {
  71 + res.redirect('/');
  72 + return;
  73 + }
  74 +
  75 + payModel.getPayAli(param).then(result => {
  76 + if (result.match === true) {
  77 + res.render('pay/pay-ali', Object.assign(responseData, result));
  78 + } else {
  79 + res.redirect('/');
  80 + }
  81 +
  82 + }).catch(next);
  83 +};
  84 +
  85 +module.exports = {
  86 + payCod,
  87 + payAli
  88 +};
1 /** 1 /**
  2 +<<<<<<< HEAD
2 * sub app cart 3 * sub app cart
3 * @author: xuan.chen@yoho.cn<xuan.chen@yoho.cn> 4 * @author: xuan.chen@yoho.cn<xuan.chen@yoho.cn>
4 * @date: 2016/09/26 5 * @date: 2016/09/26
  6 +=======
  7 + * sub app guang
  8 + * @author: Bi Kai<kai.bi@yoho.cn>
  9 + * @date: 2016/05/09
  10 +>>>>>>> feature/payment
5 */ 11 */
6 12
7 var express = require('express'), 13 var express = require('express'),
@@ -21,11 +27,18 @@ app.use(global.yoho.hbs({ @@ -21,11 +27,18 @@ app.use(global.yoho.hbs({
21 extname: '.hbs', 27 extname: '.hbs',
22 defaultLayout: 'layout', 28 defaultLayout: 'layout',
23 layoutsDir: doraemon, 29 layoutsDir: doraemon,
24 - partialsDir: path.join(__dirname, 'views/partial'), 30 + partialsDir: path.join(__dirname, './views/partial'),
25 views: path.join(__dirname, 'views/action'), 31 views: path.join(__dirname, 'views/action'),
26 helpers: global.yoho.helpers 32 helpers: global.yoho.helpers
27 })); 33 }));
28 34
  35 +// for zookeeper, inject locals
  36 +app.use((req, res, next) => {
  37 + req.app.locals.wap = app.locals.wap;
  38 +
  39 + next();
  40 +});
  41 +
29 // router 42 // router
30 app.use(require('./router')); 43 app.use(require('./router'));
31 44
  1 +/**
  2 + * 支付成功页
  3 + * @author: jing.li<jing.li@yoho.cn>
  4 + * @date: 2016/10/25
  5 + */
  6 +
  7 +'use strict';
  8 +
  9 +const api = global.yoho.API;
  10 +const serviceAPI = global.yoho.ServiceAPI;
  11 +const utils = '../../../utils';
  12 +const productProcess = require(`${utils}/product-process`);
  13 +
  14 +// 资源位
  15 +const _getBanner = (param) => {
  16 + return serviceAPI.get('operations/api/v5/resource/get', {
  17 + content_code: param.contentCode
  18 + }, {
  19 + code: 200
  20 + }).then((result) => {
  21 +
  22 + result = result.data;
  23 +
  24 + return result;
  25 + });
  26 +};
  27 +
  28 +// 购买此商品的用户也购买了
  29 +const _getOthersBuy2 = (param) => {
  30 + return api.get('', {
  31 + method: 'app.recommend.purchased',
  32 + productSkn: param.skn,
  33 + udid: param.uid,
  34 + rec_pos: '100005',
  35 + limit: 2
  36 + }, {
  37 + code: 200
  38 + }).then((result) => {
  39 +
  40 + if (result && result.data && result.data.product_list) {
  41 + return productProcess.processProductList(result.data.product_list);
  42 + }
  43 +
  44 + });
  45 +};
  46 +
  47 +// 订单信息
  48 +const _getOtherDetail = (param) => {
  49 + return api.get('', {
  50 + method: 'app.SpaceOrders.detail',
  51 + uid: param.uid,
  52 + order_code: param.orderCode
  53 + }, {
  54 + code: 200
  55 + }).then((result) => {
  56 +
  57 + return result;
  58 +
  59 + });
  60 +};
  61 +
  62 +// 购买此商品的用户也购买了,要先从订单详情获取商品skn
  63 +const _getOthersBuy = (param) => {
  64 + return api.all([
  65 + _getOtherDetail(param)
  66 + ]).then((result) => {
  67 +
  68 + let goodSkn = '';
  69 +
  70 + if (result && result[0] && result[0].data && result[0].data.order_goods) {
  71 + goodSkn = result[0].data.order_goods[0].product_skn;
  72 + }
  73 +
  74 + return _getOthersBuy2(Object.assign(param, {skn: goodSkn}));
  75 +
  76 + }).then((result) => {
  77 +
  78 + return result;
  79 + });
  80 +};
  81 +
  82 +// 货到付款
  83 +const getPayCod = (param) => {
  84 + return api.all([
  85 + _getBanner(param),
  86 + _getOthersBuy(param),
  87 + _getOtherDetail(param)
  88 + ]).then((result) => {
  89 +
  90 + let resu = {
  91 + match: true,
  92 + banner: [],
  93 + othersBuy: []
  94 + };
  95 +
  96 + if (result && result[0]) {
  97 + resu.banner = result[0];
  98 + }
  99 +
  100 + if (result && result[1]) {
  101 + resu.othersBuy = result[1];
  102 + }
  103 +
  104 + if (result && result[2] && result[2].data && result[2].data.payment_amount) {
  105 + resu.payment = result[2].data.payment_amount;
  106 + } else {
  107 + resu.match = false;
  108 + }
  109 +
  110 + resu.orderCode = param.orderCode;
  111 +
  112 + resu.orderUrl = '/home/orders/detail?order_code=' + param.orderCode;
  113 +
  114 + return resu;
  115 + });
  116 +};
  117 +
  118 +// 支付宝支付
  119 +const getPayAli = (param) => {
  120 + return api.all([
  121 + _getBanner(param),
  122 + _getOthersBuy(param),
  123 + _getOtherDetail(param)
  124 + ]).then((result) => {
  125 +
  126 + let resu = {
  127 + match: true,
  128 + banner: [],
  129 + othersBuy: []
  130 + };
  131 +
  132 + if (result && result[0]) {
  133 + resu.banner = result[0];
  134 + }
  135 +
  136 + if (result && result[1]) {
  137 + resu.othersBuy = result[1];
  138 + }
  139 +
  140 + if (result && result[2] && result[2].data && result[2].data.payment_amount) {
  141 + resu.payment = result[2].data.payment_amount;
  142 + } else {
  143 + resu.match = false;
  144 + }
  145 +
  146 + resu.orderCode = param.orderCode;
  147 +
  148 + resu.orderUrl = '/home/orders/detail?order_code=' + param.orderCode;
  149 +
  150 + return resu;
  151 + });
  152 +};
  153 +
  154 +module.exports = {
  155 + getPayCod,
  156 + getPayAli
  157 +};
@@ -12,6 +12,7 @@ const authMW = require('../../doraemon/middleware/auth'); @@ -12,6 +12,7 @@ const authMW = require('../../doraemon/middleware/auth');
12 12
13 const seckill = require(cRoot + '/seckill'); 13 const seckill = require(cRoot + '/seckill');
14 const countController = require(`${cRoot}/count`); 14 const countController = require(`${cRoot}/count`);
  15 +const payController = require(`${cRoot}/pay`);
15 16
16 // Your controller here 17 // Your controller here
17 router.all('/index/seckill/', authMW); 18 router.all('/index/seckill/', authMW);
@@ -21,5 +22,7 @@ router.post('/index/seckill/compute', seckill.compute); @@ -21,5 +22,7 @@ router.post('/index/seckill/compute', seckill.compute);
21 router.post('/index/seckill/submit', seckill.submit); 22 router.post('/index/seckill/submit', seckill.submit);
22 23
23 router.get('/index/count', countController.cartCount); 24 router.get('/index/count', countController.cartCount);
  25 +router.get('/paySuccess/payCod', payController.payCod);// 支付成功,货到付款
  26 +router.get('/shopping/pay/aliwapreturn', payController.payAli);// 支付成功,支付宝付款
24 27
25 module.exports = router; 28 module.exports = router;
  1 +<div class="pay-success">
  2 + <div class="top-tip">
  3 + <div class="img-c"></div>
  4 + <p class="ok-tip">恭喜您,付款成功!</p>
  5 + </div>
  6 + <div class="info-table-c">
  7 + <table class="info-table">
  8 + <tr>
  9 + <td>订单编号</td>
  10 + <td>{{orderCode}}</td>
  11 + </tr>
  12 + <tr>
  13 + <td>付款金额</td>
  14 + <td>¥{{payment}}</td>
  15 + </tr>
  16 + <tr>
  17 + <td>付款方式</td>
  18 + <td>支付宝</td>
  19 + </tr>
  20 + </table>
  21 + </div>
  22 + <div class="btn-c">
  23 + <a href="/">随便逛逛</a>
  24 + <a href="{{orderUrl}}">查看订单</a>
  25 + </div>
  26 + {{# banner}}
  27 + {{#data}}
  28 + <a href="{{url}}" class="ad-pic" alt="{{alt}}">
  29 + <img src="{{image src 640 200}}" />
  30 + </a>
  31 + {{/data}}
  32 + {{/banner}}
  33 + <div class="others-buy clearfix">
  34 + <p>购买此商品的用户也购买了</p>
  35 + {{# othersBuy}}
  36 + {{> common/goods}}
  37 + {{/ othersBuy}}
  38 + </div>
  39 + {{> home/maybe-like}}
  40 +</div>
  41 +
  1 +<div class="pay-success">
  2 + <div class="top-tip">
  3 + <div class="img-c"></div>
  4 + <p class="ok-tip">订单提交成功</p>
  5 + <p class="left-tip">您需要在收货时向售货员支付¥{{payment}}</p>
  6 + </div>
  7 + <div class="info-table-c">
  8 + <table class="info-table">
  9 + <tr>
  10 + <td>订单编号</td>
  11 + <td>{{orderCode}}</td>
  12 + </tr>
  13 + <tr>
  14 + <td>付款金额</td>
  15 + <td>¥{{payment}}</td>
  16 + </tr>
  17 + <tr>
  18 + <td>付款方式</td>
  19 + <td>货到付款</td>
  20 + </tr>
  21 + </table>
  22 + </div>
  23 + <div class="btn-c">
  24 + <a href="/">随便逛逛</a>
  25 + <a href="{{orderUrl}}">查看订单</a>
  26 + </div>
  27 + {{# banner}}
  28 + {{#data}}
  29 + <a href="{{url}}" class="ad-pic" alt="{{alt}}">
  30 + <img src="{{image src 640 200}}" />
  31 + </a>
  32 + {{/data}}
  33 + {{/banner}}
  34 + <div class="others-buy clearfix">
  35 + <p>购买此商品的用户也购买了</p>
  36 + {{# othersBuy}}
  37 + {{> common/goods}}
  38 + {{/ othersBuy}}
  39 + </div>
  40 + {{> home/maybe-like}}
  41 +</div>
  42 +
@@ -16,6 +16,11 @@ module.exports = () => { @@ -16,6 +16,11 @@ module.exports = () => {
16 req.url = `/activity${req.url}`; 16 req.url = `/activity${req.url}`;
17 } 17 }
18 18
  19 + if (/^\/shopping\/pay\/aliwapreturn/.test(req.url)) {
  20 + // 兼容php的url
  21 + req.url = `/cart${req.url}`;
  22 + }
  23 +
19 if (/^\/sale/.test(req.url)) { 24 if (/^\/sale/.test(req.url)) {
20 // sale 兼容php的url 25 // sale 兼容php的url
21 res.redirect(301, helpers.urlFormat('/product/sale', req.query, 'default')); 26 res.redirect(301, helpers.urlFormat('/product/sale', req.query, 'default'));
  1 +var $ = require('yoho-jquery'),
  2 + lazyLoad = require('yoho-jquery-lazyload');
  3 +
  4 +require('../common');
  5 +
  6 +lazyLoad($('img.lazy'));
  7 +
  8 +function getGender() {
  9 + return window.cookie('_Channel') || 'boys';
  10 +}
  11 +
  12 +require('../channel/maybe-like')(getGender());
  13 +
  14 +if ($('#goods-list').length === 0) {
  15 + $('.maybe-like').hide();
  16 +}
  1 +.pay-success {
  2 + width: 100%;
  3 + overflow: hidden;
  4 + position: relative;
  5 + background-color: #f0f0f0;
  6 +
  7 + .top-tip {
  8 + width: 100%;
  9 + height: 240px;
  10 + border-bottom: solid 1px #e0e0e0;
  11 + text-align: center;
  12 + background-color: #fff;
  13 +
  14 + .img-c {
  15 + margin-top: 25px;
  16 + width: 102px;
  17 + height: 102px;
  18 + background: resolve("cart/pay-ok.png") no-repeat;
  19 + background-size: 100% 100%;
  20 + display: inline-block;
  21 + }
  22 +
  23 + .ok-tip {
  24 + font-size: 24px;
  25 + color: #d0021b;
  26 + line-height: 60px;
  27 + }
  28 +
  29 + .left-tip {
  30 + font-size: 19px;
  31 + color: #b0b0b0;
  32 + }
  33 + }
  34 +
  35 + .info-table-c {
  36 + height: 160px;
  37 + border-bottom: solid 1px #e0e0e0;
  38 + padding: 20px 25px;
  39 + background-color: #fff;
  40 +
  41 + table {
  42 + width: 100%;
  43 +
  44 + tr {
  45 + height: 40px;
  46 + }
  47 +
  48 + td {
  49 + font-size: 24px;
  50 + color: #444;
  51 + }
  52 +
  53 + td:nth-child(2) {
  54 + text-align: right;
  55 + }
  56 + }
  57 + }
  58 +
  59 + .btn-c {
  60 + width: 100%;
  61 + height: 102px;
  62 + background-color: #fff;
  63 + border-bottom: solid 1px #e0e0e0;
  64 + padding: 0 25px;
  65 +
  66 + a {
  67 + width: 270px;
  68 + height: 53px;
  69 + border: solid 2px #444;
  70 + display: block;
  71 + float: left;
  72 + line-height: 53px;
  73 + text-align: center;
  74 + border-radius: 5px;
  75 + box-sizing: border-box;
  76 + -moz-box-sizing: border-box;
  77 + margin-top: 24px;
  78 + font-size: 24px;
  79 + color: #444;
  80 + }
  81 +
  82 + a:nth-child(2) {
  83 + margin-left: 50px;
  84 + }
  85 + }
  86 +
  87 + .ad-pic {
  88 + width: 100%;
  89 + height: 200px;
  90 + display: block;
  91 + background-color: #fff;
  92 + margin: 25px 0;
  93 + }
  94 +
  95 + .others-buy {
  96 + width: 100%;
  97 + margin-bottom: 25px;
  98 + background-color: #fff;
  99 + padding: 25px 0;
  100 + border-top: solid 1px #e4e4e4;
  101 + padding-left: 15px;
  102 +
  103 + p {
  104 + text-align: center;
  105 + color: #444;
  106 + font-size: 27px;
  107 + }
  108 + }
  109 +}
@@ -27,3 +27,4 @@ @@ -27,3 +27,4 @@
27 @import "cart/index"; 27 @import "cart/index";
28 @import "home/index"; 28 @import "home/index";
29 @import "me/index"; 29 @import "me/index";
  30 +@import "cart/pay-success"