Authored by 陈峰

fix

@@ -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 }