Bladeren bron

细节优化,创建企业优化

wufeng 2 jaren geleden
bovenliggende
commit
143310f3d2
4 gewijzigde bestanden met toevoegingen van 264 en 217 verwijderingen
  1. 1 0
      app/admin/common/User.php
  2. 93 73
      app/admin/controller/Consult.php
  3. 168 143
      app/admin/controller/Customar.php
  4. 2 1
      app/command/SplitSale.php

+ 1 - 0
app/admin/common/User.php

@@ -61,6 +61,7 @@ class User
         'bTitle' => 'bTitle',
         'cInfo' => 'cInfo',
         'cTitle' => 'cTitle',
+        'cCreate' => 'cCreate',
         'getCodeAndName' => 'getCodeAndName',
         'upgrade' => 'supplerUpgrade',
         'get_business_list_tmp' => 'get_business_list_tmp',

+ 93 - 73
app/admin/controller/Consult.php

@@ -2153,56 +2153,57 @@ class Consult extends Base
         }
         return app_show(0,"获取成功",$data);
     }
-    public function bragain_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=[['bo.is_del',"=",0]];
-        $bidsNo = isset($this->post['bidsNo'])&&$this->post['bidsNo']!=""?trim($this->post['bidsNo']):"";
-        if($bidsNo!=""){
-            $where[]=["bo.bidsNo","like","%$bidsNo%"];
+    public function bragain_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 = [['bo.is_del', "=", 0]];
+        $bidsNo = isset($this->post['bidsNo']) && $this->post['bidsNo'] != "" ? trim($this->post['bidsNo']) : "";
+        if ($bidsNo != "") {
+            $where[] = ["bo.bidsNo", "like", "%$bidsNo%"];
         }
         $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
         if ($zxNo !== "") {
-            $where[] = ['bo.zxNo','like',"%$zxNo%"];
+            $where[] = ['bo.zxNo', 'like', "%$zxNo%"];
         }
         $bargainNo = isset($this->post['bargainNo']) && $this->post['bargainNo'] !== "" ? trim($this->post['bargainNo']) : "";
         if ($bargainNo !== "") {
-            $where[] = ['bo.bargainNo','like',"%$bargainNo%"];
+            $where[] = ['bo.bargainNo', 'like', "%$bargainNo%"];
         }
 
         $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
-        if ($status!== "") {
-            $where[] = ['bo.status','=',$status];
+        if ($status !== "") {
+            $where[] = ['bo.status', '=', $status];
         }
 
         $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
         if ($infoNo !== "") {
-            $where[] = ['bo.infoNo','like',"%$infoNo%"];
+            $where[] = ['bo.infoNo', 'like', "%$infoNo%"];
         }
 
         $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
         if ($projectNo !== "") {
-            $zxlist = Db::name("consult_order")->where(["projectNo"=>$projectNo,"is_del"=>0,"is_project"=>1])->column("zxNo");
-            $where[] = ['bo.zxNo','in',$zxlist];
+            $zxlist = Db::name("consult_order")->where(["projectNo" => $projectNo, "is_del" => 0, "is_project" => 1])->column("zxNo");
+            $where[] = ['bo.zxNo', 'in', $zxlist];
         }
         $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
         if ($pgNo !== "") {
-            $bidinfo = Db::name("consult_info")->where([["pgNo","=",$pgNo],["is_del","=",0]])->column("infoNo");
-            $where[] = ['bo.infoNo','in',$bidinfo];
+            $bidinfo = Db::name("consult_info")->where([["pgNo", "=", $pgNo], ["is_del", "=", 0]])->column("infoNo");
+            $where[] = ['bo.infoNo', 'in', $bidinfo];
         }
-        $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start'] : "";
-        $end= isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] : "";
-        if($start!=""){
-            $where[]=["bo.addtime",">=",date("Y-m-d H:i:s",strtotime($start))];
+        $start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start'] : "";
+        $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] : "";
+        if ($start != "") {
+            $where[] = ["bo.addtime", ">=", date("Y-m-d H:i:s", strtotime($start))];
         }
-        if($end!=""){
-            $where[]=["bo.addtime","<=",date("Y-m-d H:i:s",strtotime($end))];
+        if ($end != "") {
+            $where[] = ["bo.addtime", "<=", date("Y-m-d H:i:s", strtotime($end))];
         }
         $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
         if ($company_name !== "") $where[] = ["bo.createrid", 'in', get_company_item_user_by_name($company_name)];
 
-        $relaComNo = trim($this->post['relaComNo']??'');
-        if ($relaComNo !== "") $where[] = ["b.companyNo", '=', $relaComNo];
+        $companyNo = trim($this->post['companyNo'] ?? '');
+        if ($companyNo !== "") $where[] = ["b.companyNo", 'like', '%' . $companyNo . '%'];
 
 //        $role=$this->checkRole();
 //        if(!empty($role['write'])){
@@ -2211,15 +2212,16 @@ class Consult extends Base
 //        $role = $this->checkDataShare();
 //        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['bo.createrid', 'in', $role[DataGroupModel::$type_全部]];
         $role = $this->checkDataShare();
-        $hand = resign_hand_user($this->uid,0);
+        $hand = resign_hand_user($this->uid, 0);
         if (!empty($role[DataGroupModel::$type_全部])) {
-        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
-			$where[] = ['bo.createrid', 'in',$arr];
+            $arr = array_unique(array_merge($hand, $role[DataGroupModel::$type_全部]));
+            $where[] = ['bo.createrid', 'in', $arr];
         }
 
-        $count=Db::name("bargain_order")
+        $count = Db::name("bargain_order")
             ->alias('bo')
-            ->leftJoin('consult_order b','b.zxNo=bo.zxNo')
+            ->leftJoin('consult_order b', 'b.zxNo=bo.zxNo')
+            ->leftJoin('consult_info c', 'c.infoNo=bo.infoNo')
             ->where($where)
             ->count('bo.id');
 
@@ -2227,76 +2229,94 @@ class Consult extends Base
         $page = $page >= $total ? $total : $page;
         $list = Db::name('bargain_order')
             ->alias('bo')
-            ->field('bo.*,b.companyNo')
-            ->leftJoin('consult_order b','b.zxNo=bo.zxNo')
+            ->field('bo.*,b.companyNo,c.num')
+            ->leftJoin('consult_order b', 'b.zxNo=bo.zxNo')
+            ->leftJoin('consult_info c', 'c.infoNo=bo.infoNo')
             ->where($where)
             ->page($page, $size)
             ->order('bo.addtime', 'desc')
             ->select()
             ->toArray();
 
-        $all_createrid = array_column($list,'createrid');
+        $all_createrid = array_column($list, 'createrid');
         $item = get_company_name_by_uid($all_createrid);
 
         $userCommon = new \app\admin\common\User();
-        $names = $userCommon->handle('getCodeAndName',['code'=>array_column($list,'companyNo')]);
+        $names = $userCommon->handle('getCodeAndName', ['code' => array_column($list, 'companyNo')]);
 
-        $data=[];
-        foreach ($list as $value){
-            $value['companyName'] = $names['data'][$value['companyNo']]??'';
-           $bidinfos =   Db::name("consult_bids")->where([["bidNo","=",$value['bidsNo']],["is_del","=",0]])->find();
-           $value['spuCode'] = isset($bidinfos['spuCode'])?$bidinfos['spuCode']:"";
-           $value['good_name'] = isset($bidinfos['good_name'])?$bidinfos['good_name']:"";
-           $value['good_img'] = isset($bidinfos['good_img'])?$bidinfos['good_img']:"";
-           $value['brand_id'] = isset($bidinfos['brand_id'])?$bidinfos['brand_id']:"";
-            if($bidinfos['brand_id']!=0){
+        $bidinfos_list = Db::name('consult_bids')
+            ->where(['is_del' => 0, 'bidNo' => array_column($list, 'bidsNo')])
+            ->column('*', 'bidNo');
+
+        $brand = Db::name("brand")
+            ->where(["id" =>array_column($bidinfos_list,'brand_id')])
+            ->column('brand_name', 'id');
+
+        $cat = Db::name("cat")
+            ->where(["id" => array_column($bidinfos_list,'cat_id')])
+            ->column('order_rate', 'id');
+
+        $unit = Db::name("unit")
+            ->where(["id" => array_column($bidinfos_list,'unit_id')])
+            ->column('unit', 'id');
+
+        $data = [];
+        foreach ($list as $value) {
+            $value['companyName'] = $names['data'][$value['companyNo']] ?? '';
+//           $bidinfos =   Db::name("consult_bids")->where([["bidNo","=",$value['bidsNo']],["is_del","=",0]])->find();
+            $bidinfos = $bidinfos_list[$value['bidsNo']];
+            $value['spuCode'] = isset($bidinfos['spuCode']) ? $bidinfos['spuCode'] : "";
+            $value['good_name'] = isset($bidinfos['good_name']) ? $bidinfos['good_name'] : "";
+            $value['good_img'] = isset($bidinfos['good_img']) ? $bidinfos['good_img'] : "";
+            $value['brand_id'] = isset($bidinfos['brand_id']) ? $bidinfos['brand_id'] : "";
+            if ($bidinfos['brand_id'] != 0) {
                 $value['brand_id'] = $bidinfos['brand_id'];
-                $brand=Db::name("brand")->where(["id"=>$bidinfos['brand_id']])->find();
-                $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
-            }else{
-                $value["brand_name"]="";
-                $value["brand_id"]="";
+//                $brand=Db::name("brand")->where(["id"=>$bidinfos['brand_id']])->find();
+                $value["brand_name"] = $brand[$value['brand_id']] ?? '';//isset($brand['brand_name'])?$brand['brand_name']:"";
+            } else {
+                $value["brand_name"] = "";
+                $value["brand_id"] = "";
             }
-            $catinfo = Db::name("cat")->where(["id"=>$bidinfos['cat_id']])->find();
-            $value['can']= isset($bidinfos['cat_id']) && $bidinfos['cat_id'] !=0 ? made($bidinfos['cat_id']):[];
-            $unit =Db::name("unit")->where(["id"=>$bidinfos['unit_id']])->find();
-            $value['unit'] = isset($unit['unit'])?$unit['unit']:'';
-            $bidinfoe = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
-            $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
-            $value['budget'] =$budget;
-            $god=[
-                "metal_id"=>$bidinfos['metal_id'],
-                "weight"=>$bidinfos["good_weight"],
-                "demo_fee"=>$bidinfos["demo_fee"],
-                "delivery_fee"=>$bidinfos["delivery_fee"],
-                "open_fee"=>$bidinfos["open_fee"],
-                "packing_fee"=>$bidinfos["pakge_fee"],
-                "mark_fee"=>$bidinfos["mark_fee"],
-                "nake_fee"=>$bidinfos["nake_fee"],
-                "cert_fee"=>$bidinfos["cert_fee"],
-                "cost_fee"=>$bidinfos["cost_fee"],
-                "num"=>$bidinfoe["num"],
+//            $catinfo = Db::name("cat")->where(["id"=>$bidinfos['cat_id']])->find();
+            $value['can'] = isset($bidinfos['cat_id']) && $bidinfos['cat_id'] != 0 ? made($bidinfos['cat_id']) : [];
+//            $unit =Db::name("unit")->where(["id"=>$bidinfos['unit_id']])->find();
+            $value['unit'] = $unit[$bidinfos['unit_id']] ?? '';//isset($unit['unit'])?$unit['unit']:'';
+//            $bidinfoe = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
+            $budget = $cat[$bidinfos['cat_id']] ?? 0;//isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
+            $value['budget'] = $budget;
+            $god = [
+                "metal_id" => $bidinfos['metal_id'],
+                "weight" => $bidinfos["good_weight"],
+                "demo_fee" => $bidinfos["demo_fee"],
+                "delivery_fee" => $bidinfos["delivery_fee"],
+                "open_fee" => $bidinfos["open_fee"],
+                "packing_fee" => $bidinfos["pakge_fee"],
+                "mark_fee" => $bidinfos["mark_fee"],
+                "nake_fee" => $bidinfos["nake_fee"],
+                "cert_fee" => $bidinfos["cert_fee"],
+                "cost_fee" => $bidinfos["cost_fee"],
+                "num" => $value["num"],
             ];
 //            if($bidinfos['is_gold_price']==1){
 //                $price = GoldPrice($god, $budget/100);
 //            }else{
 //                $price = GoodPrice($god, $budget/100);
 //            }
-            $value['metal_name']=isset($bidinfos['metal_id'])&& $bidinfos['metal_id']!=0?$this->noble[$bidinfos['metal_id']]:"";
-            $value['sale_price'] =round($bidinfos['origin_price'],2);
-            $value['cost_before_price'] =round($bidinfos['origin_cost_fee'],2);
+            $value['metal_name'] = isset($bidinfos['metal_id']) && $bidinfos['metal_id'] != 0 ? $this->noble[$bidinfos['metal_id']] : "";
+            $value['sale_price'] = round($bidinfos['origin_price'], 2);
+            $value['cost_before_price'] = round($bidinfos['origin_cost_fee'], 2);
 
-            $value['specinfo'] = isset($bidinfos['specinfo'])&&$bidinfos['specinfo']!=""?json_decode($bidinfos['specinfo'],true):[];
-            $value['company_name'] = $item[$value['createrid']]??'';
+            $value['specinfo'] = isset($bidinfos['specinfo']) && $bidinfos['specinfo'] != "" ? json_decode($bidinfos['specinfo'], true) : [];
+            $value['company_name'] = $item[$value['createrid']] ?? '';
 
             //是否具有编辑权限
             $value['is_allow_update'] = 0;
             if (in_array($this->roleid, [1, 33]) || in_array($value['createrid'], $role[DataGroupModel::$type_可编辑])) $value['is_allow_update'] = 1;
 
-            $data[]=$value;
+            $data[] = $value;
         }
 
-        return app_show(0,"获取成功",["list"=>$data,"count"=>$count]);
+        return app_show(0, "获取成功", ["count" => $count, "list" => $data]);
     }
 
     //招标工作台

+ 168 - 143
app/admin/controller/Customar.php

@@ -8,7 +8,7 @@ use think\App;
 use think\facade\Db;
 
 //客户
-class Customar extends BaseController
+class Customar extends Base
 {
     public $post = "";
 
@@ -20,123 +20,132 @@ class Customar extends BaseController
 
     public function create()
     {
-        $token = isset($this->post['token']) && $this->post['token'] != '' ? trim($this->post['token']) : "";
-        if ($token == '') {
-            return error_show(1005, "参数token不能为空");
-        }
-        $companyNo = makeNo("KH");
-        $companyName = isset($this->post['companyName']) && $this->post['companyName'] !== "" ? $this->post['companyName'] : "";
-        if ($companyName == "") {
-            return error_show(1002, "参数companyName不能为空");
-        }
-        $parent = isset($this->post['parent']) && $this->post['parent'] !== "" ? intval($this->post['parent'] ) : "";
-        $rename = Db::name('customer_org1')->where(['is_del' =>0,'id'=>$parent])->find();
-        $item = Db::name('customer_info')->where(['itemid'=>$rename['id'],'companyName'=>$companyName,'is_del'=>0])->find();
-        if ($item!=false) {
-            return error_show(1002, "公司名称已存在");
-        }
+        $param = $this->request->filter('trim')->post();
+
+        $param['uid']= $this->uid;
+        $param['uname']= $this->uname;
+
+        $userCommon = new \app\admin\common\User();
+        $rs = $userCommon->handle('cCreate',$param);
+
+        return json_show($rs['code'],$rs['message'],$rs['data']);
+//        $token = isset($this->post['token']) && $this->post['token'] != '' ? trim($this->post['token']) : "";
+//        if ($token == '') {
+//            return error_show(1005, "参数token不能为空");
+//        }
+//        $companyNo = makeNo("KH");
+//        $companyName = isset($this->post['companyName']) && $this->post['companyName'] !== "" ? $this->post['companyName'] : "";
+//        if ($companyName == "") {
+//            return error_show(1002, "参数companyName不能为空");
+//        }
+//        $parent = isset($this->post['parent']) && $this->post['parent'] !== "" ? intval($this->post['parent'] ) : "";
+//        $rename = Db::name('customer_org1')->where(['is_del' =>0,'id'=>$parent])->find();
+//        $item = Db::name('customer_info')->where(['itemid'=>$rename['id'],'companyName'=>$companyName,'is_del'=>0])->find();
+//        if ($item!=false) {
+//            return error_show(1002, "公司名称已存在");
+//        }
 //        if ($parent === "") {
 //            return error_show(1002, "参数parent不能为空");
 //        }
         //$itemid = isset($this->post['itemid']) && $this->post['itemid'] !== "" ? intval($this->post['itemid'] ) : "";
-        $customer_member = isset($this->post['customer_member']) && $this->post['customer_member'] !== "" ? $this->post['customer_member'] : "";
-        if ($customer_member == "") {
-            return error_show(1002, "参数customer_member不能为空");
-        }
+//        $customer_member = isset($this->post['customer_member']) && $this->post['customer_member'] !== "" ? $this->post['customer_member'] : "";
+//        if ($customer_member == "") {
+//            return error_show(1002, "参数customer_member不能为空");
+//        }
 //        $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']):"";
 //        if($status==""){
 //            return error_show(1002,"参数status不能为空");
 //        }
-        $user = GetUserInfo($token);
-        if (empty($user) || $user['code'] != 0) {
-            return error_show(102, "创建人数据不存在");
-        }
-        $createrid = isset($user["data"]['id']) ? $user["data"]['id'] : "";
-        $creater = isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
-        Db::startTrans();
-        try {
-            $data = [
-                "companyNo" => $companyNo,
-                "companyName" => $companyName,
-                "parent" => $parent,
-                "itemid" => $parent,
-                "area" => "",
-                "comdepart" => "",
-                "commobile" => "",
-                "comtel" => "",
-                "contactor" => "",
-                "depart" => "",
-                "mobile" => "",
-                "invoice_title" => "",
-                "invoice_people" => "",
-                "invoice_addr" => "",
-                "invoice_mobile" => "",
-                "invoice_code" => "",
-                "invoice_bank" => "",
-                "invoice_bankNo" => "",
-                "companyCode" => "",
-                "status" => 0,
-                "sales_name" => "",
-                "sales_depart" => "",
-                "branch" => "",
-                "middle" => "",
-                "country" => "",
-                "is_del" => 0,
-                "creater" => $creater,
-                "modifier" => "",
-                "addtime" => date("Y-m-d H:i:s"),
-                "updatetime" => date("Y-m-d H:i:s"),
-            ];
-            $datainfo = Db::name('customer_info')->insert($data);
-            if ($datainfo) {
-
-//                $var = [];
-//                //var_dump($customer_member);
-                foreach ($customer_member as $value) {
-//                    if($value['ownerid']!==""){
-//                        $to = GetInfoById($token, ['id' => $value['ownerid']]);
-//                        if (empty($to) || $to['code'] != 0) {
-//                            return app_show(1002, "数据拥有者信息不存在");
-//                        }
-//                    }
-                $item = [];
-//                $info = $to['data'];
-//                $item['owner'] =  isset($info['nickname']) ? $info['nickname'] : "";
-                // $item['ownerid'] = $info['id'];
-                $item['commobile'] = isset($value['commobile']) ? $value['commobile'] : "";;
-                $item['comtel'] =  "";
-                $item['contactor'] = isset($value['contactor']) ? $value['contactor'] : "";
-                $item['position'] = isset($value['position']) ? $value['position'] : "";
-                $item['wxaccount'] = isset($value['wxaccount']) ? $value['wxaccount'] : "";
-                $item['qqaccount'] = isset($value['qqaccount']) ? $value['qqaccount'] : "";
-                $item['email'] = isset($value['email']) ? $value['email'] : "";
-                $item['comdepart'] = isset($value['comdepart']) ? $value['comdepart'] : "";
-                //$item['is_private'] = isset($value['is_private']) ? $value['is_private'] : "";
-                $item['status'] = $value['status'];
-                $item['createrid'] = $createrid;
-                $item['creater'] = $creater;
-                $item['companyNo'] = $companyNo;
-                $item['is_del'] = 0;
-                $item['addtime'] = date("Y-m-d H:i:s");
-                $item['updatetime'] = date("Y-m-d H:i:s");
-                $var[] = $item;
-            }
-                $vp = Db::name('customer_member')->insertAll($var);
-                if ($vp == "") {
-                    Db::rollback();
-                    return error_show(1002, "新建失败");
-                }
-
-                Db::commit();
-                return error_show(0, "新建成功");
-            } else {
-                Db::rollback();
-                return error_show(1002, "新建失败");
-            }
-        } catch (\Exception $e) {
-            Db::rollback();
-            return error_show(1005, $e->getMessage());
-        }
+//        $user = GetUserInfo($token);
+//        if (empty($user) || $user['code'] != 0) {
+//            return error_show(102, "创建人数据不存在");
+//        }
+//        $createrid = isset($user["data"]['id']) ? $user["data"]['id'] : "";
+//        $creater = isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
+//        Db::startTrans();
+//        try {
+//            $data = [
+//                "companyNo" => $companyNo,
+//                "companyName" => $companyName,
+//                "parent" => $parent,
+//                "itemid" => $parent,
+//                "area" => "",
+//                "comdepart" => "",
+//                "commobile" => "",
+//                "comtel" => "",
+//                "contactor" => "",
+//                "depart" => "",
+//                "mobile" => "",
+//                "invoice_title" => "",
+//                "invoice_people" => "",
+//                "invoice_addr" => "",
+//                "invoice_mobile" => "",
+//                "invoice_code" => "",
+//                "invoice_bank" => "",
+//                "invoice_bankNo" => "",
+//                "companyCode" => "",
+//                "status" => 0,
+//                "sales_name" => "",
+//                "sales_depart" => "",
+//                "branch" => "",
+//                "middle" => "",
+//                "country" => "",
+//                "is_del" => 0,
+//                "creater" => $creater,
+//                "modifier" => "",
+//                "addtime" => date("Y-m-d H:i:s"),
+//                "updatetime" => date("Y-m-d H:i:s"),
+//            ];
+//            $datainfo = Db::name('customer_info')->insert($data);
+//            if ($datainfo) {
+//
+////                $var = [];
+////                //var_dump($customer_member);
+//                foreach ($customer_member as $value) {
+////                    if($value['ownerid']!==""){
+////                        $to = GetInfoById($token, ['id' => $value['ownerid']]);
+////                        if (empty($to) || $to['code'] != 0) {
+////                            return app_show(1002, "数据拥有者信息不存在");
+////                        }
+////                    }
+//                $item = [];
+////                $info = $to['data'];
+////                $item['owner'] =  isset($info['nickname']) ? $info['nickname'] : "";
+//                // $item['ownerid'] = $info['id'];
+//                $item['commobile'] = isset($value['commobile']) ? $value['commobile'] : "";;
+//                $item['comtel'] =  "";
+//                $item['contactor'] = isset($value['contactor']) ? $value['contactor'] : "";
+//                $item['position'] = isset($value['position']) ? $value['position'] : "";
+//                $item['wxaccount'] = isset($value['wxaccount']) ? $value['wxaccount'] : "";
+//                $item['qqaccount'] = isset($value['qqaccount']) ? $value['qqaccount'] : "";
+//                $item['email'] = isset($value['email']) ? $value['email'] : "";
+//                $item['comdepart'] = isset($value['comdepart']) ? $value['comdepart'] : "";
+//                //$item['is_private'] = isset($value['is_private']) ? $value['is_private'] : "";
+//                $item['status'] = $value['status'];
+//                $item['createrid'] = $createrid;
+//                $item['creater'] = $creater;
+//                $item['companyNo'] = $companyNo;
+//                $item['is_del'] = 0;
+//                $item['addtime'] = date("Y-m-d H:i:s");
+//                $item['updatetime'] = date("Y-m-d H:i:s");
+//                $var[] = $item;
+//            }
+//                $vp = Db::name('customer_member')->insertAll($var);
+//                if ($vp == "") {
+//                    Db::rollback();
+//                    return error_show(1002, "新建失败");
+//                }
+//
+//                Db::commit();
+//                return error_show(0, "新建成功");
+//            } else {
+//                Db::rollback();
+//                return error_show(1002, "新建失败");
+//            }
+//        } catch (\Exception $e) {
+//            Db::rollback();
+//            return error_show(1005, $e->getMessage());
+//        }
     }
 
     public function list()
@@ -296,47 +305,63 @@ class Customar extends BaseController
     public function info()
     {
         $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !== "" ? trim($this->post['companyNo']) : "";
-        if ($companyNo == "") {
-            return error_show(1002, "参数companyNo不能为空");
-        }
+        if ($companyNo == "")   return error_show(1002, "参数companyNo不能为空");
+
+        $userCommon = new \app\admin\common\User();
+        $rs = $userCommon->handle('cInfo',['companyNo'=>$companyNo]);
+
+        return json_show($rs['code'],$rs['message'],$rs['data']);
+
         //>field("companyNo,companyName,itemid as parent,id")-
-        $idinfo = Db::name('customer_info')->where(['companyNo' => $companyNo, 'is_del' => 0])->find();
-        if ($idinfo == "") {
-            return error_show(1002, "未找到数据");
-        }
-        $info = Db::name("customer_member")->where(['companyNo' => $idinfo['companyNo'], "is_del" => 0])->select();
-        if ($info == "") {
-            return error_show(1002, "未找到customer_member数据");
-        }
+//        $idinfo = Db::name('customer_info')->where(['companyNo' => $companyNo, 'is_del' => 0])->find();
+//        if ($idinfo == "") {
+//            return error_show(1002, "未找到数据");
+//        }
+//        $info = Db::name("customer_member")->where(['companyNo' => $idinfo['companyNo'], "is_del" => 0])->select();
+//        if ($info == "") {
+//            return error_show(1002, "未找到customer_member数据");
+//        }
 //        $in = Db::name("customer_attr")->where(['id' => $idinfo['parent'], "is_del" => 0])->find();
 //        if ($in == "") {
 //            return error_show(1002, "未找到customer_attr数据");
 //        }
 //        $idinfo['attr_name'] = $in['name'];
-        $idinfo['member'] = $info;
-        if ($idinfo == "") {
-            return error_show(1002, "未找到数据");
-        }
-        return app_show(0, "获取成功", $idinfo);
+//        $idinfo['member'] = $info;
+//        if ($idinfo == "") {
+//            return error_show(1002, "未找到数据");
+//        }
+//        return app_show(0, "获取成功", $idinfo);
     }
     public function del(){
-        $id = $this->post['id'] && $this->post['id'] !=="" ? intval($this->post['id']) :"";
-        if($id===""){
-            return  error_show(1004,"参数id不能为空");
-        }
-        $str= Db::name('customer_info')->where(['id'=>$id,'is_del'=>0])->find();
-        if(empty($str)){
-            return error_show(1002,"未找到数据");
-        }
-        if($str['status']==1){
-            return error_show(1005,"启用状态,不允许删除");
-        }
-        $end = Db::name('customer_info')->update(['id'=>$id,'is_del'=>1]);
-        if($end){
-            return error_show(0,"删除成功");
-        }else{
-            return error_show(1002,"删除失败");
-        }
+
+        $param = $this->request->only(['id' => 0], 'post', 'trim');
+
+        $userCommon = new \app\admin\common\User();
+        $rs = $userCommon->handle('delete', [
+            'ids' => [$param['id']],
+            'type' => 3,
+            'updater' => $this->uname,
+            'updaterid' => $this->uid,
+        ]);
+        return json_show($rs['code'], $rs['message'], $rs['data']);
+
+//        $id = $this->post['id'] && $this->post['id'] !=="" ? intval($this->post['id']) :"";
+//        if($id===""){
+//            return  error_show(1004,"参数id不能为空");
+//        }
+//        $str= Db::name('customer_info')->where(['id'=>$id,'is_del'=>0])->find();
+//        if(empty($str)){
+//            return error_show(1002,"未找到数据");
+//        }
+//        if($str['status']==1){
+//            return error_show(1005,"启用状态,不允许删除");
+//        }
+//        $end = Db::name('customer_info')->update(['id'=>$id,'is_del'=>1]);
+//        if($end){
+//            return error_show(0,"删除成功");
+//        }else{
+//            return error_show(1002,"删除失败");
+//        }
     }
     public function status(){
         $id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']):"";

+ 2 - 1
app/command/SplitSale.php

@@ -101,7 +101,8 @@ class SplitSale extends Command
                         ->where(['is_del' => 0, 'pay_id' => $sale['pay_id'], 'orderCode' => $sale['orderCode']])
                         ->field(true)
                         ->order(['weight' => 'desc'])
-                        ->cursor();
+                        ->select()
+                        ->toArray();
 
                     //关联的采购单信息
                     $cgd = Db::name('order_num')