TestController.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Authority;
  4. use App\Batch;
  5. use App\Carrier;
  6. use App\Events\CancelOrder;
  7. use App\Events\WeighedEvent;
  8. use App\Events\WmsReceiveNewEvent;
  9. use App\Jobs\MeasuringMachineQueue;
  10. use App\Jobs\ProcessReceiveCombined;
  11. use App\Logistic;
  12. use App\MeasuringMachine;
  13. use App\Order;
  14. use App\Package;
  15. use App\ProcessDaily;
  16. use App\Rejected;
  17. use App\RejectedBill;
  18. use App\RejectedBillItem;
  19. use App\Role;
  20. use App\User;
  21. use App\UserDutyCheck;
  22. use App\WMSReflectReceive;
  23. use Carbon\Carbon;
  24. use Illuminate\Database\Eloquent\Collection;
  25. use Illuminate\Http\Request;
  26. use Illuminate\Support\Facades\Gate;
  27. use Zttp\Zttp;
  28. class TestController extends Controller
  29. {
  30. private $data=[];
  31. public function __construct()
  32. {
  33. $this->data["active_test"]="active";
  34. }
  35. public function method(Request $request,$method)
  36. {
  37. return call_user_func([$this, $method],$request);
  38. }
  39. function t1(Request $request){ //x
  40. $url=url(config('api.flux.receive.new'));
  41. dd($url,config('api.flux.receive'),config('api.flux'));
  42. }
  43. function tj(Request $request){
  44. $bills=RejectedBill::where('is_loaded',2)->where('created_at','<',Carbon::now()->subHours(10)->toDateTimeString());
  45. $bills->each(function ($bill){
  46. $receives=WMSReflectReceive::where('ASNREFERENCE3',$bill['logistic_number_return'])->where('is_uploaded',0)->get();
  47. if($receives->isNotEmpty()){
  48. event(new WmsReceiveNewEvent($bill['logistic_number_return'],$receives->first()));
  49. (new Controller())->log(__METHOD__,'replenished_'.__FUNCTION__,$bill['logistic_number_return']);
  50. }
  51. });
  52. }
  53. function injectJS(Request $request){
  54. $items=RejectedBillItem::whereHas('rejectedBill',function($query){
  55. return $query->where('id_owner',2);
  56. })->where('created_at','>','2019-12-23 18:11:00')->where('created_at','<','2019-12-24 11:25:00')->get();
  57. (new RejectedBillItemController())->collectionsToPackConfirm($items);
  58. }
  59. public function tj2(Request $request)
  60. {
  61. $rejected = Rejected::find(10);
  62. $rejectedJianshang=new \App\Http\Controllers\api\jianshang\RejectedController();
  63. dd( $rejectedJianshang->sendRejected($rejected));
  64. }
  65. public function excelIt()
  66. {
  67. $excel=new ExcelController();
  68. return $excel->makeExcel();
  69. }
  70. public function featureIt()
  71. {
  72. LogisticNumberFeatureController::loadRecentRejectedsToFeatures(5,2500);
  73. }
  74. public function newSku()
  75. {
  76. $url='http://bswcs/api/sorting/flux/newSku';
  77. $response = Zttp::post($url, [
  78. 'request'=>[
  79. [
  80. "SKU"=> "1234567890",
  81. "NAME"=> "瑞士莲**巧克力",
  82. "Alternate_SKU1"=> "1122334455",
  83. "GrossWeight"=> "1.2",
  84. "Cube"=> "0.75",
  85. "SKULength"=> "0.25",
  86. "SKUWidth"=> "0.15",
  87. "SKUHigh"=> "0.05"
  88. ],
  89. [
  90. "SKU"=> "1234567892",
  91. "NAME"=> "跳跳饼",
  92. "Alternate_SKU1"=> "",
  93. "GrossWeight"=> "1.3",
  94. "Cube"=> "0.75",
  95. "SKULength"=> "0.25",
  96. "SKUWidth"=> "0.15",
  97. "SKUHigh"=> "0.25"
  98. ],
  99. ]
  100. ]);
  101. return $response->json();
  102. }
  103. public function changePackage(){
  104. $packages=Package::where('delivery_number','<>',null)->where('logistic_id',null)->get();
  105. dd($packages);
  106. $packages=Package::whereRaw('delivery_number IS NOT NULL AND logistic_id IS NULL')->get();
  107. $logistics=Logistic::get();
  108. $packages->each(function ($package)use($logistics){
  109. $logistics->each(function ($logistic)use($package){
  110. if ($package->WMSReflectPackage->CarrierID==$logistic->code){
  111. $package->logistic_id=$logistic->id;
  112. return;
  113. }
  114. });
  115. });
  116. return "OK";
  117. }
  118. public function tNull(){
  119. }
  120. public function deletePackageAuthority()
  121. {
  122. $authorities=Authority::where('name','like','%包裹信息%')->get();
  123. $authorities->each(function ($authority){
  124. $authority->delete();
  125. });
  126. }
  127. public function test1(){
  128. /* $a=Package::orderBy('id')->first();
  129. $date=date("Y-m-d",strtotime("+1 day",strtotime($a->created_at->format('Y-m-d'))));
  130. dd($a->created_at->format('Y-m-d'));
  131. $b=Package::orderBy('id','desc')->first();
  132. $sf=$a->created_at->format('Y-m-d');dd((int)$sf);
  133. $result=$sf->lte("11:00");
  134. $c=Carbon::parse("9:10:05");
  135. $d=Carbon::parse("18:01:20");
  136. $x=($d->diffInSeconds($c))/3600;
  137. dd($c,$d,round($x,2)-1);*/
  138. $userDutyCheckStart=UserDutyCheck::select('id','checked_at')->where('user_id',1)
  139. ->where('checked_at','like','2020-03-13%')->where('type','登入')->orderBy('id')->first();
  140. $today=Carbon::now()->format('Y-m-d');
  141. $date=date("Y-m-d",strtotime('+'.strval(5)." day",strtotime($today)));
  142. $startDate=Carbon::parse("2020-03-31");
  143. $diffDay=$startDate->diffInDays($today,true);
  144. dd($diffDay);
  145. $package=Package::orderBy('updated_at','DESC')->get();
  146. }
  147. }