Commit 7add9f4f authored by clone's avatar clone

新增分佣方 预计收款时间,分用方搜索

parent 7e063537
......@@ -219,7 +219,8 @@ class OrderLog extends Basic
if (!isset($params["submit_agent_id"]) || !isset($params["submit_agent_name"]) || !isset($params["report_id"]) ||
!isset($params["order_id"]) || !isset($params["order_no"]) || !isset($params["trade_type"]) ||
//!isset($params["house_number"]) || !isset($params["is_open"]) || !isset($params["industry_type"]) ||
//!isset($params["estimated_receipt_date"]) ||
!isset($params["house_number"]) || !isset($params["is_open"]) || !isset($params["industry_type"]) ||
!isset($params["price"]) || !isset($params["commission"]) || !isset($params["commission_arr"])) {
return $this->response("101", "请求参数错误");
}
......@@ -234,8 +235,8 @@ class OrderLog extends Basic
"trade_type" => 10, //成交类型 10出租 20 增佣 30 代理 40 好处费
"price" => 112131, //成交价格 存分
"commission" => 111, //佣金 存分
//`role` '分佣方 1盘方 2客方 3 反签 4独家 5合作方',
"estimated_receipt_date" => '2018-07-15',
//`role` '分佣方 1盘方 2客方 3 反签 4独家 5合作方 6APP盘下载方 7APP客下载方',
//`agent_id`'分佣经纪人id',
//`scale`'分佣比例 如 5表示百分之5',
// `scale_fee` '应分佣金 存分 ',
......@@ -244,15 +245,17 @@ class OrderLog extends Basic
{ "role": 11, "agent_id" : 12, "scale": 13, "scale_fee" : 1112 }]',
);*/
$house_number = !isset($params["house_number"]) ? null : $params["house_number"];
$is_open = !isset($params["is_open"]) ? 0 : $params["is_open"];
$industry_type = !isset($params["industry_type"]) ? null : $params["industry_type"];
$house_number = !isset($params["house_number"]) ? null : $params["house_number"];
$is_open = !isset($params["is_open"]) ? 0 : $params["is_open"];
$industry_type = !isset($params["industry_type"]) ? null : $params["industry_type"];
$estimated_receipt_date = $params["estimated_receipt_date"];
$params["commission_arr"] = json_decode($params["commission_arr"], true);
$is_ok = $this->service_->addBargain($params["submit_agent_id"], $params["submit_agent_name"], $params["report_id"], $params["order_id"], $params["order_no"],
$params["trade_type"], $params["price"], $params["commission"], $params["commission_arr"], $house_number, $is_open, $industry_type);
$is_ok = $this->service_->addBargain($params["submit_agent_id"], $params["submit_agent_name"], $params["report_id"],
$params["order_id"], $params["order_no"], $params["trade_type"], $params["price"], $params["commission"],
$params["commission_arr"], $house_number, $is_open, $industry_type, $estimated_receipt_date);
if ($is_ok > 0) {
//todo 更改用户信息 求租->已租
......
......@@ -124,13 +124,14 @@ class OrderLogService
* @param $house_number
* @param $is_open
* @param $industry_type
* @param $estimated_receipt_date
* @return int|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function addBargain($submit_agent_id, $submit_agent_name, $report_id, $order_id, $order_no, $trade_type, $price,
$commission, $commission_arr, $house_number, $is_open, $industry_type)
$commission, $commission_arr, $house_number, $is_open, $industry_type, $estimated_receipt_date)
{
$bargain_arr = [];
$father_id = 0;
......@@ -140,11 +141,11 @@ class OrderLogService
&& isset($commission_val["scale_fee"])) {
if ($father_id == 0) {
$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);
$order_no, $trade_type, $price, $commission, $house_number, $is_open, $industry_type, $estimated_receipt_date);
$father_id = $this->bargainModel->insertBargain($params);
} else {
array_push($bargain_arr, $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));
$order_id, $order_no, $trade_type, $price, $commission, $house_number, $is_open, $industry_type, $estimated_receipt_date));
}
}
array_push($agent_arr, [ $commission_val["agent_id"] ]);
......@@ -166,26 +167,27 @@ class OrderLogService
}
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)
$order_no, $trade_type, $price, $commission, $house_number, $is_open, $industry_type, $estimated_receipt_date)
{
$arr["report_id"] = $report_id;
$arr["father_id"] = $father_id;
$arr["order_no"] = $order_no;
$arr["order_id"] = $order_id;
$arr["submit_agent_id"] = $submit_agent_id;
$arr["submit_agent_name"] = $submit_agent_name;
$arr["trade_type"] = $trade_type;
$arr["price"] = $price;
$arr["commission"] = $commission;
$arr["role"] = $commission_val["role"];
$arr["agent_id"] = $commission_val["agent_id"];
$arr["scale"] = $commission_val["scale"];
$arr["scale_fee"] = $commission_val["scale_fee"];
$arr["house_number"] = $house_number;
$arr["is_open"] = $is_open;
$arr["create_time"] = date("Y-m-d H:i:s", time());
$arr["update_time"] = date("Y-m-d H:i:s", time());
$arr["industry_type"] = $industry_type;
$arr["report_id"] = $report_id;
$arr["father_id"] = $father_id;
$arr["order_no"] = $order_no;
$arr["order_id"] = $order_id;
$arr["submit_agent_id"] = $submit_agent_id;
$arr["submit_agent_name"] = $submit_agent_name;
$arr["trade_type"] = $trade_type;
$arr["price"] = $price;
$arr["commission"] = $commission;
$arr["role"] = $commission_val["role"];
$arr["agent_id"] = $commission_val["agent_id"];
$arr["scale"] = $commission_val["scale"];
$arr["scale_fee"] = $commission_val["scale_fee"];
$arr["house_number"] = $house_number;
$arr["is_open"] = $is_open;
$arr["create_time"] = date("Y-m-d H:i:s", time());
$arr["update_time"] = date("Y-m-d H:i:s", time());
$arr["estimated_receipt_date"] = $estimated_receipt_date;
$arr["industry_type"] = $industry_type;
return $arr;
}
......@@ -814,7 +816,7 @@ class OrderLogService
$item = $params[0];
$agent_id = $params[0]["agent_id"];
$cent_commission["id"] = $item["id"];
$cent_commission["id"] = $item["id"];
$cent_commission["agent_id"] = $item["agent_id"];
$cent_commission["role"] = !empty($item["role"]) ? $item["role"] : $item["roles"];
$cent_commission["scale"] = !empty($item["scale"]) ? $item["scale"] : $item["scales"];
......@@ -827,14 +829,14 @@ class OrderLogService
for ($j = 0; $j < $length; $j++) {
$value = $params[$j];
if ($value["agent_id"] == $agent_id) {
$arr["real_fee"] = $value["real_fee"];
$arr["create_time"] = $value["create_time"];
$arr["confirm_date"] = $value["confirm_date"];
$arr["charity_fund"] = $value["charity_fund"];
$arr["cash"] = $value["cash"];
$arr["practical_fee"] = $value["practical_fee"];
$arr["service_charge"] = $value["service_charge"];
if(!empty($value["real_fee"]) && !empty($value["create_time"])){ //过滤掉空的
$arr["real_fee"] = $value["real_fee"];
$arr["create_time"] = $value["create_time"];
$arr["confirm_date"] = $value["confirm_date"];
$arr["charity_fund"] = $value["charity_fund"];
$arr["cash"] = $value["cash"];
$arr["practical_fee"] = $value["practical_fee"];
$arr["service_charge"] = $value["service_charge"];
if (!empty($value["real_fee"]) && !empty($value["create_time"])) { //过滤掉空的
$cent_commission["info"][$key] = $arr;
}
......@@ -992,6 +994,17 @@ class OrderLogService
case 5:
return null;
break;
case 6:
return null;
break;
case 7:
$userModel = new Users();
$params["a.id"] = $result[0]["user_id"];
$params["a.referrer_source"] = 20;
$params["a.status"] = 0;
$params["b.status"] = 0;
$list = $userModel->getAgentByReferrer($field, $params);
break;
default:
return null;
......
......@@ -575,6 +575,15 @@ class Users extends Model
->where($params)
->select();
}
public function getAgentByReferrer($field, $params)
{
return Db::name($this->table)
->field($field)
->alias("a")
->join("a_agents b", "a.referrer_id=b.id", "left")
->where($params)
->select();
}
/**
* 跟进用户手机号查询信息
......
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