TestController.php 6.7 KB

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