TestController.php 8.5 KB

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