Browse Source

商品详情,接收砍价活动

lizhen_gitee 4 months ago
parent
commit
a27dbedcdb
1 changed files with 27 additions and 1 deletions
  1. 27 1
      addons/shopro/controller/goods/Goods.php

+ 27 - 1
addons/shopro/controller/goods/Goods.php

@@ -95,6 +95,7 @@ class Goods extends Common
         $user = auth_user();
         $id = $this->request->param('id');
         $activity_id = $this->request->param('activity_id');
+        $goods_sku_price_id = $this->request->param('goods_sku_price_id');
 
         //判断一下活动是否还可用
         $mapa = [
@@ -102,7 +103,32 @@ class Goods extends Common
             'start_time' => ['lt',time()],
             'end_time'   => ['gt',time()],
         ];
-        $activity_id = Db::name('shopro_activity')->where($mapa)->where('deletetime',NULL)->find() ? $activity_id : 0;
+        $activity = Db::name('shopro_activity')->where($mapa)->where('deletetime',NULL)->find();
+        $activity_id = $activity ? $activity_id : 0;
+
+        //砍价活动处理
+        if($activity && $activity['type'] == 'kan'){
+
+            $kan_id = $this->request->param('kan_id',0);
+
+            if($kan_id && $goods_sku_price_id){
+                $map_kan = [
+                    'id'                 => $kan_id,
+                    'user_id'            => $user['id'],
+                    'goods_id'           => $id,
+                    'goods_sku_price_id' => $goods_sku_price_id,
+                    'activity_id'        => $activity_id,
+                    'status'             => ['IN',['ing','finish']],
+                ];
+                $kan = Db::name('shopro_activity_kan')->where($map_kan)->find();
+                if(!$kan){
+                    $activity_id = 0;
+                }
+            }else{
+                $activity_id = 0;
+            }
+
+        }
 
 
         // 存一下,获取器获取指定活动的时候会用到