TestController.php 4.4 KB

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