WIN-2308041133\Administrator 1 semana atrás
pai
commit
5ef1d46697
1 arquivos alterados com 56 adições e 26 exclusões
  1. 56 26
      app/api/controller/Education.php

+ 56 - 26
app/api/controller/Education.php

@@ -219,35 +219,65 @@ class Education
      * @param \app\Request $request
      * @param \app\Request $request
      * @return mixed
      * @return mixed
      */
      */
-    public function getContractTemplatInfo(\think\Request $request)
+//    public function getContractTemplatInfo(\think\Request $request)
+//    {
+//        $post = UtilService::getMore([
+//            ['id', ''],
+//        ], $request);
+//        $where=[];
+//        $where[]=["is_show","=",1];
+//        $where[]=["id","=",$post['id']];
+//        $totalCount = (new ContractTemplateModel)->where($where)->count();
+//        $data=null;
+//        if($totalCount>0){
+//            $data = (new ContractTemplateModel)
+//                ->where($where)
+////                ->order("id", "desc")
+////                ->page($post["page"], $post["pageSize"])
+//                ->find();
+////            $data['id'] = $oData['id'];
+//            if (empty($data)){
+//                return app('json')->fail("模版号不存在");
+//            }
+//            $data['imgs'] = getImageAr($data["imgs"]);
+//
+//            $data['content'] = json_decode($data['content']);
+//            $data['time'] = date("Y-m-d H:i:s", $data["time"]);
+//            $data['admin_time'] = date("Y-m-d H:i:s", $data["admin_time"]);
+//        }
+//        $data = empty($data)?[]:$data;
+//        return app('json')->success($data);
+//    }
+    public function getContractTemplatInfo($id)
     {
     {
-        $post = UtilService::getMore([
-            ['id', ''],
-        ], $request);
-        $where=[];
-        $where[]=["is_show","=",1];
-        $where[]=["id","=",$post['id']];
-        $totalCount = (new ContractTemplateModel)->where($where)->count();
-        $data=null;
-        if($totalCount>0){
-            $data = (new ContractTemplateModel)
-                ->where($where)
-//                ->order("id", "desc")
-//                ->page($post["page"], $post["pageSize"])
-                ->find();
-//            $data['id'] = $oData['id'];
-            if (empty($data)){
-                return app('json')->fail("模版号不存在");
-            }
-            $data['imgs'] = getImageAr($data["imgs"]);
-
-            $data['content'] = json_decode($data['content']);
-            $data['time'] = date("Y-m-d H:i:s", $data["time"]);
-            $data['admin_time'] = date("Y-m-d H:i:s", $data["admin_time"]);
+        $data = (new ContractTemplateModel)
+            ->field("*")
+            ->where("id", $id)
+            ->where("is_show",1)
+            ->find();
+        if (empty($data)) {
+            return app('json')->fail("模板不存在");
         }
         }
-        $data = empty($data)?[]:$data;
+        if ($data["is_init"] == 0 && $data["status"] != 1) {
+            return app('json')->fail("模板已下架");
+        }
+        $data = $data->toArray();
+//        $data["is_use"] = 0;
+        $data["imgs"] = getImageAr($data["imgs"]);
+        $data['content'] = json_decode($data['content']);
+        $data["img"] = empty($data["imgs"]) ? "" : $data["imgs"][0];
+        $data['time'] = date("Y-m-d H:i:s", $data["time"]);
+        $data['admin_time'] = date("Y-m-d H:i:s", $data["admin_time"]);
+//        $data["sales_count"] = $data["real_sales"] + $data["unreal_sales"];
+//        unset($data["real_sales"]);
+        unset($data["code"]);
+        //验证是否购买过并添加浏览记录
+//        $this->checkUser(request()->header("token", ""));
+//        if (!empty($this->user)) {
+//            $data["is_use"] = (new UserShowTemplate)->where("uid", $this->user["uid"])->where("show_template_id", $data["id"])->count() > 0 ? 1 : 0;
+//            (new ShowTemplate)->where('id', $data["id"])->inc('look_count', 1)->update();
+//        }
         return app('json')->success($data);
         return app('json')->success($data);
     }
     }
 
 
-
 }
 }