TestController.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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\User;
  48. use App\UserDetail;
  49. use App\UserDutyCheck;
  50. use App\ValueStore;
  51. use App\Waybill;
  52. use Carbon\Carbon;
  53. use Carbon\CarbonPeriod;
  54. use Illuminate\Database\Eloquent\Collection;
  55. use Illuminate\Foundation\Http\FormRequest;
  56. use Illuminate\Http\Request;
  57. use Illuminate\Support\Facades\Cache;
  58. use Illuminate\Support\Facades\Auth;
  59. use Illuminate\Support\Facades\Cookie;
  60. use Illuminate\Support\Facades\DB;
  61. use Illuminate\Support\Facades\Http;
  62. use PhpOffice\PhpSpreadsheet\Calculation\Web\Service;
  63. class TestController extends Controller
  64. {
  65. use AsyncResponse,ErrorPush;
  66. const ASNREFERENCE_2 = 'ASNREFERENCE2';
  67. public function __construct()
  68. {
  69. $this->data["active_test"] = "active";
  70. }
  71. public function method(Request $request, $method)
  72. {
  73. return call_user_func([$this, $method], $request);
  74. }
  75. public function test1(){
  76. ini_set('max_execution_time',-1);
  77. $date = date("Y-m-d H:i:s");
  78. ErrorTemp::query()->truncate();
  79. OwnerFeeStorage::query()->truncate();
  80. OwnerFeeExpress::query()->truncate();
  81. OwnerFeeLogistic::query()->truncate();
  82. OwnerFeeOperation::query()->truncate();
  83. OwnerFeeOperationDetail::query()->truncate();
  84. foreach (Order::query()->where("wms_edittime",">=","2021-08-16 00:00:00")
  85. ->where("wms_status","订单完成")
  86. ->where("wms_edittime","<",$date)->get() as $order){
  87. $fee = OwnerFeeDetail::query()->where("outer_table_name","orders")->where("outer_id",$order->id)->first();
  88. if ($fee){
  89. OwnerFeeDetailLogistic::query()->where("owner_fee_detail_id",$fee->id)->delete();
  90. $fee->delete();
  91. }
  92. $a = new Collection([$order]);
  93. $this->dispatch(new OrderCreateInstantBill($a));
  94. }
  95. foreach (Store::query()->where("updated_at",">=","2021-08-16 00:00:00")
  96. ->where("status","已入库")
  97. ->where("updated_at","<",$date)->get() as $store){
  98. OwnerFeeDetail::query()->where("outer_table_name","stores")->where("outer_id",$store->id)->delete();
  99. $a = new Collection([$store]);
  100. $this->dispatch(new StoreCreateInstantBill($a));
  101. }
  102. }
  103. public function test()
  104. {
  105. ini_set('max_execution_time',-1);
  106. $day = (string)\request("day");
  107. $d = (int)$day+1;
  108. $d = $d<10 ? '0'.(string)$d : (string)$d;
  109. foreach (Order::query()->where("wms_edittime",">=","2021-08-{$day} 00:00:00")
  110. ->where("wms_status","订单完成")
  111. ->where("wms_edittime","<","2021-08-{$d} 00:00:00")->get() as $order){
  112. $fee = OwnerFeeDetail::query()->where("outer_table_name","orders")->where("outer_id",$order->id)->first();
  113. if ($fee){
  114. OwnerFeeDetailLogistic::query()->where("owner_fee_detail_id",$fee->id)->delete();
  115. $fee->delete();
  116. }
  117. $a = new Collection([$order]);
  118. $this->dispatch(new OrderCreateInstantBill($a));
  119. }
  120. foreach (Store::query()->where("updated_at",">=","2021-08-{$day} 00:00:00")
  121. ->where("status","已入库")
  122. ->where("updated_at","<","2021-08-{$d} 00:00:00")->get() as $store){
  123. OwnerFeeDetail::query()->where("outer_table_name","stores")->where("outer_id",$store->id)->delete();
  124. $a = new Collection([$store]);
  125. $this->dispatch(new StoreCreateInstantBill($a));
  126. }
  127. }
  128. public function test3()
  129. {
  130. dispatch(new WeightUpdateInstantBill(OrderPackage::query()->find(17000457)));
  131. dispatch(new WeightUpdateInstantBill(OrderPackage::query()->find(17000456)));
  132. }
  133. public function OwnerStoreFeeReportService_recordReport()
  134. {
  135. /** @var OwnerStoreFeeReportService $service */
  136. $service = app('OwnerStoreFeeReportService');
  137. $service->recordReport('2021-08-01');
  138. }
  139. public function OwnerStoreOutFeeReportService_recordReport()
  140. {
  141. /** @var OwnerStoreOutFeeReportService $service */
  142. $service = app('OwnerStoreOutFeeReportService');
  143. $service->recordReport('2021-08-01');
  144. }
  145. public function OwnerFeeTotalService_record()
  146. {
  147. /** @var OwnerFeeTotalService $service */
  148. $service = app('OwnerFeeTotalService');
  149. $service->record('2021-08-01');
  150. }
  151. //快递
  152. public function OwnerLogisticFeeReportService_record()
  153. {
  154. ini_set('max_execution_time',-1);
  155. /** @var OwnerLogisticFeeReportService $service */
  156. $service = app('OwnerLogisticFeeReportService');
  157. $service->recordReport('2021-08-01');
  158. }
  159. public function order_packages_sync_routes_flag_init()
  160. {
  161. OrderPackage::query()->whereNotNull('transfer_status')->update(['sync_routes_flag'=>true]);
  162. }
  163. }