Authored by 陈峰

Merge branch 'release/0823' into 'master'

Release/0823



See merge request !43
@@ -68,6 +68,14 @@ function getActivityStatus(info = {}, num, now) { @@ -68,6 +68,14 @@ function getActivityStatus(info = {}, num, now) {
68 return resStatus; 68 return resStatus;
69 } 69 }
70 70
  71 +function replaceHttp(url) {
  72 + if (url && url.indexOf('http:') > -1) {
  73 + url = url.replace(/http:/ig, 'https:');
  74 + }
  75 +
  76 + return url;
  77 +}
  78 +
71 function handelActivityList(list, nums) { 79 function handelActivityList(list, nums) {
72 let now = new Date().getTime() / 1000; 80 let now = new Date().getTime() / 1000;
73 81
@@ -75,6 +83,7 @@ function handelActivityList(list, nums) { @@ -75,6 +83,7 @@ function handelActivityList(list, nums) {
75 nums = _.concat([], nums); 83 nums = _.concat([], nums);
76 84
77 _.forEach(list, (value, index) => { 85 _.forEach(list, (value, index) => {
  86 + value.cover_img = replaceHttp(value.cover_img);
78 value.price = '¥' + (value.price || 0).toFixed(2); 87 value.price = '¥' + (value.price || 0).toFixed(2);
79 value.status = getActivityStatus(value, nums[index], now); 88 value.status = getActivityStatus(value, nums[index], now);
80 }); 89 });
@@ -100,11 +109,27 @@ module.exports = class extends global.yoho.BaseModel { @@ -100,11 +109,27 @@ module.exports = class extends global.yoho.BaseModel {
100 page = parseInt(page, 10) || 1; 109 page = parseInt(page, 10) || 1;
101 110
102 let limit = `${(page - 1) * PAGE_SIZE},${PAGE_SIZE}`; 111 let limit = `${(page - 1) * PAGE_SIZE},${PAGE_SIZE}`;
  112 + let where = ['act_id = :actId'];
  113 +
  114 + let now = new Date().getTime() / 1000;
  115 +
  116 + switch (+extra.type) {
  117 + case 1:
  118 + where.push('status > 0 and start_time > :now');
  119 + break;
  120 + case 2:
  121 + where.push('status > 0');
  122 + where.push('(end_time < :now or is_full > 0)');
  123 + break;
  124 + default:
  125 + where.push('status = 1 and start_time <= :now and end_time >= :now and is_full = 0');
  126 + break;
  127 + }
103 128
104 return mysqlCli.query(`select * from ${TABLE_ACT_PRIZE_PRODUCT} 129 return mysqlCli.query(`select * from ${TABLE_ACT_PRIZE_PRODUCT}
105 - where act_id = :actId and status > 0  
106 - order by sort desc limit ${limit}`, {  
107 - actId 130 + where ${where.join(' and ')} order by sort desc limit ${limit}`, {
  131 + actId,
  132 + now
108 }, { 133 }, {
109 cache: PRODUCT_CACHE_TIMES 134 cache: PRODUCT_CACHE_TIMES
110 }).then(result => { 135 }).then(result => {
@@ -216,11 +241,16 @@ module.exports = class extends global.yoho.BaseModel { @@ -216,11 +241,16 @@ module.exports = class extends global.yoho.BaseModel {
216 if (product && product.length) { 241 if (product && product.length) {
217 resData = product[0] || {}; 242 resData = product[0] || {};
218 resData.content = _.sortBy(content || [], o => { 243 resData.content = _.sortBy(content || [], o => {
  244 + if (+o.floor_type === 2) {
  245 + o.content = replaceHttp(o.content);
  246 + }
  247 +
219 return o.sort; 248 return o.sort;
220 }); 249 });
221 250
222 let joinNum = _.get(count, 'join_num', 0); 251 let joinNum = _.get(count, 'join_num', 0);
223 252
  253 + resData.cover_img = replaceHttp(resData.cover_img);
224 resData.price = '¥' + resData.price.toFixed(2); 254 resData.price = '¥' + resData.price.toFixed(2);
225 resData.joinNum = joinNum; 255 resData.joinNum = joinNum;
226 resData.status = getActivityStatus(resData, joinNum); 256 resData.status = getActivityStatus(resData, joinNum);
@@ -492,7 +522,7 @@ module.exports = class extends global.yoho.BaseModel { @@ -492,7 +522,7 @@ module.exports = class extends global.yoho.BaseModel {
492 params: JSON.stringify({ 522 params: JSON.stringify({
493 activityTitle: extra.actName, 523 activityTitle: extra.actName,
494 activityTime: `${timeFormat(extra.actStartTime)} - ${timeFormat(extra.actEndTime)}`, 524 activityTime: `${timeFormat(extra.actStartTime)} - ${timeFormat(extra.actEndTime)}`,
495 - pageUrl: '/page/subPackage/pages/zeroSell/detail?actPrizeId=' + actPrizeId 525 + pageUrl: 'page/subPackage/pages/zeroSell/detail?actPrizeId=' + actPrizeId
496 }), 526 }),
497 uidList: [uid] 527 uidList: [uid]
498 } 528 }
@@ -147,6 +147,24 @@ const couponController = { @@ -147,6 +147,24 @@ const couponController = {
147 next; 147 next;
148 } 148 }
149 }, 149 },
  150 + downloadTpl(req, res) {
  151 + let conf = {
  152 + name: 'mysheet',
  153 + cols: [
  154 + {
  155 + caption: 'couponNo',
  156 + type: 'String'
  157 + }
  158 + ],
  159 + rows: [['c3236233105'], ['c3236233105']]
  160 + };
  161 + let exportFile = excelExport.execute(conf);
  162 +
  163 + res.setHeader('Content-Type', 'application/vnd.openxmlformats');
  164 + res.setHeader('Content-Disposition', 'attachment; filename=couponNoTpl.xlsx');
  165 + res.end(exportFile, 'binary');
  166 +
  167 + },
150 downloadNoList(req, res, next) { 168 downloadNoList(req, res, next) {
151 const couponId = req.query.id; 169 const couponId = req.query.id;
152 170
@@ -761,7 +761,7 @@ class AdminModel extends global.yoho.BaseModel { @@ -761,7 +761,7 @@ class AdminModel extends global.yoho.BaseModel {
761 params: JSON.stringify({ 761 params: JSON.stringify({
762 activityTitle: productInfo.name, 762 activityTitle: productInfo.name,
763 activityTime: moment().format('YYYY-MM-DD HH:mm') + ':00', 763 activityTime: moment().format('YYYY-MM-DD HH:mm') + ':00',
764 - pageUrl: '/page/subPackage/pages/zeroSell/detail?actPrizeId=' + id 764 + pageUrl: 'page/subPackage/pages/zeroSell/detail?actPrizeId=' + id
765 }) 765 })
766 }; 766 };
767 767
@@ -67,6 +67,7 @@ router.post('/api/coupon/modify', coupon.modifyCoupon); @@ -67,6 +67,7 @@ router.post('/api/coupon/modify', coupon.modifyCoupon);
67 router.post('/api/coupon/batchAddNo', mutilpartMiddleware, coupon.loadCouponNoList); 67 router.post('/api/coupon/batchAddNo', mutilpartMiddleware, coupon.loadCouponNoList);
68 router.get('/api/coupon/downloadNo', coupon.downloadNoList); 68 router.get('/api/coupon/downloadNo', coupon.downloadNoList);
69 router.get('/api/coupon/delete', coupon.deleteCoupon); 69 router.get('/api/coupon/delete', coupon.deleteCoupon);
  70 +router.get('/api/coupon/downloadTpl', coupon.downloadTpl);
70 71
71 // 用户管理[ajax] 72 // 用户管理[ajax]
72 router.post('/api/user/delete', user.deleteUser); 73 router.post('/api/user/delete', user.deleteUser);
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 <div class="x_panel"> 6 <div class="x_panel">
7 <div class="x_title"> 7 <div class="x_title">
8 <a href="/admin/coupon/option" class="btn btn-primary">创建券</a> 8 <a href="/admin/coupon/option" class="btn btn-primary">创建券</a>
  9 + <a href="/admin/api/coupon/downloadTpl" class="btn btn-primary">下载导入券码模版</a>
9 <div class="btn-group" style="vertical-align: top"> 10 <div class="btn-group" style="vertical-align: top">
10 <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> 11 <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
11 <span id="dropdown-toggle-txt">全部 </span> <span class="caret"></span> 12 <span id="dropdown-toggle-txt">全部 </span> <span class="caret"></span>
@@ -5,11 +5,18 @@ @@ -5,11 +5,18 @@
5 */ 5 */
6 const qiniu = require('qiniu'); 6 const qiniu = require('qiniu');
7 const qiniuConfig = global.yoho.config.qiniu; 7 const qiniuConfig = global.yoho.config.qiniu;
  8 +const qiniuYohoCdnConfig = global.yoho.config.qiniuYohoCdn;
8 9
9 function getToken(req, res) { 10 function getToken(req, res) {
10 - let mac = new qiniu.auth.digest.Mac(qiniuConfig.ACCESS_KEY, qiniuConfig.SECRET_KEY); 11 + let conf = qiniuConfig;
  12 +
  13 + if (req.query.type === 'yohoCdn') {
  14 + conf = qiniuYohoCdnConfig;
  15 + }
  16 +
  17 + let mac = new qiniu.auth.digest.Mac(conf.ACCESS_KEY, conf.SECRET_KEY);
11 let options = { 18 let options = {
12 - scope: qiniuConfig.BUCKET_NAME, 19 + scope: conf.BUCKET_NAME
13 }; 20 };
14 let putPolicy = new qiniu.rs.PutPolicy(options); 21 let putPolicy = new qiniu.rs.PutPolicy(options);
15 let uploadToken = putPolicy.uploadToken(mac); 22 let uploadToken = putPolicy.uploadToken(mac);
@@ -217,7 +217,7 @@ const yohood = { @@ -217,7 +217,7 @@ const yohood = {
217 217
218 let couponDetail = await req.ctx(YohoodModel).getCouponDetail(uid, couponId); 218 let couponDetail = await req.ctx(YohoodModel).getCouponDetail(uid, couponId);
219 219
220 - // console.log('couponDetail:', couponDetail); 220 + // console.log('couponDetail:', couponDetail, uid, couponId);
221 // console.log('couponInfo', couponInfo.data[0].coupon_num); 221 // console.log('couponInfo', couponInfo.data[0].coupon_num);
222 222
223 if (couponDetail.code === 200 && couponDetail.data.length > 0) { 223 if (couponDetail.code === 200 && couponDetail.data.length > 0) {
@@ -108,6 +108,12 @@ module.exports = { @@ -108,6 +108,12 @@ module.exports = {
108 SECRET_KEY: '_x2VtO7fEmylgjojmLi7qwTBtRm30S8BrO0FxOPK', 108 SECRET_KEY: '_x2VtO7fEmylgjojmLi7qwTBtRm30S8BrO0FxOPK',
109 BUCKET_NAME: 'cmsimg01' 109 BUCKET_NAME: 'cmsimg01'
110 }, 110 },
  111 + qiniuYohoCdn: {
  112 + ACCESS_KEY: 'BwWhoJN536BnV3CzlE20AjNKC9O2bP0l5tFpKsDU',
  113 + SECRET_KEY: '_x2VtO7fEmylgjojmLi7qwTBtRm30S8BrO0FxOPK',
  114 + ORIGIN: 'https://cdn.yoho.cn',
  115 + BUCKET_NAME: 'yohocdn'
  116 + },
111 yohoSecret: '3bd815162342d9733f06ab6811082c64', 117 yohoSecret: '3bd815162342d9733f06ab6811082c64',
112 wechat: { 118 wechat: {
113 appID: 'wx1fe49f08f41b6c26', // jsapi 用 119 appID: 'wx1fe49f08f41b6c26', // jsapi 用
@@ -116,7 +116,7 @@ function initUpload() { @@ -116,7 +116,7 @@ function initUpload() {
116 Qiniu.uploader({ // eslint-disable-line 116 Qiniu.uploader({ // eslint-disable-line
117 runtimes: 'html5,flash,html4', 117 runtimes: 'html5,flash,html4',
118 browse_button: 'upload-btn', 118 browse_button: 'upload-btn',
119 - uptoken_url: '/api/getToken', 119 + uptoken_url: '/api/getToken?type=yohoCdn',
120 unique_names: true, 120 unique_names: true,
121 multi_selection: false, 121 multi_selection: false,
122 filters: { 122 filters: {
@@ -125,7 +125,7 @@ function initUpload() { @@ -125,7 +125,7 @@ function initUpload() {
125 }] 125 }]
126 }, 126 },
127 dragdrop: false, 127 dragdrop: false,
128 - domain: 'http://img01.yohoboys.com/', 128 + domain: 'https://cdn.yoho.cn/',
129 max_file_size: '10mb', 129 max_file_size: '10mb',
130 max_retries: 3, 130 max_retries: 3,
131 chunk_size: '10mb', 131 chunk_size: '10mb',
@@ -59,7 +59,6 @@ class SqlHelper { @@ -59,7 +59,6 @@ class SqlHelper {
59 }); 59 });
60 } 60 }
61 async execute(sql, params, options = {}) { 61 async execute(sql, params, options = {}) {
62 - console.log(sql);  
63 let cacheTime = parseInt(options.cache, 10) || 0; 62 let cacheTime = parseInt(options.cache, 10) || 0;
64 let cacheKey; 63 let cacheKey;
65 64