Authored by shuaiguo

feat(feature): 优惠券状态查询并修改

  1 +/* eslint-disable indent */
1 /* eslint-disable comma-spacing */ 2 /* eslint-disable comma-spacing */
2 /* eslint-disable keyword-spacing */ 3 /* eslint-disable keyword-spacing */
3 /* eslint-disable quotes */ 4 /* eslint-disable quotes */
@@ -282,7 +283,7 @@ class featureModel extends global.yoho.BaseModel { @@ -282,7 +283,7 @@ class featureModel extends global.yoho.BaseModel {
282 /** 283 /**
283 * 限时抢券时间转换 284 * 限时抢券时间转换
284 */ 285 */
285 - _formatSeckillCouponTime(featureData = {}) { 286 + _formatSeckillCouponTime(featureData = {}) {
286 const {floors = []} = featureData; 287 const {floors = []} = featureData;
287 288
288 const seckillCouponFloor = floors.find(floor=> { 289 const seckillCouponFloor = floors.find(floor=> {
@@ -373,9 +374,8 @@ class featureModel extends global.yoho.BaseModel { @@ -373,9 +374,8 @@ class featureModel extends global.yoho.BaseModel {
373 374
374 floor.component = component.map(c=> { 375 floor.component = component.map(c=> {
375 if(c.type === 'coupon' && colNum === 1) { 376 if(c.type === 'coupon' && colNum === 1) {
376 - const statusImg = seckillCouponStatusInfo[status];  
377 377
378 - return {...c, startTime, endOfDayTime, currentTime, status, statusImg}; 378 + return {...c, startTime, endOfDayTime, currentTime, status, statusImg: seckillCouponStatusInfo};
379 }else { 379 }else {
380 return c; 380 return c;
381 } 381 }
@@ -135,7 +135,10 @@ @@ -135,7 +135,10 @@
135 {{#isEqualOr seckillCoupon '1'}} 135 {{#isEqualOr seckillCoupon '1'}}
136 {{#if statusImg}} 136 {{#if statusImg}}
137 <div class="status-img"> 137 <div class="status-img">
138 - <img src="{{statusImg}}"/> 138 + <img
  139 + {{#isEqualOr status 'begin'}}id="{{token}}"{{/isEqualOr}}
  140 + data-status-imgs="{{stringify statusImg}}"
  141 + src="{{getKeyValue statusImg status}}"/>
139 </div> 142 </div>
140 {{/if}} 143 {{/if}}
141 {{!-- yoho-conpon 领券 --}} 144 {{!-- yoho-conpon 领券 --}}
@@ -133,7 +133,9 @@ module.exports = { @@ -133,7 +133,9 @@ module.exports = {
133 notifyUrl: domains.service + 'payment/weixin_notify', 133 notifyUrl: domains.service + 'payment/weixin_notify',
134 }, 134 },
135 geetestJs: '//static.geetest.com/static/tools/gt.js', 135 geetestJs: '//static.geetest.com/static/tools/gt.js',
136 - jsSdk: '//cdn.yoho.cn/js-sdk/1.3.24/jssdk.js', 136 +
  137 + // jsSdk: '//cdn.yoho.cn/js-sdk/1.3.24/jssdk.js',
  138 + jsSdk: 'https://cdn.yoho.cn/js-sdk/1.3.25-beta-2/jssdk.js',
137 redis: { 139 redis: {
138 connect: { 140 connect: {
139 host: '192.168.102.49', 141 host: '192.168.102.49',
1 { 1 {
2 "name": "yohobuywap-node-activity", 2 "name": "yohobuywap-node-activity",
3 - "version": "6.9.15-22", 3 + "version": "6.9.15-23",
4 "private": true, 4 "private": true,
5 "description": "A New Yohobuy Project With Express", 5 "description": "A New Yohobuy Project With Express",
6 "repository": { 6 "repository": {
@@ -1383,6 +1383,42 @@ function seckillCouponTimeTask() { @@ -1383,6 +1383,42 @@ function seckillCouponTimeTask() {
1383 } 1383 }
1384 } 1384 }
1385 1385
  1386 +// 限时抢券 优惠券已抢光状态
  1387 +function couponSendFinished() {
  1388 + let activityId = JSON.parse($('.activity-id').val());
  1389 + let templateId = JSON.parse($('.template-id').val());
  1390 +
  1391 + let data = {
  1392 + activityId,
  1393 + templateId
  1394 + };
  1395 +
  1396 + $.ajax({
  1397 + url: '//m.yohobuy.com/activity/feature/coupon/send/info',
  1398 + dataType: 'jsonp',
  1399 + data
  1400 + }).then((res)=> {
  1401 + if(res.code === 200) {
  1402 + res.data.forEach(coupon => {
  1403 + const { token, sendFinished } = coupon;
  1404 +
  1405 + // 1: 已发完 0: 未发完
  1406 + if(sendFinished) {
  1407 + let $img = $(`#${token}`);
  1408 +
  1409 + if($img) {
  1410 + let statusImgs = $img.data('status-imgs');
  1411 +
  1412 + if(statusImgs) {
  1413 + $img.attr('src', statusImgs.end);
  1414 + }
  1415 + }
  1416 + }
  1417 + });
  1418 + }
  1419 + });
  1420 +}
  1421 +
1386 // 活动计划动态刷新 1422 // 活动计划动态刷新
1387 function activityPlan() { 1423 function activityPlan() {
1388 let atlBo = $('.activity-plan').val(); 1424 let atlBo = $('.activity-plan').val();
@@ -1555,4 +1591,7 @@ $(function() { @@ -1555,4 +1591,7 @@ $(function() {
1555 1591
1556 // 限时抢券定时任务 1592 // 限时抢券定时任务
1557 seckillCouponTimeTask(); 1593 seckillCouponTimeTask();
  1594 +
  1595 + // couponSendFinished
  1596 + couponSendFinished();
1558 }); 1597 });
@@ -309,5 +309,8 @@ module.exports = { @@ -309,5 +309,8 @@ module.exports = {
309 return s; 309 return s;
310 } 310 }
311 }); 311 });
  312 + },
  313 + getKeyValue(obj = {}, key) {
  314 + return obj[key] || '';
312 } 315 }
313 }; 316 };