Browse Source

内部使用oa后台

gogs 1 year ago
parent
commit
0b5bc7e4bf
100 changed files with 0 additions and 9150 deletions
  1. 0 74
      app/Http/Controllers/Api/BasicTypeController.php
  2. 0 86
      app/Http/Controllers/Api/BookingListController.php
  3. 0 34
      app/Http/Controllers/Api/CheckController.php
  4. 0 242
      app/Http/Controllers/Api/ConstructionController.php
  5. 0 73
      app/Http/Controllers/Api/ContactsController.php
  6. 0 100
      app/Http/Controllers/Api/CustomerController.php
  7. 0 22
      app/Http/Controllers/Api/DataSyncToU8Controller.php
  8. 0 71
      app/Http/Controllers/Api/DeleteController.php
  9. 0 49
      app/Http/Controllers/Api/DouShopController.php
  10. 0 35
      app/Http/Controllers/Api/ExcelController.php
  11. 0 22
      app/Http/Controllers/Api/ExportFileController.php
  12. 0 74
      app/Http/Controllers/Api/FollowUpRecordController.php
  13. 0 61
      app/Http/Controllers/Api/HeaderWordController.php
  14. 0 42
      app/Http/Controllers/Api/IOController.php
  15. 0 48
      app/Http/Controllers/Api/ImportController.php
  16. 0 74
      app/Http/Controllers/Api/InvoiceOrderController.php
  17. 0 53
      app/Http/Controllers/Api/OperationLogController.php
  18. 0 85
      app/Http/Controllers/Api/PaymentReceiptController.php
  19. 0 77
      app/Http/Controllers/Api/ProductActivityController.php
  20. 0 155
      app/Http/Controllers/Api/ProductController.php
  21. 0 76
      app/Http/Controllers/Api/ProductInventoryController.php
  22. 0 76
      app/Http/Controllers/Api/PurchaseOrderController.php
  23. 0 87
      app/Http/Controllers/Api/PurchaseOrderSpecialController.php
  24. 0 22
      app/Http/Controllers/Api/RangeController.php
  25. 0 74
      app/Http/Controllers/Api/ReturnExchangeOrderController.php
  26. 0 125
      app/Http/Controllers/Api/SalesOrderController.php
  27. 0 155
      app/Http/Controllers/Api/ScheduleController.php
  28. 0 74
      app/Http/Controllers/Api/SportsBagController.php
  29. 0 76
      app/Http/Controllers/Api/StorehouseController.php
  30. 0 74
      app/Http/Controllers/Api/SupplierController.php
  31. 0 35
      app/Http/Controllers/Api/TableHeadController.php
  32. 0 74
      app/Http/Controllers/Api/TakeOrderController.php
  33. 0 74
      app/Http/Controllers/Api/TechnologyController.php
  34. 0 45
      app/Model/BasicType.php
  35. 0 38
      app/Model/BookingList.php
  36. 0 17
      app/Model/BookingListInfo.php
  37. 0 46
      app/Model/Construction.php
  38. 0 13
      app/Model/ConstructionFile.php
  39. 0 20
      app/Model/ConstructionInfo.php
  40. 0 13
      app/Model/ConstructionProductInfo.php
  41. 0 40
      app/Model/DeliveryNote.php
  42. 0 19
      app/Model/EmployeeFoursShop.php
  43. 0 14
      app/Model/EmployeeManagerDepart.php
  44. 0 19
      app/Model/EmployeeMenuPermission.php
  45. 0 19
      app/Model/FollowUpRecord.php
  46. 0 17
      app/Model/FollowUpRecordFile.php
  47. 0 11
      app/Model/InOutRecord.php
  48. 0 23
      app/Model/InvoiceOrder.php
  49. 0 13
      app/Model/InvoiceOrderInfo.php
  50. 0 73
      app/Model/OrderOperation.php
  51. 0 42
      app/Model/PaymentReceipt.php
  52. 0 24
      app/Model/PaymentReceiptInfo.php
  53. 0 50
      app/Model/Product.php
  54. 0 18
      app/Model/ProductActivity.php
  55. 0 13
      app/Model/ProductActivityPrice.php
  56. 0 11
      app/Model/ProductCategory.php
  57. 0 19
      app/Model/ProductInfo.php
  58. 0 13
      app/Model/ProductIntroduction.php
  59. 0 11
      app/Model/ProductInventory.php
  60. 0 20
      app/Model/ProductInventorySet.php
  61. 0 13
      app/Model/ProductPriceDetail.php
  62. 0 19
      app/Model/ProductRange.php
  63. 0 40
      app/Model/PurchaseOrder.php
  64. 0 17
      app/Model/PurchaseOrderFile.php
  65. 0 21
      app/Model/PurchaseOrderInfo.php
  66. 0 22
      app/Model/PurchaseOrderSpecial.php
  67. 0 21
      app/Model/PurchaseOrderSpecialInfo.php
  68. 0 48
      app/Model/ReturnExchangeOrder.php
  69. 0 19
      app/Model/ReturnExchangeOrderProductInfo.php
  70. 0 19
      app/Model/ReturnExchangeOrderRange.php
  71. 0 108
      app/Model/SalesOrder.php
  72. 0 30
      app/Model/SalesOrderInfo.php
  73. 0 13
      app/Model/SalesOrderOtherFee.php
  74. 0 13
      app/Model/SalesOrderProductInfo.php
  75. 0 21
      app/Model/SalesOrderRange.php
  76. 0 12
      app/Model/Schedule.php
  77. 0 13
      app/Model/ScheduleDetail.php
  78. 0 15
      app/Model/ScheduleInfo.php
  79. 0 42
      app/Model/SeeRange.php
  80. 0 20
      app/Model/Setting.php
  81. 0 12
      app/Model/SportsBag.php
  82. 0 13
      app/Model/SportsBagProductInfo.php
  83. 0 19
      app/Model/SportsBagRange.php
  84. 0 11
      app/Model/Storehouse.php
  85. 0 19
      app/Model/StorehouseEmployee.php
  86. 0 14
      app/Model/Supplier.php
  87. 0 19
      app/Model/SupplierInfo.php
  88. 0 14
      app/Model/TableSetting.php
  89. 0 20
      app/Model/TakeOrder.php
  90. 0 13
      app/Model/TakeOrderInfo.php
  91. 0 19
      app/Model/Team.php
  92. 0 35
      app/Model/U8Job.php
  93. 0 587
      app/Model/UseScopeBaseModel.php
  94. 0 267
      app/Service/BasicTypeService.php
  95. 0 255
      app/Service/BookingListService.php
  96. 0 1580
      app/Service/CheckService.php
  97. 0 1216
      app/Service/ConstructionService.php
  98. 0 318
      app/Service/ContactsService.php
  99. 0 38
      app/Service/CustomerPondService.php
  100. 0 995
      app/Service/CustomerService.php

+ 0 - 74
app/Http/Controllers/Api/BasicTypeController.php

@@ -1,74 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\BasicTypeService;
-use Illuminate\Http\Request;
-
-class BasicTypeController extends BaseController
-{
-    public function basicTypeAdd(Request $request)
-    {
-        $service = new BasicTypeService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->basicTypeAdd($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function basicTypeEdit(Request $request)
-    {
-        $service = new BasicTypeService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->basicTypeEdit($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function basicTypeDel(Request $request)
-    {
-        $service = new BasicTypeService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->basicTypeDel($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function basicTypeList(Request $request)
-    {
-        $service = new BasicTypeService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->basicTypeList($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function basicTypeCustomerList(Request $request)
-    {
-        $service = new BasicTypeService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->basicTypeCustomerList($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 86
app/Http/Controllers/Api/BookingListController.php

@@ -1,86 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\BookingListService;
-use Illuminate\Http\Request;
-
-class BookingListController extends BaseController
-{
-    //金额记账
-    public function customerAdd(Request $request)
-    {
-        $service = new BookingListService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->customerAdd($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function customerEdit(Request $request)
-    {
-        $service = new BookingListService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->customerEdit($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function customerDel(Request $request)
-    {
-        $service = new BookingListService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->customerDel($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function customerList(Request $request)
-    {
-        $service = new BookingListService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->customerList($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function customerDetail(Request $request)
-    {
-        $service = new BookingListService();
-        list($status,$data) = $service->customerDetail($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function customerConfirm(Request $request)
-    {
-        $service = new BookingListService();
-        list($status,$data) = $service->customerConfirm($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 34
app/Http/Controllers/Api/CheckController.php

@@ -1,34 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\CheckService;
-use Illuminate\Http\Request;
-
-class CheckController extends BaseController
-{
-    public function checkAll(Request $request)
-    {
-        $service = new CheckService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->checkAll($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function getOrderDetail(Request $request){
-        $service = new CheckService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->getOrderDetail($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 242
app/Http/Controllers/Api/ConstructionController.php

@@ -1,242 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\ConstructionService;
-use Barryvdh\DomPDF\Facade\Pdf;
-use Illuminate\Http\Request;
-
-class ConstructionController extends BaseController
-{
-    public function constructionAdd(Request $request)
-    {
-        $service = new ConstructionService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->constructionAdd($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function constructionEdit(Request $request)
-    {
-        $service = new ConstructionService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->constructionEdit($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function constructionDel(Request $request)
-    {
-        $service = new ConstructionService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->constructionDel($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function constructionList(Request $request)
-    {
-        $service = new ConstructionService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->constructionList($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function constructionDetail(Request $request)
-    {
-        $service = new ConstructionService();
-        list($status,$data) = $service->detail($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function constructionGet(Request $request)
-    {
-        $service = new ConstructionService();
-        list($status,$data) = $service->constructionGet($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-
-    public function deliveryNoteList(Request $request)
-    {
-        $service = new ConstructionService();
-        list($status,$data) = $service->deliveryNoteList($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function deliveryNoteDetail(Request $request)
-    {
-        $service = new ConstructionService();
-        list($status,$data) = $service->deliveryNoteDetail($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-
-    public function deliveryNoteEdit(Request $request)
-    {
-        $service = new ConstructionService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->deliveryNoteEdit($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function deliveryNoteDel(Request $request)
-    {
-        $service = new ConstructionService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->deliveryNoteDel($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function constructionPdf(Request $request)
-    {
-        $service = new ConstructionService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->constructionPdf($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function constructionOperation(Request $request)
-    {
-        $service = new ConstructionService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->constructionOperation($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function show(Request $request){
-        $construction = [
-          "id" => 45,
-          "model_type" => 1,
-          "order_number" => "WO0.202404021158317949",
-          "title" => "cs",
-          "customer_id" => 0,
-          "customer_contact_id" => 0,
-          "install_method" => 195,
-          "install_position" => 205,
-          "sales_order_id" => 170,
-          "construction_fee" => "26.82",
-          "service_price" => "0.00",
-          "crt_id" => 91,
-          "del_time" => 0,
-          "crt_time" => "2024-04-02 11:58:52",
-          "upd_time" => "1712913661",
-          "mark" => "",
-          "construction_time" => 0,
-          "handover_time" => "",
-          "urgency" => 0,
-          "state" => 2,
-          "pq_state" => 1,
-          "address1" => "",
-          "address2" => "",
-          "introduction" => "",
-          "depart_id" => 46,
-          "top_depart_id" => 2,
-          "storehouse_id" => 10,
-          "start_time" => 1711987200,
-          "end_time" => 1711987200,
-          "schedule_id" => 19,
-          "day_stamp" => 1713715200,
-          "day_start_stamp" => 1713715200,
-          "day_end_stamp" => 1713715260,
-          "customer_title" => "",
-          "sales_order_number" => "T9XS.202404021129349107",
-          "crt_name" => "苏盈心  三部  13772835000",
-          "xt_name" => "",
-        ];
-        $product = [
-         [
-            "id" => 94,
-            "construction_id" => 45,
-            "product_id" => 4018,
-            "del_time" => 0,
-            "crt_time" => "1712210724",
-            "upd_time" => "0",
-            "number" => "1.00",
-            "mark" => "",
-            "cost" => "0.00",
-            "retail_price" => "889.00",
-            "storehouse_id" => 10,
-            "basic_type_id" => 0,
-            "price" => "889.00",
-            "final_amount" => "893.84",
-            "count" => 1,
-            "title" => "全新智能香氛等离子系统",
-            "code" => "1000004536",
-            "size" => "Model 3/Y",
-            "unit" => "套",
-          ]
-        ];
-        $detail =  [
-            0 => "陈建斌 技术部,技术部 15372086866|高健 技术部,技术部 13388601173"
-        ];
-        $pdf = Pdf::loadView('pdf.construction', ['order' => $construction,'product'=>$product,'detail'=>$detail]);
-
-        return $pdf->stream('11.pdf');
-//        return response($pdf->output())
-//            ->header('Content-Type', 'application/pdf')
-//            ->header('Content-Disposition', 'attachment; filename="report.pdf"');
-//
-        return $pdf->download('report.pdf');
-
-        return view('pdf.construction',['order' => $construction,'product'=>$product]);
-    }
-}

+ 0 - 73
app/Http/Controllers/Api/ContactsController.php

@@ -1,73 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\ContactsService;
-use Illuminate\Http\Request;
-
-class ContactsController extends BaseController
-{
-    public function contactsAdd(Request $request)
-    {
-        $service = new ContactsService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->contactsAdd($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function contactsEdit(Request $request)
-    {
-        $service = new ContactsService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->contactsEdit($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function contactsDel(Request $request)
-    {
-        $service = new ContactsService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->contactsDel($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function contactsList(Request $request)
-    {
-        $service = new ContactsService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->contactsList($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function contactsDetail(Request $request)
-    {
-        $service = new ContactsService();
-        list($status,$data) = $service->contactsDetail($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 100
app/Http/Controllers/Api/CustomerController.php

@@ -1,100 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\CustomerService;
-use Illuminate\Http\Request;
-
-class CustomerController extends BaseController
-{
-    public function customerAdd(Request $request)
-    {
-        $service = new CustomerService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->customerAdd($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function customerEdit(Request $request)
-    {
-        $service = new CustomerService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->customerEdit($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function customerDel(Request $request)
-    {
-        $service = new CustomerService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->customerDel($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function customerList(Request $request)
-    {
-        $service = new CustomerService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->customerList($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function customerList2(Request $request)
-    {
-        $service = new CustomerService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->customerList2($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function customerDetail(Request $request)
-    {
-        $service = new CustomerService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->customerDetail($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function customerGrabbing(Request $request)
-    {
-        $service = new CustomerService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->customerGrabbing($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 22
app/Http/Controllers/Api/DataSyncToU8Controller.php

@@ -1,22 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\DataSyncToU8Service;
-use Illuminate\Http\Request;
-
-class DataSyncToU8Controller extends BaseController
-{
-    public function add(Request $request)
-    {
-        $service = new DataSyncToU8Service();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->add($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 71
app/Http/Controllers/Api/DeleteController.php

@@ -1,71 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\DeleteService;
-use Illuminate\Http\Request;
-
-class DeleteController extends BaseController
-{
-    public function getMan(Request $request)
-    {
-        $service = new DeleteService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->getMan($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function delete(Request $request)
-    {
-        $service = new DeleteService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->delete($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function fp(Request $request){
-        $service = new DeleteService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->fp($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function yj(Request $request){
-        $service = new DeleteService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->yj($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function pq(Request $request){
-        $service = new DeleteService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->pq($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 49
app/Http/Controllers/Api/DouShopController.php

@@ -1,49 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Model\BasicType;
-use App\Service\DouShopService;
-use Illuminate\Http\Request;
-
-class DouShopController extends BaseController
-{
-    public function douShopOrderList(Request $request)
-    {
-        $service = new DouShopService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->getOrderList($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function douShopOrderDetail(Request $request)
-    {
-        $service = new DouShopService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->getOrderDetail($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function insertDouOrder(Request $request)
-    {
-        $service = new DouShopService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->insertDouOrder($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 35
app/Http/Controllers/Api/ExcelController.php

@@ -1,35 +0,0 @@
-<?php
-namespace App\Http\Controllers\Api;
-
-use App\Exports\MyExport;
-use App\Service\Excel\ExcelService;
-use Illuminate\Http\Request;
-
-//导入导出
-class ExcelController extends BaseController
-{
-    /**
-     * 下载
-     * @param Request $request
-     * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
-     */
-    public function excelDownload(Request $request){
-
-        $data = $request->all();
-        $file_name = $data['file_name'];
-        $excel = new MyExport();
-        return  $excel->excelDownload($file_name);
-    }
-
-    public function excelExport(Request $request){
-        $service = new ExcelService();
-        list($status,$data) = $service->excelExport($request);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-}

+ 0 - 22
app/Http/Controllers/Api/ExportFileController.php

@@ -1,22 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\ExportFileService;
-use Illuminate\Http\Request;
-
-class ExportFileController extends BaseController
-{
-    public function exportFile(Request $request)
-    {
-        $service = new ExportFileService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->exportAll($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',['file'=>$data]);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 74
app/Http/Controllers/Api/FollowUpRecordController.php

@@ -1,74 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\FollowUpRecordService;
-use Illuminate\Http\Request;
-
-class FollowUpRecordController extends BaseController
-{
-    public function followUpRecordEdit(Request $request)
-    {
-        $service = new FollowUpRecordService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->followUpRecordEdit($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-    
-    public function followUpRecordAdd(Request $request)
-    {
-        $service = new FollowUpRecordService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->followUpRecordAdd($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-    
-    public function followUpRecordDel(Request $request)
-    {
-        $service = new FollowUpRecordService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->followUpRecordDel($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function followUpRecordList(Request $request)
-    {
-        $service = new FollowUpRecordService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->followUpRecordList($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function followUpRecordDetail(Request $request)
-    {
-        $service = new FollowUpRecordService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->followUpRecordDetail($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 61
app/Http/Controllers/Api/HeaderWordController.php

@@ -1,61 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-
-use App\Service\HeaderWord\HeaderWordHookService;
-use App\Service\ProcessService;
-use Illuminate\Http\Request;
-
-
-class HeaderWordController extends BaseController
-{
-    public function getHeaderWord(Request $request)
-    {
-        $service =  HeaderWordHookService::getInstance();
-        $data = $request->all();
-        list($status,$data) = $service->getHeaderWord($data);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function getHeaderSettings(Request $request){
-        $service =  HeaderWordHookService::getInstance();
-        $data = $request->all();
-        list($status,$data) = $service->getHeaderSettings($data);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function add(Request $request){
-        $service =  HeaderWordHookService::getInstance();
-        $data = $request->all();
-        list($status,$data) = $service->add($data);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function detail(Request $request){
-        $service =  HeaderWordHookService::getInstance();
-        $data = $request->all();
-        list($status,$data) = $service->detail($data);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 42
app/Http/Controllers/Api/IOController.php

@@ -1,42 +0,0 @@
-<?php
-namespace App\Http\Controllers\Api;
-
-use App\Exports\MyExport;
-use App\Service\IOService;
-use Illuminate\Http\Request;
-
-
-//导入导出
-class IOController extends BaseController
-{
-    /**
-     * 下载
-     * @param Request $request
-     * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
-     */
-    public function excelDownload(Request $request){
-
-        $data = $request->all();
-        $file_name = $data['file_name'];
-        $excel = new MyExport();
-        return  $excel->excelDownload($file_name);
-    }
-
-
-    public function apiExport(Request $request){
-
-
-
-//        $data = $request->all();
-
-        $service = new IOService();
-        list($status,$data) = $service->apiExport($request);
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-
-    }
-}

+ 0 - 48
app/Http/Controllers/Api/ImportController.php

@@ -1,48 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\ImportService;
-use Illuminate\Http\Request;
-
-class ImportController extends BaseController
-{
-    public function import(Request $request)
-    {
-        $service = new ImportService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->import($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function getTableTitleXls(Request $request)
-    {
-        $service = new ImportService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->getTableTitleXls($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function importAll(Request $request)
-    {
-        $service = new ImportService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->importAll($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 74
app/Http/Controllers/Api/InvoiceOrderController.php

@@ -1,74 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\InvoiceOrderService;
-use Illuminate\Http\Request;
-
-class InvoiceOrderController extends BaseController
-{
-    public function invoiceOrderAdd(Request $request)
-    {
-        $service = new InvoiceOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->add($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function invoiceOrderEdit(Request $request)
-    {
-        $service = new InvoiceOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->edit($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function invoiceOrderDetail(Request $request)
-    {
-        $service = new InvoiceOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->detail($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function invoiceOrderDel(Request $request)
-    {
-        $service = new InvoiceOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->del($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function invoiceOrderList(Request $request)
-    {
-        $service = new InvoiceOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->getList($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 53
app/Http/Controllers/Api/OperationLogController.php

@@ -1,53 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-
-use App\Service\OaService;
-use App\Service\OperationLogService;
-use Illuminate\Http\Request;
-
-
-class OperationLogController extends BaseController
-{
-
-
-
-
-
-    public function getOperationList(Request $request)
-    {
-
-
-        $service = new OperationLogService();
-        list($status,$data) = $service->getOperationList($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-    public function setOperationList(Request $request){
-        $service = new OperationLogService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->setOperationList($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-
-
-
-
-
-
-
-
-}

+ 0 - 85
app/Http/Controllers/Api/PaymentReceiptController.php

@@ -1,85 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\PaymentReceiptService;
-use Illuminate\Http\Request;
-
-class PaymentReceiptController extends BaseController
-{
-    public function paymentReceiptGet(Request $request){
-        $service = new PaymentReceiptService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->paymentReceiptGet($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function paymentReceiptAdd(Request $request)
-    {
-        $service = new PaymentReceiptService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->customerAdd($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function paymentReceiptEdit(Request $request)
-    {
-        $service = new PaymentReceiptService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->customerEdit($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function paymentReceiptDel(Request $request)
-    {
-        $service = new PaymentReceiptService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->customerDel($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function paymentReceiptList(Request $request)
-    {
-        $service = new PaymentReceiptService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->customerList($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function paymentReceiptDetail(Request $request)
-    {
-        $service = new PaymentReceiptService();
-        list($status,$data) = $service->customerDetail($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 77
app/Http/Controllers/Api/ProductActivityController.php

@@ -1,77 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-
-use App\Service\ProductActivityService;
-use Illuminate\Http\Request;
-
-class ProductActivityController extends BaseController
-{
-    public function productEdit(Request $request)
-    {
-        $service = new ProductActivityService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->productEdit($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function productAdd(Request $request)
-    {
-        $service = new ProductActivityService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->productAdd($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-    public function productDel(Request $request)
-    {
-        $service = new ProductActivityService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->productDel($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-    public function productList(Request $request)
-    {
-        $service = new ProductActivityService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->productList($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function productDetail(Request $request)
-    {
-        $service = new ProductActivityService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->productDetail($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 155
app/Http/Controllers/Api/ProductController.php

@@ -1,155 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-
-use App\Service\ProductService;
-use Illuminate\Http\Request;
-
-class ProductController extends BaseController
-{
-    public function productCategoryEdit(Request $request)
-    {
-        $service = new ProductService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->productCategoryEdit($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-    
-    public function productCategoryAdd(Request $request)
-    {
-        $service = new ProductService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->productCategoryAdd($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-    
-    public function productCategoryDel(Request $request)
-    {
-        $service = new ProductService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->productCategoryDel($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function productCategoryList(Request $request)
-    {
-        $service = new ProductService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->productCategoryList($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function productCategoryList2(Request $request)
-    {
-        $service = new ProductService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->productCategoryList2($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function productEdit(Request $request)
-    {
-        $service = new ProductService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->productEdit($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function productAdd(Request $request)
-    {
-        $service = new ProductService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->productAdd($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-    public function productDel(Request $request)
-    {
-        $service = new ProductService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->productDel($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-    public function productList(Request $request)
-    {
-        $service = new ProductService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->productList($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function productList2(Request $request)
-    {
-        $service = new ProductService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->productList2($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function productDetail(Request $request)
-    {
-        $service = new ProductService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->productDetail($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 76
app/Http/Controllers/Api/ProductInventoryController.php

@@ -1,76 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-
-use App\Service\ProductInventoryService;
-use App\Service\ProductService;
-use Illuminate\Http\Request;
-
-class ProductInventoryController extends BaseController
-{
-    public function productInventoryList(Request $request)
-    {
-        $service = new ProductInventoryService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->productInventoryList($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function productInventoryStockList(Request $request)
-    {
-        $service = new ProductInventoryService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->productInventoryStockList($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function productInventorySetList(Request $request)
-    {
-        $service = new ProductInventoryService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->productInventorySetList($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function productInventorySet(Request $request)
-    {
-        $service = new ProductInventoryService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->productInventorySet($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function getMySetting(Request $request)
-    {
-        $service = new ProductInventoryService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->getMySetting($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 76
app/Http/Controllers/Api/PurchaseOrderController.php

@@ -1,76 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\ProductService;
-use App\Service\PurchaseOrderService;
-use Illuminate\Http\Request;
-
-class PurchaseOrderController extends BaseController
-{
-    public function purchaseOrderAdd(Request $request)
-    {
-        $service = new PurchaseOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->add($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function purchaseOrderEdit(Request $request)
-    {
-        $service = new PurchaseOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->edit($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function purchaseOrderDetail(Request $request)
-    {
-        $service = new PurchaseOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->detail($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function purchaseOrderDel(Request $request)
-    {
-        $service = new PurchaseOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->del($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function purchaseOrderList(Request $request)
-    {
-        $service = new PurchaseOrderService();
-        if(is_array($request->userData)) $userData = $request->userData;
-        else $userData = $request->userData->toArray();
-        list($status,$data) = $service->getList($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 87
app/Http/Controllers/Api/PurchaseOrderSpecialController.php

@@ -1,87 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\PurchaseOrderSpecialService;
-use Illuminate\Http\Request;
-
-class PurchaseOrderSpecialController extends BaseController
-{
-    public function purchaseOrderAdd(Request $request)
-    {
-        $service = new PurchaseOrderSpecialService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->add($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function purchaseOrderEdit(Request $request)
-    {
-        $service = new PurchaseOrderSpecialService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->edit($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function purchaseOrderDetail(Request $request)
-    {
-        $service = new PurchaseOrderSpecialService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->detail($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function purchaseOrderDel(Request $request)
-    {
-        $service = new PurchaseOrderSpecialService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->del($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function purchaseOrderList(Request $request)
-    {
-        $service = new PurchaseOrderSpecialService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->getList($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function purchaseOrderConfirm(Request $request)
-    {
-        $service = new PurchaseOrderSpecialService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->purchaseOrderConfirm($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 22
app/Http/Controllers/Api/RangeController.php

@@ -1,22 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\RangeService;
-use Illuminate\Http\Request;
-
-class RangeController extends BaseController
-{
-    public function seeRange(Request $request)
-    {
-        $service = new RangeService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->seeRange($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 74
app/Http/Controllers/Api/ReturnExchangeOrderController.php

@@ -1,74 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\ReturnExchangeOrderService;
-use Illuminate\Http\Request;
-
-class ReturnExchangeOrderController extends BaseController
-{
-    public function ReturnExchangeOrderAdd(Request $request)
-    {
-        $service = new ReturnExchangeOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->add($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function ReturnExchangeOrderEdit(Request $request)
-    {
-        $service = new ReturnExchangeOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->edit($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function ReturnExchangeOrderDetail(Request $request)
-    {
-        $service = new ReturnExchangeOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->detail($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function ReturnExchangeOrderDel(Request $request)
-    {
-        $service = new ReturnExchangeOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->del($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function ReturnExchangeOrderList(Request $request)
-    {
-        $service = new ReturnExchangeOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->getList($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 125
app/Http/Controllers/Api/SalesOrderController.php

@@ -1,125 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\SalesOrderService;
-use Illuminate\Http\Request;
-
-class SalesOrderController extends BaseController
-{
-    public function salesOrderAdd(Request $request)
-    {
-        $service = new SalesOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->salesOrderAdd($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function salesOrderEdit(Request $request)
-    {
-        $service = new SalesOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->salesOrderEdit($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function salesOrderDel(Request $request)
-    {
-        $service = new SalesOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->salesOrderDel($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function salesOrderList(Request $request)
-    {
-        $service = new SalesOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->salesOrderList($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function salesOrderDetail(Request $request)
-    {
-        $service = new SalesOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->detail($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function salesOrderGet(Request $request)
-    {
-        $service = new SalesOrderService();
-        list($status,$data) = $service->salesOrderGet($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function salesOrderDispatchSale(Request $request)
-    {
-        $service = new SalesOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->salesOrderDispatchSale($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function salesOrderDispatchCompany(Request $request)
-    {
-        $service = new SalesOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->salesOrderDispatchCompany($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function batchConfirm(Request $request)
-    {
-        $service = new SalesOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->batchConfirm($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 155
app/Http/Controllers/Api/ScheduleController.php

@@ -1,155 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-
-use App\Service\ScheduleService;
-use Illuminate\Http\Request;
-
-class ScheduleController extends BaseController
-{
-    public function edit(Request $request)
-    {
-        $service = new ScheduleService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->edit($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function add(Request $request)
-    {
-        $service = new ScheduleService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->add($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-    public function del(Request $request)
-    {
-        $service = new ScheduleService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->del($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-    public function getList(Request $request)
-    {
-        $service = new ScheduleService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->getList($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function detail(Request $request)
-    {
-        $service = new ScheduleService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->detail($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function scheduleGetForConstruction(Request $request)
-    {
-        $service = new ScheduleService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->scheduleGetForConstruction($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function getScheduleSetting(Request $request)
-    {
-        $service = new ScheduleService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->getScheduleSetting($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function getSettingTotal(Request $request)
-    {
-        $service = new ScheduleService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->getSettingTotal($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function getSettingGetDetail(Request $request)
-    {
-        $service = new ScheduleService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->getSettingGetDetail($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function getSettingTotal2(Request $request)
-    {
-        $service = new ScheduleService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->getSettingTotal2($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function getSettingGetDetail2(Request $request)
-    {
-        $service = new ScheduleService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->getSettingGetDetail2($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 74
app/Http/Controllers/Api/SportsBagController.php

@@ -1,74 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\SportsBagService;
-use Illuminate\Http\Request;
-
-class SportsBagController extends BaseController
-{
-    public function add(Request $request)
-    {
-        $service = new SportsBagService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->add($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function edit(Request $request)
-    {
-        $service = new SportsBagService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->edit($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function detail(Request $request)
-    {
-        $service = new SportsBagService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->detail($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function del(Request $request)
-    {
-        $service = new SportsBagService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->del($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function orderList(Request $request)
-    {
-        $service = new SportsBagService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->getList($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 76
app/Http/Controllers/Api/StorehouseController.php

@@ -1,76 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-
-use App\Service\BoxService;
-use App\Service\StorehouseService;
-use Illuminate\Http\Request;
-
-
-class StorehouseController extends BaseController
-{
-    public function add(Request $request)
-    {
-        $service = new StorehouseService();
-        list($status,$data) = $service->add($request->all(), $userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function edit(Request $request)
-    {
-        $service = new StorehouseService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->edit($request->all(), $userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function del(Request $request)
-    {
-        $service = new StorehouseService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->del($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-
-    public function storehouseList(Request $request)
-    {
-        $service = new StorehouseService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->storehouseList($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function storehouseDetail(Request $request)
-    {
-        $service = new StorehouseService();
-        list($status,$data) = $service->storeDetail($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 74
app/Http/Controllers/Api/SupplierController.php

@@ -1,74 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\SupplierService;
-use Illuminate\Http\Request;
-
-class SupplierController extends BaseController
-{
-    //供应商
-    public function customerAdd(Request $request)
-    {
-        $service = new SupplierService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->customerAdd($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function customerEdit(Request $request)
-    {
-        $service = new SupplierService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->customerEdit($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function customerDel(Request $request)
-    {
-        $service = new SupplierService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->customerDel($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function customerList(Request $request)
-    {
-        $service = new SupplierService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->customerList($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function customerDetail(Request $request)
-    {
-        $service = new SupplierService();
-        list($status,$data) = $service->customerDetail($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 35
app/Http/Controllers/Api/TableHeadController.php

@@ -1,35 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\TableHeadService;
-use Illuminate\Http\Request;
-
-class TableHeadController extends BaseController
-{
-    public function tableHeadAdd(Request $request)
-    {
-        $service = new TableHeadService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->tableheadAdd($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function tableHeadGet(Request $request)
-    {
-        $service = new TableHeadService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->tableheadGet($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 74
app/Http/Controllers/Api/TakeOrderController.php

@@ -1,74 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\TakeOrderService;
-use Illuminate\Http\Request;
-
-class TakeOrderController extends BaseController
-{
-    public function invoiceOrderAdd(Request $request)
-    {
-        $service = new TakeOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->add($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function invoiceOrderEdit(Request $request)
-    {
-        $service = new TakeOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->edit($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function invoiceOrderDetail(Request $request)
-    {
-        $service = new TakeOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->detail($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function invoiceOrderDel(Request $request)
-    {
-        $service = new TakeOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->del($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function invoiceOrderList(Request $request)
-    {
-        $service = new TakeOrderService();
-        $userData = $request->userData->toArray();
-        list($status,$data) = $service->getList($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 74
app/Http/Controllers/Api/TechnologyController.php

@@ -1,74 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\TechnologyService;
-use Illuminate\Http\Request;
-
-class TechnologyController extends BaseController
-{
-    public function technologyList(Request $request)
-    {
-        $service = new TechnologyService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->technologyList($request->all(),$request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function technologyEdit(Request $request)
-    {
-        $service = new TechnologyService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->technologyEdit($request->all(),$request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function technologyAdd(Request $request)
-    {
-        $service = new TechnologyService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->technologyAdd($request->all(),$request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function technologyDel(Request $request)
-    {
-        $service = new TechnologyService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->technologyDel($request->all(),$request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function technologyCopy(Request $request)
-    {
-        $service = new TechnologyService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->technologyCopy($request->all(),$request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-}

+ 0 - 45
app/Model/BasicType.php

@@ -1,45 +0,0 @@
-<?php
-
-namespace App\Model;
-
-class BasicType extends UseScopeBaseModel
-{
-    protected $table = "basic_type"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-
-    const type_22 = 22;
-    public static $type = [
-        1 => '客户意向类型',
-        2 => '客户来源类型',
-        3 => '客户类型(T9改装)',
-        4 => '客户电话类型',
-        5 => '进展阶段类型',
-        6 => '客户状态类型',
-        7 => '决策关系类型',
-//        8 => '客户分级',
-        9 => '状态类型',
-        10 => '车型',
-        11 => '订单类型',
-//        12 => '成交类型',
-//        13 => '合同状态',
-//        14 => '合同类型',
-        15 => '付款方式',
-//        16 => '发货状态',
-        17 => '物流公司',
-        18 => '安装方式',
-        19 => '紧急程度',
-        20 => '产品单位',
-        21 => '跟进方式',
-        22 => '产品价格',
-        23 => '安装地点',
-        24 => '平台类型',
-//        25 => '业务类型',
-//        26 => '销售类型',
-        27 => '采购类型',
-        28 => '默认账户',
-        29 => '客户简称',
-        30 => '客户类型(T9二手车)',
-    ];
-}

+ 0 - 38
app/Model/BookingList.php

@@ -1,38 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class BookingList extends Model
-{
-    protected $table = "booking_list"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const STATE_ZERO = 0;//未确认
-    const STATE_ONE = 1;//已确认
-    public static $name = [
-        self::STATE_ZERO => '未确认',
-        self::STATE_ONE => '已确认',
-    ];
-
-    const type_one = 1; // 收款
-    const type_two = 2; // 坏账
-    const type_three = 3; // 退款
-    const type_four = 4; // 补收
-    public static $model_type = [
-        self::type_one => '收款',
-        self::type_two => '坏账',
-        self::type_three => '退款',
-        self::type_four => '补收',
-    ];
-
-    const data_type_one = 1; // 合同
-    const data_type_two = 2; // 采购
-    public static $data_type = [
-        self::data_type_one => '合同',
-        self::data_type_two => '采购',
-    ];
-
-}

+ 0 - 17
app/Model/BookingListInfo.php

@@ -1,17 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class BookingListInfo extends Model
-{
-    protected $table = "booking_list_info"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const type_one = 1; // 文件
-    public static $type = [
-        self::type_one,
-    ];
-}

+ 0 - 46
app/Model/Construction.php

@@ -1,46 +0,0 @@
-<?php
-
-namespace App\Model;
-
-class Construction extends UseScopeBaseModel
-{
-    protected $table = "construction"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const Model_type_one = 1; // 总部安装
-    const Model_type_two = 2; // 分社网点安装
-    public static $model_type = [
-        self::Model_type_one,
-        self::Model_type_two,
-    ];
-    public static $model_type_title = [
-        self::Model_type_one => '总部安装',
-        self::Model_type_two => '分社网点安装',
-    ];
-
-    public static $prefix = [
-        self::Model_type_one => 'WO0.',
-        self::Model_type_two => 'T9SH.',
-    ];
-
-    const STATE_ZERO = 0;//未审核
-    const STATE_ONE = 1;//待审核
-    const STATE_TWO = 2;//已审核
-    const STATE_THREE = 3;//待确认
-    const STATE_FOUR = 4;//已完结
-    public static $name = [
-        self::STATE_ZERO => '未审核',
-        self::STATE_ONE => '待审核',
-        self::STATE_TWO => '施工中',
-        self::STATE_THREE => '待完结审核',
-        self::STATE_FOUR => '已完结',
-    ];
-
-    public static $pq_name = [
-        self::STATE_ZERO => '未排期',
-        self::STATE_ONE => '已排期',
-    ];
-    const range_function = 'constructionRange';
-    const is_check_function = 'constructionCheck';
-}

+ 0 - 13
app/Model/ConstructionFile.php

@@ -1,13 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class ConstructionFile extends Model
-{
-    protected $table = "construction_file"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-}

+ 0 - 20
app/Model/ConstructionInfo.php

@@ -1,20 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class ConstructionInfo extends Model
-{
-    protected $table = "construction_info"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const type_one = 1; // 联系方式
-    const type_two = 2; // 协同人
-    const type_three = 3; // 负责人
-    public static $type = [
-        self::type_one,
-        self::type_two
-    ];
-}

+ 0 - 13
app/Model/ConstructionProductInfo.php

@@ -1,13 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class ConstructionProductInfo extends Model
-{
-    protected $table = "construction_product_info"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-}

+ 0 - 40
app/Model/DeliveryNote.php

@@ -1,40 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 交车单
- * Class Unit
- * @package App\Models
- */
-class DeliveryNote extends Model
-{
-    protected $table = "delivery_note"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-
-
-
-    public function getBreakAttribute($value)
-    {
-        return json_decode($value, true);
-    }
-
-
-
-    public function getBreakMarkAttribute($value)
-    {
-        return json_decode($value, true);
-    }
-
-
-
-    public function getProjectIdAttribute($value)
-    {
-        return json_decode($value, true);
-    }
-
-}

+ 0 - 19
app/Model/EmployeeFoursShop.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 人员绑定的四s店
- * Class Unit
- * @package App\Models
- */
-class EmployeeFoursShop extends Model
-{
-    protected $table = "employee_fours_shop"; //指定表
-    const CREATED_AT = null;
-    const UPDATED_AT = null;
-    protected $dateFormat = 'U';
-
-}

+ 0 - 14
app/Model/EmployeeManagerDepart.php

@@ -1,14 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class EmployeeManagerDepart extends Model
-{
-    protected $table = "employee_manager_depart"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-
-}

+ 0 - 19
app/Model/EmployeeMenuPermission.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 菜单管理
- * Class Unit
- * @package App\Models
- */
-class EmployeeMenuPermission extends Model
-{
-    protected $table = "employee_menu_permission"; //指定表
-    const CREATED_AT = null;
-    const UPDATED_AT = null;
-    protected $dateFormat = 'U';
-
-}

+ 0 - 19
app/Model/FollowUpRecord.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class FollowUpRecord extends Model
-{
-    protected $table = "follow_up_record"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const type_one = 'customer';
-    const type_two = 'sales_order';
-    public static $type = [
-        self::type_one => '客户跟进记录',
-        self::type_two => '合同跟进记录',
-    ];
-}

+ 0 - 17
app/Model/FollowUpRecordFile.php

@@ -1,17 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class FollowUpRecordFile extends Model
-{
-    protected $table = "follow_up_record_file"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const type_one = 1; // 图片
-    public static $type = [
-        self::type_one,
-    ];
-}

+ 0 - 11
app/Model/InOutRecord.php

@@ -1,11 +0,0 @@
-<?php
-
-namespace App\Model;
-
-class InOutRecord extends UseScopeBaseModel
-{
-    protected $table = "in_out_record"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-}

+ 0 - 23
app/Model/InvoiceOrder.php

@@ -1,23 +0,0 @@
-<?php
-
-namespace App\Model;
-
-class InvoiceOrder extends UseScopeBaseModel
-{
-    protected $table = "invoice_order"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const STATE_ZERO = 0;//未确认
-    const STATE_ONE = 1;//待确认
-    const STATE_TWO = 2;//已确认
-    const prefix = 'FH';
-    public static $name = [
-        0 => '未确认',
-        1 => '待确认',
-        2 => '已确认',
-    ];
-
-    const range_function = 'invoiceRange';
-    const is_check_function = 'invoiceCheck';
-}

+ 0 - 13
app/Model/InvoiceOrderInfo.php

@@ -1,13 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class InvoiceOrderInfo extends Model
-{
-    protected $table = "invoice_order_info"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-}

+ 0 - 73
app/Model/OrderOperation.php

@@ -1,73 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-
-class OrderOperation extends Model
-{
-    protected $table = "order_operation"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-
-    //审批操作对应的数值
-    const zero = 0;
-    const one = 1;
-    const two = 2;
-    const three = 3;
-    const four = 4;
-    const five = 5;
-    const six = 6;
-    const seven = 7;
-    const eight = 8;
-    const nine = 9;
-    const ten = 10;
-    const eve = 11;
-    const twl = 12;
-    const thi = 13;
-    const fourteen = 14;
-    const fif = 15;
-    const sixty = 16;
-    const seventeen = 17;
-    const eighteen = 18;
-    const nineteen = 19;
-    const twenty = 20;
-    const twenty_one = 21;
-    const twenty_two = 22;
-    const twenty_three = 23;
-    const twenty_four = 24;
-    const twenty_five = 25;
-    const twenty_six = 26;
-
-    public static $type = [
-        self::zero => '系统设置变更 ',
-        self::one => '线上派单',
-        self::two => '门店派单',
-        self::three => '合同确认',
-        self::four => '合同弃审',
-        self::five => '合同公司完结',
-        self::six => '合同客户完结',
-        self::seven => '金额记账记录增加',
-        self::eight => '发货单确认',
-        self::nine => '退换货审核',
-        self::ten => '退换货弃审',
-        self::eve => '施工单审核',
-        self::twl => '施工单弃审',
-        self::thi => '采购确认',
-        self::fourteen => '采购入库',
-        self::fif => '采购入库弃审',
-        self::sixty => '合同修改负责人',
-        self::seventeen => '合同修改协同人',
-        self::eighteen => '合同分配',
-        self::nineteen => '合同移交',
-        self::twenty => '采购确认弃审',
-        self::twenty_one => '收付款单审核',
-        self::twenty_two => '收付款单弃审',
-        self::twenty_three => '客户分配',
-        self::twenty_four => '客户移交',
-        self::twenty_five => '合同批量确认',
-        self::twenty_six => '施工单分配/调配',
-    ];
-}

+ 0 - 42
app/Model/PaymentReceipt.php

@@ -1,42 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class PaymentReceipt extends UseScopeBaseModel
-{
-    protected $table = "payment_receipt"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const STATE_ZERO = 0;//未确认
-    const STATE_ONE = 1;//待确认
-    const STATE_TWO = 2;//已确认
-    public static $name = [
-        self::STATE_ZERO => '未核销',
-        self::STATE_ONE => '待核销',
-        self::STATE_TWO => '已核销',
-    ];
-
-    const type_one = 1; // 收款
-    const type_two = 2; // 付款
-    const type_three = 3; // 红冲
-    const type_four = 4; // 坏账
-    public static $model_type = [
-        self::type_one => '收款',
-        self::type_two => '付款',
-        self::type_three => '红冲',
-        self::type_four => '坏账',
-    ];
-
-    const data_type_one = 1; // 合同
-    const data_type_two = 2; // 采购
-    public static $data_type = [
-        self::data_type_one => '合同',
-        self::data_type_two => '采购',
-    ];
-
-    const prefix = "T9RMO.";
-    const is_check_function = 'paymentReceiptCheck';
-}

+ 0 - 24
app/Model/PaymentReceiptInfo.php

@@ -1,24 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class PaymentReceiptInfo extends Model
-{
-    protected $table = "payment_receipt_info"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const type_one = 1; // 文件/图片
-    const type_two = 2; // 归属人
-    const type_three = 3; // 回款信息
-    public static $type = [
-        self::type_one,
-        self::type_two,
-        self::type_three,
-    ];
-    public static $man = [
-        self::type_two,
-    ];
-}

+ 0 - 50
app/Model/Product.php

@@ -1,50 +0,0 @@
-<?php
-
-namespace App\Model;
-
-class Product extends UseScopeBaseModel
-{
-    protected $table = "product"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const State_zero = 0;
-    const State_one = 1;
-    const State_two = 2;
-    public static $state = [
-        self::State_zero => '新增',
-        self::State_one => '上架',
-        self::State_two => '下架',
-    ];
-
-    const range_function = 'productRangeNot';
-
-    const Product_attribute_zero = 0;
-    const Product_attribute_one = 1;
-    const Product_attribute_two = 2;
-    const Product_attribute_three = 3;
-    public static $product_attribute = [
-        self::Product_attribute_zero => '无',
-        self::Product_attribute_one => '其他',
-        self::Product_attribute_two => '主推款',
-        self::Product_attribute_three => '热卖款',
-    ];
-    public static $product_attribute_color = [
-        self::Product_attribute_zero => [
-            'background_color' => 'white',
-            'font_color' => 'black',
-        ],
-        self::Product_attribute_one => [
-            'background_color' => 'white',
-            'font_color' => 'black',
-        ],
-        self::Product_attribute_two => [
-            'background_color' => '#ed4446',
-            'font_color' => 'white',
-        ],
-        self::Product_attribute_three => [
-            'background_color' => '#98FB98',
-            'font_color' => 'white',
-        ],
-    ];
-}

+ 0 - 18
app/Model/ProductActivity.php

@@ -1,18 +0,0 @@
-<?php
-
-namespace App\Model;
-
-class ProductActivity extends UseScopeBaseModel
-{
-    protected $table = "product_activity"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const range_function = '';
-    const type_one = 1;
-    const type_two = 2;
-    public static $type_name = [
-        self::type_one => '零售活动',
-        self::type_two => '供应商活动',
-    ];
-}

+ 0 - 13
app/Model/ProductActivityPrice.php

@@ -1,13 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class ProductActivityPrice extends Model
-{
-    protected $table = "product_activity_price"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-}

+ 0 - 11
app/Model/ProductCategory.php

@@ -1,11 +0,0 @@
-<?php
-
-namespace App\Model;
-
-class ProductCategory extends UseScopeBaseModel
-{
-    protected $table = "product_category"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-}

+ 0 - 19
app/Model/ProductInfo.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class ProductInfo extends Model
-{
-    protected $table = "product_info"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const type_one = 1; // 图片
-    const type_two = 2; // 文件
-    public static $type = [
-        self::type_one,
-        self::type_two,
-    ];
-}

+ 0 - 13
app/Model/ProductIntroduction.php

@@ -1,13 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class ProductIntroduction extends Model
-{
-    protected $table = "product_introduction"; //指定表
-    const CREATED_AT = null;
-    const UPDATED_AT = null;
-    protected $dateFormat = 'U';
-}

+ 0 - 11
app/Model/ProductInventory.php

@@ -1,11 +0,0 @@
-<?php
-
-namespace App\Model;
-
-class ProductInventory extends UseScopeBaseModel
-{
-    protected $table = "product_inventory"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = null;
-    protected $dateFormat = 'U';
-}

+ 0 - 20
app/Model/ProductInventorySet.php

@@ -1,20 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use App\Scopes\TopDepartmentScope;
-use Illuminate\Database\Eloquent\Model;
-
-class ProductInventorySet extends UseScopeBaseModel
-{
-    protected $table = "depart_set"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const type_one = 1;//校验库存
-    const type_two = 2;//不校验证库存
-    public static $type_name = [
-        self::type_one => '是',
-        self::type_two => '否',
-    ];
-}

+ 0 - 13
app/Model/ProductPriceDetail.php

@@ -1,13 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class ProductPriceDetail extends Model
-{
-    protected $table = "product_price_detail"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-}

+ 0 - 19
app/Model/ProductRange.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class ProductRange extends Model
-{
-    protected $table = "product_range"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const type_one = 1; // 部门
-    const type_two = 2; // 人
-    public static $type = [
-        self::type_one,
-        self::type_two,
-    ];
-}

+ 0 - 40
app/Model/PurchaseOrder.php

@@ -1,40 +0,0 @@
-<?php
-
-namespace App\Model;
-
-class PurchaseOrder extends UseScopeBaseModel
-{
-    protected $table = "purchase_order"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const STATE_ZERO = 0;//未确认
-    const STATE_ONE = 1;//待确认
-    const STATE_TWO = 2;//未入库
-    const STATE_Three = 3;//待入库
-    const STATE_Four = 4;//已入库
-    const prefix = 'CG';
-    public static $name = [
-        self::STATE_ZERO => '未确认',
-        self::STATE_ONE => '待确认',
-        self::STATE_TWO => '已审核',
-        self::STATE_Three => '已发货',
-        self::STATE_Four => '已入库',
-    ];
-
-    const Order_type_one = 1;//总社采购
-    const Order_type_two = 2;//分社外采
-    const Order_type_three = 3;//分社要货 不要合同
-    const Order_type_four = 4;//分社订货 要合同
-    const Order_type_five = 5;
-
-    public static $order_type = [
-        self::Order_type_one => '总社采购',
-        self::Order_type_two => '分社外采',
-        self::Order_type_three => '分社要货',
-        self::Order_type_four => '分社订货',
-    ];
-
-    const range_function = 'purchaseRange';
-    const is_check_function = 'purchaseCheck';
-}

+ 0 - 17
app/Model/PurchaseOrderFile.php

@@ -1,17 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class PurchaseOrderFile extends Model
-{
-    protected $table = "purchase_order_file"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = null;
-    protected $dateFormat = 'U';
-    const type_one = 1; // 文件
-    public static $type = [
-        self::type_one,
-    ];
-}

+ 0 - 21
app/Model/PurchaseOrderInfo.php

@@ -1,21 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class PurchaseOrderInfo extends Model
-{
-    protected $table = "purchase_order_info"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = null;
-    protected $dateFormat = 'U';
-    const STATE_ZERO = 0;//未发货
-    const STATE_ONE = 1;//部分已发货
-    const STATE_TWO = 2;//已发货
-    public static $name = [
-        0 => '未发货',
-        1 => '部分已发货',
-        2 => '已发货'
-    ];
-}

+ 0 - 22
app/Model/PurchaseOrderSpecial.php

@@ -1,22 +0,0 @@
-<?php
-
-namespace App\Model;
-
-class PurchaseOrderSpecial extends UseScopeBaseModel
-{
-    protected $table = "purchase_order_special"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const STATE_ZERO = 0;//未确认
-    const STATE_ONE = 1;//未入库
-    const STATE_TWO = 2;//已入库
-    const prefix = 'XNCG';
-    public static $name = [
-        self::STATE_ZERO => '未确认',
-        self::STATE_ONE => '未入库',
-        self::STATE_TWO => '已入库',
-    ];
-
-    const range_function = '';
-}

+ 0 - 21
app/Model/PurchaseOrderSpecialInfo.php

@@ -1,21 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class PurchaseOrderSpecialInfo extends Model
-{
-    protected $table = "purchase_order_special_info"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = null;
-    protected $dateFormat = 'U';
-    const STATE_ZERO = 0;//未发货
-    const STATE_ONE = 1;//部分已发货
-    const STATE_TWO = 2;//已发货
-    public static $name = [
-        0 => '未发货',
-        1 => '部分已发货',
-        2 => '已发货'
-    ];
-}

+ 0 - 48
app/Model/ReturnExchangeOrder.php

@@ -1,48 +0,0 @@
-<?php
-
-namespace App\Model;
-
-class ReturnExchangeOrder extends UseScopeBaseModel
-{
-    protected $table = "return_exchange_order"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-
-    const Order_type = 0; //合同
-    const Order_type2 = 1; // 采购单
-    public static $order_type_name = [
-        self::Order_type => '合同',
-        self::Order_type2 => '采购单',
-    ];
-    const Model_type_one = 1; // 退货单
-    const Model_type_two = 2; // 换货单
-    const Model_type_three = 3; // 仅退款
-    public static $model_type = [
-        self::Model_type_one,
-        self::Model_type_two,
-        self::Model_type_three,
-    ];
-    public static $model_type_name = [
-        self::Model_type_one => '退货单',
-        self::Model_type_two => '换货单',
-        self::Model_type_three => '仅退款',
-    ];
-
-    const State_zero = 0;//未确认
-    const State_one = 1;//待确认
-    const State_two = 2;//已确认
-    public static $state = [
-        self::State_zero => '未提交',
-        self::State_one => '待审核',
-        self::State_two => '已审核',
-    ];
-
-    public static $prefix = [
-        self::Model_type_one => 'TH',
-        self::Model_type_two => 'HH',
-        self::Model_type_three => 'TK',
-    ];
-    const range_function = 'returnExchangeOrderRange';
-    const is_check_function = 'returnExchangeOrderCheck';
-}

+ 0 - 19
app/Model/ReturnExchangeOrderProductInfo.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class ReturnExchangeOrderProductInfo extends Model
-{
-    protected $table = "return_exchange_order_product_info"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const type_one = 1; // 退货
-    const type_two = 2; // 换货
-    public static $model_type = [
-        self::type_one,
-        self::type_one,
-    ];
-}

+ 0 - 19
app/Model/ReturnExchangeOrderRange.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class ReturnExchangeOrderRange extends Model
-{
-    protected $table = "return_exchange_order_range"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const type_one = 1; // 部门
-    const type_two = 2; // 人
-    public static $type = [
-        self::type_one,
-        self::type_two,
-    ];
-}

+ 0 - 108
app/Model/SalesOrder.php

@@ -1,108 +0,0 @@
-<?php
-
-namespace App\Model;
-
-class SalesOrder extends UseScopeBaseModel
-{
-    protected $table = "sales_order"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const range_function = 'salesOrderRange';
-    const is_check_function = 'salesOrderCheck';
-    const Order_type_one = 1;//安装件
-    const Order_type_two = 2;//快递件
-    public static $order_type = [
-        self::Order_type_one => '安装件',
-        self::Order_type_two => '快递件',
-    ];
-    public static $order_type_name = [
-        '安装件' => self::Order_type_one,
-        '快递件' => self::Order_type_two,
-    ];
-
-    const Model_type_one = 1; // 线下订单合同
-    const Model_type_two = 2; // 分社订货合同
-    const Model_type_three = 3; // 二手车交易合同
-    const Model_type_four = 4; // 线上订单合同
-    const Model_type_five = 5; // 二手车加装合同
-    const Model_type_six = 6; // 外贸订单
-    public static $model_type = [
-        self::Model_type_one,
-        self::Model_type_two,
-        self::Model_type_three,
-        self::Model_type_four,
-        self::Model_type_five,
-        self::Model_type_six,
-    ];
-    public static $model_type_title = [
-        self::Model_type_one => '线下订单',
-        self::Model_type_two => '分社订货',
-        self::Model_type_three => '二手车交易',
-        self::Model_type_four => '线上订单',
-        self::Model_type_five => '二手车加装',
-        self::Model_type_six => '外贸订单',
-    ];
-
-    public static $model_type_title_u8 = [
-        self::Model_type_one => '线下销售',
-        self::Model_type_two => '线下销售',
-        self::Model_type_three => '二手车交易',
-        self::Model_type_four => '线上销售',
-        self::Model_type_five => '二手车加装',
-        self::Model_type_six => '外贸订单',
-    ];
-
-    //安装件
-    const State_minus_one = -1;//驳回
-    const State_zero = 0;//未确认
-    const State_one = 1;//待确认
-    const State_two = 2;//已确认
-    const State_three = 3;//已派销售
-    const State_four = 4;//已派总设或分社
-    const State_five = 5;//已下施工单
-    const State_six = 6;//退换货
-    const State_seven = 7;//完结 公司
-    const State_eight = 8;//完结 客户
-
-    const special_status = -100;
-    //审核通过条件  安装件 且 线上订单的已审核是2  其它是3
-    const search = "(sales_order_type = " . SalesOrder::Order_type_one . " and ((model_type = " . SalesOrder::Model_type_four ." and state = " . SalesOrder::State_two.") or (model_type <> " . SalesOrder::Model_type_four ." and state = " . SalesOrder::State_three.")))";
-    public static $state = [
-        self::State_minus_one => '已驳回',
-        self::State_zero => '待创建人确认',
-        self::State_one => '待审批人审核',
-        self::State_two => '审核通过',
-        self::State_three => '待被指派门店接收',
-        self::State_four => '已门店派单',
-        self::State_five => '施工中',
-        self::State_six => '退换货',
-        self::State_seven => '公司完结',
-        self::State_eight => '客户完结',
-    ];
-
-    //快递件
-    const State2_zero = 0;//未发货
-    const State2_one = 1;//已发货
-    public static $state2 = [
-        self::State2_zero => '未发货',
-        self::State2_one => '已发货',
-    ];
-
-    //发货状态
-    const invoice_zero = 0;//未发货
-    const invoice_one = 1;//已发货
-    public static $invoice_state = [
-        self::invoice_zero => '未发货',
-        self::invoice_one => '已发货',
-    ];
-
-    public static $prefix = [
-        self::Model_type_one => 'T9XX.',
-        self::Model_type_two => 'T9SO.',
-        self::Model_type_three => 'T9XX.',
-        self::Model_type_four => 'T9XS.',
-        self::Model_type_five => 'T9XX.',
-        self::Model_type_six => 'T9XX.',
-    ];
-}

+ 0 - 30
app/Model/SalesOrderInfo.php

@@ -1,30 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class SalesOrderInfo extends Model
-{
-    protected $table = "sales_order_info"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const type_one = 1; // 签订人
-    const type_two = 2; // 负责人
-    const type_three = 3; // 协同人
-    const type_four = 4; // 文件
-    const type_five = 5; // 活动包
-    const type_six = 6; // 客户完结图片
-    public static $type = [
-        self::type_one,
-        self::type_two,
-        self::type_three,
-        self::type_four,
-    ];
-    public static $man = [
-        self::type_one,
-        self::type_two,
-        self::type_three,
-    ];
-}

+ 0 - 13
app/Model/SalesOrderOtherFee.php

@@ -1,13 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class SalesOrderOtherFee extends Model
-{
-    protected $table = "sales_order_other_fee"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-}

+ 0 - 13
app/Model/SalesOrderProductInfo.php

@@ -1,13 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class SalesOrderProductInfo extends Model
-{
-    protected $table = "sales_order_product_info"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-}

+ 0 - 21
app/Model/SalesOrderRange.php

@@ -1,21 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class SalesOrderRange extends Model
-{
-    protected $table = "sales_order_range"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const type_one = 1; // 部门
-    const type_two = 2; // 人
-    const type_three = 3; // 公司
-    public static $type = [
-        self::type_one,
-        self::type_two,
-        self::type_three,
-    ];
-}

+ 0 - 12
app/Model/Schedule.php

@@ -1,12 +0,0 @@
-<?php
-
-namespace App\Model;
-
-class Schedule extends UseScopeBaseModel
-{
-    protected $table = "schedule"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const range_function = '';
-}

+ 0 - 13
app/Model/ScheduleDetail.php

@@ -1,13 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class ScheduleDetail extends Model
-{
-    protected $table = "schedule_detail"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-}

+ 0 - 15
app/Model/ScheduleInfo.php

@@ -1,15 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class ScheduleInfo extends Model
-{
-    protected $table = "schedule_info"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const not_use = 0;
-    const limit_key = "scheduleInfo";
-}

+ 0 - 42
app/Model/SeeRange.php

@@ -1,42 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class SeeRange extends Model
-{
-    protected $table = "see_range"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const type_one = 1; // 客户
-    const type_two = 2; // 施工单
-    const type_three = 3; // 发货单
-    const type_four = 4; // 产品
-    const type_five = 5; // 采购单
-    const type_six = 6; // 退换货
-    const type_seven = 7; // 合同
-    const type_eight = 8; // 活动包
-    const type_nine = 9; //供应商
-    public static $type = [
-        self::type_one,
-        self::type_two,
-        self::type_three,
-        self::type_four,
-        self::type_five,
-        self::type_six,
-        self::type_seven,
-        self::type_eight,
-        self::type_nine,
-    ];
-
-    const data_one = 1; // 部门
-    const data_two = 2; // 人
-    const data_three = 3; // 公司
-    public static $data_type = [
-        self::data_one,
-        self::data_two,
-        self::data_three,
-    ];
-}

+ 0 - 20
app/Model/Setting.php

@@ -1,20 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 设置
- * Class Unit
- * @package App\Models
- */
-class Setting extends Model
-{
-    protected $table = "setting"; //指定表
-    const CREATED_AT = null;
-    const UPDATED_AT = null;
-    protected $dateFormat = 'U';
-
-    const LOCK_NUMBER = 0; //是否启用锁定库存
-}

+ 0 - 12
app/Model/SportsBag.php

@@ -1,12 +0,0 @@
-<?php
-
-namespace App\Model;
-
-class SportsBag extends UseScopeBaseModel
-{
-    protected $table = "sports_bag"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const range_function = 'sportsBagRange';
-}

+ 0 - 13
app/Model/SportsBagProductInfo.php

@@ -1,13 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class SportsBagProductInfo extends Model
-{
-    protected $table = "sports_bag_product_info"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-}

+ 0 - 19
app/Model/SportsBagRange.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class SportsBagRange extends Model
-{
-    protected $table = "sports_bag_range"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const type_one = 1; // 部门
-    const type_two = 2; // 人
-    public static $type = [
-        self::type_one,
-        self::type_two,
-    ];
-}

+ 0 - 11
app/Model/Storehouse.php

@@ -1,11 +0,0 @@
-<?php
-
-namespace App\Model;
-
-class Storehouse extends UseScopeBaseModel
-{
-    protected $table = "storehouse"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-}

+ 0 - 19
app/Model/StorehouseEmployee.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 仓库
- * Class Unit
- * @package App\Models
- */
-class StorehouseEmployee extends Model
-{
-    protected $table = "storehouse_employee"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-
-}

+ 0 - 14
app/Model/Supplier.php

@@ -1,14 +0,0 @@
-<?php
-
-namespace App\Model;
-
-class Supplier extends UseScopeBaseModel
-{
-    protected $table = "supplier"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const is_main = 1;//是否总供应商
-
-    const range_function = 'supplierRange';
-}

+ 0 - 19
app/Model/SupplierInfo.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class SupplierInfo extends Model
-{
-    protected $table = "supplier_info"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const type_one = 1; // 可见部门
-    const type_two = 2; // 可见人
-    public static $type = [
-        self::type_one,
-        self::type_two,
-    ];
-}

+ 0 - 14
app/Model/TableSetting.php

@@ -1,14 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-
-class TableSetting extends Model
-{
-    protected $table = "table_setting"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-}

+ 0 - 20
app/Model/TakeOrder.php

@@ -1,20 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class TakeOrder extends Model
-{
-    protected $table = "take_order"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const STATE_ZERO = 0;//未确认
-    const STATE_ONE = 1;//已确认
-    const prefix = 'SH';
-    public static $name = [
-        0 => '未确认',
-        1 => '已确认',
-    ];
-}

+ 0 - 13
app/Model/TakeOrderInfo.php

@@ -1,13 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class TakeOrderInfo extends Model
-{
-    protected $table = "take_order_info"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-}

+ 0 - 19
app/Model/Team.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 班组管理
- * Class Unit
- * @package App\Models
- */
-class Team extends Model
-{
-    protected $table = "team"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-
-}

+ 0 - 35
app/Model/U8Job.php

@@ -1,35 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-
-class U8Job extends Model
-{
-    protected $table = "u8_job"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-
-    const success = 1;
-    const failed = 2;
-
-    const one = 1;
-    const two = 2;
-    public static $type = [
-        self::one,
-        self::two,
-    ];
-    public static $type_title = [
-        self::one => '采购单同步',
-        self::two => '销售订单(合同同步)',
-    ];
-
-    const job1 = 't9u8_purchase';
-    const job2 = 't9u8_sales';
-    public static $job = [
-        self::one => self::job1,
-        self::two => self::job2,
-    ];
-}

+ 0 - 587
app/Model/UseScopeBaseModel.php

@@ -1,587 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use App\Service\RangeService;
-use Illuminate\Database\Eloquent\Model;
-
-class UseScopeBaseModel extends Model
-{
-    //可见范围
-    const range_function = '';
-    const is_check_function = '';
-
-    public function __construct(array $attributes = [])
-    {
-        parent::__construct($attributes);
-    }
-
-    //顶级部门过滤
-    public function scopeTopClear($query, $user, $search)
-    {
-        //是否所有部门
-        $is_all_depart = $user['is_all_depart'] ?? 0;
-        //权限范围内的部门
-        $depart_range = $user['depart_range'] ?? [];
-
-        //顶级部门
-        $search_depart_id = $search['top_depart_id'] ?? 0;
-        if(empty($search_depart_id)){
-            //默认进来 自身顶级公司
-            $top_depart_id = $user['depart_top'][0] ?? [];
-            $top_depart_id = $top_depart_id['depart_id'] ?? 0;
-        }else{
-            //查询 顶级公司
-            $top_depart_id = $search_depart_id;
-        }
-
-        if($is_all_depart){
-            //所有部门
-            if(empty($search_depart_id)){
-                //全部
-                $query->whereIn('top_depart_id', $depart_range);
-            }else{
-                //查看某个分社
-                $query->where('top_depart_id', $top_depart_id);
-            }
-        }else{
-            //某个分社全部
-            $query->where('top_depart_id', $top_depart_id);
-        }
-
-        //获取当前门店下
-        if(! empty($search['get_my_top_depart_data'])){
-            $depart = ! empty($user['depart_top'][0]) ? $user['depart_top'][0]: [];
-            $depart_id = $depart['depart_id'] ?? 0;
-            $query->where('top_depart_id', $depart_id);
-        }
-
-        return $query;
-    }
-
-    //部门和顶级部门(公司)过滤
-    public function scopeClear($query, $user, $search)
-    {
-        //是否所有部门
-        $is_all_depart = $user['is_all_depart'] ?? 0;
-        //权限范围内的部门
-        $depart_range = $user['depart_range'] ?? [];
-        //我可见的
-        if(isset($search['is_see'])){
-            if($search['is_see']){
-                $is_see = 1;
-            }else{
-                $is_see = 0;
-            }
-        }else{
-            $is_see = 0;
-        }
-
-        //全部 待审 待我审核
-        if(isset($search['is_check'])){
-            if($search['is_check']){
-                $is_check = $search['is_check'];
-            }else{
-                $is_check = 0;
-            }
-        }else{
-            $is_check = 0;
-        }
-
-        $model = $query->getModel(); // 获取模型的实例
-        $className = get_class($model); // 获取模型类名
-
-        //可见范围方法
-        $range_function = "";
-        if (defined($className . '::range_function')) $range_function = $className::range_function;
-        $function_range_bool = $this->hasMethod(new RangeService(),$range_function);
-
-        //全部 待审 已审
-        $is_check_function = "";
-        if (defined($className . '::is_check_function')) $is_check_function = $className::is_check_function;
-        $is_check_function_bool = $this->hasMethod(new RangeService(),$is_check_function);
-
-        //顶级部门
-        $search_depart_id = $search['top_depart_id'] ?? 0; //顶级公司
-        if(empty($search_depart_id)){
-            //默认进来 自身顶级公司
-            $top_depart_id = $user['depart_top'][0] ?? [];
-            $top_depart_id = $top_depart_id['depart_id'] ?? 0;
-        }else{
-            //查询 顶级公司
-            $top_depart_id = $search_depart_id;
-        }
-
-        $id = [];
-        //可见范围 以及单据里面填写人员 (状态类 是全部时检索)
-        if($function_range_bool) $id = RangeService::$range_function($user,$search);
-
-        //全部0 待审1 已审2 (状态类 是全部时检索)
-        $check_search = "";
-        if($is_check_function_bool && $is_check) $check_search = RangeService::$is_check_function($user,$search);
-
-        //个人部门所有
-        $auth_type = $this->getQx($search,$user);
-
-        if($is_all_depart){
-            //所有权限
-            if(empty($search_depart_id)){
-                if($is_see){
-                    //可见
-                    $query->whereIn('id', $id);
-                }elseif ($is_check){
-                    if(! $auth_type){
-                        //全部
-                        $query->whereIn('depart_id', $depart_range)
-                            ->when(! empty($check_search), function ($query) use ($check_search) {
-                                return $query->whereRaw($check_search);
-                            });
-                    }else{
-                        if($auth_type == 1) { //我创建的 且加上可见
-                            $query->where('crt_id',$user['id'])
-                                ->when(! empty($check_search), function ($query) use ($check_search) {
-                                    return $query->whereRaw($check_search);
-                                })
-                                ->when(! empty($id), function ($query) use ($id) {
-                                    return $query->orWhereIn('id', $id);
-                                });
-                        }elseif ($auth_type == 2 || $auth_type == 3){
-                            //自己权限范围内的部门 或 所有
-                            $query->whereIn('depart_id', $depart_range)
-                            ->when(! empty($check_search), function ($query) use ($check_search) {
-                                return $query->whereRaw($check_search);
-                            });
-                        }
-                    }
-                }else{
-                    if(! $auth_type){
-                        //全部
-                        $query->whereIn('depart_id', $depart_range);
-                    }else{
-                        if($auth_type == 1) { //我创建的 且加上可见
-                            $query->where('crt_id',$user['id'])
-                                ->when(! empty($id), function ($query) use ($id) {
-                                    return $query->orWhereIn('id', $id);
-                                });
-                        }elseif ($auth_type == 2 || $auth_type == 3){
-                            //自己权限范围内的部门 或 所有
-                            $query->whereIn('depart_id', $depart_range);
-                        }
-                    }
-                }
-            }else{
-                if($is_see){
-                    //查看指定公司 且 我可见
-                    $query->whereIn('id', $id);
-                }elseif ($is_check){
-                    if(! $auth_type){
-                        //查看指定公司
-                        $query->where('top_depart_id', $top_depart_id)
-                            ->when(! empty($check_search), function ($query) use ($check_search) {
-                                return $query->whereRaw($check_search);
-                            });
-                    }else{
-                        if($auth_type == 1) { //指定公司下 且 我创建的  且加上可见
-                            $query->where('top_depart_id', $top_depart_id)
-                                ->where('crt_id',$user['id'])
-                                ->when(! empty($check_search), function ($query) use ($check_search) {
-                                    return $query->whereRaw($check_search);
-                                })
-                                ->when(! empty($id), function ($query) use ($id) {
-                                    return $query->orWhereIn('id', $id);
-                                });
-                        }elseif ($auth_type == 2 || $auth_type == 3){
-                            // (指定公司下的 且 自己权限范围内的部门 或 所有) 且加上可见
-                            $query->where('top_depart_id', $top_depart_id)
-                                ->whereIn('depart_id', $depart_range)
-                                ->when(! empty($check_search), function ($query) use ($check_search) {
-                                    return $query->whereRaw($check_search);
-                                })
-                                ->when(! empty($id), function ($query) use ($id) {
-                                    return $query->orWhereIn('id', $id);
-                                });
-                        }
-                    }
-                }else{
-                    if(! $auth_type){
-                        //查看指定公司
-                        $query->where('top_depart_id', $top_depart_id);
-                    }else{
-                        if($auth_type == 1) { //指定公司下 且 我创建的  且加上可见
-                            $query->where('top_depart_id', $top_depart_id)
-                                ->where('crt_id',$user['id'])
-                                ->when(! empty($id), function ($query) use ($id) {
-                                    return $query->orWhereIn('id', $id);
-                                });
-                        }elseif ($auth_type == 2 || $auth_type == 3){
-                            // (指定公司下的 且 自己权限范围内的部门 或 所有) 且加上可见
-                            $query->where('top_depart_id', $top_depart_id)
-                                ->whereIn('depart_id', $depart_range)
-                                ->when(! empty($id), function ($query) use ($id) {
-                                    return $query->orWhereIn('id', $id);
-                                });
-                        }
-                    }
-                }
-            }
-        }else{
-            //非所有权限
-            if($is_see){
-                //某个分社可见
-                $query->whereIn('id', $id);
-            }elseif ($is_check){
-                if(! $auth_type){
-                    //指定公司下全部  且加上可见
-                    $query->where('top_depart_id', $top_depart_id)
-                        ->whereIn('depart_id', $depart_range)
-                        ->when(! empty($check_search), function ($query) use ($check_search) {
-                            return $query->whereRaw($check_search);
-                        })
-                        ->when(! empty($id), function ($query) use ($id) {
-                            return $query->orWhereIn('id', $id);
-                        });
-                }else{
-                    if($auth_type == 1) {
-                        //指定公司下 且 我创建的 且加上可见
-                        $query->where('top_depart_id', $top_depart_id)
-                            ->where('crt_id',$user['id'])
-                            ->when(! empty($check_search), function ($query) use ($check_search) {
-                                return $query->whereRaw($check_search);
-                            })
-                            ->when(! empty($id), function ($query) use ($id) {
-                                return $query->orWhereIn('id', $id);
-                            });
-                    }elseif ($auth_type == 2) {
-                        //指定公司下 且 自己权限范围内的部门 且加上可见
-                        $query->where('top_depart_id', $top_depart_id)
-                            ->whereIn('depart_id', $depart_range)
-                            ->when(! empty($check_search), function ($query) use ($check_search) {
-                                return $query->whereRaw($check_search);
-                            })
-                            ->when(! empty($id), function ($query) use ($id) {
-                                return $query->orWhereIn('id', $id);
-                            });
-                    }elseif ($auth_type == 3) {
-                        // 指定公司下所有 且加上可见
-                        $query->where('top_depart_id', $top_depart_id)
-                            ->when(! empty($check_search), function ($query) use ($check_search) {
-                                return $query->whereRaw($check_search);
-                            })
-                            ->when(! empty($id), function ($query) use ($id) {
-                                return $query->orWhereIn('id', $id);
-                            });
-                    }
-                }
-            }else{
-                if(! $auth_type){
-                    //指定公司下全部  且加上可见
-                    $query->where('top_depart_id', $top_depart_id)
-                        ->whereIn('depart_id', $depart_range)
-                        ->when(! empty($id), function ($query) use ($id) {
-                            return $query->orWhereIn('id', $id);
-                        });
-                }else{
-                    if($auth_type == 1) {
-                        //指定公司下 且 我创建的 且加上可见
-                        $query->where('top_depart_id', $top_depart_id)
-                            ->where('crt_id',$user['id'])
-                            ->when(! empty($id), function ($query) use ($id) {
-                                return $query->orWhereIn('id', $id);
-                            });
-                    }elseif ($auth_type == 2) {
-                        //指定公司下 且 自己权限范围内的部门 且加上可见
-                        $query->where('top_depart_id', $top_depart_id)
-                            ->whereIn('depart_id', $depart_range)
-                            ->when(! empty($id), function ($query) use ($id) {
-                                return $query->orWhereIn('id', $id);
-                            });
-                    }elseif ($auth_type == 3) {
-                        // 指定公司下所有 且加上可见
-                        $query->where('top_depart_id', $top_depart_id)
-                            ->when(! empty($id), function ($query) use ($id) {
-                                return $query->orWhereIn('id', $id);
-                            });
-                    }
-                }
-            }
-        }
-
-        if(! empty($search['get_my_top_depart_data'])){
-            $depart = ! empty($user['depart_top'][0]) ? $user['depart_top'][0]: [];
-            $depart_id = $depart['depart_id'] ?? 0;
-            $query->where('top_depart_id', $depart_id);
-        }
-    }
-
-    //部门和顶级部门(公司)过滤 取别名a
-    public function scopeAClear($query, $user, $search)
-    {
-        //是否所有部门
-        $is_all_depart = $user['is_all_depart'] ?? 0;
-        //权限范围内的部门
-        $depart_range = $user['depart_range'] ?? [];
-        //我可见的
-        $is_see = $search['is_see'] ?? 0;
-
-        //可见范围方法
-        $model = $query->getModel(); // 获取模型的实例
-        $range_function = $model::range_function ?? ""; // 访问静态属性
-        $is_function_range = $this->hasMethod(new RangeService(),$range_function);
-
-        //顶级部门
-        $search_depart_id = $search['top_depart_id'] ?? 0; //顶级公司
-        if(empty($search_depart_id)){
-            //默认进来 自身顶级公司
-            $top_depart_id = $user['depart_top'][0] ?? [];
-            $top_depart_id = $top_depart_id['depart_id'] ?? 0;
-        }else{
-            //查询 顶级公司
-            $top_depart_id = $search_depart_id;
-        }
-
-        $id = [];
-        //可见范围 以及单据里面填写人员
-        if($is_function_range) $id = RangeService::$range_function($user,$search);
-
-        //个人部门所有
-        $auth_type = $this->getQx($search,$user);
-
-        if($is_all_depart){
-            //所有权限
-            if(empty($search_depart_id)){
-                if(! $is_see){
-                    if(! $auth_type){
-                        //全部
-                        $query->whereIn('a.depart_id', $depart_range);
-                    }else{
-                        if($auth_type == 1) { //我创建的 且加上可见
-                            $query->where('a.crt_id',$user['id'])
-                                ->orWhereIn('a.id', $id);
-                        }elseif ($auth_type == 2 || $auth_type == 3){
-                            //自己权限范围内的部门 或 所有
-                            $query->whereIn('a.depart_id', $depart_range);
-                        }
-                    }
-                }else{
-                    //可见
-                    $query->whereIn('a.id', $id);
-                }
-            }else{
-                if(! $is_see){
-                    if(! $auth_type){
-                        //查看指定公司
-                        $query->where('a.top_depart_id', $top_depart_id);
-                    }else{
-                        if($auth_type == 1) { //指定公司下 且 我创建的  且加上可见
-                            $query->where('a.top_depart_id', $top_depart_id)
-                                ->where('a.crt_id',$user['id'])
-                                ->orWhereIn('a.id', $id);
-                        }elseif ($auth_type == 2 || $auth_type == 3){
-                            // (指定公司下的 且 自己权限范围内的部门 或 所有) 且加上可见
-                            $query->where('a.top_depart_id', $top_depart_id)
-                                ->whereIn('a.depart_id', $depart_range)
-                                ->orWhereIn('a.id', $id);
-                        }
-                    }
-                }else{
-                    //查看指定公司 且 我可见
-                    $query->whereIn('a.id', $id);
-                }
-            }
-        }else{
-            //非所有权限
-            if(! $is_see){
-                if(! $auth_type){
-                    //指定公司下全部  且加上可见
-                    $query->where('a.top_depart_id', $top_depart_id)
-                        ->whereIn('a.depart_id', $depart_range)
-                        ->orWhereIn('a.id', $id);
-                }else{
-                    if($auth_type == 1) {
-                        //指定公司下 且 我创建的 且加上可见
-                        $query->where('a.top_depart_id', $top_depart_id)
-                            ->where('a.crt_id',$user['id'])
-                            ->orWhereIn('a.id', $id);
-                    }elseif ($auth_type == 2) {
-                        //指定公司下 且 自己权限范围内的部门 且加上可见
-                        $query->where('a.top_depart_id', $top_depart_id)
-                            ->whereIn('a.depart_id', $depart_range)
-                            ->orWhereIn('a.id', $id);
-                    }elseif ($auth_type == 3) {
-                        // 指定公司下所有 且加上可见
-                        $query->where('a.top_depart_id', $top_depart_id)
-                            ->orWhereIn('a.id', $id);
-                    }
-                }
-            }else{
-                //某个分社可见
-                $query->whereIn('a.id', $id);
-            }
-        }
-    }
-
-    //部门和顶级部门(公司)过滤 Old
-    public function scopeClear1($query, $user, $search)
-    {
-        //是否所有部门
-        $is_all_depart = $user['is_all_depart'] ?? 0;
-        //权限范围内的部门
-        $depart_range = $user['depart_range'] ?? [];
-        //我可见的
-        $is_see = $search['is_see'] ?? 0;
-
-        //可见范围方法
-        $model = $query->getModel(); // 获取模型的实例
-        $range_function = $model::range_function ?? ""; // 访问静态属性
-        $is_function_range = $this->hasMethod(new RangeService(),$range_function);
-
-        //顶级部门
-        $search_depart_id = $search['top_depart_id'] ?? 0; //顶级公司
-        if(empty($search_depart_id)){
-            //默认进来 自身顶级公司
-            $top_depart_id = $user['depart_top'][0] ?? [];
-            $top_depart_id = $top_depart_id['depart_id'] ?? 0;
-        }else{
-            //查询 顶级公司
-            $top_depart_id = $search_depart_id;
-        }
-
-        $id = [];
-        //可见范围 以及单据里面填写人员
-        if($is_function_range) $id = RangeService::$range_function($user,$search);
-
-        if($is_all_depart){
-            //所有部门
-            if(empty($search_depart_id)){
-                if(! $is_see){
-                    //全部
-                    $query->whereIn('depart_id', $depart_range);
-                }else{
-                    //可见
-                    $query->whereIn('id', $id);
-                }
-            }else{
-                if(! $is_see){
-                    //查看某个分社
-                    $query->where('top_depart_id', $top_depart_id);
-                }else{
-                    //查看某个分社可见
-                    $query->whereIn('id', $id);
-                }
-            }
-        }else{
-            //某个分社
-            if(! $is_see){
-                //某个分社全部
-                $query->where('top_depart_id', $top_depart_id)
-                    ->whereIn('depart_id', $depart_range)
-                    ->orWhereIn('id', $id);
-            }else{
-                //某个分社可见
-                $query->whereIn('id', $id);
-            }
-        }
-    }
-
-    //顶级部门过滤 取别名a
-    public function scopeATopClear($query, $user, $search)
-    {
-        //是否所有部门
-        $is_all_depart = $user['is_all_depart'] ?? 0;
-        //权限范围内的部门
-        $depart_range = $user['depart_range'] ?? [];
-
-        //顶级部门
-        $search_depart_id = $search['top_depart_id'] ?? 0;
-        if(empty($search_depart_id)){
-            //默认进来 自身顶级公司
-            $top_depart_id = $user['depart_top'][0] ?? [];
-            $top_depart_id = $top_depart_id['depart_id'] ?? 0;
-        }else{
-            //查询 顶级公司
-            $top_depart_id = $search_depart_id;
-        }
-
-        if($is_all_depart){
-            //所有部门
-            if(empty($search_depart_id)){
-                //全部
-                $query->whereIn('a.top_depart_id', $depart_range);
-            }else{
-                //查看某个分社
-                $query->where('a.top_depart_id', $top_depart_id);
-            }
-        }else{
-            //某个分社全部
-            $query->where('a.top_depart_id', $top_depart_id);
-        }
-
-        return $query;
-    }
-
-    //产品不可见 部门和顶级部门(公司)过滤
-    public function scopeProductClear($query, $user, $search)
-    {
-        //是否所有部门
-        $is_all_depart = $user['is_all_depart'] ?? 0;
-        //权限范围内的部门
-        $depart_range = $user['depart_range'] ?? [];
-        //总社id
-        $top_depart_id = $user['head'] ?? [];
-        $top_depart = $top_depart_id['id'] ?? 0;
-
-        //可见范围方法
-        $model = $query->getModel(); // 获取模型的实例
-        $range_function = $model::range_function ?? ""; // 访问静态属性
-        $is_function_range = $this->hasMethod(new RangeService(),$range_function);
-
-        //顶级部门
-        $search_depart_id = $search['top_depart_id'] ?? 0; //顶级公司
-        if(empty($search_depart_id)){
-            //默认进来 自身顶级公司
-            $top_depart_id = $user['depart_top'][0] ?? [];
-            $top_depart_id = $top_depart_id['depart_id'] ?? 0;
-        }else{
-            //查询 顶级公司
-            $top_depart_id = $search_depart_id;
-        }
-
-        $id = [];
-        //产品 不可见范围
-        if($is_function_range) $id = RangeService::$range_function($user,$search);
-
-        if($is_all_depart){
-            //所有部门
-            if(empty($search_depart_id)){
-                //全部
-                $query->whereIn('depart_id', $depart_range);
-            }else{
-                //查看某个分社
-                $query->where('top_depart_id', $top_depart_id);
-            }
-        }else{
-            //某个分社全部 去掉不可见数
-            $query->where('top_depart_id', $top_depart_id)
-                ->whereIn('depart_id', $depart_range)
-                ->orWhere('top_depart_id',$top_depart)
-                ->whereNotIn('id', $id);
-        }
-    }
-
-    public function getQx($data, $user){
-        if(empty($data['menu_id'])) return 0;
-        if($user['id'] == Employee::SPECIAL_ADMIN) return 0;
-        if(! empty($user['role_authority'][$data['menu_id']])) {
-            //指定菜单 显示对应权限
-            return $user['role_authority'][$data['menu_id']];
-        }else{
-            return 0;
-        }
-    }
-
-    function hasMethod($class, $methodName)
-    {
-        $reflection = new \ReflectionClass($class);
-        return $reflection->hasMethod($methodName);
-    }
-}

+ 0 - 267
app/Service/BasicTypeService.php

@@ -1,267 +0,0 @@
-<?php
-
-namespace App\Service;
-
-use App\Model\BasicType;
-use App\Model\Depart;
-use Illuminate\Support\Facades\DB;
-
-/**
- * 基础分类设置相关
- */
-class BasicTypeService extends Service
-{
-    /**
-     * 基础类型编辑
-     * @param $data
-     * @return array
-     */
-    public function basicTypeEdit($data, $user){
-        list($status,$msg) = $this->basicTypeRule($data,$user,false);
-        if(!$status) return [$status,$msg];
-
-        $update = $msg['data'][0];
-        BasicType::where('id',$data['id'])->update($update);
-
-        return [true,''];
-    }
-
-    /**
-     * 基础类型新增
-     * @param $data
-     * @return array
-     */
-    public function basicTypeAdd($data,$user){
-        list($status,$msg) = $this->basicTypeRule($data, $user);
-        if(!$status) return [$status,$msg];
-
-        BasicType::insert($msg['data']);
-
-        return [true,''];
-    }
-
-    /**
-     * 基础类型删除
-     * @param $data
-     * @return array
-     */
-    public function basicTypeDel($data){
-        if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
-
-        BasicType::whereIn('id',$data['id'])->update([
-            'del_time'=>time()
-        ]);
-
-        return [true,''];
-    }
-
-    /**
-     * 基础类型列表
-     * @param $data
-     * @return array
-     */
-    public function basicTypeList($data, $user){
-        $model = BasicType::TopClear($user,$data);
-        $model = $model->where('del_time',0)
-            ->select('title','id','type','code','top_depart_id')
-            ->orderby('id', 'asc');
-
-        if(! empty($data['type'])) $model->where('type',$data['type']);
-        if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
-
-        $list = $this->limit($model,'',$data);
-        $list = $this->fillData($list);
-
-        return [true, $list];
-    }
-
-    public function basicTypeCustomerList($data, $user){
-        $data['top_depart_id'] = $user['head']['id'];
-        $model = BasicType::TopClear($user,$data);
-        $model = $model->where('del_time',0)
-            ->select('title','id','type','code','top_depart_id')
-            ->orderby('id', 'asc');
-
-        if(! empty($data['type'])) $model->where('type',$data['type']);
-        if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
-
-        $list = $this->limit($model,'',$data);
-        $list = $this->fillData($list);
-
-        return [true, $list];
-    }
-
-    /**
-     * 基础类型参数规则
-     * @param $data
-     * @param $is_check
-     * @return array
-     */
-    public function basicTypeRule($data,$user, $is_check = true){
-        if($this->isEmpty($data,'data')) return [false,'数据不能为空!'];
-
-        //所属部门 以及  顶级部门
-        if(empty($data['depart_id'])) $data['depart_id'] = $this->getDepart($user);
-        $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
-
-        $type = array_column($data['data'],'type');
-        $type = array_map(function($val) {
-            return $val !== null ? $val : 0;
-        }, $type);
-        foreach ($type as $value){
-            if(empty($value)) return [false,'类型不能为空!'];
-            if(! isset(BasicType::$type[$value])) return [false,'类型不存在!'];
-        }
-
-        $map = [];
-        foreach ($data['data'] as $value){
-            if(! isset($map[$value['title']])){
-                $map[$value['title']][] = $value['type'];
-            }else{
-                if(! in_array($value['type'],$map[$value['title']])){
-                    $map[$value['title']][] = $value['type'];
-                }
-            }
-        }
-
-        $title = array_column($data['data'],'title');
-        $title = array_map(function($val) {
-            return $val !== null ? $val : 0;
-        }, $title);
-        $title_count = array_count_values($title);
-        foreach ($title as $value){
-            if(empty($value)) return [false,'名称不能为空!'];
-            if($title_count[$value] > 1 && count($map[$value]) != $title_count[$value]) return [false,'同一归属类别下,名称不能重复'];
-        }
-
-        foreach ($data['data'] as $key => $value){
-            $data['data'][$key]['type'] = $value['type'];
-            $data['data'][$key]['upd_time'] = time();
-            if($is_check){
-                $bool = BasicType::where('title',$value['title'])
-                    ->where('top_depart_id',$data['top_depart_id'])
-                    ->where('type',$value['type'])
-                    ->where('del_time',0)
-                    ->exists();
-                $data['data'][$key]['crt_time'] = time();
-                $data['data'][$key]['crt_id'] = $user['id'];
-                $data['data'][$key]['depart_id'] = $data['depart_id'];
-                $data['data'][$key]['top_depart_id'] = $data['top_depart_id'];
-            }else{
-                if($this->isEmpty($data,'id')) return [false,'id不能为空!'];
-                $top_depart_id = BasicType::where('id',$data['id'])->value('top_depart_id');
-                $bool = BasicType::where('title',$value['title'])
-                    ->where('top_depart_id',$top_depart_id)
-                    ->where('type',$value['type'])
-                    ->where('id','<>',$data['id'])
-                    ->where('del_time',0)
-                    ->exists();
-            }
-            if($bool) return [false,'名称不能重复'];
-        }
-
-        return [true, $data];
-    }
-
-    /**
-     * 拼接数据
-     * @param $data
-     * @return array
-     */
-    public function fillData($data){
-        if(empty($data['data'])) return $data;
-
-        foreach ($data['data'] as $key => $value){
-            $data['data'][$key]['type_name'] = BasicType::$type[$value['type']] ?? '';
-        }
-
-        return $data;
-    }
-
-    public function basicTypeSearch($data){
-        $basic = BasicType::where('title', 'LIKE', '%'.$data.'%')
-            ->select('id')
-            ->get()->toArray();
-        return array_column($basic,'id');
-    }
-
-    public function basicTypeSearchId($data){
-        $title = "";
-        $basic = BasicType::where('id', $data)
-            ->select('title')
-            ->first();
-        if(! empty($basic)) $title = $basic->title;
-        $basic = BasicType::where('title', $title)
-            ->select('id')
-            ->get()->toArray();
-        return array_column($basic,'id');
-    }
-
-    //获取当前
-    public function getMyBasicList($user, $type){
-        if(! is_array($type)) $type = [$type];
-        $depart_id = $this->getDepart($user);
-        $top_depart_id = $user['depart_map'][$depart_id] ?? 0;
-        return BasicType::where('del_time',0)
-            ->whereIn('type',$type)
-            ->where('top_depart_id',$top_depart_id)
-            ->get()->toArray();
-    }
-
-    public function maked(){
-        $list = BasicType::where('del_time',0)
-            ->select('title','type','top_depart_id')
-            ->get()->toArray();
-        $basic_type2 = [];
-        $basic_other_type = [];
-        foreach ($list as $value){
-            if($value['top_depart_id'] == 2){
-                if(! in_array($value['type'], [28,23,24,22,8])){
-                    $basic_type2[] = $value['title'] . '|' . $value['type'];
-                }
-            }else{
-                $basic_other_type[$value['top_depart_id']][] = $value['title'] . '|' . $value['type'];
-            }
-        }dd($basic_type2);
-        $depart = Depart::where('del_time',0)
-            ->where('id','<>',2)
-            ->where('parent_id',0)
-//            ->whereIn('id',[139,49])
-            ->select('id')
-            ->orderBy('id','asc')
-            ->get()->toArray();
-        $depart = array_column($depart,'id');
-        $insert = [];
-        $time = time();
-        foreach ($depart as $value){
-            if(! empty($basic_other_type[$value])){
-                foreach ($basic_type2 as $val){
-                    if(! in_array($val,$basic_other_type[$value])) {
-                        $tmp = explode('|',$val);
-                        $insert[] = [
-                            'title' => $tmp[0],
-                            'type' => $tmp[1],
-                            'top_depart_id' => $value,
-                            'crt_time' => $time,
-                            'crt_id' => 1
-                        ];
-                    }
-                }
-            }else{
-                foreach ($basic_type2 as $val){
-                    $tmp = explode('|',$val);
-                    $insert[] = [
-                        'title' => $tmp[0],
-                        'type' => $tmp[1],
-                        'top_depart_id' => $value,
-                        'crt_time' => $time,
-                        'crt_id' => 1
-                    ];
-                }
-            }
-        }
-
-        if(! empty($insert)) BasicType::insert($insert);
-        dd('ok');
-    }
-}

+ 0 - 255
app/Service/BookingListService.php

@@ -1,255 +0,0 @@
-<?php
-
-namespace App\Service;
-
-use App\Model\BookingList;
-use App\Model\BookingListInfo;
-use App\Model\Employee;
-use App\Model\OrderOperation;
-use App\Model\SalesOrder;
-use Illuminate\Support\Facades\DB;
-
-class BookingListService extends Service
-{
-    public function customerEdit($data,$user){
-        list($status,$msg) = $this->customerRule($data,$user, false);
-        if(!$status) return [$status,$msg];
-
-        try {
-            DB::beginTransaction();
-
-            $model = BookingList::where('id',$data['id'])->first();
-            $model->type = $data['type'];
-            $model->mark = $data['mark'] ?? '';
-            $model->amount = $data['amount'] ?? 0;
-            $model->save();
-
-            $time = time();
-            BookingListInfo::where('del_time',0)
-                ->where('booking_list_id',$data['id'])
-                ->update(['del_time' => $time]);
-            if(! empty($data['file'])){
-                $insert = [];
-                foreach ($data['file'] as $value){
-                    $insert[] = [
-                        'booking_list_id' => $model->id,
-                        'file' => $value['url'],
-                        'type' => BookingListInfo::type_one,
-                        'name' => $value['name'],
-                        'crt_time' => $time,
-                    ];
-                }
-                BookingListInfo::insert($insert);
-            }
-
-            DB::commit();
-        }catch (\Exception $exception){
-            DB::rollBack();
-            return [false,$exception->getMessage()];
-        }
-
-        return [true,''];
-    }
-
-    public function customerAdd($data,$user){
-        list($status,$msg) = $this->customerRule($data,$user);
-        if(!$status) return [$status,$msg];
-
-        try {
-            DB::beginTransaction();
-
-            $model = new BookingList();
-            $model->data_id = $data['data_id'];
-            $model->data_type = $data['data_type'] ?? 0;
-            $model->type = $data['type'] ?? 0;
-            $model->amount = $data['amount'] ?? 0;
-            $model->mark = $data['mark'] ?? '';
-            $model->crt_id = $user['id'];
-            $model->save();
-
-            if(! empty($data['file'])){
-                $insert = [];
-                foreach ($data['file'] as $value){
-                    $insert[] = [
-                        'booking_list_id' => $model->id,
-                        'file' => $value['url'],
-                        'type' => BookingListInfo::type_one,
-                        'name' => $value['name'],
-                        'crt_time' => time(),
-                    ];
-                }
-                BookingListInfo::insert($insert);
-            }
-
-            if($data['data_type'] == BookingList::data_type_one){
-                $order = SalesOrder::where('id',$data['data_id'])->first();
-                $order = $order->toArray();
-                (new OrderOperationService())->add([
-                    'order_number' => $order['order_number'],
-                    'msg' => OrderOperation::$type[OrderOperation::seven],
-                    'type' => OrderOperation::seven
-                ],$user);
-            }
-
-            DB::commit();
-        }catch (\Exception $exception){
-            DB::rollBack();
-            return [false,$exception->getMessage()];
-        }
-
-        return [true,''];
-    }
-
-    public function customerDel($data){
-        if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
-        $booking = BookingList::where('del_time',0)->where('id',$data['id'])->first();
-        if(empty($booking)) return [false,'记录不存在或已被删除'];
-        $booking = $booking->toArray();
-        if($booking['state'] != BookingList::STATE_ZERO) return [false,'请确认记录状态,删除失败'];
-
-        try {
-            DB::beginTransaction();
-
-            $time = time();
-            BookingList::where('id',$data['id'])->update([
-                'del_time'=> $time
-            ]);
-            BookingListInfo::where('del_time',0)
-                ->where('booking_list_id',$data['id'])
-                ->update(['del_time' => $time]);
-
-            DB::commit();
-        }catch (\Exception $exception){
-            DB::rollBack();
-            return [false,$exception->getMessage()];
-        }
-
-        return [true,''];
-    }
-
-    public function customerDetail($data){
-        if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
-
-        $customer = BookingList::where('del_time',0)
-            ->where('id',$data['id'])
-            ->first();
-        if(empty($customer)) return [false,'记录不存在或已被删除'];
-        $customer = $customer->toArray();
-        $customer['state_title'] = BookingList::$name[$customer['state']] ?? "";
-        $customer['type_title'] = BookingList::$model_type[$customer['type']] ?? "";
-
-        $customer['crt_name'] = Employee::where('id',$customer['crt_id'])->value('emp_name');
-        $customer['crt_time'] = $customer['crt_time'] ? date("Y-m-d H:i:s",$customer['crt_time']): '';
-
-        $file = BookingListInfo::where('del_time',0)
-            ->where('booking_list_id',$data['id'])
-            ->get()->toArray();
-        $customer['file'] = [];
-        foreach ($file as $value){
-            if($value['type'] == BookingListInfo::type_one){
-                $tmp = [
-                    'url' => $value['file'],
-                    'name' => $value['name'],
-                ];
-                $customer['file'][] = $tmp;
-            }
-        }
-
-        return [true, $customer];
-    }
-
-    public function customerList($data,$user){
-        $model = BookingList::where('del_time',0)
-            ->select('id','data_id','data_type','type','amount','crt_id','crt_time','state','mark')
-            ->orderby('id', 'asc');
-
-        if(! empty($data['data_id'])) $model->where('data_id', $data['data_id']);
-        if(! empty($data['data_type'])) $model->where('data_type',$data['data_type']);
-
-        $list = $this->limit($model,'',$data);
-        $list = $this->fillData($list);
-
-        return [true, $list];
-    }
-
-    public function customerRule(&$data, $user, $is_add = true){
-        if(empty($data['data_id'])) return [false,'数据ID不能为空'];
-        if(empty($data['data_type'])) return [false,'数据类型不能为空'];
-        if(empty($data['type'])) return [false,'金额类型不能为空'];
-        if(empty($data['amount'])) return [false,'金额不能为空'];
-        $res = $this->checkNumber($data['amount']);
-        if(! $res) return [false, '金额请输入不超过两位小数并且大于0的数值'];
-
-        if($data['data_type'] == BookingList::data_type_one){
-            $bool = SalesOrder::where('id',$data['data_id'])->where('state',SalesOrder::State2_zero)->exists();
-            if($bool) return [false,'合同还未指派,添加金额记录失败'];
-        }
-
-        if($is_add){
-
-        }else{
-            if(empty($data['id'])) return [false,'ID不能为空'];
-            $booking = BookingList::where('del_time',0)->where('id',$data['id'])->first();
-            if(empty($booking)) return [false,'记录不存在或已被删除'];
-            $booking = $booking->toArray();
-            if($booking['state'] != BookingList::STATE_ZERO) return [false,'请确认记录状态,编辑失败'];
-
-        }
-
-        return [true, ''];
-    }
-
-    public function fillData($data){
-        if(empty($data['data'])) return $data;
-
-        $emp = Employee::whereIn('id',array_unique(array_column($data['data'],'crt_id')))
-            ->pluck('emp_name','id')
-            ->toArray();
-
-        foreach ($data['data'] as $key => $value){
-            $data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
-            $data['data'][$key]['crt_name'] = $emp[$value['crt_id']] ?? '';
-            $data['data'][$key]['state_title'] = BookingList::$name[$value['state']] ?? '';
-            $data['data'][$key]['type_title'] = BookingList::$model_type[$value['type']] ?? '';
-        }
-
-        return $data;
-    }
-
-    public function customerConfirm($data){
-        if(empty($data['id'])) return [false,'记录ID不能为空'];
-        $customer = BookingList::where('del_time',0)
-            ->where('id',$data['id'])
-            ->first();
-        if(empty($customer)) return [false,'记录不存在或已被删除'];
-        $customer = $customer->toArray();
-        if($customer['state'] != BookingList::STATE_ZERO) return [false,'请确认记录状态,确认金额失败'];
-
-        BookingList::where('id',$data['id'])->update(['state' => BookingList::STATE_ONE]);
-
-        return [true,''];
-    }
-
-    public function getAllAmount($data_id = [], $data_type = 0){
-        if(empty($data_id) || empty($data_type)) return [];
-        return [];
-
-        $booking = BookingList::where('del_time',0)
-            ->where('state',BookingList::STATE_ONE)
-            ->whereIn('data_id',$data_id)
-            ->where('data_type',$data_type)
-            ->select('data_id','amount','type')
-            ->get()->toArray();
-
-        $return = [];
-        foreach ($booking as $value){
-            if(isset($return[$value['data_id']][$value['type']])){
-                $return[$value['data_id']][$value['type']] += $value['amount'];
-            }else{
-                $return[$value['data_id']][$value['type']] = $value['amount'];
-            }
-        }
-
-        return $return;
-    }
-}

+ 0 - 1580
app/Service/CheckService.php

@@ -1,1580 +0,0 @@
-<?php
-
-namespace App\Service;
-
-use App\Model\Construction;
-use App\Model\ConstructionProductInfo;
-use App\Model\Customer;
-use App\Model\Depart;
-use App\Model\Employee;
-use App\Model\InOutRecord;
-use App\Model\InvoiceOrder;
-use App\Model\InvoiceOrderInfo;
-use App\Model\OrderOperation;
-use App\Model\PaymentReceipt;
-use App\Model\PaymentReceiptInfo;
-use App\Model\ProductInventory;
-use App\Model\ProductInventorySet;
-use App\Model\PurchaseOrder;
-use App\Model\PurchaseOrderInfo;
-use App\Model\PurchaseOrderSpecial;
-use App\Model\PurchaseOrderSpecialInfo;
-use App\Model\ReturnExchangeOrder;
-use App\Model\ReturnExchangeOrderProductInfo;
-use App\Model\SalesOrder;
-use App\Model\SalesOrderInfo;
-use App\Model\SalesOrderOtherFee;
-use App\Model\SalesOrderProductInfo;
-use App\Model\SeeRange;
-use App\Model\Storehouse;
-use App\Model\Supplier;
-use App\Service\OaService;
-use Illuminate\Support\Facades\DB;
-
-class CheckService extends Service
-{
-    //特殊操作数
-    const minus_one = -1;//跳出库存流水
-
-    //审批操作对应的数值
-    const one = 1; //收货
-    const two = 2; //发货
-    const three = 3; //采购单入库
-    const four = 4; //合同公司完结
-    const five = 5; //施工单
-    const six = 6; //退换货单
-    const seven = 7; //采购单确认
-    const eight = 8; //合同确认
-    const nine = 9; //合同客户完结
-    const ten  = 10; //收付款确认
-    const eve  = 11; //接受派单
-
-    //中文对照
-    public $map = [
-        self::one => '收货单',
-        self::two => '发货单',//确认后出库
-        self::three => '采购单入库',//确认后入库
-        self::four => '公司完结', // 安装件 合同完结
-        self::five => '施工单',//确认后出库
-        self::six => '退换货单',//确认后出库或出库入库
-        self::seven => '采购单确认',
-        self::eight => '合同确认',
-        self::nine => '合同客户完结',
-        self::ten => '收付款确认',
-        self::eve => '接受门店派单',
-    ];
-
-    //入库操作
-    public static $in_opt = [
-        self::three,
-    ];
-
-    //出库操作
-    public static $out_opt = [
-        self::two,
-        self::five,
-    ];
-
-    const TYPE_ONE = 1;//通过
-    const TYPE_TWO = 2;//不通过
-    const TYPE_THREE = 3;//通过后驳回
-
-    //改为待审核状态 校验
-    public static $opt_1case_check = [
-        self::five => 'checkConstruction',//施工单
-    ];
-
-    //改为待审核状态
-    public static $opt_1case = [
-        self::two => 'waitInvoice',//发货单
-//        self::three => 'waitPurchase',//采购单 入库
-        self::five => 'waitConstruction',//施工单
-        self::six => 'waitReturnExchange',//退换货单
-        self::seven => 'waitPurchaseConfirm', //采购单确认
-        self::eight => 'waitSales', // 合同安装件 合同确认
-        self::ten => 'waitPaymentReceipt', //收付款确认
-    ];
-
-    public static $finished = [
-        self::three => 'confirmPurchaseOrder',//采购单 入库
-        self::four => 'settleSalesOrder', // 合同 安装件 合同公司完结
-        self::nine => 'settleSalesOrderCustomer', // 合同 安装件 合同客户完结
-        self::eve => 'settleSalesOrderConfirm', // 合同 安装件 合同接收
-    ];
-
-    //单据操作
-    public static $opt_case = [
-        self::two => 'confirmInvoiceOrder',
-//        self::three => 'confirmPurchaseOrder',
-        self::five => 'confirmConstruction',
-        self::six => 'confirmReturnExchangeOrder',
-        self::seven => 'confirmPurchaseOrderState',
-        self::eight => 'confirmSales', // 合同 安装件 合同确认
-        self::ten => 'confirmPaymentReceipt', // 确认收付款单
-    ];
-
-    //单据库存流水
-    public static $record = [
-        self::two => 'recordInvoiceOrder',
-        self::three => 'recordPurchaseOrder',
-        self::five => 'recordConstruction',
-        self::six => 'recordReturnExchangeOrder'
-    ];
-
-    //自动生成
-    public static $create = [
-        self::seven => 'createPurchaseOrderSales', //分社合同生成
-        self::four => 'createPurchaseOrder', // 派给分社的合同 公司完结以后生成虚拟采购单
-    ];
-
-    //自动生成的删除
-    public static $create_del = [
-        self::seven => 'delCreatePurchaseOrderSales', //分社合同生成(删除)
-//        self::four => 'delCreatePurchaseOrder', // 派给分社的合同确认以后生成虚拟采购单
-    ];
-
-    //审核通过后 驳回
-    public static $opt_case_reject = [
-        self::four => 'reject_sales', // 合同
-//        self::three => 'reject_purchase', //采购入库
-        self::seven => 'reject_purchase_confirm', //采购确认驳回
-        self::five => 'reject_construction',//施工单
-        self::six => 'reject_return_exchange',//退换货
-        self::ten => 'reject_payment_receipt',//收付款单
-    ];
-
-    //审核通过后 驳回 产生流水
-    public static $reject_record = [
-        self::five => 'reject_record_construction', //施工单驳回
-        self::three => 'reject_record_purchase', //采购
-        self::six => 'reject_record_return_exchange',//退换货
-    ];
-
-    //旅程日志 同意
-    public static $operation_order = [
-        self::eight => OrderOperation::three, //合同确认
-        self::two => OrderOperation::eight, //发货单确认
-        self::six => OrderOperation::nine, //退换货审核
-        self::five => OrderOperation::eve, //施工单
-        self::seven => OrderOperation::thi,//采购单确认
-        self::three => OrderOperation::fourteen,//采购单入库
-        self::ten => OrderOperation::twenty_one,//收付款单
-    ];
-
-    //旅程日志 驳回
-    public static $operation_order_reject = [
-        self::four => OrderOperation::four, //合同弃审
-        self::six => OrderOperation::ten, //退换货弃审
-        self::five => OrderOperation::twl, //施工单弃审
-        self::three => OrderOperation::fif,//采购单入库弃审
-        self::seven => OrderOperation::twenty,//采购单确认弃审
-        self::ten => OrderOperation::twenty_two,//收付款单
-    ];
-
-    //校验
-    public function checkConstruction($data, $user){
-        $order = Construction::where('del_time',0)
-            ->where('order_number',$data['order_number'])
-            ->first();
-        if(empty($order)) return [false,'施工单不存在或已被删除'];
-        $order = $order->toArray();
-
-        //总社id
-        $head = $user['head'] ?? [];
-        $head = $head['id'] ?? 0;
-        //分社自己的施工单 直接返回
-        if($order['top_depart_id'] != $head) return [true, ''];
-        //不校验库存
-        if($user['is_check_stock'] == ProductInventorySet::type_two)  return [true,''];
-
-        //施工单产品
-        $sub = ConstructionProductInfo::where('construction_id',$order['id'])
-            ->where('del_time',0)
-            ->get()->toArray();
-        if(empty($sub)) return [false,'施工单产品不存在或已被删除'];
-        $product_submit = $product_id = [];
-        foreach ($sub as $value){
-            $product_id[] = $value['product_id'];
-            $key = $value['product_id'] . ',' . $value['storehouse_id'];
-            if(isset($product_save[$key])){
-                $product_submit[$key] += $value['number'];
-            }else{
-                $product_submit[$key] = $value['number'];
-            }
-        }
-
-        //比较库存
-        list($status,$msg) = (new ProductInventoryService())->compareStock($user,$product_id, $product_submit, []);
-        if(! $status) return [false, $msg];
-
-        //锁定库存
-        ProductInventoryService::changeLockNumber($user,$product_submit);
-
-        return [true, ''];
-    }
-
-    //改为待审核---------------------------------
-    public function waitInvoice($data){
-        $model = InvoiceOrder::where('id',$data['id'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '发货单不存在或已被删除'];
-        if($model->state != InvoiceOrder::STATE_ZERO) return [false, '请确认发货单状态,操作失败'];
-
-        InvoiceOrder::where('del_time',0)->where('id',$data['id'])
-            ->update(['state' => InvoiceOrder::STATE_ONE]);
-
-        return [true, $model->toArray()];
-    }
-
-    public function waitPurchaseConfirm($data){
-        $model = PurchaseOrder::where('id',$data['id'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false,'采购单不存在或已被删除'];
-        if($model->state != PurchaseOrder::STATE_ZERO) return [false,'请确认采购单状态,操作失败'];
-
-        //待确认
-        PurchaseOrder::where('id',$data['id'])->update(['state' => PurchaseOrder::STATE_ONE]);
-        return [true, $model->toArray()];
-    }
-
-    public function waitPurchase($data){
-        $model = PurchaseOrder::where('id',$data['id'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '采购订单不存在或已被删除'];
-        if($model->state != PurchaseOrder::STATE_TWO) return [false, '请确认采购订单状态,操作失败'];
-
-        //待入库
-        PurchaseOrder::where('del_time',0)->where('id',$data['id'])
-            ->update(['state' => PurchaseOrder::STATE_Three]);
-
-        return [true, $model->toArray()];
-    }
-
-    public function waitConstruction($data){
-        $model = Construction::where('id',$data['id'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '施工单不存在或已被删除'];
-        if($model->state != Construction::STATE_ZERO) return [false, '请确认施工单状态,操作失败'];
-
-        //待确认
-        Construction::where('del_time',0)->where('id',$data['id'])
-            ->update(['state' => Construction::STATE_ONE]);
-
-        return [true, $model->toArray()];
-    }
-
-    public function waitReturnExchange($data){
-        $model = ReturnExchangeOrder::where('id',$data['id'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '退换货单不存在或已被删除'];
-        if($model->state != ReturnExchangeOrder::State_zero) return [false, '请确认退换货单状态,操作失败'];
-
-        //待确认
-        ReturnExchangeOrder::where('del_time',0)->where('id',$data['id'])
-            ->update(['state' => ReturnExchangeOrder::State_one]);
-
-        return [true, $model->toArray()];
-    }
-
-    public function waitSales($data){
-        $model = SalesOrder::where('id', $data['id'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '合同不存在或已被删除'];
-        //安装件
-        if(! in_array($model->state, [SalesOrder::State_minus_one,SalesOrder::State_zero])) return [false, '请确认合同状态,操作失败'];
-
-        SalesOrder::where('del_time',0)->where('id',$data['id'])
-            ->update(['state' => SalesOrder::State_one]);
-
-        return [true, $model->toArray()];
-    }
-
-    public function waitPaymentReceipt($data){
-        $model = PaymentReceipt::where('id', $data['id'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '收付款单不存在或已被删除'];
-        if($model->state != PaymentReceipt::STATE_ZERO) return [false, '请确认收付款单状态,操作失败'];
-
-        PaymentReceipt::where('del_time',0)->where('id',$data['id'])
-            ->update(['state' => PaymentReceipt::STATE_ONE]);
-
-        return [true, $model->toArray()];
-    }
-    //改为待审核---------------------------------
-
-    //自动生成-----------------------------------
-    //总社派给分社的合同 完成生成虚拟采购单
-    public function createPurchaseOrder($order,$user){
-        //快递件
-        if($order['sales_order_type'] == SalesOrder::Order_type_two) return [true,''];
-
-        //不是总公司的合同
-        $head = $user['head'] ?? [];
-        $head = $head['id'] ?? 0; //总社id
-        if($head != $order['top_depart_id']) return [true, ''];
-
-        $see = SeeRange::where('del_time',0)
-            ->where('data_id',$order['id'])
-            ->where('data_type',SeeRange::type_seven)
-            ->where('type',SeeRange::data_three)
-            ->first();
-        if(empty($see)) return [false, '未找到指派分社信息'];
-        $depart_id = $see->param_id;//指派的分社
-
-        //总社指派给自己
-        if($depart_id == $head) return [true, ''];
-
-        //获取指派分社时候的金额
-        $fee = SalesOrderOtherFee::where('del_time',0)
-            ->where('sales_order_id',$order['id'])
-            ->first();
-        if(empty($fee)) return [false, '未找到指派分社时填写的金额'];
-        $fee = $fee->toArray();
-
-        $order_number = (new OrderNoService())->createOrderNumber(PurchaseOrderSpecial::prefix);
-        $storehouse = Storehouse::where('depart_id',$head)->value('id');
-        $product = SalesOrderProductInfo::where('del_time',0)
-            ->where('sales_order_id',$order['id'])
-            ->select('product_id','number','retail_price')
-            ->get()->toArray();
-        $product_map = $rate = [];
-        $total = 0;
-        foreach ($product as $value){
-            $total += $value['number'] * $value['retail_price'];
-            if(isset($product_map[$value['product_id']])){
-                $product_map[$value['product_id']] += $value['retail_price'] * $value['number'];
-            }else{
-                $product_map[$value['product_id']] = $value['retail_price'] * $value['number'];
-            }
-        }
-        foreach ($product_map as $key => $value){
-            $rate[$key] = sprintf("%.2f", round($value / $total, 2));
-        }
-
-        $model = new PurchaseOrderSpecial();
-        $model->order_number = $order_number;
-        $model->sales_order_id = $order['id'];
-        $model->depart_id = $head;
-        $model->top_depart_id = $head;
-        $model->crt_id = Employee::SPECIAL_ADMIN;
-        $model->purchase_id = Employee::SPECIAL_ADMIN;
-        $model->purchase_total = $fee['other_fee_1'] ?? 0;
-        $model->storehouse_id = $storehouse ?? 0;
-        $model->save();
-        if(empty($model->id)) return [false,'采购单主信息生成失败'];
-        $purchase_order_id = $model->id;
-
-        $insert = [];$product_total = 0;
-        foreach ($product as $value){
-            $rate_tmp = $rate[$value['product_id']] ?? 0;
-            $price = sprintf("%.2f", round($rate_tmp * $fee['other_fee_1'] / $value['number'], 2));
-            $product_total += $price * $value['number'];
-            $insert[] = [
-                'purchase_order_special_id' => $purchase_order_id,
-                'product_id' => $value['product_id'],
-                'order_number' => $order_number,
-                'number' => $value['number'],
-                'price' => $price,
-                'storehouse_id' => $storehouse,
-            ];
-        }
-        PurchaseOrderSpecialInfo::insert($insert);
-        PurchaseOrderSpecial::where('id',$purchase_order_id)->update(['total' => $product_total]);
-
-        return [true, ''];
-    }
-
-    //分社向总社采购 生成 分社订货合同
-    public function createPurchaseOrderSales($order,$user){
-        //没有供应商 不创建合同
-        if(empty($order['supplier'])) return [true, ''];
-        //总公司的采购单 不创建合同
-        $head = $user['head'] ?? [];
-        $head = $head['id'] ?? 0; //总社id
-        if($head == $order['top_depart_id']) return [true, ''];
-        //分社公司的采购单 不向总供应商采购 不创建合同
-        $is_create = Supplier::where('id',$order['supplier'])->value('is_main');
-        if(empty($is_create)) return [true, ''];
-        $customer_short_name = Depart::where('id',$order['top_depart_id'])->value('id') ?? "";
-
-        $prefix = SalesOrder::$prefix[SalesOrder::Model_type_two];
-        $order_number = OrderNoService::createSalesOrderNumber($prefix);
-        $product = PurchaseOrderInfo::where('del_time',0)
-            ->where('purchase_order_id',$order['id'])
-            ->get()->toArray();
-        if(empty($product)) return [false, '采购订单产品数据不能为空'];
-
-        $time = time();
-        $model = new SalesOrder();
-        $model->model_type = SalesOrder::Model_type_two;
-        $model->sales_order_type = SalesOrder::Order_type_two;
-        $model->customer_id = Customer::special_id;
-        $model->order_number = $order_number;
-        $model->crt_id = $order['crt_id'];
-        $model->depart_id = $head;
-        $model->top_depart_id = $head;
-        $model->other_fee = $order['other_fee'];
-        $model->discount_fee = $order['discount_fee'];
-        $model->contract_fee = $order['purchase_total'];
-        $model->contact_order_no = $order['order_number'];
-        $model->sign_time = $time;
-
-        $model->save();
-        $sales_order_id = $model->id;
-
-        //产品字典
-        $product_map = (new ProductService())->getProductDetail(array_column($product,'product_id'));
-
-        $insert = [];
-        $product_total = 0;
-        foreach ($product as $value){
-            $tmp = $product_map[$value['product_id']] ?? [];
-            $product_total += $value['price'] * $value['number'];
-            $insert[] = [
-                'sales_order_id' => $sales_order_id,
-                'product_id' => $value['product_id'],
-                'number' => $value['number'],
-                'basic_type_id' => $value['basic_type_id'],
-                'price' => $value['price'],
-                'cost' => $tmp['cost'] ?? 0,
-                'retail_price' => $tmp['retail_price'] ?? 0,
-                'final_amount' => $value['price'] * $value['number'],
-            ];
-        }
-        $bool = SalesOrderProductInfo::insert($insert);
-        if(! $bool) return [false,'合同生成失败!'];
-
-        //反写数据
-        $tmp = $product_total + $order['other_fee'];
-        $tmp = $tmp > 0 ? $tmp : 1;
-        $rate = ($product_total + $order['other_fee'] - $order['discount_fee']) / $tmp;
-        SalesOrder::where('id',$sales_order_id)->update([
-            'product_total' => $product_total,
-            'rate' => $rate
-        ]);
-
-        //生成付款单
-        $model = new PaymentReceipt();
-        $model->order_number = (new OrderNoService())->createOrderNumber(PaymentReceipt::prefix);
-        $model->data_type = PaymentReceipt::data_type_one;
-        $model->type = PaymentReceipt::type_one;
-        $model->crt_id = $user['id'];
-        $model->depart_id = $head;
-        $model->top_depart_id = $head;
-        $model->save();
-
-        $insert = [];
-        $insert[] = [
-            'payment_receipt_id' => $model->id,
-            'data_type' => PaymentReceipt::type_one,
-            'data_order_no' => $order_number,
-            'data_order_type' => PaymentReceipt::data_type_one,
-            'amount' => $order['purchase_total'],
-            'type' => PaymentReceiptInfo::type_three,
-            'crt_time' => $time,
-        ];
-        PaymentReceiptInfo::insert($insert);
-
-        return [true,''];
-    }
-    //自动生成-----------------------------------
-
-    //自动生成删除
-
-    //分社订货合同删除
-    public function delCreatePurchaseOrderSales($data, $order){
-        $sale_order = SalesOrder::where('del_time',0)
-            ->where('contact_order_no',$order['order_number'])
-            ->select('id','order_number')
-            ->get()->toArray();
-        if(empty($sale_order)) return [true,''];
-
-        foreach ($sale_order as $value){
-            list($status, $msg) = (new SalesOrderService())->salesOrderDel(['id' => $value['id']]);
-            if(! $status) return [false,$msg];
-
-            list($status, $msg) = (new PaymentReceiptService())->customerDel(['id' => $value['id']]);
-            if(! $status) return [false,$msg];
-        }
-
-        return [true, ''];
-    }
-
-    //自动生成删除
-
-    public function confirmPaymentReceipt($data){
-        $model = PaymentReceipt::where('order_number',$data['order_number'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '收付款单不存在或已被删除'];
-        if($model->state != PaymentReceipt::STATE_ONE) return [false, '请确认收付款单状态,操作失败'];
-
-        if($data['type'] == self::TYPE_ONE){
-            //通过
-            $model->state = PaymentReceipt::STATE_TWO;
-            $model->save();
-        }else{
-            //驳回
-            $model->state = InvoiceOrder::STATE_ZERO;
-            $model->save();
-        }
-
-        return [true, $model->toArray()];
-    }
-
-    public function confirmInvoiceOrder($data){
-        $model = InvoiceOrder::where('order_number',$data['order_number'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '发货单不存在或已被删除'];
-        if($model->state != InvoiceOrder::STATE_ONE) return [false, '请确认发货单状态,操作失败'];
-
-        if($data['type'] == self::TYPE_ONE){
-            //通过
-            $model->state = InvoiceOrder::STATE_TWO;
-            $model->save();
-
-            $sale = SalesOrder::where('id',$model->sales_order_id)->first();
-            if($sale['sales_order_type'] == SalesOrder::Order_type_one){
-                //安装件更新发货状态
-                SalesOrder::where('id',$model->sales_order_id)
-                    ->update(['invoice_state' => SalesOrder::invoice_one]);
-            }else{
-                //快递件更新 单据状态 发货状态
-                SalesOrder::where('id',$model->sales_order_id)
-                    ->update([
-                        'state' => SalesOrder::State2_one,
-                        'invoice_state' => SalesOrder::invoice_one
-                    ]);
-            }
-        }else{
-            //驳回
-            $model->state = InvoiceOrder::STATE_ZERO;
-            $model->save();
-        }
-
-        return [true, $model->toArray()];
-    }
-
-    public function recordInvoiceOrder($data, $order){
-        $result = InvoiceOrderInfo::where('del_time',0)
-            ->where('order_number',$order['order_number'])
-            ->get()->toArray();
-        if(empty($result)) return [false,'发货单产品信息不存在或已被删除'];
-        $insert = [];
-        $time = time();
-        foreach ($result as $value){
-            $key = $value['product_id'] . $value['storehouse_id'];
-            if(isset($insert[$key])){
-                $insert[$key]['number'] += -($value['number']);
-            }else{
-                $insert[$key] = [
-                    'product_id' => $value['product_id'],
-                    'number' => -($value['number']),
-                    'order_type' => InvoiceOrder::prefix,
-                    'order_number' => $order['order_number'],
-                    'crt_time' => $time,
-                    'storehouse_id' => $value['storehouse_id'],
-                    'depart_id' => $order['depart_id'],
-                    'top_depart_id' => $order['top_depart_id'],
-                ];
-            }
-        }
-        $insert = array_values($insert);
-        $bool = InOutRecord::insert($insert);
-        if(! $bool) return [false,'流水写入失败'];
-
-        return [true,''];
-    }
-
-    public function confirmPurchaseOrderState($data){
-        $model = PurchaseOrder::where('order_number',$data['order_number'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false,'采购单不存在或已被删除'];
-        if($model->state != PurchaseOrder::STATE_ONE) return [false,'请确认采购单状态,操作失败'];
-
-        if($data['type'] == self::TYPE_ONE){
-            $model->state = PurchaseOrder::STATE_TWO;
-            $model->save();
-        }else{
-            $model->state = PurchaseOrder::STATE_ZERO;
-            $model->save();
-        }
-
-        return [true, $model->toArray()];
-    }
-
-    public function confirmPurchaseOrder($data,$user){
-        $model = PurchaseOrder::where('order_number',$data['order_number'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '采购订单不存在或已被删除'];
-        if($model->state != PurchaseOrder::STATE_TWO) return [false, '请确认采购订单状态,操作失败'];
-        $model->state = PurchaseOrder::STATE_Four;
-        $model->save();
-
-        return [true, $model->toArray()];
-    }
-
-    public function recordPurchaseOrder($data, $order){
-        $result = PurchaseOrderInfo::where('del_time',0)
-            ->where('order_number',$order['order_number'])
-            ->get()->toArray();
-        if(empty($result)) return [false,'采购单产品信息不存在或已被删除'];
-        $insert = [];
-        $time = time();
-
-        foreach ($result as $value){
-            $key = $value['product_id'] . $value['storehouse_id'];
-            if(isset($insert[$key])){
-                $insert[$key]['number'] += $value['number'];
-            }else{
-                $insert[$key] = [
-                    'product_id' => $value['product_id'],
-                    'number' => $value['number'],
-                    'order_type' => PurchaseOrder::prefix,
-                    'order_number' => $order['order_number'],
-                    'crt_time' => $time,
-                    'storehouse_id' => $value['storehouse_id'],
-                    'depart_id' => $order['depart_id'],
-                    'top_depart_id' => $order['top_depart_id'],
-                ];
-            }
-        }
-        $insert = array_values($insert);
-        $bool = InOutRecord::insert($insert);
-        if(! $bool) return [false,'流水写入失败'];
-
-        return [true,''];
-    }
-
-    public function confirmConstruction($data){
-        $model = Construction::where('order_number',$data['order_number'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '施工单不存在或已被删除'];
-        if($model->state != Construction::STATE_ONE) return [false, '请确认施工单状态,操作失败'];
-
-        if($data['type'] == self::TYPE_ONE){
-            $model->state = Construction::STATE_TWO;
-            $model->save();
-
-            //已下施工
-            SalesOrder::where('id',$model->sales_order_id)->update(['state' => SalesOrder::State_five]);
-        }else{
-            $model->state = Construction::STATE_ZERO;
-            $model->save();
-        }
-
-        return [true, $model->toArray()];
-    }
-
-    public function recordConstruction($data, $order){
-        $result = ConstructionProductInfo::where('del_time',0)
-            ->where('construction_id',$order['id'])
-            ->get()->toArray();
-        if(empty($result)) return [false,'施工单产品信息不存在或已被删除'];
-        $insert = [];
-        $time = time();
-        foreach ($result as $value){
-            $key = $value['product_id'] . $value['storehouse_id'];
-            if(isset($insert[$key])){
-                $insert[$key]['number'] += -($value['number']);
-            }else{
-                $insert[$key] = [
-                    'product_id' => $value['product_id'],
-                    'number' => -($value['number']),
-                    'order_type' => Construction::$prefix[$order['model_type']] ?? '',
-                    'order_number' => $order['order_number'],
-                    'crt_time' => $time,
-                    'storehouse_id' => $value['storehouse_id'],
-                    'depart_id' => $order['depart_id'],
-                    'top_depart_id' => $order['top_depart_id'],
-                ];
-            }
-        }
-        $insert = array_values($insert);
-        $bool = InOutRecord::insert($insert);
-        if(! $bool) return [false,'流水写入失败'];
-
-        return [true,''];
-    }
-
-    public function confirmReturnExchangeOrder($data){
-        $model = ReturnExchangeOrder::where('order_number',$data['order_number'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '退换货单不存在或已被删除'];
-        if($model->state != ReturnExchangeOrder::State_one) return [false, '请确认退换货单状态,操作失败'];
-
-        if($data['type'] == self::TYPE_ONE){
-            $model->state = ReturnExchangeOrder::State_two;
-            $model->save();
-
-//            if($model->data_type == ReturnExchangeOrder::Order_type){
-//                SalesOrder::where('id', $model->data_id)->update([
-//                    'state' => SalesOrder::State_six
-//                ]);
-//            }
-        }else{
-            $model->state = ReturnExchangeOrder::State_zero;
-            $model->save();
-        }
-
-        return [true, $model->toArray()];
-    }
-
-    public function recordReturnExchangeOrder($data, $order){
-        if($order['model_type'] == ReturnExchangeOrder::Model_type_three) return [true, self::minus_one];
-//        if($order['type'] == ReturnExchangeOrder::Order_type){
-//            //快递件不记录流水
-//            $sales_order_type = SalesOrder::where('id',$order['data_id'])->value('sales_order_type');
-//            if($sales_order_type == SalesOrder::Order_type_two) return [true, self::minus_one];
-//        }
-
-        $result = ReturnExchangeOrderProductInfo::where('del_time',0)
-            ->where('return_exchange_id',$order['id'])
-            ->get()->toArray();
-        if(empty($result)) return [false,'退换货单产品信息不存在或已被删除'];
-        $insert = $insert2 = [];
-        $time = time();
-        foreach ($result as $value){
-            $key = $value['product_id'] . $value['storehouse_id'];
-            $prefix = ReturnExchangeOrder::$prefix[$value['return_or_exchange']] ?? '';
-            if($value['return_or_exchange'] == ReturnExchangeOrderProductInfo::type_one){
-                //退货
-                if(isset($insert[$key])){
-                    $insert[$key]['number'] += $value['number'];
-                }else{
-                    $insert[$key] = [
-                        'product_id' => $value['product_id'],
-                        'number' => $value['number'],
-                        'order_type' => $prefix,
-                        'order_number' => $order['order_number'],
-                        'crt_time' => $time,
-                        'storehouse_id' => $value['storehouse_id'],
-                        'depart_id' => $order['depart_id'],
-                        'top_depart_id' => $order['top_depart_id'],
-                    ];
-                }
-            }else{
-                //换货
-                if(isset($insert2[$key])){
-                    $insert2[$key]['number'] += -($value['number']);
-                }else{
-                    $insert2[$key] = [
-                        'product_id' => $value['product_id'],
-                        'number' => -($value['number']),
-                        'order_type' => $prefix,
-                        'order_number' => $order['order_number'],
-                        'crt_time' => $time,
-                        'storehouse_id' => $value['storehouse_id'],
-                        'depart_id' => $order['depart_id'],
-                        'top_depart_id' => $order['top_depart_id'],
-                    ];
-                }
-            }
-
-        }
-        $insert = array_values($insert);
-        $bool = InOutRecord::insert($insert);
-        if(! $bool) return [false,'流水写入失败'];
-
-        if(! empty($insert2)) {
-            $insert2 = array_values($insert2);
-            $bool = InOutRecord::insert($insert2);
-            if(! $bool) return [false,'流水写入失败'];
-        }
-
-        return [true,''];
-    }
-
-    public function settleSalesOrder($data,$user){
-        $model = SalesOrder::where('order_number', $data['order_number'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '合同不存在或已被删除'];
-        //安装件
-        if($model->state <= SalesOrder::State_four || $model->state >= SalesOrder::State_seven) return [false, '请确认合同状态,操作失败'];
-
-        SalesOrder::where('del_time',0)->where('order_number',$data['order_number'])
-            ->update(['state' => SalesOrder::State_seven]);
-
-        return [true, $model->toArray()];
-    }
-
-    public function settleSalesOrderCustomer($data,$user){
-        $model = SalesOrder::where('order_number', $data['order_number'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '合同不存在或已被删除'];
-        if(empty($data['img'])) return [false,'图片不能为空'];
-        //安装件
-        if($model->state != SalesOrder::State_seven) return [false, '请确认合同状态,操作失败'];
-
-        SalesOrder::where('del_time',0)->where('order_number',$data['order_number'])
-            ->update(['state' => SalesOrder::State_eight]);
-        SalesOrderInfo::insert([
-            'sales_order_id' => $model->id,
-            'type' => SalesOrderInfo::type_six,
-            'file' => $data['img'],
-            'crt_time' => time(),
-        ]);
-
-        return [true, $model->toArray()];
-    }
-
-    public function settleSalesOrderConfirm($data,$user){
-        $model = SalesOrder::where('order_number', $data['order_number'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '合同不存在或已被删除'];
-        //安装件
-        if($model->state != SalesOrder::State_four) return [false, '请确认合同状态,操作失败'];
-        $model->is_confirm = 1;
-        $model->save();
-
-        $emp_name = Employee::where('id',$user['id'])->value('emp_name');
-        $take_id = $model->dispatch_time_second_id ?? 0;
-        $send_data = [];
-        if(! empty($take_id)){
-            $send_data[] = [
-                'employee_id' => $take_id,
-                'type' => 2,
-                'state' => 0,
-                'menu_id' => 37,
-                'order_number' => $model->order_number,
-                'tmp_data' => [
-                    $model->order_number,
-                    "派单合同",
-                    "接收派单成功",
-                    $emp_name,
-                    date('Y-m-d H:i:s'),
-                ],
-            ];
-
-            (new OaService())->sendWxOaCheckMessage($send_data);
-        }
-
-        return [true, $model->toArray()];
-    }
-
-    public function confirmSales($data){
-        $model = SalesOrder::where('order_number', $data['order_number'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '合同不存在或已被删除'];
-        if($model->state != SalesOrder::State_one) return [false, '请确认合同状态,操作失败'];
-
-        if($data['type'] == self::TYPE_ONE){
-            $state = SalesOrder::State_three;
-            if($model->model_type == SalesOrder::Model_type_four){
-                //线上订单
-                $state = SalesOrder::State_two;
-            }
-            $model->state = $state;
-            $model->save();
-        }else{
-            $model->state = SalesOrder::State_minus_one;
-            $model->save();
-        }
-
-        return [true, $model->toArray()];
-    }
-
-    public function reject_sales($data){
-        $model = SalesOrder::where('order_number', $data['order_number'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '合同不存在或已被删除'];
-        //安装件
-
-        if($model->model_type == SalesOrder::Model_type_four){
-            //线上订单
-            if($model->state != SalesOrder::State_two) return [false, '请确认合同状态,操作失败'];
-        }else{
-            //除线上订单之外
-            if($model->state != SalesOrder::State_three) return [false, '请确认合同状态,操作失败'];
-        }
-
-        //未确认
-        $model->state = SalesOrder::State_zero;
-        $model->save();
-
-        return [true, $model->toArray()];
-    }
-
-    public function reject_purchase($data){
-        $model = PurchaseOrder::where('order_number', $data['order_number'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '采购单不存在或已被删除'];
-        //安装件
-        if($model->state != PurchaseOrder::STATE_Four) return [false, '请确认采购单状态,操作失败'];
-
-        $model->state = PurchaseOrder::STATE_TWO;
-        $model->save();
-
-        return [true, $model->toArray()];
-    }
-
-    public function reject_purchase_confirm($data){
-        $model = PurchaseOrder::where('order_number', $data['order_number'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '采购单不存在或已被删除'];
-        //安装件
-        if($model->state != PurchaseOrder::STATE_TWO) return [false, '请确认采购单状态,操作失败'];
-
-        $model->state = PurchaseOrder::STATE_ZERO;
-        $model->save();
-
-        return [true, $model->toArray()];
-    }
-
-    public function reject_construction($data){
-        $model = Construction::where('order_number', $data['order_number'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '施工单不存在或已被删除'];
-        //安装件
-        if($model->state != Construction::STATE_TWO) return [false, '请确认施工单状态,操作失败'];
-
-        $model->state = Construction::STATE_ZERO;
-        $model->save();
-
-        return [true, $model->toArray()];
-    }
-
-    public function reject_payment_receipt($data){
-        $model = PaymentReceipt::where('order_number', $data['order_number'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '收付款单不存在或已被删除'];
-        if($model->state != PaymentReceipt::STATE_TWO) return [false, '请确认收付款单状态,操作失败'];
-
-        $model->state = PaymentReceipt::STATE_ZERO;
-        $model->save();
-
-        return [true, $model->toArray()];
-    }
-
-    public function reject_return_exchange($data){
-        $model = ReturnExchangeOrder::where('order_number', $data['order_number'])
-            ->where('del_time',0)
-            ->first();
-        if(empty($model)) return [false, '退换货单不存在或已被删除'];
-        if($model->state != ReturnExchangeOrder::State_two) return [false, '请确认退换货单状态,操作失败'];
-
-        $model->state = ReturnExchangeOrder::State_zero;
-        $model->save();
-
-        return [true, $model->toArray()];
-    }
-
-    public function reject_record_construction($data,$order){
-        //获取单据最新数据时间 正常施工数据
-        $latest = InOutRecord::where('del_time',0)
-            ->where('order_number',$data['order_number'])
-            ->where('number','<',0)
-            ->select('crt_time')
-            ->orderBy('crt_time', 'desc')
-            ->first();
-        $latest = $latest->toArray();
-
-        $result = InOutRecord::where('del_time',0)
-            ->where('crt_time',$latest['crt_time'])
-            ->where('order_number',$data['order_number'])
-            ->where('number','<',0)
-            ->select('product_id','storehouse_id','number','depart_id','order_number','top_depart_id','order_type')
-            ->get()->toArray();
-        if(empty($result)) return [false,'施工出库流水数据未找到'];
-
-        //生成对冲数据
-        $time = time();
-        foreach ($result as $key => $value){
-            $result[$key]['number'] = abs($value['number']);
-            $result[$key]['crt_time'] = $time;
-        }
-
-        $bool = InOutRecord::insert($result);
-        if(! $bool) return [false,'流水写入失败'];
-
-        //写入流水
-        return [true, ''];
-    }
-
-    public function reject_record_purchase($data,$order){
-        //获取单据最新数据时间 正常采购入库数据
-        $latest = InOutRecord::where('del_time',0)
-            ->where('order_number',$data['order_number'])
-            ->where('number','>',0)
-            ->select('crt_time')
-            ->orderBy('crt_time', 'desc')
-            ->first();
-        $latest = $latest->toArray();
-
-        $result = InOutRecord::where('del_time',0)
-            ->where('crt_time',$latest['crt_time'])
-            ->where('order_number',$data['order_number'])
-            ->where('number','>',0)
-            ->select('product_id','storehouse_id','number','depart_id','order_number','top_depart_id','order_type')
-            ->get()->toArray();
-        if(empty($result)) return [false,'采购入库流水数据未找到'];
-
-        //生成对冲数据
-        $time = time();
-        foreach ($result as $key => $value){
-            $result[$key]['number'] = - $value['number'];
-            $result[$key]['crt_time'] = $time;
-        }
-
-        $bool = InOutRecord::insert($result);
-        if(! $bool) return [false,'流水写入失败'];
-
-        //写入流水
-        return [true, ''];
-    }
-
-    public function reject_record_return_exchange($data,$order){
-        if($order['model_type'] == ReturnExchangeOrder::Model_type_three) return [true, self::minus_one];
-//        if($order['type'] == ReturnExchangeOrder::Order_type){
-//            //快递件不记录流水
-//            $sales_order_type = SalesOrder::where('id',$order['data_id'])->value('sales_order_type');
-//            if($sales_order_type == SalesOrder::Order_type_two) return [true, self::minus_one];
-//        }
-
-        $result = ReturnExchangeOrderProductInfo::where('del_time',0)
-            ->where('return_exchange_id',$order['id'])
-            ->get()->toArray();
-        if(empty($result)) return [false,'退换货单产品信息不存在或已被删除'];
-        $insert = $insert2 = [];
-        $time = time();
-        foreach ($result as $value){
-            $key = $value['product_id'] . $value['storehouse_id'];
-            $prefix = ReturnExchangeOrder::$prefix[$value['return_or_exchange']] ?? '';
-            if($value['return_or_exchange'] == ReturnExchangeOrderProductInfo::type_one){
-                //退货 扣出
-                if(isset($insert[$key])){
-                    $insert[$key]['number'] += -($value['number']);
-                }else{
-                    $insert[$key] = [
-                        'product_id' => $value['product_id'],
-                        'number' => -($value['number']),
-                        'order_type' => $prefix,
-                        'order_number' => $order['order_number'],
-                        'crt_time' => $time,
-                        'storehouse_id' => $value['storehouse_id'],
-                        'depart_id' => $order['depart_id'],
-                        'top_depart_id' => $order['top_depart_id'],
-                    ];
-                }
-            }else{
-                //换货 加回
-                if(isset($insert2[$key])){
-                    $insert2[$key]['number'] += $value['number'];
-                }else{
-                    $insert2[$key] = [
-                        'product_id' => $value['product_id'],
-                        'number' => $value['number'],
-                        'order_type' => $prefix,
-                        'order_number' => $order['order_number'],
-                        'crt_time' => $time,
-                        'storehouse_id' => $value['storehouse_id'],
-                        'depart_id' => $order['depart_id'],
-                        'top_depart_id' => $order['top_depart_id'],
-                    ];
-                }
-            }
-
-        }
-        $insert = array_values($insert);
-        $bool = InOutRecord::insert($insert);
-        if(! $bool) return [false,'流水写入失败'];
-
-        if(! empty($insert2)) {
-            $insert2 = array_values($insert2);
-            $bool = InOutRecord::insert($insert2);
-            if(! $bool) return [false,'流水写入失败'];
-        }
-
-        return [true,''];
-    }
-
-    public function getOrderDetail($data,$user){
-        if(empty($data['order_number'])) return [false,'必传参数不能为空'];
-        $array = [];
-        foreach (Construction::$prefix as $value){
-            $array[$value] = "\App\Service\\ConstructionService";
-        }
-        foreach (ReturnExchangeOrder::$prefix as $value){
-            $array[$value] = "\App\Service\\ReturnExchangeOrderService";
-        }
-        foreach (SalesOrder::$prefix as $value){
-            $array[$value] = "\App\Service\\SalesOrderService";
-        }
-
-        $status = true;
-        $msg = [];
-        foreach ($array as $key => $value){
-            if(strpos($data['order_number'],$key) !== false) {
-                list($status, $msg) = (new $value)->detail($data);
-                return [$status, $msg];
-            }
-        }
-
-        if(strpos($data['order_number'],PurchaseOrder::prefix) !== false){
-            $service = "\App\Service\\PurchaseOrderService";
-            list($status, $msg) = (new $service)->detail($data,$user);
-            return [$status, $msg];
-        }
-
-        return [$status, $msg];
-    }
-
-    public function checkAll($data,$user){
-        if(empty($data['id']) || empty($data['order_number'])|| empty($data['opt_case'])) return [false,'必传参数不能为空或者参数值错误!'];
-
-        list($status,$msg) = $this->limitingSendRequestBackgExpire($data['order_number'].$data['opt_case']);
-        if(! $status) return [false,$msg];
-
-        //走审批流 单据校验
-        $function_check = self::$opt_1case_check[$data['opt_case']] ?? '';
-        //走审批流 单据状态改为待审批方法
-        $function = self::$opt_1case[$data['opt_case']] ?? '';
-
-        //单据不走审批流
-        $function2 = self::$finished[$data['opt_case']] ?? '';
-        try{
-            DB::beginTransaction();
-
-            //不走审批流,更新完直接返回
-            if($function2) {
-                list($bool,$msg) = $this->$function2($data,$user);
-                if($bool) {
-                    $order = $msg;
-
-                    list($bool,$err) = $this->createRecordAndInventoryMy($data,$user,$order);
-                    if($bool){
-                        DB::commit();
-                        return [true, ''];
-                    }else{
-                        DB::rollBack();
-                        return [false, $err];
-                    }
-                }else{
-                    DB::rollBack();
-                    return [false, $msg];
-                }
-            }
-
-            //需要审批流,校验
-            if($function_check){
-                list($bool,$msg) = $this->$function_check($data, $user);
-                if(! $bool){
-                    DB::rollBack();
-                    return [false, $msg];
-                }
-            }
-
-            //需要审批流,从未审核变成待审核
-            if($function){
-                list($bool,$msg) = $this->$function($data);
-
-                if(! $bool){
-                    DB::rollBack();
-                    return [false, $msg];
-                }
-
-                //创建审批流
-                $args = [
-                    'order_no' => $data['order_number'],
-                    'menu_id' => $data['menu_id'] ?? 0,
-                    'opt_case' => $data['opt_case'],
-                    'order' => $msg,
-                ];
-
-                $oa = new OaService($user);
-                list($bool,$msg) = $oa->createOaOrder($args);
-                if(! $bool) {
-                    DB::rollBack();
-                    if($msg) return [false,$msg];
-                }
-            }
-
-            DB::commit();
-            return [true, ''];
-        }catch (\Throwable $exception){
-            DB::rollBack();
-            return [false, $exception->getMessage() . $exception->getFile(). $exception->getLine()];
-        }
-    }
-
-    //更新库存
-    public function changeInventory($data,$order,$user){
-        $number_symbol = "";
-        if(in_array($data['opt_case'],self::$in_opt)){
-            $number_symbol = ">";
-        }elseif (in_array($data['opt_case'],self::$out_opt)){
-            $number_symbol = "<";
-        }
-
-        //获取单据最新数据时间 正常审核的数据
-        $latest = InOutRecord::where('del_time',0)
-            ->where('order_number',$order['order_number'])
-            ->when(! empty($number_symbol), function ($query) use ($number_symbol) {
-                return $query->where('number', $number_symbol,0);
-            })
-            ->select('crt_time')
-            ->orderBy('crt_time', 'desc')
-            ->first();
-
-        $model = InOutRecord::where('del_time',0)
-            ->where('order_number',$order['order_number'])
-            ->when(! empty($number_symbol), function ($query) use ($number_symbol) {
-                return $query->where('number', $number_symbol,0);
-            })
-            ->select('number','crt_time','product_id','storehouse_id','top_depart_id');
-        if(! empty($latest)) {
-            $t = $latest->toArray();
-            $model->where('crt_time',$t['crt_time']);
-        }
-
-        $record = $model->get()->toArray();
-        if (empty($record)) return [false,'流水记录不存在'];
-        $top_depart_id = Storehouse::where('id', $order['storehouse_id'])->value('top_depart_id');
-        $result = $lock_number = [];
-        foreach ($record as $value){
-            $key = $value['product_id'] . $value['storehouse_id'];
-            if(isset($result[$key])){
-                $result[$key]['number'] += $value['number'];
-            }else{
-                $result[$key] = [
-                    'product_id' => $value['product_id'],
-                    'number' => $value['number'],
-                    'crt_time' => $value['crt_time'],
-                    'storehouse_id' => $value['storehouse_id'],
-                    'top_depart_id' => $top_depart_id,
-                ];
-            }
-            if($value['number'] < 0){
-                if(isset($lock_number[$key])){
-                    $lock_number[$key] += $value['number'];
-                }else{
-                    $lock_number[$key] = $value['number'];
-                }
-            }
-        }
-
-        //是否校验库存 是的话锁定数量要更新(根据当前操作人所在门店是否校验库存)
-        $lock = $user['is_check_stock'];
-
-        $result = array_values($result);
-        foreach ($result as $key => $value){
-            $keys = $value['product_id'] . $value['storehouse_id'];
-            $m = ProductInventory::where('product_id',$value['product_id'])
-                ->where('storehouse_id',$value['storehouse_id'])
-                ->select('product_id','number','storehouse_id')
-                ->first();
-
-            if(empty($m)){
-                ProductInventory::insert($result[$key]);
-            }else{
-                //锁定数量
-                $lock_number_tmp = 0;
-                if($lock && ! empty($lock_number[$keys])) $lock_number_tmp = $lock_number[$keys];
-
-                ProductInventory::where('product_id',$m->product_id)
-                    ->where('storehouse_id',$m->storehouse_id)
-                    ->lockForUpdate()
-                    ->update([
-                        'number' => DB::raw('number + ('. $value['number'] . ')'),
-                        'lock_number' => DB::raw('lock_number + ('. $lock_number_tmp . ')')
-                    ]);
-            }
-        }
-
-        return [true,''];
-    }
-
-    //业务单据审批通过后 驳回 更新库存
-    public function changeInventoryReject($data,$order,$user){
-        $number_symbol = "";
-        if(in_array($data['opt_case'],self::$in_opt)){
-            $number_symbol = "<";
-        }elseif (in_array($data['opt_case'],self::$out_opt)){
-            $number_symbol = ">";
-        }
-
-        //获取单据最新数据时间 正常审核的数据
-        $latest = InOutRecord::where('del_time',0)
-            ->where('order_number',$order['order_number'])
-            ->when(! empty($number_symbol), function ($query) use ($number_symbol) {
-                return $query->where('number', $number_symbol,0);
-            })
-            ->select('crt_time')
-            ->orderBy('crt_time', 'desc')
-            ->first();
-
-        $model = InOutRecord::where('del_time',0)
-            ->where('order_number',$order['order_number'])
-            ->when(! empty($number_symbol), function ($query) use ($number_symbol) {
-                return $query->where('number', $number_symbol,0);
-            })
-            ->select('number','crt_time','product_id','storehouse_id','top_depart_id');
-        if(! empty($latest)) {
-            $t = $latest->toArray();
-            $model->where('crt_time',$t['crt_time']);
-        }
-
-        $record = $model->get()->toArray();
-        if (empty($record)) return [false,'流水记录不存在'];
-        $top_depart_id = Storehouse::where('id', $order['storehouse_id'])->value('top_depart_id');
-        $result = $lock_number = [];
-        foreach ($record as $value){
-            $key = $value['product_id'] . $value['storehouse_id'];
-            if(isset($result[$key])){
-                $result[$key]['number'] += $value['number'];
-            }else{
-                $result[$key] = [
-                    'product_id' => $value['product_id'],
-                    'number' => $value['number'],
-                    'crt_time' => $value['crt_time'],
-                    'storehouse_id' => $value['storehouse_id'],
-                    'top_depart_id' => $top_depart_id,
-                ];
-            }
-            if($value['number'] > 0){
-                if(isset($lock_number[$key])){
-                    $lock_number[$key] += $value['number'];
-                }else{
-                    $lock_number[$key] = $value['number'];
-                }
-            }
-        }
-
-        //是否校验库存 是的话锁定数量要更新(根据当前操作人所在门店是否校验库存)
-        $lock = $user['is_check_stock'];
-
-        $result = array_values($result);
-        foreach ($result as $key => $value){
-            $keys = $value['product_id'] . $value['storehouse_id'];
-            $m = ProductInventory::where('product_id',$value['product_id'])
-                ->where('storehouse_id',$value['storehouse_id'])
-                ->select('product_id','number','storehouse_id')
-                ->first();
-
-            if(empty($m)){
-                ProductInventory::insert($result[$key]);
-            }else{
-                //锁定数量
-                $lock_number_tmp = 0;
-                if($lock && ! empty($lock_number[$keys])) $lock_number_tmp = $lock_number[$keys];
-
-                ProductInventory::where('product_id',$m->product_id)
-                    ->where('storehouse_id',$m->storehouse_id)
-                    ->lockForUpdate()
-                    ->update([
-                        'number' => DB::raw('number + ('. $value['number'] . ')'),
-                        'lock_number' => DB::raw('lock_number + ('. $lock_number_tmp . ')')
-                    ]);
-            }
-        }
-
-        return [true,''];
-    }
-
-    public function createRecordAndInventory($data = []){
-        if(empty($data['type']) || empty($data['opt_case']) || empty($data['order_number'])) return [false, '传递参数缺少'];
-        $user = $data['user_data'] ?? [];
-
-        if($data['type'] == self::TYPE_THREE){
-            //通过后弃审
-            if(! isset(self::$opt_case_reject[$data['opt_case']])) return [false, '该操作不存在'];
-
-            //具体方法
-            $function = self::$opt_case_reject[$data['opt_case']];
-
-            //流水
-            $function2 = self::$reject_record[$data['opt_case']] ?? '';
-
-            //自动生成删除
-            $function3 = self::$create_del[$data['opt_case']] ?? '';
-            try{
-                DB::beginTransaction();
-
-                //更新单据的状态
-                list($bool,$msg) = $this->$function($data);
-                if(! $bool){
-                    DB::rollBack();
-                    return [false, $msg];
-                }
-                $order = $msg;
-
-                if($function3){
-                    list($boolean,$msg) = $this->$function3($data,$order);
-                    if(! $boolean) {
-                        DB::rollBack();
-                        return [false, $msg];
-                    }
-                }
-
-                if($function2) {
-                    //流水
-                    list($boolean,$msg) = $this->$function2($data,$order);
-                    if(! $boolean) {
-                        DB::rollBack();
-                        return [false, $msg];
-                    }
-
-                    if($msg != self::minus_one){
-                        //库存
-                        list($bool,$msg) = $this->changeInventoryReject($data,$order,$user);
-                        if(! $bool){
-                            DB::rollBack();
-                            return [false, $msg];
-                        }
-                    }
-                }
-
-                if(! empty(self::$operation_order_reject[$data['opt_case']])){
-                    $type = self::$operation_order_reject[$data['opt_case']];
-                    (new OrderOperationService())->add([
-                        'order_number' => $order['order_number'],
-                        'msg' => OrderOperation::$type[$type],
-                        'type' => $type
-                    ],$user);
-                }
-
-                DB::commit();
-                return [true, ''];
-            }catch (\Throwable $exception){
-                DB::rollBack();
-                return [false, $exception->getMessage() . $exception->getLine() . $exception->getFile()];
-            }
-        }else{
-            //具体方法
-            $function = self::$opt_case[$data['opt_case']] ?? "";
-            $record = self::$record[$data['opt_case']] ?? "";
-            $create = self::$create[$data['opt_case']] ?? "";
-
-            try{
-                DB::beginTransaction();
-
-                list($bool,$msg) = $this->$function($data);
-
-                if(! $bool){
-                    DB::rollBack();
-                    return [false, $msg];
-                }
-                $order = $msg;
-
-                if($data['type'] == self::TYPE_ONE){
-                    if($record) {
-                        //流水
-                        list($bool,$msg) = $this->$record($data, $order);
-                        if(! $bool) {
-                            DB::rollBack();
-                            return [false, $msg];
-                        }
-
-                        if($msg != self::minus_one){
-                            //库存
-                            list($bool,$msg) = $this->changeInventory($data, $order, $user);
-                            if(! $bool) {
-                                DB::rollBack();
-                                return [false, $msg];
-                            }
-                        }
-                    }
-
-                    if($create) {
-                        list($bool,$msg) = $this->$create($order,$user);
-                        if(! $bool) {
-                            DB::rollBack();
-                            return [false, $msg];
-                        }
-                    }
-                }
-
-                if(! empty(self::$operation_order[$data['opt_case']])){
-                    $user = $data['user_data'] ?? [];
-                    $type = self::$operation_order[$data['opt_case']];
-                    (new OrderOperationService())->add([
-                        'order_number' => $order['order_number'],
-                        'msg' => OrderOperation::$type[$type],
-                        'type' => $type
-                    ],$user);
-                }
-
-                DB::commit();
-                return [true, ''];
-            }catch (\Throwable $exception){
-                DB::rollBack();
-                return [false, $exception->getMessage() . $exception->getLine() . $exception->getFile()];
-            }
-        }
-    }
-
-    //不需要走审批流 直接调用
-    public function createRecordAndInventoryMy($data = [],$user = [],$order = []){
-        if(! empty($data['type']) && $data['type'] == self::TYPE_THREE){
-        }else{
-            //具体方法
-            $record = self::$record[$data['opt_case']] ?? "";
-            $create = self::$create[$data['opt_case']] ?? "";
-            try{
-                DB::beginTransaction();
-
-                if($record) {
-                    //流水
-                    list($bool,$msg) = $this->$record($data, $order);
-                    if(! $bool) {
-                        DB::rollBack();
-                        return [false, $msg];
-                    }
-
-                    if($msg != self::minus_one){
-                        //库存
-                        list($bool,$msg) = $this->changeInventory($data, $order, $user);
-                        if(! $bool) {
-                            DB::rollBack();
-                            return [false, $msg];
-                        }
-                    }
-                }
-
-                if($create) {
-                    list($bool,$msg) = $this->$create($order,$user);
-                    if(! $bool) {
-                        DB::rollBack();
-                        return [false, $msg];
-                    }
-                }
-
-                if(! empty(self::$operation_order[$data['opt_case']])){
-                    $type = self::$operation_order[$data['opt_case']];
-                    (new OrderOperationService())->add([
-                        'order_number' => $order['order_number'],
-                        'msg' => OrderOperation::$type[$type],
-                        'type' => $type
-                    ],$user);
-                }
-
-                DB::commit();
-                return [true, ''];
-            }catch (\Throwable $exception){
-                DB::rollBack();
-                return [false, $exception->getMessage() . $exception->getLine() . $exception->getFile()];
-            }
-        }
-    }
-}

+ 0 - 1216
app/Service/ConstructionService.php

@@ -1,1216 +0,0 @@
-<?php
-
-namespace App\Service;
-
-use App\Model\BasicType;
-use App\Model\Construction;
-use App\Model\ConstructionFile;
-use App\Model\ConstructionInfo;
-use App\Model\ConstructionProductInfo;
-use App\Model\Customer;
-use App\Model\CustomerInfo;
-use App\Model\DeliveryNote;
-use App\Model\Depart;
-use App\Model\Employee;
-use App\Model\EmployeeDepartPermission;
-use App\Model\Oa;
-use App\Model\OaSub;
-use App\Model\OaSubEmployee;
-use App\Model\OaSubReportEmployee;
-use App\Model\OaSubRule;
-use App\Model\Product;
-use App\Model\ReturnExchangeOrder;
-use App\Model\ReturnExchangeOrderProductInfo;
-use App\Model\SalesOrder;
-use App\Model\SalesOrderInfo;
-use App\Model\SalesOrderProductInfo;
-use App\Model\ScheduleInfo;
-use App\Model\SeeRange;
-use App\Model\Storehouse;
-use Illuminate\Support\Facades\DB;
-//use Barryvdh\DomPDF\Facade as PDF;
-use Barryvdh\DomPDF\PDF;
-
-
-/**
- * 施工订单
- */
-class ConstructionService extends Service
-{
-    /**
-     * 施工订单编辑
-     * @param $data
-     * @param $user
-     * @return array
-     */
-    public function constructionEdit($data,$user){
-        list($status,$msg) = $this->constructionRule($data, $user, false);
-        if(!$status) return [$status,$msg];
-
-        $params = $this->getDataFile($data);
-        (new OperationLogService())->setOperationList($params,$user,2);
-
-        try {
-            DB::beginTransaction();
-
-            $model = Construction::where('id', $data['id'])->first();
-            $model->model_type = $data['model_type'];
-            $model->order_number = $data['order_number'];
-            $model->title = $data['title'] ?? '';
-            $model->customer_id = $data['customer_id'] ?? 0;
-            $model->customer_contact_id = $data['customer_contact_id'] ?? 0;
-            $model->install_method = $data['install_method'] ?? 0;
-            $model->install_position = $data['install_position'] ?? 0;
-            $model->sales_order_id = $data['sales_order_id'] ?? 0;
-            $model->construction_fee = $data['construction_fee'] ?? 0;
-            $model->service_price = $data['service_price'] ?? 0;
-            $model->construction_time = $data['construction_time'] ?? 0;
-            $model->handover_time = $data['handover_time'] ?? 0;
-            $model->urgency = $data['urgency'] ?? 0;
-            $model->mark = $data['mark'] ?? '';
-            $model->address1 = ! empty($data['address1']) ? json_encode($data['address1']) : '';
-            $model->address2 = $data['address2'] ?? '';
-            $model->introduction = $data['introduction'] ?? '';
-            $model->storehouse_id = $data['storehouse_id'] ?? 0;
-            $model->start_time = $data['start_time'] ?? 0;
-            $model->end_time = $data['end_time'] ?? 0;
-            $model->schedule_id = $data['schedule_id'] ?? 0;
-            $model->day_stamp = $data['day_stamp'] ?? 0;
-            $model->day_start_stamp = $data['day_start_stamp'] ?? 0;
-            $model->day_end_stamp = $data['day_end_stamp'] ?? 0;
-            $model->product_introduction = $data['product_introduction'] ?? "";
-            $model->vin_no = $data['vin_no'] ?? "";
-            $model->save();
-            $time = time();
-
-            ConstructionInfo::where('del_time',0)
-                ->where('construction_id',$data['id'])
-                ->where('type',ConstructionInfo::type_two)
-                ->update(['del_time' => $time]);
-            ConstructionProductInfo::where('del_time',0)
-                ->where('construction_id',$data['id'])
-                ->update(['del_time' => $time]);
-            $old = ConstructionFile::where('del_time',0)
-                ->where('construction_id',$data['id'])
-                ->select('file')
-                ->get()->toArray();
-            $old = array_column($old,'file');
-            ConstructionFile::where('del_time',0)
-                ->where('construction_id',$data['id'])
-                ->update(['del_time' => $time]);
-
-            if(! empty($data['construction_contact'])){
-                $insert = [];
-                foreach ($data['construction_contact'] as $value){
-                    $insert[] = [
-                        'construction_id' => $model->id,
-                        'contact_type' => $value['id'],
-                        'contact_info' => $value['info'],
-                        'type' => ConstructionInfo::type_one,
-                        'crt_time' => $time,
-                    ];
-                }
-                ConstructionInfo::insert($insert);
-            }
-
-            if(! empty($data['employee_one'])){
-                $insert = [];
-                foreach ($data['employee_one'] as $value){
-                    $insert[] = [
-                        'construction_id' => $model->id,
-                        'employee_id' => $value,
-                        'type' => ConstructionInfo::type_two,
-                        'crt_time' => $time,
-                    ];
-                }
-                ConstructionInfo::insert($insert);
-            }
-
-            if(! empty($data['product'])){
-                $insert = [];
-                foreach ($data['product'] as $value){
-                    $insert[] = [
-                        'construction_id' => $model->id,
-                        'product_id' => $value['product_id'],
-                        'number' => $value['number'],
-                        'cost' => $value['cost'] ?? 0,
-                        'retail_price' => $value['retail_price'] ?? 0,
-                        'mark' => $value['mark'] ?? '',
-                        'crt_time' => $time,
-                        'storehouse_id' => $data['storehouse_id'] ?? 0,
-                        'basic_type_id' => $value['basic_type_id'],
-                        'price' => $value['price'],
-                        'final_amount' => $value['final_amount'] ?? 0,
-                    ];
-                }
-                ConstructionProductInfo::insert($insert);
-
-                //锁定库存
-                ProductInventoryService::changeLockNumber($user,$msg[0],$msg[1]);
-            }
-
-            if(! empty($data['schedule_info_id'])) ScheduleInfo::where('id',$data['schedule_info_id'])->update(['is_use' => 1]);
-
-            $new = [];
-            if(! empty($data['file'])){
-                $insert = [];
-                foreach ($data['file'] as $value){
-                    $insert[] = [
-                        'order_number' => $data['order_number'],
-                        'construction_id' => $data['id'],
-                        'file' => $value['url'],
-                        'name' => $value['name'],
-                        'mark' => $value['mark'] ?? "",
-                        'crt_time' => $time,
-                    ];
-                    if(in_array($value['url'], $old)) {
-                        foreach ($old as $o_k => $o_v){
-                            if($o_v == $value['url']) unset($old[$o_k]);
-                        }
-                    }else{
-                        $new[] = $value['url'];
-                    }
-                }
-                ConstructionFile::insert($insert);
-            }
-
-            DB::commit();
-        }catch (\Exception $exception){
-            DB::rollBack();
-            return [false,$exception->getMessage()];
-        }
-
-        if(! empty($data['check'])) {
-            list($status,$msg) = (new CheckService())->checkAll([
-                "id" => $model->id,
-                "order_number" => $data['order_number'],
-                "opt_case" => CheckService::five,
-                "menu_id" => $data['menu_id']
-            ],$user);
-//            if(! $status) return [true, '保存成功,施工单确认失败,异常信息:' . $msg];
-        }
-
-        return [true, ['file' => ['new' => $new, 'old' => $old]]];
-    }
-
-    /**
-     * 施工订单新增
-     * @param $data
-     * @param $user
-     * @return array
-     */
-    public function constructionAdd($data,$user){
-        list($status,$msg) = $this->constructionRule($data,$user);
-        if(!$status) return [$status,$msg];
-
-        try {
-            DB::beginTransaction();
-
-            $model = new Construction();
-            $model->model_type = $data['model_type'];
-            $model->order_number = $data['order_number'];
-            $model->title = $data['title'] ?? '';
-            $model->customer_id = $data['customer_id'] ?? 0;
-            $model->customer_contact_id = $data['customer_contact_id'] ?? 0;
-            $model->install_method = $data['install_method'] ?? 0;
-            $model->install_position = $data['install_position'] ?? 0;
-            $model->sales_order_id = $data['sales_order_id'] ?? 0;
-            $model->construction_fee = $data['construction_fee'] ?? 0;
-            $model->service_price = $data['service_price'] ?? 0;
-            $model->construction_time = $data['construction_time'] ?? 0;
-            $model->handover_time = $data['handover_time'] ?? 0;
-            $model->urgency = $data['urgency'] ?? 0;
-            $model->mark = $data['mark'] ?? '';
-            $model->address1 = ! empty($data['address1']) ? json_encode($data['address1']) : '';
-            $model->address2 = $data['address2'] ?? '';
-            $model->introduction = $data['introduction'] ?? '';
-            $model->crt_id = $user['id'];
-            $model->depart_id = $data['depart_id'] ?? 0;
-            $model->top_depart_id = $data['top_depart_id'] ?? 0;
-            $model->storehouse_id = $data['storehouse_id'] ?? 0;
-            $model->start_time = $data['start_time'] ?? 0;
-            $model->end_time = $data['end_time'] ?? 0;
-            $model->schedule_id = $data['schedule_id'] ?? 0;
-            $model->day_stamp = $data['day_stamp'] ?? 0;
-            $model->day_start_stamp = $data['day_start_stamp'] ?? 0;
-            $model->day_end_stamp = $data['day_end_stamp'] ?? 0;
-            $model->product_introduction = $data['product_introduction'] ?? "";
-            $model->vin_no = $data['vin_no'] ?? "";
-            $model->save();
-            $time = time();
-
-            if(! empty($data['construction_contact'])){
-                $insert = [];
-                foreach ($data['construction_contact'] as $value){
-                    $insert[] = [
-                        'construction_id' => $model->id,
-                        'contact_type' => $value['id'],
-                        'contact_info' => $value['info'],
-                        'type' => ConstructionInfo::type_one,
-                        'crt_time' => $time,
-                    ];
-                }
-                ConstructionInfo::insert($insert);
-            }
-
-            if(! empty($data['employee_one'])){
-                $insert = [];
-                foreach ($data['employee_one'] as $value){
-                    $insert[] = [
-                        'construction_id' => $model->id,
-                        'employee_id' => $value,
-                        'type' => ConstructionInfo::type_two,
-                        'crt_time' => $time,
-                    ];
-                }
-                ConstructionInfo::insert($insert);
-            }
-
-            if(! empty($data['product'])){
-                $insert = [];
-                foreach ($data['product'] as $value){
-                    $insert[] = [
-                        'construction_id' => $model->id,
-                        'product_id' => $value['product_id'],
-                        'number' => $value['number'],
-                        'cost' => $value['cost'] ?? 0,
-                        'retail_price' => $value['retail_price'] ?? 0,
-                        'mark' => $value['mark'] ?? '',
-                        'crt_time' => $time,
-                        'storehouse_id' => $data['storehouse_id'] ?? 0,
-                        'basic_type_id' => $value['basic_type_id'],
-                        'price' => $value['price'],
-                        'final_amount' => $value['final_amount'] ?? 0,
-                    ];
-                }
-                ConstructionProductInfo::insert($insert);
-
-                //锁定库存
-                ProductInventoryService::changeLockNumber($user,$msg[0],[]);
-            }
-
-            if(! empty($data['schedule_info_id'])) ScheduleInfo::where('id',$data['schedule_info_id'])->update(['is_use' => 1]);
-
-            $new = [];
-            if(! empty($data['file'])){
-                $insert = [];
-                foreach ($data['file'] as $value){
-                    $insert[] = [
-                        'order_number' => $data['order_number'],
-                        'construction_id' => $model->id,
-                        'file' => $value['url'],
-                        'name' => $value['name'],
-                        'mark' => $value['mark'] ?? "",
-                        'crt_time' => $time,
-                    ];
-                    if(! empty($value['url'])) $new[] = $value['url'];
-                }
-                ConstructionFile::insert($insert);
-            }
-
-            DB::commit();
-        }catch (\Exception $exception){
-            DB::rollBack();
-            return [false,$exception->getMessage()];
-        }
-        (new OperationLogService())->setOperationList($data,$user);
-
-        if(! empty($data['check'])) {
-            list($status,$msg) = (new CheckService())->checkAll([
-                "id" => $model->id,
-                "order_number" => $data['order_number'],
-                "opt_case" => CheckService::five,
-                "menu_id" => $data['menu_id']
-            ],$user);
-//            if(! $status) return [true, '保存成功,施工单确认失败,异常信息:' . $msg];
-        }
-
-        return [true, ['file' => ['new' => $new]]];
-    }
-
-    /**
-     * 施工订单删除
-     * @param $data
-     * @return array
-     */
-    public function constructionDel($data,$user){
-        if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
-        $construction = Construction::where('del_time',0)->where('id',$data['id'])->first();
-        if(empty($construction)) return [false,'施工单不存在或已被删除'];
-        $construction = $construction->toArray();
-        if($construction['state'] > Construction::STATE_ZERO) return [false,'请确认施工单状态,操作失败'];
-
-        $product_save = $this->getSaveDetail($data['id']);
-        try {
-            DB::beginTransaction();
-
-            Construction::where('id',$data['id'])->update([
-                'del_time'=> time()
-            ]);
-            ConstructionInfo::where('del_time',0)
-                ->where('construction_id',$data['id'])
-                ->update(['del_time' => time()]);
-            $old = ConstructionFile::where('del_time',0)
-                ->where('construction_id',$data['id'])
-                ->select('file')
-                ->get()->toArray();
-            $old = array_column($old,'file');
-
-            ConstructionFile::where('del_time',0)
-                ->where('construction_id',$data['id'])
-                ->update(['del_time' => time()]);
-            ConstructionProductInfo::where('del_time',0)
-                ->where('construction_id',$data['id'])
-                ->update(['del_time' => time()]);
-            (new RangeService())->RangeDelete($data['id'],SeeRange::type_two);
-
-            //锁定库存释放
-            ProductInventoryService::changeLockNumber($user,[],$product_save);
-
-            //排班修改
-//            $schedule = ScheduleInfo::where('del_time',0)
-//                ->where('schedule_id',$construction['schedule_id'])
-//                ->where('start_time',$construction['day_start_stamp'])
-//                ->where('end_time',$construction['day_end_stamp'])
-//                ->where('is_use','>', ScheduleInfo::not_use)
-//                ->first();
-//            if(! empty($schedule)) ScheduleInfo::where('id',$schedule->id)->update(['is_use' => ScheduleInfo::not_use]);
-
-            DB::commit();
-        }catch (\Exception $exception){
-            DB::rollBack();
-            return [false,$exception->getMessage()];
-        }
-
-        return [true, ['file' => ['old' => $old]]];
-    }
-
-    /**
-     * 施工订单详情
-     * @param $data
-     * @return array
-     */
-    public function detail($data){
-        if(empty($data['id']) && empty($data['order_number'])) return [false,'请选择数据!'];
-
-        if(! empty($data['id'])){
-            $construction = Construction::where('del_time',0)
-                ->where('id',$data['id'])
-                ->first();
-        }else{
-            $construction = Construction::where('del_time',0)
-                ->where('order_number',$data['order_number'])
-                ->first();
-            $data['id'] = empty($construction->id) ? 0 : $construction->id;
-        }
-        if(empty($construction)) return [false,'施工订单不存在或已被删除'];
-        $construction = $construction->toArray();
-        $construction['state_title'] = Construction::$name[$construction['state']] ?? '';
-
-        $address_map = config('address');
-        $address_str = [];
-        if(! empty($construction['address1'])) {
-            $tmp = json_decode($construction['address1'],true);
-            $construction['address1'] = $tmp;
-            $this->findLabelsByValue($address_map,$tmp,$address_str);
-            $tmp = implode(' ',$address_str);
-            $tmp .= ' ' . $construction['address2'];
-            $address = $tmp;
-        }else{
-            $address = $construction['address2'];
-        }
-        $construction['address'] = $address;
-        $start_time = $construction['start_time'] ? date("Y-m-d H:i",$construction['start_time']) : '';
-        $end_time = $construction['end_time'] ? date("Y-m-d H:i",$construction['end_time']) : '';
-        $construction['construction_period'] = $start_time . '——' . $end_time;
-        $sales = SalesOrder::where('id',$construction['sales_order_id'])->value('order_number');
-        $construction['sales_order_number'] = $sales;
-        $customer_title = Customer::where('id',$construction['customer_id'])->value('title');
-        $construction['customer_title'] = $customer_title ?? "";
-        $info = CustomerInfo::from('customer_info as a')
-            ->leftJoin('basic_type as b','b.id','a.contact_type')
-            ->where('a.del_time',0)
-            ->where('a.customer_id',$construction['customer_id'])
-            ->where('a.contact_type','>',0)
-            ->select('b.title','a.contact_info')
-            ->get()->toArray();
-        $construction['customer_array'] = $info;
-        $info = CustomerInfo::from('customer_info as a')
-            ->leftJoin('basic_type as b','b.id','a.contact_type')
-            ->where('a.del_time',0)
-            ->where('a.customer_id',$construction['customer_id'])
-            ->where('a.contact_type','>',0)
-            ->select('b.title','a.contact_info')
-            ->get()->toArray();
-        $construction['customer_array'] = $info;
-        $construction['storehouse_title'] = Storehouse::where('id',$construction['storehouse_id'])->value('title');
-        $emp_title = Employee::where('id',$construction['customer_contact_id'])->value('emp_name');
-        $construction['customer_contact_title'] = $emp_title;
-        $construction['employee_two'] = $construction['employee_one'] = $construction['construction_contact'] = $construction['product'] = [];
-        $array = [
-            $construction['install_method'],
-            $construction['install_position'],
-            $construction['urgency'],
-        ];
-        $basic_map = BasicType::whereIn('id',$array)
-            ->pluck('title','id')
-            ->toArray();
-        $construction = [$construction];
-        foreach ($construction as $key => $value){
-            $construction[$key]['install_method_title'] = $basic_map[$value['install_method']] ?? '';
-            $construction[$key]['install_position_title'] = $basic_map[$value['install_position']] ?? '';
-            $construction[$key]['urgency_title'] = $basic_map[$value['urgency']] ?? '';
-        }
-        $construction = $construction[0];
-
-        $construction['file'] = [];
-        $file = ConstructionFile::where('del_time',0)
-            ->where('construction_id',$construction['id'])
-            ->select('id','construction_id','file','name','mark')
-            ->get()->toArray();
-        $fileUploadService = new FileUploadService();
-        foreach ($file as $value){
-            $construction['file'][] = [
-                'url' => $value['file'],
-                'name' => $value['name'],
-                'mark' => $value['mark'],
-                'show_url' => $fileUploadService->getFileShow($value['file']),
-            ];
-        }
-
-        $construction_info = ConstructionInfo::where('del_time',0)
-            ->where('construction_id',$construction['id'])
-            ->select('id','construction_id','employee_id','type','contact_type','contact_info')
-            ->get()->toArray();
-        $emp_map = Employee::whereIn('id',array_unique(array_merge_recursive([$construction['crt_id']],array_column($construction_info,'employee_id'))))
-            ->pluck('emp_name','id')
-            ->toArray();
-        $basic_map2 = BasicType::whereIn('id',array_unique(array_column($construction_info,'contact_type')))
-            ->pluck('title','id')
-            ->toArray();
-        foreach ($construction_info as $value){
-            if($value['type'] == ConstructionInfo::type_one){
-                $tmp = [
-                    'id' => $value['contact_type'],
-                    'title' => $basic_map2[$value['contact_type']] ?? '',
-                    'info' => $value['contact_info']
-                ];
-                $construction['construction_contact'][] = $tmp;
-            }elseif ($value['type'] == ConstructionInfo::type_two){
-                $tmp = [
-                    'id' => $value['employee_id'],
-                    'name' => $emp_map[$value['employee_id']] ?? '',
-                ];
-                $construction['employee_one'][] = $tmp;
-            }elseif ($value['type'] == ConstructionInfo::type_three){
-                $tmp = [
-                    'id' => $value['employee_id'],
-                    'name' => $emp_map[$value['employee_id']] ?? '',
-                ];
-                $construction['employee_two'][] = $tmp;
-            }
-        }
-
-        $p_info = ConstructionProductInfo::where('del_time',0)
-            ->where('construction_id',$construction['id'])
-            ->get()->toArray();
-        $basic_price = BasicType::whereIn('id',array_unique(array_column($p_info,'basic_type_id')))->pluck('title','id')->toArray();
-        $map = (new ProductService())->getProductDetail(array_column($p_info,'product_id'));
-        foreach ($p_info as $value){
-            $tmp = $map[$value['product_id']] ?? [];
-            $value['title'] = $tmp['title'] ?? "";
-            $value['code'] = $tmp['code'] ?? "";
-            $value['size'] = $tmp['size'] ?? "";
-            $value['unit'] = $tmp['unit'] ?? "";
-            $value['bar_code'] = $tmp['bar_code'] ?? "";
-            $value['basic_type_title'] = $basic_price[$value['basic_type_id']] ?? "";
-            $construction['product'][] = $value;
-        }
-        $construction['crt_name'] = $emp_map[$construction['crt_id']] ?? '';
-        $construction['crt_time'] = $construction['crt_time'] ? date("Y-m-d H:i:s",$construction['crt_time']): '';
-
-        //可见范围
-        $return = (new RangeService())->RangeDetail($data['id'],SeeRange::type_two);
-        $construction['depart'] = $return[0] ?? [];
-        $construction['employee'] = $return[1] ?? [];
-
-        return [true, $construction];
-    }
-
-    /**
-     * 施工订单列表
-     * @param $data
-     * @param $user
-     * @return array
-     */
-    public function constructionList($data,$user){
-        $model = Construction::Clear($user,$data);
-        $model = $model->where('del_time',0)
-            ->select('title','id','model_type','order_number','customer_id','customer_contact_id','install_method','install_position','sales_order_id','construction_fee','construction_time','handover_time','urgency','crt_id','crt_time','mark','state','address1','address2','introduction','service_price','storehouse_id','start_time','end_time','pq_state','day_start_stamp','day_end_stamp')
-            ->orderby('id', 'desc');
-
-        if(isset($data['state'])) $model->where('state', $data['state']);
-        if(isset($data['pq_state'])) $model->where('pq_state', $data['pq_state']);
-        if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
-        if(! empty($data['model_type'])) $model->where('model_type',$data['model_type']);
-        if(! empty($data['time_type'])) {
-            if($data['time_type'] == 1) {
-                $start = strtotime('today');
-                $end = strtotime('tomorrow') - 1;
-            }elseif ($data['time_type'] == 2){
-                $start = strtotime('this week',strtotime('today'));
-                $end = strtotime('this week +6 days 23:59:59', strtotime('today'));
-            }
-            if(! empty($start) && ! empty($end)) {
-                $model->where('crt_time','>=',$start);
-                $model->where('crt_time','<=',$end);
-            }
-        }
-        if(! empty($data['construction_period'][0]) && ! empty($data['construction_period'][1])) {
-            $return = $this->changeDateToTimeStampAboutRange($data['construction_period']);
-            $model->where('start_time','>=',$return[0]);
-            $model->where('end_time','<=',$return[1]);
-        }
-        if(! empty($data['pq_period'][0]) && ! empty($data['pq_period'][1])) {
-            $model->where('day_start_stamp','>=',$this->changeDateToDateMin($data['pq_period'][0]));
-            $model->where('day_end_stamp','<=',$this->changeDateToDateMin($data['pq_period'][1]));
-        }
-        if(! empty($data['sale_order'])){
-            $model2 = SalesOrder::Clear($user,$data);
-            $sale = $model2->where('del_time',0)
-                ->where('order_number', 'LIKE', '%'.$data['sale_order'].'%')
-                ->select('id')
-                ->get()->toArray();
-            $model->whereIn('sales_order_id',array_unique(array_column($sale,'id')));
-        }
-        if(! empty($data['install_method'])) {
-            $id = (new BasicTypeService())->basicTypeSearchId($data['install_method']);
-            $model->whereIn('install_method',$id);
-        }
-        if(! empty($data['install_position'])) {
-            $id = (new BasicTypeService())->basicTypeSearchId($data['install_position']);
-            $model->whereIn('install_position',$id);
-        }
-        if(! empty($data['order_number'])) $model->where('order_number', 'LIKE', '%'.$data['order_number'].'%');
-
-        $list = $this->limit($model,'',$data);
-        $list = $this->fillData($list);
-
-        return [true, $list];
-    }
-
-    /**
-     * 参数规则
-     * @param $data
-     * @param $user
-     * @param $is_add
-     * @return array
-     */
-    public function constructionRule(&$data, $user, $is_add = true){
-        if(empty($data['model_type'])) return [false,'工单模板类型不能为空'];
-        if(! in_array($data['model_type'],Construction::$model_type)) return [false,'工单模板类型错误'];
-        if(empty($data['order_number'])) return [false,'工单编号不能为空'];
-        if(empty($data['storehouse_id'])) return [false,'请选择仓库'];
-        if(empty($data['sales_order_id'])) return [false,'请选择合同'];
-        $sale = SalesOrder::where('del_time',0)->where('id',$data['sales_order_id'])->first();
-        if(empty($sale)) return [false,'合同不存在或已被删除'];
-        $sale = $sale->toArray();
-        if($sale['state'] < SalesOrder::State_two) return [false,'合同未通过确认,不允许新建施工单'];
-        if($sale['state'] >= SalesOrder::State_seven) return [false,'请确认合同状态,新建施工单失败'];
-        if($sale['top_depart_id'] == $user['head']['id']){
-            //总社的订单 需要派单 才能建施工
-            if($sale['state'] < SalesOrder::State_four) return [false,'合同未门店派单,不允许新建施工单'];
-        }
-        list($status,$msg) = $this->limitingSendRequestBackgExpire("construction" . $sale['order_number']);
-        if(! $status) return [false, $msg];
-        if(empty($data['product'])) return [false,'请选择产品'];
-        if(empty($data['construction_period'][0]) || empty($data['construction_period'][1])) return [false,'请填写施工时间范围'];
-        $data['start_time'] = $this->changeDateToDateMin($data['construction_period'][0]);
-        $data['end_time'] = $this->changeDateToDateMin($data['construction_period'][1]);
-
-        if(! empty($data['construction_fee'])){
-            $res = $this->checkNumber($data['construction_fee']);
-            if(! $res) return [false,'施工费用请输入不超过两位小数并且大于0的数值'];
-        }
-        if(! empty($data['service_price'])){
-            $res = $this->checkNumber($data['service_price']);
-            if(! $res) return [false,'服务价格请输入不超过两位小数并且大于0的数值'];
-        }
-        if(! empty($data['construction_time'])) $data['construction_time'] = $this->changeDateToDateMin($data['construction_time']);
-        if(! empty($data['handover_time'])) $data['handover_time'] = $this->changeDateToDateMin($data['handover_time']);
-
-        if($data['model_type'] == Construction::Model_type_one){
-//            if(empty($data['install_method'])) return [false,'安装方式不能为空'];
-//            if(empty($data['install_position'])) return [false,'安装地点不能为空'];
-        }else{
-//            if(empty($data['construction_contact'])) return [false,'联系方式不能为空'];
-//            if(empty($data['address1']) || empty($data['address2'])) return [false,'地址不能为空'];
-        }
-
-        //所属部门 以及  顶级部门
-        if(empty($data['depart_id'])) {
-            $data['depart_id'] = $this->getDepart($user);
-            $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
-        }
-
-        $product_submit = $product_id = [];
-        foreach ($data['product'] as $value){
-            if(empty($value['number'])) return [false,'产品数量不能为空'];
-            $res = $this->checkNumber($value['number']);
-            if(! $res) return [false,'请输入正确的产品数量'];
-
-            $key = $value['product_id'] . ',' .$data['storehouse_id'];
-            if(isset($product_submit[$key])){
-                $product_submit[$key] += $value['number'];
-            }else{
-                $product_submit[$key] = $value['number'];
-            }
-            $product_id[] = $value['product_id'];
-        }
-
-        //剩余能施工
-        $id = $data['id'] ?? 0;
-        $s_product = $this->getSaveReturnCompareMessage($id, $data['sales_order_id']);
-
-        //比较
-        foreach ($product_submit as $pro => $number){
-            $tmp = explode(',',$pro);
-            $p = $tmp[0];
-            if(! isset($s_product[$p])) return [false,'施工产品错误,合同中不存在该产品'];
-            $s_number = $s_product[$p];
-
-            if($number > $s_number) return [false,'施工产品数量不能超过合同产品数据(包含已退货产品)'];
-        }
-
-        $id = $data['id'] ?? 0;
-        $product_save = $this->getSaveDetail($id);
-
-        //是否校验库存
-        ProductInventoryService::is_check($user,$data);
-
-        list($status,$msg) = (new ProductInventoryService())->compareStock($user,$product_id, $product_submit, $product_save);
-        if(! $status) return [false, $msg];
-
-        $start_time = date("Y-m-d H:i",$data['start_time']);
-        $end_time = date("Y-m-d H:i",$data['end_time']);
-        if($is_add){
-            $bool = Construction::where('del_time',0)
-                ->where('order_number',$data['order_number'])
-                ->exists();
-            if($bool) return [false,'工单编号已存在,请重新获取'];
-//            $bool = Construction::where('del_time',0)
-//                ->where('sales_order_id',$data['sales_order_id'])
-//                ->where('start_time', '<=', $data['end_time'])
-//                ->where('end_time', '>=', $data['start_time'])
-//                ->exists();
-//            if($bool) return [false,'合同:' . $sale['order_number'] . '在' . $start_time . '——' . $end_time . '已下施工单'];
-        }else{
-            if(empty($data['id'])) return [false,'ID不能为空'];
-//            $bool = Construction::where('del_time',0)
-//                ->where('id','<>',$data['id'])
-//                ->where('sales_order_id',$data['sales_order_id'])
-//                ->where('start_time', '<=', $data['end_time'])
-//                ->where('end_time', '>=', $data['start_time'])
-//                ->exists();
-//            if($bool)  return [false,'合同:' . $sale['order_number'] . '在' . $start_time . '——' . $end_time . '已下施工单'];
-        }
-
-        return [true, [$product_submit, $product_save]];
-    }
-
-    /**
-     * 数据拼接
-     * @param $data
-     * @return array
-     */
-    public function fillData($data){
-        if(empty($data['data'])) return $data;
-
-        $array = array_unique(array_merge_recursive(array_column($data['data'],'install_method'),array_column($data['data'],'urgency'),array_column($data['data'],'install_position')));
-        $basic_map = BasicType::whereIn('id',$array)
-            ->pluck('title','id')
-            ->toArray();
-        $emp = Employee::whereIn('id',array_unique(array_merge_recursive(array_column($data['data'],'crt_id'),array_column($data['data'],'customer_contact_id'))))
-            ->pluck('emp_name','id')
-            ->toArray();
-        $customer = Customer::whereIn('id',array_unique(array_column($data['data'],'customer_id')))
-            ->pluck('title','id')
-            ->toArray();
-        $sales_map = SalesOrder::whereIn('id',array_unique(array_column($data['data'],'sales_order_id')))->pluck('order_number','id')->toArray();
-        $storehouse = Storehouse::whereIn('id',array_unique(array_column($data['data'],'storehouse_id')))
-            ->pluck('title','id')
-            ->toArray();
-
-        //分派的总社或分社
-        $dispatch = $this->getDispatchData($data['data']);
-
-        //施工产品
-        $product_map = $this->getProduct($data['data']);
-
-        //订单状态数据组织
-        $state_array = $this->getStateMake($data['data']);
-
-        $address_map = config('address');
-        foreach ($data['data'] as $key => $value){
-            $address_str = [];
-            $product_tmp = $product_map[$value['id']] ?? [];
-            $data['data'][$key]['product_detail'] = implode(',',$product_tmp);
-            if(! empty($value['address1'])) {
-                $tmp = json_decode($value['address1'],true);
-                $this->findLabelsByValue($address_map,$tmp,$address_str);
-                $tmp = implode(' ',$address_str);
-                $tmp .= ' ' . $value['address2'];
-                $address = $tmp;
-            }else{
-                $address = $value['address2'];
-            }
-            $start_time = $value['start_time'] ? date("Y-m-d H:i",$value['start_time']) : '';
-            $end_time = $value['end_time'] ? date("Y-m-d H:i",$value['end_time']) : '';
-            $data['data'][$key]['construction_period'] = $start_time . '——' . $end_time;
-            $data['data'][$key]['address'] = $address;
-            $data['data'][$key]['model_type_title'] = Construction::$model_type_title[$value['model_type']] ?? '';
-            $data['data'][$key]['install_position_title'] = $basic_map[$value['install_position']] ?? '';
-            $data['data'][$key]['install_method_title'] = $basic_map[$value['install_method']] ?? '';
-            $data['data'][$key]['urgency_title'] = $basic_map[$value['urgency']] ?? '';
-            $data['data'][$key]['customer_title'] = $customer[$value['customer_id']] ?? '';
-            $data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
-            $data['data'][$key]['crt_name'] = $emp[$value['crt_id']] ?? '';
-            $data['data'][$key]['state_title'] = $this->makeState($data['data'][$key], $state_array);
-            $data['data'][$key]['customer_contact_title'] = $emp[$value['customer_contact_id']] ?? '';
-            $tmp_sales = $sales_map[$value['sales_order_id']] ?? "";
-//            $tmp_sales_time = $tmp_sales['handover_time'] ? date("Y-m-d") : "";
-            $data['data'][$key]['sales_order_number'] = $tmp_sales;
-            $data['data'][$key]['handover_time'] = $value['handover_time'] ? date("Y-m-d",$value['handover_time']) : "";
-            $data['data'][$key]['storehouse_title'] = $storehouse[$value['storehouse_id']] ?? '';
-            $data['data'][$key]['dispatch_company'] = $dispatch[$value['sales_order_id']] ?? '';
-//            $data['data'][$key]['pq_state_title'] = Construction::$pq_name[$value['pq_state']] ?? '';
-//            $str = "";
-//            $start_time = $value['day_start_stamp'] ? date("Y-m-d H:i",$value['day_start_stamp']) : '';
-//            $end_time = $value['day_end_stamp'] ? date("Y-m-d H:i",$value['day_end_stamp']) : '';
-//            if(! empty($start_time) && ! empty($end_time)) $str = $start_time . '——' . $end_time;
-//            $data['data'][$key]['pq_period'] = $str;
-        }
-
-        return $data;
-    }
-
-    public function getStateMake($data){
-        if(empty($data)) return [];
-
-        $order_no = [];
-        foreach ($data as $value){
-            if($value['state'] != Construction::STATE_ONE) continue;
-            $order_no[] = $value['order_number'];
-        }
-
-        return (new OaService())->getOaTeamDetailList($order_no);
-    }
-
-    public function makeState($value, $state_array){
-        if(! empty($state_array[$value['order_number']])){
-            $emp_tmp = $state_array[$value['order_number']];
-            $state = "待" . $emp_tmp . "审核";
-        }elseif($value['state'] == Construction::STATE_ZERO){
-            $state = "待" . $value['crt_name'] . "提交";
-        }else{
-            $state = Construction::$name[$value['state']] ?? '';
-        }
-
-        return $state;
-    }
-
-    public function getProduct($data){
-        $search_id = array_column($data,'id');
-        if(empty($search_id)) return [];
-
-        $product = ConstructionProductInfo::where('del_time',0)
-            ->whereIn('construction_id',$search_id)
-            ->select('product_id','construction_id')
-            ->get()->toArray();
-        $product_map = Product::whereIn('id',array_unique(array_column($product,'product_id')))->pluck('title','id')->toArray();
-
-        $return = [];
-        foreach ($product as $value){
-            $product_tmp = $product_map[$value['product_id']] ?? "";
-            if($product_tmp) $return[$value['construction_id']][] = $product_tmp;
-        }
-
-        return $return;
-    }
-
-    public function getDispatchData($data){
-        $search_id = [];
-        foreach ($data as $value){
-            $search_id[] = $value['sales_order_id'];
-        }
-        if(empty($search_id)) return [];
-
-        $see = SeeRange::where('del_time',0)
-            ->whereIn('data_id',$search_id)
-            ->where('data_type',SeeRange::type_seven)
-            ->where('type',SeeRange::data_three)
-            ->select('data_id','param_id')
-            ->get()->toArray();
-        $map = Depart::whereIn('id',array_unique(array_column($see,'param_id')))
-            ->pluck('title','id')
-            ->toArray();
-        $see_array = [];
-        foreach ($see as $value){
-            $see_array[$value['data_id']] = $map[$value['param_id']] ?? "";
-        }
-
-        return $see_array;
-    }
-
-    /**
-     * 获取施工单号
-     * @param $data
-     * @return array
-     */
-    public function constructionGet($data){
-        if(empty($data['model_type'])) return [false,'工单模板类型不能为空'];
-        if(! isset(Construction::$prefix[$data['model_type']])) return [false,'工单模板类型错误'];
-        $prefix = Construction::$prefix[$data['model_type']];
-        $order_number = OrderNoService::createConstructionOrderNumber($prefix);
-        if(! $order_number) return [false,'工单编号生成失败!'];
-
-        return [true,['order_number' => $order_number]];
-    }
-
-    /**
-     * 获取保存详情
-     * @param $id
-     * @return array
-     */
-    public function getSaveDetail($id){
-        $product_save = [];
-        if(empty($id)) return $product_save;
-
-        $sub = ConstructionProductInfo::where('construction_id',$id)
-            ->where('del_time',0)
-            ->get()->toArray();
-        foreach ($sub as $value){
-            $key = $value['product_id'] . ',' . $value['storehouse_id'];
-            if(isset($product_save[$key])){
-                $product_save[$key] += $value['number'];
-            }else{
-                $product_save[$key] = $value['number'];
-            }
-        }
-
-        return $product_save;
-    }
-
-    public function getSaveReturnCompareMessage($id = 0, $sales_order_id = 0){
-        $construction = Construction::where('del_time',0)
-            ->where('sales_order_id',$sales_order_id)
-            ->select('id')->get()->toArray();
-        $construction_id = array_column($construction,'id');
-
-        $product_save = [];
-        $sub = ConstructionProductInfo::where('del_time',0)
-            ->whereIn('construction_id',$construction_id)
-            ->when(! empty($id), function ($query) use ($id) {
-                return $query->where('construction_id', '<>',$id);
-            })
-            ->get()->toArray();
-        foreach ($sub as $value){
-            if(isset($product_save[$value['product_id']])){
-                $product_save[$value['product_id']] += $value['number'];
-            }else{
-                $product_save[$value['product_id']] = $value['number'];
-            }
-        }
-
-        $product_save2 = [];
-        $sub1 = ReturnExchangeOrder::where('del_time',0)
-            ->where('type',ReturnExchangeOrder::Order_type)
-            ->where('model_type',ReturnExchangeOrder::Model_type_one)
-            ->where('data_id',$sales_order_id)
-            ->get()->toArray();
-        $sub1_array = ReturnExchangeOrderProductInfo::where('del_time',0)
-            ->whereIn('return_exchange_id',array_column($sub1,'id'))
-            ->get()->toArray();
-        foreach ($sub1_array as $value){
-            if(isset($product_save2[$value['product_id']])){
-                $product_save2[$value['product_id']] += $value['number'];
-            }else{
-                $product_save2[$value['product_id']] = $value['number'];
-            }
-        }
-
-        $sales_order_product = [];
-        $sales_product = SalesOrderProductInfo::where('del_time',0)
-            ->where('sales_order_id',$sales_order_id)
-            ->get()->toArray();
-        foreach ($sales_product as $value){
-            $product_save_tmp = $product_save[$value['product_id']] ?? 0;
-            $product_save_tmp2 = $product_save2[$value['product_id']] ?? 0;
-            if(isset($sales_order_product[$value['product_id']])){
-                $sales_order_product[$value['product_id']] += $value['number'];
-            }else{
-                $sales_order_product[$value['product_id']] = $value['number'] - $product_save_tmp - $product_save_tmp2;
-            }
-        }
-
-        return $sales_order_product;
-    }
-
-    public function deliveryNoteEdit($data,$user){
-        $id = $user['id'];
-        if(isset($data['id'])) {
-            $model = DeliveryNote::where('id',$data['id'])->first();
-            if($model->img3) return [false,'客户已签字,无法编辑!'];
-            if(DeliveryNote::where('del_time',0)->where('construction_order_number',$data['construction_order_number'])->where('id','<>',$data['id'])->first()) return [false,'施工单客户确认单已存在!'];
-        }
-
-        else {
-            $model = new DeliveryNote();
-            $model->crt_id = $id;
-        }
-        try {
-            $model->upd_id = $id;
-            $model->construction_order_number = $data['construction_order_number'] ?? '';
-            $model->start_time = $data['start_time'] ?? '';
-            $model->end_time = $data['end_time'] ?? '';
-            $model->vin_no = $data['vin_no'] ?? '';
-            $model->system = $data['system'] ?? '';
-            $model->mile = $data['mile'] ?? '';
-            $model->is_wait = $data['is_wait'] ?? '';
-            $model->customer_name = $data['customer_name'] ?? '';
-            $model->customer_mobile = $data['customer_mobile'] ?? '';
-            $model->sale_man = $data['sale_man'] ?? '';
-            $model->install_man = $data['install_man'] ?? '';
-            $model->is_brash = $data['is_brash'] ?? '';
-            $model->is_chong = $data['is_chong'] ?? '';
-            $model->service_mark = $data['service_mark'] ?? '';
-            $model->mark = $data['mark'] ?? '';
-            $model->break = $data['break'] ? json_encode($data['break']):json_encode([]);
-            $model->break_mark = $data['break_mark'] ? json_encode($data['break_mark']):json_encode([]);
-            $model->project_id = $data['project_id'] ? json_encode($data['project_id']):json_encode([]);
-            $model->other_project_mark = $data['other_project_mark'] ?? '';
-            $model->img = $data['img'] ?? '';
-            $model->img1 = $data['img1'] ?? '';
-            $model->img2 = $data['img2'] ?? '';
-            $model->img3 = $data['img3'] ?? '';
-            $model->save();
-            return [true,'保存成功!'];
-        }catch (\Throwable $e){
-            return [true,'保存成功!'];
-        }
-
-
-
-
-    }
-
-    public function deliveryNoteList($data)
-    {
-        $list = DeliveryNote::where('del_time',0);
-        $list = $this->limit($list,'*',$data);
-        return [true,$list];
-    }
-
-    public function deliveryNoteDetail($data){
-        if(isset($data['id'])) $model = DeliveryNote::where('id',$data['id'])->where('del_time',0)->first();
-        if(isset($data['construction_order_number'])) $model = DeliveryNote::where('id',$data['construction_order_number'])->where('del_time',0)->first();
-        if(empty($model)) return [false,'数据不存在!'];
-        $employee_key_list = Employee::pluck('emp_name','id')->toArray();
-        $detail = $model->toArray();
-
-        $detail['install_man_title'] = $employee_key_list[$detail['install_man']] ?? "";
-        $detail['sale_man_title'] = $employee_key_list[$detail['sale_man']] ?? "";
-        $img_list = ConstructionFile::where('order_number',$detail['construction_order_number'])->where('del_time',0)->select('file as url','name','mark')->get()->toArray();
-        $detail['file'] = $img_list;
-        return [true,$detail];
-    }
-
-    public function deliveryNoteDel($data,$user){
-        DeliveryNote::where('id',$data['id'])->update(
-            [
-                'del_time' => time(),
-                'upd_id' => $user['id'],
-            ]
-        );
-        return [true,'删除成功!'];
-    }
-
-    public function constructionPdf($data, $user){
-        if(empty($data['id'])) return [false, '请选择下载的施工单'];
-        $construction = Construction::where('del_time',0)
-            ->where('id',$data['id'])
-            ->first();
-        if(empty($construction)) return [false, '施工单不存在或已被删除'];
-        $construction = $construction->toArray();
-        $customer_title = Customer::where('id',$construction['customer_id'])->value('title');
-        $construction['customer_title'] = $customer_title ?? "";
-        $construction['sales_order_number'] = SalesOrder::where('id',$construction['sales_order_id'])->value('order_number') ?? '';
-        $construction['handover_time'] = $construction['handover_time'] ? date("Y-m-d H:i:s",$construction['handover_time']): '';
-        $construction['crt_time'] = $construction['crt_time'] ? date("Y-m-d H:i:s",$construction['crt_time']): '';
-
-        $construction_info = ConstructionInfo::where('del_time',0)
-            ->where('construction_id',$construction['id'])
-            ->where('type',CustomerInfo::type_two)
-            ->select('id','employee_id')
-            ->get()->toArray();
-        $emp_list = Employee::whereIn('id',array_unique(array_merge_recursive([$construction['crt_id']],array_column($construction_info,'employee_id'))))
-            ->select('emp_name','id','mobile')
-            ->get()->toArray();
-        $emp_map = [];
-        foreach ($emp_list as $value){
-            $emp_map[$value['id']] = [
-                'name' => $value['emp_name'],
-                'mobile' => $value['mobile'],
-            ];
-        }
-
-        $emp_message = EmployeeDepartPermission::from('employee_depart_permission as a')
-            ->leftJoin('depart as b', 'b.id', 'a.depart_id')
-            ->select('a.employee_id', 'b.title')
-            ->whereIn('employee_id',array_column($emp_list,'id'))
-            ->get()->toArray();
-        $emp_message_map = [];
-        foreach ($emp_message as $value){
-            if(isset($emp_message_map[$value['employee_id']])){
-                $emp_message_map[$value['employee_id']] .= ',' . $value['title'];
-            }else{
-                $emp_message_map[$value['employee_id']] = $value['title'];
-            }
-        }
-
-        $crt_name = ($emp_map[$construction['crt_id']]['name'] ?? '') . '  ' . ($emp_message_map[$construction['crt_id']] ?? '') . '  ' . ($emp_map[$construction['crt_id']]['mobile'] ?? '');
-        $construction['crt_name'] = $crt_name;
-        $xt_name = "";
-        foreach ($construction_info as $value){
-            $xt_name .=  ($emp_map[$value['employee_id']]['name'] ?? '') . '  ' . ($emp_message_map[$value['employee_id']] ?? '') . '  ' . ($emp_map[$value['employee_id']]['mobile'] ?? '') . " | ";
-        }
-
-        $xt_name = rtrim($xt_name, " | ");
-        $construction['xt_name'] = $xt_name;
-
-        $p_info = ConstructionProductInfo::where('del_time',0)
-            ->where('construction_id',$construction['id'])
-            ->get()->toArray();
-        $map = (new ProductService())->getProductDetail(array_column($p_info,'product_id'));
-        $unit_map = BasicType::whereIn('id',array_column($map,'unit'))
-            ->pluck('title','id')->toArray();
-        $product = [];
-        $count = 0;
-        foreach ($p_info as $value){
-            $tmp = $map[$value['product_id']] ?? [];
-            $value['count'] = $count+1;
-            $value['title'] = $tmp['title'] ?? "";
-            $value['code'] = $tmp['code'] ?? "";
-            $value['size'] = $tmp['size'] ?? "";
-            $value['unit'] = $unit_map[$tmp['unit']] ?? "";
-            $product[] = $value;
-        }
-
-        //工单进展
-        $detail  = $this->getOaJz($data,$user);
-
-        $order_message = ['order' => $construction, 'product' => $product,'detail'=> $detail];
-
-        $pdf = app('dompdf.wrapper')->loadView('pdf.construction', $order_message);
-        $file_name = time().rand(1000,9999);
-        $filename =  '施工单_' . $file_name.'.' . 'pdf';
-        $pdf->save(storage_path('app/public/export/' . $filename));
-
-        return [true, ['file' => $filename]];
-    }
-
-    public function getOaJz($data,$user)
-    {
-        $oa = Oa::where('menu_id', 34)
-            ->where('del_time',0)
-            ->where('channel',$user['depart_top'][0]['depart_id'])
-            ->first();
-        if(empty($oa)) return [];
-        $oa = $oa->toArray();
-        $list = OaSub::where('oa_id', $oa['id'])->where('del_time', 0)->get()->toArray();
-        $oa_sub_ids = [];
-        foreach ($list as $v) {
-            $oa_sub_ids[] = $v['id'];
-        }
-        $oaEmployee = OaSubEmployee::wherein('oa_sub_id', $oa_sub_ids)->get()->toArray();
-
-        $emp_list = Employee::whereIn('id',array_column($oaEmployee,'employee_id'))
-            ->select('emp_name','id','mobile')
-            ->get()->toArray();
-        $emp_map = [];
-        foreach ($emp_list as $value){
-            $emp_map[$value['id']] = [
-                'name' => $value['emp_name'],
-                'mobile' => $value['mobile'],
-            ];
-        }
-
-        $emp_message = EmployeeDepartPermission::from('employee_depart_permission as a')
-            ->leftJoin('depart as b', 'b.id', 'a.depart_id')
-            ->whereIn('a.employee_id',array_column($emp_list,'id'))
-            ->select('a.employee_id', 'b.title')
-            ->get()->toArray();
-        $emp_message_map = [];
-        foreach ($emp_message as $value){
-            if(isset($emp_message_map[$value['employee_id']])){
-                $emp_message_map[$value['employee_id']] .= ',' . $value['title'];
-            }else{
-                $emp_message_map[$value['employee_id']] = $value['title'];
-            }
-        }
-
-        $oaEmployeeKey = [];
-        foreach ($oaEmployee as $v) {
-            $str = "";
-            $tmp = $emp_map[$v['employee_id']] ?? [];
-            $tmp2 = $emp_message_map[$v['employee_id']] ?? "";
-            $str = $tmp['name'] . " " . $tmp2 . " " . $tmp['mobile'];
-            $oaEmployeeKey[$v['oa_sub_id']][] = [
-                'id' => $v['employee_id'],
-                'emp_name' => $str,
-            ];
-        }
-
-        $return = [];
-        foreach ($list as $v) {
-            $return[$v['sort']][] = [
-                'emp_id' => $oaEmployeeKey[$v['id']],
-                'index' => $v['h5_key'],
-            ];
-        }
-        $detail = [];
-        foreach ($return as $v) {
-            $children = "";
-            foreach ($v as $vv) {
-                $children .= implode('|',array_column($vv['emp_id'],'emp_name')) . ',';
-            }
-            $detail[] = rtrim($children,',');
-        }
-
-        return $detail;
-    }
-
-    public function constructionOperation($data, $user){
-        if(empty($data['order_number'])) return [false, '施工单号不能为空'];
-        if(empty($data['type'])) return [false, '操作类型不能为空'];
-
-        $order = Construction::where('del_time',0)
-            ->where('order_number',$data['order_number'])
-            ->first();
-        if(empty($order)) return [false,'施工单不存在或已被删除,操作失败'];
-        $order = $order->toArray();
-
-        if($data['type'] == 1){
-            if($order['state'] != Construction::STATE_TWO) return [false, '请确认施工单单据状态,操作完结失败'];
-            $state = Construction::STATE_THREE;
-        }else{
-            if($order['state'] != Construction::STATE_THREE) return [false, '请确认施工单单据状态,操作待确认失败'];
-            $state = Construction::STATE_FOUR;
-        }
-
-        Construction::where('order_number',$data['order_number'])
-            ->update(['state' => $state]);
-
-        return [true, ''];
-    }
-}

+ 0 - 318
app/Service/ContactsService.php

@@ -1,318 +0,0 @@
-<?php
-
-namespace App\Service;
-
-use App\Model\BasicType;
-use App\Model\Contacts;
-use App\Model\ContactsInfo;
-use App\Model\Employee;
-use Illuminate\Support\Facades\DB;
-
-class ContactsService extends Service
-{
-    public function contactsEdit($data,$user){
-        list($status,$msg) = $this->contactsRule($data,false);
-        if(!$status) return [$status,$msg];
-
-        try {
-            DB::beginTransaction();
-
-            $model = Contacts::where('id',$data['id'])->first();
-            $model->img = $data['img'] ?? '';
-            $model->title = $data['title'];
-            $model->mailbox = $data['mailbox'] ?? '';
-            $model->qq = $data['qq'] ?? '';
-            $model->postal_code = $data['postal_code'] ?? '';
-            $model->sex = $data['sex'] ?? '';
-            $model->gregorian_bir = $data['gregorian_bir'] ?? '';
-            $model->lunar_bir = $data['lunar_bir'] ?? '';
-            $model->address1 = $data['address1'] ?? '';
-            $model->address2 = $data['address2'] ?? '';
-            $model->hobby = $data['hobby'] ?? '';
-            $model->mark = $data['mark'] ?? '';
-            $model->importance = $data['importance'] ?? '';
-            $model->intimacy = $data['intimacy'] ?? '';
-            $model->depart = $data['depart'] ?? '';
-            $model->depart_id = $data['depart_id'] ?? '';
-            $model->job = $data['job'] ?? '';
-            $model->decision = $data['decision'] ?? 0;
-            $model->grade = $data['grade'] ?? 0;
-            $model->save();
-
-            $time = time();
-
-            ContactsInfo::where('del_time',0)
-                ->where('contacts_id',$data['id'])
-                ->update(['del_time' => $time]);
-
-            if(! empty($data['contacts'])){
-                $insert = [];
-                foreach ($data['contacts'] as $value){
-                    $insert[] = [
-                        'contacts_id' => $model->id,
-                        'contact_type' => $value['id'],
-                        'contact_info' => $value['info'],
-                        'type' => ContactsInfo::type_one,
-                        'crt_time' => $time,
-                    ];
-                }
-                ContactsInfo::insert($insert);
-            }
-
-            if(! empty($data['customers'])){
-                $insert = [];
-                foreach ($data['customers'] as $value){
-                    $insert[] = [
-                        'contacts_id' => $model->id,
-                        'employee_id' => $value,
-                        'type' => ContactsInfo::type_two,
-                        'crt_time' => $time,
-                    ];
-                }
-                ContactsInfo::insert($insert);
-            }
-
-            if(! empty($data['employee_one'])){
-                $insert = [];
-                foreach ($data['employee_one'] as $value){
-                    $insert[] = [
-                        'contacts_id' => $model->id,
-                        'employee_id' => $value,
-                        'type' => ContactsInfo::type_three,
-                        'crt_time' => $time,
-                    ];
-                }
-                ContactsInfo::insert($insert);
-            }
-
-            if(! empty($data['employee_two'])){
-                $insert = [];
-                foreach ($data['employee_two'] as $value){
-                    $insert[] = [
-                        'contacts_id' => $model->id,
-                        'employee_id' => $value,
-                        'type' => ContactsInfo::type_four,
-                        'crt_time' => $time,
-                    ];
-                }
-                ContactsInfo::insert($insert);
-            }
-
-            DB::commit();
-        }catch (\Exception $exception){
-            DB::rollBack();
-            return [false,$exception->getMessage()];
-        }
-
-        return [true,''];
-    }
-
-    public function contactsAdd($data,$user){
-        list($status,$msg) = $this->contactsRule($data);
-        if(!$status) return [$status,$msg];
-
-        try {
-            DB::beginTransaction();
-
-            $model = new Contacts();
-            $model->img = $data['img'] ?? '';
-            $model->title = $data['title'];
-            $model->mailbox = $data['mailbox'] ?? '';
-            $model->qq = $data['qq'] ?? '';
-            $model->postal_code = $data['postal_code'] ?? '';
-            $model->sex = $data['sex'] ?? '';
-            $model->gregorian_bir = $data['gregorian_bir'] ?? '';
-            $model->lunar_bir = $data['lunar_bir'] ?? '';
-            $model->address1 = $data['address1'] ?? '';
-            $model->address2 = $data['address2'] ?? '';
-            $model->hobby = $data['hobby'] ?? '';
-            $model->crt_id = $user['id'];
-            $model->mark = $data['mark'] ?? '';
-            $model->importance = $data['importance'] ?? '';
-            $model->intimacy = $data['intimacy'] ?? '';
-            $model->depart = $data['depart'] ?? '';
-            $model->depart_id = $data['depart_id'] ?? '';
-            $model->job = $data['job'] ?? '';
-            $model->decision = $data['decision'] ?? 0;
-            $model->grade = $data['grade'] ?? 0;
-            $model->save();
-            $time = time();
-
-            if(! empty($data['contacts'])){
-                $insert = [];
-                foreach ($data['contacts'] as $value){
-                    $insert[] = [
-                        'contacts_id' => $model->id,
-                        'contact_type' => $value['id'],
-                        'contact_info' => $value['info'],
-                        'type' => ContactsInfo::type_one,
-                        'crt_time' => $time,
-                    ];
-                }
-                ContactsInfo::insert($insert);
-            }
-
-            if(! empty($data['customers'])){
-                $insert = [];
-                foreach ($data['customers'] as $value){
-                    $insert[] = [
-                        'contacts_id' => $model->id,
-                        'employee_id' => $value,
-                        'type' => ContactsInfo::type_two,
-                        'crt_time' => $time,
-                    ];
-                }
-                ContactsInfo::insert($insert);
-            }
-
-            if(! empty($data['employee_one'])){
-                $insert = [];
-                foreach ($data['employee_one'] as $value){
-                    $insert[] = [
-                        'contacts_id' => $model->id,
-                        'employee_id' => $value,
-                        'type' => ContactsInfo::type_three,
-                        'crt_time' => $time,
-                    ];
-                }
-                ContactsInfo::insert($insert);
-            }
-
-            if(! empty($data['employee_two'])){
-                $insert = [];
-                foreach ($data['employee_two'] as $value){
-                    $insert[] = [
-                        'contacts_id' => $model->id,
-                        'employee_id' => $value,
-                        'type' => ContactsInfo::type_four,
-                        'crt_time' => $time,
-                    ];
-                }
-                ContactsInfo::insert($insert);
-            }
-
-            DB::commit();
-        }catch (\Exception $exception){
-            DB::rollBack();
-            return [false,$exception->getMessage()];
-        }
-
-        return [true,''];
-    }
-
-    public function contactsDel($data){
-        if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
-
-        try {
-            DB::beginTransaction();
-
-            Contacts::whereIn('id',$data['id'])->update([
-                'del_time'=> time()
-            ]);
-            ContactsInfo::where('del_time',0)
-                ->where('contacts_id',$data['id'])
-                ->update(['del_time' => time()]);
-
-            DB::commit();
-        }catch (\Exception $exception){
-            DB::rollBack();
-            return [false,$exception->getMessage()];
-        }
-
-        return [true,''];
-    }
-
-    public function contactsDetail($data){
-        if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
-
-        $customer = Contacts::where('del_time',0)
-            ->where('id',$data['id'])
-            ->first();
-        if(empty($customer)) return [false,'联系人不存在或已被删除'];
-        $customer = $customer->toArray();
-        $customer['contacts'] = $customer['customers'] = $customer['employee_one'] = $customer['employee_two'] = [];
-        $array = [
-            $customer['decision'],
-            $customer['grade'],
-        ];
-        $basic_map = BasicType::whereIn('id',$array)
-            ->pluck('title','id')
-            ->toArray();
-        $customer = [$customer];
-        foreach ($customer as $key => $value){
-            $customer[$key]['decision_title'] = $basic_map[$value['decision']] ?? '';
-            $customer[$key]['grade_title'] = $basic_map[$value['grade']] ?? '';
-        }
-        $customer = $customer[0];
-
-        $customer_info = ContactsInfo::where('del_time',0)
-            ->where('contacts_id',$customer['id'])
-            ->select('id','contacts_id','contact_type','contact_info','employee_id','type')
-            ->get()->toArray();
-        foreach ($customer_info as $value){
-            if($value['type'] == ContactsInfo::type_one){
-                $customer['contacts'][] = [
-                    'id' => $value['contact_type'],
-                    'info' => $value['contact_info']
-                ];
-            }elseif ($value['type'] == ContactsInfo::type_two){
-                $customer['customers'][] = $value['employee_id'];
-            }elseif ($value['type'] == ContactsInfo::type_three){
-                $customer['employee_one'][] = $value['employee_id'];
-            }elseif ($value['type'] == ContactsInfo::type_four){
-                $customer['employee_two'][] = $value['employee_id'];
-            }
-        }
-
-        return [true, $customer];
-    }
-
-    public function contactsList($data,$user){
-        $model = Contacts::where('del_time',0)
-            ->select('title','id','img','mailbox','qq','postal_code','sex','gregorian_bir','lunar_bir','hobby','address1','address2','crt_id','crt_time','mark','importance','depart','job','decision','grade')
-            ->orderby('id', 'desc');
-
-        if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
-
-        $list = $this->limit($model,'',$data);
-        $list = $this->fillData($list);
-
-        return [true, $list];
-    }
-
-    public function contactsRule($data, $is_add = true){
-        if(empty($data['title'])) return [false,'联系人名不能为空'];
-        if(empty($data['contacts'])) return [false,'联系方式不能为空'];
-        if(empty($data['customers'])) return [false,'关联客户不能为空'];
-        if(empty($data['employee_one'])) return [false,'负责人不能为空'];
-
-        if($is_add){
-
-        }else{
-
-        }
-
-        return [true, $data];
-    }
-
-    public function fillData($data){
-        if(empty($data['data'])) return $data;
-
-        $array = array_unique(array_merge_recursive(array_column($data['data'],'decision'),array_column($data['data'],'grade')));
-        $basic_map = BasicType::whereIn('id',$array)
-            ->pluck('title','id')
-            ->toArray();
-        $emp = Employee::whereIn('id',array_unique(array_column($data['data'],'crt_id')))
-            ->pluck('emp_name','id')
-            ->toArray();
-
-        foreach ($data['data'] as $key => $value){
-            $data['data'][$key]['decision_title'] = $basic_map[$value['decision']] ?? '';
-            $data['data'][$key]['grade_title'] = $basic_map[$value['grade']] ?? '';
-            $data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
-            $data['data'][$key]['crt_name'] = $emp[$value['crt_id']] ?? '';
-        }
-
-        return $data;
-    }
-}

+ 0 - 38
app/Service/CustomerPondService.php

@@ -1,38 +0,0 @@
-<?php
-
-namespace App\Service;
-
-
-use App\Model\Customer;
-use App\Model\Setting;
-
-class CustomerPondService extends Service
-{
-
-    protected $rule;
-    public function updateCustomerPond(){
-        $customerModel = new Customer();
-        $customerList = $customerModel->where('pond_state',0)->where('del_time',0)->first();
-        $this->rule = Setting::where('setting_name','customer_pond_limit_time')->value('setting_value');
-        foreach ($customerList as $v){
-            if($this->customerPondRule($v)){
-
-            }
-        }
-    }
-
-    //
-    public function customerPondRule($customer){
-        if($this->finishRule($customer)){
-            return true;
-        }
-        return false;
-//        if()
-    }
-
-    //关于客户的进入公海池流程(后续再出)
-    public function finishRule(){
-        $time = $this->rule;
-        return true;
-    }
-}

+ 0 - 995
app/Service/CustomerService.php

@@ -1,995 +0,0 @@
-<?php
-
-namespace App\Service;
-
-use App\Model\BasicType;
-use App\Model\Customer;
-use App\Model\CustomerInfo;
-use App\Model\Depart;
-use App\Model\Employee;
-use App\Model\FollowUpRecord;
-use App\Model\Product;
-use App\Model\SeeRange;
-use Illuminate\Support\Facades\DB;
-
-/**
- * 客户管理相关
- */
-class CustomerService extends Service
-{
-    /**
-     * 客户编辑
-     * @param $data
-     * @param $user
-     * @return array
-     */
-    public function customerEdit($data,$user){
-        list($status,$msg) = $this->customerRule($data,$user, false);
-        if(!$status) return [$status,$msg];
-
-        $data['order_number'] = Customer::$order_number . "|" . $data['id'] . "|" . $data['title'];
-        $params = $this->getDataFile($data);
-        (new OperationLogService())->setOperationList($params,$user,2);
-
-        try {
-            DB::beginTransaction();
-
-            //车型
-            if(empty($data['car_type']) && ! empty($data['car_type_title'])){
-                $model_2 = new BasicType();
-                $model_2->title = $data['car_type_title'];
-                $model_2->type = 10;
-                $model_2->depart_id = $data['depart_id'] ?? 0;
-                $model_2->top_depart_id = $data['top_depart_id'] ?? 0;
-                $model_2->crt_id = $user['id'];
-                $model_2->save();
-                $data['car_type'] = $model_2->id;
-            }
-
-            $model = Customer::where('id',$data['id'])->first();
-            $model->title = $data['title'];
-            $model->code = $data['code'] ?? "";
-            $model->model_type = $data['model_type'];
-            $model->customer_intention = $data['customer_intention'] ?? 0;
-            $model->customer_from = $data['customer_from'] ?? 0;
-            $model->customer_type = $data['customer_type'] ?? 0;
-            $model->car_type = $data['car_type'] ?? 0;
-            $model->consulting_product = $data['consulting_product'] ?? '';
-            $model->intention_product = $data['intention_product'] ?? 0;
-            $model->progress_stage = $data['progress_stage'] ?? 0;
-            $model->address1 = ! empty($data['address1']) ? json_encode($data['address1']) : '';
-            $model->address2 = $data['address2'] ?? '';
-            $model->mark = $data['mark'] ?? '';
-            $model->importance = $data['importance'] ?? '';
-            $model->company = $data['company'] ?? '';
-//            $model->company_short_name = $data['company_short_name'] ?? '';
-            $model->state_type = $data['state_type'] ?? 0;
-            $model->customer_state = $data['customer_state'] ?? 0;
-            $model->save();
-            $time = time();
-
-            $old = CustomerInfo::where('del_time',0)
-                ->where('customer_id',$data['id'])
-                ->whereIn('type',[CustomerInfo::type_five,CustomerInfo::type_six])
-                ->select('file')
-                ->get()->toArray();
-            $old = array_column($old,'file');
-            CustomerInfo::where('del_time',0)
-                ->where('customer_id',$data['id'])
-                ->where('type','<>',CustomerInfo::type_two)
-                ->update(['del_time' => $time]);
-
-            if(! empty($data['customer_contact'])){
-                $insert = [];
-                foreach ($data['customer_contact'] as $value){
-                    $insert[] = [
-                        'customer_id' => $model->id,
-                        'contact_type' => $value['id'],
-                        'contact_info' => $value['info'],
-                        'type' => CustomerInfo::type_one,
-                        'crt_time' => $time,
-                    ];
-                }
-                CustomerInfo::insert($insert);
-            }
-
-//            if(! empty($data['employee_one'])){
-//                $insert = [];
-//                foreach ($data['employee_one'] as $value){
-//                    $insert[] = [
-//                        'customer_id' => $model->id,
-//                        'data_id' => $value,
-//                        'type' => CustomerInfo::type_two,
-//                        'crt_time' => $time,
-//                    ];
-//                }
-//                CustomerInfo::insert($insert);
-//            }
-
-            if(! empty($data['employee_two'])){
-                $insert = [];
-                foreach ($data['employee_two'] as $value){
-                    $insert[] = [
-                        'customer_id' => $model->id,
-                        'data_id' => $value,
-                        'type' => CustomerInfo::type_three,
-                        'crt_time' => $time,
-                    ];
-                }
-                CustomerInfo::insert($insert);
-            }
-
-            if(! empty($data['employee_three'])){
-                $insert = [];
-                foreach ($data['employee_three'] as $value){
-                    $insert[] = [
-                        'customer_id' => $model->id,
-                        'data_id' => $value,
-                        'type' => CustomerInfo::type_four,
-                        'crt_time' => $time,
-                    ];
-                }
-                CustomerInfo::insert($insert);
-            }
-
-            $new = [];
-            if(! empty($data['img'])){
-                $insert = [];
-                foreach ($data['img'] as $value){
-                    $insert[] = [
-                        'customer_id' => $model->id,
-                        'file' => $value['url'],
-                        'type' => CustomerInfo::type_five,
-                        'name' => $value['name'],
-                        'crt_time' => $time,
-                    ];
-                    if(in_array($value['url'], $old)) {
-                        foreach ($old as $o_k => $o_v){
-                            if($o_v == $value['url']) unset($old[$o_k]);
-                        }
-                    }else{
-                        $new[] = $value['url'];
-                    }
-                }
-                CustomerInfo::insert($insert);
-            }
-
-            if(! empty($data['file'])){
-                $insert = [];
-                foreach ($data['file'] as $value){
-                    $insert[] = [
-                        'customer_id' => $model->id,
-                        'file' => $value['url'],
-                        'type' => CustomerInfo::type_six,
-                        'name' => $value['name'],
-                        'crt_time' => $time,
-                    ];
-                    if(in_array($value['url'], $old)) {
-                        foreach ($old as $o_k => $o_v){
-                            if($o_v == $value['url']) unset($old[$o_k]);
-                        }
-                    }else{
-                        $new[] = $value['url'];
-                    }
-                }
-                CustomerInfo::insert($insert);
-            }
-
-            DB::commit();
-        }catch (\Exception $exception){
-            DB::rollBack();
-            return [false,$exception->getMessage()];
-        }
-
-        return [true, ['file' => ['new' => $new, 'old' => $old]]];
-    }
-
-    /**
-     * 客户新增
-     * @param $data
-     * @param $user
-     * @return array
-     */
-    public function customerAdd($data,$user){
-        list($status,$msg) = $this->customerRule($data,$user);
-        if(!$status) return [$status,$msg];
-
-        try {
-            DB::beginTransaction();
-
-            //车型
-            if(empty($data['car_type']) && ! empty($data['car_type_title'])){
-                $model_2 = new BasicType();
-                $model_2->title = $data['car_type_title'];
-                $model_2->type = 10;
-                $model_2->depart_id = $data['depart_id'] ?? 0;
-                $model_2->top_depart_id = $data['top_depart_id'] ?? 0;
-                $model_2->crt_id = $user['id'];
-                $model_2->save();
-                $data['car_type'] = $model_2->id;
-            }
-
-            $model = new Customer();
-            $model->title = $data['title'];
-            $model->code = $data['code'] ?? "";
-            $model->model_type = $data['model_type'];
-            $model->customer_intention = $data['customer_intention'] ?? 0;
-            $model->customer_from = $data['customer_from'] ?? 0;
-            $model->customer_type = $data['customer_type'] ?? 0;
-            $model->car_type = $data['car_type'] ?? 0;
-            $model->consulting_product = $data['consulting_product'] ?? '';
-            $model->intention_product = $data['intention_product'] ?? 0;
-            $model->progress_stage = $data['progress_stage'] ?? 0;
-            $model->address1 = ! empty($data['address1']) ? json_encode($data['address1']) : '';
-            $model->address2 = $data['address2'] ?? '';
-            $model->crt_id = $user['id'];
-            $model->mark = $data['mark'] ?? '';
-            $model->importance = $data['importance'] ?? '';
-            $model->company = $data['company'] ?? '';
-//            $model->company_short_name = $data['company_short_name'] ?? '';
-            $model->depart_id = $data['depart_id'] ?? 0;
-            $model->top_depart_id = $data['top_depart_id'] ?? 0;
-            $model->state_type = $data['state_type'] ?? 0;
-            $model->customer_state = $data['customer_state'] ?? 0;
-            $model->save();
-            $time = time();
-
-            if(! empty($data['customer_contact'])){
-                $insert = [];
-                foreach ($data['customer_contact'] as $value){
-                    $insert[] = [
-                        'customer_id' => $model->id,
-                        'contact_type' => $value['id'],
-                        'contact_info' => $value['info'],
-                        'type' => CustomerInfo::type_one,
-                        'crt_time' => $time,
-                    ];
-                }
-                CustomerInfo::insert($insert);
-            }
-
-            if(! empty($data['employee_one'])){
-                $insert = [];
-                foreach ($data['employee_one'] as $value){
-                    $insert[] = [
-                        'customer_id' => $model->id,
-                        'data_id' => $value,
-                        'type' => CustomerInfo::type_two,
-                        'crt_time' => $time,
-                    ];
-                }
-                CustomerInfo::insert($insert);
-
-                Customer::where('id',$model->id)->update([
-                    'fp_top_depart_id' => $data['fp_top_depart_id'] ?? 0,
-                    'fp_time' => $time,
-                ]);
-            }
-
-            if(! empty($data['employee_two'])){
-                $insert = [];
-                foreach ($data['employee_two'] as $value){
-                    $insert[] = [
-                        'customer_id' => $model->id,
-                        'data_id' => $value,
-                        'type' => CustomerInfo::type_three,
-                        'crt_time' => $time,
-                    ];
-                }
-                CustomerInfo::insert($insert);
-            }
-
-            if(! empty($data['employee_three'])){
-                $insert = [];
-                foreach ($data['employee_three'] as $value){
-                    $insert[] = [
-                        'customer_id' => $model->id,
-                        'data_id' => $value,
-                        'type' => CustomerInfo::type_four,
-                        'crt_time' => $time,
-                    ];
-                }
-                CustomerInfo::insert($insert);
-            }
-
-            $new = [];
-            if(! empty($data['img'])){
-                $insert = [];
-                foreach ($data['img'] as $value){
-                    $insert[] = [
-                        'customer_id' => $model->id,
-                        'file' => $value['url'],
-                        'type' => CustomerInfo::type_five,
-                        'name' => $value['name'],
-                        'crt_time' => $time,
-                    ];
-                    if(! empty($value['url'])) $new[] = $value['url'];
-                }
-                CustomerInfo::insert($insert);
-            }
-
-            if(! empty($data['file'])){
-                $insert = [];
-                foreach ($data['file'] as $value){
-                    $insert[] = [
-                        'customer_id' => $model->id,
-                        'file' => $value['url'],
-                        'type' => CustomerInfo::type_six,
-                        'name' => $value['name'],
-                        'crt_time' => $time,
-                    ];
-                    if(! empty($value['url'])) $new[] = $value['url'];
-                }
-                CustomerInfo::insert($insert);
-            }
-
-            DB::commit();
-        }catch (\Exception $exception){
-            DB::rollBack();
-            return [false,$exception->getMessage()];
-        }
-
-        $data['order_number'] = Customer::$order_number . "|" . $model->id . "|" . $data['title'];
-        (new OperationLogService())->setOperationList($data,$user);
-
-        return [true, ['file' => ['new' => $new]]];
-    }
-
-    /**
-     * 客户删除
-     * @param $data
-     * @return array
-     */
-    public function customerDel($data){
-        if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
-
-        if($data['id'] < 0) return [false, '系统数据,操作失败!'];
-        try {
-            DB::beginTransaction();
-
-            Customer::where('id',$data['id'])->update([
-                'del_time'=> time()
-            ]);
-            $old = CustomerInfo::where('del_time',0)
-                ->where('customer_id',$data['id'])
-                ->whereIn('type',[CustomerInfo::type_five,CustomerInfo::type_six])
-                ->select('file')
-                ->get()->toArray();
-            $old = array_column($old,'file');
-
-            CustomerInfo::where('del_time',0)
-                ->where('customer_id',$data['id'])
-                ->update(['del_time' => time()]);
-
-            (new RangeService())->RangeDelete($data['id'],SeeRange::type_one);
-
-            DB::commit();
-        }catch (\Exception $exception){
-            DB::rollBack();
-            return [false,$exception->getMessage()];
-        }
-
-        return [true, ['file' => ['old' => $old]]];
-    }
-
-    /**
-     * 客户详情
-     * @param $data
-     * @return array
-     */
-    public function customerDetail($data,$user){
-        if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
-
-        $customer = Customer::where('del_time',0)
-            ->where('id',$data['id'])
-            ->first();
-        if(empty($customer)) return [false,'客户不存在或已被删除'];
-        $customer = $customer->toArray();
-        //是否是总社的客户
-        $is_main = 0;
-        if($customer['top_depart_id'] == $user['head']['id']) $is_main = 1;
-        $customer['is_belong_to_main'] = $is_main;
-        $customer['order_number'] = Customer::$order_number . "|" . $data['id'] . "|" . $customer['title'];
-        $customer['intention_product_title'] = Product::where('id',$customer['intention_product'])->value('title') ?? "";
-        $customer['product_category'] = [];
-        if(! empty($customer['intention_product'])){
-            $pro = (new ProductService())->getProductDetail([$customer['intention_product']]);
-            $product_category = $pro[$customer['intention_product']]['product_category'] ?? '';
-            $customer['product_category'] = $product_category ? json_decode($product_category,true) : [];
-        }
-
-        $address_map = config('address');
-        $address_str = [];
-        if(! empty($customer['address1'])) {
-            $tmp = json_decode($customer['address1'],true);
-            $this->findLabelsByValue($address_map,$tmp,$address_str);
-            $customer['address1'] = $tmp;
-            $tmp = implode(' ',$address_str);
-            $tmp .= ' ' . $customer['address2'];
-            $address = $tmp;
-        }else{
-            $address = $customer['address2'];
-        }
-        $customer['address'] = $address;
-        $customer['customer_contact'] = $customer['employee_one'] = $customer['employee_two'] = $customer['employee_three'] = $customer['img'] = $customer['file'] = $customer['old_employee_one'] = [];
-        $array = [
-            $customer['customer_intention'],
-            $customer['customer_from'],
-            $customer['customer_type'],
-            $customer['car_type'],
-            $customer['progress_stage'],
-            $customer['state_type'],
-            $customer['customer_state'],
-        ];
-        $basic_map = BasicType::whereIn('id',$array)
-            ->pluck('title','id')
-            ->toArray();
-        $depart_title = Depart::where('id',$customer['depart_id'])->select('title')->value('title');
-        $customer = [$customer];
-        foreach ($customer as $key => $value){
-            $customer[$key]['customer_intention_title'] = $basic_map[$value['customer_intention']] ?? '';
-            $customer[$key]['customer_from_title'] = $basic_map[$value['customer_from']] ?? '';
-            $customer[$key]['customer_type_title'] = $basic_map[$value['customer_type']] ?? '';
-            $customer[$key]['car_type_title'] = $basic_map[$value['car_type']] ?? '';
-            $customer[$key]['progress_stage_title'] = $basic_map[$value['progress_stage']] ?? '';
-            $customer[$key]['state_type_title'] = $basic_map[$value['state_type']] ?? '';
-            $customer[$key]['customer_state_title'] = $basic_map[$value['customer_state']] ?? '';
-            $customer[$key]['depart_title'] = $depart_title ?? '';
-        }
-        $customer = $customer[0];
-
-        $customer_info = CustomerInfo::where('del_time',0)
-            ->where('customer_id',$customer['id'])
-            ->select('id','customer_id','contact_type','contact_info','data_id','file','type','name')
-            ->get()->toArray();
-        $emp_id = [];
-        $emp_id[] = $customer['crt_id'];
-        foreach ($customer_info as $value){
-            if(in_array($value['type'], CustomerInfo::$man)){
-                $emp_id[] = $value['data_id'];
-            }
-        }
-        $emp_map = Employee::whereIn('id',array_unique($emp_id))
-            ->pluck('emp_name','id')
-            ->toArray();
-        $basic_map2 = BasicType::whereIn('id',array_unique(array_column($customer_info,'contact_type')))
-            ->pluck('title','id')
-            ->toArray();
-        $fileUploadService = new FileUploadService();
-        foreach ($customer_info as $value){
-            if($value['type'] == CustomerInfo::type_one){
-                $tmp = [
-                    'id' => $value['contact_type'],
-                    'title' => $basic_map2[$value['contact_type']] ?? '',
-                    'info' => $value['contact_info']
-                ];
-                $customer['customer_contact'][] = $tmp;
-            }elseif ($value['type'] == CustomerInfo::type_two){
-                $tmp = [
-                    'id' => $value['data_id'],
-                    'name' => $emp_map[$value['data_id']] ?? '',
-                ];
-                $customer['employee_one'][] = $tmp;
-            }elseif ($value['type'] == CustomerInfo::type_three){
-                $tmp = [
-                    'id' => $value['data_id'],
-                    'name' => $emp_map[$value['data_id']] ?? '',
-                ];
-                $customer['employee_two'][] = $tmp;
-            }elseif ($value['type'] == CustomerInfo::type_four){
-                $tmp = [
-                    'id' => $value['data_id'],
-                    'name' => $emp_map[$value['data_id']] ?? '',
-                ];
-                $customer['employee_three'][] = $tmp;
-            }elseif ($value['type'] == CustomerInfo::type_five){
-                $tmp = [
-                    'url' => $value['file'],
-                    'name' => $value['name'],
-                    'show_url' => $fileUploadService->getFileShow($value['file']),
-                ];
-                $customer['img'][] = $tmp;
-            }elseif ($value['type'] == CustomerInfo::type_six){
-                $tmp = [
-                    'url' => $value['file'],
-                    'name' => $value['name'],
-                    'show_url' => $fileUploadService->getFileShow($value['file']),
-                ];
-                $customer['file'][] = $tmp;
-            }elseif ($value['type'] == CustomerInfo::type_nine){
-                $tmp = [
-                    'id' => $value['data_id'],
-                    'name' => $emp_map[$value['data_id']] ?? '',
-                ];
-                $customer['old_employee_one'][] = $tmp;
-            }
-        }
-        $customer['crt_name'] = $emp_map[$customer['crt_id']] ?? '';
-        $customer['crt_time'] = $customer['crt_time'] ? date("Y-m-d H:i:s",$customer['crt_time']): '';
-
-        //可见范围
-        $return = (new RangeService())->RangeDetail($data['id'],SeeRange::type_one);
-        $customer['depart'] = $return[0] ?? [];
-        $customer['employee'] = $return[1] ?? [];
-
-        return [true, $customer];
-    }
-
-    /**
-     * 客户列表
-     * @param $data
-     * @param $user
-     * @return array
-     */
-    public function customerList($data,$user){
-        $model = Customer::Clear($user,$data);
-        $model = $model->where('del_time',0)
-            ->select('title','id','model_type','customer_intention','customer_from','customer_type','car_type','consulting_product','intention_product','progress_stage','address1','address2','crt_id','crt_time','mark','importance','company','company_short_name','depart_id','state_type','customer_state','pond_state','top_depart_id','fp_time','fp_top_depart_id')
-            ->orderby('id', 'desc');
-
-        if(! empty($data['id'])) $model->where('id', $data['id']);
-        if(! empty($data['my_fz']) || ! empty($data['my_xt'])){
-            $id = $this->getCustomerId($data,$user);
-            $model->whereIn('id',$id);
-        }
-        if(! empty($data['pond_state'])) {
-            $search_depart_id = $data['top_depart_id'] ?? 0; //顶级公司
-            if(empty($search_depart_id)){
-                $top_depart_id = $user['depart_top'][0] ?? [];
-                $top_depart_id = $top_depart_id['depart_id'] ?? 0;
-            }else{
-                //查询 顶级公司
-                $top_depart_id = $search_depart_id;
-            }
-            // 进入公海池的客户 公司下所有人可见
-            $model->where('pond_state', '>',0)->where('top_depart_id',$top_depart_id);
-        }
-        if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
-        if(! empty($data['time_type'])) {
-            if($data['time_type'] == 1) {
-                $start = strtotime('today');
-                $end = strtotime('tomorrow') - 1;
-            }elseif ($data['time_type'] == 2){
-                $start = strtotime('this week',strtotime('today'));
-                $end = strtotime('this week +6 days 23:59:59', strtotime('today'));
-            }
-            if(! empty($start) && ! empty($end)) {
-                $model->where('crt_time','>=',$start);
-                $model->where('crt_time','<=',$end);
-            }
-        }
-        if(! empty($data['model_type'])) $model->where('model_type',$data['model_type']);
-        if(! empty($data['consulting_product'])) $model->where('consulting_product','LIKE', '%'.$data['consulting_product'].'%');
-        if(! empty($data['mark'])) $model->where('mark','LIKE', '%'.$data['mark'].'%');
-        if(! empty($data['customer_intention'])) $model->where('customer_intention',$data['customer_intention']);
-        if(! empty($data['customer_from'])) $model->where('customer_from',$data['customer_from']);
-        if(! empty($data['customer_type'])) $model->where('customer_type',$data['customer_type']);
-        if(! empty($data['customer_intention_title'])){
-            $id = (new RangeService())->customerBasicTypeSearch($data['customer_intention_title'],[1]);
-            $model->whereIn('customer_intention', $id);
-        }
-        if(! empty($data['customer_from_title'])){
-            $id = (new RangeService())->customerBasicTypeSearch($data['customer_from_title'],[2]);
-            $model->whereIn('customer_from', $id);
-        }
-        if(! empty($data['customer_type_title'])) {
-            $id = (new RangeService())->customerBasicTypeSearch($data['customer_type_title'],[3,30]);
-            $model->whereIn('customer_type', $id);
-        }
-        if(! empty($data['crt_time'][0]) && ! empty($data['crt_time'][1])) {
-            $return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
-            $model->where('crt_time','>=',$return[0]);
-            $model->where('crt_time','<=',$return[1]);
-        }
-        if(! empty($data['crt_name'])){
-            $id = (new RangeService())->crtNameSearch($data);
-            $model->whereIn('crt_id',$id);
-        }
-        if(! empty($data['fz'])){
-            $id = (new RangeService())->customerSearch($data);
-            $model->whereIn('id',$id);
-        }
-        if(! empty($data['last_visit_time'])){
-            $id = (new FollowUpRecordService())->getLastVisitData($data['last_visit_time']);
-            $model->whereIn('id',$id);
-        }
-        if(! empty($data['contact_info'])){
-            $customer_info = CustomerInfo::where('del_time',0)
-                ->where("type",CustomerInfo::type_one)
-                ->where('contact_info','LIKE', '%'.$data['contact_info'].'%')
-                ->select('customer_id')
-                ->get()->toArray();
-            $model->whereIn('id',array_column($customer_info,'customer_id'));
-        }
-
-        $list = $this->limit($model,'',$data);
-        $list = $this->fillData($list,$data);
-
-        return [true, $list];
-    }
-
-    public function customerList2($data,$user){
-        $model = Customer::Clear($user,$data);
-        $model = $model->where('del_time',0)
-            ->where('fp_time','>',0)
-            ->select('title','id','model_type','customer_intention','customer_from','customer_type','car_type','consulting_product','intention_product','progress_stage','address1','address2','crt_id','crt_time','mark','importance','company','company_short_name','depart_id','state_type','customer_state','pond_state','top_depart_id','fp_time','fp_top_depart_id')
-            ->orderby('fp_time', 'desc');
-
-        if(! empty($data['my_fz']) || ! empty($data['my_xt'])){
-            $id = $this->getCustomerId($data,$user);
-            $model->whereIn('id',$id);
-        }
-        if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
-        if(! empty($data['time_type'])) {
-            if($data['time_type'] == 1) {
-                $start = strtotime('today');
-                $end = strtotime('tomorrow') - 1;
-            }elseif ($data['time_type'] == 2){
-                $start = strtotime('this week',strtotime('today'));
-                $end = strtotime('this week +6 days 23:59:59', strtotime('today'));
-            }
-            if(! empty($start) && ! empty($end)) {
-                $model->where('crt_time','>=',$start);
-                $model->where('crt_time','<=',$end);
-            }
-        }
-        if(! empty($data['model_type'])) $model->where('model_type',$data['model_type']);
-        if(! empty($data['consulting_product'])) $model->where('consulting_product','LIKE', '%'.$data['consulting_product'].'%');
-        if(! empty($data['mark'])) $model->where('mark','LIKE', '%'.$data['mark'].'%');
-        if(! empty($data['customer_intention'])) $model->where('customer_intention',$data['customer_intention']);
-        if(! empty($data['customer_from'])) $model->where('customer_from',$data['customer_from']);
-        if(! empty($data['customer_type'])) $model->where('customer_type',$data['customer_type']);
-        if(! empty($data['crt_time'][0]) && ! empty($data['crt_time'][1])) {
-            $return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
-            $model->where('crt_time','>=',$return[0]);
-            $model->where('crt_time','<=',$return[1]);
-        }
-        if(! empty($data['crt_name'])){
-            $id = (new RangeService())->crtNameSearch($data);
-            $model->whereIn('crt_id',$id);
-        }
-        if(! empty($data['fz'])){
-            $id = (new RangeService())->customerSearch($data);
-            $model->whereIn('id',$id);
-        }
-        if(! empty($data['last_visit_time'])){
-            $id = (new FollowUpRecordService())->getLastVisitData($data['last_visit_time']);
-            $model->whereIn('id',$id);
-        }
-        if(! empty($data['contact_info'])){
-            $customer_info = CustomerInfo::where('del_time',0)
-                ->where("type",CustomerInfo::type_one)
-                ->where('contact_info','LIKE', '%'.$data['contact_info'].'%')
-                ->select('customer_id')
-                ->get()->toArray();
-            $model->whereIn('id',array_column($customer_info,'customer_id'));
-        }
-        if(! empty($data['fp_time'][0]) && ! empty($data['fp_time'][1])){
-            $return = $this->changeDateToTimeStampAboutRange($data['fp_time']);
-            $model->where('fp_time','>=',$return[0]);
-            $model->where('fp_time','<=',$return[1]);
-        }
-
-        $list = $this->limit($model,'',$data);
-        $list = $this->fillData($list,$data);
-
-        return [true, $list];
-    }
-
-    public function getCustomerId($data,$user){
-        $return = [];
-        if(! empty($data['my_fz'])){
-            $info = CustomerInfo::where('del_time',0)
-                ->where('data_id',$user['id'])
-                ->where('type',CustomerInfo::type_two)
-                ->select('customer_id')
-                ->get()->toArray();
-            $return = array_unique(array_column($info,'customer_id'));
-        }
-
-        if(! empty($data['my_xt'])){
-            $info = CustomerInfo::where('del_time',0)
-                ->where('data_id',$user['id'])
-                ->where('type',CustomerInfo::type_three)
-                ->select('customer_id')
-                ->get()->toArray();
-            $return = array_unique(array_column($info,'customer_id'));
-        }
-
-        return $return;
-    }
-
-    /**
-     * 客户参数规则
-     * @param $data
-     * @param $is_add
-     * @return array
-     */
-    public function customerRule(&$data, $user, $is_add = true){
-        if(empty($data['model_type'])) return [false,'客户模板类型不能为空'];
-        if(! in_array($data['model_type'],Customer::$model_type)) return [false,'客户模板类型错误'];
-        if(empty($data['title'])) return [false,'客户名称不能为空'];
-        //所属部门 以及  顶级部门
-        if(empty($data['depart_id'])) {
-            $data['depart_id'] = $this->getDepart($user);
-            $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
-        }
-        if($data['model_type'] == Customer::Model_type_one){
-//            if(empty($data['customer_from'])) return [false,'客户来源不能为空'];
-//            if(empty($data['customer_type'])) return [false,'客户类别不能为空'];
-//            if(empty($data['consulting_product'])) return [false,'咨询产品不能为空'];
-//            if(empty($data['progress_stage'])) return [false,'进展阶段不能为空'];
-//            if(empty($data['employee_one'])) return [false,'销售SA不能为空'];
-        }else{
-//            if(empty($data['car_type'])) return [false,'车型不能为空'];
-//            if(empty($data['customer_contact'])) return [false,'客户联系方式不能为空'];
-        }
-
-
-        if(empty($data['car_type']) && ! empty($data['car_type_title'])){
-            $bool = BasicType::where('title',$data['car_type_title'])
-                ->where('top_depart_id',$data['top_depart_id'])
-                ->where('type',10)
-                ->where('del_time',0)
-                ->exists();
-            if($bool) return [false,'车型名称已存在'];
-        }
-
-        if($is_add){
-            $bool = Customer::where('del_time',0)
-                ->where('top_depart_id',$data['top_depart_id'])
-                ->where('title',$data['title'])
-//                ->where('model_type',$data['model_type'])
-                ->exists();
-            if(! empty($data['customer_contact'])) {
-                $search = [];
-                foreach ($data['customer_contact'] as $value){
-                    $search[] = $value['info'];
-                }
-                $boolean = CustomerInfo::from('customer_info as a')
-                    ->join('customer as b','b.id','a.customer_id')
-                    ->where('a.del_time',0)
-                    ->where('b.del_time',0)
-                    ->where('b.top_depart_id',$data['top_depart_id'])
-                    ->whereIn('a.contact_info', $search)
-                    ->exists();
-                if($boolean) return [false,'客户联系内容已存在'];
-            }
-        }else{
-            if(empty($data['id'])) return [false,'ID不能为空'];
-            $bool = Customer::where('del_time',0)
-                ->where('id','<>',$data['id'])
-                ->where('top_depart_id',$data['top_depart_id'])
-                ->where('title',$data['title'])
-//                ->where('model_type',$data['model_type'])
-                ->exists();
-
-            if(! empty($data['customer_contact'])) {
-                $search = [];
-                foreach ($data['customer_contact'] as $value){
-                    $search[] = $value['info'];
-                }
-                $boolean = CustomerInfo::from('customer_info as a')
-                    ->join('customer as b','b.id','a.customer_id')
-                    ->where('b.id','<>',$data['id'])
-                    ->where('a.del_time',0)
-                    ->where('b.del_time',0)
-                    ->where('b.top_depart_id',$data['top_depart_id'])
-                    ->whereIn('a.contact_info', $search)
-                    ->exists();
-                if($boolean) return [false,'客户联系内容已存在'];
-            }
-        }
-        if($bool) return [false,'客户名称不能重复'];
-
-        return [true, ''];
-    }
-
-    /**
-     * 拼接数据
-     * @param $data
-     * @return array
-     */
-    public function fillData($data,$ergs){
-        if(empty($data['data'])) return $data;
-
-        $array = array_unique(array_merge_recursive(array_column($data['data'],'customer_intention'),array_column($data['data'],'customer_from'),array_column($data['data'],'customer_type'),array_column($data['data'],'car_type'),array_column($data['data'],'progress_stage'),array_column($data['data'],'state_type'),array_column($data['data'],'customer_state')));
-        $basic_map = BasicType::whereIn('id',$array)
-            ->pluck('title','id')
-            ->toArray();
-        $depart_title = Depart::where('id',array_unique(array_column($data['data'],'depart_id')))
-            ->pluck('title','id')
-            ->toArray();
-        $emp = Employee::whereIn('id',array_unique(array_column($data['data'],'crt_id')))
-            ->pluck('emp_name','id')
-            ->toArray();
-        $product = Product::whereIn('id',array_unique(array_column($data['data'],'intention_product')))
-            ->pluck('title','id')
-            ->toArray();
-
-        //跟进记录
-        $record = FollowUpRecord::where('del_time',0)
-            ->where('type',FollowUpRecord::type_one)
-            ->whereIn('data_id',array_column($data['data'],'id'))
-            ->select('data_id',DB::raw('max(visit_time) as visit_time'))
-            ->groupBy('data_id')
-            ->pluck('visit_time','data_id')->toArray();
-        $record_array = [];
-        if(! empty($record)){
-            $now = time();
-            foreach ($record as $key => $value){
-                $record_array[$key] = $this->showTimeAgo($value, $now);
-            }
-        }
-
-        $customer_info = CustomerInfo::where('del_time',0)
-            ->whereIn('customer_id',array_column($data['data'],'id'))
-            ->whereIn('type',[CustomerInfo::type_one,CustomerInfo::type_two])
-            ->select('type','contact_type','contact_info','customer_id','data_id')
-            ->get()->toArray();
-
-        //客户的联系方式  客户的负责人
-        $customer_info_map = $fz = $customer_info_map2 = [];
-        $emp_map = Employee::whereIn('id',array_filter(array_column($customer_info,'data_id')))
-            ->pluck('emp_name','id')
-            ->toArray();
-        $basic_maps = BasicType::whereIn('id',array_unique(array_filter(array_column($customer_info,'contact_type'))))->pluck('title','id')->toArray();
-        foreach ($customer_info as $value){
-            if($value['type'] == CustomerInfo::type_one){
-                $value['contact_type_title'] = $basic_maps[$value['contact_type']] ?? "";
-                $customer_info_map[$value['customer_id']][] = $value;
-                if(! isset($customer_info_map2[$value['customer_id']])){
-                    $customer_info_map2[$value['customer_id']] = $value['contact_type_title'] . ": " . $value['contact_info'];
-                }else{
-                    $customer_info_map2[$value['customer_id']] .= ',' . $value['contact_type_title'] . ": " . $value['contact_info'];
-                }
-            }else{
-                $tmp = $emp_map[$value['data_id']] ?? "";
-                if(isset($fz[$value['customer_id']])){
-                    $fz[$value['customer_id']] .= ',' . $tmp;
-                }else{
-                    $fz[$value['customer_id']] = $tmp;
-                }
-            }
-        }
-
-        $array2 = array_unique(array_merge_recursive(array_column($data['data'],'top_depart_id'),array_column($data['data'],'fp_top_depart_id')));
-        $depart = Depart::whereIn('id',$array2)->pluck('title','id')->toArray();
-
-        $address_map = config('address');
-        foreach ($data['data'] as $key => $value){
-            $address_str = [];
-            if(! empty($value['address1'])) {
-                $tmp = json_decode($value['address1'],true);
-                $this->findLabelsByValue($address_map,$tmp,$address_str);
-                $tmp = implode(' ',$address_str);
-                $tmp .= ' ' . $value['address2'];
-                $address = $tmp;
-            }else{
-                $address = $value['address2'];
-            }
-            $data['data'][$key]['address'] = $address;
-            $data['data'][$key]['customer_intention_title'] = $basic_map[$value['customer_intention']] ?? '';
-            $data['data'][$key]['customer_from_title'] = $basic_map[$value['customer_from']] ?? '';
-            $data['data'][$key]['customer_type_title'] = $basic_map[$value['customer_type']] ?? '';
-            $data['data'][$key]['car_type_title'] = $basic_map[$value['car_type']] ?? '';
-            $data['data'][$key]['intention_product_title'] = $product[$value['intention_product']] ?? '';
-            $data['data'][$key]['progress_stage_title'] = $basic_map[$value['progress_stage']] ?? '';
-            $data['data'][$key]['state_type_title'] = $basic_map[$value['state_type']] ?? '';
-            $data['data'][$key]['customer_state_title'] = $basic_map[$value['customer_state']] ?? '';
-            $data['data'][$key]['depart_title'] = $depart_title[$value['depart_id']] ?? '';
-            $data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
-            $data['data'][$key]['fp_time'] = $value['fp_time'] ? date('Y-m-d H:i:s',$value['fp_time']) : '';
-            $data['data'][$key]['crt_name'] = $emp[$value['crt_id']] ?? '';
-            $customer_tmp = $customer_info_map[$value['id']] ?? [];
-            $data['data'][$key]['customer_detail'] = $customer_tmp;
-            $data['data'][$key]['customer_detail2'] = $customer_info_map2[$value['id']] ?? "";
-            $data['data'][$key]['fz'] = $fz[$value['id']] ?? [];
-            $record_tmp = $record_array[$value['id']] ?? "";
-            $data['data'][$key]['has_record'] = $record_tmp ? "查看" : "无记录";
-            $data['data'][$key]['follow_record'] = $record_array[$value['id']] ?? "";
-            $data['data'][$key]['order_number'] = Customer::$order_number . "|" . $value['id'] . "|" . $value['title'];
-            $data['data'][$key]['top_depart_title'] = $depart[$value['top_depart_id']] ?? "";
-            $data['data'][$key]['fp_top_depart_title'] = $depart[$value['fp_top_depart_id']] ?? "";
-        }
-
-        return $data;
-    }
-
-    //抢客户
-    public function customerGrabbing($data, $user){
-        $key = Customer::$limitKey . $data['customer_id'];
-        list($status,$msg) = $this->customerGrabbingRule($data,$key);
-        if(! $status) {
-            //释放锁
-            $this->dellimitingSendRequestBackg($key);
-            return [false,$msg];
-        }
-
-        try {
-            DB::beginTransaction();
-            $time = time();
-
-            $insert = [];
-
-            //负责人获取 改为前负责人
-            $man = CustomerInfo::where('del_time',0)
-                ->where('customer_id',$data['customer_id'])
-                ->where('type', CustomerInfo::type_two)
-                ->get()->toArray();
-            foreach ($man as $value){
-                $insert[] = [
-                    'customer_id' => $data['customer_id'],
-                    'data_id' => $value['data_id'],
-                    'type' => CustomerInfo::type_nine,
-                    'crt_time' => $time
-                ];
-            }
-            //增加自己为负责人
-            $insert[] = [
-                'customer_id' => $data['customer_id'],
-                'data_id' => $user['id'],
-                'type' => CustomerInfo::type_two,
-                'crt_time' => $time
-            ];
-
-            //人员清空
-            CustomerInfo::where('del_time',0)
-                ->where('customer_id',$data['customer_id'])
-                ->whereIn('type', CustomerInfo::$man2)
-                ->update(['del_time' => $time]);
-
-            //写入最新人员
-            CustomerInfo::insert($insert);
-
-            //更新公海池状态
-            Customer::where('id',$data['customer_id'])->update([
-                'pond_state' => 0
-            ]);
-
-            DB::commit();
-        }catch (\Exception $exception){
-            //释放锁
-            $this->dellimitingSendRequestBackg($key);
-
-            DB::rollBack();
-            return [false,$exception->getMessage()];
-        }
-
-        //释放锁
-        $this->dellimitingSendRequestBackg($key);
-
-        return [true, ''];
-    }
-
-    public function customerGrabbingRule($data, $key){
-        if(empty($data['customer_id'])) return [false,'请选择客户'];
-        //上锁
-        list($status,$msg) = $this->limitingSendRequestBackg($key);
-        if(! $status) return [false,$msg];
-
-        $customer = Customer::where('del_time',0)->where('id',$data['customer_id'])->first();
-        if(empty($customer)) return [false,'客户不存在或已被删除'];
-        $customer = $customer->toArray();
-        if(empty($customer['pond_state'])) return [false,'客户已退出公海池'];
-
-        return [true,''];
-    }
-
-    public function searchBy($data,$user){
-        $model = BasicType::TopClear($user,$data);
-        $result = $model->where('del_time',0)
-            ->where('type', 2)
-            ->where('title', 'LIKE', '%'.$data['customer_from'].'%')
-            ->select('id')
-            ->get()->toArray();
-
-        $model2 = Customer::Clear($user,$data);
-        $customer = $model2->where('del_time',0)
-            ->whereIn('customer_from', array_column($result,'id'))
-            ->select('id')
-            ->get()->toArray();
-
-        return array_column($customer,'id');
-    }
-}

Some files were not shown because too many files changed in this diff