TestController.php 5.4 KB

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