Commit ff92a238 authored by clone's avatar clone

没有分佣默认给成交报告中的比列

parent b23049ca
......@@ -842,6 +842,7 @@ class OrderLogService
$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;
}
......@@ -866,6 +867,20 @@ class OrderLogService
}
$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++;
}
}
$result["cent_commission"] = $cent_commission;
//税费
......
......@@ -34,6 +34,7 @@ class OBargainModel extends Model
return 0;
}
}
public function insertBargain($params)
{
Db::startTrans();
......@@ -134,25 +135,26 @@ class OBargainModel extends Model
return $this->db_
->field($filed)
->alias("a")
->join("a_agents b","a.agent_id = b.id","left")
->join("a_agents b", "a.agent_id = b.id", "left")
->where($where_)
->select();
}
public function getBargainByOrderId($field,$params){
public function getBargainByOrderId($field, $params)
{
$where_ = [];
if(isset($params["order_id"])){
if (isset($params["order_id"])) {
$where_["a.order_id"] = $params["order_id"];
}
if(isset($params["house_title"])){
if (isset($params["house_title"])) {
$where_["b.house_title"] = $params["house_title"];
}
return Db::table($this->table)
->field($field)
->alias("a")
->join("o_order b","a.order_id = b.id","left")
->join("a_agents c","a.agent_id = c.id","left")
->join("a_store d","c.store_id = d.id","left")
->join("o_order b", "a.order_id = b.id", "left")
->join("a_agents c", "a.agent_id = c.id", "left")
->join("a_store d", "c.store_id = d.id", "left")
->where($where_)
->select();
}
......@@ -169,17 +171,18 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function selectBargainList($filed,$params,$pageNo,$pageSize){
public function selectBargainList($filed, $params, $pageNo, $pageSize)
{
$where_ = [];
if (isset($params["status"])) {
$where_["a.status"] = $params["status"];
}
if (isset($params["ids"])) {
$where_["a.agent_id"] = array("in",$params["ids"]);
$where_["a.agent_id"] = array( "in", $params["ids"] );
}
if (isset($params["keyword"])) {
$where_["b.user_phone|b.user_name|d.internal_address"] = array( "like", "%".$params["keyword"]."%") ;
$where_["b.user_phone|b.user_name|d.internal_address"] = array( "like", "%" . $params["keyword"] . "%" );
}
$where_["b.status"] = 0;
......@@ -187,9 +190,9 @@ class OBargainModel extends Model
$result = $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")
->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)
......@@ -209,8 +212,9 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function selectBargainDetail($filed,$params){
$where_ = $whereOr_ =[];
public function selectBargainDetail($filed, $params)
{
$where_ = $whereOr_ = [];
if (isset($params["bargain_id"])) {
$where_["a.id"] = $params["bargain_id"];
}
......@@ -218,9 +222,9 @@ class OBargainModel extends Model
$result = $this->db_
->field($filed)
->alias("a")
->join("o_order b" ,"a.order_id = b.id","left")
->join("g_houses c" ,"b.house_id = c.id","left")
->join("o_report d","a.report_id = d.id","left")
->join("o_order b", "a.order_id = b.id", "left")
->join("g_houses c", "b.house_id = c.id", "left")
->join("o_report d", "a.report_id = d.id", "left")
->where($where_)
->whereOr($whereOr_)
->order("a.id asc")
......@@ -242,12 +246,13 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getBargain($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
public function getBargain($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '')
{
return $this->field($field)->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')
->join('o_financial_audit e','e.bargain_id = a.id','left')
->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')
->join('o_financial_audit e', 'e.bargain_id = a.id', 'left')
->where($params)
->order($order_)
->limit($pageSize)
......@@ -261,12 +266,13 @@ class OBargainModel extends Model
* @param string $params
* @return int|string
*/
public function getBargainTotal($params = '') {
public function getBargainTotal($params = '')
{
return $this->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')
->join('o_financial_audit e','e.bargain_id = a.id','left')
->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')
->join('o_financial_audit e', 'e.bargain_id = a.id', 'left')
->where($params)
->count();
}
......@@ -284,7 +290,8 @@ class OBargainModel extends Model
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function addCheckBargain(int $id,array $data, int $source, int $status) : bool {
public function addCheckBargain(int $id, array $data, int $source, int $status): bool
{
$this->startTrans();
$bargain_data = $this->field('id,report_id,agent_id,order_no,order_id')->where([
'id' => $id,
......@@ -305,7 +312,7 @@ class OBargainModel extends Model
$save_data['audit_id'] = $data['audit_id'];
$save_data['audit_name'] = $data['audit_name'];
$return = 0;
$audit_level = $data['audit_level']-1;
$audit_level = $data['audit_level'] - 1;
//是否有审核记录,只做一次审核。
if (isset($audit_data['id'])) {
......@@ -328,11 +335,11 @@ class OBargainModel extends Model
$update_data['status'] = 11;
$update_data['account_statement'] = 1;
$update_data['account_time'] = time();
$this->save($update_data,['id'=>$bargain_data['id']]);
$this->save($update_data, [ 'id' => $bargain_data['id'] ]);
}
if ($data['audit_level'] == 3 && $status == 20) {
$this->where('id',$bargain_data['id'])->setField('status',21);
$this->where('id', $bargain_data['id'])->setField('status', 21);
}
$this->commit();
......@@ -358,11 +365,12 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getBargainInfo($field,$params) {
public function getBargainInfo($field, $params)
{
$data = $this->field($field)->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')
->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($params)
->find();
......@@ -382,21 +390,22 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAddBargainNumGroupTime($params,$type){
public function getAddBargainNumGroupTime($params, $type)
{
$field = "";
$where_ = [];
if($type == 1){
if ($type == 1) {
$field = "sum(scale_fee) as num,DATE(create_time) as day";
}elseif($type == 2){
} elseif ($type == 2) {
$field = "sum(practical_fee) as num,DATE(create_time) as day";
}elseif ($type == 3){
} elseif ($type == 3) {
$field = "count(1) as num,DATE(create_time) as day";
}
if(isset($params["agent_id"])){
if (isset($params["agent_id"])) {
$where_["agent_id"] = $params["agent_id"];
}
if(isset($params["create_time"])){
if (isset($params["create_time"])) {
$where_["create_time"] = $params["create_time"];
}
......@@ -408,58 +417,59 @@ class OBargainModel extends Model
}
public function getAddBargainNum($params,$type){
public function getAddBargainNum($params, $type)
{
$where_ = [];
$field = "";
if($type == 1){
if ($type == 1) {
$field = "sum(scale_fee) as num";
}elseif($type == 2){
} elseif ($type == 2) {
$field = "sum(practical_fee) as num";
}elseif ($type == 3){
} elseif ($type == 3) {
$field = "count(1) as num";
}
if(isset($params["agent_id"])){
if (isset($params["agent_id"])) {
$where_["a.agent_id"] = $params["agent_id"];
}
if(isset($params["create_time"])){
if (isset($params["create_time"])) {
$where_["a.create_time"] = $params["create_time"];
}
if(isset($params["house_ids"])){
$where_["b.house_id"] = array("in",$params["house_ids"]);
if (isset($params["house_ids"])) {
$where_["b.house_id"] = array( "in", $params["house_ids"] );
}
return Db::table($this->table)
->field($field)
->alias("a")
->join("o_order b","a.order_id = b.id","left")
->join("o_order b", "a.order_id = b.id", "left")
->where($where_)
->select();
}
public function getAddBargainOrderList($field,$params){
public function getAddBargainOrderList($field, $params)
{
$where_ = [];
if(isset($params["agent_id"])){
if (isset($params["agent_id"])) {
$where_["a.agent_id"] = $params["agent_id"];
}
if(isset($params["create_time"])){
if (isset($params["create_time"])) {
$where_["a.create_time"] = $params["create_time"];
}
if(isset($params["house_ids"])){
$where_["b.house_id"] = array("in",$params["house_ids"]);
if (isset($params["house_ids"])) {
$where_["b.house_id"] = array( "in", $params["house_ids"] );
}
return Db::table($this->table)
->field($field)
->alias("a")
->join("o_order b","a.order_id = b.id","left")
->join("o_report c","b.f_id = c.id","left")
->join('g_houses d','b.house_id = d.id','left')
->join("o_order b", "a.order_id = b.id", "left")
->join("o_report c", "b.f_id = c.id", "left")
->join('g_houses d', 'b.house_id = d.id', 'left')
->where($where_)
->select();
}
......@@ -467,7 +477,8 @@ class OBargainModel extends Model
/**
* 判断同一个订单是否有多个成交报告
*/
public function ifBargainNumByOrderId($params){
public function ifBargainNumByOrderId($params)
{
return Db::table($this->table)
->where($params)
->count();
......@@ -481,7 +492,8 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getBargainDetail($field,$params){
public function getBargainDetail($field, $params)
{
return Db::table($this->table)
->field($field)
->where($params)
......@@ -503,7 +515,8 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function addBargainCommission($id, $submit_agent_id, $agent_id, $role, $scale_fee, $scale,$source) {
public function addBargainCommission($id, $submit_agent_id, $agent_id, $role, $scale_fee, $scale, $source)
{
$this->startTrans();
$bargain_data = $this->where('id', $id)->find();
......@@ -555,10 +568,11 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getBargainPartial($pageNo, $pageSize, $order_ = 'id desc', $fields, $where) {
public function getBargainPartial($pageNo, $pageSize, $order_ = 'id desc', $fields, $where)
{
$data = $this->field($fields)
->alias('a')
->join('a_agents b', 'a.agent_id = b.id','left')
->join('a_agents b', 'a.agent_id = b.id', 'left')
->where($where)
->order($order_)
->limit($pageSize)
......@@ -574,31 +588,36 @@ class OBargainModel extends Model
$result[$k] = $v;
if (isset($v['agent_id'])) {
$agent_data = $m_agent->getStoreDistrict($fields_str, ['a.id'=>$v['agent_id']]);
$result[$k]['agent'] = $agent_data['name'].'-'.$agent_data['phone'];
$result[$k]['district_store'] = $agent_data['district_name'] .'-'.$agent_data['store_name'];
$agent_data = $m_agent->getStoreDistrict($fields_str, [ 'a.id' => $v['agent_id'] ]);
$result[$k]['agent'] = $agent_data['name'] . '-' . $agent_data['phone'];
$result[$k]['district_store'] = $agent_data['district_name'] . '-' . $agent_data['store_name'];
}
if (isset($v['role'])) {
switch ($v['role']) {
case 1 :
$result[$k]['role_name'] = '盘方';break;
$result[$k]['role_name'] = '盘方';
break;
case 2 :
$result[$k]['role_name'] = '客方';break;
$result[$k]['role_name'] = '客方';
break;
case 3 :
$result[$k]['role_name'] = '反签';break;
$result[$k]['role_name'] = '反签';
break;
case 4 :
$result[$k]['role_name'] = '独家';break;
$result[$k]['role_name'] = '独家';
break;
case 5 :
$result[$k]['role_name'] = '合作方';break;
$result[$k]['role_name'] = '合作方';
break;
default :
$result[$k]['role_name'] = '无';
}
}
$result[$k]['partial_commission'] = $m_partial->field('id,scale,practical_fee,cash,service_charge,charity_fund,real_fee,confirm_date,should_commission')
->where('bargain_id',$v['id'])
->where('is_del',0)
->where('bargain_id', $v['id'])
->where('is_del', 0)
->select();
}
return $result;
......@@ -618,7 +637,8 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getCommissionTotalList($pageNo = 1, $pageSize = 15, $order_ = 'a.id desc', $field = '', $params = '', $whereOr = []) {
public function getCommissionTotalList($pageNo = 1, $pageSize = 15, $order_ = 'a.id desc', $field = '', $params = '', $whereOr = [])
{
$data = $this->alias('a')
->field($field)
->join('o_taxes b', 'a.id = b.bargain_id', 'left')
......@@ -637,8 +657,8 @@ class OBargainModel extends Model
$m_fee = new OTaxes();
foreach ($data as $k => $v) {
if (isset($v['agent_id'])) {
$district_store = $m_agent->getStoreDistrict('store_name,district_name', ['a.id'=>$v['agent_id']]);
$data[$k]['district_store'] = $district_store['district_name'] .'-'. $district_store['store_name'];
$district_store = $m_agent->getStoreDistrict('store_name,district_name', [ 'a.id' => $v['agent_id'] ]);
$data[$k]['district_store'] = $district_store['district_name'] . '-' . $district_store['store_name'];
}
// $data[$k]['tax_fee'] = $m_fee->where('bargain_id', $v['id'])->sum('fee');
......@@ -654,7 +674,8 @@ class OBargainModel extends Model
* @param array $whereOr
* @return int|string
*/
public function getCommissionTotalListTotal($params, $whereOr = []) {
public function getCommissionTotalListTotal($params, $whereOr = [])
{
return $this->alias('a')
->join('o_taxes b', 'a.id = b.bargain_id', 'left')
->join('o_partial_commission c', 'a.id = c.bargain_id', 'left')
......@@ -675,21 +696,22 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAgentTypeByBargainId(int $bargain_id) : array {
public function getAgentTypeByBargainId(int $bargain_id): array
{
$m_partial = new OPartialCommission();
$data = $m_partial->getBragainScale($bargain_id);
if (empty($data)) {
$data = $this->field('role,agent_id,scale')
->where('id',$bargain_id)
$data = $this->field('role,agent_id,scale,scale_fee')
->where('id', $bargain_id)
->whereOr('father_id', $bargain_id)
->select();
}
$m_agent = new AAgents();
$result = [];
foreach ($data as $k=>$v) {
foreach ($data as $k => $v) {
if (isset($v['role'])) {
$agent_name = $m_agent->getAgentInfo('id,name,phone', $v['agent_id']);
......@@ -698,18 +720,24 @@ class OBargainModel extends Model
$result[$k]['phone'] = $agent_name['phone'];
$result[$k]['role'] = $v['role'];
$result[$k]['scale'] = $v['scale'];
$result[$k]['scale_fee'] = $v['scale_fee'];
switch ($v['role']) {
case 1 :
$result[$k]['role_name'] = '盘方';break;
$result[$k]['role_name'] = '盘方';
break;
case 2 :
$result[$k]['role_name'] = '客方';break;
$result[$k]['role_name'] = '客方';
break;
case 3 :
$result[$k]['role_name'] = '反签';break;
$result[$k]['role_name'] = '反签';
break;
case 4 :
$result[$k]['role_name'] = '独家';break;
$result[$k]['role_name'] = '独家';
break;
case 5 :
$result[$k]['role_name'] = '合作方';break;
$result[$k]['role_name'] = '合作方';
break;
}
}
}
......@@ -727,7 +755,8 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getCheckBargain(string $field, int $id) {
public function getCheckBargain(string $field, int $id)
{
return $this->field($field)
->where('status', 'in', '10,11')
->where('id', $id)
......
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