TestController.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Authority;
  4. use App\Batch;
  5. use App\City;
  6. use App\Events\CancelOrder;
  7. use App\Events\WmsReceiveNewEvent;
  8. use App\Http\Controllers\Api\thirdPart\flux\WaybillController;
  9. use App\Logistic;
  10. use App\Order;
  11. use App\Package;
  12. use App\ProcessStatistic;
  13. use App\Rejected;
  14. use App\RejectedBill;
  15. use App\RejectedBillItem;
  16. use App\Unit;
  17. use App\UploadFile;
  18. use App\User;
  19. use App\UserToken;
  20. use App\Waybill;
  21. use App\OraccleBasCustomer;
  22. use App\WMSReflectReceive;
  23. use Carbon\Carbon;
  24. use Endroid\QrCode\Response\QrCodeResponse;
  25. use Illuminate\Http\Request;
  26. use Illuminate\Support\Facades\DB;
  27. use function PHPSTORM_META\map;
  28. use Zttp\Zttp;
  29. class TestController extends Controller
  30. {
  31. private $data = [];
  32. public function __construct()
  33. {
  34. $this->data["active_test"] = "active";
  35. }
  36. public function method(Request $request, $method)
  37. {
  38. return call_user_func([$this, $method], $request);
  39. }
  40. function packageFromLog(Request $request)
  41. { //x $packagesBatch=Package::where('batch_number',$batch_number)->first();
  42. ini_set('max_execution_time', 2500);
  43. ini_set('memory_limit', '1526M');
  44. $uploaded = 0;
  45. $count = DB::table('logs')->where('operation', 'like', "%PackageController::new_%")
  46. ->where('created_at', '>', "2020-06-08 15:46:00")
  47. ->where('created_at', '<', "2020-06-08 15:47:00")
  48. ->where('type', "request_new_")
  49. ->count();
  50. $requests = DB::table('logs')->where('operation', 'like', "%PackageController::new_%")
  51. ->where('created_at', '>', "2020-06-08 15:46:00")
  52. ->where('created_at', '<', "2020-06-08 15:47:00")
  53. ->where('type', "request_new_")
  54. ->get();
  55. $requests->each(function ($request) use (&$uploaded) {
  56. $requestJson = json_decode($request->description, true);
  57. $response = Zttp::withHeaders(['content-type' => 'application/json',
  58. ])->post('https://was.baoshi56.com/api/thirdPart/flux/package/new',
  59. $requestJson
  60. );
  61. if ($response->json() && $response->json()['response'] && $response->json()['response']['flag'] == 'Y')
  62. $uploaded += 1;
  63. });
  64. dd($uploaded . '/' . $count);
  65. }
  66. function t2(Request $request)
  67. { //x $packagesBatch=Package::where('batch_number',$batch_number)->first();
  68. $uploaded = 0;
  69. $count = DB::table('logs')->where('operation', 'like', "%PackageController::new_%")
  70. ->where('created_at', '>', "2020-06-03 14:02:00")
  71. ->where('created_at', '<', "2020-06-03 15:05:00")
  72. ->where('type', "request_new_")
  73. ->where('description', 'like', "%W200603000117%")
  74. ->count();
  75. $requests = DB::table('logs')->where('operation', 'like', "%PackageController::new_%")
  76. ->where('created_at', '>', "2020-06-03 14:02:00")
  77. ->where('created_at', '<', "2020-06-03 15:05:00")
  78. ->where('description', 'like', "%W200603000117%")
  79. ->where('type', "request_new_")
  80. ->get();
  81. $requests->each(function ($request) use (&$uploaded) {
  82. $requestJson = json_decode($request->description, true);
  83. $response = Zttp::withHeaders(['content-type' => 'application/json',
  84. ])->post('https://was.baoshi56.com/api/thirdPart/flux/package/new',
  85. $requestJson
  86. );
  87. if ($response->json() && $response->json()['response'] && $response->json()['response']['flag'] == 'Y')
  88. $uploaded += 1;
  89. });
  90. dd($uploaded . '/' . $count);
  91. }
  92. function tj(Request $request)
  93. {
  94. $waybills = Waybill::where('created_at', 'like', '%2020-05-25%')->orWhere('created_at', 'like', '%2020-05-30%')->get();
  95. $controller = (new WaybillController());
  96. $waybills->each(function ($waybill) use ($controller) {
  97. $controller->accomplishToWMS($waybill);
  98. });
  99. dd($waybills->count());
  100. }
  101. function injectJS(Request $request)
  102. {
  103. $items = RejectedBillItem::whereHas('rejectedBill', function ($query) {
  104. return $query->where('id_owner', 2);
  105. })->where('created_at', '>', '2019-12-23 18:11:00')->where('created_at', '<', '2019-12-24 11:25:00')->get();
  106. (new RejectedBillItemController())->collectionsToPackConfirm($items);
  107. }
  108. public function tj2(Request $request)
  109. {
  110. $rejected = Rejected::find(10);
  111. $rejectedJianshang = new \App\Http\Controllers\api\jianshang\RejectedController();
  112. dd($rejectedJianshang->sendRejected($rejected));
  113. }
  114. public function excelIt()
  115. {
  116. $excel = new ExcelController();
  117. return $excel->makeExcel();
  118. }
  119. public function featureIt()
  120. {
  121. LogisticNumberFeatureController::loadRecentRejectedsToFeatures(5, 2500);
  122. }
  123. public function newSku()
  124. {
  125. $url = 'http://bswcs/api/sorting/flux/newSku';
  126. $response = Zttp::post($url, [
  127. 'request' => [
  128. [
  129. "SKU" => "1234567890",
  130. "NAME" => "瑞士莲**巧克力",
  131. "Alternate_SKU1" => "1122334455",
  132. "GrossWeight" => "1.2",
  133. "Cube" => "0.75",
  134. "SKULength" => "0.25",
  135. "SKUWidth" => "0.15",
  136. "SKUHigh" => "0.05"
  137. ],
  138. [
  139. "SKU" => "1234567892",
  140. "NAME" => "跳跳饼",
  141. "Alternate_SKU1" => "",
  142. "GrossWeight" => "1.3",
  143. "Cube" => "0.75",
  144. "SKULength" => "0.25",
  145. "SKUWidth" => "0.15",
  146. "SKUHigh" => "0.25"
  147. ],
  148. ]
  149. ]);
  150. return $response->json();
  151. }
  152. public function changePackage()
  153. {
  154. $packages = Package::where('delivery_number', '<>', null)->where('logistic_id', null)->get();
  155. dd($packages);
  156. $packages = Package::whereRaw('delivery_number IS NOT NULL AND logistic_id IS NULL')->get();
  157. $logistics = Logistic::get();
  158. $packages->each(function ($package) use ($logistics) {
  159. $logistics->each(function ($logistic) use ($package) {
  160. if ($package->WMSReflectPackage->CarrierID == $logistic->code) {
  161. $package->logistic_id = $logistic->id;
  162. return;
  163. }
  164. });
  165. });
  166. return "OK";
  167. }
  168. public function tNull()
  169. {
  170. }
  171. public function deletePackageAuthority()
  172. {
  173. $authorities = Authority::where('name', 'like', '%包裹信息%')->get();
  174. $authorities->each(function ($authority) {
  175. $authority->delete();
  176. });
  177. }
  178. /*1*/
  179. function test()
  180. {/**/
  181. }
  182. }