Commit c94062ff authored by clone's avatar clone

bug

parent 683cd546
......@@ -130,7 +130,7 @@ class OrderLogService
* @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)
{
$bargain_arr = [];
$father_id = 0;
......@@ -140,11 +140,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);
$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));
}
}
array_push($agent_arr, [ $commission_val["agent_id"] ]);
......@@ -166,7 +166,7 @@ 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)
{
$arr["report_id"] = $report_id;
$arr["father_id"] = $father_id;
......@@ -805,6 +805,47 @@ class OrderLogService
}
private function recursion($params, $cent_commissions, $i)
{
if (count($params) == 0) {
return $cent_commissions;
} else {
$item = $params[0];
$agent_id = $params[0]["agent_id"];
$cent_commission["agent_id"] = $item["agent_id"];
$cent_commission["role"] = $item["role"];
$cent_commission["scale"] = $item["scale"];
$cent_commission["name"] = $item["name"];
$cent_commission["phone"] = $item["phone"];
$cent_commission["should_commission"] = $item["should_commission"];
$key = 0;
$length = count($params);
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"];
$cent_commission["info"][$key] = $arr;
$key++;
unset($params[$j]);
}
}
$cent_commissions[$i] = $cent_commission;
$i++;
return $this->recursion(array_merge($params), $cent_commissions, $i);
}
}
/**
* 获取我得成交报告详情
......@@ -818,8 +859,8 @@ class OrderLogService
{
$bargainModel = new OBargainModel();
$bargain_info_filed = "a.id,a.house_number,a.account_time,a.account_statement,a.is_open,a.trade_type,a.price,a.industry_type,
a.commission,c.id,c.internal_title,c.internal_address,d.user_id,d.user_phone,d.user_name";
$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.commission,c.id,c.internal_title,c.internal_address,d.user_id,d.user_phone,d.user_name";
$result = [];
$bargainInfo = $bargainModel->selectBargainDetail($bargain_info_filed, $params);
......@@ -834,62 +875,23 @@ class OrderLogService
$bargainInfo[0]["realIncome"] = $realIncomeArr;
$result["bargainInfo"] = $bargainInfo[0];
$bargain_id = $bargainInfo[0]["father_id"] == 0 ? $bargainInfo[0]["id"] : $bargainInfo[0]["father_id"];
//分佣提成 o_partial_commission
$partialCommissionModel = new OPartialCommission();
$field = "a.agent_id,a.role,b.name,b.phone,a.scale,a.should_commission,a.confirm_date,a.create_time,a.real_fee,a.charity_fund,
a.cash,a.practical_fee,a.service_charge";
$commissionParams["bargain_id"] = $params["bargain_id"];
$cent_commission_arr = $partialCommissionModel->getCommissionListByBargainId($field, $commissionParams);
//dump($cent_commission_arr);exit;
$cent_commission_ = $cent_commission = array();
if (count($cent_commission_arr) > 0) {
foreach ($cent_commission_arr as $k => $v) {
$cent_commission_[$v['agent_id']][] = $v;
}
$z = 0;
foreach ($cent_commission_ as $item) {
$cent_commission[$z]["agent_id"] = $item[0]["agent_id"];
$cent_commission[$z]["role"] = $item[0]["role"];
$cent_commission[$z]["scale"] = $item[0]["scale"];
$cent_commission[$z]["name"] = $item[0]["name"];
$cent_commission[$z]["phone"] = $item[0]["phone"];
$cent_commission[$z]["should_commission"] = $item[0]["should_commission"];
$key = 0;
foreach ($item as $i => $j) {
$cent_commission[$z]["info"][$key]["real_fee"] = $j["real_fee"];
$cent_commission[$z]["info"][$key]["create_time"] = $j["create_time"];
$cent_commission[$z]["info"][$key]["confirm_date"] = $j["confirm_date"];
$cent_commission[$z]["info"][$key]["charity_fund"] = $j["charity_fund"];
$cent_commission[$z]["info"][$key]["cash"] = $j["cash"];
$cent_commission[$z]["info"][$key]["practical_fee"] = $j["practical_fee"];
$cent_commission[$z]["info"][$key]["service_charge"] = $j["service_charge"];
$key++;
}
$z++;
}
} else {
$bargainList = $this->bargainModel->getAgentTypeByBargainId($params["bargain_id"]);
$z = 0;
foreach ($bargainList as $item) {
$cent_commission[$z]["agent_id"] = $item["id"];
$cent_commission[$z]["role"] = $item["role"];
$cent_commission[$z]["scale"] = $item["scale"];
$cent_commission[$z]["name"] = $item["name"];
$cent_commission[$z]["phone"] = $item["phone"];
$cent_commission[$z]["should_commission"] = $item["scale_fee"];
$z++;
}
}
$field_commission = "a.agent_id,b.role,c.name,c.phone,b.scale,b.should_commission,b.confirm_date,b.create_time,b.real_fee,b.charity_fund,
b.cash,b.practical_fee,b.service_charge";
$cent_commission_arr = $bargainModel->selectBargainCommission($field_commission, [ "bargain_id" => $bargain_id ]);
$cent_commissions = [];
$result["cent_commission"] = $this->recursion($cent_commission_arr, $cent_commissions, 0);
$result["cent_commission"] = $cent_commission;
//税费
$taxesModel = new OTaxes();
$fieldTaxes = "id,bargain_id,fee,total_fee,father_id,operation_date,agent_id,agent_name,scale,create_time,role";
$taxesArr = $taxesModel->getBargainTaxes($params["bargain_id"], $fieldTaxes);
$taxesArr = $taxesModel->getBargainTaxes($bargain_id, $fieldTaxes);
$taxes_ = $taxes = array();
foreach ($taxesArr as $items) {
......@@ -999,7 +1001,8 @@ class OrderLogService
* @param $order_id
* @return array
*/
public function searchBargainAllAgents($order_id) {
public function searchBargainAllAgents($order_id)
{
$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,
c.user_pic,c.sex";
......@@ -1010,46 +1013,46 @@ class OrderLogService
return null;
}
$houseAgents = new GHousesToAgents();
$field = "b.id,b.phone,b.name";
$houseAgents = new GHousesToAgents();
$field = "b.id,b.phone,b.name";
$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["b.status"] = 0;
$agent_house = $houseAgents->getAgentsByHouseId($field.',a.type', $where_house);
$agent_house = $houseAgents->getAgentsByHouseId($field . ',a.type', $where_house);
$list = [];
$key = 0;
//盘方和独家
foreach ($agent_house as $v) {
$list[$key]['id'] = $v['id'];
$list[$key]['id'] = $v['id'];
$list[$key]['phone'] = $v['phone'];
$list[$key]['name'] = $v['name'];
if ($v['type'] == 2) {
$list[$key]['role'] = 1;
$list[$key]['role_name'] = '盘方';
$list[$key]['role'] = 1;
$list[$key]['role_name'] = '盘方';
} else {
$list[$key]['role'] = 4;
$list[$key]['role_name'] = '独家';
$list[$key]['role'] = 4;
$list[$key]['role_name'] = '独家';
}
$key++;
}
$userModel = new Users();
$userModel = new Users();
$where_user["a.id"] = $result[0]["user_id"];
$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'])) {
$list[$key]['id'] = $user_data[0]['id'];
$list[$key]['phone'] = $user_data[0]['phone'];
$list[$key]['name'] = $user_data[0]['name'];
$list[$key]['role'] = 2;
$list[$key]['role_name'] = '客方';
$list[$key]['id'] = $user_data[0]['id'];
$list[$key]['phone'] = $user_data[0]['phone'];
$list[$key]['name'] = $user_data[0]['name'];
$list[$key]['role'] = 2;
$list[$key]['role_name'] = '客方';
$key++;
}
......@@ -1060,11 +1063,11 @@ class OrderLogService
//反签
if (isset($report_data[0]['id'])) {
$list[$key]['id'] = $report_data[0]['id'];
$list[$key]['phone'] = $report_data[0]['phone'];
$list[$key]['name'] = $report_data[0]['name'];
$list[$key]['role'] = 3;
$list[$key]['role_name'] = '反签';
$list[$key]['id'] = $report_data[0]['id'];
$list[$key]['phone'] = $report_data[0]['phone'];
$list[$key]['name'] = $report_data[0]['name'];
$list[$key]['role'] = 3;
$list[$key]['role_name'] = '反签';
}
return $list;
......
......@@ -258,6 +258,37 @@ class OBargainModel extends Model
return $result;
}
/**
* 获取成交报告详情
*
* @param $filed
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function selectBargainCommission($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("o_partial_commission b", "a.id = b.bargain_id", "left")
->join("a_agents c", "a.agent_id = c.id", "left")
->where($where_)
->whereOr($whereOr_)
->order("a.id asc")
->select();
//echo $this->getLastSql();
return $result;
}
// /**
// * 成交报告
// *
......
......@@ -180,10 +180,11 @@ class OPartialCommission extends BaseModel
$result = $this->field($field)
->alias("a")
->join("a_agents b","a.agent_id=b.id","left")
->join("o_bargain c","a.bargain_id=c.id or a.bargain_id = c.father_id","left")
->where($params)
->order("a.create_time desc")
->select();
//echo $this->getLastSql();
echo $this->getLastSql();
return $result ;
}
......
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