|
@@ -89,13 +89,22 @@ class Goods extends Common
|
|
|
$this->success('获取成功', $goods);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ //商品详情
|
|
|
public function detail()
|
|
|
{
|
|
|
$user = auth_user();
|
|
|
$id = $this->request->param('id');
|
|
|
$activity_id = $this->request->param('activity_id');
|
|
|
|
|
|
+ //判断一下活动是否还可用
|
|
|
+ $mapa = [
|
|
|
+ 'id' => $activity_id,
|
|
|
+ 'start_time' => ['lt',time()],
|
|
|
+ 'end_time' => ['gt',time()],
|
|
|
+ ];
|
|
|
+ $activity_id = Db::name('shopro_activity')->where($mapa)->where('deletetime',NULL)->find() ? $activity_id : 0;
|
|
|
+
|
|
|
+
|
|
|
// 存一下,获取器获取指定活动的时候会用到
|
|
|
session('goods-activity_id:' . $id, $activity_id);
|
|
|
$service = new GoodsService(function ($goods, $service) use ($activity_id) {
|
|
@@ -140,6 +149,33 @@ class Goods extends Common
|
|
|
$this->success('获取成功', $goods);
|
|
|
}
|
|
|
|
|
|
+ //秒杀列表
|
|
|
+ public function seckill_list(){
|
|
|
+ $list = Db::name('shopro_activity')
|
|
|
+ ->field('id,title,start_time,end_time')
|
|
|
+ ->where('type','seckill')->where('deletetime',NULL)
|
|
|
+ ->where('end_time','>',time())
|
|
|
+ ->order('start_time','asc')
|
|
|
+ ->autopage()->select();
|
|
|
+ foreach($list as $key => $val){
|
|
|
+ $val['current'] = 0;
|
|
|
+ if($key == 0){
|
|
|
+ $val['current'] = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ $val['title'] = '即将开抢';
|
|
|
+ if(time() > $val['start_time']){
|
|
|
+ $val['title'] = date('H',$val['start_time']).'点场';
|
|
|
+ }
|
|
|
+
|
|
|
+ $val['seconds'] = $val['end_time'] - time();
|
|
|
+
|
|
|
+ $list[$key] = $val;
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('获取成功',$list);
|
|
|
+ }
|
|
|
+
|
|
|
//某秒杀的商品列表,带分页
|
|
|
public function seckill_productsku_list(){
|
|
|
$activity_id = $this->request->param('activity_id');
|
|
@@ -163,7 +199,7 @@ class Goods extends Common
|
|
|
->join('shopro_goods g' ,'asp.goods_id = g.id','LEFT')
|
|
|
->join('shopro_goods_sku_price gsp','asp.goods_sku_price_id = gsp.id','LEFT')
|
|
|
->where('asp.status','up')
|
|
|
- ->where('a.deletetime',NULL)
|
|
|
+ ->where('a.deletetime',NULL)->where('a.type','seckill')
|
|
|
->where('g.deletetime',NULL)->whereIn('g.status', ['up', 'hidden'])
|
|
|
->where('gsp.status','up')
|
|
|
->where($map);
|
|
@@ -172,7 +208,7 @@ class Goods extends Common
|
|
|
$list->where('find_in_set(:category_ids,g.category_ids)', ['category_ids' => $category_id]);
|
|
|
}
|
|
|
|
|
|
- $list = $list->autopage()->select(false);echo $list;exit;
|
|
|
+ $list = $list->autopage()->select();
|
|
|
$list = list_domain_image($list,['image','sku_image']);
|
|
|
foreach($list as $key => $val){
|
|
|
//sku图片代替主图
|