LoadController.php
4.2 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/6/7
* Time: 16:48
*/
namespace app\portal\controller;
use app\portal\model\IndentModel;
use app\portal\model\LogisticsModel;
use cmf\controller\HomeBaseController;
use think\Db;
class LoadController extends HomeBaseController
{
public function index(){
$indentModel = new IndentModel();
$where['state'] = ['eq',2];
$data = $indentModel->selectData($where);
if(!empty($data)){
foreach($data as $key => $vo){
$birdController = new BirdController();
$result = $birdController->getOrder($vo['id']);
}
}
}
public function test(){
dump(cache('a1'));
dump(cache('yuyue1'));
dump(cache('dingyue1'));
dump(cache('b'));
dump(cache('result'));
dump(cache('result_data'));
}
public function notify(){
$RequestType = empty($_POST['RequestType']) ? 0: $_POST['RequestType'];
$RequestData = empty($_POST['RequestData']) ? 0: $_POST['RequestData'];
if(empty($RequestType)){
$this->error('error');
}
if($RequestType != 101){
$this->error('error');
}
$result = json_decode($RequestData,true);
cache('result',$result);
cache('result_data',$result['Data']);
$indentModel = new IndentModel();
foreach($result['Data'] as $key => $vo){
$indent = $indentModel->findData(['logistic_code'=>$vo['LogisticCode']]);
if(!empty($indent)){
if($vo['State'] ==1 || $vo['State'] == 2){
if($indent['state'] == 2){
$indentModel->updateData(['id'=>$indent['id']],['state'=>5]);
}
}
if($vo['State'] == 3){
$indentModel->updateData(['id'=>$indent['id']],['state'=>3]);
}
}
}
$bird = config('bird');
$date = date("Y-m-d H:i:s",time());
$data = '{ "EBusinessID": "'.$bird['EBusinessID'].'", "UpdateTime": "'.$date.'", "Success": true, "Reason": ""}';
cache('data',$data);
return $data;
}
/**
*服务器定时任务 删除超过24小时的订单
*/
public function indent_overtime(){
//查询所有订单
$indent = Db::name('indent') -> where("state",4) -> select();
foreach ($indent as $key => $val){
$now_time = time();
$time = $now_time-$val['create_time'];
if($time>86400){
Db::name('indent') -> delete($val['id']);
}
}
}
/**
* 服务器定时任务 三个月未交易改变老师状态
*/
public function binding(){
//查询所有业务员
$salesman = Db::name('my_user') -> where('status',2) -> select() -> toArray();
//查询这个业务员下的所有老师
foreach ($salesman as $key => $val){
$teacher = Db::name('my_user') -> where('pid',$val['id']) -> select() -> toArray();
//查询老师下的学生
foreach ($teacher as $key2 => $val2){
$student = Db::name('my_user') -> where('pid',$val2['id']) -> select() -> toArray();
//查询学生下的订单
foreach ($student as $key3 => $val3){
$student_indent[] = Db::name('indent') -> where('uid='.$val3['uid']) -> where("state = 2 or state = 3 or state = 5") -> select() -> toArray();
}
//查询老师的订单
$teacher_indent = Db::name('indent') -> where("uid=".$val2['uid']) -> where("state = 2 or state = 3 or state = 5 ") -> select() -> toArray();
//判断订单状态
if(empty($teacher_indent) && empty($student_indent)){
$time = time()-$val2['bind_time'];
//超过三个月修改订单状态
if($time >= 7776000){
Db::name('my_user') -> where('id',$val2['id']) -> update(['bind_status'=>2]);
}
}
$student_indent = [];
}
}
}
}