Browse Source

Merge branch 'master-new-dev-wf' of wugg/phpstock into master-new

wufeng 2 years ago
parent
commit
24c412edad

+ 92 - 71
app/admin/controller/After.php

@@ -370,74 +370,96 @@ class After extends Base
 
         return app_show(0,"获取成功",$info);
     }
+
+    //售后申请单 审核
     public function status(){
-        $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
-        if($bkcode==""){
-            return error_show(1005,"参数returnCode 不能为空");
-        }
-        $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
-        if(empty($info)){
-            return error_show(1005,"未找到售后数据");
-        }
-        $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']) :"";
-        if($status===""){
-            return error_show(1005,"参数status 不能为空");
-        }
-        $orde= Db::name("order_out")->where(["outCode"=>$info['outCode'],"is_del"=>0])->find();
-        if($orde==false){
-            return error_show(1005,"未找到出库单数据");
-        }
-        $sale = Db::name("sale")->where(["orderCode"=> $info['orderCode']])->find();
-        if($sale==false){
-            return error_show(1005,"未找到销售单数据");
-        }
-      $remark = isset($this->post['remark'])&&$this->post['remark']!=''?trim($this->post['remark']):"";
-        if($remark!=''){
-            $info['remark'] =$remark;
-        }
-        if($status==3 && $info['is_receive']==1){
-            $post =isset($this->post['is_post'])&&$this->post['is_post']!==""? intval($this->post['is_post']):"";
-            if($post===""){
-                return error_show(1005,"参数is_post不能为空");
-            }
-            $info['is_post']=$post;
-            $return_tag =isset($this->post['return_tag'])&&$this->post['return_tag']!==""? intval($this->post['return_tag']):"";
-            if($return_tag===""){
-                return error_show(1005,"参数return_tag不能为空");
-            }
-            $info['return_tag']=$return_tag;
-            $is_th =isset($this->post['is_th'])&&$this->post['is_th']!==""? intval($this->post['is_th']):"0";
-            $info['is_th']=$is_th;
-        }
-//        $status = $info['order_status']==1&&$info['order_type']==1 && $status==1?4:$status;
+
+        $param = $this->request->only(['returnCode','status','remark'=>''],'post','trim');
+
+        $val = Validate::rule([
+            'returnCode'=>'require',
+            'status'=>'require|number|in:1,2,4,5,6,9,10',
+        ]);
+
+        if($val->check($param) == false) return json_show(1004,$val->getError());
+
+//        $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
+//        if($bkcode==""){
+//            return error_show(1005,"参数returnCode 不能为空");
+//        }
+        $info = Db::name("order_return")
+            ->where(['is_del'=>0,'returnCode'=>$param['returnCode']])
+            ->findOrEmpty();
+        if(empty($info)) return json_show(1005,"未找到售后数据");
+        if($info['status'] == 5) return json_show(1005,'售后已完成,无法操作');
+        if($info['status'] == 8) return json_show(1005,'申请已取消,无法操作');
+
+
+//        $param['status'] = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']) :"";
+//        if($param['status']===""){
+//            return error_show(1005,"参数status 不能为空");
+//        }
+        $orde= Db::name("order_out")
+            ->field('id,outCode,status')
+            ->where(["outCode"=>$info['outCode'],"is_del"=>0])
+            ->findOrEmpty();
+        if(empty($orde)) return json_show(1005,"未找到出库单数据");
+
+        $sale = Db::name("sale")
+            ->field('id,th_num,th_fee,sale_price,good_code,good_name,cat_id')
+            ->where(['is_del'=>0,"orderCode"=> $info['orderCode']])
+            ->findOrEmpty();
+        if(empty($sale)) return json_show(1005,"未找到销售单数据");
+
+//      $remark = isset($this->post['remark'])&&$this->post['remark']!=''?trim($this->post['remark']):"";
+        if($param['remark']!='')  $info['remark'] =$param['remark'];
+
+//        if($param['status']==3 && $info['is_receive']==1){
+//            $post =isset($this->post['is_post'])&&$this->post['is_post']!==""? intval($this->post['is_post']):"";
+//            if($post===""){
+//                return error_show(1005,"参数is_post不能为空");
+//            }
+//            $info['is_post']=$post;
+//            $return_tag =isset($this->post['return_tag'])&&$this->post['return_tag']!==""? intval($this->post['return_tag']):"";
+//            if($return_tag===""){
+//                return error_show(1005,"参数return_tag不能为空");
+//            }
+//            $info['return_tag']=$return_tag;
+//            $is_th =isset($this->post['is_th'])&&$this->post['is_th']!==""? intval($this->post['is_th']):"0";
+//            $info['is_th']=$is_th;
+//        }
+//        $param['status'] = $info['order_status']==1&&$info['order_type']==1 && $param['status']==1?4:$param['status'];
         Db::startTrans();
         try{
+
+            $date = date('Y-m-d H:i:s');
+            $action_log_user = ['id'=>$this->uid,'nickname'=>$this->uname];
+
             $var=$info['status'];
-            $info['status']=$status;
-            $info['updatetime']=date("Y-m-d H:i:s");
+            $info['status']=$param['status'];
+            $info['updatetime']=$date;
             $up =Db::name("order_return")->save($info);
             if($up){
-                if($status==5 && $info['is_receive']==0){
+
+                //售后完成
+                if($param['status']==5 && $info['is_receive']==0){
                     $od_status = $orde['status'];
                     $orde['status']=4;
-                    $orde['updatetime']=date("Y-m-d H:i:s");
+                    $orde['updatetime']=$date;
                     $out = Db::name("order_out")->save($orde);
-                    if($out==false){
-                        Db::rollback();
-                        return error_show(1004,"发货单更新失败");
-                    }
+                    if($out==false) throw new Exception("发货单更新失败");
+
                     $order = ["order_code"=>$orde['outCode'],"status"=>$od_status,"action_remark"=>'',"action_type"=>"edit"];
-                    ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname],$order,"CKD", $orde['status'],$this->post);
+                    ActionLog::logAdd($action_log_user,$order,"CKD", $orde['status'],$this->post);
                     $process=["order_code"=>$orde['outCode'],"order_id"=>$orde['id'],"order_status"=>$orde['status'],"order_type"=>"CKD","before_status"=>$od_status];
-                    ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
+                    ProcessOrder::AddProcess($action_log_user,$process);
+
                     $sale['th_num'] += $info['error_num'];
                     $sale['th_fee'] += round($info['error_num']*$sale['sale_price'],2);
-                    $sale['updatetime']=date("Y-m-d H:i:s");
+                    $sale['updatetime']= $date;
                     $sup =Db::name("sale")->save($sale);
-                    if($sup==false){
-                        Db::rollback();
-                        return error_show(1004,"销售单更新失败");
-                    }
+                    if($sup==false) throw new Exception("销售单更新失败");
+
                     $data=[
                         "orderCode"=>$info['orderCode'],
                         "th_type"=>2,
@@ -449,51 +471,50 @@ class After extends Base
                         "cat_id"=>$sale['cat_id'],
                         "apply_id"=>$info['apply_id'],
                         "apply_name"=>$info['apply_name'],
-                        "addtime"=>date("Y-m-d H:i:s"),
+                        "addtime"=>$date,
                         "status"=>1,
                         "is_del"=>0
                     ];
                     $inse=Db::name("th_data")->insert($data);
-                    if($inse==false){
-                        Db::rollback();
-                        return error_show(1004,"退回单更新失败");
-                    }
+                    if($inse==false) throw new Exception('退回单更新失败');
+
                 }
+
                 $order = ["order_code"=>$info['returnCode'],"status"=>$var,"action_remark"=>'',"action_type"=>"edit"];
-                ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname],$order,"SHD", $info['status'],$this->post);
+                ActionLog::logAdd($action_log_user,$order,"SHD", $info['status'],$this->post);
 
-//                switch ($status) {
+//                switch ($param['status']) {
 //                    //待采购审核
 //                    case 2:
-//                        $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['person_id'], 'wait_name' => $info['person'], 'holder_id' => $info['person_id']];
+//                        $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['person_id'], 'wait_name' => $info['person'], 'holder_id' => $info['person_id']];
 //                        break;
 //
 //                    //待设置仓库
 //                    case 3:
-//                        $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['cgderid'], 'wait_name' => $info['cgder'], 'holder_id' => $info['cgderid']];
+//                        $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['cgderid'], 'wait_name' => $info['cgder'], 'holder_id' => $info['cgderid']];
 //                        break;
 //
 //                    //待客户退货
 //                    case 4:
-//                        $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['apply_id'], 'wait_name' => $info['apply_name'], 'holder_id' => $info['apply_id']];
+//                        $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['apply_id'], 'wait_name' => $info['apply_name'], 'holder_id' => $info['apply_id']];
 //                        break;
 //
 //                    default:
-//                        $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'holder_id' => $info['apply_id']];
+//                        $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'holder_id' => $info['apply_id']];
 //                }
-//                if (in_array($status, [2, 3])) $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['cgderid'], 'wait_name' => $info['cgder'],'holder_id'=>$info['cgderid']];
-//                elseif ($status == 4) $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['apply_id'], 'wait_name' => $info['apply_name'],'holder_id'=>$info['apply_id']];
-//                else $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var,'holder_id'=>$info['apply_id']];
-                $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['person_id'], 'wait_name' => $info['person'], 'holder_id' => $info['person_id']];
+//                if (in_array($param['status'], [2, 3])) $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['cgderid'], 'wait_name' => $info['cgder'],'holder_id'=>$info['cgderid']];
+//                elseif ($param['status'] == 4) $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['apply_id'], 'wait_name' => $info['apply_name'],'holder_id'=>$info['apply_id']];
+//                else $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var,'holder_id'=>$info['apply_id']];
+                $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['person_id'], 'wait_name' => $info['person'], 'holder_id' => $info['person_id']];
 
-                ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
+                ProcessOrder::AddProcess($action_log_user,$process);
                 Db::commit();
                 return app_show(0,"更新成功");
             }else{
                 Db::rollback();
                 return error_show(1004,"更新失败");
             }
-        }catch (\Exception $e){
+        }catch (Exception $e){
             Db::rollback();
             return error_show(1004,$e->getMessage());
         }

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

@@ -196,7 +196,7 @@ class Business extends Base
     public function edit()
     {
 
-        $param = $this->request->only(['id', 'inv_addr', 'inv_bank', 'inv_bankNo', 'mobile'], 'post', 'trim');
+        $param = $this->request->only(['id', 'inv_addr', 'inv_bank', 'inv_bankNo', 'mobile','invoice_title'], 'post', 'trim');
 
         $val = Validate::rule([
             'id' => 'require|number|gt:0',
@@ -204,6 +204,7 @@ class Business extends Base
             'inv_bank' => 'require|max:255',
             'inv_bankNo' => 'require|max:255',
             'mobile' => 'require|max:255',
+            'invoice_title' => 'require|max:255',
         ]);
 
         if ($val->check($param) == false) return json_show(1005, $val->getError());

+ 18 - 10
app/admin/controller/Consult.php

@@ -2202,6 +2202,7 @@ class Consult extends Base
         return app_show(0,"获取成功",["list"=>$data,"count"=>$count]);
     }
 
+    //招标工作台
     public function  crontablist(){
         $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";
@@ -2241,7 +2242,7 @@ class Consult extends Base
 
         //查看非本公司的竞价单
         $relaComNo = isset($this->post['relaComNo']) && $this->post['relaComNo']!="" ? trim($this->post['relaComNo']):"";
-        if($relaComNo!="") $where[]=['b.companyNo','<>', $relaComNo];
+        if($this->level!=1 & $relaComNo!="") $where[]=['b.companyNo','<>', $relaComNo];
 
 //        $role=$this->checkRole();
 //        if(!empty($role['platform']) ){
@@ -2259,28 +2260,35 @@ class Consult extends Base
             ->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")
+            ->field("a.*,b.createrid,b.creater,b.is_project,b.projectNo,b.khNo,b.endtime,b.platform_code,b.saleid,b.salesman,b.depart,b.companyNo")
             ->select()
             ->toArray();
         $data=[];
         foreach ($list as $value){
             $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
-              $cat =Db::name("cat")->where(["id"=>$value['cat_id']])->find();
-              $budget = isset($cat['order_rate']) ? $cat['order_rate']:0;
-               $value['original_price']=sprintf("%.2f",$value['budget_price']* (1 -$budget/100));
+//              $cat =Db::name("cat")
+//                  ->where(["id"=>$value['cat_id']])
+//                  ->find();
+//              $budget = isset($cat['order_rate']) ? $cat['order_rate']:0;
+            $budget = get_budget($value['cat_id'], $value['companyNo'], $value['platform_code']);
+               $value['original_price']=sprintf("%.2f",$value['budget_price']* (1 -$budget));
 
             $brand = Db::name("brand")->where(['id'=>$value['brand_id']])->find();
             $value['brand_name']= isset($brand['brand_name']) && $brand['brand_name']!='' ? $brand['brand_name']:"";
             $value['khname']="";
-            $value['specinfo']=isset($value['specinfo'])&&$value['specinfo']!=""? json_decode($value['specinfo'],
-                true):[];
+            $value['specinfo']=isset($value['specinfo'])&&$value['specinfo']!=""? json_decode($value['specinfo'],true):[];
             if($value['khNo']!==""){
-                $kh=Db::name("customer_info")->where(['companyNo'=>$value['khNo']])->find();
+                $kh=Db::name("customer_info")
+                    ->where(['companyNo'=>$value['khNo']])
+                    ->find();
                 $value['khname']= isset($kh['companyName'])?$kh['companyName']:"";
             }
-            $consult =Db::name("consult_bids")->where(["infoNo"=>$value['infoNo'],"createrid"=>$this->uid,"is_del"=>0])
+            $consult =Db::name("consult_bids")
+                ->where(["infoNo"=>$value['infoNo'],"createrid"=>$this->uid,"is_del"=>0])
+                ->find();
+            $consults =Db::name("consult_bids")
+                ->where(["infoNo"=>$value['infoNo'],"is_del"=>0])
                 ->find();
-            $consults =Db::name("consult_bids")->where(["infoNo"=>$value['infoNo'],"is_del"=>0])->find();
             $value['is_feed'] =$consult==false?0:1;
             $value['is_all_feed'] =$consults==false?0:1;
             $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";

+ 4 - 4
app/admin/controller/Goodup.php

@@ -142,14 +142,14 @@ class Goodup extends Base
         $hand = resign_hand_user($this->uid,0);
         if (!empty($role[DataGroupModel::$type_全部])) {
         	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
-			$where[] = ['gb.chargerid', 'in',$arr];
+            $where[] = ['gb.chargerid|gb.createrid', 'in', $arr];
         }
 
         $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
         if ($company_name !== "") $where[] = ["gb.createrid", 'in', get_company_item_user_by_name($company_name)];
 
         $relaComNo = isset($this->post['relaComNo']) && $this->post['relaComNo']!="" ? trim($this->post['relaComNo']):"";
-        if($relaComNo!="") $where[]=['gb.companyNo|gb.supplierNo','=', $relaComNo];
+        if($relaComNo!="") $where[]=['gb.companyNo','=', $relaComNo];
 
         $count = Db::name('good_basic')
             ->alias('gb')
@@ -491,8 +491,8 @@ class Goodup extends Base
                         return app_show(1004,"商品规格值创建失败");
                     }
                 }
-                $catinfo = Db::name("cat")->where(["id"=>$cat_id])->find();
-                $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:0;
+//                $catinfo = Db::name("cat")->where(["id"=>$cat_id])->find();
+//                $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:0;
                 $top_cat_id = made($cat_id);//获取所有分类
                 $top_cat_id = isset($top_cat_id[0]['id']) ? $top_cat_id[0]['id'] : 0;//获取顶级分类id
                 if($good_ladder!=="" && !empty($good_ladder)){

+ 7 - 5
app/admin/controller/Menu.php

@@ -62,7 +62,6 @@ class Menu extends Base
     {
         $post = $this->request->filter('trim')->post();
 
-        $level = $post['level'] ?? $this->level;
 //        $uid = $this->uid;
 //        if ($uid == '') {
 //            return error_show(101, '未找到用户信息');
@@ -73,14 +72,15 @@ class Menu extends Base
 
         $where = [['status', '=', 1], ['cstatus', '=', 1], ['is_display', '=', 1]];
 
-        switch ($level) {
+        //先把当前账号能看到的菜单筛选出来
+        switch ($this->level) {
 
             case 1:
                 //超管,能看到等级为012的菜单
                 $role['action_conllect'] = Db::name('action')
                     ->where(['is_del' => 0, 'status' => 1])
                     ->column('id');
-                $where[] = ['blevel', 'in', [0, 1, 2]];
+//                $where[] = ['blevel', 'in', [0, 1, 2]];
                 break;
             case 2:
                 $role['action_conllect'] = Db::name('user_role')
@@ -89,7 +89,7 @@ class Menu extends Base
                     ->where(['a.uid' => $this->uid, 'a.is_del' => 0, 'a.companyNo' => $post['relaComNo']])
                     ->value('b.action_conllect');
 
-                $where[] = ['blevel', 'in', [0, $level]];
+//                $where[] = ['blevel', 'in', [0, $level]];
                 break;
 
             case 3:
@@ -100,11 +100,13 @@ class Menu extends Base
                     ->where(['a.uid' => $this->uid, 'a.is_del' => 0])
                     ->value('b.action_conllect');
 
-                $where[] = ['blevel', 'in', [0, $level]];
+//                $where[] = ['blevel', 'in', [0, $level]];
                 break;
 
         }
 
+        if (isset($post['level']) && $post['level'] !== '' && $post['level'] != 1) $where[] = ['blevel', 'in', [0, $post['level']]];
+
 //        if (empty($role['action_conllect'])) {
 //            return app_show(0, "获取成功", []);
 //        }

+ 5 - 1
app/admin/controller/Platform.php

@@ -105,12 +105,16 @@ class Platform extends Base
 
             if ($param['is_select_pay_rate'] == 1) {
 
+                $userCommon = new \app\admin\common\User();
+                $company_names = $userCommon->handle('getCodeAndName',['code'=>array_column($param['pay_list'],'companyNo')]);
+                if(!isset($company_names['code']) || $company_names['code']!=0) throw new Exception($company_names['message']);
+
                 $insert_da = [];
                 foreach ($param['pay_list'] as $pay) {
                     $insert_da[] = [
                         'platform_id' => $platform_id,
                         'companyNo' => $pay['companyNo'],
-                        'companyName' => $pay['companyName'],
+                        'companyName' => $company_names['data'][$pay['companyNo']] ?? '',
                         'rate' => $pay['rate'],
                         'status' => 1,
                         'is_del' => 0,

+ 3 - 2
app/command/TempHandleBusinessData.php

@@ -28,7 +28,7 @@ class TempHandleBusinessData extends Command
 
         if ($tmp) return '';//不执行
 
-        Cache::store('redis')->handler()->set($this->key,1);
+        Cache::store('redis')->handler()->set($this->key,1,5*60);
 
         try {
 
@@ -64,7 +64,8 @@ class TempHandleBusinessData extends Command
                             'is_del' => $item['is_del'],
                             'addtime' => $item['addtime'],
                             'updatetime' => $item['updatetime'],
-                            //以下字段天空字符串,需要用户在结算平台补充值
+                            'invoice_title' => $item['invoice_title'],
+                            //以下字段填空字符串,需要用户在结算平台补充值
                             'input_ticket' => '',
                             'out_ticket' => '',
                             'voider' => '',