Просмотр исходного кода

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

wugg 1 год назад
Родитель
Сommit
2d1ad188a6

+ 0 - 12
app/admin/controller/Consult.php

@@ -2016,20 +2016,8 @@ class Consult extends Base
             ("zxNo");
             $where[] = ['zxNo','in',$zxlist];
         }
-//        $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
-//        if($token==''){
-//            return error_show(102,"参数token不能为空");
-//        }
         $is_own = isset($this->post['is_own']) ? intval($this->post['is_own']) : "0";
         if($is_own==1){
-//            $token = isset($this->post['token']) ? trim($this->post['token']) : "";
-//            if($token==""){
-//                return error_show(101,'token不能为空');
-//            }
-//            $apply_id =GetUserInfo($token);
-//            if(empty($apply_id)||$apply_id['code']!=0){
-//                return error_show(1002,"申请人数据不存在");
-//            }
             $rm= $this->uid;//isset($apply_id["data"]['id']) ?  $apply_id["data"]['id'] : "";
             $where[]=['createrid',"=",$rm];
         }

+ 2 - 0
app/admin/controller/OrderOutChild.php

@@ -56,6 +56,7 @@ class OrderOutChild extends Base
             'outChildCode' => '',
             'companyNo' => '',
             'spuCode' => '',
+            'good_name' => '',
             'outCode' => '',
             'order_source' => '',
             'wsm_code' => '',
@@ -83,6 +84,7 @@ class OrderOutChild extends Base
         if ($param['order_source'] != '') $where[] = ['a.order_source', '=', $param['order_source']];
         if ($param['wsm_code'] != '') $where[] = ['a.wsm_code', 'like', '%' . $param['wsm_code'] . '%'];
         if ($param['supplierNo'] != '') $where[] = ['a.supplierNo', 'like', '%' . $param['supplierNo'] . '%'];
+        if ($param['good_name'] != '') $where[] = ['a.good_name', 'like', '%' . $param['good_name'] . '%'];
         if ($param['skuCode'] != '') $where[] = ['a.skuCode', 'like', '%' . $param['skuCode'] . '%'];
         if ($param['apply_id'] !== '') $where[] = ['a.apply_id', '=', $param['apply_id']];
         if ($param['apply_name'] != '') $where[] = ['a.apply_name', 'like', '%' . $param['apply_name'] . '%'];

+ 1 - 1
app/admin/controller/Purch.php

@@ -342,7 +342,7 @@ class Purch extends Base
             $var[] = $value;
         }
         //采购工差单
-        $dom = Db::name("purchease_diff")->where(['cgdNo' => $data['cgdNo'], 'is_del' => 0])->find();
+        $dom = Db::name("purchease_diff")->where(['cgdNo' => $data['cgdNo'], 'is_del' => 0])->order("id desc")->find();
 
         if (in_array($data['order_type'], [3, 4])) {
             $goon = Db::name("good_zixun")->where(["spuCode" => $data['spuCode'], "is_del" => 0])->find();

+ 49 - 5
app/admin/controller/ReorderChild.php

@@ -303,7 +303,30 @@ class ReorderChild extends Base
 
         $info = Db::name('sale_return_child')
             ->alias('a')
-            ->field('a.id,a.num,a.status,a.returnCode,a.outChildCode,a.return_num,a.return_wsm_code,a.orderCode,a.outCode,a.saleReturnChildCode,a.apply_id,b.good_code spuCode,c.status order_out_status,b.id saleid,d.num thnum,d.id sr_id,d.apply_id sr_apply_id,b.is_stock,b.order_type,d.is_addr')
+            ->field('a.id,
+            a.num,
+            a.status,
+            a.returnCode,
+            a.outChildCode,
+            a.return_num,
+            a.return_wsm_code,
+            a.orderCode,
+            a.outCode,
+            a.saleReturnChildCode,
+            a.apply_id,
+            b.good_code spuCode,
+            b.sale_price,
+            b.good_name,
+            b.cat_id,
+            c.status order_out_status,
+            b.id saleid,
+            d.num thnum,
+            d.id sr_id,
+            d.apply_id sr_apply_id,
+            d.apply_name sr_apply_name,
+            b.is_stock,
+            b.order_type,
+            d.is_addr')
             ->leftJoin('sale b', 'b.orderCode=a.orderCode')
             ->leftJoin('order_out_child c', 'c.outChildCode=a.outChildCode AND c.is_del=0')
             ->leftJoin('sale_return d', 'd.returnCode=a.returnCode')
@@ -359,10 +382,31 @@ class ReorderChild extends Base
                 ->where(['is_del' => 0, 'returnCode' => $info['returnCode'], 'status' => 1])
                 ->findOrEmpty();
             if (empty($temp)) {
-                Db::name('sale_return')
+               $up= Db::name('sale_return')
                     ->where(['is_del' => 0, 'returnCode' => $info['returnCode'], 'status' => 12])
                     ->update(['status' => 4, 'updatetime' => $date]);
-
+				if($up==false) throw new Exception('退货单更新失败');
+
+					  $data=[
+                        "orderCode"=>$info['orderCode'],
+                        "th_type"=>1,
+                        "th_num"=>$info['thnum'],
+                        "th_fee"=>round($info['sale_price']*$info['thnum'],2),
+                        "thCode"=>$info['returnCode'],
+                        "spuCode"=>$info['spuCode'],
+                        "good_name"=>$info['good_name'],
+                        "cat_id"=>$info['cat_id'],
+                        "apply_id"=>$info['sr_apply_id'],
+                        "apply_name"=>$info['sr_apply_name'],
+                        "addtime"=>$date,
+                        "status"=>1,
+                        "is_del"=>0
+                    ];
+                    $inse=Db::name("th_data")->insert($data);
+                    if($inse==false){
+                        throw new Exception('退货单更新失败');
+//                        return json_show(1004,"退货单更新失败");
+                    }
                 //修改状态,添加待办
                 ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
                     "order_code" => $info['returnCode'],//单号
@@ -419,14 +463,14 @@ class ReorderChild extends Base
                 if ($uap == false) throw new Exception('销售单订单更新失败');
 
                 if ($old_status != $order['status']) {
-                    ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
+                    ActionLog::logAdd(['id' => $info['sr_apply_id'], 'nickname' =>$info['sr_apply_name']], [
                         "order_code" => $order["orderCode"],//出库单号
                         "status" => $old_status,//这里的status是之前的值
                         "action_remark" => '',//备注
                         "action_type" => "status"//新建create,编辑edit,更改状态status
                     ], "XSQRD", $order['status'], $order);
 
-                    ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
+                    ProcessOrder::AddProcess(['id' => $info['sr_apply_id'], 'nickname' =>$info['sr_apply_name']], [
                         "order_type" => 'XSQRD',
                         "order_code" => $order["orderCode"],//出库单号
                         "order_id" => $order["id"],

+ 42 - 6
app/admin/controller/Report.php

@@ -499,6 +499,8 @@ class Report extends Base
             'cbaddtime_end_date' => '',
             'supplier' => '',
             'creater' => '',
+            'good_name' => '',
+            'apply_name' => '',
             'page' => 1,
             'size' => 15,
         ], 'post', 'trim');
@@ -519,6 +521,8 @@ class Report extends Base
         if ($param['supplier'] != '') $where[] = ['cb.supplierNo|cb.supplierName', 'like', '%' . $param['supplier'] .'%'];
         if ($param['creater'] != '') $where[] = ['cb.creater', 'like', '%' . $param['creater'] . '%'];
         if ($param['zxNo'] != '') $where[] = ['cb.infoNo', 'like', '%' . $param['zxNo'] . '%'];
+        if ($param['good_name'] != '') $where[] = ['cb.good_name', 'like', '%' . $param['good_name'] . '%'];
+        if ($param['apply_name'] != '') $where[] = ['co.salesman', 'like', '%' . $param['apply_name'] . '%'];
 
 
         $count = Db::name('consult_bids')
@@ -590,6 +594,8 @@ class Report extends Base
             'cbaddtime_end_date' => '',
             'supplier' => '',
             'creater' => '',
+            'good_name' => '',
+            'apply_name' => '',
             'page' => 1,
             'size' => 15,
         ], 'post', 'trim');
@@ -613,7 +619,8 @@ class Report extends Base
         if ($param['cbaddtime_start_date'] != '' && $param['cbaddtime_end_date'] != '') $rs->whereBetween('cb.addtime', [$param['cbaddtime_start_date'] . ' 00:00:00', $param['cbaddtime_end_date'] . ' 23:59:59']);
         if ($param['supplier'] != '') $rs->whereLike('cb.supplierNo|s.name', '%' . $param['supplier'] . '%');
         if ($param['creater'] != '') $rs->whereLike('cb.creater', '%' . $param['creater'] . '%');
-
+        if ($param['good_name'] != '') $where[] = ['cb.good_name', 'like', '%' . $param['good_name'] . '%'];
+        if ($param['apply_name'] != '') $where[] = ['co.salesman', 'like', '%' . $param['apply_name'] . '%'];
 
         $data = $rs
             ->field('ci.addtime as 咨询时间,cb.bidNo as 采购单反馈单号,cb.infoNo as 咨询订单号,cb.addtime as 回复时间,cb.good_name as 产品名称,cb.supplierName as 供应商名称,cb.total_fee 成本合计,cb.delivery_day 物流时间,cb.work_day 产品工期,cb.expire_day 信息有效期,cb.creater 采购员,"" 采购员所属部门,ci.num 需求数量,ci.arrival_time 要求到货日期,co.salesman 业务人员,"" 业务人员所属部门,"" 客户名称,co.khNo,cb.createrid,co.saleid')
@@ -656,6 +663,9 @@ class Report extends Base
             'end_date' => '',
             'start_updatetime' => '',
             'end_updatetime' => '',
+            "apply_name"=>"",
+            "status"=>"",
+            "depart"=>"",
             'page' => 1,
             'size' => 15,
         ], 'post', 'trim');
@@ -673,9 +683,15 @@ class Report extends Base
 
         if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['ci.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
         if ($param['companyName'] != '') $where[] = ['csi.companyName', 'like', '%' . $param['companyName'] . '%'];
+        if ($param['apply_name'] != '') $where[] = ['co.salesman', 'like', '%' . $param['apply_name'] . '%'];
+        if ($param['status'] != '') $where[] = ['ci.status', '=',  $param['status']];
+        if ($param['departid'] != ''){
+//        	$uarr =get_company_item_user_by_name($param['dapart']);
+        	$where[] = ['co.depart', '=', $param['departid']];
+        }
         if ($param['start_updatetime'] != '' && $param['end_updatetime'] != '') $where[] = ['ci.updatetime', 'between', [$param['start_updatetime'] . ' 00:00:00', $param['end_updatetime'] . ' 23:59:59']];
 
-        $status = [1 => '招标进行中', 2 => '招标已结束', 3 => '等待议价结果', 4 => '确认商品', 5 => '成功转单', 6 => '取消转单', 7 => '招标已暂停'];
+        $status = [1 => '招标进行中', 2 => '招标已结束', 3 => '等待议价结果', 4 => '确认商品', 5 => '成功转单', 6 => '超时已关闭', 7 => '招标已暂停'];
 
         $count = Db::name('consult_info')
             ->alias('ci')
@@ -689,7 +705,7 @@ class Report extends Base
 
         $data = Db::name('consult_info')
             ->alias('ci')
-            ->field('ci.infoNo zxNo,ci.good_name,ci.num,csi.companyName,ci.addtime,ci.arrival_time endtime,ci.updatetime,ci.status')
+            ->field('ci.infoNo zxNo,ci.good_name,ci.num,csi.companyName,ci.addtime,ci.arrival_time endtime,ci.updatetime,ci.status,co.salesman,co.saleid')
             ->leftJoin('consult_bids cb', 'cb.infoNo=ci.infoNo')
             ->leftJoin('consult_order co', 'co.zxNo=ci.zxNo')
             ->leftJoin('customer_info csi', 'csi.companyNo=co.khNo')
@@ -702,6 +718,10 @@ class Report extends Base
             })
             ->select()
             ->toArray();
+        $deparuid =get_company_name_by_uid(array_unique(array_column($data,"saleid")));
+        foreach ($data as &$v) {
+            $v['depart']=$deparuid[$v['saleid']]??"";
+        }
 
         return json_show(0, '请求成功', ['list' => $data, 'count' => $count]);
 
@@ -718,6 +738,9 @@ class Report extends Base
             'end_date' => '',
             'start_updatetime' => '',
             'end_updatetime' => '',
+            "apply_name"=>"",
+            "status"=>"",
+            "depart"=>"",
         ], 'post', 'trim');
 
         $val_params = Validate::rule([
@@ -734,12 +757,19 @@ class Report extends Base
         if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['ci.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
         if ($param['companyName'] != '') $where[] = ['csi.companyName', 'like', '%' . $param['companyName'] . '%'];
         if ($param['start_updatetime'] != '' && $param['end_updatetime'] != '') $where[] = ['ci.updatetime', 'between', [$param['start_updatetime'] . ' 00:00:00', $param['end_updatetime'] . ' 23:59:59']];
-
-        $status = [1 => '招标进行中', 2 => '招标已结束', 3 => '等待议价结果', 4 => '确认商品', 5 => '成功转单', 6 => '取消转单', 7 => '招标已暂停'];
+        if ($param['apply_name'] != '') $where[] = ['co.salesman', 'like', '%' . $param['apply_name'] . '%'];
+        if ($param['status'] != '') $where[] = ['ci.status', '=',  $param['status']];
+        if ($param['departid'] != ''){
+//        	$uarr =get_company_item_user_by_name($param['dapart']);
+        	$where[] = ['co.createrid', '=', $param['departid']];
+        }
+        $status = [1 => '招标进行中', 2 => '招标已结束', 3 => '等待议价结果', 4 => '确认商品', 5 => '成功转单', 6 => '超时已关闭', 7 => '招标已暂停'];
 
         $data = Db::name('consult_info')
             ->alias('ci')
-            ->field('ci.infoNo 竞价订单号,ci.good_name 商品名称,ci.num 需求数量,csi.companyName 客户名称,ci.addtime 创建时间,ci.arrival_time 截止时间,ci.updatetime 结束时间,ci.status 状态')
+            ->field('ci.infoNo 竞价订单号,ci.good_name 商品名称,
+            ci.num 需求数量,csi.companyName 客户名称,ci.addtime 创建时间,ci.arrival_time 截止时间,ci.updatetime 结束时间,
+            ci.status 状态,co.creater 业务人员,co.createrid 部门')
             ->leftJoin('consult_bids cb', 'cb.infoNo=ci.infoNo')
             ->leftJoin('consult_order co', 'co.zxNo=ci.zxNo')
             ->leftJoin('customer_info csi', 'csi.companyNo=co.khNo')
@@ -753,6 +783,12 @@ class Report extends Base
             ->toArray();
 
         if (empty($data)) $data[] = ['没有可供导出的数据'];
+        else{
+        	$deparuid =get_company_name_by_uid(array_unique(array_column($data,"部门")));
+        foreach ($data as &$v) {
+            $v['部门']=$deparuid[$v['部门']]??"";
+        }
+        }
 
         $headerArr = array_keys($data[0]);
         excelSave('咨询单报表-未采反信息' . date('YmdHis'), $headerArr, $data);