Ver Fonte

wesmiler 抢表商城

APPLE há 3 anos atrás
pai
commit
e6dfd0533e

+ 15 - 0
app/Http/Controllers/Api/v1/GoodsController.php

@@ -66,6 +66,21 @@ class GoodsController extends webApp
     }
 
     /**
+     * 审核上架
+     * @return array
+     */
+    public function sellCheck()
+    {
+        $params = request()->all();
+        $goodsId = isset($params['id'])? $params['id'] : 0;
+        if(GoodsService::make()->sellCheck($goodsId)){
+            return message(GoodsService::make()->getError(), true);
+        }else{
+            return message(GoodsService::make()->getError(), false);
+        }
+    }
+
+    /**
      * 积分商品
      * @return array
      */

+ 28 - 0
app/Services/Common/GoodsService.php

@@ -146,6 +146,7 @@ class GoodsService extends BaseService
         if($list){
             foreach($list['data'] as &$item){
                 $item['create_time'] = $item['create_time']? datetime($item['create_time'],'Y-m-d H.i.s') : '';
+                $item['confirm_time'] = $item['confirm_time']? datetime($item['confirm_time'],'Y-m-d H.i.s') : '';
                 $item['thumb'] = isset($item['thumb']) && $item['thumb']? get_image_url($item['thumb']) : '';
             }
         }
@@ -406,4 +407,31 @@ class GoodsService extends BaseService
         $this->error = 1009;
         return false;
     }
+
+    /**
+     * 审核上架
+     * @param $goodsId
+     * @return bool
+     */
+    public function sellCheck($goodsId)
+    {
+        $goods = $this->where(['id'=> $goodsId,'mark'=>1])->first();
+        if(empty($goods)){
+            $this->error = 2061;
+            return false;
+        }
+
+        $data = [
+            'is_sell'=> 2,
+            'update_time'=>time(),
+        ];
+
+        if($this->model->where(['id'=> $goodsId])->update($data)){
+            $this->error = 1018;
+            return true;
+        }
+
+        $this->error = 1019;
+        return false;
+    }
 }