wugg 3 years ago
parent
commit
72b202d7dd
5 changed files with 274 additions and 54 deletions
  1. 185 52
      app/admin/controller/Consult.php
  2. 2 1
      app/admin/controller/Goodup.php
  3. 16 0
      app/admin/route/app.php
  4. 69 0
      app/common.php
  5. 2 1
      composer.json

+ 185 - 52
app/admin/controller/Consult.php

@@ -13,66 +13,124 @@ class Consult extends BaseController
     {
         parent::__construct($app);
         $this->post=$this->request->post();
-        $token = isset($this->post['token']) ? trim($this->post['token']) : "";
-        if($token==""){
-            return error_show(101,'token不能为空');
-        }
-        $effetc = VerifyTokens($token);
-        if(!empty($effetc) && $effetc['code']!=0) {
-            return error_show($effetc['code'], $effetc['message']);
-        }
+//        $token = isset($this->post['token']) ? trim($this->post['token']) : "";
+//        if($token==""){
+//            return error_show(101,'token不能为空');
+//        }
+//        $effetc = VerifyTokens($token);
+//        if(!empty($effetc) && $effetc['code']!=0) {
+//            return error_show($effetc['code'], $effetc['message']);
+//        }
     }
-    public function list(){
-      $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
-      $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
-      $where=[['is_del',"=",0],["cat_id","<>",0]];
-      $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
-      if ($zxNo !== "") {
-          $where[] = ['zxNo','=',$zxNo];
-      }
-      $sequenceNo = isset($this->post['sequenceNo']) && $this->post['sequenceNo'] !== "" ? trim($this->post['sequenceNo']) : "";
-      if ($sequenceNo !== "") {
-            $where[] = ['sequenceNo','like',"%$sequenceNo%"];
-        }
-      $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
-      if ($salesman !== "") {
-          //$where["salesman"] =Db::Raw("like '%$salesman%'");
-          $where[]= ["salesman",'like',"%$salesman%"];
+//    public function list(){
+//      $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
+//      $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
+//      $where=[['is_del',"=",0],["cat_id","<>",0]];
+//      $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
+//      if ($zxNo !== "") {
+//          $where[] = ['zxNo','=',$zxNo];
+//      }
+//      $sequenceNo = isset($this->post['sequenceNo']) && $this->post['sequenceNo'] !== "" ? trim($this->post['sequenceNo']) : "";
+//      if ($sequenceNo !== "") {
+//            $where[] = ['sequenceNo','like',"%$sequenceNo%"];
+//        }
+//      $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
+//      if ($salesman !== "") {
+//          //$where["salesman"] =Db::Raw("like '%$salesman%'");
+//          $where[]= ["salesman",'like',"%$salesman%"];
+//        }
+//        $cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : "";
+//        if ($cpName !== "") {
+//            //$where["cpName"]= Db::Raw("like '%$cpName%'");
+//            $where[]= ["cpName",'like',"%$cpName%"];
+//        }
+//      $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
+//      if ($khNo !== "") {
+//         // $where['khNo'] = $khNo;
+//          $where[]= ["khNo",'like',"%$khNo%"];
+//        }
+//        $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
+//        if ($start !="") {
+//            //$where = ["zxtime"=>Db::raw(">= '{$start}'")];
+//            $where[]= ["zxtime",'>=',$start];
+//        }
+//        $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
+//        if($end !=""){
+//            $where[]= ["zxtime",'<=',$end];
+//        }
+//      $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
+//      if ($status !== "") {
+//          $where[]= ["status",'=',$status];
+//        }
+//        $count = Db::name('consult')->where($where)->count();
+//        $total = ceil($count / $size);
+//        $page = $page >= $total ? $total : $page;
+//      $list = Db::name('consult')->where($where)->page($page,$size)
+//          ->select();
+//     $data=[];
+//      foreach ($list as $value){
+//          $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
+//          $data[]=$value;
+//      }
+//      return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
+//    }
+    public function conlist(){
+        $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
+        $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
+        $where=[['a.is_del',"=",0],['b.is_del',"=",0]];
+        $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
+        if ($zxNo !== "") {
+            $where[] = ['a.zxNo','=',$zxNo];
+        }
+//        $sequenceNo = isset($this->post['sequenceNo']) && $this->post['sequenceNo'] !== "" ? trim($this->post['sequenceNo']) : "";
+//        if ($sequenceNo !== "") {
+//            $where[] = ['sequenceNo','like',"%$sequenceNo%"];
+//        }
+        $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
+        if ($salesman !== "") {
+            //$where["salesman"] =Db::Raw("like '%$salesman%'");
+            $where[]= ["b.salesman",'like',"%$salesman%"];
         }
         $cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : "";
         if ($cpName !== "") {
             //$where["cpName"]= Db::Raw("like '%$cpName%'");
-            $where[]= ["cpName",'like',"%$cpName%"];
+            $where[]= ["a.good_Name",'like',"%$cpName%"];
         }
-      $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
-      if ($khNo !== "") {
-         // $where['khNo'] = $khNo;
-          $where[]= ["khNo",'like',"%$khNo%"];
+        $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
+        if ($khNo !== "") {
+            // $where['khNo'] = $khNo;
+            $where[]= ["b.khNo",'like',"%$khNo%"];
         }
         $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
         if ($start !="") {
             //$where = ["zxtime"=>Db::raw(">= '{$start}'")];
-            $where[]= ["zxtime",'>=',$start];
+            $where[]= ["a.addtime",'>=',$start];
         }
         $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
         if($end !=""){
-            $where[]= ["zxtime",'<=',$end];
+            $where[]= ["a.addtime",'<=',$end];
         }
-      $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
-      if ($status !== "") {
-          $where[]= ["status",'=',$status];
+        $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
+        if ($status !== "") {
+            $where[]= ["a.status",'=',$status];
         }
-        $count = Db::name('consult')->where($where)->count();
+        $count = Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)
+            ->count();
         $total = ceil($count / $size);
         $page = $page >= $total ? $total : $page;
-      $list = Db::name('consult')->where($where)->page($page,$size)
-          ->select();
-     $data=[];
-      foreach ($list as $value){
-          $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
-          $data[]=$value;
-      }
-      return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
+        $list =Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)->page($page,$size)
+            ->field("a.*,b.createrid,b.creater,b.is_project,b.projectNo,b.khNo,b.endtime,b.platform_code,b.saleid,b.salesman,b.depart")->select();
+        $data=[];
+        foreach ($list as $value){
+            $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
+            $value['khname']="";
+            if($value['khNo']!==""){
+                $kh=Db::name("customer_info")->where(['companyNo'=>$value['khNo']])->find();
+                $value['khname']= isset($kh['companyName'])?$kh['companyName']:"";
+            }
+            $data[]=$value;
+        }
+        return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
     }
     public function info(){
         $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) : "";
@@ -92,7 +150,7 @@ class Consult extends BaseController
         $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) : "";
         $de = Db::name('consult')->where(['id'=>$id,'is_del'=>0])->find();
         if($de==false){
-            return error_show(1002,'咨询单编号未找到');
+            return error_show(1002,'咨询单信息未找到');
         }
         $dell= Db::name('consult')->update(['id'=>$id,'is_del'=>1,'updatetime'=>date("Y-m-d H:i:s")]);
         if($dell){
@@ -239,12 +297,12 @@ class Consult extends BaseController
             if($gold_price===""){
                 return error_show(1004,"参数gold_price不能为空");
             }
-            $budget_price = isset($this->post['budget_price'])&&$this->post['budget_price']!==""?floatval($this->post['budget_price']):"";
-            if($budget_price===""){
-                return error_show(1004,"参数budget_price不能为空");
-            }
-        }
 
+        }
+        $budget_price = isset($this->post['budget_price'])&&$this->post['budget_price']!==""?floatval($this->post['budget_price']):"";
+        if($budget_price===""){
+            return error_show(1004,"参数budget_price不能为空");
+        }
         $num = isset($this->post['num'])&&$this->post['num']!==""?intval($this->post['num']):"";
         if($num===""){
             return error_show(1004,"参数num不能为空");
@@ -314,10 +372,11 @@ class Consult extends BaseController
         if($zxinfo==false){
             return error_show(1004,"未找到信息数据");
         }
-        $zxorder = Db::name("consilt_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
+        $zxorder = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
         if($zxorder==false){
             return error_show(1004,"未找到咨询信息数据");
         }
+        $zxinfo['can']= isset($zxinfo['cat_id']) && $zxinfo['cat_id'] !=0 ? made($zxinfo['cat_id'],[]):[];
         $zxorder['khname']="";
         if($zxorder['khNo']!==""){
             $kh=Db::name("customer_info")->where(['companyNo'=>$zxorder['khNo']])->find();
@@ -459,6 +518,7 @@ class Consult extends BaseController
             "createrid"=>$createrid,
             "creater"=>$creater,
             "status"=>0,
+            "is_del"=>0,
             "addtime"=>date("Y-m-d H:i:s"),
             "updatetime"=>date("Y-m-d H:i:s")
         ];
@@ -512,11 +572,11 @@ class Consult extends BaseController
        if($bidNo==""){
            return error_show(1004,"参数bidNo不能为空");
        }
-       $info =Db::name("good_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
+       $info =Db::name("consult_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
        if($info==false){
            return error_show(1004,"未找到商品数据");
        }
-        $unit =Db::name("unit")->where(["id"=>$info['good_unit']])->find();
+        $unit =Db::name("unit")->where(["id"=>$info['unit_id']])->find();
         $info['unit'] = isset($unit['unit'])?$unit['unit']:'';
         $info['cat_info'] = made($info['cat_id'],[]);
         $supplier = Db::name("supplier")->where(["code"=>$info['supplierNo']])->find();
@@ -530,7 +590,80 @@ class Consult extends BaseController
             $info["brand_name"]="";
             $info["brand_id"]="";
         }
+        return app_show(0,"获取成功",$info);
+    }
+    public function bargain_add(){
+        $bidNo = isset($this->post['bidNo'])&& $this->post['bidNo']!=""?trim($this->post['bidNo']):"";
+        if($bidNo===""){
+            return error_show(1004,"参数bidNo不能为空");
+        }
+        $info =Db::name("good_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
+        if($info==false){
+            return error_show(1004,"未找到商品数据");
+        }
+        $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
+        if($token==''){
+            return error_show(1005,"参数token不能为空");
+        }
+        $user =GetUserInfo($token);
+        if(empty($user)||$user['code']!=0){
+            return error_show(1002,"用户数据不存在");
+        }
 
+        $type = isset($this->post['type'])&& $this->post['type']!=""?intval($this->post['type']):"";
+        if($type===""){
+            return error_show(1004,"参数type不能为空");
+        }
+        $status = isset($this->post['status'])&& $this->post['status']!==""?intval($this->post['status']):"";
+        if($status===""){
+            return error_show(1004,"参数status不能为空");
+        }
+        $createrid= isset($user["data"]['id']) ?  $user["data"]['id'] : "";
+        $creater= isset($user["data"]['nickname']) ?  $user["data"]['nickname'] : "";
+        $bargainNo =makeNo("BAR");
+        Db::startTrans();
+        try{
+            $data=[
+                "bidsNo"=>$bidNo,
+                "bargainNo"=>$bargainNo,
+                "bargain_type"=>$type,
+                "sale_price"=>$info['sale_price'],
+                "cost_before_price"=>$info['cost_fee'],
+                "cost_after_price"=>$info['cost_fee'],
+                "before_rate"=>$info['cost_fee'],
+                "after_rate"=>$info['cost_fee'],
+                "after_price"=>$info['cost_fee'],
+                "status"=>$status,
+                "is_del"=>0,
+                "creater"=>$creater,
+                "createrid"=>$createrid,
+                "addtime"=>date("Y-m-d H:i:s"),
+                "updatetime"=>date("Y-m-d H:i:s")
+            ];
+            $int = Db::name("bargain_order")->insert($data);
+            if($int){
+                if($type===1){
+                    $info['status']=3;
+                    $info['updatetime']=date("Y-m-d H:i:s");
+                }
+                if($type===2){
+                    $info['status']=4;
+                    $status==1?$info['sale_price']=$data['after_price']:"";
+                    $info['updatetime']=date("Y-m-d H:i:s");
+                }
 
+                $up =Db::name("good_bids")->save($info);
+                if($up){
+                    Db::commit();
+                    return  app_show(0,"审核成功");
+                }else{
+                    Db::rollback();
+                    return error_show(1004,"审核失败");
+                }
+            }
+        }catch (\Exception $e){
+            Db::rollback();
+            return error_show(1004,$e->getMessage());
+        }
     }
 }

+ 2 - 1
app/admin/controller/Goodup.php

@@ -839,13 +839,14 @@ class Goodup extends BaseController
         $creater= isset($user["data"]['nickname']) ?  $user["data"]['nickname'] : "";
         $data=[];
         foreach ($spuCode as $value){
+            $count = Db::name("good_nake")->where(["spuCode"=>$value,"is_del"=>0])->count();
             $data[]=[
                 "spuCode"=>$value,
                 "skuCode"=>makeNo("SKU"),
                 "platform_code"=>$platform,
                 "online_reason"=>$online_reason,
                 "online_remark"=>$online_remark,
-                "exam_status"=>0,
+                "exam_status"=>$count>0 ?3:2,
                 "is_online"=>0,
                 "status"=>1,
                 "is_del"=>0,

+ 16 - 0
app/admin/route/app.php

@@ -377,3 +377,19 @@ Route::rule('titleedit','admin/Title/edit');
 Route::rule('titleinfo','admin/Title/info');
 Route::rule('titledelete','admin/Title/del');
 Route::rule('titlestatus','admin/Title/status');
+
+Route::rule('ocrquery','admin/Ocrlicense/query');
+
+
+//Route::rule('consultlist','admin/Consult/conlist');
+Route::rule('consultlists','admin/Consult/conlist');
+Route::rule('consultinfo','admin/Consult/info');
+Route::rule('consultdel','admin/Consult/del');
+Route::rule('consultcreate','admin/Consult/create');
+Route::rule('consultzxadd','admin/Consult/zxadd');
+Route::rule('consultzxinfo','admin/Consult/zxinfo');
+Route::rule('consultbar','admin/Consult/bargain');
+Route::rule('consultfeed','admin/Consult/feadback');
+Route::rule('consultfeadinfo','admin/Consult/feadinfo');
+Route::rule('consultbaradd','admin/Consult/bargain_add');
+

+ 69 - 0
app/common.php

@@ -539,4 +539,73 @@ function GetAddr($AddrJson=""){
     }
     return $addr;
 }
+/**
+ * POST 请求
+ * @param string $url
+ * @param array $param
+ * @param boolean $post_file 是否文件上传
+ * @return string content
+ */
+function post($url,$data,$header=[])
+{
+    //对空格进行转义
+    $url = str_replace(' ','+',$url);
+    $ch = curl_init();
+
+    //设置选项,包括URL
+    curl_setopt($ch, CURLOPT_URL, "$url");
+    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+    curl_setopt($ch, CURLOPT_HEADER, 0);
+    curl_setopt($ch,CURLOPT_TIMEOUT,3);  //定义超时3秒钟
+    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+    // POST数据
+    //  curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
+    curl_setopt($ch, CURLOPT_POST, 1);
+    // 把post的变量加上
+    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);    //所需传的数组用http_bulid_query()函数处理一下,就ok了
+    curl_setopt($ch, CURLOPT_HEADER, true);
+    //执行并获取url地址的内容
+    $output = curl_exec($ch);
+    $errorCode = curl_errno($ch);
+    //释放curl句柄
+    $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
+
+// 根据头大小去获取头信息内容
+
+    $header = substr($output, 0, $headerSize);
+
+
+    curl_close($ch);
+    if(0 !== $errorCode) {
+        return false;
+    }
+    return $header;
+}
+
+function post2($url,$data,$header=[])
+{
+    //对空格进行转义
+    $url = str_replace(' ','+',$url);
+    $ch = curl_init();
+    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
+    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+
+    //设置选项,包括URL
+    curl_setopt($ch, CURLOPT_URL, "$url");
+    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+    curl_setopt($ch, CURLOPT_HEADER, 0);
+    // POST数据
+    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
+    curl_setopt($ch, CURLOPT_POST, 1);
+    // 把post的变量加上
+    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);    //所需传的数组用http_bulid_query()函数处理一下,就ok了
+    $output = curl_exec($ch);
+    $errorCode = curl_errno($ch);
+    curl_close($ch);
+    if(0 !== $errorCode) {
+        return false;
+    }
+    return $output;
+}
+
 

+ 2 - 1
composer.json

@@ -24,7 +24,8 @@
         "topthink/framework": "^6.0.0",
         "topthink/think-orm": "^2.0",
         "topthink/think-multi-app": "^1.0",
-        "phpoffice/phpexcel": "^1.8"
+        "phpoffice/phpexcel": "^1.8",
+        "huaweicloud/huaweicloud-sdk-php": "3.0.3-beta"
     },
     "require-dev": {
         "symfony/var-dumper": "^4.2",