Commit 8396821d authored by clone's avatar clone

1

parent c1fb6271
<?php
namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\api_broker\service\PushMessageService;
use app\api_broker\service\ReportService;
use app\api_broker\service\VipService;
use app\index\service\UserService;
use app\model\AAgents;
use app\model\FollowUpLogModel;
use app\model\GHousesToAgents;
use app\model\OReportModel;
use think\Exception;
/**
* Created by PhpStorm.
* User : zw
* Date : 2019/7/18
* Time : 14:24
* Intro: 报销申请
*/
class StoreFee extends Basic
{
private $service_;
private $fulModel;
private $userService;
public function __construct($request = null)
{
parent::__construct($request);
$this->service_ = new ReportService();
$this->fulModel = new FollowUpLogModel();
$this->userService = new UserService();
}
/**
* 报备
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function report()
{
$params = $this->params;
if (!isset($params['report_agent_id']) || !isset($params['report_agent_phone']) || !isset($params['report_store_id']) || !isset($params['user_id']) ||
!isset($params['house_ids']) || !isset($params['vehicle'])) {
return $this->response("101", "请求参数错误");
}
/* $params = array(
"report_agent_id" => 1,//报备经纪人id
"report_agent_phone" => '13817616471',//报备经纪人id
"report_store_id" => 1,//门店id
"user_id" => 1,//用户id
"house_ids" => "1,2,3",//楼盘id
"vehicle" => 10,//交通工具
"intro" => "123123123",//备注
"predict_see_time" => time(),//预计到看时间
);*/
$agent_id = $params["report_agent_id"];
$agent_phone = $params["report_agent_phone"];
$store_id = $params["report_store_id"];
$user_id = $params["user_id"];
$house_ids = $params["house_ids"];
$vehicle = $params["vehicle"];
$intro = $params["intro"];
$predict_see_time = $params["predict_see_time"];
//todo 验证用户id是否正常
$userArr = $this->service_->verifyUser($user_id);
if (!$userArr) {
return $this->response("101", "不存在此用户");
}
$is_ok = $this->service_->verifyReport($agent_id, $agent_phone, $this->agentName, $store_id, $user_id, $userArr["user_phone"],
$userArr["user_name"], $house_ids, $vehicle, $intro, $predict_see_time);
if ($is_ok > 0) {
$this->userService->setUserSites($user_id, $this->siteId);//设置用户站点 朱伟 2018-10-22
/*记录推送*/
$push = new PushMessageService();
$house_ids_arr = explode(',', $house_ids);
if (is_array($house_ids_arr)) {
foreach ($house_ids_arr as $k => $v) {
$push->pushReportMessage($v, $agent_id, 1, $this->agentId, $user_id); //推送报备信息
}
}
/*记录推送*/
return $this->response("200", "request success", []);
} else {
return $this->response("101", "save exception");
}
}
/**
* 获取报备列表
* @return \think\Response
* @throws \think\db\exception\BindParamException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function reportList()
{
$params = $this->params;
/* $params = array(
"agent_id" =>6562,
"type" => 1,//1表示全部 2表示进场 3 表示收款 4成交报告
"is_all"=>0,//0搜索我自己的,1全部
"page_no"=>1,
"page_size"=>15
);*/
$checkResult = $this->validate($params, "PerformanceValidate.verifyCollectionList");
if (true !== $checkResult) {
return $this->response("101", $checkResult);
}
$pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
$pageSize = empty($params['page_size']) ? 15 : $params['page_size'];
$field = "a.id,a.user_id,a.user_phone,a.user_name,a.predict_see_time,a.create_time,b.id as order_id,b.order_no,
b.house_id,b.house_title";
$params["report_agent_id"] = $params["agent_id"];
$result = [];
$agentModel = new AAgents();
$agents_data = $agentModel->getAgentInfo('id,level', $this->agentId);
if (isset($params["is_all"]) && $params["is_all"] == 1) {
$check_type = 1;
if ($agents_data["level"] < 30) {
$check_type = $this->service_->getCheckType($this->agentId);
if ($check_type == 0) {
return $this->response(101, "暂无权限");
}
}
$result = $this->service_->orderListAll($field, $params, $pageNo, $pageSize, $check_type);
} else {
$result = $this->service_->orderList($field, $params, $pageNo, $pageSize);
}
if (count($result) > 0) {
return $this->response("200", "request success", $result);
} else {
return $this->response("200", "request null");
}
}
}
\ No newline at end of file
<?php
namespace app\api_broker\validate;
use think\Validate;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/8/23
* Time : 14:51
* Intro:
*/
class BargainValidate extends Validate
{
protected $rule = [
'submit_agent_id' => 'require|number',
'status' => 'require|number|in:0,1,2,3,4,5',
'is_my_correlation' => 'require|number|in:0,1',
];
protected $message = [
'submit_agent_id.require' => '经纪人为必填字段',
'submit_agent_id.number' => '经纪人id只能为数字',
'status.require' => '状态参数不能为空',
'status.number' => '状态参数只能为数字',
'status.in' => '状态错误',
'is_my_correlation.require' => '与我相关不能为空',
'is_my_correlation.number' => '与我相关只能是数字',
'is_my_correlation.in' => '与我相关错误',
];
protected $scene = [
'bargainList' => [ 'submit_agent_id', 'status', 'is_my_correlation' ],
];
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment