Commit 634fb25d authored by zw's avatar zw

订单搜索

parent bebc797d
......@@ -74,12 +74,12 @@ class OrderLog extends Basic
{
$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["industry_type"])) {
return $this->response("101", "请求参数错误");
}
/* $params = array(
}*/
$params = array(
"agent_id" => 1,//收款经纪人id
"report_id" => 111,//报备id
"order_id" => 2, //关联order表id
......@@ -94,7 +94,7 @@ class OrderLog extends Basic
"industry_type" => "asdasdasd",
"remark" => "没什么备注",
"transfer_img" => "12312312312"
);*/
);
$remark = isset($params["remark"]) ? $params["remark"] : "";
$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
if (!empty($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,
......
<?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 @@
*/
namespace app\model;
use think\Db;
class AAgents extends BaseModel
{
protected $table = 'a_agents';
/**
* 返回经纪人和部门信息
*
......@@ -19,33 +22,38 @@ class AAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getInfo($phone) {
public function getInfo($phone)
{
$agents_data = $this->where([
'phone' => $phone,
'status' => 0
])->find();
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;
}
if (!empty($agents_data->auth_group_id)) {
$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;
$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['commission'] = 500;
switch ($agents_data['level']) {
case 10 :
$agents_data['level_name'] = '业务员';break;
$agents_data['level_name'] = '业务员';
break;
case 20 :
$agents_data['level_name'] = '店长';break;
$agents_data['level_name'] = '店长';
break;
case 30 :
$agents_data['level_name'] = '总监';break;
$agents_data['level_name'] = '总监';
break;
case 40 :
$agents_data['level_name'] = '总监';break;
$agents_data['level_name'] = '总监';
break;
}
return $agents_data;
......@@ -63,7 +71,7 @@ class AAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @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)
->alias('a')
......@@ -86,25 +94,30 @@ class AAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function repetition($name,$key){
$r=$this->field($name)
->where($name,'=',$key)
public function repetition($name, $key)
{
$r = $this->field($name)
->where($name, '=', $key)
->select();
//$this->getLastSql();
if($r){
if ($r) {
return true;
}else{
} else {
return false;
}
}
//更新数据
public function saveStatus($name,$key,$ids){
$r = $this->where("id",'in',$ids)->update([$name=>$key]);
public function saveStatus($name, $key, $ids)
{
$r = $this->where("id", 'in', $ids)->update([ $name => $key ]);
return $r;
}
//删除数据
public function delUid($name,$ids){
$this->where($name,'in',$ids)->delete();
public function delUid($name, $ids)
{
$this->where($name, 'in', $ids)->delete();
}
......@@ -114,18 +127,19 @@ class AAgents extends BaseModel
* @return array|false|int
* @throws \Exception
*/
public function addAllAccess($ids,$data){
$idarr=explode($ids);
if(is_array($idarr)){
$arr=array();
foreach ($idarr as $v){
$data['uid']=$v;
$arr[]=$data;
public function addAllAccess($ids, $data)
{
$idarr = explode($ids);
if (is_array($idarr)) {
$arr = array();
foreach ($idarr as $v) {
$data['uid'] = $v;
$arr[] = $data;
}
$r= $this->saveAll($arr);
}else{
$data['uid']=$ids;
$r= $this->save($data);
$r = $this->saveAll($arr);
} else {
$data['uid'] = $ids;
$r = $this->save($data);
}
return $r;
}
......@@ -136,7 +150,7 @@ class AAgents extends BaseModel
* @param $params
* @return int|string
*/
public function getTotal2($join,$params)
public function getTotal2($join, $params)
{
return $this->alias('a')
->join($join)
......@@ -177,10 +191,10 @@ class AAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @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')
->join($join)
->where($params)
......@@ -202,7 +216,8 @@ class AAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @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)
->where($params)
->order($order_)
......@@ -213,7 +228,7 @@ class AAgents extends BaseModel
$district_where['status'] = 0;
$store_where['status'] = 0;
$result = array();
foreach ($data as $k=>$v){
foreach ($data as $k => $v) {
$result[$k] = $v;
if (isset($v->district_id)) {
$district_where['id'] = $v->district_id;
......@@ -235,7 +250,8 @@ class AAgents extends BaseModel
* @param $params
* @return int|string
*/
public function getListDistrictTotal($params){
public function getListDistrictTotal($params)
{
return $this->where($params)
->count();
}
......@@ -250,9 +266,10 @@ class AAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAgentById($field = "id",$params){
public function getAgentById($field = "id", $params)
{
$where_ = [];
if(isset($params["agent_id"])){
if (isset($params["agent_id"])) {
$where_["id"] = $params["agent_id"];
}
......@@ -269,22 +286,36 @@ class AAgents extends BaseModel
* @param $old_pwd
* @return bool|false|int
*/
public function editPwd($id, $pwd, $old_pwd) {
$field_pwd = $this->where('id',$id)->value('password');
public function editPwd($id, $pwd, $old_pwd)
{
$field_pwd = $this->where('id', $id)->value('password');
if ($field_pwd == md5($old_pwd)) {
$result = $this->save(['password'=>md5($pwd)],['id'=>$id]);
$result = $this->save([ 'password' => md5($pwd) ], [ 'id' => $id ]);
} else {
$result = false;
}
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)
->alias('a')
......@@ -296,4 +327,17 @@ public function saveList(){
->select();
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
->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
* @param $params
* @return array|false|\PDOStatement|string|\think\Model
*/
function getHouseDetailById($field,$params){
public function getHouseDetailById($field,$params){
return Db::table($this->table)
->field($field)
->alias("a")
......@@ -425,6 +425,24 @@ class GHouses extends BaseModel
->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 ************/
}
......@@ -283,4 +283,24 @@ class Users extends Model
->select();
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