TestController.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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\Jobs\CacheShelfTaskJob;
  11. use App\Jobs\OrderCreateInstantBill;
  12. use App\Jobs\OrderCreateWaybill;
  13. use App\Jobs\StoreCreateInstantBill;
  14. use App\MaterialBox;
  15. use App\MaterialBoxModel;
  16. use App\Order;
  17. use App\Owner;
  18. use App\OwnerFeeDetail;
  19. use App\OwnerFeeDetailLogistic;
  20. use App\OwnerFeeExpress;
  21. use App\OwnerFeeLogistic;
  22. use App\OwnerFeeOperation;
  23. use App\OwnerFeeOperationDetail;
  24. use App\OwnerFeeStorage;
  25. use App\OwnerPriceOperation;
  26. use App\OrderPackageCountingRecord;
  27. use App\RejectedBill;
  28. use App\Services\CacheShelfService;
  29. use App\Services\ForeignHaiRoboticsService;
  30. use App\Services\OrderService;
  31. use App\Services\OwnerPriceOperationService;
  32. use App\Services\StationService;
  33. use App\Services\StorageService;
  34. use App\Station;
  35. use App\StationTask;
  36. use App\StationTaskMaterialBox;
  37. use App\Store;
  38. use App\TaskTransaction;
  39. use App\Unit;
  40. use App\Waybill;
  41. use Carbon\Carbon;
  42. use Carbon\CarbonPeriod;
  43. use Illuminate\Database\Eloquent\Collection;
  44. use Illuminate\Http\Request;
  45. use Illuminate\Support\Facades\Cache;
  46. use Illuminate\Support\Facades\Auth;
  47. use Illuminate\Support\Facades\Cookie;
  48. use Illuminate\Support\Facades\DB;
  49. use Illuminate\Support\Facades\Http;
  50. class TestController extends Controller
  51. {
  52. use AsyncResponse,ErrorPush;
  53. const ASNREFERENCE_2 = 'ASNREFERENCE2';
  54. private $data = [];
  55. public function __construct()
  56. {
  57. $this->data["active_test"] = "active";
  58. }
  59. public function method(Request $request, $method)
  60. {
  61. return call_user_func([$this, $method], $request);
  62. }
  63. public function test1(){
  64. ini_set('max_execution_time',-1);
  65. $date = date("Y-m-d H:i:s");
  66. ErrorTemp::query()->truncate();
  67. OwnerFeeStorage::query()->truncate();
  68. OwnerFeeExpress::query()->truncate();
  69. OwnerFeeLogistic::query()->truncate();
  70. OwnerFeeOperation::query()->truncate();
  71. OwnerFeeOperationDetail::query()->truncate();
  72. foreach (Order::query()->where("wms_edittime",">=","2021-08-16 00:00:00")
  73. ->where("wms_status","订单完成")
  74. ->where("wms_edittime","<",$date)->get() as $order){
  75. $fee = OwnerFeeDetail::query()->where("outer_table_name","orders")->where("outer_id",$order->id)->first();
  76. if ($fee){
  77. OwnerFeeDetailLogistic::query()->where("owner_fee_detail_id",$fee->id)->delete();
  78. $fee->delete();
  79. }
  80. $a = new Collection([$order]);
  81. $this->dispatch(new OrderCreateInstantBill($a));
  82. }
  83. foreach (Store::query()->where("updated_at",">=","2021-08-16 00:00:00")
  84. ->where("status","已入库")
  85. ->where("updated_at","<",$date)->get() as $store){
  86. OwnerFeeDetail::query()->where("outer_table_name","stores")->where("outer_id",$store->id)->delete();
  87. $a = new Collection([$store]);
  88. $this->dispatch(new StoreCreateInstantBill($a));
  89. }
  90. }
  91. public function test()
  92. {
  93. ini_set('max_execution_time',-1);
  94. $day = (string)\request("day");
  95. $d = (int)$day+1;
  96. $d = $d<10 ? '0'.(string)$d : (string)$d;
  97. foreach (Order::query()->where("wms_edittime",">=","2021-08-{$day} 00:00:00")
  98. ->where("wms_status","订单完成")
  99. ->where("wms_edittime","<","2021-08-{$d} 00:00:00")->get() as $order){
  100. $fee = OwnerFeeDetail::query()->where("outer_table_name","orders")->where("outer_id",$order->id)->first();
  101. if ($fee){
  102. OwnerFeeDetailLogistic::query()->where("owner_fee_detail_id",$fee->id)->delete();
  103. $fee->delete();
  104. }
  105. $a = new Collection([$order]);
  106. $this->dispatch(new OrderCreateInstantBill($a));
  107. }
  108. foreach (Store::query()->where("updated_at",">=","2021-08-{$day} 00:00:00")
  109. ->where("status","已入库")
  110. ->where("updated_at","<","2021-08-{$d} 00:00:00")->get() as $store){
  111. OwnerFeeDetail::query()->where("outer_table_name","stores")->where("outer_id",$store->id)->delete();
  112. $a = new Collection([$store]);
  113. $this->dispatch(new StoreCreateInstantBill($a));
  114. }
  115. }
  116. public function test3()
  117. {
  118. $row = [
  119. "运单类型", "货主", "上游单号", "wms订单号", "运单号", "运输收费",
  120. "其他收费", "其他收费备注", "始发地", "目的地","下单备注", "承运商", "承运商单号",
  121. "仓库计抛", "承运商计抛", "仓库计重", "承运商计重", "车型", "车辆信息",
  122. "计件", "里程数", "运费(元)", "提货费(元)", "其他费用(元)", "发货时间",
  123. "调度备注", "创建时间", "省", "市", "区", "FLUX地址", "FLUX重量", "FLUX数量"
  124. ];
  125. dd($row[27]);
  126. }
  127. public function testZC()
  128. {
  129. // $batch=Batch::query()
  130. // ->with('orders.orderCommodities.commodity.barcodes')
  131. // ->where('code','W210814000158')
  132. // ->first();
  133. // dd($batch);
  134. // app(ForeignZhenCangService::class)->broadcastBatch($batch);
  135. // dd('上传成功');
  136. }
  137. }