作者 王晓刚
1 个管道 的构建 通过 耗费 0 秒

接收推送消息

... ... @@ -10,6 +10,7 @@ namespace app\portal\controller;
use app\portal\model\IndentModel;
use app\portal\model\LogisticsModel;
use cmf\controller\HomeBaseController;
class LoadController extends HomeBaseController
... ... @@ -32,9 +33,8 @@ class LoadController extends HomeBaseController
dump(cache('data'));
}
public function notify(){
$RequestType = $_POST['RequestType'];
$RequestData = $_POST['RequestData'];
$RequestType = empty($_POST['RequestType']) ? 0: $_POST['RequestType'];
$RequestData = empty($_POST['RequestData']) ? 0: $_POST['RequestData'];
if(empty($RequestType)){
$this->error('error');
}
... ... @@ -42,10 +42,21 @@ class LoadController extends HomeBaseController
$this->error('error');
}
$result = json_decode($RequestData,true);
$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]);
}
}
}
}
cache('result',$result);
$bird = config('bird');
$date = date("Y-m-d H:i:s",time());
$data = '{ "EBusinessID": "test1472267", "UpdateTime": "'.$date.'", "Success": true, "Reason": ""}';
$data = '{ "EBusinessID": "'.$bird['EBusinessID'].'", "UpdateTime": "'.$date.'", "Success": true, "Reason": ""}';
cache('data',$data);
return $data;
}
... ...
... ... @@ -40,6 +40,17 @@ class IndentModel extends Model
}
/**
* 更新
* @param $where
* @param $data
* @return IndentModel
*/
public function updateData($where,$data){
$result = $this->where($where)->update($data);
return $result;
}
/**
* 删除订单
* @param $where
* @return int
... ...
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/6/8
* Time: 14:34
*/
namespace app\portal\model;
use think\Model;
class LogisticsModel extends Model
{
/**
* 获取单条数据
* @param $where
* @return array|false|\PDOStatement|string|Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function findData($where){
$data = $this->where($where)->find();
return $data;
}
/**
* 更新
* @param $where
* @param $data
* @return LogisticsModel
*/
public function updateData($where,$data){
$result = $this->where($where)->update($data);
return $result;
}
}
\ No newline at end of file
... ...