TestController.php 6.5 KB

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