diff --git a/addon/futures/api/controller/Futures.php b/addon/futures/api/controller/Futures.php index bb9ad1e4..80a66e7c 100644 --- a/addon/futures/api/controller/Futures.php +++ b/addon/futures/api/controller/Futures.php @@ -14,11 +14,7 @@ class Futures extends BaseApi{ $token = $this->checkToken(); if ($token['code'] < 0) return $this->response($token); - $fenxiao = model('fenxiao')->getInfo([['member_id', '=', $this->member_id]]); - // $is_read = FALSE; - // if(empty($fenxiao) || $fenxiao['diamond'] < 0){ - // $is_read = - // }//TODO 判断当前时间是否在秒杀开启时间,并区分有无钻石用户 + //判断当前时间是否在秒杀开启时间,并区分有无钻石用户 $status = input('status', 'miaosha'); @@ -29,15 +25,38 @@ class Futures extends BaseApi{ switch($status){ case 'miaosha': $condition[] = ['a.status', '=', '2']; + $startTimeKey = 'miaosha_start_time'; + $endTimeKey = 'miaosha_end_time'; + $fenxiao = model('fenxiao')->getInfo([['member_id', '=', $this->member_id]]); + if(!empty($fenxiao) && $fenxiao['diamond'] > 0){ + $startTimeKey = 'miaosha_early_start_time'; + } break; case 'jianlou': $condition[] = ['a.status', '=', '7']; + $startTimeKey = 'jianlou_start_time'; + $endTimeKey = 'jianlou_end_time'; break; default: - $condition[] = ['a.status', '=', '2']; + return $this->response($this->error('','参数不合法')); break; } + $nowTime = time() - strtotime("today"); + $is_read = FALSE; + + $futuresModel = new FuturesModel; + $basics = $futuresModel->getBasicsConfig($this->site_id)['data']['value']; + foreach($basics['times'] as $times){ + if($times[$startTimeKey] <= $nowTime && $times[$endTimeKey] >= $nowTime){ + $is_read = TRUE; + break; + } + } + + if(!$is_read){ + return $this->response($this->error('','未到秒杀时间')); + } // 获取内容 $field = [ @@ -62,7 +81,7 @@ class Futures extends BaseApi{ ['goods g', 'g.goods_id = a.goods_id', 'left'],// 获取商品信息 ]; - $futuresModel = new FuturesModel; + $page = input('page', 1); $page_size = input('page_size', PAGE_LIST_ROWS); $list = $futuresModel->getPageList($condition, $page, $page_size, 'a.created_time desc,a.id desc', $field, 'a', $join); diff --git a/addon/futures/shop/view/config/basics.html b/addon/futures/shop/view/config/basics.html index e77118dd..1a614a3c 100644 --- a/addon/futures/shop/view/config/basics.html +++ b/addon/futures/shop/view/config/basics.html @@ -16,17 +16,15 @@ 秒杀时间设置
-
-
- -
- - -
-
-
+ + + + + + + + +
@@ -70,19 +68,21 @@
- - - - - + + + + + + + - + @@ -92,13 +92,13 @@
*秒杀提前开始时间 *秒杀开始时间 *秒杀结束时间 *捡漏开始时间 *捡漏结束时间操作
- - - - - - - +
@@ -131,7 +131,7 @@ function isNullTable() { var len = $(".attr-new .goods-attr-tr").length; if (len == 0) { - $(".attr-new").html('无数据'); + $(".attr-new").html('无数据'); } else { $(".attr-new .null-data").remove(); } @@ -154,8 +154,18 @@ form.render(); - addNewAttr = function (times){ + addNewAttr = function (times = { + miaosha_early_start_time: 0, + miaosha_start_time: 0, + miaosha_end_time: 0, + jianlou_start_time: 0, + jianlou_end_time: 0, + }){ var html = '' + + '' + + '' + + '' + + '' + '' + '' + '' + @@ -172,30 +182,40 @@ '' + '' + '' + - // '' + - // '
删除
' + - // '' + + '' + + '
删除
' + + '' + ''; $(".attr-new").append(html); isNullTable(); - console.log(times.miaosha_start_time,getData(times.miaosha_start_time)) + laydate.render({ + elem: '#miaoshaEarlyStartTime' + ($('.goods-attr-tr').length - 1) + , type: 'time' + ,value: getData(times.miaosha_early_start_time) + ,done: function(value, date, endDate){ + var time = date.hours * 3600 + date.minutes * 60 + date.seconds; + $('#miaoshaEarlyStartTimeInput' + this.elem.selector.substr(-1)).val(time); + } + }); + console.log($('.goods-attr-tr').length) laydate.render({ elem: '#miaoshaStartTime' + ($('.goods-attr-tr').length - 1) , type: 'time' ,value: getData(times.miaosha_start_time) ,done: function(value, date, endDate){ var time = date.hours * 3600 + date.minutes * 60 + date.seconds; - $('#miaoshaStartTimeInput' + ($('.goods-attr-tr').length - 1)).val(time); + $('#miaoshaStartTimeInput' + this.elem.selector.substr(-1)).val(time); } }); + console.log($('.goods-attr-tr').length) laydate.render({ elem: '#miaoshaEndTime' + ($('.goods-attr-tr').length - 1) , type: 'time' ,value: getData(times.miaosha_end_time) ,done: function(value, date, endDate){ var time = date.hours * 3600 + date.minutes * 60 + date.seconds; - $('#miaoshaEndTimeInput' + ($('.goods-attr-tr').length - 1)).val(time); + $('#miaoshaEndTimeInput' + this.elem.selector.substr(-1)).val(time); } }); laydate.render({ @@ -204,7 +224,7 @@ ,value: getData(times.jianlou_start_time) ,done: function(value, date, endDate){ var time = date.hours * 3600 + date.minutes * 60 + date.seconds; - $('#jianlouStartTimeInput' + ($('.goods-attr-tr').length - 1)).val(time); + $('#jianlouStartTimeInput' + this.elem.selector.substr(-1)).val(time); } }); laydate.render({ @@ -213,7 +233,7 @@ ,value: getData(times.jianlou_end_time) ,done: function(value, date, endDate){ var time = date.hours * 3600 + date.minutes * 60 + date.seconds; - $('#jianlouEndTimeInput' + ($('.goods-attr-tr').length - 1)).val(time); + $('#jianlouEndTimeInput' + this.elem.selector.substr(-1)).val(time); } }); @@ -221,6 +241,7 @@ {foreach name="info.times" item="vo"} addNewAttr({ + miaosha_early_start_time: {$vo['miaosha_early_start_time']}, miaosha_start_time: {$vo['miaosha_start_time']}, miaosha_end_time: {$vo['miaosha_end_time']}, jianlou_start_time: {$vo['jianlou_start_time']}, @@ -228,12 +249,7 @@ }) {/foreach} - addNewAttr({ - miaosha_start_time: 0, - miaosha_end_time: 0, - jianlou_start_time: 0, - jianlou_end_time: 0, - }) + addNewAttr() form.verify({ start_time: function(value, item){ //value:表单的值、item:表单的DOM对象