NoReturnOrder.php
2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
namespace App\Console\Commands;
use App\Common\Http;
use App\Modules\Models\Production\Production;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
class NoReturnOrder extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'NoReturnOrder {--day=}';
/**
* The console command description.
*
* @var string
*/
protected $description = '未归还的订单费用';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//
$datas = Production::select('machine.mac_no', 'production.power_no', 'production.rent_hatch_no','production.is_return', 'power.machine_id', 'rent.deposit', 'rent.one_day_price', 'rent.pay_time')
->leftjoin('power', 'production.power_no', '=', 'power.power_no')
->leftjoin('rent', 'rent.id', '=', 'production.rent_id')
->leftjoin('machine', 'machine.id', '=', 'production.rent_machine_id')
->where('production.is_return', '=', 0)
->where('rent.is_over', '=', 0)
->whereNull('power.machine_id')
->get()
->toArray();
foreach ($datas as $key => $data){
$days = ceil($data['deposit'] / $data['one_day_price']);
if(time() > (strtotime($data['pay_time']) + $days * 60 * 60 * 24)){
//todo 请求归还接口
$datas = "machine=".$data["mac_no"].
"&hatch_no=".$data["rent_hatch_no"].
"&power_no=".$data["power_no"].
"&has_power=80".
"&backTime=".date('Y-m-d H:i:s').
"&isTrue=0";
$url = "http://api.ssw-htzn.com/api/v1/customers/manualReturn";
json_decode( Http::post($datas, $url ), true) ;
Log::info('未归还设备请求手动归还: '. $data['power_no']);
}
}
Log::info('未归还设备请求手动归还---------------------end---------------------------');
}
}