TestController.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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\OwnerPriceOperationService;
  29. use App\Services\StationService;
  30. use App\Services\StorageService;
  31. use App\Station;
  32. use App\StationTask;
  33. use App\StationTaskMaterialBox;
  34. use App\Store;
  35. use App\TaskTransaction;
  36. use App\Unit;
  37. use App\Waybill;
  38. use Carbon\Carbon;
  39. use Carbon\CarbonPeriod;
  40. use Illuminate\Database\Eloquent\Collection;
  41. use Illuminate\Http\Request;
  42. use Illuminate\Support\Facades\Cache;
  43. use Illuminate\Support\Facades\Auth;
  44. use Illuminate\Support\Facades\Cookie;
  45. use Illuminate\Support\Facades\DB;
  46. use Illuminate\Support\Facades\Http;
  47. class TestController extends Controller
  48. {
  49. use AsyncResponse,ErrorPush;
  50. const ASNREFERENCE_2 = 'ASNREFERENCE2';
  51. private $data = [];
  52. public function __construct()
  53. {
  54. $this->data["active_test"] = "active";
  55. }
  56. public function method(Request $request, $method)
  57. {
  58. return call_user_func([$this, $method], $request);
  59. }
  60. public function test1(){
  61. ini_set('max_execution_time',-1);
  62. $date = date("Y-m-d H:i:s");
  63. ErrorTemp::query()->truncate();
  64. OwnerFeeStorage::query()->truncate();
  65. OwnerFeeExpress::query()->truncate();
  66. OwnerFeeLogistic::query()->truncate();
  67. OwnerFeeOperation::query()->truncate();
  68. OwnerFeeOperationDetail::query()->truncate();
  69. foreach (Order::query()->where("wms_edittime",">=","2021-08-16 00:00:00")
  70. ->where("wms_status","订单完成")
  71. ->where("wms_edittime","<",$date)->get() as $order){
  72. $fee = OwnerFeeDetail::query()->where("outer_table_name","orders")->where("outer_id",$order->id)->first();
  73. if ($fee){
  74. OwnerFeeDetailLogistic::query()->where("owner_fee_detail_id",$fee->id)->delete();
  75. $fee->delete();
  76. }
  77. $a = new Collection([$order]);
  78. $this->dispatch(new OrderCreateInstantBill($a));
  79. }
  80. foreach (Store::query()->where("updated_at",">=","2021-08-16 00:00:00")
  81. ->where("status","已入库")
  82. ->where("updated_at","<",$date)->get() as $store){
  83. OwnerFeeDetail::query()->where("outer_table_name","stores")->where("outer_id",$store->id)->delete();
  84. $a = new Collection([$store]);
  85. $this->dispatch(new StoreCreateInstantBill($a));
  86. }
  87. }
  88. public function test()
  89. {
  90. ini_set('max_execution_time',-1);
  91. $day = (string)\request("day");
  92. $d = (int)$day+1;
  93. $d = $d<10 ? '0'.(string)$d : (string)$d;
  94. foreach (Order::query()->where("wms_edittime",">=","2021-08-{$day} 00:00:00")
  95. ->where("wms_status","订单完成")
  96. ->where("wms_edittime","<","2021-08-{$d} 00:00:00")->get() as $order){
  97. $fee = OwnerFeeDetail::query()->where("outer_table_name","orders")->where("outer_id",$order->id)->first();
  98. if ($fee){
  99. OwnerFeeDetailLogistic::query()->where("owner_fee_detail_id",$fee->id)->delete();
  100. $fee->delete();
  101. }
  102. $a = new Collection([$order]);
  103. $this->dispatch(new OrderCreateInstantBill($a));
  104. }
  105. foreach (Store::query()->where("updated_at",">=","2021-08-{$day} 00:00:00")
  106. ->where("status","已入库")
  107. ->where("updated_at","<","2021-08-{$d} 00:00:00")->get() as $store){
  108. OwnerFeeDetail::query()->where("outer_table_name","stores")->where("outer_id",$store->id)->delete();
  109. $a = new Collection([$store]);
  110. $this->dispatch(new StoreCreateInstantBill($a));
  111. }
  112. }
  113. }