TestController.php 6.8 KB

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