TestController.php 8.8 KB

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