审查视图

app/portal/controller/LoadController.php 4.2 KB
王晓刚 authored
1 2 3 4 5 6 7 8 9 10 11 12
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/6/7
 * Time: 16:48
 */

namespace app\portal\controller;


use app\portal\model\IndentModel;
王晓刚 authored
13
use app\portal\model\LogisticsModel;
王晓刚 authored
14
use cmf\controller\HomeBaseController;
5  
anyv authored
15
use think\Db;
王晓刚 authored
16 17 18 19 20 21 22 23 24 25 26 27 28 29

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']);
            }
        }
    }
王晓刚 authored
30
    public function test(){
王晓刚 authored
31 32
        dump(cache('a1'));
        dump(cache('yuyue1'));
王晓刚 authored
33 34
        dump(cache('dingyue1'));
        dump(cache('b'));
王晓刚 authored
35 36
        dump(cache('result'));
        dump(cache('result_data'));
王晓刚 authored
37
    }
王晓刚 authored
38
    public function notify(){
王晓刚 authored
39 40
        $RequestType = empty($_POST['RequestType']) ? 0: $_POST['RequestType'];
        $RequestData = empty($_POST['RequestData']) ? 0: $_POST['RequestData'];
王晓刚 authored
41 42 43 44 45
        if(empty($RequestType)){
            $this->error('error');
        }
        if($RequestType != 101){
            $this->error('error');
王晓刚 authored
46
        }
王晓刚 authored
47
        $result = json_decode($RequestData,true);
王晓刚 authored
48
        cache('result',$result);
王晓刚 authored
49
        cache('result_data',$result['Data']);
王晓刚 authored
50
        $indentModel = new IndentModel();
王晓刚 authored
51
        foreach($result['Data'] as $key => $vo){
王晓刚 authored
52 53
            $indent = $indentModel->findData(['logistic_code'=>$vo['LogisticCode']]);
            if(!empty($indent)){
54
                if($vo['State'] ==1 || $vo['State'] == 2){
王晓刚 authored
55 56 57 58
                    if($indent['state'] == 2){
                        $indentModel->updateData(['id'=>$indent['id']],['state'=>5]);
                    }
                }
59 60 61
                if($vo['State'] == 3){
                    $indentModel->updateData(['id'=>$indent['id']],['state'=>3]);
                }
王晓刚 authored
62 63
            }
        }
王晓刚 authored
64 65
        $bird = config('bird');
        $date = date("Y-m-d H:i:s",time());
王晓刚 authored
66
        $data = '{ "EBusinessID": "'.$bird['EBusinessID'].'", "UpdateTime": "'.$date.'", "Success": true, "Reason": ""}';
王晓刚 authored
67
        cache('data',$data);
王晓刚 authored
68
        return $data;
王晓刚 authored
69
    }
anyv authored
70 71 72 73 74

    /**
     *服务器定时任务 删除超过24小时的订单
     */
    public function indent_overtime(){
5  
anyv authored
75
anyv authored
76 77 78 79 80 81 82 83 84 85 86 87
        //查询所有订单
        $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']);
            }
        }

    }
anyv authored
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
    /**
     * 服务器定时任务 三个月未交易改变老师状态
     */
    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 = [];
            }
        }

    }
anyv authored
121 122 123 124 125 126





王晓刚 authored
127
}