TestController.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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\Http\Requests\OrderDelivering;
  11. use App\Jobs\CacheShelfTaskJob;
  12. use App\Jobs\OrderCreateInstantBill;
  13. use App\Jobs\OrderCreateWaybill;
  14. use App\Jobs\SettlementBillReportTask;
  15. use App\Jobs\StoreCreateInstantBill;
  16. use App\Jobs\WeightUpdateInstantBill;
  17. use App\MaterialBox;
  18. use App\MaterialBoxModel;
  19. use App\Order;
  20. use App\OrderPackage;
  21. use App\Owner;
  22. use App\OwnerFeeDetail;
  23. use App\OwnerFeeDetailLogistic;
  24. use App\OwnerFeeExpress;
  25. use App\OwnerFeeLogistic;
  26. use App\OwnerFeeOperation;
  27. use App\OwnerFeeOperationDetail;
  28. use App\OwnerFeeStorage;
  29. use App\OwnerPriceOperation;
  30. use App\OrderPackageCountingRecord;
  31. use App\RejectedBill;
  32. use App\Services\CacheShelfService;
  33. use App\Services\ForeignHaiRoboticsService;
  34. use App\Services\OrderService;
  35. use App\Services\OwnerFeeTotalService;
  36. use App\Services\OwnerLogisticFeeReportService;
  37. use App\Services\OwnerPriceOperationService;
  38. use App\Services\OwnerStoreFeeReportService;
  39. use App\Services\OwnerStoreOutFeeReportService;
  40. use App\Services\StationService;
  41. use App\Services\StorageService;
  42. use App\Station;
  43. use App\StationTask;
  44. use App\StationTaskMaterialBox;
  45. use App\Store;
  46. use App\TaskTransaction;
  47. use App\Unit;
  48. use App\Waybill;
  49. use Carbon\Carbon;
  50. use Carbon\CarbonPeriod;
  51. use Illuminate\Database\Eloquent\Collection;
  52. use Illuminate\Foundation\Http\FormRequest;
  53. use Illuminate\Http\Request;
  54. use Illuminate\Support\Facades\Cache;
  55. use Illuminate\Support\Facades\Auth;
  56. use Illuminate\Support\Facades\Cookie;
  57. use Illuminate\Support\Facades\DB;
  58. use Illuminate\Support\Facades\Http;
  59. use PhpOffice\PhpSpreadsheet\Calculation\Web\Service;
  60. class TestController extends Controller
  61. {
  62. use AsyncResponse,ErrorPush;
  63. const ASNREFERENCE_2 = 'ASNREFERENCE2';
  64. public function __construct()
  65. {
  66. $this->data["active_test"] = "active";
  67. }
  68. public function method(Request $request, $method)
  69. {
  70. return call_user_func([$this, $method], $request);
  71. }
  72. public function test1(){
  73. ini_set('max_execution_time',-1);
  74. $date = date("Y-m-d H:i:s");
  75. ErrorTemp::query()->truncate();
  76. OwnerFeeStorage::query()->truncate();
  77. OwnerFeeExpress::query()->truncate();
  78. OwnerFeeLogistic::query()->truncate();
  79. OwnerFeeOperation::query()->truncate();
  80. OwnerFeeOperationDetail::query()->truncate();
  81. foreach (Order::query()->where("wms_edittime",">=","2021-08-16 00:00:00")
  82. ->where("wms_status","订单完成")
  83. ->where("wms_edittime","<",$date)->get() as $order){
  84. $fee = OwnerFeeDetail::query()->where("outer_table_name","orders")->where("outer_id",$order->id)->first();
  85. if ($fee){
  86. OwnerFeeDetailLogistic::query()->where("owner_fee_detail_id",$fee->id)->delete();
  87. $fee->delete();
  88. }
  89. $a = new Collection([$order]);
  90. $this->dispatch(new OrderCreateInstantBill($a));
  91. }
  92. foreach (Store::query()->where("updated_at",">=","2021-08-16 00:00:00")
  93. ->where("status","已入库")
  94. ->where("updated_at","<",$date)->get() as $store){
  95. OwnerFeeDetail::query()->where("outer_table_name","stores")->where("outer_id",$store->id)->delete();
  96. $a = new Collection([$store]);
  97. $this->dispatch(new StoreCreateInstantBill($a));
  98. }
  99. }
  100. public function test()
  101. {
  102. ini_set('max_execution_time',-1);
  103. $day = (string)\request("day");
  104. $d = (int)$day+1;
  105. $d = $d<10 ? '0'.(string)$d : (string)$d;
  106. foreach (Order::query()->where("wms_edittime",">=","2021-08-{$day} 00:00:00")
  107. ->where("wms_status","订单完成")
  108. ->where("wms_edittime","<","2021-08-{$d} 00:00:00")->get() as $order){
  109. $fee = OwnerFeeDetail::query()->where("outer_table_name","orders")->where("outer_id",$order->id)->first();
  110. if ($fee){
  111. OwnerFeeDetailLogistic::query()->where("owner_fee_detail_id",$fee->id)->delete();
  112. $fee->delete();
  113. }
  114. $a = new Collection([$order]);
  115. $this->dispatch(new OrderCreateInstantBill($a));
  116. }
  117. foreach (Store::query()->where("updated_at",">=","2021-08-{$day} 00:00:00")
  118. ->where("status","已入库")
  119. ->where("updated_at","<","2021-08-{$d} 00:00:00")->get() as $store){
  120. OwnerFeeDetail::query()->where("outer_table_name","stores")->where("outer_id",$store->id)->delete();
  121. $a = new Collection([$store]);
  122. $this->dispatch(new StoreCreateInstantBill($a));
  123. }
  124. }
  125. public function test3()
  126. {
  127. $sql = <<<SQL
  128. select * from DOC_ORDER_HEADER
  129. where ADDTIME>=to_date('2021-08-15 00:00:00','yyyy-mm-dd hh24:mi:ss') AND
  130. ADDTIME<=to_date('2021-08-20 16:00:00','yyyy-mm-dd hh24:mi:ss') and SOSTATUS >= '40'
  131. and CARRIERID in (
  132. 'BSZFC','BSZX','BSZFCDF','BSZXDF','DBWL','DBWLDF'
  133. )
  134. SQL;
  135. $s = new \App\Http\Controllers\api\thirdPart\flux\WaybillController();
  136. $arr = DB::connection("oracle")->select(DB::raw($sql));
  137. foreach ($arr as $ar){
  138. if (Waybill::query()->where("wms_bill_number",'like','%'.$ar->orderno.'%')
  139. ->where("created_at",">=",'2021-08-10 00:00:00')->first())continue;
  140. $sql = <<<SQL
  141. select * from DOC_ORDER_DETAILS left join bas_sku on DOC_ORDER_DETAILS.CUSTOMERID = BAS_SKU.CUSTOMERID and DOC_ORDER_DETAILS.sku = BAS_SKU.SKU
  142. where ORDERNO = ?
  143. SQL;
  144. $details = [];
  145. foreach (DB::connection("oracle")->select(DB::raw($sql),[$ar->orderno]) as $item){
  146. $details[] = [
  147. "SKU_Descr_c" => $item->descr_c,
  148. "SKU" => $item->sku,
  149. "Alternate_sku1" => $item->alternate_sku1,
  150. "Qtyordered_each" => $item->qtyordered_each,
  151. "Cubic" => $item->cubic,
  152. "GrossWeight" => $item->grossweight,
  153. "NetWeight" => $item->netweight,
  154. "ReservedField01" => $ar->soreference1,
  155. "ReservedField02" => $ar->soreference2,
  156. "ReservedField03" => $ar->soreference3,
  157. "ReservedField04" => $ar->soreference4,
  158. "ReservedField05" => $ar->soreference5,
  159. ];
  160. }
  161. $r = new Request();
  162. $res = [
  163. "OrderNo" => $ar->orderno,
  164. "CustomerID" => $ar->customerid,
  165. "CarrierID" => $ar->carrierid,
  166. "ConsigneeName" => $ar->consigneename,
  167. "C_Tel1" => $ar->c_tel1,
  168. "C_Address1" => $ar->c_address1,
  169. "C_Province" => $ar->c_province,
  170. "C_City" => $ar->c_city,
  171. "C_District" => $ar->c_district,
  172. "ReservedField01" => $ar->soreference1,
  173. "ReservedField02" => $ar->soreference2,
  174. "ReservedField03" => $ar->soreference3,
  175. "ReservedField04" => $ar->soreference4,
  176. "ReservedField05" => $ar->soreference5,
  177. "order_list" => $details,
  178. ];
  179. $a = [$res];
  180. $r->offsetSet("request",$a);
  181. $s->new_($r);
  182. }
  183. }
  184. public function test4()
  185. {
  186. return response()->redirectTo("transport/waybill/android/waybillDispatch");
  187. }
  188. public function OwnerStoreFeeReportService_recordReport()
  189. {
  190. /** @var OwnerStoreFeeReportService $service */
  191. $service = app('OwnerStoreFeeReportService');
  192. $service->recordReport('2021-08-01');
  193. }
  194. public function OwnerStoreOutFeeReportService_recordReport()
  195. {
  196. /** @var OwnerStoreOutFeeReportService $service */
  197. $service = app('OwnerStoreOutFeeReportService');
  198. $service->recordReport('2021-08-01');
  199. }
  200. public function OwnerFeeTotalService_record()
  201. {
  202. /** @var OwnerFeeTotalService $service */
  203. $service = app('OwnerFeeTotalService');
  204. $service->record('2021-08-01');
  205. }
  206. //快递
  207. public function OwnerLogisticFeeReportService_record()
  208. {
  209. ini_set('max_execution_time',-1);
  210. /** @var OwnerLogisticFeeReportService $service */
  211. $service = app('OwnerLogisticFeeReportService');
  212. $service->recordReport('2021-08-01');
  213. }
  214. public function order_packages_sync_routes_flag_init()
  215. {
  216. OrderPackage::query()->whereNotNull('transfer_status')->update(['sync_routes_flag'=>true]);
  217. }
  218. public function SettlementBillReportTask()
  219. {
  220. SettlementBillReportTask::dispatchNow('2021-08-01');
  221. }
  222. }