Commit 9938d83d authored by clone's avatar clone

1

parent eac73ff2
...@@ -45,53 +45,6 @@ class OrderLog extends Basic ...@@ -45,53 +45,6 @@ class OrderLog extends Basic
$this->verifyService_ = new VerifyRepetitionService(); $this->verifyService_ = new VerifyRepetitionService();
} }
/**
* 进场
* @return \think\Response
*/
public function marchIn()
{
$params = $this->params;
if (!isset($params["march_in_area"]) || !isset($params["report_id"]) || !isset($params["reception_id"])
|| !isset($params["reception_name"]) || !isset($params["order_id"]) || !isset($params["order_no"])) {
return $this->response("101", "请求参数错误");
}
/* $params = array(
"reception_id" => 10010,//带看经纪人id
"reception_name" => 1,//带看经纪人id
"report_id" => 1,//报备id
"order_id" => 1, //关联order表id
"order_no" => "123123123123123", //订单no
"march_in_remark" => "有意向购买", //进场备注
"march_in_img" => "123123", //备注图片
"march_in_area" => "上海市虹口区中山公园", //进场地址
);*/
// $params["reception_id"] = $this->agentName;
//todo 兼容2.9.9bug ios
if (isset($params["transfer_img"])) {
$transfer_img = json_decode($params["transfer_img"], true);
$params["march_in_img"] = $transfer_img[0];
unset($params["transfer_img"]);
}
$is_execute = $this->verifyService_->verifyStart(1, $params["reception_id"], $params["order_id"]);
if (!$is_execute) {
return $this->response("101", "请不要重复提交");
}
$is_ok = $this->o_march_in_model->addMarchIn($params);
if ($is_ok > 0) {
$pushMarchIn = new PushMessageService();
$pushMarchIn->pushMarchInMessage($params["report_id"], 1, $this->agentId); //推送
return $this->response("200", "request success", []);
} else {
return $this->response("101", "request faild");
}
}
/** /**
* @return \think\Response * @return \think\Response
* @throws Exception * @throws Exception
...@@ -143,8 +96,6 @@ class OrderLog extends Basic ...@@ -143,8 +96,6 @@ class OrderLog extends Basic
} else { } else {
return $this->response("101", "request faild"); return $this->response("101", "request faild");
} }
} }
/** /**
...@@ -166,62 +117,6 @@ class OrderLog extends Basic ...@@ -166,62 +117,6 @@ class OrderLog extends Basic
} }
} }
/**
* 收款
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function collectingBillV2()
{
$params = $this->params;
if (!isset($params["agent_id"]) || !isset($params["agent_id"]) || !isset($params["report_id"]) || !isset($params["order_id"]) || !isset($params["order_no"])
|| !isset($params["collecting_bill"]) || !isset($params["house_number"]) || !isset($params["industry_type"])) {
return $this->response("101", "请求参数错误");
}
/* $params = array(
"agent_id" => 1,//收款经纪人id
"agent_name" => 1,//收款经纪人id
"report_id" => 111,//报备id
"order_id" => 2, //关联order表id
"order_no" => "123123123", //订单no
// `type` '付款类型 10意向金 20定金 30保管金 40押金 50 租金 60 进场费 70转让费 80其他',
//`pay_type` '支付方式 10支付宝 20 微信 30pos机器 40转账 50现金',
// `money` '入账金额 存分',
"collecting_bill" => [ { "type" : 10, "pay_type" : 10, "money" : 1100 }, { "type" :10, "pay_type" : 10, "money": 1200 } ],
"house_number" => "3301号",
"industry_type" => "asdasdasd",
"remark" => "没什么备注",
"transfer_img" => "12312312312"
);*/
$vip_services = new VipService();
if ($vip_services->vip($params['agent_id'], 'broker/collectingBill')) {
return $this->response("101", "没有权限");
}
$params["collecting_bill"] = json_decode($params["collecting_bill"], true);
$remark = isset($params["remark"]) ? $params["remark"] : "";
$transfer_img = isset($params["transfer_img"]) ? json_decode($params["transfer_img"], true) : "";
Log::record("********************transfer_img**" . json_encode($transfer_img));
$source = isset($params["source"]) ? $params["source"] : 0;
$income_time = isset($params["income_time"]) ? $params["income_time"] : "";
$received_money = isset($params["received_money"]) ? $params["received_money"] : "";
$type_ext = isset($params["type_ext"]) ? $params["type_ext"] : "";
$bargain_id = isset($params['bargain_id']) ? $params['bargain_id'] : 0;
$is_open = isset($params['is_open']) ? $params['is_open'] : -1;
$is_ok = $this->service_->addCollectingBillV2($params["agent_id"], $params["agent_name"], $params["report_id"], $params["order_id"], $params["order_no"], $params["collecting_bill"], $params["house_number"], $params["industry_type"], $remark, $transfer_img, $source, $income_time, $received_money, $type_ext, $bargain_id, $is_open);
if ($is_ok > 0) {
return $this->response("200", "request success", ["bill_id" => $is_ok]);
}
return $this->response("101", "request faild");
}
/** /**
* 收款 * 收款
* @return \think\Response * @return \think\Response
......
...@@ -38,7 +38,7 @@ class OrderLogService ...@@ -38,7 +38,7 @@ class OrderLogService
function __construct() function __construct()
{ {
$this->payLogModel = new OPayLogModel(); $this->payLogModel = new OPayLogModel();
$this->bargainModel = new OBargainModel(); $this->bargainModel = new OBargainModel();
} }
...@@ -59,6 +59,8 @@ class OrderLogService ...@@ -59,6 +59,8 @@ class OrderLogService
* @param $income_time * @param $income_time
* @param $received_money * @param $received_money
* @param $type_ext * @param $type_ext
* @param $bargain_id
* @param $is_open
* @return int|string * @return int|string
* @throws \think\Exception * @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
...@@ -66,22 +68,25 @@ class OrderLogService ...@@ -66,22 +68,25 @@ class OrderLogService
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function addCollectingBillV2($agent_id, $agent_name, $report_id, $order_id, $order_no, $collecting_bill, $house_number, public function addCollectingBillV2($agent_id, $agent_name, $report_id, $order_id, $order_no, $collecting_bill, $house_number,
$industry_type, $remark, $transfer_img, $source, $income_time, $received_money, $type_ext, $bargain_id, $is_open) $industry_type, $remark, $transfer_img, $source, $income_time, $received_money,
$type_ext, $bargain_id, $is_open)
{ {
$bill_arr = $params = []; $bill_arr = $params = [];
$father_id = $pay_type = 0; $father_id = $pay_type = 0;
foreach ($collecting_bill as $collecting) { foreach ($collecting_bill as $collecting) {
if (isset($collecting["type"]) && isset($collecting["pay_type"]) && isset($collecting["money"])) { if (isset($collecting["type"]) && isset($collecting["pay_type"]) && isset($collecting["money"])) {
if ($father_id == 0) { if ($father_id == 0) {
$params = $this->collectingBillBin($father_id, $collecting, $agent_id, $agent_name, $report_id, $order_id, $order_no, $params = $this->collectingBillBin($father_id, $collecting, $agent_id, $agent_name, $report_id,
$house_number, $industry_type, $remark, $transfer_img, $source, $income_time, 0, 0, $received_money, $type_ext, $bargain_id); $order_id, $order_no, $house_number, $industry_type, $remark, $transfer_img, $source, $income_time,
0, 0, $received_money, $type_ext, $bargain_id, $is_open);
$father_id = $this->payLogModel->insertPayLog($params); $father_id = $this->payLogModel->insertPayLog($params);
} else { } else {
array_push($bill_arr, $this->collectingBillBin($father_id, $collecting, $agent_id, $agent_name, $report_id, $order_id, $order_no, array_push($bill_arr, $this->collectingBillBin($father_id, $collecting, $agent_id, $agent_name,
$house_number, $industry_type, $remark, $transfer_img, $source, $income_time, 0, 0, $received_money, $type_ext, $bargain_id)); $report_id, $order_id, $order_no, $house_number, $industry_type, $remark, $transfer_img, $source,
$income_time, 0, 0, $received_money, $type_ext, $bargain_id, $is_open));
} }
$this->updateBargainIsOpen($bargain_id, $collecting['type'], $is_open); // $this->updateBargainIsOpen($bargain_id, $collecting['type'], $is_open);
$type = $collecting['type']; $type = $collecting['type'];
} }
} }
...@@ -122,6 +127,8 @@ class OrderLogService ...@@ -122,6 +127,8 @@ class OrderLogService
* @param $transfer_name * @param $transfer_name
* @param $received_money * @param $received_money
* @param $type_ext * @param $type_ext
* @param $bargain_id
* @param $is_open
* @return int|string * @return int|string
* @throws \think\Exception * @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
...@@ -130,19 +137,20 @@ class OrderLogService ...@@ -130,19 +137,20 @@ class OrderLogService
*/ */
public function addCollectingBill($agent_id, $agent_name, $report_id, $order_id, $order_no, $collecting_bill, $house_number, public function addCollectingBill($agent_id, $agent_name, $report_id, $order_id, $order_no, $collecting_bill, $house_number,
$industry_type, $remark, $transfer_img, $source, $income_time, $is_dividend, $industry_type, $remark, $transfer_img, $source, $income_time, $is_dividend,
$last_transfer_time, $pay_id, $receipt_number, $transfer_name, $received_money, $type_ext, $bargain_id, $is_open) $last_transfer_time, $pay_id, $receipt_number, $transfer_name, $received_money,
$type_ext, $bargain_id, $is_open)
{ {
$bill_arr = $params = []; $bill_arr = $params = [];
$father_id = 0; $father_id = 0;
$money = 0; $money = 0;
$type = 0; $type = 0;
foreach ($collecting_bill as $collecting) { foreach ($collecting_bill as $collecting) {
if (isset($collecting["type"]) && isset($collecting["pay_type"]) && isset($collecting["money"])) { if (isset($collecting["type"]) && isset($collecting["pay_type"]) && isset($collecting["money"])) {
if (!$this->verifyType($collecting["type"], $collecting["pay_type"], $receipt_number)) { if (!$this->verifyType($collecting["type"], $collecting["pay_type"], $receipt_number)) {
return -1; return -1;
} }
$money = $collecting["money"]; $money = $collecting["money"];
$type = $collecting["type"]; $type = $collecting["type"];
if ($pay_id > 0) { if ($pay_id > 0) {
$is_ok = $this->verifyMoney($pay_id, $money); $is_ok = $this->verifyMoney($pay_id, $money);
if ($is_ok != 0) { if ($is_ok != 0) {
...@@ -150,16 +158,18 @@ class OrderLogService ...@@ -150,16 +158,18 @@ class OrderLogService
} }
} }
if ($father_id == 0) { if ($father_id == 0) {
$params = $this->collectingBillBin($father_id, $collecting, $agent_id, $agent_name, $report_id, $params = $this->collectingBillBin($father_id, $collecting, $agent_id, $agent_name, $report_id,
$order_id, $order_no, $house_number, $industry_type, $remark, $transfer_img, $source, $income_time, $order_id, $order_no, $house_number, $industry_type, $remark, $transfer_img, $source, $income_time,
$is_dividend, $last_transfer_time, $receipt_number, $transfer_name, $received_money, $type_ext, $bargain_id); $is_dividend, $last_transfer_time, $receipt_number, $transfer_name, $received_money, $type_ext,
$bargain_id, $is_open);
$father_id = $this->payLogModel->insertPayLog($params); $father_id = $this->payLogModel->insertPayLog($params);
} else { } else {
array_push($bill_arr, $this->collectingBillBin($father_id, $collecting, $agent_id, $agent_name, array_push($bill_arr, $this->collectingBillBin($father_id, $collecting, $agent_id, $agent_name,
$report_id, $order_id, $order_no, $house_number, $industry_type, $remark, $transfer_img, $source, $report_id, $order_id, $order_no, $house_number, $industry_type, $remark, $transfer_img, $source,
$income_time, $is_dividend, $last_transfer_time, $receipt_number, $transfer_name, $received_money, $type_ext, $bargain_id)); $income_time, $is_dividend, $last_transfer_time, $receipt_number, $transfer_name, $received_money,
$type_ext, $bargain_id, $is_open));
} }
$this->updateBargainIsOpen($bargain_id, $collecting['type'], $is_open); //$this->updateBargainIsOpen($bargain_id, $collecting['type'], $is_open);
} }
} }
if ($father_id > 0) { if ($father_id > 0) {
...@@ -184,21 +194,22 @@ class OrderLogService ...@@ -184,21 +194,22 @@ class OrderLogService
return $father_id; return $father_id;
} }
public function verifyIsShowAdjustment($pay_id,$agent_id){ public function verifyIsShowAdjustment($pay_id, $agent_id)
{
$params["id"] = $pay_id; $params["id"] = $pay_id;
$pay_log_info = $this->payLogModel->getPayLogByOrderId("a.id,a.agent_id,c.store_id",$params); $pay_log_info = $this->payLogModel->getPayLogByOrderId("a.id,a.agent_id,c.store_id", $params);
if(count($pay_log_info) <= 0){ if (count($pay_log_info) <= 0) {
return ["code"=> 101 ,"msg"=> "没有找到相对应的收款信息"]; return ["code" => 101, "msg" => "没有找到相对应的收款信息"];
} }
$agentModel = new AAgents(); $agentModel = new AAgents();
$agent_info = $agentModel->getAgentById("id,store_id",["id"=>$agent_id]); $agent_info = $agentModel->getAgentById("id,store_id", ["id" => $agent_id]);
if(count($agent_info) <= 0){ if (count($agent_info) <= 0) {
return ["code"=> 101 ,"msg"=> "没有找到相对应的经纪人信息"]; return ["code" => 101, "msg" => "没有找到相对应的经纪人信息"];
} }
if($pay_log_info[0]["store_id"] != $agent_info[0]["store_id"]){ if ($pay_log_info[0]["store_id"] != $agent_info[0]["store_id"]) {
return ["code"=> 200 ,"is_show"=> false]; return ["code" => 200, "is_show" => false];
}else{ } else {
return ["code"=> 200 ,"is_show"=> true]; return ["code" => 200, "is_show" => true];
} }
} }
...@@ -319,42 +330,47 @@ class OrderLogService ...@@ -319,42 +330,47 @@ class OrderLogService
* @param $received_money * @param $received_money
* @param $type_ext * @param $type_ext
* @param $bargain_id * @param $bargain_id
* @param $is_open
* @return mixed * @return mixed
*/ */
private function collectingBillBin($father_id, $collecting_arr, $agent_id, $agent_name, $report_id, $order_id, private function collectingBillBin($father_id, $collecting_arr, $agent_id, $agent_name, $report_id, $order_id,
$order_no, $house_number, $industry_type, $remark, $transfer_img, $source, $order_no, $house_number, $industry_type, $remark, $transfer_img, $source,
$income_time, $is_dividend, $last_transfer_time, $receipt_number, $transfer_name, $received_money, $type_ext, $bargain_id) $income_time, $is_dividend, $last_transfer_time, $receipt_number, $transfer_name,
$received_money, $type_ext, $bargain_id, $is_open)
{ {
$arr["report_id"] = $report_id; $arr["report_id"] = $report_id;
$arr["father_id"] = $father_id; $arr["father_id"] = $father_id;
$arr["order_no"] = $order_no; $arr["order_no"] = $order_no;
$arr["order_id"] = $order_id; $arr["order_id"] = $order_id;
$arr["source"] = $source; $arr["source"] = $source;
$arr["agent_id"] = $agent_id; $arr["agent_id"] = $agent_id;
$arr["agent_name"] = $agent_name; $arr["agent_name"] = $agent_name;
$arr["type"] = $collecting_arr["type"]; $arr["type"] = $collecting_arr["type"];
$arr["pay_type"] = $collecting_arr["pay_type"]; $arr["pay_type"] = $collecting_arr["pay_type"];
$arr["money"] = $collecting_arr["money"]; $arr["money"] = $collecting_arr["money"];
$arr["house_number"] = $house_number; $arr["house_number"] = $house_number;
$arr["industry_type"] = $industry_type; $arr["industry_type"] = $industry_type;
$arr["remark"] = $remark; $arr["remark"] = $remark;
$arr["receipt_number"] = $receipt_number; $arr["receipt_number"] = $receipt_number;
$arr["transfer_name"] = $transfer_name; $arr["transfer_name"] = $transfer_name;
$arr["transfer_img"] = $transfer_img; $arr["transfer_img"] = $transfer_img;
$arr["create_time"] = date("Y-m-d H:i:s", time()); $arr["create_time"] = date("Y-m-d H:i:s", time());
$arr["update_time"] = date("Y-m-d H:i:s", time()); $arr["update_time"] = date("Y-m-d H:i:s", time());
$arr["is_dividend"] = $is_dividend; $arr["is_dividend"] = $is_dividend;
$arr["received_money"] = $received_money; $arr["received_money"] = $received_money;
$arr["type_ext"] = $type_ext; $arr["type_ext"] = $type_ext;
$arr["bargain_id"] = $bargain_id; $arr["bargain_id"] = $bargain_id;
$arr["is_open"] = $is_open;
if ($income_time) { if ($income_time) {
$arr["income_time"] = date("Y-m-d H:i:s", $income_time); $arr["income_time"] = date("Y-m-d H:i:s", $income_time);
} }
if ($last_transfer_time) { if ($last_transfer_time) {
$arr["last_transfer_time"] = date("Y-m-d H:i:s", $last_transfer_time); $arr["last_transfer_time"] = date("Y-m-d H:i:s", $last_transfer_time);
} }
if ($is_open && $is_open == 1) {
$arr["open_time"] = date("Y-m-d H:i:s", $last_transfer_time);
}
return $arr; return $arr;
} }
...@@ -383,13 +399,13 @@ class OrderLogService ...@@ -383,13 +399,13 @@ class OrderLogService
$commission, $commission_arr, $house_number, $is_open, $industry_type, $estimated_receipt_date) $commission, $commission_arr, $house_number, $is_open, $industry_type, $estimated_receipt_date)
{ {
$bargain_arr = []; $bargain_arr = [];
$father_id = 0; $father_id = 0;
foreach ($commission_arr as $commission_val) { foreach ($commission_arr as $commission_val) {
if (isset($commission_val["role"]) && isset($commission_val["agent_id"]) && isset($commission_val["scale"]) if (isset($commission_val["role"]) && isset($commission_val["agent_id"]) && isset($commission_val["scale"])
&& isset($commission_val["scale_fee"])) { && isset($commission_val["scale_fee"])) {
if ($father_id == 0) { if ($father_id == 0) {
$params = $this->bargainBin($father_id, $commission_val, $submit_agent_id, $submit_agent_name, $report_id, $order_id, $params = $this->bargainBin($father_id, $commission_val, $submit_agent_id, $submit_agent_name, $report_id, $order_id,
$order_no, $trade_type, $price, $commission, $house_number, $is_open, $industry_type, $estimated_receipt_date); $order_no, $trade_type, $price, $commission, $house_number, $is_open, $industry_type, $estimated_receipt_date);
$father_id = $this->bargainModel->insertBargain($params); $father_id = $this->bargainModel->insertBargain($params);
} else { } else {
...@@ -419,25 +435,25 @@ class OrderLogService ...@@ -419,25 +435,25 @@ class OrderLogService
private function bargainBin($father_id, $commission_val, $submit_agent_id, $submit_agent_name, $report_id, $order_id, private function bargainBin($father_id, $commission_val, $submit_agent_id, $submit_agent_name, $report_id, $order_id,
$order_no, $trade_type, $price, $commission, $house_number, $is_open, $industry_type, $estimated_receipt_date) $order_no, $trade_type, $price, $commission, $house_number, $is_open, $industry_type, $estimated_receipt_date)
{ {
$arr["report_id"] = $report_id; $arr["report_id"] = $report_id;
$arr["father_id"] = $father_id; $arr["father_id"] = $father_id;
$arr["order_no"] = $order_no; $arr["order_no"] = $order_no;
$arr["order_id"] = $order_id; $arr["order_id"] = $order_id;
$arr["submit_agent_id"] = $submit_agent_id; $arr["submit_agent_id"] = $submit_agent_id;
$arr["submit_agent_name"] = $submit_agent_name; $arr["submit_agent_name"] = $submit_agent_name;
$arr["trade_type"] = $trade_type; $arr["trade_type"] = $trade_type;
$arr["price"] = $price; $arr["price"] = $price;
$arr["commission"] = $commission; $arr["commission"] = $commission;
$arr["role"] = $commission_val["role"]; $arr["role"] = $commission_val["role"];
$arr["agent_id"] = $commission_val["agent_id"]; $arr["agent_id"] = $commission_val["agent_id"];
$arr["scale"] = $commission_val["scale"]; $arr["scale"] = $commission_val["scale"];
$arr["scale_fee"] = $commission_val["scale_fee"]; $arr["scale_fee"] = $commission_val["scale_fee"];
$arr["house_number"] = $house_number; $arr["house_number"] = $house_number;
$arr["is_open"] = $is_open; $arr["is_open"] = $is_open;
$arr["create_time"] = date("Y-m-d H:i:s", time()); $arr["create_time"] = date("Y-m-d H:i:s", time());
$arr["update_time"] = date("Y-m-d H:i:s", time()); $arr["update_time"] = date("Y-m-d H:i:s", time());
$arr["estimated_receipt_date"] = date("Y-m-d H:i:s", $estimated_receipt_date); $arr["estimated_receipt_date"] = date("Y-m-d H:i:s", $estimated_receipt_date);
$arr["industry_type"] = $industry_type; $arr["industry_type"] = $industry_type;
return $arr; return $arr;
} }
...@@ -449,9 +465,9 @@ class OrderLogService ...@@ -449,9 +465,9 @@ class OrderLogService
public function selectOrderDetail($where_) public function selectOrderDetail($where_)
{ {
$orderModel = new OrderModel(); $orderModel = new OrderModel();
$field = "a.id,a.order_no,a.house_id,a.house_title,b.id as report_id,b.user_id,c.user_name as user_nick,c.user_phone, $field = "a.id,a.order_no,a.house_id,a.house_title,b.id as report_id,b.user_id,c.user_name as user_nick,c.user_phone,
c.user_pic,c.sex,d.internal_address as house_address"; c.user_pic,c.sex,d.internal_address as house_address";
$result = $orderModel->selectOrderDetail($field, $where_); $result = $orderModel->selectOrderDetail($field, $where_);
foreach ($result as $k => $v) { foreach ($result as $k => $v) {
//$result[$k]["user_phone"] = preg_replace('/(\d{3})\d{4}(\d{4})/','$1****$2',$v["user_phone"]); //$result[$k]["user_phone"] = preg_replace('/(\d{3})\d{4}(\d{4})/','$1****$2',$v["user_phone"]);
$result[$k]["user_pic"] = HEADERIMGURL . $v["user_pic"]; $result[$k]["user_pic"] = HEADERIMGURL . $v["user_pic"];
...@@ -472,16 +488,16 @@ class OrderLogService ...@@ -472,16 +488,16 @@ class OrderLogService
public function selectListByOrderNoV2($order_id) public function selectListByOrderNoV2($order_id)
{ {
$result = []; $result = [];
$sort = 0; $sort = 0;
//todo 1.验证订单是否存在 //todo 1.验证订单是否存在
$orderModel = new OrderModel(); $orderModel = new OrderModel();
$oReportModel = new OReportModel(); $oReportModel = new OReportModel();
$oMarchInModel = new OMarchInModel(); $oMarchInModel = new OMarchInModel();
$followUpLogModel = new FollowUpLogModel(); $followUpLogModel = new FollowUpLogModel();
$oPayLogModel = new OPayLogModel(); $oPayLogModel = new OPayLogModel();
$oRefundModel = new ORefundModel(); $oRefundModel = new ORefundModel();
$oBargainModel = new OBargainModel(); $oBargainModel = new OBargainModel();
$orderData = $orderModel->selectOrderByOrderId("a.f_id,a.house_title,b.internal_address", ["order_id" => $order_id]); $orderData = $orderModel->selectOrderByOrderId("a.f_id,a.house_title,b.internal_address", ["order_id" => $order_id]);
...@@ -499,14 +515,14 @@ class OrderLogService ...@@ -499,14 +515,14 @@ class OrderLogService
return ["101", "报备记录未找到"]; return ["101", "报备记录未找到"];
} }
//报备 //报备
$reportData[0]["step_name"] = "report"; $reportData[0]["step_name"] = "report";
$reportData[0]["house_title"] = $orderData[0]["house_title"]; $reportData[0]["house_title"] = $orderData[0]["house_title"];
$reportData[0]["internal_address"] = $orderData[0]["internal_address"]; $reportData[0]["internal_address"] = $orderData[0]["internal_address"];
$result[$sort++] = $reportData[0]; $result[$sort++] = $reportData[0];
//进场 march in //进场 march in
$field_march_in = "id,reception_id,reception_name,report_id,order_no,march_in_remark,march_in_img,march_in_area,create_time"; $field_march_in = "id,reception_id,reception_name,report_id,order_no,march_in_remark,march_in_img,march_in_area,create_time";
$marchInData = $oMarchInModel->selectMarchInByOrderNo($field_march_in, ["order_id" => $order_id]); $marchInData = $oMarchInModel->selectMarchInByOrderNo($field_march_in, ["order_id" => $order_id]);
if (count($marchInData) > 0) { if (count($marchInData) > 0) {
/* foreach ($marchInData as $k => $v) { /* foreach ($marchInData as $k => $v) {
$v["step_name"] = "march_in"; $v["step_name"] = "march_in";
...@@ -515,9 +531,9 @@ class OrderLogService ...@@ -515,9 +531,9 @@ class OrderLogService
}*/ }*/
foreach ($marchInData as $k => $v) { foreach ($marchInData as $k => $v) {
$v["step_name"] = "march_in"; $v["step_name"] = "march_in";
$v["img_path"] = CHAT_IMG_URL; $v["img_path"] = CHAT_IMG_URL;
$v["img"] = $this->getOImg($v["id"], 1); $v["img"] = $this->getOImg($v["id"], 1);
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -528,9 +544,9 @@ class OrderLogService ...@@ -528,9 +544,9 @@ class OrderLogService
if (count($followUpLogData) > 0) { if (count($followUpLogData) > 0) {
foreach ($followUpLogData as $k => $v) { foreach ($followUpLogData as $k => $v) {
$v["step_name"] = "follow_up_log"; $v["step_name"] = "follow_up_log";
$v = $this->convertFollowUp($v); $v = $this->convertFollowUp($v);
$v["img_path"] = CHAT_IMG_URL; $v["img_path"] = CHAT_IMG_URL;
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -538,12 +554,12 @@ class OrderLogService ...@@ -538,12 +554,12 @@ class OrderLogService
//收款 //收款
$field_pay_log = "id,order_no,father_id,order_id,agent_id,agent_name,type,pay_type,money,house_number,industry_type, $field_pay_log = "id,order_no,father_id,order_id,agent_id,agent_name,type,pay_type,money,house_number,industry_type,
remark,transfer_img,real_money,source,create_time"; remark,transfer_img,real_money,source,create_time";
$payLogData = $oPayLogModel->selectPayLogByOrderNo($field_pay_log, ["order_id" => $order_id]); $payLogData = $oPayLogModel->selectPayLogByOrderNo($field_pay_log, ["order_id" => $order_id]);
if (count($payLogData) > 0) { if (count($payLogData) > 0) {
$sortPayLogData = $this->arr2tree($payLogData); $sortPayLogData = $this->arr2tree($payLogData);
foreach ($sortPayLogData as $k => $v) { foreach ($sortPayLogData as $k => $v) {
$v["step_name"] = "pay_log"; $v["step_name"] = "pay_log";
$v["img_path"] = CHAT_IMG_URL; $v["img_path"] = CHAT_IMG_URL;
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -551,11 +567,11 @@ class OrderLogService ...@@ -551,11 +567,11 @@ class OrderLogService
//退款 //退款
$field_refund = "id,report_id,agent_id,agent_name,order_no,order_id,refund_money,status,name,bank,card_no, $field_refund = "id,report_id,agent_id,agent_name,order_no,order_id,refund_money,status,name,bank,card_no,
remark,remark_img,create_time"; remark,remark_img,create_time";
$refundData = $oRefundModel->selectRefundByOrderNo($field_refund, ["order_id" => $order_id]); $refundData = $oRefundModel->selectRefundByOrderNo($field_refund, ["order_id" => $order_id]);
if (count($refundData) > 0) { if (count($refundData) > 0) {
foreach ($refundData as $k => $v) { foreach ($refundData as $k => $v) {
$v["step_name"] = "refund"; $v["step_name"] = "refund";
$v["img_path"] = CHAT_IMG_URL; $v["img_path"] = CHAT_IMG_URL;
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -563,7 +579,7 @@ class OrderLogService ...@@ -563,7 +579,7 @@ class OrderLogService
//成交报告 //成交报告
$field_bargain = "a.id,a.father_id,a.house_number,a.is_open,a.report_id,a.order_id,a.trade_type,a.submit_agent_id,a.industry_type, $field_bargain = "a.id,a.father_id,a.house_number,a.is_open,a.report_id,a.order_id,a.trade_type,a.submit_agent_id,a.industry_type,
a.estimated_receipt_date,a.submit_agent_name, a.price,a.commission,a.role,a.agent_id,a.scale,a.scale_fee,a.create_time,b.name,b.phone,a.is_commission"; a.estimated_receipt_date,a.submit_agent_name, a.price,a.commission,a.role,a.agent_id,a.scale,a.scale_fee,a.create_time,b.name,b.phone,a.is_commission";
$bargainData = $oBargainModel->selectBargainListByOrderNo($field_bargain, ["order_id" => $order_id]); $bargainData = $oBargainModel->selectBargainListByOrderNo($field_bargain, ["order_id" => $order_id]);
if (count($bargainData) > 0) { if (count($bargainData) > 0) {
$bargain_data_arr = $this->arr2TreeBargain($bargainData); $bargain_data_arr = $this->arr2TreeBargain($bargainData);
foreach ($bargain_data_arr as $k2 => $v2) { foreach ($bargain_data_arr as $k2 => $v2) {
...@@ -586,18 +602,18 @@ class OrderLogService ...@@ -586,18 +602,18 @@ class OrderLogService
public function selectListByOrderNo($order_id) public function selectListByOrderNo($order_id)
{ {
$result = []; $result = [];
$sort = 0; $sort = 0;
//todo 1.验证订单是否存在 //todo 1.验证订单是否存在
$orderModel = new OrderModel(); $orderModel = new OrderModel();
$oReportModel = new OReportModel(); $oReportModel = new OReportModel();
$oMarchInModel = new OMarchInModel(); $oMarchInModel = new OMarchInModel();
$followUpLogModel = new FollowUpLogModel(); $followUpLogModel = new FollowUpLogModel();
$oPayLogModel = new OPayLogModel(); $oPayLogModel = new OPayLogModel();
$oRefundModel = new ORefundModel(); $oRefundModel = new ORefundModel();
$oBargainModel = new OBargainModel(); $oBargainModel = new OBargainModel();
$oPayLogAdjustmentModel = new OPayLogAdjustment(); $oPayLogAdjustmentModel = new OPayLogAdjustment();
$oRefundLogModel = new ORefundLogModel(); $oRefundLogModel = new ORefundLogModel();
$orderData = $orderModel->selectOrderByOrderId("a.f_id,a.house_title,b.internal_address", ["order_id" => $order_id]); $orderData = $orderModel->selectOrderByOrderId("a.f_id,a.house_title,b.internal_address", ["order_id" => $order_id]);
...@@ -615,19 +631,19 @@ class OrderLogService ...@@ -615,19 +631,19 @@ class OrderLogService
return ["101", "报备记录未找到"]; return ["101", "报备记录未找到"];
} }
//报备 //报备
$reportData[0]["step_name"] = "report"; $reportData[0]["step_name"] = "report";
$reportData[0]["house_title"] = $orderData[0]["house_title"]; $reportData[0]["house_title"] = $orderData[0]["house_title"];
$reportData[0]["internal_address"] = $orderData[0]["internal_address"]; $reportData[0]["internal_address"] = $orderData[0]["internal_address"];
$result[$sort++] = $reportData[0]; $result[$sort++] = $reportData[0];
//进场 march in //进场 march in
$field_march_in = "id,reception_id,reception_name,report_id,order_no,march_in_remark,march_in_img,march_in_area,create_time"; $field_march_in = "id,reception_id,reception_name,report_id,order_no,march_in_remark,march_in_img,march_in_area,create_time";
$marchInData = $oMarchInModel->selectMarchInByOrderNo($field_march_in, ["order_id" => $order_id]); $marchInData = $oMarchInModel->selectMarchInByOrderNo($field_march_in, ["order_id" => $order_id]);
if (count($marchInData) > 0) { if (count($marchInData) > 0) {
foreach ($marchInData as $k => $v) { foreach ($marchInData as $k => $v) {
$v["step_name"] = "march_in"; $v["step_name"] = "march_in";
$v["img_path"] = CHAT_IMG_URL; $v["img_path"] = CHAT_IMG_URL;
$v["img"] = $this->getOImg($v["id"], 1); $v["img"] = $this->getOImg($v["id"], 1);
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -638,9 +654,9 @@ class OrderLogService ...@@ -638,9 +654,9 @@ class OrderLogService
if (count($followUpLogData) > 0) { if (count($followUpLogData) > 0) {
foreach ($followUpLogData as $k => $v) { foreach ($followUpLogData as $k => $v) {
$v["step_name"] = "follow_up_log"; $v["step_name"] = "follow_up_log";
$v = $this->convertFollowUp($v); $v = $this->convertFollowUp($v);
$v["img_path"] = CHAT_IMG_URL; $v["img_path"] = CHAT_IMG_URL;
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -648,12 +664,12 @@ class OrderLogService ...@@ -648,12 +664,12 @@ class OrderLogService
//收款 //收款
$field_pay_log = "id,order_no,father_id,order_id,agent_id,agent_name,type,pay_type,money,house_number,industry_type, $field_pay_log = "id,order_no,father_id,order_id,agent_id,agent_name,type,pay_type,money,house_number,industry_type,
remark,transfer_img,real_money,source,create_time,is_dividend,last_transfer_time,receipt_number,transfer_name,income_time"; remark,transfer_img,real_money,source,create_time,is_dividend,last_transfer_time,receipt_number,transfer_name,income_time";
$payLogData = $oPayLogModel->selectPayLogByOrderNo($field_pay_log, ["order_id" => $order_id]); $payLogData = $oPayLogModel->selectPayLogByOrderNo($field_pay_log, ["order_id" => $order_id]);
if (count($payLogData) > 0) { if (count($payLogData) > 0) {
$sortPayLogData = $this->arr2tree($payLogData); $sortPayLogData = $this->arr2tree($payLogData);
foreach ($sortPayLogData as $k => $v) { foreach ($sortPayLogData as $k => $v) {
$v["step_name"] = "pay_log"; $v["step_name"] = "pay_log";
$v["img_path"] = CHAT_IMG_URL; $v["img_path"] = CHAT_IMG_URL;
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -662,12 +678,12 @@ class OrderLogService ...@@ -662,12 +678,12 @@ class OrderLogService
$field_refund = "a.id,a.report_id,a.agent_id,a.agent_name,a.order_no,a.order_id,a.refund_money,a.status,a.name $field_refund = "a.id,a.report_id,a.agent_id,a.agent_name,a.order_no,a.order_id,a.refund_money,a.status,a.name
,a.phone,a.bank,a.card_no, a.remark,a.receipt_number,a.type,a.refund_cause,a.pay_log_id,a.refund_way, ,a.phone,a.bank,a.card_no, a.remark,a.receipt_number,a.type,a.refund_cause,a.pay_log_id,a.refund_way,
a.create_time,b.income_time"; a.create_time,b.income_time";
$refundData = $oRefundModel->selectRefundDetailByOrderNo($field_refund, ["order_id" => $order_id, 'del'=>0]); $refundData = $oRefundModel->selectRefundDetailByOrderNo($field_refund, ["order_id" => $order_id, 'del' => 0]);
if (count($refundData) > 0) { if (count($refundData) > 0) {
foreach ($refundData as $k => $v) { foreach ($refundData as $k => $v) {
$v["step_name"] = "refund"; $v["step_name"] = "refund";
$v["img_path"] = CHAT_IMG_URL; $v["img_path"] = CHAT_IMG_URL;
$v["img"] = $this->getOImg($v["id"], 3); $v["img"] = $this->getOImg($v["id"], 3);
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -675,7 +691,7 @@ class OrderLogService ...@@ -675,7 +691,7 @@ class OrderLogService
//成交报告 //成交报告
$field_bargain = "a.id,a.father_id,a.house_number,a.is_open,a.report_id,a.order_id,a.trade_type,a.submit_agent_id,a.industry_type, $field_bargain = "a.id,a.father_id,a.house_number,a.is_open,a.report_id,a.order_id,a.trade_type,a.submit_agent_id,a.industry_type,
a.estimated_receipt_date,a.submit_agent_name, a.price,a.commission,a.role,a.agent_id,a.scale,a.scale_fee,a.create_time,b.name,b.phone,a.is_commission"; a.estimated_receipt_date,a.submit_agent_name, a.price,a.commission,a.role,a.agent_id,a.scale,a.scale_fee,a.create_time,b.name,b.phone,a.is_commission";
$bargainData = $oBargainModel->selectBargainListByOrderNo($field_bargain, ["order_id" => $order_id, 'status'=> ['<>', 30]]); $bargainData = $oBargainModel->selectBargainListByOrderNo($field_bargain, ["order_id" => $order_id, 'status' => ['<>', 30]]);
if (count($bargainData) > 0) { if (count($bargainData) > 0) {
$bargain_data_arr = $this->arr2TreeBargain($bargainData); $bargain_data_arr = $this->arr2TreeBargain($bargainData);
foreach ($bargain_data_arr as $k2 => $v2) { foreach ($bargain_data_arr as $k2 => $v2) {
...@@ -685,7 +701,7 @@ class OrderLogService ...@@ -685,7 +701,7 @@ class OrderLogService
} }
//调整 //调整
$field_adjustment = "a.id,a.paylog_id,a.new_paylog_id,d.order_id,a.type,a.money,a.create_time,a.update_time,c.name"; $field_adjustment = "a.id,a.paylog_id,a.new_paylog_id,d.order_id,a.type,a.money,a.create_time,a.update_time,c.name";
$adjustmentData = $oPayLogAdjustmentModel->getAdjustmentListByOrderId($field_adjustment, ["order_id" => $order_id, 'is_del'=>0]); $adjustmentData = $oPayLogAdjustmentModel->getAdjustmentListByOrderId($field_adjustment, ["order_id" => $order_id, 'is_del' => 0]);
if (count($adjustmentData) > 0) { if (count($adjustmentData) > 0) {
foreach ($adjustmentData as $k2 => $v2) { foreach ($adjustmentData as $k2 => $v2) {
$v2["step_name"] = "adjustment"; $v2["step_name"] = "adjustment";
...@@ -693,16 +709,16 @@ class OrderLogService ...@@ -693,16 +709,16 @@ class OrderLogService
} }
} }
//退款审核 //退款审核
$field_turn_down = "id,refund_id,status,remark,operation_id,operation_name,create_time"; $field_turn_down = "id,refund_id,status,remark,operation_id,operation_name,create_time";
$turn_down["order_id"] = $order_id; $turn_down["order_id"] = $order_id;
$turn_down["status"] = array("in", ("2,4")); $turn_down["status"] = array("in", ("2,4"));
$turn_down["is_del"] = 0; $turn_down["is_del"] = 0;
$turnDownData = $oRefundLogModel->getListAll($field_turn_down, $turn_down); $turnDownData = $oRefundLogModel->getListAll($field_turn_down, $turn_down);
if (count($turnDownData) > 0) { if (count($turnDownData) > 0) {
foreach ($turnDownData as $k2 => $v2) { foreach ($turnDownData as $k2 => $v2) {
$v2["step_name"] = "refund_check"; $v2["step_name"] = "refund_check";
$v2["img_path"] = CHAT_IMG_URL; $v2["img_path"] = CHAT_IMG_URL;
$v2["img"] = $this->getOImg($v2["id"], 4); $v2["img"] = $this->getOImg($v2["id"], 4);
$result[$sort++] = $v2; $result[$sort++] = $v2;
} }
} }
...@@ -712,10 +728,10 @@ class OrderLogService ...@@ -712,10 +728,10 @@ class OrderLogService
public function getOImg($id, $img_type) public function getOImg($id, $img_type)
{ {
//查询图片 //查询图片
$oImgModel = new OImg(); $oImgModel = new OImg();
$params["img_id"] = $id; $params["img_id"] = $id;
$params["img_type"] = $img_type; $params["img_type"] = $img_type;
$img_arr = $oImgModel->getImgList($params); $img_arr = $oImgModel->getImgList($params);
return $img_arr; return $img_arr;
} }
...@@ -732,12 +748,12 @@ class OrderLogService ...@@ -732,12 +748,12 @@ class OrderLogService
} }
foreach ($tree as $i => $v) { foreach ($tree as $i => $v) {
//查询图片 //查询图片
$oImgModel = new OImg(); $oImgModel = new OImg();
$params["img_id"] = $v[0]["father_id"]; $params["img_id"] = $v[0]["father_id"];
$params["img_type"] = 2; $params["img_type"] = 2;
$img_arr = $oImgModel->getImgList($params); $img_arr = $oImgModel->getImgList($params);
$trees[$i]["img"] = $img_arr; $trees[$i]["img"] = $img_arr;
$trees[$i]["list"] = $v; $trees[$i]["list"] = $v;
$trees[$i]["create_time"] = $v[0]["create_time"]; $trees[$i]["create_time"] = $v[0]["create_time"];
} }
...@@ -763,12 +779,12 @@ class OrderLogService ...@@ -763,12 +779,12 @@ class OrderLogService
foreach ($list as $k => $v) { foreach ($list as $k => $v) {
$tree[$v["father_id"]]['create_time'] = $v['create_time']; $tree[$v["father_id"]]['create_time'] = $v['create_time'];
if ($v['father_id'] == $v['id']) { if ($v['father_id'] == $v['id']) {
$tree[$v["father_id"]]['trade_type'] = $v['trade_type']; $tree[$v["father_id"]]['trade_type'] = $v['trade_type'];
$tree[$v["father_id"]]['house_number'] = $v['house_number']; $tree[$v["father_id"]]['house_number'] = $v['house_number'];
$tree[$v["father_id"]]['industry_type'] = $v['industry_type']; $tree[$v["father_id"]]['industry_type'] = $v['industry_type'];
$tree[$v["father_id"]]['price'] = $v['price']; $tree[$v["father_id"]]['price'] = $v['price'];
$tree[$v["father_id"]]['commission'] = $v['commission']; $tree[$v["father_id"]]['commission'] = $v['commission'];
$tree[$v["father_id"]]['is_open'] = $v['is_open']; $tree[$v["father_id"]]['is_open'] = $v['is_open'];
} }
$tree[$v["father_id"]]['list_array'][] = $v; $tree[$v["father_id"]]['list_array'][] = $v;
...@@ -791,24 +807,24 @@ class OrderLogService ...@@ -791,24 +807,24 @@ class OrderLogService
public function selectListByUserId($user_id, $search = "", $site_id) public function selectListByUserId($user_id, $search = "", $site_id)
{ {
$result = []; $result = [];
$sort = 0; $sort = 0;
//todo 1.验证订单是否存在 //todo 1.验证订单是否存在
$oReportModel = new OReportModel(); $oReportModel = new OReportModel();
$oMarchInModel = new OMarchInModel(); $oMarchInModel = new OMarchInModel();
$followUpLogModel = new FollowUpLogModel(); $followUpLogModel = new FollowUpLogModel();
$oPayLogModel = new OPayLogModel(); $oPayLogModel = new OPayLogModel();
$oRefundModel = new ORefundModel(); $oRefundModel = new ORefundModel();
$oBargainModel = new OBargainModel(); $oBargainModel = new OBargainModel();
$uPhoneFollowModel = new UPhoneFollowUp($site_id); $uPhoneFollowModel = new UPhoneFollowUp($site_id);
$uPhoneFollowTempModel = new UPhoneFollowUpTemporary($site_id); $uPhoneFollowTempModel = new UPhoneFollowUpTemporary($site_id);
//电话跟进 //电话跟进
$userParams["user_id"] = $user_id; $userParams["user_id"] = $user_id;
$userParams["type"] = 0; //电话跟进 $userParams["type"] = 0; //电话跟进
$field_user_follow = "a.id,a.content,a.user_id,a.agent_id,a.type,a.create_time,a.user_status,b.name,b.phone,b.img,c.store_name"; $field_user_follow = "a.id,a.content,a.user_id,a.agent_id,a.type,a.create_time,a.user_status,b.name,b.phone,b.img,c.store_name";
$bargainData = $uPhoneFollowModel->getFollowUpListByUserId($field_user_follow, $userParams); $bargainData = $uPhoneFollowModel->getFollowUpListByUserId($field_user_follow, $userParams);
$bargainDataTemp = $uPhoneFollowTempModel->getFollowUpListByUserId($field_user_follow, $userParams); $bargainDataTemp = $uPhoneFollowTempModel->getFollowUpListByUserId($field_user_follow, $userParams);
if (count($bargainDataTemp) > 0) { if (count($bargainDataTemp) > 0) {
foreach ($bargainDataTemp as $k => $v) { foreach ($bargainDataTemp as $k => $v) {
$type = "无效"; $type = "无效";
...@@ -818,7 +834,7 @@ class OrderLogService ...@@ -818,7 +834,7 @@ class OrderLogService
$type = "已租"; $type = "已租";
} }
$v["step_name"] = "phone_follow_up"; $v["step_name"] = "phone_follow_up";
$v["step"] = "电话跟进:" . $v['content'] . "【" . $type . "】"; $v["step"] = "电话跟进:" . $v['content'] . "【" . $type . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
} }
...@@ -832,15 +848,15 @@ class OrderLogService ...@@ -832,15 +848,15 @@ class OrderLogService
$type = "已租"; $type = "已租";
} }
$v["step_name"] = "phone_follow_up"; $v["step_name"] = "phone_follow_up";
$v["step"] = "电话跟进:" . $v['content'] . "【" . $type . "】"; $v["step"] = "电话跟进:" . $v['content'] . "【" . $type . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
//跟进 //跟进
$userParams["type"] = 1; //普通跟进 $userParams["type"] = 1; //普通跟进
$bargainData = $uPhoneFollowModel->getFollowUpListByUserId($field_user_follow, $userParams); $bargainData = $uPhoneFollowModel->getFollowUpListByUserId($field_user_follow, $userParams);
$bargainDataTemp = $uPhoneFollowTempModel->getFollowUpListByUserId($field_user_follow, $userParams); $bargainDataTemp = $uPhoneFollowTempModel->getFollowUpListByUserId($field_user_follow, $userParams);
if (count($bargainDataTemp) > 0) { if (count($bargainDataTemp) > 0) {
foreach ($bargainDataTemp as $k => $v) { foreach ($bargainDataTemp as $k => $v) {
$type = "无效"; $type = "无效";
...@@ -850,8 +866,8 @@ class OrderLogService ...@@ -850,8 +866,8 @@ class OrderLogService
$type = "已租"; $type = "已租";
} }
$v["step_name"] = "follow_up"; $v["step_name"] = "follow_up";
$v["step"] = "跟进:" . $v['content'] . "【" . $type . "】"; $v["step"] = "跟进:" . $v['content'] . "【" . $type . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -864,8 +880,8 @@ class OrderLogService ...@@ -864,8 +880,8 @@ class OrderLogService
$type = "已租"; $type = "已租";
} }
$v["step_name"] = "follow_up"; $v["step_name"] = "follow_up";
$v["step"] = "跟进:" . $v['content'] . "【" . $type . "】"; $v["step"] = "跟进:" . $v['content'] . "【" . $type . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -881,8 +897,8 @@ class OrderLogService ...@@ -881,8 +897,8 @@ class OrderLogService
foreach ($reportData as $k => $v) { foreach ($reportData as $k => $v) {
$v["step_name"] = "report"; $v["step_name"] = "report";
//$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***"; //$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***";
$house_title = $v['house_title']; $house_title = $v['house_title'];
$v["step"] = "报备【id:" . $v['house_id'] . " " . $house_title . "】"; $v["step"] = "报备【id:" . $v['house_id'] . " " . $house_title . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
$order_ids .= $v["order_id"] . ","; $order_ids .= $v["order_id"] . ",";
...@@ -890,52 +906,52 @@ class OrderLogService ...@@ -890,52 +906,52 @@ class OrderLogService
$report_ids .= $v["id"] . ","; $report_ids .= $v["id"] . ",";
} }
$order_ids = rtrim($order_ids, ","); $order_ids = rtrim($order_ids, ",");
$report_ids = rtrim($report_ids, ","); $report_ids = rtrim($report_ids, ",");
$orderParams["order_id"] = array("in", $order_ids); $orderParams["order_id"] = array("in", $order_ids);
$orderParams["house_title"] = array("like", "%" . trim($search) . "%"); $orderParams["house_title"] = array("like", "%" . trim($search) . "%");
$reportParams["report_id"] = array("in", $report_ids); $reportParams["report_id"] = array("in", $report_ids);
//进场 march in //进场 march in
$field_march_in = "a.id,a.reception_id,a.create_time,b.id as order_id,b.house_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name"; $field_march_in = "a.id,a.reception_id,a.create_time,b.id as order_id,b.house_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name";
$marchInData = $oMarchInModel->getMarchInListByOrderId($field_march_in, $orderParams); $marchInData = $oMarchInModel->getMarchInListByOrderId($field_march_in, $orderParams);
if (count($marchInData) > 0) { if (count($marchInData) > 0) {
foreach ($marchInData as $k => $v) { foreach ($marchInData as $k => $v) {
$v["step_name"] = "march_in"; $v["step_name"] = "march_in";
//$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***"; //$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***";
$house_title = $v['house_title']; $house_title = $v['house_title'];
$v["step"] = "进场【id:" . $v['house_id'] . " " . $house_title . "】"; $v["step"] = "进场【id:" . $v['house_id'] . " " . $house_title . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
//跟进 20190112产品沟通去掉这块 //跟进 20190112产品沟通去掉这块
/* $field_follow_up = "a.id,a.agent_id,a.agent_name,a.user_type,a.decision_maker,a.industry_type,a.area_requirement,a.price_requirement,a.province,a.city, /* $field_follow_up = "a.id,a.agent_id,a.agent_name,a.user_type,a.decision_maker,a.industry_type,a.area_requirement,a.price_requirement,a.province,a.city,
a.district,a.business_area,a.explain,a.explain_img,a.create_time,b.name,b.img,c.store_name"; a.district,a.business_area,a.explain,a.explain_img,a.create_time,b.name,b.img,c.store_name";
$followUpLogData = $followUpLogModel->getFollowUpByOrderId($field_follow_up, $reportParams); $followUpLogData = $followUpLogModel->getFollowUpByOrderId($field_follow_up, $reportParams);
if (count($followUpLogData) > 0) { if (count($followUpLogData) > 0) {
foreach ($followUpLogData as $k => $v) { foreach ($followUpLogData as $k => $v) {
$v["step_name"] = "follow_up_log"; $v["step_name"] = "follow_up_log";
$v["step"] = "跟进"; $v["step"] = "跟进";
$v = $this->convertFollowUp($v); $v = $this->convertFollowUp($v);
$v["img_path"] = CHAT_IMG_URL; $v["img_path"] = CHAT_IMG_URL;
$v["explain_img"] = $v["explain_img"]; $v["explain_img"] = $v["explain_img"];
$result[$sort++] = $v; $result[$sort++] = $v;
} }
}*/ }*/
//收款 //收款
$field_pay_log = "a.id,a.create_time,b.id as order_id,b.house_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name"; $field_pay_log = "a.id,a.create_time,b.id as order_id,b.house_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name";
$payLogData = $oPayLogModel->getPayLogByOrderId($field_pay_log, $orderParams); $payLogData = $oPayLogModel->getPayLogByOrderId($field_pay_log, $orderParams);
if (count($payLogData) > 0) { if (count($payLogData) > 0) {
foreach ($payLogData as $k => $v) { foreach ($payLogData as $k => $v) {
$v["step_name"] = "pay_log"; $v["step_name"] = "pay_log";
//$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***"; //$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***";
$house_title = $v['house_title']; $house_title = $v['house_title'];
$v["step"] = "收款【id:" . $v['house_id'] . " " . $house_title . "】"; $v["step"] = "收款【id:" . $v['house_id'] . " " . $house_title . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -949,21 +965,21 @@ class OrderLogService ...@@ -949,21 +965,21 @@ class OrderLogService
foreach ($refundData as $k => $v) { foreach ($refundData as $k => $v) {
$v["step_name"] = "refund"; $v["step_name"] = "refund";
//$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***"; //$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***";
$house_title = $v['house_title']; $house_title = $v['house_title'];
$v["step"] = "退款【id:" . $v['house_id'] . " " . $house_title . "】"; $v["step"] = "退款【id:" . $v['house_id'] . " " . $house_title . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
//成交报告 //成交报告
$field_bargain = "a.id,a.create_time,a.house_number,a.is_open,b.id as order_id,b.house_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name"; $field_bargain = "a.id,a.create_time,a.house_number,a.is_open,b.id as order_id,b.house_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name";
$bargainData = $oBargainModel->getBargainByOrderId($field_bargain, $orderParams); $bargainData = $oBargainModel->getBargainByOrderId($field_bargain, $orderParams);
if (count($bargainData) > 0) { if (count($bargainData) > 0) {
foreach ($bargainData as $k => $v) { foreach ($bargainData as $k => $v) {
$v["step_name"] = "bargain"; $v["step_name"] = "bargain";
//$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***"; //$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***";
$house_title = $v['house_title']; $house_title = $v['house_title'];
$v["step"] = "成交报告【id:" . $v['house_id'] . " " . $house_title . "】"; $v["step"] = "成交报告【id:" . $v['house_id'] . " " . $house_title . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -983,25 +999,25 @@ class OrderLogService ...@@ -983,25 +999,25 @@ class OrderLogService
public function selectListByUserIdAndSiteId($user_id, $search = "", $site_id) public function selectListByUserIdAndSiteId($user_id, $search = "", $site_id)
{ {
$result = []; $result = [];
$sort = 0; $sort = 0;
//todo 1.验证订单是否存在 //todo 1.验证订单是否存在
$oReportModel = new OReportModel(); $oReportModel = new OReportModel();
$oMarchInModel = new OMarchInModel(); $oMarchInModel = new OMarchInModel();
$followUpLogModel = new FollowUpLogModel(); $followUpLogModel = new FollowUpLogModel();
$oPayLogModel = new OPayLogModel(); $oPayLogModel = new OPayLogModel();
$oRefundModel = new ORefundModel(); $oRefundModel = new ORefundModel();
$oBargainModel = new OBargainModel(); $oBargainModel = new OBargainModel();
$appointWatchShopModel = new AppointWatchShop(); $appointWatchShopModel = new AppointWatchShop();
//客户c端提交预约看铺 //客户c端提交预约看铺
$field_appoint = "a.id,a.create_time,b.user_name as name"; $field_appoint = "a.id,a.create_time,b.user_name as name";
$appointData = $appointWatchShopModel->getAppointWatchOur(1,15,"a.id desc",$field_appoint,["a.user_id"=>$user_id]); $appointData = $appointWatchShopModel->getAppointWatchOur(1, 15, "a.id desc", $field_appoint, ["a.user_id" => $user_id]);
if (count($appointData) > 0) { if (count($appointData) > 0) {
foreach ($appointData as $k => $v) { foreach ($appointData as $k => $v) {
$v["step_name"] = "appoint"; $v["step_name"] = "appoint";
$v["step"] = "提交预约看铺"; $v["step"] = "提交预约看铺";
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -1011,7 +1027,7 @@ class OrderLogService ...@@ -1011,7 +1027,7 @@ class OrderLogService
$reportData = $oReportModel->selectReportByUserId($field_report, ["user_id" => $user_id]); $reportData = $oReportModel->selectReportByUserId($field_report, ["user_id" => $user_id]);
if (count($appointData) > 0 && count($reportData) <= 0) { if (count($appointData) > 0 && count($reportData) <= 0) {
return $this->sortByTime($result); return $this->sortByTime($result);
}elseif(count($appointData) <= 0 && count($reportData) <= 0){ } elseif (count($appointData) <= 0 && count($reportData) <= 0) {
return []; return [];
} }
...@@ -1021,8 +1037,8 @@ class OrderLogService ...@@ -1021,8 +1037,8 @@ class OrderLogService
foreach ($reportData as $k => $v) { foreach ($reportData as $k => $v) {
$v["step_name"] = "report"; $v["step_name"] = "report";
//$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***"; //$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***";
$house_title = $v['house_title']; $house_title = $v['house_title'];
$v["step"] = "报备【id:" . $v['house_id'] . " " . $house_title . "】"; $v["step"] = "报备【id:" . $v['house_id'] . " " . $house_title . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
$order_ids .= $v["order_id"] . ","; $order_ids .= $v["order_id"] . ",";
...@@ -1030,9 +1046,9 @@ class OrderLogService ...@@ -1030,9 +1046,9 @@ class OrderLogService
$report_ids .= $v["id"] . ","; $report_ids .= $v["id"] . ",";
} }
$order_ids = rtrim($order_ids, ","); $order_ids = rtrim($order_ids, ",");
$report_ids = rtrim($report_ids, ","); $report_ids = rtrim($report_ids, ",");
$orderParams["order_id"] = array("in", $order_ids); $orderParams["order_id"] = array("in", $order_ids);
$orderParams["house_title"] = array("like", "%" . trim($search) . "%"); $orderParams["house_title"] = array("like", "%" . trim($search) . "%");
$reportParams["report_id"] = array("in", $report_ids); $reportParams["report_id"] = array("in", $report_ids);
...@@ -1040,13 +1056,13 @@ class OrderLogService ...@@ -1040,13 +1056,13 @@ class OrderLogService
//进场 march in //进场 march in
$field_march_in = "a.id,a.reception_id,a.create_time,b.id as order_id,b.house_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name"; $field_march_in = "a.id,a.reception_id,a.create_time,b.id as order_id,b.house_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name";
$marchInData = $oMarchInModel->getMarchInListByOrderId($field_march_in, $orderParams); $marchInData = $oMarchInModel->getMarchInListByOrderId($field_march_in, $orderParams);
if (count($marchInData) > 0) { if (count($marchInData) > 0) {
foreach ($marchInData as $k => $v) { foreach ($marchInData as $k => $v) {
$v["step_name"] = "march_in"; $v["step_name"] = "march_in";
//$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***"; //$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***";
$house_title = $v['house_title']; $house_title = $v['house_title'];
$v["step"] = "进场【id:" . $v['house_id'] . " " . $house_title . "】"; $v["step"] = "进场【id:" . $v['house_id'] . " " . $house_title . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -1059,24 +1075,24 @@ class OrderLogService ...@@ -1059,24 +1075,24 @@ class OrderLogService
if (count($followUpLogData) > 0) { if (count($followUpLogData) > 0) {
foreach ($followUpLogData as $k => $v) { foreach ($followUpLogData as $k => $v) {
$v["step_name"] = "follow_up_log"; $v["step_name"] = "follow_up_log";
$v["step"] = "跟进"; $v["step"] = "跟进";
$v = $this->convertFollowUp($v); $v = $this->convertFollowUp($v);
$v["img_path"] = CHAT_IMG_URL; $v["img_path"] = CHAT_IMG_URL;
$v["explain_img"] = $v["explain_img"]; $v["explain_img"] = $v["explain_img"];
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
//收款 //收款
$field_pay_log = "a.id,a.create_time,b.id as order_id,b.house_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name"; $field_pay_log = "a.id,a.create_time,b.id as order_id,b.house_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name";
$payLogData = $oPayLogModel->getPayLogByOrderId($field_pay_log, $orderParams); $payLogData = $oPayLogModel->getPayLogByOrderId($field_pay_log, $orderParams);
if (count($payLogData) > 0) { if (count($payLogData) > 0) {
foreach ($payLogData as $k => $v) { foreach ($payLogData as $k => $v) {
$v["step_name"] = "pay_log"; $v["step_name"] = "pay_log";
//$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***"; //$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***";
$house_title = $v['house_title']; $house_title = $v['house_title'];
$v["step"] = "收款【id:" . $v['house_id'] . " " . $house_title . "】"; $v["step"] = "收款【id:" . $v['house_id'] . " " . $house_title . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -1090,21 +1106,21 @@ class OrderLogService ...@@ -1090,21 +1106,21 @@ class OrderLogService
foreach ($refundData as $k => $v) { foreach ($refundData as $k => $v) {
$v["step_name"] = "refund"; $v["step_name"] = "refund";
//$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***"; //$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***";
$house_title = $v['house_title']; $house_title = $v['house_title'];
$v["step"] = "退款【id:" . $v['house_id'] . " " . $house_title . "】"; $v["step"] = "退款【id:" . $v['house_id'] . " " . $house_title . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
//成交报告 //成交报告
$field_bargain = "a.id,a.create_time,a.house_number,a.is_open,b.id as order_id,b.house_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name"; $field_bargain = "a.id,a.create_time,a.house_number,a.is_open,b.id as order_id,b.house_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name";
$bargainData = $oBargainModel->getBargainByOrderId($field_bargain, $orderParams); $bargainData = $oBargainModel->getBargainByOrderId($field_bargain, $orderParams);
if (count($bargainData) > 0) { if (count($bargainData) > 0) {
foreach ($bargainData as $k => $v) { foreach ($bargainData as $k => $v) {
$v["step_name"] = "bargain"; $v["step_name"] = "bargain";
//$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***"; //$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***";
$house_title = $v['house_title']; $house_title = $v['house_title'];
$v["step"] = "成交报告【id:" . $v['house_id'] . " " . $house_title . "】"; $v["step"] = "成交报告【id:" . $v['house_id'] . " " . $house_title . "】";
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -1123,17 +1139,17 @@ class OrderLogService ...@@ -1123,17 +1139,17 @@ class OrderLogService
public function selectListByHouseId($house_id) public function selectListByHouseId($house_id)
{ {
$result = []; $result = [];
$sort = 0; $sort = 0;
$gHousesFollowModel = new GHousesFollowUp(); $gHousesFollowModel = new GHousesFollowUp();
//楼盘跟进 //楼盘跟进
$field_shop_follow_up = "a.id,a.follow_up_info,a.agent_id,a.create_time,b.name as agent_name,b.img,c.store_name"; $field_shop_follow_up = "a.id,a.follow_up_info,a.agent_id,a.create_time,b.name as agent_name,b.img,c.store_name";
$houseFollowUpData = $gHousesFollowModel->getShopFollowUpList($field_shop_follow_up, ["house_id" => $house_id]); $houseFollowUpData = $gHousesFollowModel->getShopFollowUpList($field_shop_follow_up, ["house_id" => $house_id]);
if (count($houseFollowUpData) > 0) { if (count($houseFollowUpData) > 0) {
foreach ($houseFollowUpData as $k => $v) { foreach ($houseFollowUpData as $k => $v) {
$v["step_name"] = "shop_follow_up"; $v["step_name"] = "shop_follow_up";
$v["step"] = "跟进:" . $v["follow_up_info"]; $v["step"] = "跟进:" . $v["follow_up_info"];
$result[$sort++] = $v; $result[$sort++] = $v;
} }
} }
...@@ -1214,8 +1230,8 @@ class OrderLogService ...@@ -1214,8 +1230,8 @@ class OrderLogService
$item["price_requirement"] = "其他"; $item["price_requirement"] = "其他";
} }
$regions = new Regions(); $regions = new Regions();
$cityInfo = $regions->getAddressByDiscCode($item["district"]); $cityInfo = $regions->getAddressByDiscCode($item["district"]);
$item["area_detail"] = $cityInfo; $item["area_detail"] = $cityInfo;
return $item; return $item;
} }
...@@ -1231,7 +1247,7 @@ class OrderLogService ...@@ -1231,7 +1247,7 @@ class OrderLogService
for ($i = 0; $i < count($result); $i++) { for ($i = 0; $i < count($result); $i++) {
for ($j = $i + 1; $j < count($result); $j++) { for ($j = $i + 1; $j < count($result); $j++) {
if (strtotime($result[$j]["create_time"]) - strtotime($result[$i]["create_time"]) > 0) { if (strtotime($result[$j]["create_time"]) - strtotime($result[$i]["create_time"]) > 0) {
$temp = $result[$j]; $temp = $result[$j];
$result[$j] = $result[$i]; $result[$j] = $result[$i];
$result[$i] = $temp; $result[$i] = $temp;
} }
...@@ -1255,7 +1271,7 @@ class OrderLogService ...@@ -1255,7 +1271,7 @@ class OrderLogService
public function getSearchOrder($params, $pageNo, $pageSize) public function getSearchOrder($params, $pageNo, $pageSize)
{ {
$condition = $where_ = "1=1 "; $condition = $where_ = "1=1 ";
$field = "a.id,a.order_no,a.f_id as report_id,a.house_id,a.house_title,b.report_agent_id,b.report_agent_phone,b.report_agent_name, $field = "a.id,a.order_no,a.f_id as report_id,a.house_id,a.house_title,b.report_agent_id,b.report_agent_phone,b.report_agent_name,
b.user_id,b.user_phone,b.user_name,b.predict_see_time"; b.user_id,b.user_phone,b.user_name,b.predict_see_time";
switch ((int)$params["type"]) { switch ((int)$params["type"]) {
case 0: case 0:
...@@ -1289,7 +1305,7 @@ class OrderLogService ...@@ -1289,7 +1305,7 @@ class OrderLogService
return ["code" => "101", "msg" => "搜索类型错误"]; return ["code" => "101", "msg" => "搜索类型错误"];
} }
$vModel = new VerifyService(); $vModel = new VerifyService();
$agentArr = $vModel->getAgentsByAgentId($params["agent_id"]); $agentArr = $vModel->getAgentsByAgentId($params["agent_id"]);
if (empty($agentArr)) { if (empty($agentArr)) {
return ["code" => "101", "msg" => "经纪人不存在"]; return ["code" => "101", "msg" => "经纪人不存在"];
...@@ -1297,23 +1313,23 @@ class OrderLogService ...@@ -1297,23 +1313,23 @@ class OrderLogService
$where_ = $condition; $where_ = $condition;
if ($agentArr) { if ($agentArr) {
$params["report_agent_id"] = $agentArr; $params["report_agent_id"] = $agentArr;
$params["agent_id_s"] = array("in", $agentArr); $params["agent_id_s"] = array("in", $agentArr);
$condition .= " and b.report_agent_id in (" . trim($agentArr) . ") "; $condition .= " and b.report_agent_id in (" . trim($agentArr) . ") ";
} }
$caseHouseId = $vModel->getPanpartyAndExclusiveHouseIdByAgentId($params["agent_id_s"]); $caseHouseId = $vModel->getPanpartyAndExclusiveHouseIdByAgentId($params["agent_id_s"]);
$ids = ""; $ids = "";
foreach ($caseHouseId as $item) { foreach ($caseHouseId as $item) {
$ids .= $item["houses_id"] . ","; $ids .= $item["houses_id"] . ",";
} }
$ids = rtrim($ids, ","); $ids = rtrim($ids, ",");
$ids = $ids ? $ids : 0; $ids = $ids ? $ids : 0;
$where_ .= " and a.house_id in ($ids)"; $where_ .= " and a.house_id in ($ids)";
$orderModel = new OrderModel(); $orderModel = new OrderModel();
$result = $orderModel->searchOrder($field, $condition, $where_, $pageNo, $pageSize); $result = $orderModel->searchOrder($field, $condition, $where_, $pageNo, $pageSize);
$reportService = new ReportService(); $reportService = new ReportService();
return $reportService->returnResult($result); return $reportService->returnResult($result);
...@@ -1331,7 +1347,7 @@ class OrderLogService ...@@ -1331,7 +1347,7 @@ class OrderLogService
public function getSearchOrderByAll($params, $pageNo, $pageSize) public function getSearchOrderByAll($params, $pageNo, $pageSize)
{ {
$condition = $where_ = "1=1 "; $condition = $where_ = "1=1 ";
$field = "a.id,a.order_no,a.f_id as report_id,a.house_id,a.house_title,b.report_agent_id,b.report_agent_phone,b.report_agent_name, $field = "a.id,a.order_no,a.f_id as report_id,a.house_id,a.house_title,b.report_agent_id,b.report_agent_phone,b.report_agent_name,
b.user_id,b.user_phone,b.user_name,b.predict_see_time"; b.user_id,b.user_phone,b.user_name,b.predict_see_time";
switch ((int)$params["type"]) { switch ((int)$params["type"]) {
case 0: case 0:
...@@ -1367,7 +1383,7 @@ class OrderLogService ...@@ -1367,7 +1383,7 @@ class OrderLogService
$orderModel = new OrderModel(); $orderModel = new OrderModel();
$result = $orderModel->searchOrderAll($field, $condition, $pageNo, $pageSize); $result = $orderModel->searchOrderAll($field, $condition, $pageNo, $pageSize);
$reportService = new ReportService(); $reportService = new ReportService();
return $reportService->returnResult($result); return $reportService->returnResult($result);
...@@ -1384,26 +1400,26 @@ class OrderLogService ...@@ -1384,26 +1400,26 @@ class OrderLogService
public function getBargainList($params) public function getBargainList($params)
{ {
$pageNo = empty($params["page_no"]) ? 1 : $params["page_no"]; $pageNo = empty($params["page_no"]) ? 1 : $params["page_no"];
$pageSize = empty($params["page_size"]) ? 15 : $params["page_size"]; $pageSize = empty($params["page_size"]) ? 15 : $params["page_size"];
$agent_id = $params["submit_agent_id"]; $agent_id = $params["submit_agent_id"];
$aService = new VerifyService(); $aService = new VerifyService();
$ids = $aService->getAgentsByAgentId($agent_id); $ids = $aService->getAgentsByAgentId($agent_id);
$params["ids"] = $ids; $params["ids"] = $ids;
$bargainModel = new OBargainModel(); $bargainModel = new OBargainModel();
$filed = "a.id,a.father_id,a.house_number,a.price,a.commission,a.agent_id,a.create_time,b.user_phone, $filed = "a.id,a.father_id,a.house_number,a.price,a.commission,a.agent_id,a.create_time,b.user_phone,
b.user_name,b.user_id,c.id as order_id,c.order_no,d.id as house_id,d.internal_title,d.internal_address,b.id as report_id"; b.user_name,b.user_id,c.id as order_id,c.order_no,d.id as house_id,d.internal_title,d.internal_address,b.id as report_id";
$result = $bargainModel->selectBargainList($filed, $params, $pageNo, $pageSize); $result = $bargainModel->selectBargainList($filed, $params, $pageNo, $pageSize);
$list = []; $list = [];
foreach ($result as $k => $v) { foreach ($result as $k => $v) {
$father_id = $v["father_id"]; $father_id = $v["father_id"];
if ($father_id > 0 && in_array($father_id, $list)) { if ($father_id > 0 && in_array($father_id, $list)) {
unset($result[$k]); unset($result[$k]);
} else { } else {
$result[$k]["create_time"] = date("Y-m-d", strtotime($v["create_time"])); $result[$k]["create_time"] = date("Y-m-d", strtotime($v["create_time"]));
$result[$k]["id"] = $v["father_id"] == 0 ? $v["id"] : $v["father_id"]; $result[$k]["id"] = $v["father_id"] == 0 ? $v["id"] : $v["father_id"];
array_push($list, $father_id); array_push($list, $father_id);
} }
} }
...@@ -1428,17 +1444,17 @@ class OrderLogService ...@@ -1428,17 +1444,17 @@ class OrderLogService
$params["order_id"] = $order_id; $params["order_id"] = $order_id;
$bargainModel = new OBargainModel(); $bargainModel = new OBargainModel();
$filed = "a.id,a.father_id,a.price,a.house_number,a.commission,a.agent_id,a.create_time,b.user_phone,b.user_name,b.user_id,c.id as order_id, $filed = "a.id,a.father_id,a.price,a.house_number,a.commission,a.agent_id,a.create_time,b.user_phone,b.user_name,b.user_id,c.id as order_id,
d.id as house_id,d.internal_title,d.internal_address,c.order_no,a.report_id"; d.id as house_id,d.internal_title,d.internal_address,c.order_no,a.report_id";
$result = $bargainModel->selectBargainList($filed, $params,1, 15); $result = $bargainModel->selectBargainList($filed, $params, 1, 15);
$list = []; $list = [];
foreach ($result as $k => $v) { foreach ($result as $k => $v) {
$father_id = $v["father_id"]; $father_id = $v["father_id"];
if ($father_id > 0 && in_array($father_id, $list)) { if ($father_id > 0 && in_array($father_id, $list)) {
unset($result[$k]); unset($result[$k]);
} else { } else {
$result[$k]["create_time"] = date("Y-m-d", strtotime($v["create_time"])); $result[$k]["create_time"] = date("Y-m-d", strtotime($v["create_time"]));
$result[$k]["id"] = $v["father_id"] == 0 ? $v["id"] : $v["father_id"]; $result[$k]["id"] = $v["father_id"] == 0 ? $v["id"] : $v["father_id"];
array_push($list, $father_id); array_push($list, $father_id);
} }
} }
...@@ -1460,26 +1476,26 @@ class OrderLogService ...@@ -1460,26 +1476,26 @@ class OrderLogService
$item = $params[0]; $item = $params[0];
$role = !empty($params[0]["role"]) ? $params[0]["role"] : $params[0]["roles"]; $role = !empty($params[0]["role"]) ? $params[0]["role"] : $params[0]["roles"];
$cent_commission["id"] = $item["id"]; $cent_commission["id"] = $item["id"];
$cent_commission["agent_id"] = $item["agent_id"]; $cent_commission["agent_id"] = $item["agent_id"];
$cent_commission["role"] = !empty($item["role"]) ? $item["role"] : $item["roles"]; $cent_commission["role"] = !empty($item["role"]) ? $item["role"] : $item["roles"];
$cent_commission["scale"] = !empty($item["scale"]) ? $item["scale"] : $item["scales"]; $cent_commission["scale"] = !empty($item["scale"]) ? $item["scale"] : $item["scales"];
$cent_commission["name"] = $item["name"]; $cent_commission["name"] = $item["name"];
$cent_commission["phone"] = $item["phone"]; $cent_commission["phone"] = $item["phone"];
$cent_commission["should_commission"] = $item["should_commission"]; $cent_commission["should_commission"] = $item["should_commission"];
$cent_commission["scale_fee"] = $item["scale_fee"]; $cent_commission["scale_fee"] = $item["scale_fee"];
$key = 0; $key = 0;
$length = count($params); $length = count($params);
for ($j = 0; $j < $length; $j++) { for ($j = 0; $j < $length; $j++) {
$value = $params[$j]; $value = $params[$j];
if ($value["role"] == $role || $value["roles"] == $role) { if ($value["role"] == $role || $value["roles"] == $role) {
$arr["real_fee"] = $value["real_fee"]; $arr["real_fee"] = $value["real_fee"];
$arr["create_time"] = $value["create_time"]; $arr["create_time"] = $value["create_time"];
$arr["confirm_date"] = $value["confirm_date"]; $arr["confirm_date"] = $value["confirm_date"];
$arr["charity_fund"] = $value["charity_fund"]; $arr["charity_fund"] = $value["charity_fund"];
$arr["cash"] = $value["cash"]; $arr["cash"] = $value["cash"];
$arr["practical_fee"] = $value["practical_fee"]; $arr["practical_fee"] = $value["practical_fee"];
$arr["service_charge"] = $value["service_charge"]; $arr["service_charge"] = $value["service_charge"];
if (!empty($value["real_fee"]) && !empty($value["create_time"])) { //过滤掉空的 if (!empty($value["real_fee"]) && !empty($value["create_time"])) { //过滤掉空的
$cent_commission["info"][$key] = $arr; $cent_commission["info"][$key] = $arr;
...@@ -1509,12 +1525,12 @@ class OrderLogService ...@@ -1509,12 +1525,12 @@ class OrderLogService
public function getBargainDetail($params): array public function getBargainDetail($params): array
{ {
$bargainModel = new OBargainModel(); $bargainModel = new OBargainModel();
$bargain_info_filed = "a.id,a.house_number,a.account_time,a.account_statement,a.father_id,a.is_open,a.trade_type, $bargain_info_filed = "a.id,a.house_number,a.account_time,a.account_statement,a.father_id,a.is_open,a.trade_type,
a.price,a.industry_type,a.estimated_receipt_date,a.commission,c.id as house_id,c.internal_title,c.internal_address, a.price,a.industry_type,a.estimated_receipt_date,a.commission,c.id as house_id,c.internal_title,c.internal_address,
d.user_id,d.user_phone,d.user_name"; d.user_id,d.user_phone,d.user_name";
$result = []; $result = [];
$bargainInfo = $bargainModel->selectBargainDetail($bargain_info_filed, $params); $bargainInfo = $bargainModel->selectBargainDetail($bargain_info_filed, $params);
if (count($bargainInfo) <= 0) { if (count($bargainInfo) <= 0) {
...@@ -1522,11 +1538,11 @@ class OrderLogService ...@@ -1522,11 +1538,11 @@ class OrderLogService
} }
//o_real_income //o_real_income
$realIncomeModel = new ORealIncome(); $realIncomeModel = new ORealIncome();
$realIncomeArr = $realIncomeModel->getBargainTaxes($params["bargain_id"]); $realIncomeArr = $realIncomeModel->getBargainTaxes($params["bargain_id"]);
$bargainInfo[0]["realIncome"] = $realIncomeArr; $bargainInfo[0]["realIncome"] = $realIncomeArr;
$bargainInfo[0]["user_phone"] = substr_replace($bargainInfo[0]["user_phone"], '****', 3, 4); $bargainInfo[0]["user_phone"] = substr_replace($bargainInfo[0]["user_phone"], '****', 3, 4);
$result["bargainInfo"] = $bargainInfo[0]; $result["bargainInfo"] = $bargainInfo[0];
$bargain_id = $bargainInfo[0]["father_id"] == 0 ? $bargainInfo[0]["id"] : $bargainInfo[0]["father_id"]; $bargain_id = $bargainInfo[0]["father_id"] == 0 ? $bargainInfo[0]["id"] : $bargainInfo[0]["father_id"];
...@@ -1545,7 +1561,7 @@ class OrderLogService ...@@ -1545,7 +1561,7 @@ class OrderLogService
//税费 //税费
$taxesModel = new OTaxes(); $taxesModel = new OTaxes();
$fieldTaxes = "id,bargain_id,fee,total_fee,father_id,operation_date,agent_id,agent_name,scale,create_time,role"; $fieldTaxes = "id,bargain_id,fee,total_fee,father_id,operation_date,agent_id,agent_name,scale,create_time,role";
$taxesArr = $taxesModel->getBargainTaxes($bargain_id, $fieldTaxes); $taxesArr = $taxesModel->getBargainTaxes($bargain_id, $fieldTaxes);
$taxes_ = $taxes = array(); $taxes_ = $taxes = array();
foreach ($taxesArr as $items) { foreach ($taxesArr as $items) {
...@@ -1555,14 +1571,14 @@ class OrderLogService ...@@ -1555,14 +1571,14 @@ class OrderLogService
$z = 0; $z = 0;
foreach ($taxes_ as $item) { foreach ($taxes_ as $item) {
$taxes[$z]["operation_date"] = $item[0]["operation_date"]; $taxes[$z]["operation_date"] = $item[0]["operation_date"];
$taxes[$z]["total_fee"] = $item[0]["total_fee"]; $taxes[$z]["total_fee"] = $item[0]["total_fee"];
$key = 0; $key = 0;
foreach ($item as $i => $j) { foreach ($item as $i => $j) {
$taxes[$z]["info"][$key]["role"] = $j["role"]; $taxes[$z]["info"][$key]["role"] = $j["role"];
$taxes[$z]["info"][$key]["agent_name"] = $j["agent_name"]; $taxes[$z]["info"][$key]["agent_name"] = $j["agent_name"];
$taxes[$z]["info"][$key]["scale"] = $j["scale"]; $taxes[$z]["info"][$key]["scale"] = $j["scale"];
$taxes[$z]["info"][$key]["fee"] = $j["fee"]; $taxes[$z]["info"][$key]["fee"] = $j["fee"];
$key++; $key++;
} }
$z++; $z++;
...@@ -1583,10 +1599,10 @@ class OrderLogService ...@@ -1583,10 +1599,10 @@ class OrderLogService
*/ */
public function userUpdateInfo($report_id) public function userUpdateInfo($report_id)
{ {
$reportModel = new OReportModel(); $reportModel = new OReportModel();
$filed = "id,user_id"; $filed = "id,user_id";
$params["id"] = $report_id; $params["id"] = $report_id;
$result = $reportModel->selectReportById($filed, $params); $result = $reportModel->selectReportById($filed, $params);
if (count($result) > 0) { if (count($result) > 0) {
$Users = new Users(); $Users = new Users();
$Users->update_user_status(['id' => $result[0]["user_id"], 'user_status' => 1]); $Users->update_user_status(['id' => $result[0]["user_id"], 'user_status' => 1]);
...@@ -1601,43 +1617,43 @@ class OrderLogService ...@@ -1601,43 +1617,43 @@ class OrderLogService
*/ */
public function searchBargainAgents($type, $order_id) public function searchBargainAgents($type, $order_id)
{ {
$orderModel = new OrderModel(); $orderModel = new OrderModel();
$field = "a.id,a.order_no,a.house_id,a.house_title,b.id as report_id,b.user_id,c.user_nick,c.user_phone, $field = "a.id,a.order_no,a.house_id,a.house_title,b.id as report_id,b.user_id,c.user_nick,c.user_phone,
c.user_pic,c.sex"; c.user_pic,c.sex";
$where_["order_id"] = $order_id; $where_["order_id"] = $order_id;
$result = $orderModel->selectOrderDetail($field, $where_); $result = $orderModel->selectOrderDetail($field, $where_);
if (count($result) <= 0 || $result[0]["house_id"] <= 0 || $result[0]["user_id"] <= 0) { if (count($result) <= 0 || $result[0]["house_id"] <= 0 || $result[0]["user_id"] <= 0) {
return null; return null;
} }
$houseAgents = new GHousesToAgents(); $houseAgents = new GHousesToAgents();
$field = "b.id,b.phone,b.name"; $field = "b.id,b.phone,b.name";
switch ($type) {//1盘方,2客方,3反签,4独家,5合作方 switch ($type) {//1盘方,2客方,3反签,4独家,5合作方
case 1: case 1:
$params["a.houses_id"] = $result[0]["house_id"]; $params["a.houses_id"] = $result[0]["house_id"];
$params["a.type"] = 2; $params["a.type"] = 2;
$params["a.is_del"] = 0; $params["a.is_del"] = 0;
$params["b.status"] = 0; $params["b.status"] = 0;
$list = $houseAgents->getAgentsByHouseId($field, $params); $list = $houseAgents->getAgentsByHouseId($field, $params);
break; break;
case 2: case 2:
$userModel = new Users(); $userModel = new Users();
$params["a.id"] = $result[0]["user_id"]; $params["a.id"] = $result[0]["user_id"];
$params["b.status"] = 0; $params["b.status"] = 0;
$list = $userModel->getAgentByUserId($field, $params); $list = $userModel->getAgentByUserId($field, $params);
break; break;
case 3: //反签 == 报备人 case 3: //反签 == 报备人
$reportModel = new OReportModel(); $reportModel = new OReportModel();
$params["a.id"] = $result[0]["report_id"]; $params["a.id"] = $result[0]["report_id"];
$params["b.status"] = 0; $params["b.status"] = 0;
$list = $reportModel->getAgentByOrderId($field, $params); $list = $reportModel->getAgentByOrderId($field, $params);
break; break;
case 4: case 4:
$params["a.houses_id"] = $result[0]["house_id"]; $params["a.houses_id"] = $result[0]["house_id"];
$params["a.type"] = 3; $params["a.type"] = 3;
$params["a.is_del"] = 0; $params["a.is_del"] = 0;
$params["b.status"] = 0; $params["b.status"] = 0;
$list = $houseAgents->getAgentsByHouseId($field, $params); $list = $houseAgents->getAgentsByHouseId($field, $params);
break; break;
case 5: case 5:
return null; return null;
...@@ -1646,12 +1662,12 @@ class OrderLogService ...@@ -1646,12 +1662,12 @@ class OrderLogService
return null; return null;
break; break;
case 7: case 7:
$userModel = new Users(); $userModel = new Users();
$params["a.id"] = $result[0]["user_id"]; $params["a.id"] = $result[0]["user_id"];
$params["a.referrer_source"] = 20; $params["a.referrer_source"] = 20;
$params["a.status"] = 0; $params["a.status"] = 0;
$params["b.status"] = 0; $params["b.status"] = 0;
$list = $userModel->getAgentByReferrer($field, $params); $list = $userModel->getAgentByReferrer($field, $params);
break; break;
default: default:
return null; return null;
...@@ -1671,85 +1687,85 @@ class OrderLogService ...@@ -1671,85 +1687,85 @@ class OrderLogService
*/ */
public function searchBargainAllAgents($order_id) public function searchBargainAllAgents($order_id)
{ {
$orderModel = new OrderModel(); $orderModel = new OrderModel();
$field = "a.id,a.order_no,a.house_id,a.house_title,b.id as report_id,b.user_id,c.user_nick,c.user_phone, $field = "a.id,a.order_no,a.house_id,a.house_title,b.id as report_id,b.user_id,c.user_nick,c.user_phone,
c.user_pic,c.sex"; c.user_pic,c.sex";
$where_["order_id"] = $order_id; $where_["order_id"] = $order_id;
$result = $orderModel->selectOrderDetail($field, $where_); $result = $orderModel->selectOrderDetail($field, $where_);
if (count($result) <= 0 || $result[0]["house_id"] <= 0 || $result[0]["user_id"] <= 0) { if (count($result) <= 0 || $result[0]["house_id"] <= 0 || $result[0]["user_id"] <= 0) {
return null; return null;
} }
$houseAgents = new GHousesToAgents(); $houseAgents = new GHousesToAgents();
$field = "b.id,b.phone,b.name"; $field = "b.id,b.phone,b.name";
$where_house["a.houses_id"] = $result[0]["house_id"]; $where_house["a.houses_id"] = $result[0]["house_id"];
$where_house["a.type"] = ['in', '2,3']; $where_house["a.type"] = ['in', '2,3'];
$where_house["a.is_del"] = 0; $where_house["a.is_del"] = 0;
$where_house["b.status"] = 0; $where_house["b.status"] = 0;
$agent_house = $houseAgents->getAgentsByHouseId($field . ',a.type', $where_house); $agent_house = $houseAgents->getAgentsByHouseId($field . ',a.type', $where_house);
$list = []; $list = [];
$key = 0; $key = 0;
//盘方和独家 //盘方和独家
foreach ($agent_house as $v) { foreach ($agent_house as $v) {
$list[$key]['id'] = $v['id']; $list[$key]['id'] = $v['id'];
$list[$key]['phone'] = $v['phone']; $list[$key]['phone'] = $v['phone'];
$list[$key]['name'] = $v['name']; $list[$key]['name'] = $v['name'];
if ($v['type'] == 2) { if ($v['type'] == 2) {
$list[$key]['role'] = 1; $list[$key]['role'] = 1;
$list[$key]['role_name'] = '盘方'; $list[$key]['role_name'] = '盘方';
} else { } else {
$list[$key]['role'] = 4; $list[$key]['role'] = 4;
$list[$key]['role_name'] = '独家'; $list[$key]['role_name'] = '独家';
} }
$key++; $key++;
} }
$userModel = new Users(); $userModel = new Users();
$where_user["a.id"] = $result[0]["user_id"]; $where_user["a.id"] = $result[0]["user_id"];
$where_user["b.status"] = 0; $where_user["b.status"] = 0;
$user_data = $userModel->getAgentByUserId($field, $where_user); $user_data = $userModel->getAgentByUserId($field, $where_user);
//客方 //客方
if (isset($user_data[0]['id'])) { if (isset($user_data[0]['id'])) {
$list[$key]['id'] = $user_data[0]['id']; $list[$key]['id'] = $user_data[0]['id'];
$list[$key]['phone'] = $user_data[0]['phone']; $list[$key]['phone'] = $user_data[0]['phone'];
$list[$key]['name'] = $user_data[0]['name']; $list[$key]['name'] = $user_data[0]['name'];
$list[$key]['role'] = 2; $list[$key]['role'] = 2;
$list[$key]['role_name'] = '客方'; $list[$key]['role_name'] = '客方';
$key++; $key++;
} }
$reportModel = new OReportModel(); $reportModel = new OReportModel();
$params["a.id"] = $result[0]["report_id"]; $params["a.id"] = $result[0]["report_id"];
$params["b.status"] = 0; $params["b.status"] = 0;
$report_data = $reportModel->getAgentByOrderId($field, $params); $report_data = $reportModel->getAgentByOrderId($field, $params);
//反签 //反签
if (isset($report_data[0]['id'])) { if (isset($report_data[0]['id'])) {
$list[$key]['id'] = $report_data[0]['id']; $list[$key]['id'] = $report_data[0]['id'];
$list[$key]['phone'] = $report_data[0]['phone']; $list[$key]['phone'] = $report_data[0]['phone'];
$list[$key]['name'] = $report_data[0]['name']; $list[$key]['name'] = $report_data[0]['name'];
$list[$key]['role'] = 3; $list[$key]['role'] = 3;
$list[$key]['role_name'] = '反签'; $list[$key]['role_name'] = '反签';
$key++; $key++;
} }
$params["a.id"] = $result[0]["user_id"]; $params["a.id"] = $result[0]["user_id"];
$params["a.referrer_source"] = 20; $params["a.referrer_source"] = 20;
$params["a.status"] = 0; $params["a.status"] = 0;
$params["b.status"] = 0; $params["b.status"] = 0;
$referrer = $userModel->getAgentByReferrer($field, $params); $referrer = $userModel->getAgentByReferrer($field, $params);
if ($referrer[0]['id']) { if ($referrer[0]['id']) {
$list[$key]['id'] = $referrer[0]['id']; $list[$key]['id'] = $referrer[0]['id'];
$list[$key]['phone'] = $referrer[0]['phone']; $list[$key]['phone'] = $referrer[0]['phone'];
$list[$key]['name'] = $referrer[0]['name']; $list[$key]['name'] = $referrer[0]['name'];
$list[$key]['role'] = 7; $list[$key]['role'] = 7;
$list[$key]['role_name'] = 'APP客下载方'; $list[$key]['role_name'] = 'APP客下载方';
} }
...@@ -1777,18 +1793,19 @@ class OrderLogService ...@@ -1777,18 +1793,19 @@ class OrderLogService
*/ */
public function updateBillInfo($id, $trade_no, $pay_time, $real_money) public function updateBillInfo($id, $trade_no, $pay_time, $real_money)
{ {
$params["id"] = $id; $params["id"] = $id;
$params["trade_no"] = $trade_no; $params["trade_no"] = $trade_no;
$params["pay_time"] = date("Y-m-d H:i:s", $pay_time); $params["pay_time"] = date("Y-m-d H:i:s", $pay_time);
$params["real_money"] = $real_money; $params["real_money"] = $real_money;
return $this->payLogModel->updatePayLog($params); return $this->payLogModel->updatePayLog($params);
} }
public function getCommission( $bargain_id){ public function getCommission($bargain_id)
$filed = "a.role,a.agent_id,b.name,a.scale"; {
$filed = "a.role,a.agent_id,b.name,a.scale";
$params["a.id|a.father_id"] = $bargain_id; $params["a.id|a.father_id"] = $bargain_id;
$params["a.role"] = array("in","3,4,5"); $params["a.role"] = array("in", "3,4,5");
return $this->bargainModel->agentBargainAll($filed, $params); return $this->bargainModel->agentBargainAll($filed, $params);
} }
...@@ -1801,16 +1818,17 @@ class OrderLogService ...@@ -1801,16 +1818,17 @@ class OrderLogService
* @param $is_open * @param $is_open
* @return bool|int * @return bool|int
*/ */
public function updateBargainIsOpen($bargain_id, $type, $is_open) { public function updateBargainIsOpen($bargain_id, $type, $is_open)
if (empty($bargain_id) || !in_array($type, [91,92])) { {
if (empty($bargain_id) || !in_array($type, [91, 92])) {
return false; return false;
} }
if (!in_array($is_open, [0,1])) { if (!in_array($is_open, [0, 1])) {
return false; return false;
} }
$num = $this->bargainModel->updateBargainById($bargain_id, ['is_open'=>$is_open]); $num = $this->bargainModel->updateBargainById($bargain_id, ['is_open' => $is_open]);
if ($num) { if ($num) {
$result = 1; $result = 1;
} else { } else {
......
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