U8ServerService.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. namespace App\Service;
  3. use App\Jobs\ProcessDataJob;
  4. use App\Model\Depart;
  5. use App\Model\Employee;
  6. use App\Model\EmployeeDepartPermission;
  7. use App\Model\EmployeeIndex;
  8. use App\Model\Product;
  9. use App\Model\RevenueCost;
  10. use App\Model\RevenueCostTotal;
  11. use App\Model\SalaryEmployee;
  12. use Illuminate\Database\Schema\Blueprint;
  13. use Illuminate\Support\Facades\DB;
  14. use Illuminate\Support\Facades\Schema;
  15. class U8ServerService extends Service
  16. {
  17. protected $databaseService;
  18. /**
  19. * @var string|null
  20. */
  21. protected $error;
  22. /**
  23. * U8ServerService constructor.
  24. */
  25. public function __construct($loginUser = [])
  26. {
  27. $service = new U8DatabaseServerService($loginUser);
  28. $this->databaseService = $service->db;
  29. $this->error = $service->error;
  30. }
  31. /**
  32. * 获取错误信息
  33. *
  34. * @return string|null
  35. */
  36. public function getError()
  37. {
  38. return $this->error;
  39. }
  40. public function purchaseRequisition($data, $user){
  41. $model = $this->databaseService->table('PU_AppVouch as a')
  42. ->leftJoin('Person as c', 'c.cPersonCode', 'a.cPersonCode')
  43. ->where('a.cMaker',$user['username'])
  44. ->where('a.iverifystateex',0)
  45. ->select('a.cMaker as crt_name', 'c.cPersonName as purchase_name','a.cBusType as business_type','a.cCode as order_number','a.dDate as order_date')
  46. ->orderBy('a.ID','desc');
  47. $list = $this->limit($model,'',$data);
  48. return [true , $list];
  49. }
  50. public function purchaseRequisitionDetail($data, $user){
  51. if(empty($data['order_number'])) return [false, '采购请购单号不能为空'];
  52. $order = $this->databaseService->table('PU_AppVouch as a')
  53. ->leftJoin('Person as c', 'c.cPersonCode', 'a.cPersonCode')
  54. ->where('a.cMaker',$user['username'])
  55. ->select('a.cMaker as crt_name', 'c.cPersonName as purchase_name','a.cBusType as business_type','a.cCode as order_number','a.dDate as order_date','a.ID as id')
  56. ->first();
  57. if(empty($order)) return [false, '采购请购单不存在'];
  58. $order = $order->toArray();
  59. $detail = $this->databaseService->table('PU_AppVouchs as a')
  60. ->leftJoin('Inventory as b', 'b.cInvCode', 'a.cInvCode')
  61. ->leftJoin('ComputationUnit as c', 'c.cComunitCode', 'b.cComUnitCode')
  62. ->where('a.ID', $order['id'])
  63. ->select('b.cInvName as product_title','b.cInvCode as product_code','a.fQuantity as quantity','c.cComUnitName as unit_title','a.dRequirDate as need_arrived_date')
  64. ->get()->toArray();
  65. $order['detail'] = $detail;
  66. return [true, $order];
  67. }
  68. public function purchaseOrder($data, $user){
  69. $model = $this->databaseService->table('PO_Pomain as a')
  70. ->leftJoin('Vendor as c', 'c.cVenCode', 'a.cVenCode')
  71. ->where('a.cMaker',$user['username'])
  72. ->where('a.iverifystateex',0)
  73. ->select('a.cMaker as crt_name', 'a.cBusType as business_type','a.cPOID as order_number','a.dPODate as order_date','c.cVenName as supplier_title')
  74. ->orderBy('a.POID','desc');
  75. $list = $this->limit($model,'',$data);
  76. return [true , $list];
  77. }
  78. public function purchaseOrderDetail($data, $user){
  79. if(empty($data['order_number'])) return [false, '采购单号不能为空'];
  80. $order = $this->databaseService->table('PO_Pomain as a')
  81. ->leftJoin('Vendor as c', 'c.cVenCode', 'a.cVenCode')
  82. ->where('a.cMaker',$user['username'])
  83. ->where('a.iverifystateex',0)
  84. ->select('a.cMaker as crt_name', 'a.cBusType as business_type','a.cPOID as order_number','a.dPODate as order_date','c.cVenName as supplier_title','a.POID as id')
  85. ->first();
  86. if(empty($order)) return [false, '采购单不存在'];
  87. $order = $order->toArray();
  88. $detail = $this->databaseService->table('PO_Podetails as a')
  89. ->leftJoin('Inventory as b', 'b.cInvCode', 'a.cInvCode')
  90. ->leftJoin('ComputationUnit as c', 'c.cComunitCode', 'b.cComUnitCode')
  91. ->where('a.POID', $order['id'])
  92. ->select('b.cInvName as product_title','b.cInvCode as product_code','a.iQuantity as quantity','c.cComUnitName as unit_title','a.iSum as amount')
  93. ->get()->toArray();
  94. $order['detail'] = $detail;
  95. return [true, $order];
  96. }
  97. public function paymentOrder($data, $user){
  98. $model = $this->databaseService->table('AP_ApplyPayVouch as a')
  99. ->leftJoin('Vendor as c', 'c.cVenCode', 'a.cDwCode')
  100. ->where('a.cOperator',$user['username'])
  101. ->whereNull('a.cCheckMan')
  102. ->select('a.cOperator as crt_name', 'c.cVenName as supplier_title','a.cVouchID as order_number','a.dVouchDate as order_date')
  103. ->orderBy('a.PID','desc');
  104. $list = $this->limit($model,'',$data);
  105. return [true , $list];
  106. }
  107. public function paymentOrderDetail($data, $user){
  108. if(empty($data['order_number'])) return [false, '付款单号不能为空'];
  109. $order = $this->databaseService->table('AP_ApplyPayVouch as a')
  110. ->leftJoin('Vendor as c', 'c.cVenCode', 'a.cDwCode')
  111. ->where('a.cOperator',$user['username'])
  112. ->whereNull('a.cCheckMan')
  113. ->select('a.cOperator as crt_name', 'c.cVenName as supplier_title','a.cVouchID as order_number','a.dVouchDate as order_date','a.PID as id')
  114. ->first();
  115. if(empty($order)) return [false, '付款单不存在'];
  116. $order = $order->toArray();
  117. $detail = $this->databaseService->table('AP_ApplyPayVouchs as a')
  118. ->where('a.PID', $order['id'])
  119. ->select('a.cSource as source','a.cCoVouchID as source_order_number','a.iApplyAmt_f as amount')
  120. ->get()->toArray();
  121. $order['detail'] = $detail;
  122. return [true, $order];
  123. }
  124. }