Commit 42a3d28c authored by clone's avatar clone

1

parent d4fd721a
......@@ -5,6 +5,7 @@ namespace app\api_broker\service;
use app\api\untils\GeTuiUtils;
use app\model\GHouses;
use app\model\GHousesToAgents;
use app\model\OfficeGRoom;
use app\model\OfficeOrderModel;
use app\model\OfficeOReportModel;
use app\model\Users;
......@@ -24,8 +25,8 @@ class OfficeReportService
function __construct()
{
$this->reportModel = new OfficeOReportModel();
$this->orderModel = new OfficeOrderModel();
$this->reportModel = new OfficeOReportModel();
$this->orderModel = new OfficeOrderModel();
}
/**
......@@ -42,9 +43,9 @@ class OfficeReportService
if (count($userArr) > 0) {
$userResult["user_phone"] = $userArr["user_phone"];
if (empty($userArr['user_name'])) {
$userResult["user_name"] = $userArr["user_nick"];
$userResult["user_name"] = $userArr["user_nick"];
} else {
$userResult["user_name"] = $userArr["user_name"];
$userResult["user_name"] = $userArr["user_name"];
}
} else {
return null;
......@@ -83,7 +84,7 @@ class OfficeReportService
foreach ($house_arr as $k => $v) {
//todo 批量插入到数据库
if($v <= 0){
if ($v <= 0) {
break;
}
$order_no = $this->createOrderNumber();
......@@ -109,9 +110,9 @@ class OfficeReportService
{
//todo 获取我报备的我的案场的,
//如果是店长则获取其下所有的经纪人 这里去掉了for190218
$vModel = new VerifyService();
$vModel = new VerifyService();
// $agentArr = $vModel->getAgentsByAgentId($params["report_agent_id"]);
$params["agent_id_s"] = array( "in", $params["report_agent_id"] );
$params["agent_id_s"] = array("in", $params["report_agent_id"]);
$caseHouseId = $vModel->getCaseHouseIdByAgentIdV2($params["agent_id_s"]);
$ids = "";
......@@ -137,25 +138,26 @@ class OfficeReportService
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function returnResult($result){
$ids_str = "";
public function returnResult($result)
{
$ids_str = "";
$house_id_str = "";
if (count($result) > 0) {
foreach ($result as $k => $v) {
$order_id = 0;
if(isset($v["order_id"])){
if (isset($v["order_id"])) {
$order_id = $v["order_id"];
}else{
} else {
$order_id = $v["id"];
}
$ids_str .= $order_id . ",";
$ids_str .= $order_id . ",";
$house_id_str .= $v["house_id"] . ",";
}
$ids_str = rtrim($ids_str, ",");
$ids_str = rtrim($ids_str, ",");
$house_id_str = rtrim($house_id_str, ",");
$sign_arr = $this->orderSign($ids_str);
$sign_arr = $this->orderSign($ids_str);
$house_arr = $this->houseInfo($house_id_str);
foreach ($result as $k => $v) {
......@@ -173,8 +175,9 @@ class OfficeReportService
}
}
return $result;
return $result;
}
/**
* 报备订单列表All
* @param $field
......@@ -185,9 +188,9 @@ class OfficeReportService
* @throws \think\db\exception\BindParamException
* @throws \think\exception\PDOException
*/
public function orderListAll($field, $params, $pageNo, $pageSize,$check_type)
public function orderListAll($field, $params, $pageNo, $pageSize, $check_type)
{
$vModel = new VerifyService();
$vModel = new VerifyService();
$result = [];
switch ($check_type) {
case 1 :
......@@ -195,19 +198,19 @@ class OfficeReportService
break;
case 2 :
case 3 :
$agentArr = $vModel->getAgentsByAgentIdAndType($params["report_agent_id"], $check_type);
$params["agent_id_s"] = array( "in", $agentArr);
$agentArr = $vModel->getAgentsByAgentIdAndType($params["report_agent_id"], $check_type);
$params["agent_id_s"] = array("in", $agentArr);
$params["report_agent_id"] = $agentArr;
$caseHouseId = $vModel->getPanpartyAndExclusiveHouseIdByAgentId($params["agent_id_s"]);
$ids = "";
$caseHouseId = $vModel->getPanpartyAndExclusiveHouseIdByAgentId($params["agent_id_s"]);
$ids = "";
if (count($caseHouseId) > 0) {
foreach ($caseHouseId as $item) {
$ids .= $item["houses_id"] . ",";
}
}
$ids = rtrim($ids, ",");
$ids = $ids ? $ids : 0;
$ids = rtrim($ids, ",");
$ids = $ids ? $ids : 0;
$params["house_ids"] = $ids;
$result = $this->reportModel->selectReportList($field, $params, $pageNo, $pageSize);
......@@ -234,7 +237,7 @@ class OfficeReportService
$vModel = new VerifyService();
$agentArr = $vModel->getAgentsByAgentId($params["report_agent_id"]);
if ($agentArr) {
$params["agent_id_s"] = array( "in", $agentArr );
$params["agent_id_s"] = array("in", $agentArr);
$params["report_agent_id"] = $agentArr;
}
......@@ -251,11 +254,11 @@ class OfficeReportService
$params["house_ids"] = $ids;
$result = $this->reportModel->selectReportList($field, $params, $pageNo, $pageSize);
$count = $this->reportModel->selectReportCount($field,$params);
$count = $this->reportModel->selectReportCount($field, $params);
if (count($result) > 0) {
$data["result"] = $this->returnResult($result);
$data["total"] = $count[0]["total"] ? $count[0]["total"] : 0;
$data["total"] = $count[0]["total"] ? $count[0]["total"] : 0;
return $data;
}
return null;
......@@ -276,9 +279,9 @@ class OfficeReportService
*/
public function houseInfo($house_id_str)
{
$houseModel = new GHouses();
$params["id"] = array("in",($house_id_str));
return $houseModel->getHouseInfo("id,internal_address",$params);
$houseModel = new GHouses();
$params["id"] = array("in", ($house_id_str));
return $houseModel->getHouseInfo("id,internal_address", $params);
}
public function signTitle($type)
......@@ -352,9 +355,9 @@ class OfficeReportService
*/
private function orderBin($order_no, $f_id, $house_id)
{
$houseModel = new GHouses();
$houseResult = $houseModel->getHouseDetail("id,internal_title", [ "id" => $house_id ]);
$house_title = count($houseResult) > 0 && isset($houseResult["internal_title"]) ? $houseResult["internal_title"] : null;
$roomModel = new OfficeGRoom();
$houseResult = $roomModel->getHouseDetail("a.id,c.title,c.address,a.room_number", ["id" => $house_id]);
$house_title = count($houseResult) > 0 ? $houseResult["address"] . " " . $houseResult["room_number"] : null;
$param["order_no"] = $order_no;
$param["f_id"] = $f_id;
$param["house_id"] = $house_id;
......@@ -373,15 +376,15 @@ class OfficeReportService
public function getCheckType($agent_id)
{
$vip = new VipService();
if($vip->vip($agent_id, 'index/inspectionRecordAll/3') == 0){//代表公司
if ($vip->vip($agent_id, 'index/inspectionRecordAll/3') == 0) {//代表公司
return 1;
}
if($vip->vip($agent_id, 'index/inspectionRecordDistrict/2') == 0){//代表部门
if ($vip->vip($agent_id, 'index/inspectionRecordDistrict/2') == 0) {//代表部门
return 2;
}
if($vip->vip($agent_id, 'index/inspectionRecordStore/1') == 0){//代表门店
if ($vip->vip($agent_id, 'index/inspectionRecordStore/1') == 0) {//代表门店
return 3;
}
return 0;
......
......@@ -418,4 +418,22 @@ class OfficeGRoom extends BaseModel
->page($pageNo)
->select();
}
/**
* @param $field
* @param $params
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
function getHouseDetail($field, $params)
{
return $data = $this
->field($field)
->alias("a")
->join("office_g_building b","a.building_id=a.id")
->where($params)
->find();
}
}
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