Commit 634fb25d authored by zw's avatar zw

订单搜索

parent bebc797d
...@@ -74,12 +74,12 @@ class OrderLog extends Basic ...@@ -74,12 +74,12 @@ class OrderLog extends Basic
{ {
$params = $this->params; $params = $this->params;
if (!isset($params["agent_id"]) || !isset($params["report_id"]) || !isset($params["order_id"]) || !isset($params["order_no"]) /* if (!isset($params["agent_id"]) || !isset($params["report_id"]) || !isset($params["order_id"]) || !isset($params["order_no"])
|| !isset($params["collecting_bill"]) || !isset($params["collecting_bill"][0]["type"]) || !isset($params["house_number"]) || !isset($params["collecting_bill"]) || !isset($params["collecting_bill"][0]["type"]) || !isset($params["house_number"])
|| !isset($params["industry_type"])) { || !isset($params["industry_type"])) {
return $this->response("101", "请求参数错误"); return $this->response("101", "请求参数错误");
} }*/
/* $params = array( $params = array(
"agent_id" => 1,//收款经纪人id "agent_id" => 1,//收款经纪人id
"report_id" => 111,//报备id "report_id" => 111,//报备id
"order_id" => 2, //关联order表id "order_id" => 2, //关联order表id
...@@ -94,7 +94,7 @@ class OrderLog extends Basic ...@@ -94,7 +94,7 @@ class OrderLog extends Basic
"industry_type" => "asdasdasd", "industry_type" => "asdasdasd",
"remark" => "没什么备注", "remark" => "没什么备注",
"transfer_img" => "12312312312" "transfer_img" => "12312312312"
);*/ );
$remark = isset($params["remark"]) ? $params["remark"] : ""; $remark = isset($params["remark"]) ? $params["remark"] : "";
$transfer_img = isset($params["transfer_img"]) ? $params["transfer_img"] : ""; $transfer_img = isset($params["transfer_img"]) ? $params["transfer_img"] : "";
......
<?php
namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\api_broker\service\StatementService;
use think\Exception;
use think\Request;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/3/8
* Time : 上午11:22
* Intro:
*/
class Statement extends Basic
{
private $service_;
public function __construct(Request $request = null)
{
parent::__construct($request);
$this->service_ = new StatementService();
}
public function dayStatement()
{
$params = $this->params;
$params = array(
"agent_id" => 1,
//"type" => 1, // 1.日报 2.周报
"time_start" => date("Y-m-d", time()),
"time_end" => date("Y-m-d", time()) . " 23:59:59",
);
if (!isset($params["agent_id"]) || !isset($params["type"])) {
return $this->response("101", "请求参数错误");
}
try {
$result = $this->service_->selectStatementByAgentId($params["agent_id"], $params["time_start"], $params["time_end"]);
if (count($result) > 0) {
return $this->response("200", "request success", $result);
} else {
return $this->response("200", "request is null");
}
} catch (Exception $exception) {
return $this->response("101", "request is error,msg:" . $exception);
}
}
}
\ No newline at end of file
...@@ -63,7 +63,7 @@ class OrderLogService ...@@ -63,7 +63,7 @@ class OrderLogService
if (!empty($bill_arr)) { if (!empty($bill_arr)) {
return $this->payLogModel->addPayLog($bill_arr); return $this->payLogModel->addPayLog($bill_arr);
} }
return 0; return $father_id;
} }
private function collectingBillBin($father_id,$collecting_arr, $agent_id, $report_id, $order_id, $order_no, $house_number, private function collectingBillBin($father_id,$collecting_arr, $agent_id, $report_id, $order_id, $order_no, $house_number,
......
<?php
namespace app\api_broker\service;
use app\model\AAgents;
use app\model\FollowUpLogModel;
use app\model\GHouses;
use app\model\Users;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/3/8
* Time : 上午11:33
* Intro:
*/
class StatementService {
private $agentModel;
private $houseModel;
private $userModel;
private $followUpModel;
function __construct()
{
$this->agentModel = new AAgents();
$this->houseModel = new GHouses();
$this->userModel = new Users();
$this->followUpModel = new FollowUpLogModel();
}
/**
* @param $agent_id
* @param $time_start
* @param $time_end
* @return array|null
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function selectStatementByAgentId($agent_id,$time_start,$time_end){
$field = "id,store_id,district_id,level,name,phone,sex,status";
$agent_result = $this->agentModel->getAgentById($field,$agent_id);
if(count($agent_result) <= 0){
return null;
}
$user_type = 0; //经纪人权限,0经纪人 1店长 2总监
if($agent_result[0]["level"] == 20){
$user_type = 1;
}elseif ($agent_result[0]["level"] == 30 || $agent_result[0]["level"] == 40 ){
$user_type = 2;
}
$store_id = $agent_result[0]["store_id"];
$district_id = $agent_result[0]["district_id"];
$conditions["agent_id"] = $agent_id;
$conditions['create_time'] = array( 'between', array( $time_start, $time_end ) );
return $this->selectStatement($conditions,$user_type,$store_id,$district_id);
}
private function selectStatement($conditions,$user_type,$store_id,$district_id){
$result = $params = [];
switch ($user_type){
case 0:
//todo
break;
case 1:
//todo 统计门店下的所有经纪人
$params["store_id"] = $store_id;
$params["status"] = 0; //只查询正常状态的经纪人
break;
case 2:
$params["district_id"] = $district_id;
$params["status"] = 0; //只查询正常状态的经纪人
break;
}
if(!empty($params)){
$agentsArr = $this->agentModel->getAgentsByStoreId($params);
if(count($agentsArr) > 0){
$agentIds = "";
foreach ($agentsArr as $key => $value){
$agentIds .= $value["id"] . ",";
}
$agentIds = rtrim($agentIds, ",");
$conditions["agent_id"] = array("in",$agentIds);
}
}
$result["house_num"] = $this->houseModel->getAddHouseNumByAgentId($conditions);
$result["user_num"] = $this->userModel->getAddUserNumByAgentId($conditions);
$result["follow_up_num"] = $this->followUpModel->getAddFollowUpNumByAgentId($conditions);
return $result;
}
}
\ No newline at end of file
...@@ -7,10 +7,13 @@ ...@@ -7,10 +7,13 @@
*/ */
namespace app\model; namespace app\model;
use think\Db; use think\Db;
class AAgents extends BaseModel class AAgents extends BaseModel
{ {
protected $table = 'a_agents';
/** /**
* 返回经纪人和部门信息 * 返回经纪人和部门信息
* *
...@@ -19,33 +22,38 @@ class AAgents extends BaseModel ...@@ -19,33 +22,38 @@ class AAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getInfo($phone) { public function getInfo($phone)
{
$agents_data = $this->where([ $agents_data = $this->where([
'phone' => $phone, 'phone' => $phone,
'status' => 0 'status' => 0
])->find(); ])->find();
if (!empty($agents_data->store_id)) { if (!empty($agents_data->store_id)) {
$store_name = Db::table('a_store')->where('id',$agents_data['store_id'])->value('store_name'); $store_name = Db::table('a_store')->where('id', $agents_data['store_id'])->value('store_name');
$agents_data['department'] = $store_name; $agents_data['department'] = $store_name;
} }
if (!empty($agents_data->auth_group_id)) { if (!empty($agents_data->auth_group_id)) {
$district_name = Db::table('a_district')->where('id',$agents_data['district_id'])->value('district_name'); $district_name = Db::table('a_district')->where('id', $agents_data['district_id'])->value('district_name');
$agents_data['department'] = $agents_data['department'] ? $district_name.'-'.$store_name : $district_name; $agents_data['department'] = $agents_data['department'] ? $district_name . '-' . $store_name : $district_name;
} }
$agents_data['commission'] = 500; $agents_data['commission'] = 500;
switch ($agents_data['level']) { switch ($agents_data['level']) {
case 10 : case 10 :
$agents_data['level_name'] = '业务员';break; $agents_data['level_name'] = '业务员';
break;
case 20 : case 20 :
$agents_data['level_name'] = '店长';break; $agents_data['level_name'] = '店长';
break;
case 30 : case 30 :
$agents_data['level_name'] = '总监';break; $agents_data['level_name'] = '总监';
break;
case 40 : case 40 :
$agents_data['level_name'] = '总监';break; $agents_data['level_name'] = '总监';
break;
} }
return $agents_data; return $agents_data;
...@@ -63,7 +71,7 @@ class AAgents extends BaseModel ...@@ -63,7 +71,7 @@ class AAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getListJoin($p = 1, $pageSize = 15, $order_ = 'id desc', $field = '',$join='', $where = '') public function getListJoin($p = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $join = '', $where = '')
{ {
$data = $this->field($field) $data = $this->field($field)
->alias('a') ->alias('a')
...@@ -73,7 +81,7 @@ class AAgents extends BaseModel ...@@ -73,7 +81,7 @@ class AAgents extends BaseModel
->limit($pageSize) ->limit($pageSize)
->page($p) ->page($p)
->select(); ->select();
//echo $this->getLastSql(); //echo $this->getLastSql();
return $data; return $data;
} }
...@@ -86,25 +94,30 @@ class AAgents extends BaseModel ...@@ -86,25 +94,30 @@ class AAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function repetition($name,$key){ public function repetition($name, $key)
$r=$this->field($name) {
->where($name,'=',$key) $r = $this->field($name)
->where($name, '=', $key)
->select(); ->select();
//$this->getLastSql(); //$this->getLastSql();
if($r){ if ($r) {
return true; return true;
}else{ } else {
return false; return false;
} }
} }
//更新数据 //更新数据
public function saveStatus($name,$key,$ids){ public function saveStatus($name, $key, $ids)
$r = $this->where("id",'in',$ids)->update([$name=>$key]); {
return $r; $r = $this->where("id", 'in', $ids)->update([ $name => $key ]);
return $r;
} }
//删除数据 //删除数据
public function delUid($name,$ids){ public function delUid($name, $ids)
$this->where($name,'in',$ids)->delete(); {
$this->where($name, 'in', $ids)->delete();
} }
...@@ -114,18 +127,19 @@ class AAgents extends BaseModel ...@@ -114,18 +127,19 @@ class AAgents extends BaseModel
* @return array|false|int * @return array|false|int
* @throws \Exception * @throws \Exception
*/ */
public function addAllAccess($ids,$data){ public function addAllAccess($ids, $data)
$idarr=explode($ids); {
if(is_array($idarr)){ $idarr = explode($ids);
$arr=array(); if (is_array($idarr)) {
foreach ($idarr as $v){ $arr = array();
$data['uid']=$v; foreach ($idarr as $v) {
$arr[]=$data; $data['uid'] = $v;
$arr[] = $data;
} }
$r= $this->saveAll($arr); $r = $this->saveAll($arr);
}else{ } else {
$data['uid']=$ids; $data['uid'] = $ids;
$r= $this->save($data); $r = $this->save($data);
} }
return $r; return $r;
} }
...@@ -136,9 +150,9 @@ class AAgents extends BaseModel ...@@ -136,9 +150,9 @@ class AAgents extends BaseModel
* @param $params * @param $params
* @return int|string * @return int|string
*/ */
public function getTotal2($join,$params) public function getTotal2($join, $params)
{ {
return $this->alias('a') return $this->alias('a')
->join($join) ->join($join)
->where($params)->count(); ->where($params)->count();
} }
...@@ -177,16 +191,16 @@ class AAgents extends BaseModel ...@@ -177,16 +191,16 @@ class AAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function verifyUser($field,$join,$params) public function verifyUser($field, $join, $params)
{ {
$r= $this->field($field) $r = $this->field($field)
->alias('a') ->alias('a')
->join($join) ->join($join)
->where($params) ->where($params)
->find(); ->find();
//echo $this->getLastSql(); //echo $this->getLastSql();
return $r; return $r;
} }
/** /**
...@@ -202,7 +216,8 @@ class AAgents extends BaseModel ...@@ -202,7 +216,8 @@ class AAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getListDistrict($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') { public function getListDistrict($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '')
{
$data = $this->field($field) $data = $this->field($field)
->where($params) ->where($params)
->order($order_) ->order($order_)
...@@ -212,15 +227,15 @@ class AAgents extends BaseModel ...@@ -212,15 +227,15 @@ class AAgents extends BaseModel
$district_where['status'] = 0; $district_where['status'] = 0;
$store_where['status'] = 0; $store_where['status'] = 0;
$result = array(); $result = array();
foreach ($data as $k=>$v){ foreach ($data as $k => $v) {
$result[$k] = $v; $result[$k] = $v;
if (isset($v->district_id)) { if (isset($v->district_id)) {
$district_where['id'] = $v->district_id; $district_where['id'] = $v->district_id;
$result[$k]['district_name'] = Db::table('a_district')->where($district_where)->value('district_name'); $result[$k]['district_name'] = Db::table('a_district')->where($district_where)->value('district_name');
if ($result[$k]['district_name']) { if ($result[$k]['district_name']) {
$store_where['district_id'] = $v->district_id; $store_where['district_id'] = $v->district_id;
$result[$k]['store_num'] = Db::table('a_store')->where($store_where)->count('store_name'); $result[$k]['store_num'] = Db::table('a_store')->where($store_where)->count('store_name');
} else { } else {
$result[$k]['store_num'] = ''; $result[$k]['store_num'] = '';
} }
...@@ -235,7 +250,8 @@ class AAgents extends BaseModel ...@@ -235,7 +250,8 @@ class AAgents extends BaseModel
* @param $params * @param $params
* @return int|string * @return int|string
*/ */
public function getListDistrictTotal($params){ public function getListDistrictTotal($params)
{
return $this->where($params) return $this->where($params)
->count(); ->count();
} }
...@@ -250,9 +266,10 @@ class AAgents extends BaseModel ...@@ -250,9 +266,10 @@ class AAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getAgentById($field = "id",$params){ public function getAgentById($field = "id", $params)
{
$where_ = []; $where_ = [];
if(isset($params["agent_id"])){ if (isset($params["agent_id"])) {
$where_["id"] = $params["agent_id"]; $where_["id"] = $params["agent_id"];
} }
...@@ -269,22 +286,36 @@ class AAgents extends BaseModel ...@@ -269,22 +286,36 @@ class AAgents extends BaseModel
* @param $old_pwd * @param $old_pwd
* @return bool|false|int * @return bool|false|int
*/ */
public function editPwd($id, $pwd, $old_pwd) { public function editPwd($id, $pwd, $old_pwd)
$field_pwd = $this->where('id',$id)->value('password'); {
$field_pwd = $this->where('id', $id)->value('password');
if ($field_pwd == md5($old_pwd)) { if ($field_pwd == md5($old_pwd)) {
$result = $this->save(['password'=>md5($pwd)],['id'=>$id]); $result = $this->save([ 'password' => md5($pwd) ], [ 'id' => $id ]);
} else { } else {
$result = false; $result = false;
} }
return $result; return $result;
} }
public function saveList(){ public function saveList()
{
} }
//分页列表 /**
public function getList($p = 1, $pageSize = 15, $order_ = 'id desc', $field = '',$join='', $where = '') * 分页列表
* @param int $p
* @param int $pageSize
* @param string $order_
* @param string $field
* @param string $join
* @param string $where
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getList($p = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $join = '', $where = '')
{ {
$data = $this->field($field) $data = $this->field($field)
->alias('a') ->alias('a')
...@@ -296,4 +327,17 @@ public function saveList(){ ...@@ -296,4 +327,17 @@ public function saveList(){
->select(); ->select();
return $data; return $data;
} }
/**
* 批量获取经纪人
* @param $params
* @return false|\PDOStatement|string|\think\Collection
*/
public function getAgentsByStoreId($params){
return Db::table($this->table)
->field("id")
->where($params)
->select();
}
} }
\ No newline at end of file
...@@ -95,4 +95,23 @@ class FollowUpLogModel extends Model ...@@ -95,4 +95,23 @@ class FollowUpLogModel extends Model
->select(); ->select();
} }
/**
* 获取经纪人新增带看数量
* @param $params
* @return int|string
*/
public function getAddFollowUpNumByAgentId($params){
$where_ = [];
if(isset($params["agent_id"])){
$where_["agent_id"] = $params["agent_id"];
}
if(isset($params["create_time"])){
$where_["create_time"] = $params["create_time"];
}
return $this->db_
->where($where_)
->count();
}
} }
\ No newline at end of file
...@@ -416,7 +416,7 @@ class GHouses extends BaseModel ...@@ -416,7 +416,7 @@ class GHouses extends BaseModel
* @param $params * @param $params
* @return array|false|\PDOStatement|string|\think\Model * @return array|false|\PDOStatement|string|\think\Model
*/ */
function getHouseDetailById($field,$params){ public function getHouseDetailById($field,$params){
return Db::table($this->table) return Db::table($this->table)
->field($field) ->field($field)
->alias("a") ->alias("a")
...@@ -425,6 +425,24 @@ class GHouses extends BaseModel ...@@ -425,6 +425,24 @@ class GHouses extends BaseModel
->find($params["id"]); ->find($params["id"]);
} }
/**
* 获取经纪人时间段中新添加的楼盘个数
* @param $params
* @return int|string
*/
public function getAddHouseNumByAgentId($params){
$where_ = [];
if(isset($params["agent_id"])){
$where_["upload_id"] = $params["agent_id"];
}
if(isset($params["create_time"])){
$where_["create_time"] = $params["create_time"];
}
return Db::table($this->table)
->where($where_)
->count();
}
/******zw end ************/ /******zw end ************/
} }
...@@ -283,4 +283,24 @@ class Users extends Model ...@@ -283,4 +283,24 @@ class Users extends Model
->select(); ->select();
return $data; return $data;
}*/ }*/
/**
* 获取经纪人新增用户数量
* @param $params
* @return int|string
*/
public function getAddUserNumByAgentId($params){
$where_ = [];
if(isset($params["agent_id"])){
$where_["agent_id"] = $params["agent_id"];
}
if(isset($params["create_time"])){
$where_["create_time"] = $params["create_time"];
}
return Db::table($this->table)
->where($where_)
->count();
}
} }
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