wugg 1 anno fa
parent
commit
28e3f7af19

+ 17 - 1
app/admin/controller/After.php

@@ -1502,7 +1502,23 @@ class After extends Base
                                     ->update();
                             }
                         }
-
+						 $data = [
+                            "orderCode" => $info['orderCode'],
+                            "th_type" => 2,
+                            "th_num" => $info['error_num'],
+                            "th_fee" => round($info['error_num'] * $sale['sale_price'], 2),
+                            "thCode" => $info['returnCode'],
+                            "spuCode" => $sale['good_code'],
+                            "good_name" => $sale['good_name'],
+                            "cat_id" => $sale['cat_id'],
+                            "apply_id" => $info['apply_id'],
+                            "apply_name" => $info['apply_name'],
+                            "addtime" => $info['updatetime'],
+                            "status" => 1,
+                            "is_del" => 0
+                        ];
+                        $inse = Db::name("th_data")->insert($data);
+                        if ($inse == false) throw new Exception('退回单更新失败');
                     }
 
                     Db::commit();

+ 18 - 2
app/admin/controller/AfterChild.php

@@ -182,7 +182,7 @@ class AfterChild extends Base
 
         $order_return = Db::name('order_return')
             ->alias('a')
-            ->field('a.id,a.good_code,a.outCode,b.orderCode,c.is_stock,c.order_type,a.status')
+            ->field('a.id,a.good_code,a.good_name,c.sale_price,c.cat_id,a.apply_id,a.apply_name,a.outCode,b.orderCode,c.is_stock,c.order_type,a.status')
             ->leftJoin('order_out b', 'b.outCode=a.outCode AND b.is_del=0')
             ->leftJoin('sale c', 'c.orderCode=b.orderCode AND c.is_del=0')
             ->where(['a.is_del' => 0, 'a.returnCode' => $param['returnCode']])
@@ -608,7 +608,23 @@ class AfterChild extends Base
             Db::name('order_return_prepare')
                 ->where(['is_del' => 0, 'status' => 1, 'id' => array_column($info, 'id')])
                 ->update(['updatetime' => $date, 'status' => 3]);
-
+			 $data = [
+                            "orderCode" => $order_return['orderCode'],
+                            "th_type" => 2,
+                            "th_num" => $order_return['error_num'],
+                            "th_fee" => round($order_return['error_num'] * $order_return['sale_price'], 2),
+                            "thCode" => $order_return['returnCode'],
+                            "spuCode" => $order_return['good_code'],
+                            "good_name" => $order_return['good_name'],
+                            "cat_id" => $order_return['cat_id'],
+                            "apply_id" => $order_return['apply_id'],
+                            "apply_name" => $order_return['apply_name'],
+                            "addtime" =>$date,
+                            "status" => 1,
+                            "is_del" => 0
+                        ];
+                        $inse = Db::name("th_data")->insert($data);
+                        if ($inse == false) throw new Exception('退回单更新失败');
             Db::commit();
             return json_show(0, '库管收货成功');
         } catch (Exception $exception) {

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

@@ -1091,6 +1091,7 @@ class Sale extends Base
                     "customized" => $zxinfo['work_day'],
                     "tax" => $zxinfo['tax'],
                     "supplierNo" => $zxinfo["supplierNo"],
+                    "supplierName" =>$supplier_temp_info['name'],
                     "is_auth" => 0,
                     "craft_desc" => $zxinfo['good_name'],
                     "good_remark" => "",
@@ -1111,6 +1112,7 @@ class Sale extends Base
                     "pay_way" => $zxinfo['pay_way'],
                     "send_way" => $zxinfo['send_way'],
                     "companyNo" => $companyNo,
+                    "companyName" =>$companyinfo['data'][$companyNo]??"",
                     "status" => 1,
                     "is_del" => 0,
                     "createrid" => $zxinfo['createrid'],

+ 12 - 11
app/admin/controller/SaleReport.php

@@ -668,7 +668,7 @@ class SaleReport extends Base
             if (!isset($customer2_tmp[$value['customer_code']])) {
                 $temp = $userCommon->handle('cInfo', ['companyNo' => $value['customer_code']]);
                 $customer2_tmp[$value['customer_code']] = [
-                    'itemid' => $temp['data']['itemid'],
+                    'itemid' => $temp['data']['itemid']??"",
                     'companyName' => $temp['data']['companyName'],
                 ];
             }
@@ -676,7 +676,7 @@ class SaleReport extends Base
             $value['companyName'] = $customer2_tmp[$value['customer_code']]['companyName'];
 
             if (!empty($value['itemid'])) {
-                $customer_org1 = array_column(get_top_customer_org($value['itemid']), 'name', 'level');
+                $customer_org1 = array_column(get_top_customer_org($value['itemid'])??[], 'name', 'level');
                 $value['first_customer_org'] = isset($customer_org1[1]) ? $customer_org1[1] : '';
                 $value['second_customer_org'] = isset($customer_org1[2]) ? $customer_org1[2] : '';
             }
@@ -732,13 +732,13 @@ class SaleReport extends Base
             ->cursor();
 
         $userCommon = \app\admin\common\User::getIns();
-        $list = $customer2_tmp = $company_tmp = [];
+        $list = $customer2_tmp = $company_tmp =$depart= [];
         foreach ($data as $value) {
 
             if (!isset($customer2_tmp[$value['customer_code']])) {
                 $temp = $userCommon->handle('cInfo', ['companyNo' => $value['customer_code']]);
                 $customer2_tmp[$value['customer_code']] = [
-                    'itemid' => $temp['data']['itemid'],
+                    'itemid' => $temp['data']['itemid']??"",
                     'companyName' => $temp['data']['companyName'],
                 ];
             }
@@ -746,11 +746,15 @@ class SaleReport extends Base
             $value['客户名称'] = $customer2_tmp[$value['customer_code']]['companyName'];
 
             if (!empty($value['itemid'])) {
-                $customer_org1 = array_column(get_top_customer_org($value['itemid']), 'name', 'level');
+                $customer_org1 = array_column(get_top_customer_org($value['itemid'])??[], 'name', 'level');
                 $value['一级企业'] = isset($customer_org1[1]) ? $customer_org1[1] : '';
                 $value['二级企业'] = isset($customer_org1[2]) ? $customer_org1[2] : '';
             }
 
+	        if (!isset($depart[$value['apply_id']])) {
+		        $depart[$value['apply_id']] =get_company_name_by_uid($value['apply_id']);
+	        }
+	        $value['创建人所属部门'] = $depart[$value['apply_id']] ?? '';
             if ($value['order_type'] == 3 || $value['order_type'] == 4) $value['单位'] = Db::name("good_zixun")->alias('gz')
                 ->leftJoin('unit u', 'u.id=gz.good_unit')->where(["gz.spuCode" => $value['good_code'], "gz.is_del" => 0])->value('u.unit');
             else $value['单位'] = Db::name('good_basic')->alias('gb')->leftJoin('unit u', 'u.id=gb.good_unit')->where(["gb.spuCode" => $value['good_code'], "gb.is_del" => 0])->value('u.unit');
@@ -761,17 +765,12 @@ class SaleReport extends Base
             unset($value['itemid']);
             unset($value['good_code']);
             unset($value['order_type']);
-//            unset($value['apply_id']);
+            unset($value['apply_id']);
             unset($value['customer_code']);
 
             $list[] = $value;
         }
 
-        $all_company = get_company_name_by_uid(array_values($company_tmp));
-        foreach ($list as &$val) {
-            $val['创建人所属部门'] = $all_company[$val['apply_id']] ?? '';
-            unset($val['apply_id']);
-        }
 
         unset($customer2_tmp);
         unset($company_tmp);
@@ -1991,6 +1990,7 @@ class SaleReport extends Base
             ->leftJoin("order_send os", "os.outCode=a.outCode")
             ->leftJoin("purchease_order d", "d.cgdNo=os.cgdNo")
             ->order("a.addtime desc")
+            ->where($where)
             ->count('a.id');
 
         $data = Db::name('order_out')
@@ -2000,6 +2000,7 @@ class SaleReport extends Base
             ->leftJoin("order_send os", "os.outCode=a.outCode")
             ->leftJoin("purchease_order d", "d.cgdNo=os.cgdNo")
             ->page($param['page'], $param['size'])
+            ->where($where)
             ->order("a.addtime desc")
             ->cursor();