TestController.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. dd(OracleDOCOrderHeader::select('addtime')->where('edisendflag','W')->where('edisendtime','>',Carbon::now()->subWeek())
  97. ->orderBy('edisendtime','desc')
  98. ->get()->
  99. map(function($order){
  100. return $order['addtime'];
  101. }));
  102. }
  103. function tj(Request $request)
  104. {
  105. $waybills = Waybill::where('created_at', 'like', '%2020-05-25%')->orWhere('created_at', 'like', '%2020-05-30%')->get();
  106. $controller = (new WaybillController());
  107. $waybills->each(function ($waybill) use ($controller) {
  108. $controller->accomplishToWMS($waybill);
  109. });
  110. dd($waybills->count());
  111. }
  112. function injectJS(Request $request)
  113. {
  114. $items = RejectedBillItem::whereHas('rejectedBill', function ($query) {
  115. return $query->where('id_owner', 2);
  116. })->where('created_at', '>', '2019-12-23 18:11:00')->where('created_at', '<', '2019-12-24 11:25:00')->get();
  117. (new RejectedBillItemController())->collectionsToPackConfirm($items);
  118. }
  119. public function tj2(Request $request)
  120. {
  121. $rejected = Rejected::find(10);
  122. $rejectedJianshang = new \App\Http\Controllers\api\jianshang\RejectedController();
  123. dd($rejectedJianshang->sendRejected($rejected));
  124. }
  125. public function excelIt()
  126. {
  127. $excel = new ExcelController();
  128. return $excel->makeExcel();
  129. }
  130. public function featureIt()
  131. {
  132. LogisticNumberFeatureController::loadRecentRejectedsToFeatures(5, 2500);
  133. }
  134. public function newSku()
  135. {
  136. $url = 'http://bswcs/api/sorting/flux/newSku';
  137. $response = Zttp::post($url, [
  138. 'request' => [
  139. [
  140. "SKU" => "1234567890",
  141. "NAME" => "瑞士莲**巧克力",
  142. "Alternate_SKU1" => "1122334455",
  143. "GrossWeight" => "1.2",
  144. "Cube" => "0.75",
  145. "SKULength" => "0.25",
  146. "SKUWidth" => "0.15",
  147. "SKUHigh" => "0.05"
  148. ],
  149. [
  150. "SKU" => "1234567892",
  151. "NAME" => "跳跳饼",
  152. "Alternate_SKU1" => "",
  153. "GrossWeight" => "1.3",
  154. "Cube" => "0.75",
  155. "SKULength" => "0.25",
  156. "SKUWidth" => "0.15",
  157. "SKUHigh" => "0.25"
  158. ],
  159. ]
  160. ]);
  161. return $response->json();
  162. }
  163. public function changePackage()
  164. {
  165. $packages = Package::where('delivery_number', '<>', null)->where('logistic_id', null)->get();
  166. dd($packages);
  167. $packages = Package::whereRaw('delivery_number IS NOT NULL AND logistic_id IS NULL')->get();
  168. $logistics = Logistic::get();
  169. $packages->each(function ($package) use ($logistics) {
  170. $logistics->each(function ($logistic) use ($package) {
  171. if ($package->WMSReflectPackage->CarrierID == $logistic->code) {
  172. $package->logistic_id = $logistic->id;
  173. return;
  174. }
  175. });
  176. });
  177. return "OK";
  178. }
  179. public function tNull()
  180. {
  181. }
  182. public function deletePackageAuthority()
  183. {
  184. $authorities = Authority::where('name', 'like', '%包裹信息%')->get();
  185. $authorities->each(function ($authority) {
  186. $authority->delete();
  187. });
  188. }
  189. /*1*/
  190. function test()
  191. {/**/
  192. $data=[];
  193. $data['destination_city_id']=1;
  194. $data['destination']="陕西省零鲁区鲱鱼大街404号260";
  195. $waybill=Waybill::find(1);
  196. if ($data['destination_city_id'] && $waybill->destination_city_id != $data['destination_city_id']){
  197. $city=City::find($data['destination_city_id']);
  198. if ($city && (mb_strpos($data['destination'],$city->name)===false || mb_strpos($data['destination'],$city->province_name)===false)){
  199. if (mb_strpos($data['destination'],$city->name)===false && mb_strpos($data['destination'],$city->province_name)===false){
  200. $data['destination']=$city->province_name.$city->name.$data['destination'];
  201. goto sign;
  202. }
  203. if (mb_strpos($data['destination'],$city->province_name)===false){
  204. $data['destination']=$city->province_name.$data['destination'];
  205. }
  206. if (mb_strpos($data['destination'],$city->name)===false){var_dump(3);
  207. $province_name=$city->province_name;
  208. $start_index=mb_strpos($data['destination'],$city->province_name.'省');
  209. if ($start_index===false)$start_index=mb_strpos($data['destination'],$city->province_name);
  210. else $province_name=$province_name.'省';
  211. $strBefore=mb_substr($data['destination'],$start_index,mb_strlen($province_name));
  212. $strAfter=mb_substr($data['destination'],$start_index+mb_strlen($province_name));
  213. $data['destination']=$strBefore.$city->name.$strAfter;
  214. }
  215. }
  216. }
  217. sign:
  218. }
  219. }