Commit c5b43d57 authored by zw's avatar zw

成单详情

parent 4aa55ac8
...@@ -147,13 +147,13 @@ class OrderLog extends Basic ...@@ -147,13 +147,13 @@ class OrderLog extends Basic
{ {
$params = $this->params; $params = $this->params;
if (!isset($params["submit_agent_id"]) || !isset($params["report_id"]) || !isset($params["order_id"]) || !isset($params["order_no"]) /*if (!isset($params["submit_agent_id"]) || !isset($params["report_id"]) || !isset($params["order_id"]) || !isset($params["order_no"])
|| !isset($params["trade_type"]) || !isset($params["price"]) || !isset($params["commission"]) || !isset($params["trade_type"]) || !isset($params["price"]) || !isset($params["commission"])
|| !isset($params["commission_arr"][0]["role"]) || !isset($params["commission_arr"][0]["agent_id"]) || !isset($params["commission_arr"][0]["role"]) || !isset($params["commission_arr"][0]["agent_id"])
|| !isset($params["commission_arr"][0]["scale"]) || !isset($params["commission_arr"][0]["scale_fee"])) { || !isset($params["commission_arr"][0]["scale"]) || !isset($params["commission_arr"][0]["scale_fee"])) {
return $this->response("101", "请求参数错误"); return $this->response("101", "请求参数错误");
} }*/
/* $params = array( $params = array(
"submit_agent_id" => 1,//申请经纪人id "submit_agent_id" => 1,//申请经纪人id
"report_id" => 1,//报备id "report_id" => 1,//报备id
"order_id" => 1, //关联order表id "order_id" => 1, //关联order表id
...@@ -170,7 +170,7 @@ class OrderLog extends Basic ...@@ -170,7 +170,7 @@ class OrderLog extends Basic
"commission_arr" => [ [ "role" => 10, "agent_id" => 10, "scale" => 10, "scale_fee" => 1222 ], "commission_arr" => [ [ "role" => 10, "agent_id" => 10, "scale" => 10, "scale_fee" => 1222 ],
[ "role" => 11, "agent_id" => 12, "scale" => 13, "scale_fee" => 1112 ] ], [ "role" => 11, "agent_id" => 12, "scale" => 13, "scale_fee" => 1112 ] ],
);*/ );
$is_ok = $this->service_->addBargain($params["submit_agent_id"], $params["report_id"], $params["order_id"], $params["order_no"], $is_ok = $this->service_->addBargain($params["submit_agent_id"], $params["report_id"], $params["order_id"], $params["order_no"],
$params["trade_type"], $params["price"], $params["commission"], $params["commission_arr"]); $params["trade_type"], $params["price"], $params["commission"], $params["commission_arr"]);
...@@ -284,7 +284,66 @@ class OrderLog extends Basic ...@@ -284,7 +284,66 @@ class OrderLog extends Basic
} catch (Exception $e) { } catch (Exception $e) {
return $this->response("101", "request error,msg:" . $e); return $this->response("101", "request error,msg:" . $e);
} }
}
/**
* 我的成交
* @return \think\Response
*/
public function bargainList(){
$params = $this->params;
/* $params = array(
"submit_agent_id" => 1,
"status" => 10,
"page_no" => 1,
"page_size" =>15
);*/
if(!isset($params["submit_agent_id"]) || !isset($params["status"])){
return $this->response("101","请求参数错误");
}
try {
$result = $this->service_->getBargainList($params);
if (count($result) > 0) {
return $this->response("200", "request success", $result);
} else {
return $this->response("200", "request null");
}
} catch (Exception $e) {
return $this->response("101", "request error,msg:" . $e);
}
}
/**
* 成交报告详情
* @return \think\Response
*/
public function bargainDetail(){
$params = $this->params;
$params = array(
"bargain_id" => 6,
"house_id" => 1,
"house_title"=> "wwww",
"internal_address" =>"ewewerwer",
"user_id" => 1,
"user_name" =>"nihhkkk",
"user_phone"=>"123****3333"
);
if(!isset($params["bargain_id"]) ||!isset($params["house_id"])||!isset($params["house_title"])||!isset($params["internal_address"])
||!isset($params["user_id"])||!isset($params["user_name"])||!isset($params["user_phone"])){
return $this->response("101","请求参数错误");
}
try {
$result = $this->service_->getBargainDetail($params);
if (count($result) > 0) {
return $this->response("200", "request success", $result);
} else {
return $this->response("200", "request null");
}
} catch (Exception $e) {
return $this->response("101", "request error,msg:" . $e);
}
} }
......
...@@ -46,13 +46,19 @@ class OrderLogService ...@@ -46,13 +46,19 @@ class OrderLogService
$industry_type, $remark, $transfer_img) $industry_type, $remark, $transfer_img)
{ {
$bill_arr = []; $bill_arr = [];
$father_id = 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"])) {
array_push($bill_arr, $this->collectingBillBin($collecting, $agent_id, $report_id, $order_id, $order_no, if($father_id == 0){
$house_number, $industry_type, $remark, $transfer_img)); $params = $this->collectingBillBin($father_id,$collecting, $agent_id, $report_id, $order_id, $order_no,
$house_number, $industry_type, $remark, $transfer_img);
$father_id = $this->payLogModel->insertPayLog($params);
}else{
array_push($bill_arr, $this->collectingBillBin($father_id,$collecting, $agent_id, $report_id, $order_id, $order_no,
$house_number, $industry_type, $remark, $transfer_img));
}
} }
} }
dump($bill_arr);
//todo if bill_arr not null, save database table //todo if bill_arr not null, save database table
if (!empty($bill_arr)) { if (!empty($bill_arr)) {
return $this->payLogModel->addPayLog($bill_arr); return $this->payLogModel->addPayLog($bill_arr);
...@@ -60,11 +66,12 @@ class OrderLogService ...@@ -60,11 +66,12 @@ class OrderLogService
return 0; return 0;
} }
private function collectingBillBin($collecting_arr, $agent_id, $report_id, $order_id, $order_no, $house_number, private function collectingBillBin($father_id,$collecting_arr, $agent_id, $report_id, $order_id, $order_no, $house_number,
$industry_type, $remark, $transfer_img) $industry_type, $remark, $transfer_img)
{ {
$arr["report_id"] = $report_id; $arr["report_id"] = $report_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["agent_id"] = $agent_id; $arr["agent_id"] = $agent_id;
...@@ -96,24 +103,32 @@ class OrderLogService ...@@ -96,24 +103,32 @@ class OrderLogService
public function addBargain($submit_agent_id, $report_id, $order_id, $order_no, $trade_type, $price, $commission, $commission_arr) public function addBargain($submit_agent_id, $report_id, $order_id, $order_no, $trade_type, $price, $commission, $commission_arr)
{ {
$bargain_arr = []; $bargain_arr = [];
$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"]) && isset($commission_val["scale_fee"])) { if (isset($commission_val["role"]) && isset($commission_val["agent_id"]) && isset($commission_val["scale"])
array_push($bargain_arr, $this->bargainBin($commission_val, $submit_agent_id, $report_id, $order_id, && isset($commission_val["scale_fee"])) {
$order_no, $trade_type, $price, $commission)); if($father_id == 0){
$params = $this->bargainBin($father_id,$commission_val, $submit_agent_id, $report_id, $order_id,
$order_no, $trade_type, $price, $commission);
$father_id = $this->bargainModel->insertBargain($params);
}else{
array_push($bargain_arr, $this->bargainBin($father_id,$commission_val, $submit_agent_id, $report_id,
$order_id, $order_no, $trade_type, $price, $commission));
}
} }
} }
//todo if bill_arr not null, save database table //todo if bill_arr not null, save database table
dump($bargain_arr);
if (!empty($bargain_arr)) { if (!empty($bargain_arr)) {
return $this->bargainModel->addBargain($bargain_arr); return $this->bargainModel->addBargain($bargain_arr);
} }
return 0; return 0;
} }
private function bargainBin($commission_val, $submit_agent_id, $report_id, $order_id, $order_no, $trade_type, $price, $commission) private function bargainBin($father_id,$commission_val, $submit_agent_id, $report_id, $order_id, $order_no, $trade_type, $price, $commission)
{ {
$arr["report_id"] = $report_id; $arr["report_id"] = $report_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;
...@@ -313,4 +328,31 @@ class OrderLogService ...@@ -313,4 +328,31 @@ class OrderLogService
} }
public function getBargainList($params){
$pageNo = empty($params["page_no"]) ? 1 : $params["page_no"];
$pageSize = empty($params["page_size"]) ? 15 : $params["page_size"];
$bargainModel = new OBargainModel();
$filed = "a.id,a.create_time,b.user_phone,b.user_name,b.user_id,d.id as house_id,d.internal_title,d.internal_address";
$result = $bargainModel->selectBargainList($filed,$params,$pageNo,$pageSize);
foreach ($result as $k=>$v){
$result[$k]["user_phone"] = preg_replace('/(\d{3})\d{4}(\d{4})/','$1****$2',$v["user_phone"]);
$result[$k]["create_time"] = date("Y-m-d",strtotime($v["create_time"]));
}
return $result;
}
public function getBargainDetail($params){
$bargainModel = new OBargainModel();
$filed = "a.id,a.trade_type,a.price,a.submit_agent_id,a.commission,a.role,a.agent_id,a.scale,a.scale_fee,a.status,
b.name,b.phone";
return $bargainModel->selectBargainDetail($filed,$params);
}
} }
\ No newline at end of file
...@@ -34,6 +34,18 @@ class OBargainModel extends Model ...@@ -34,6 +34,18 @@ class OBargainModel extends Model
return 0; return 0;
} }
} }
public function insertBargain($params)
{
Db::startTrans();
try {
$id = $this->db_->insertGetId($params);
Db::commit();
return $id;
} catch (\Exception $e) {
Db::rollback();
return 0;
}
}
/** /**
* 修改信息 * 修改信息
...@@ -82,4 +94,62 @@ class OBargainModel extends Model ...@@ -82,4 +94,62 @@ class OBargainModel extends Model
->where($where_) ->where($where_)
->select(); ->select();
} }
/**
* 获取我得成交
* @param $filed
* @param $params
* @param $pageNo
* @param $pageSize
* @return false|\PDOStatement|string|\think\Collection
*/
public function selectBargainList($filed,$params,$pageNo,$pageSize){
$where_ = [];
if (isset($params["submit_agent_id"])) {
$where_["a.submit_agent_id"] = $params["submit_agent_id"];
}
if (isset($params["status"])) {
$where_["a.status"] = $params["status"];
}
$where_["a.father_id"] = 0;
$where_["b.status"] = 0;
$where_["c.is_del"] = 0;
return $this->db_
->field($filed)
->alias("a")
->join("o_report b","a.report_id = b.id","left")
->join("o_order c","a.order_id = c.id","left")
->join("g_houses d","c.house_id = d.id","left")
->where($where_)
->order("a.create_time desc")
->limit($pageSize)
->page($pageNo)
->select();
}
/**
* 获取成交报告详情
* @param $filed
* @param $params
* @return false|\PDOStatement|string|\think\Collection
*/
public function selectBargainDetail($filed,$params){
$where_ = $whereOr_ =[];
if (isset($params["bargain_id"])) {
$where_["a.id"] = $params["bargain_id"];
$whereOr_["a.father_id"] = $params["bargain_id"];
}
$result = $this->db_
->field($filed)
->alias("a")
->join("a_agents b" ,"a.agent_id = b.id","left")
->where($where_)
->whereOr($whereOr_)
->order("a.id asc")
->select();
echo $this->getLastSql();
return $result;
}
} }
\ No newline at end of file
...@@ -34,6 +34,17 @@ class OPayLogModel extends Model ...@@ -34,6 +34,17 @@ class OPayLogModel extends Model
return 0; return 0;
} }
} }
public function insertPayLog($params){
Db::startTrans();
try {
$id = $this->db_->insertGetId($params);
Db::commit();
return $id;
} catch (\Exception $e) {
Db::rollback();
return 0;
}
}
/** /**
* 查询付款记录 * 查询付款记录
......
...@@ -289,6 +289,8 @@ Route::group('broker', [ ...@@ -289,6 +289,8 @@ Route::group('broker', [
'orderDetail' => ['api_broker/OrderLog/orderDetail', [ 'method' => 'get|post' ] ], 'orderDetail' => ['api_broker/OrderLog/orderDetail', [ 'method' => 'get|post' ] ],
'selectReportAll' => ['api_broker/OrderLog/selectReportAll', [ 'method' => 'get|post' ] ], 'selectReportAll' => ['api_broker/OrderLog/selectReportAll', [ 'method' => 'get|post' ] ],
'searchOrder' => ['api_broker/OrderLog/searchOrder', [ 'method' => 'get|post' ] ], 'searchOrder' => ['api_broker/OrderLog/searchOrder', [ 'method' => 'get|post' ] ],
'bargainList' => ['api_broker/OrderLog/bargainList', [ 'method' => 'get|post' ] ],
'bargainDetail' => ['api_broker/OrderLog/bargainDetail', [ 'method' => 'get|post' ] ],
'token' => ['api_broker/broker/token', [ 'method' => 'get' ] ], 'token' => ['api_broker/broker/token', [ 'method' => 'get' ] ],
......
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