TestController.php 5.7 KB

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