TestController.php 4.2 KB

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