TestController.php 8.6 KB

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