TestController.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Components\AsyncResponse;
  4. use App\Components\Database;
  5. use App\Components\ErrorPush;
  6. use App\MaterialBox;
  7. use App\MaterialBoxModel;
  8. use App\OrderIssue;
  9. use App\RejectedBill;
  10. use App\Services\RejectedBillSyncOrderService;
  11. use App\Services\RejectedService;
  12. use App\User;
  13. use App\Waybill;
  14. use Illuminate\Database\Capsule\Manager;
  15. use Illuminate\Database\DatabaseManager;
  16. use Illuminate\Foundation\Auth\AuthenticatesUsers;
  17. use Illuminate\Http\Request;
  18. use Illuminate\Support\Facades\DB;
  19. use Illuminate\Support\Facades\Hash;
  20. use Illuminate\Support\Facades\Log;
  21. use Oursdreams\Export\Export;
  22. class TestController extends Controller
  23. {
  24. use AsyncResponse, ErrorPush, Database;
  25. const ASNREFERENCE_2 = 'ASNREFERENCE2';
  26. public function __construct()
  27. {
  28. $this->data["active_test"] = "active";
  29. }
  30. public function method(Request $request, $method)
  31. {
  32. try {
  33. return call_user_func([$this, $method], $request);
  34. }catch (\BadMethodCallException $e){
  35. dd("方法不存在");
  36. }
  37. }
  38. public function test($main, $x)
  39. {
  40. return;
  41. $db = DB::connection("aliyunMysql");
  42. foreach ($db->select(DB::raw("select * from equipments where code like 'W4%' and info is not null and id <= 4972")) as $eq){
  43. $arr = str_split ($eq->code);
  44. if (strlen($main)==2){
  45. $arr1 = str_split ($main);
  46. $arr[4] = $arr1[0];
  47. $arr[5] = $arr1[1];
  48. }else{
  49. $arr[5] = $main;
  50. }
  51. $code = implode("",$arr);
  52. $obj = json_decode($eq->info);
  53. $obj->x +=$x;
  54. $db->insert("insert into equipments(code,parent_id,info,depth,width,created_at,updated_at,warehouse_detail_id)
  55. values(?,null,?,?,?,?,?,1)",[$code,json_encode($obj),$eq->depth,$eq->width,now()->toDateTimeString(),now()->toDateTimeString()]);
  56. $a = $db->selectOne("select * from equipments where parent_id is null and code = ? ",[$code]);
  57. foreach ($db->select("select * from equipments where parent_id = ?",[$eq->id]) as $item){
  58. $arr = str_split ($item->code);
  59. if (strlen($main)==2){
  60. $arr1 = str_split ($main);
  61. $arr[4] = $arr1[0];
  62. $arr[5] = $arr1[1];
  63. }else{
  64. $arr[5] = $main;
  65. }
  66. $code = implode("",$arr);
  67. $db->insert("insert into equipments(code,parent_id,info,depth,width,height,location_tab,created_at,updated_at,warehouse_detail_id)
  68. values(?,?,null,?,?,?,?,?,?,2)",[$code,$a->id,$item->depth,$item->width,$item->height,$item->location_tab,now()->toDateTimeString(),now()->toDateTimeString()]);
  69. }
  70. }
  71. }
  72. public function test2(){
  73. return;
  74. $db = DB::connection("aliyunMysql");
  75. foreach ($db->select("select * from equipments where (code like 'W3%') and info is not null") as $eq){
  76. $obj = json_decode($eq->info);
  77. $obj->x -= 105;
  78. $db->update("UPDATE equipments SET info = ? where id = ?",[json_encode($obj),$eq->id]);
  79. }
  80. }
  81. public function test1(Request $request){
  82. return;
  83. $x = 0;
  84. $a1 = 8 + 30;
  85. $a2 = 80 + 30;
  86. $a3 = 32 + 30;
  87. }
  88. use AuthenticatesUsers;
  89. public function test3($request){
  90. dd(Hash::make("wangyan"));
  91. }
  92. public function get(){
  93. dd($this->get0() ?? $this->get1() ?? $this->get2()) ;
  94. }
  95. public function get0()
  96. {
  97. dump(1);
  98. return null;
  99. }
  100. public function get1()
  101. {
  102. dump(2);
  103. return null;
  104. }
  105. public function get2()
  106. {
  107. dump(3);
  108. return null;
  109. }
  110. public function OrderSync(){
  111. $order_issue = OrderIssue::query()->where('id',67982)->first();
  112. $service = new RejectedBillSyncOrderService();
  113. dd($service->getOrderRejectingStatus($order_issue->order));
  114. }
  115. public function rejectedSync(){
  116. $item = RejectedBill::query()->where('logistic_number_return','YT3186326829104')->first();
  117. $service = new RejectedBillSyncOrderService();
  118. $service->syncRejectingStatus($item);
  119. }
  120. public function orderIssue(){
  121. $orderIssue = OrderIssue::query()->find(1);
  122. $service = new RejectedBillSyncOrderService();
  123. $service->orderIssueSyncRejectedBills($orderIssue);
  124. }
  125. }