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

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

wugg 1 год назад
Родитель
Сommit
78411ca1ba
3 измененных файлов с 46 добавлено и 24 удалено
  1. 22 12
      app/admin/controller/OrderOutChild.php
  2. 23 12
      app/admin/controller/Report.php
  3. 1 0
      app/admin/controller/Sale.php

+ 22 - 12
app/admin/controller/OrderOutChild.php

@@ -191,6 +191,7 @@ class OrderOutChild extends Base
             'wsm_code' => '',
             'supplierNo' => '',
             'skuCode' => '',
+            'good_name' => '',
             'apply_id' => '',
             'apply_name' => '',
             'order_type' => '',
@@ -209,6 +210,7 @@ class OrderOutChild extends Base
         if ($param['outChildCode'] != '') $where[] = ['a.outChildCode', 'like', '%' . $param['outChildCode'] . '%'];
         if ($param['companyNo'] != '') $where[] = ['a.companyNo', 'like', '%' . $param['companyNo'] . '%'];
         if ($param['spuCode'] != '') $where[] = ['a.spuCode', 'like', '%' . $param['spuCode'] . '%'];
+        if ($param['good_name'] != '') $where[] = ['a.good_name', 'like', '%' . $param['good_name'] . '%'];
         if ($param['outCode'] != '') $where[] = ['a.outCode', 'like', '%' . $param['outCode'] . '%'];
         if ($param['order_source'] != '') $where[] = ['a.order_source', '=', $param['order_source']];
         if ($param['wsm_code'] != '') $where[] = ['a.wsm_code', 'like', '%' . $param['wsm_code'] . '%'];
@@ -405,10 +407,10 @@ class OrderOutChild extends Base
                 GoodStockInfo::ChildAddBn($item['outChildCode'], $wsm[$value['wsm_code']]);//维护bn号
             }
 
-            Db::name('order_out')
+           $up= Db::name('order_out')
                 ->where(['id' => $info['id'], 'is_del' => 0, 'outCode' => $param['outCode'], 'send_status' => 1])
-                ->update(['send_status' => 2, 'status' => 1]);
-
+                ->update(['send_status' => 2, 'status' => 1,"updatetime"=>date("Y-m-d H:i:s")]);
+			if($up==false) throw new \Exception("发货单更新失败");
             Db::commit();
             return json_show(0, '分单完成');
         } catch (Exception $exception) {
@@ -427,10 +429,18 @@ class OrderOutChild extends Base
 
         $info = Db::name('order_out_child')
             ->alias('a')
-            ->field('a.*,b.name wsm_name,b.contactor,b.contactor_name')
+            ->field('a.*,b.name wsm_name,b.contactor,b.contactor_name,c.addr,c.addr_code,c.contactor addr_contactor,c.mobile addr_mobile')
             ->leftJoin('warehouse_info b', 'b.wsm_code=a.wsm_code')
+            ->leftJoin('order_addr c', 'c.id=a.addrid')
             ->where(['a.is_del' => 0, 'a.outChildCode' => $outChildCode])
             ->findOrEmpty();
+
+           if ($info['addr_code'] != "") {
+                    $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
+                    list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $info['addr_code']);
+                    $addr = GetAddr(json_encode($place));
+                    $info['addr'] = $addr.$info['addr'];
+           }
         //校验是否开通了供应商账号
         $supp_account = checkHasAccountBySupplierNos([$info['supplierNo']]);
 		$info['remark'] = Db::name("sale")->where(["orderCode"=>$info['orderCode']])->value("remark",'');
@@ -541,7 +551,7 @@ class OrderOutChild extends Base
                 //工单
                 if (!isset($child[$value['outChildCode']])) throw new Exception($value['outChildCode'] . '工单不存在或状态不允许发货');
 
-                Db::name('order_out_child')
+              $up=  Db::name('order_out_child')
                     ->where(['id' => $child[$value['outChildCode']]['id'], 'is_del' => 0, 'status' => 1])
                     ->update([
                         'post_name' => $value['post_name'],
@@ -551,7 +561,7 @@ class OrderOutChild extends Base
                         'sendtime' => $date,
                         'updatetime' => $date,
                     ]);
-
+				if($up==false) throw new \Exception("发货工单更新失败");
                 //修改状态,添加待办
                 ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
                     "order_code" => $value['outChildCode'],//单号
@@ -584,7 +594,7 @@ class OrderOutChild extends Base
 				}
                 //发货单
                 //send_status 3部分发货,4全部发货
-                Db::name('order_out')
+             $our_up=   Db::name('order_out')
                     ->where(['id' => $order_out[$child[$value['outChildCode']]['outCode']]['id']])
                     ->update([
                     	'send_status' => $order_out[$child[$value['outChildCode']]['outCode']]['already_send_num'] >= $order_out[$child[$value['outChildCode']]['outCode']]['send_num'] ? 4 : 3,
@@ -595,7 +605,7 @@ class OrderOutChild extends Base
                     	'updatetime' => $date,
                     	'sendtime' => $date
                     	 ]);
-
+				if($our_up==false) throw new \Exception("发货单更新失败");
                 $sale[$child[$value['outChildCode']]['orderCode']]['send_num'] += $child[$value['outChildCode']]['num'];
                 $sale[$child[$value['outChildCode']]['orderCode']]['wsend_num'] -= $child[$value['outChildCode']]['num'];
 
@@ -631,10 +641,10 @@ class OrderOutChild extends Base
                 elseif ($sale_update_data['send_num'] == 0) $sale_update_data['status'] = 0;
                 else $sale_update_data['status'] = 1;
 
-                Db::name('sale')
+               $sale_up = Db::name('sale')
                     ->where(['is_del' => 0, 'id' => $sale[$child[$value['outChildCode']]['orderCode']]['id']])
                     ->update($sale_update_data);
-
+				if($sale_up==false) throw new \Exception("销售单更新失败");
                 if ($sale[$child[$value['outChildCode']]['orderCode']]['order_source'] == 5 && $send_status == 3) {
                     $yz_tmp[] = [
                         'post_name' => $value['post_name'],
@@ -662,12 +672,12 @@ class OrderOutChild extends Base
                 ]);
 
                 //库存
-                Db::name('good_stock')
+               $stock_up= Db::name('good_stock')
                     ->data(['updatetime' => $date])
                     ->where(['is_del' => 0, 'spuCode' => $sale[$child[$value['outChildCode']]['orderCode']]['good_code'], 'wsm_code' => $child[$value['outChildCode']]['wsm_code']])
                     ->dec('wait_out_stock', $child[$value['outChildCode']]['num'])
                     ->update();
-
+				if($stock_up==false) throw new \Exception("商品库存数更新失败");
             }
 
             //日志、待办已办……

+ 23 - 12
app/admin/controller/Report.php

@@ -626,14 +626,23 @@ class Report extends Base
             ->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')
             ->leftJoin('consult_info ci', 'ci.infoNo=cb.infoNo')
             ->leftJoin('consult_order co', 'co.zxNo=cb.zxNo')
+	        ->where($where)
             ->cursor();
 
 
         $list = [];
         $supplier=[];
+        $depart=[];
+
         foreach ($data as $value) {
-            $value['采购员所属部门'] = get_company_name_by_uid($value['createrid']);
-            $value['业务人员所属部门'] = get_company_name_by_uid($value['saleid']);
+        	if(!isset($depart[$value['createrid']])){
+        		$depart[$value['createrid']]=get_company_name_by_uid($value['createrid']);
+	        }
+	        if(!isset($depart[$value['saleid']])){
+		        $depart[$value['saleid']]=get_company_name_by_uid($value['saleid']);
+	        }
+            $value['采购员所属部门'] = $depart[$value['createrid']];
+            $value['业务人员所属部门'] = $depart[$value['saleid']];
             if(!isset($supplier[$value['khNo']])){
 	            $userCommon = \app\admin\common\User::getIns();
 	            $supplier_temp = $userCommon->handle('getCodeAndName', ['code' => $value['khNo']]);
@@ -665,7 +674,7 @@ class Report extends Base
             'end_updatetime' => '',
             "apply_name"=>"",
             "status"=>"",
-            "depart"=>"",
+            "departid"=>"",
             'page' => 1,
             'size' => 15,
         ], 'post', 'trim');
@@ -740,7 +749,7 @@ class Report extends Base
             'end_updatetime' => '',
             "apply_name"=>"",
             "status"=>"",
-            "depart"=>"",
+            "departid"=>"",
         ], 'post', 'trim');
 
         $val_params = Validate::rule([
@@ -769,7 +778,7 @@ class Report extends Base
             ->alias('ci')
             ->field('ci.infoNo 竞价订单号,ci.good_name 商品名称,
             ci.num 需求数量,csi.companyName 客户名称,ci.addtime 创建时间,ci.arrival_time 截止时间,ci.updatetime 结束时间,
-            ci.status 状态,co.creater 业务人员,co.createrid 部门')
+            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')
@@ -781,17 +790,19 @@ class Report extends Base
             })
             ->select()
             ->toArray();
-
-        if (empty($data)) $data[] = ['没有可供导出的数据'];
+//		echo Db::name('consult_info')->getLastSql();
+        if (empty($data)) $list[] = ['没有可供导出的数据'];
         else{
         	$deparuid =get_company_name_by_uid(array_unique(array_column($data,"部门")));
-        foreach ($data as &$v) {
-            $v['部门']=$deparuid[$v['部门']]??"";
-        }
+        	$list=[];
+	        foreach ($data as &$v) {
+	            $v['部门']=$deparuid[$v['部门']]??"";
+	            $list[]=$v;
+	        }
         }
 
-        $headerArr = array_keys($data[0]);
-        excelSave('咨询单报表-未采反信息' . date('YmdHis'), $headerArr, $data);
+        $headerArr = array_keys($list[0]);
+        excelSave('咨询单报表-未采反信息' . date('YmdHis'), $headerArr, $list);
 
 
     }

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

@@ -3714,6 +3714,7 @@ class Sale extends Base
         $codeinfo['order_source'] = $item['order_source'];
         $orderReturn = Db::name("order_return")->where(["outCode" => $outCode, "is_del" => 0])->order("id desc")->find();
         $codeinfo['order_return'] = $orderReturn;
+        $codeinfo['platform_order'] = $item['platform_order'];
 
         //获取销售订单对应的供应商是否有启用账号
         $codeinfo['has_account'] = 0;