TestController.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Authority;
  4. use App\Commodity;
  5. use App\CommodityMaterialBoxModel;
  6. use App\Components\AsyncResponse;
  7. use App\Components\ErrorPush;
  8. use App\ErrorTemp;
  9. use App\Feature;
  10. use App\Http\Requests\OrderDelivering;
  11. use App\Jobs\CacheShelfTaskJob;
  12. use App\Jobs\OrderCreateInstantBill;
  13. use App\Jobs\OrderCreateWaybill;
  14. use App\Jobs\StoreCreateInstantBill;
  15. use App\Jobs\WeightUpdateInstantBill;
  16. use App\MaterialBox;
  17. use App\MaterialBoxModel;
  18. use App\Order;
  19. use App\OrderPackage;
  20. use App\Owner;
  21. use App\OwnerFeeDetail;
  22. use App\OwnerFeeDetailLogistic;
  23. use App\OwnerFeeExpress;
  24. use App\OwnerFeeLogistic;
  25. use App\OwnerFeeOperation;
  26. use App\OwnerFeeOperationDetail;
  27. use App\OwnerFeeStorage;
  28. use App\OwnerPriceOperation;
  29. use App\OrderPackageCountingRecord;
  30. use App\RejectedBill;
  31. use App\Services\CacheShelfService;
  32. use App\Services\ForeignHaiRoboticsService;
  33. use App\Services\OrderService;
  34. use App\Services\OwnerFeeTotalService;
  35. use App\Services\OwnerLogisticFeeReportService;
  36. use App\Services\OwnerPriceOperationService;
  37. use App\Services\OwnerStoreFeeReportService;
  38. use App\Services\OwnerStoreOutFeeReportService;
  39. use App\Services\StationService;
  40. use App\Services\StorageService;
  41. use App\Station;
  42. use App\StationTask;
  43. use App\StationTaskMaterialBox;
  44. use App\Store;
  45. use App\TaskTransaction;
  46. use App\Unit;
  47. use App\Waybill;
  48. use Carbon\Carbon;
  49. use Carbon\CarbonPeriod;
  50. use Illuminate\Database\Eloquent\Collection;
  51. use Illuminate\Foundation\Http\FormRequest;
  52. use Illuminate\Http\Request;
  53. use Illuminate\Support\Facades\Cache;
  54. use Illuminate\Support\Facades\Auth;
  55. use Illuminate\Support\Facades\Cookie;
  56. use Illuminate\Support\Facades\DB;
  57. use Illuminate\Support\Facades\Http;
  58. use PhpOffice\PhpSpreadsheet\Calculation\Web\Service;
  59. class TestController extends Controller
  60. {
  61. use AsyncResponse,ErrorPush;
  62. const ASNREFERENCE_2 = 'ASNREFERENCE2';
  63. public function __construct()
  64. {
  65. $this->data["active_test"] = "active";
  66. }
  67. public function method(Request $request, $method)
  68. {
  69. return call_user_func([$this, $method], $request);
  70. }
  71. public function test1(){
  72. ini_set('max_execution_time',-1);
  73. $date = date("Y-m-d H:i:s");
  74. ErrorTemp::query()->truncate();
  75. OwnerFeeStorage::query()->truncate();
  76. OwnerFeeExpress::query()->truncate();
  77. OwnerFeeLogistic::query()->truncate();
  78. OwnerFeeOperation::query()->truncate();
  79. OwnerFeeOperationDetail::query()->truncate();
  80. foreach (Order::query()->where("wms_edittime",">=","2021-08-16 00:00:00")
  81. ->where("wms_status","订单完成")
  82. ->where("wms_edittime","<",$date)->get() as $order){
  83. $fee = OwnerFeeDetail::query()->where("outer_table_name","orders")->where("outer_id",$order->id)->first();
  84. if ($fee){
  85. OwnerFeeDetailLogistic::query()->where("owner_fee_detail_id",$fee->id)->delete();
  86. $fee->delete();
  87. }
  88. $a = new Collection([$order]);
  89. $this->dispatch(new OrderCreateInstantBill($a));
  90. }
  91. foreach (Store::query()->where("updated_at",">=","2021-08-16 00:00:00")
  92. ->where("status","已入库")
  93. ->where("updated_at","<",$date)->get() as $store){
  94. OwnerFeeDetail::query()->where("outer_table_name","stores")->where("outer_id",$store->id)->delete();
  95. $a = new Collection([$store]);
  96. $this->dispatch(new StoreCreateInstantBill($a));
  97. }
  98. }
  99. public function test()
  100. {
  101. ini_set('max_execution_time',-1);
  102. $day = (string)\request("day");
  103. $d = (int)$day+1;
  104. $d = $d<10 ? '0'.(string)$d : (string)$d;
  105. foreach (Order::query()->where("wms_edittime",">=","2021-08-{$day} 00:00:00")
  106. ->where("wms_status","订单完成")
  107. ->where("wms_edittime","<","2021-08-{$d} 00:00:00")->get() as $order){
  108. $fee = OwnerFeeDetail::query()->where("outer_table_name","orders")->where("outer_id",$order->id)->first();
  109. if ($fee){
  110. OwnerFeeDetailLogistic::query()->where("owner_fee_detail_id",$fee->id)->delete();
  111. $fee->delete();
  112. }
  113. $a = new Collection([$order]);
  114. $this->dispatch(new OrderCreateInstantBill($a));
  115. }
  116. foreach (Store::query()->where("updated_at",">=","2021-08-{$day} 00:00:00")
  117. ->where("status","已入库")
  118. ->where("updated_at","<","2021-08-{$d} 00:00:00")->get() as $store){
  119. OwnerFeeDetail::query()->where("outer_table_name","stores")->where("outer_id",$store->id)->delete();
  120. $a = new Collection([$store]);
  121. $this->dispatch(new StoreCreateInstantBill($a));
  122. }
  123. }
  124. public function test3()
  125. {
  126. dispatch(new WeightUpdateInstantBill(OrderPackage::query()->find(17000457)));
  127. dispatch(new WeightUpdateInstantBill(OrderPackage::query()->find(17000456)));
  128. }
  129. public function OwnerStoreFeeReportService_recordReport()
  130. {
  131. /** @var OwnerStoreFeeReportService $service */
  132. $service = app('OwnerStoreFeeReportService');
  133. $service->recordReport('2021-08-01');
  134. }
  135. public function OwnerStoreOutFeeReportService_recordReport()
  136. {
  137. /** @var OwnerStoreOutFeeReportService $service */
  138. $service = app('OwnerStoreOutFeeReportService');
  139. $service->recordReport('2021-08-01');
  140. }
  141. public function OwnerFeeTotalService_record()
  142. {
  143. /** @var OwnerFeeTotalService $service */
  144. $service = app('OwnerFeeTotalService');
  145. $service->record('2021-08-01');
  146. }
  147. //快递
  148. public function OwnerLogisticFeeReportService_record()
  149. {
  150. ini_set('max_execution_time',-1);
  151. /** @var OwnerLogisticFeeReportService $service */
  152. $service = app('OwnerLogisticFeeReportService');
  153. $service->recordReport('2021-08-01');
  154. }
  155. public function order_packages_sync_routes_flag_init()
  156. {
  157. OrderPackage::query()->whereNotNull('transfer_status')->update(['sync_routes_flag'=>true]);
  158. }
  159. }