Browse Source

Merge branch 'master-new-wgg' of wugg/phpstock into master-new

wugg 2 years ago
parent
commit
e709685fa9

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

@@ -99,6 +99,11 @@ class Consult extends Base
         $all_createrid = array_column($list,'createrid');
         $item = get_company_name_by_uid($all_createrid);
 
+		 $userCommon = new \app\admin\common\User();
+		 $tmp = $userCommon->handle('getCodeAndName', ['code' =>array_column($list,"khNo")]);
+        $kh = $tmp['data']??[];
+
+
         $brand = Db::name("brand")
             ->where(['id'=>array_column($list,'brand_id')])
             ->column('brand_name','id');
@@ -106,6 +111,7 @@ class Consult extends Base
         $userCommon = new \app\admin\common\User();
         $names = $userCommon->handle('getCodeAndName', ['code' => array_column($list, 'khNo')]);
 
+
         $data=[];
         foreach ($list as $value){
             $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
@@ -113,9 +119,15 @@ class Consult extends Base
 //            $brand = Db::name("brand")->where(['id'=>$value['brand_id']])->find();
             $value['brand_name']= $brand[$value['brand_id']]??'';//isset($brand['brand_name']) && $brand['brand_name']!='' ? $brand['brand_name']:"";
             $value['khname']="";
-            if ($value['khNo'] !== "") {
+
+            if($value['khNo']!==""){
 //                $kh=Db::name("customer_info")->where(['companyNo'=>$value['khNo']])->find();
-                $value['khname'] = $names['data'][$value['khNo']] ?? '';//isset($kh['companyName'])?$kh['companyName']:"";
+                $value['khname']=$kh[$value['khNo']]??"";
+
+//            if ($value['khNo'] !== "") {
+////                $kh=Db::name("customer_info")->where(['companyNo'=>$value['khNo']])->find();
+//                $value['khname'] = $names['data'][$value['khNo']] ?? '';//isset($kh['companyName'])?$kh['companyName']:"";
+
             }
             $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
             $value['company_name'] = $item[$value['createrid']]??'';
@@ -371,15 +383,24 @@ class Consult extends Base
         $zxinfo['unit_name']="";
         $zxinfo['metal_name']=isset($zxinfo['metal_id'])&& $zxinfo['metal_id']!=0?$this->noble[$zxinfo['metal_id']]:"";
         $zxinfo['specinfo']=json_decode($zxinfo['specinfo'],true);
+//<<<<<<< HEAD
+//		$zxinfo['khname']= '';
+//		$kccode=[];
+//        if($zxorder['khNo']!==""){
+////            $kh=Db::name("customer_info")->where(['companyNo'=>$zxorder['khNo']])->find();
+////            $zxinfo['khname']= isset($kh['companyName'])?$kh['companyName']:"";
+//=======
 
         $userCommon = new \app\admin\common\User();
         $tmp = $userCommon->handle('getCodeAndName', ['code' => [$zxorder['companyNo'],$zxorder['khNo']]]);
 
-        if($zxorder['khNo']!==""){
+//        if($zxorder['khNo']!==""){
 //            $kh=Db::name("customer_info")->where(['companyNo'=>$zxorder['khNo']])->find();
-            $zxinfo['khname']= $tmp['data'][$zxorder['khNo']]??'';//isset($kh['companyName'])?$kh['companyName']:"";
-            $zxinfo['khNo']= $zxorder['khNo'];
-        }
+//            $zxinfo['khname']= $tmp['data'][$zxorder['khNo']]??'';//isset($kh['companyName'])?$kh['companyName']:"";
+//>>>>>>> master-new
+//            $zxinfo['khNo']= $zxorder['khNo'];
+//            $kccode[]=$zxorder['khNo'];
+//        }
         if($zxinfo['unit']!==""){
             $unit=Db::name("unit")->where(['id'=>$zxinfo['unit']])->find();
             $zxinfo['unit_name']= isset($unit['unit'])?$unit['unit']:"";
@@ -388,11 +409,22 @@ class Consult extends Base
             $unit=Db::name("brand")->where(['id'=>$zxinfo['brand_id']])->find();
             $zxinfo['brand']= isset($unit['brand_name'])?$unit['brand_name']:"";
         }
-        if($zxorder['companyNo']!==""){
+//        $zxinfo['company']= '';
+//        if($zxorder['companyNo']!==""){
 //            $kh=Db::name("business")->where(['companyNo'=>$zxorder['companyNo']])->find();
 //            $zxinfo['company']= isset($kh['company'])?$kh['company']:"";
+//<<<<<<< HEAD
+//            $kccode[]=$zxorder['companyNo'];
+//        }
+//        if(!empty($kccode)){
+//            $userCommon = new \app\admin\common\User();
+//            $tmp = $userCommon->handle('getCodeAndName', ['code' =>$kccode]);
+////=======
+////>>>>>>> master-new
             $zxinfo['company'] = $tmp['data'][$zxorder['companyNo']] ?? '';
-        }
+            $zxinfo['khname'] = $tmp['data'][$zxorder['khNo']] ?? '';
+//        }
+
         if($zxorder['is_project']==1 && $zxorder['projectNo']!==""){
             $project = Db::name("project")->where(["projectNo"=>$zxorder['projectNo'],"is_del"=>0])->find();
             $zxinfo['project_name']=isset($project['project_name'])?$project['project_name']:"";
@@ -854,9 +886,12 @@ class Consult extends Base
 //            ->field('id,person,personid')
 //            ->where('code',$supplierNo)
 //            ->findOrEmpty();
-	    $user= new \app\admin\common\User();
-        $supplier =$user->handle("sInfo",["code"=>$supplierNo]);
-
+	    $userCommon= new \app\admin\common\User();
+        $supplier_temp =$userCommon->handle("hqInfo",["code"=>$supplierNo]);
+        if($supplier_temp['code']!=0 || empty($supplier_temp['data']) ) return error_show(1004,"供应商信息未找到");
+		$supplierArr=$supplier_temp['data']??[];
+		$supplier=$supplierArr['child']??[];
+		if($supplierArr['relation_code']==$zx['companyNo']) return error_show(1004,"业务公司与供应商信息一致");
         $data=[
             "bidNo"=>$bidNo,
             "infoNo"=>$infoNo,
@@ -1183,6 +1218,12 @@ class Consult extends Base
                     $mark_fee + $cert_fee + $nake_fee) / (1 - $budget);
             $total_fee = $demo_fee/$zxinfo['num']+$delivery_fee+$open_fee/$zxinfo['num'] + $cost_fee * $noble_weight + $pakge_fee + $mark_fee+$cert_fee +$nake_fee;
         }
+        $userCommon= new \app\admin\common\User();
+        $supplier_temp =$userCommon->handle("hqInfo",["code"=>$supplierNo]);
+        if($supplier_temp['code']!=0 || empty($supplier_temp['data']) ) return error_show(1004,"供应商信息未找到");
+		$supplierArr=$supplier_temp['data']??[];
+		$supplier=$supplierArr['child']??[];
+		if($supplierArr['relation_code']==$zx['companyNo']) return error_show(1004,"业务公司与供应商信息一致");
         Db::startTrans();
         try{
             $data=[

+ 10 - 5
app/admin/controller/Exclusive.php

@@ -61,14 +61,14 @@ class Exclusive extends Base
         if($name==""){
             return error_show(1004,"参数name不能为空");
         }
-        $rename = Db::name('exclusive')->where(['is_del' => 0, 'name' => $name])->find();
-        if (!empty($rename)) {
-            return error_show(1002, "专属类型名称已存在");
-        }
         $pid =isset($this->post['pid'])&&$this->post['pid']!=="" ? intval($this->post['pid']):0;
         if($pid===""){
             return error_show(1002,"父级id不能为空");
         }
+        $rename = Db::name('exclusive')->where(["pid"=>$pid,'is_del' => 0, 'name' => $name])->find();
+        if (!empty($rename)) {
+            return error_show(1002, "专属类型名称已存在");
+        }
         $level=1;
         $search = $name;
         if($pid!==0){
@@ -328,8 +328,13 @@ class Exclusive extends Base
             return error_show(1004,"参数name不能为空");
         }
         $pid =isset($this->post['pid'])&&$this->post['pid']!=="" ? intval($this->post['pid']):0;
-        if($pid==""){
+        if($pid===""){
             return error_show(1004,"参数pid不能为空");
+        }
+         $rename = Db::name('exclusive')->where(["pid"=>$pid,'is_del' => 0, 'name' => $name])->where("id","<>",$id)
+         ->findOrEmpty();
+        if (!empty($rename)) {
+            return error_show(1002, "专属类型名称已存在");
         }
         $level=1;
         $search = $name;

+ 10 - 8
app/admin/controller/Good.php

@@ -64,10 +64,10 @@ class Good extends Base
         if($supplierNo!==""){
             $where[]=['a.supplierNo',"like","%$supplierNo%"];
         }
-         $supplier_name = isset($this->post['supplier_name']) && $this->post['supplier_name'] !=="" ? trim($this->post['supplier_name']):"";
-        if($supplier_name!==""){
-            $where[]=['s.name',"like","%$supplier_name%"];
-        }
+//         $supplier_name = isset($this->post['supplier_name']) && $this->post['supplier_name'] !=="" ? trim($this->post['supplier_name']):"";
+//        if($supplier_name!==""){
+//            $where[]=['s.name',"like","%$supplier_name%"];
+//        }
         $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !=="" ? trim($this->post['companyNo']) :"";
         if($companyNo!==""){
             $where[]=['a.companyNo',"like","%$companyNo%"];
@@ -130,7 +130,7 @@ class Good extends Base
         $count = Db::name('good')
             ->alias("a")
             ->leftJoin("good_platform b","a.spuCode=b.spuCode")
-            ->leftJoin("supplier s","a.supplierNo=s.code")
+//            ->leftJoin("supplier s","a.supplierNo=s.code")
             ->leftJoin("depart_user u", "u.uid=b.createrid AND u.is_del=0")
             ->leftJoin("platform p","p.id=b.platform_code")
             ->where('p.platform_type',0)//只筛选非对接平台的商品
@@ -140,10 +140,10 @@ class Good extends Base
         $page = $page >= $total ? $total : $page;
         $list = Db::name('good')
             ->alias("a")
-            ->field("b.skuCode,b.platform_code,b.plat_code,b.id as good_id,a.cat_id,a.good_name,a.good_img,a.good_info_img,a.good_thumb_img,b.createrid,a.is_exclusive,a.brand_id,a.supplierNo,a.good_unit,a.noble_metal,a.companyNo,a.spuCode,a.good_type,b.creater,b.addtime,b.updatetime,b.exam_status,a.createrid purchase_id,a.creater purchase,a.is_stock,s.name as supplier_name")
+            ->field("b.skuCode,b.platform_code,b.plat_code,b.id as good_id,a.cat_id,a.good_name,a.good_img,a.good_info_img,a.good_thumb_img,b.createrid,a.is_exclusive,a.brand_id,a.supplierNo,a.good_unit,a.noble_metal,a.companyNo,a.spuCode,a.good_type,b.creater,b.addtime,b.updatetime,b.exam_status,a.createrid purchase_id,a.creater purchase,a.is_stock")
             //成本表里的创建人,也是线上商品的采购人,为了防止混淆,给creater取个别名
             ->leftJoin("good_platform b","a.spuCode=b.spuCode")
-            ->leftJoin("supplier s","a.supplierNo=s.code")
+//            ->leftJoin("supplier s","a.supplierNo=s.code")
 //            ->leftJoin("good_basic gb","gb.spuCode=a.spuCode")
             ->leftJoin("platform p","p.id=b.platform_code")
             ->where('p.platform_type',0)//只筛选非对接平台的商品
@@ -165,7 +165,8 @@ class Good extends Base
             ->column('unit','id');
 
         $userCommon = new \app\admin\common\User();
-        $names = $userCommon->handle('getCodeAndName',['code'=>array_column($list,'companyNo')]);
+        $names = $userCommon->handle('getCodeAndName',['code'=>array_merge(array_column($list,'companyNo'),
+        array_column($list,'supplierNo'))]);
 
         $data=[];
         foreach ($list as $value){
@@ -181,6 +182,7 @@ class Good extends Base
             $value['unit'] =$unit[$value['good_unit']]??'';//isset($unit['unit'])?$unit['unit']:"";
 //            $company = Db::name("business")->where(["companyNo"=>$value['companyNo']])->find();
             $value['company'] = $names['data'][$value['companyNo']]??'';//isset($company['company'])?$company['company']:"";
+            $value['supplierName'] = $names['data'][$value['supplierNo']]??'';//isset($company['company'])//?$company['company']:"";
             $value['stock_total'] = Db::name("good_stock")->where(['spuCode'=>$value['spuCode'],"is_del"=>0])->sum("usable_stock");
             $value['status']=$value['exam_status'];
             $value['exclusive']=makeExcluse($value['is_exclusive']);

+ 18 - 6
app/admin/controller/Goodup.php

@@ -291,9 +291,10 @@ class Goodup extends Base
             return error_show(1004,"参数supplierNo不能为空");
         }
         $userCommon= new \app\admin\common\User();
-        $supplier_temp =$userCommon->handle("sInfo",["code"=>$supplierNo]);
+        $supplier_temp =$userCommon->handle("hqInfo",["code"=>$supplierNo]);
         if($supplier_temp['code']!=0 || empty($supplier_temp['data']) ) return error_show(1004,"供应商信息未找到");
-		$supplier=$supplier_temp['data']??[];
+		$supplierArr=$supplier_temp['data']??[];
+		$supplier=$supplierArr['child']??[];
 //        $supplier =Db::name("supplier")->where(["code"=>$supplierNo])->findOrEmpty();
 //        if(empty($supplier)) return error_show(1004,"供应商信息未找到");
         $good_size = isset($this->post['good_size'])&&$this->post['good_size']!=""? trim($this->post['good_size']):"";
@@ -304,6 +305,9 @@ class Goodup extends Base
         if($company_id==''){
             return error_show(1004,"参数company_id不能为空");
         }
+        if($supplierArr['relation_code']==$company_id){
+        	 return error_show(1004,"业务公司与供应商属于同一家公司");
+        }
         $is_auth = isset($this->post['is_auth'])&&$this->post['is_auth']!==""? intval($this->post['is_auth']):"";
         if($is_auth===''){
             return error_show(1004,"参数is_auth不能为空");
@@ -661,9 +665,10 @@ class Goodup extends Base
             return error_show(1004,"参数supplierNo不能为空");
         }
         $userCommon= new \app\admin\common\User();
-        $supplier_temp =$userCommon->handle("sInfo",["code"=>$supplierNo]);
+		$supplier_temp =$userCommon->handle("hqInfo",["code"=>$supplierNo]);
         if($supplier_temp['code']!=0 || empty($supplier_temp['data']) ) return error_show(1004,"供应商信息未找到");
-		$supplier=$supplier_temp['data']??[];
+		$supplierArr=$supplier_temp['data']??[];
+		$supplier=$supplierArr['child']??[];
         $good_size = isset($this->post['good_size'])&&$this->post['good_size']!=""? trim($this->post['good_size']) :"";
         if($good_size==''){
             return error_show(1004,"参数good_size不能为空");
@@ -672,6 +677,9 @@ class Goodup extends Base
         if($company_id==''){
             return error_show(1004,"参数company_id不能为空");
         }
+        if($supplierArr['relation_code']==$company_id){
+        	 return error_show(1004,"业务公司与供应商属于同一家公司");
+        }
         $is_auth = isset($this->post['is_auth'])&&$this->post['is_auth']!==""? intval($this->post['is_auth']):"";
         if($is_auth===''){
             return error_show(1004,"参数is_auth不能为空");
@@ -2100,9 +2108,10 @@ class Goodup extends Base
             return error_show(1004,"参数supplierNo不能为空");
         }
         $userCommon= new \app\admin\common\User();
-        $supplier_temp =$userCommon->handle("sInfo",["code"=>$supplierNo]);
+        $supplier_temp =$userCommon->handle("hqInfo",["code"=>$supplierNo]);
         if($supplier_temp['code']!=0 || empty($supplier_temp['data']) ) return error_show(1004,"供应商信息未找到");
-		$supplier=$supplier_temp['data']??[];
+		$supplierArr=$supplier_temp['data']??[];
+		$supplier=$supplierArr['child']??[];
         $good_size = isset($this->post['good_size'])&&$this->post['good_size']!=""? trim($this->post['good_size']) :"";
         if($good_size==''){
             return error_show(1004,"参数good_size不能为空");
@@ -2111,6 +2120,9 @@ class Goodup extends Base
         if($company_id==''){
             return error_show(1004,"参数companyNo不能为空");
         }
+        if($supplierArr['relation_code']==$company_id){
+        	 return error_show(1004,"业务公司与供应商属于同一家公司");
+        }
         $is_auth = isset($this->post['is_auth'])&&$this->post['is_auth']!==""? intval($this->post['is_auth']):"";
         if($is_auth===''){
             return error_show(1004,"参数is_auth不能为空");

+ 17 - 16
app/admin/controller/Keepbrand.php

@@ -61,14 +61,15 @@ class Keepbrand extends Base
                 "updatetime"=>date("Y-m-d H:i:s")
             ];
         if($long===1){
-            $starttime = isset($this->post['starttime']) && $this->post['starttime'] !=="" ?$this->post['starttime']:"";
-            if($starttime==""){
-                return error_show(1005,'参数starttime不能为空');
-            }
-            $endtime= isset($this->post['endtime']) && $this->post['endtime'] !=="" ?$this->post['endtime']:"";
-            if($endtime==""){
-                return error_show(1005,'修改时间不能为空');
-            }
+            $starttime = isset($this->post['starttime']) && $this->post['starttime'] !==""
+            ?$this->post['starttime']:null;
+//            if($starttime==""){
+//                return error_show(1005,'参数starttime不能为空');
+//            }
+            $endtime= isset($this->post['endtime']) && $this->post['endtime'] !=="" ?$this->post['endtime']:null;
+//            if($endtime==""){
+//                return error_show(1005,'修改时间不能为空');
+//            }
             $data['starttime']=$starttime;
             $data['endtime']=$endtime;
         }
@@ -210,14 +211,14 @@ class Keepbrand extends Base
             "updatetime"=>date("Y-m-d H:i:s")
         ];
         if($long===1){
-            $starttime = isset($this->post['starttime']) && $this->post['starttime'] !=="" ?$this->post['starttime']:"";
-            if($starttime==""){
-                return error_show(1005,'参数starttime不能为空');
-            }
-            $endtime= isset($this->post['endtime']) && $this->post['endtime'] !=="" ?$this->post['endtime']:"";
-            if($endtime==""){
-                return error_show(1005,'修改时间不能为空');
-            }
+            $starttime = isset($this->post['starttime']) && $this->post['starttime'] !=="" ?$this->post['starttime']:null;
+//            if($starttime==""){
+//                return error_show(1005,'参数starttime不能为空');
+//            }
+            $endtime= isset($this->post['endtime']) && $this->post['endtime'] !=="" ?$this->post['endtime']:null;
+//            if($endtime==""){
+//                return error_show(1005,'修改时间不能为空');
+//            }
             $data['starttime']=$starttime;
             $data['endtime']=$endtime;
         }

+ 9 - 0
app/admin/controller/Sale.php

@@ -1683,6 +1683,15 @@ class Sale extends Base
             if ($sa == false) {
                 return false;
             }
+
+
+            $goodinfo['status'] = 5;
+            $goodinfo['updatetime'] = date("Y-m-d H:i:s");
+            $saa = Db::name("consult_info")->where(["infoNo"=>$goodinfo['infoNo']])->update(["status"=>5,
+            "updatetime"=>date("Y-m-d H:i:s")]);
+            if ($saa == false) {
+                return false;
+            }
             //修改状态,添加待办
             ActionLog::logAdd($this->post['token'], [
                 "order_code" => $goodinfo['bidNo'],//项目编码