TestController.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Commodity;
  4. use App\CommodityMaterialBoxModel;
  5. use App\Components\AsyncResponse;
  6. use App\Components\ErrorPush;
  7. use App\ErrorTemp;
  8. use App\Feature;
  9. use App\Jobs\CacheShelfTaskJob;
  10. use App\Jobs\OrderCreateInstantBill;
  11. use App\Jobs\OrderCreateWaybill;
  12. use App\Jobs\StoreCreateInstantBill;
  13. use App\MaterialBox;
  14. use App\MaterialBoxModel;
  15. use App\Order;
  16. use App\Owner;
  17. use App\OwnerFeeDetail;
  18. use App\OwnerFeeDetailLogistic;
  19. use App\OwnerFeeExpress;
  20. use App\OwnerFeeLogistic;
  21. use App\OwnerFeeOperation;
  22. use App\OwnerFeeOperationDetail;
  23. use App\OwnerFeeStorage;
  24. use App\OwnerPriceOperation;
  25. use App\OrderPackageCountingRecord;
  26. use App\RejectedBill;
  27. use App\Services\ForeignHaiRoboticsService;
  28. use App\Services\OrderService;
  29. use App\Services\OwnerPriceOperationService;
  30. use App\Services\StationService;
  31. use App\Services\StorageService;
  32. use App\Station;
  33. use App\StationTask;
  34. use App\StationTaskMaterialBox;
  35. use App\Store;
  36. use App\TaskTransaction;
  37. use App\Unit;
  38. use App\Waybill;
  39. use Carbon\Carbon;
  40. use Carbon\CarbonPeriod;
  41. use Illuminate\Database\Eloquent\Collection;
  42. use Illuminate\Http\Request;
  43. use Illuminate\Support\Facades\Cache;
  44. use Illuminate\Support\Facades\Auth;
  45. use Illuminate\Support\Facades\Cookie;
  46. use Illuminate\Support\Facades\DB;
  47. use Illuminate\Support\Facades\Http;
  48. class TestController extends Controller
  49. {
  50. use AsyncResponse,ErrorPush;
  51. const ASNREFERENCE_2 = 'ASNREFERENCE2';
  52. private $data = [];
  53. public function __construct()
  54. {
  55. $this->data["active_test"] = "active";
  56. }
  57. public function method(Request $request, $method)
  58. {
  59. return call_user_func([$this, $method], $request);
  60. }
  61. public function test1(){
  62. ini_set('max_execution_time',-1);
  63. $date = date("Y-m-d H:i:s");
  64. ErrorTemp::query()->truncate();
  65. OwnerFeeStorage::query()->truncate();
  66. OwnerFeeExpress::query()->truncate();
  67. OwnerFeeLogistic::query()->truncate();
  68. OwnerFeeOperation::query()->truncate();
  69. OwnerFeeOperationDetail::query()->truncate();
  70. foreach (Order::query()->where("wms_edittime",">=","2021-08-16 00:00:00")
  71. ->where("wms_status","订单完成")
  72. ->where("wms_edittime","<",$date)->get() as $order){
  73. $fee = OwnerFeeDetail::query()->where("outer_table_name","orders")->where("outer_id",$order->id)->first();
  74. if ($fee){
  75. OwnerFeeDetailLogistic::query()->where("owner_fee_detail_id",$fee->id)->delete();
  76. $fee->delete();
  77. }
  78. $a = new Collection([$order]);
  79. $this->dispatch(new OrderCreateInstantBill($a));
  80. }
  81. foreach (Store::query()->where("updated_at",">=","2021-08-16 00:00:00")
  82. ->where("status","已入库")
  83. ->where("updated_at","<",$date)->get() as $store){
  84. OwnerFeeDetail::query()->where("outer_table_name","stores")->where("outer_id",$store->id)->delete();
  85. $a = new Collection([$store]);
  86. $this->dispatch(new StoreCreateInstantBill($a));
  87. }
  88. }
  89. public function test()
  90. {
  91. ini_set('max_execution_time',-1);
  92. $day = (string)\request("day");
  93. $d = (int)$day+1;
  94. $d = $d<10 ? '0'.(string)$d : (string)$d;
  95. foreach (Order::query()->where("wms_edittime",">=","2021-08-{$day} 00:00:00")
  96. ->where("wms_status","订单完成")
  97. ->where("wms_edittime","<","2021-08-{$d} 00:00:00")->get() as $order){
  98. $fee = OwnerFeeDetail::query()->where("outer_table_name","orders")->where("outer_id",$order->id)->first();
  99. if ($fee){
  100. OwnerFeeDetailLogistic::query()->where("owner_fee_detail_id",$fee->id)->delete();
  101. $fee->delete();
  102. }
  103. $a = new Collection([$order]);
  104. $this->dispatch(new OrderCreateInstantBill($a));
  105. }
  106. foreach (Store::query()->where("updated_at",">=","2021-08-{$day} 00:00:00")
  107. ->where("status","已入库")
  108. ->where("updated_at","<","2021-08-{$d} 00:00:00")->get() as $store){
  109. OwnerFeeDetail::query()->where("outer_table_name","stores")->where("outer_id",$store->id)->delete();
  110. $a = new Collection([$store]);
  111. $this->dispatch(new StoreCreateInstantBill($a));
  112. }
  113. }
  114. public function test3()
  115. {
  116. Station::query()->update(["status"=>0]);
  117. }
  118. }