LoadController.php 2.0 KB
<?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;

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'] != 4){
                    if($indent['state'] == 2){
                        $indentModel->updateData(['id'=>$indent['id']],['state'=>5]);
                    }
                }
            }
        }
        $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;
    }
}