Explorar o código

活动商品详情

whitefang hai 1 ano
pai
achega
acc6b3d8f1
Modificáronse 2 ficheiros con 47 adicións e 0 borrados
  1. 7 0
      app/api/controller/GoodsController.php
  2. 40 0
      app/api/logic/GoodsLogic.php

+ 7 - 0
app/api/controller/GoodsController.php

@@ -41,6 +41,13 @@ class GoodsController extends BaseApiController
         return $this->data($result);
     }
 
+    public function eventGoodsDetail()
+    {
+        $params = (new GoodsValidate())->goCheck('goods');
+        $result = GoodsLogic::eventDetail($params['id']);
+        return $this->data($result);
+    }
+
     public function firmGoodLists()
     {
         return $this->dataLists(new FirmGoodLists());

+ 40 - 0
app/api/logic/GoodsLogic.php

@@ -71,6 +71,46 @@ class GoodsLogic extends BaseLogic
         return $goods;
     }
 
+    public static function eventDetail($id){
+        $goods = Goods::where(['id'=>$id])->visible([
+                'id','goods_image','goods_name','goods_banners','good_unit','sell_num','base_service_fee',
+                'service_total','service_fee','service_image','fee_schedule','warranty_period','goods_payment_type','goods_category_id'
+            ])->select()->toArray();
+
+        if(!empty($goods)){
+            $data = [];
+            foreach ($goods as $key => $value) {
+                if($value['goods_payment_type'] == '2'){
+                    $coupon = ($value['service_total']-$value['service_fee'])>0?'立减'.$value['service_total']-$value['service_fee']:'';
+                }
+                if($value['goods_payment_type'] == '3'){
+                    $coupon = '首付'.$value['service_fee'];
+                }
+                $data[] = [
+                    'id'=>$value['id'],
+                    'goods_image'=>$value['goods_image'],
+                    'goods_name'=>$value['goods_name'],
+                    'good_unit'=>$value['good_unit'],
+                    'goods_banners'=>!empty($value['goods_banners']) ? $value['goods_banners'] : [],
+                    'goods_payment_type'=>$value['goods_payment_type'],
+                    'sell_num'=>$value['sell_num'],
+                    'base_service_fee'=>$value['base_service_fee'],
+                    'service_total'=>$value['service_total'],
+                    'service_fee'=>$value['service_fee'],
+                    'coupon'=>!empty($coupon)?$coupon:'',
+                    'service_image'=>$value['service_image'],
+                    'warranty_period'=>$value['warranty_period'],
+                    'fee_schedule'=>$value['fee_schedule'],
+                    'goods_category_id'=>$value['goods_category_id']
+                ];
+            }
+
+            $goods = $data;
+        }
+
+        return $goods;
+    }
+
     public static function getHotData()
     {
         return Goods::where(['user_id'=>0,'is_hot'=>1])