Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
ff92a238
Commit
ff92a238
authored
May 28, 2018
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
没有分佣默认给成交报告中的比列
parent
b23049ca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
283 additions
and
239 deletions
+283
-239
OrderLogService.php
application/api_broker/service/OrderLogService.php
+135
-120
OBargainModel.php
application/model/OBargainModel.php
+148
-119
No files found.
application/api_broker/service/OrderLogService.php
View file @
ff92a238
...
@@ -476,107 +476,107 @@ class OrderLogService
...
@@ -476,107 +476,107 @@ class OrderLogService
$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();*/
$gHousesFollowModel
=
new
GHousesFollowUp
();
$gHousesFollowModel
=
new
GHousesFollowUp
();
/* $field_report = "a.id,a.create_time,a.user_name,a.user_phone,b.id as order_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name";
/* $field_report = "a.id,a.create_time,a.user_name,a.user_phone,b.id as order_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name";
$reportData = $oReportModel->selectReportByUserId($field_report, [ "house_id" => $house_id ]);
$reportData = $oReportModel->selectReportByUserId($field_report, [ "house_id" => $house_id ]);
if (count($result) <= 0 && count($reportData) <= 0) {
if (count($result) <= 0 && count($reportData) <= 0) {
return [];
return [];
}
}
$order_ids = $report_ids = "";
$order_ids = $report_ids = "";
$user_info_arr = [];
$user_info_arr = [];
//报备
//报备
foreach ($reportData as $k => $v) {
foreach ($reportData as $k => $v) {
$v["user_phone"] = preg_replace('/(\d{3})\d{4}(\d{4})/', '$1****$2', $v["user_phone"]);
$v["user_phone"] = preg_replace('/(\d{3})\d{4}(\d{4})/', '$1****$2', $v["user_phone"]);
$v["step_name"] = "report";
$v["step_name"] = "report";
$v["step"] = "报备【" . $v['user_name'] . "-" . $v["user_phone"] . "】";
$v["step"] = "报备【" . $v['user_name'] . "-" . $v["user_phone"] . "】";
$result[$sort++] = $v;
$result[$sort++] = $v;
$order_ids .= $v["order_id"] . ",";
$order_ids .= $v["order_id"] . ",";
$report_ids .= $v["id"] . ",";
$report_ids .= $v["id"] . ",";
//todo 组装成order_id为key的数组
//todo 组装成order_id为key的数组
$user_info_arr[$v["order_id"]] = $v;
$user_info_arr[$v["order_id"]] = $v;
}
}
$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 );
$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";
$v["step"] = "进场【" . $user_info_arr[$v['order_id']]['user_name'] . "-" . $user_info_arr[$v['order_id']]["user_phone"] . "】";
$v["step"] = "进场【" . $user_info_arr[$v['order_id']]['user_name'] . "-" . $user_info_arr[$v['order_id']]["user_phone"] . "】";
$result[$sort++] = $v;
$result[$sort++] = $v;
}
}
}
}
//跟进
//跟进
$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,d.user_name,d.user_phone";
a.district,a.business_area,a.explain,a.explain_img,a.create_time,b.name,b.img,c.store_name,d.user_name,d.user_phone";
$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["user_phone"] = preg_replace('/(\d{3})\d{4}(\d{4})/', '$1****$2', $v["user_phone"]);
$v["user_phone"] = preg_replace('/(\d{3})\d{4}(\d{4})/', '$1****$2', $v["user_phone"]);
$v["step"] = "报备跟进【" . $v['user_name'] . "-" . $v['user_phone'] . "】";
$v["step"] = "报备跟进【" . $v['user_name'] . "-" . $v['user_phone'] . "】";
$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;
}
}
}
}
//收款
//收款
$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";
$v["step"] = "收款【" . $user_info_arr[$v['order_id']]['user_name'] . "-" . $user_info_arr[$v['order_id']]["user_phone"] . "】";
$v["step"] = "收款【" . $user_info_arr[$v['order_id']]['user_name'] . "-" . $user_info_arr[$v['order_id']]["user_phone"] . "】";
$result[$sort++] = $v;
$result[$sort++] = $v;
}
}
}
}
//退款
//退款
$field_refund = "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_refund = "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";
$refundData = $oRefundModel->getRefundByOrderId($field_refund, $orderParams);
$refundData = $oRefundModel->getRefundByOrderId($field_refund, $orderParams);
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["step"] = "退款【" . $user_info_arr[$v['order_id']]['user_name'] . "-" . $user_info_arr[$v['order_id']]["user_phone"] . "】";
$v["step"] = "退款【" . $user_info_arr[$v['order_id']]['user_name'] . "-" . $user_info_arr[$v['order_id']]["user_phone"] . "】";
$result[$sort++] = $v;
$result[$sort++] = $v;
}
}
}
}
//成交报告
//成交报告
$field_bargain = "a.id,a.create_time,b.id as order_id,b.house_id,a.house_number,a.is_open,b.house_title,c.id as agent_id,c.name,c.img,d.store_name";
$field_bargain = "a.id,a.create_time,b.id as order_id,b.house_id,a.house_number,a.is_open,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";
$v["step"] = "成交报告【" . $user_info_arr[$v['order_id']]['user_name'] . "-" . $user_info_arr[$v['order_id']]["user_phone"] . "】";
$v["step"] = "成交报告【" . $user_info_arr[$v['order_id']]['user_name'] . "-" . $user_info_arr[$v['order_id']]["user_phone"] . "】";
$result[$sort++] = $v;
$result[$sort++] = $v;
}
}
}*/
}*/
//楼盘跟进
//楼盘跟进
$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"
;
...
@@ -842,30 +842,45 @@ class OrderLogService
...
@@ -842,30 +842,45 @@ class OrderLogService
$cent_commission_arr
=
$partialCommissionModel
->
getCommissionListByBargainId
(
$field
,
$commissionParams
);
$cent_commission_arr
=
$partialCommissionModel
->
getCommissionListByBargainId
(
$field
,
$commissionParams
);
//dump($cent_commission_arr);exit;
//dump($cent_commission_arr);exit;
$cent_commission_
=
$cent_commission
=
array
();
$cent_commission_
=
$cent_commission
=
array
();
foreach
(
$cent_commission_arr
as
$k
=>
$v
)
{
if
(
count
(
$cent_commission_arr
)
>
0
)
{
$cent_commission_
[
$v
[
'agent_id'
]][]
=
$v
;
foreach
(
$cent_commission_arr
as
$k
=>
$v
)
{
}
$cent_commission_
[
$v
[
'agent_id'
]][]
=
$v
;
$z
=
0
;
}
foreach
(
$cent_commission_
as
$item
)
{
$z
=
0
;
$cent_commission
[
$z
][
"agent_id"
]
=
$item
[
0
][
"agent_id"
];
foreach
(
$cent_commission_
as
$item
)
{
$cent_commission
[
$z
][
"role"
]
=
$item
[
0
][
"role"
];
$cent_commission
[
$z
][
"agent_id"
]
=
$item
[
0
][
"agent_id"
];
$cent_commission
[
$z
][
"scale"
]
=
$item
[
0
][
"scale"
];
$cent_commission
[
$z
][
"role"
]
=
$item
[
0
][
"role"
];
$cent_commission
[
$z
][
"name"
]
=
$item
[
0
][
"name"
];
$cent_commission
[
$z
][
"scale"
]
=
$item
[
0
][
"scale"
];
$cent_commission
[
$z
][
"phone"
]
=
$item
[
0
][
"phone"
];
$cent_commission
[
$z
][
"name"
]
=
$item
[
0
][
"name"
];
$cent_commission
[
$z
][
"should_commission"
]
=
$item
[
0
][
"should_commission"
];
$cent_commission
[
$z
][
"phone"
]
=
$item
[
0
][
"phone"
];
$cent_commission
[
$z
][
"should_commission"
]
=
$item
[
0
][
"should_commission"
];
$key
=
0
;
foreach
(
$item
as
$i
=>
$j
)
{
$key
=
0
;
$cent_commission
[
$z
][
"info"
][
$key
][
"real_fee"
]
=
$j
[
"real_fee"
];
foreach
(
$item
as
$i
=>
$j
)
{
$cent_commission
[
$z
][
"info"
][
$key
][
"create_time"
]
=
$j
[
"create_time"
];
$cent_commission
[
$z
][
"info"
][
$key
][
"real_fee"
]
=
$j
[
"real_fee"
];
$cent_commission
[
$z
][
"info"
][
$key
][
"charity_fund"
]
=
$j
[
"charity_fund"
];
$cent_commission
[
$z
][
"info"
][
$key
][
"create_time"
]
=
$j
[
"create_time"
];
$cent_commission
[
$z
][
"info"
][
$key
][
"cash"
]
=
$j
[
"cash"
];
$cent_commission
[
$z
][
"info"
][
$key
][
"charity_fund"
]
=
$j
[
"charity_fund"
];
$cent_commission
[
$z
][
"info"
][
$key
][
"practical_fee"
]
=
$j
[
"practical_fee"
];
$cent_commission
[
$z
][
"info"
][
$key
][
"cash"
]
=
$j
[
"cash"
];
$cent_commission
[
$z
][
"info"
][
$key
][
"service_charge"
]
=
$j
[
"service_charge"
];
$cent_commission
[
$z
][
"info"
][
$key
][
"practical_fee"
]
=
$j
[
"practical_fee"
];
$key
++
;
$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
++
;
}
}
$z
++
;
}
}
$result
[
"cent_commission"
]
=
$cent_commission
;
$result
[
"cent_commission"
]
=
$cent_commission
;
//税费
//税费
...
...
application/model/OBargainModel.php
View file @
ff92a238
...
@@ -34,6 +34,7 @@ class OBargainModel extends Model
...
@@ -34,6 +34,7 @@ class OBargainModel extends Model
return
0
;
return
0
;
}
}
}
}
public
function
insertBargain
(
$params
)
public
function
insertBargain
(
$params
)
{
{
Db
::
startTrans
();
Db
::
startTrans
();
...
@@ -134,25 +135,26 @@ class OBargainModel extends Model
...
@@ -134,25 +135,26 @@ class OBargainModel extends Model
return
$this
->
db_
return
$this
->
db_
->
field
(
$filed
)
->
field
(
$filed
)
->
alias
(
"a"
)
->
alias
(
"a"
)
->
join
(
"a_agents b"
,
"a.agent_id = b.id"
,
"left"
)
->
join
(
"a_agents b"
,
"a.agent_id = b.id"
,
"left"
)
->
where
(
$where_
)
->
where
(
$where_
)
->
select
();
->
select
();
}
}
public
function
getBargainByOrderId
(
$field
,
$params
){
public
function
getBargainByOrderId
(
$field
,
$params
)
{
$where_
=
[];
$where_
=
[];
if
(
isset
(
$params
[
"order_id"
]))
{
if
(
isset
(
$params
[
"order_id"
]))
{
$where_
[
"a.order_id"
]
=
$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"
];
$where_
[
"b.house_title"
]
=
$params
[
"house_title"
];
}
}
return
Db
::
table
(
$this
->
table
)
return
Db
::
table
(
$this
->
table
)
->
field
(
$field
)
->
field
(
$field
)
->
alias
(
"a"
)
->
alias
(
"a"
)
->
join
(
"o_order b"
,
"a.order_id = b.id"
,
"left"
)
->
join
(
"o_order b"
,
"a.order_id = b.id"
,
"left"
)
->
join
(
"a_agents c"
,
"a.agent_id = c.id"
,
"left"
)
->
join
(
"a_agents c"
,
"a.agent_id = c.id"
,
"left"
)
->
join
(
"a_store d"
,
"c.store_id = d.id"
,
"left"
)
->
join
(
"a_store d"
,
"c.store_id = d.id"
,
"left"
)
->
where
(
$where_
)
->
where
(
$where_
)
->
select
();
->
select
();
}
}
...
@@ -169,27 +171,28 @@ class OBargainModel extends Model
...
@@ -169,27 +171,28 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
selectBargainList
(
$filed
,
$params
,
$pageNo
,
$pageSize
){
public
function
selectBargainList
(
$filed
,
$params
,
$pageNo
,
$pageSize
)
{
$where_
=
[];
$where_
=
[];
if
(
isset
(
$params
[
"status"
]))
{
if
(
isset
(
$params
[
"status"
]))
{
$where_
[
"a.status"
]
=
$params
[
"status"
];
$where_
[
"a.status"
]
=
$params
[
"status"
];
}
}
if
(
isset
(
$params
[
"ids"
]))
{
if
(
isset
(
$params
[
"ids"
]))
{
$where_
[
"a.agent_id"
]
=
array
(
"in"
,
$params
[
"ids"
]
);
$where_
[
"a.agent_id"
]
=
array
(
"in"
,
$params
[
"ids"
]
);
}
}
if
(
isset
(
$params
[
"keyword"
]))
{
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
;
$where_
[
"b.status"
]
=
0
;
$where_
[
"c.is_del"
]
=
0
;
$where_
[
"c.is_del"
]
=
0
;
$result
=
$this
->
db_
$result
=
$this
->
db_
->
field
(
$filed
)
->
field
(
$filed
)
->
alias
(
"a"
)
->
alias
(
"a"
)
->
join
(
"o_report b"
,
"a.report_id = b.id"
,
"left"
)
->
join
(
"o_report b"
,
"a.report_id = b.id"
,
"left"
)
->
join
(
"o_order c"
,
"a.order_id = c.id"
,
"left"
)
->
join
(
"o_order c"
,
"a.order_id = c.id"
,
"left"
)
->
join
(
"g_houses d"
,
"c.house_id = d.id"
,
"left"
)
->
join
(
"g_houses d"
,
"c.house_id = d.id"
,
"left"
)
->
where
(
$where_
)
->
where
(
$where_
)
->
order
(
"a.create_time desc"
)
->
order
(
"a.create_time desc"
)
->
limit
(
$pageSize
)
->
limit
(
$pageSize
)
...
@@ -209,8 +212,9 @@ class OBargainModel extends Model
...
@@ -209,8 +212,9 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
selectBargainDetail
(
$filed
,
$params
){
public
function
selectBargainDetail
(
$filed
,
$params
)
$where_
=
$whereOr_
=
[];
{
$where_
=
$whereOr_
=
[];
if
(
isset
(
$params
[
"bargain_id"
]))
{
if
(
isset
(
$params
[
"bargain_id"
]))
{
$where_
[
"a.id"
]
=
$params
[
"bargain_id"
];
$where_
[
"a.id"
]
=
$params
[
"bargain_id"
];
}
}
...
@@ -218,14 +222,14 @@ class OBargainModel extends Model
...
@@ -218,14 +222,14 @@ class OBargainModel extends Model
$result
=
$this
->
db_
$result
=
$this
->
db_
->
field
(
$filed
)
->
field
(
$filed
)
->
alias
(
"a"
)
->
alias
(
"a"
)
->
join
(
"o_order b"
,
"a.order_id = b.id"
,
"left"
)
->
join
(
"o_order b"
,
"a.order_id = b.id"
,
"left"
)
->
join
(
"g_houses c"
,
"b.house_id = c.id"
,
"left"
)
->
join
(
"g_houses c"
,
"b.house_id = c.id"
,
"left"
)
->
join
(
"o_report d"
,
"a.report_id = d.id"
,
"left"
)
->
join
(
"o_report d"
,
"a.report_id = d.id"
,
"left"
)
->
where
(
$where_
)
->
where
(
$where_
)
->
whereOr
(
$whereOr_
)
->
whereOr
(
$whereOr_
)
->
order
(
"a.id asc"
)
->
order
(
"a.id asc"
)
->
select
();
->
select
();
// echo $this->getLastSql();
// echo $this->getLastSql();
return
$result
;
return
$result
;
}
}
...
@@ -242,12 +246,13 @@ class OBargainModel extends Model
...
@@ -242,12 +246,13 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @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'
)
return
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
join
(
'o_report b'
,
'a.report_id = b.id'
,
'left'
)
->
join
(
'o_report b'
,
'a.report_id = b.id'
,
'left'
)
->
join
(
'o_order c'
,
'a.order_id = c.id'
,
'left'
)
->
join
(
'o_order c'
,
'a.order_id = c.id'
,
'left'
)
->
join
(
'g_houses d'
,
'c.house_id = d.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_financial_audit e'
,
'e.bargain_id = a.id'
,
'left'
)
->
where
(
$params
)
->
where
(
$params
)
->
order
(
$order_
)
->
order
(
$order_
)
->
limit
(
$pageSize
)
->
limit
(
$pageSize
)
...
@@ -261,12 +266,13 @@ class OBargainModel extends Model
...
@@ -261,12 +266,13 @@ class OBargainModel extends Model
* @param string $params
* @param string $params
* @return int|string
* @return int|string
*/
*/
public
function
getBargainTotal
(
$params
=
''
)
{
public
function
getBargainTotal
(
$params
=
''
)
{
return
$this
->
alias
(
'a'
)
return
$this
->
alias
(
'a'
)
->
join
(
'o_report b'
,
'a.report_id = b.id'
,
'left'
)
->
join
(
'o_report b'
,
'a.report_id = b.id'
,
'left'
)
->
join
(
'o_order c'
,
'a.order_id = c.id'
,
'left'
)
->
join
(
'o_order c'
,
'a.order_id = c.id'
,
'left'
)
->
join
(
'g_houses d'
,
'c.house_id = d.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_financial_audit e'
,
'e.bargain_id = a.id'
,
'left'
)
->
where
(
$params
)
->
where
(
$params
)
->
count
();
->
count
();
}
}
...
@@ -284,55 +290,56 @@ class OBargainModel extends Model
...
@@ -284,55 +290,56 @@ class OBargainModel extends Model
* @throws \think\exception\DbException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
* @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
();
$this
->
startTrans
();
$bargain_data
=
$this
->
field
(
'id,report_id,agent_id,order_no,order_id'
)
->
where
([
$bargain_data
=
$this
->
field
(
'id,report_id,agent_id,order_no,order_id'
)
->
where
([
'id'
=>
$id
,
'id'
=>
$id
,
'status'
=>
$status
'status'
=>
$status
])
->
lock
(
true
)
->
find
();
])
->
lock
(
true
)
->
find
();
if
(
$bargain_data
!=
''
)
{
if
(
$bargain_data
!=
''
)
{
$audit
=
new
OFinancialAudit
();
$audit
=
new
OFinancialAudit
();
$audit_data
=
$audit
->
getLastStep
(
$bargain_data
[
'id'
]);
$audit_data
=
$audit
->
getLastStep
(
$bargain_data
[
'id'
]);
$save_data
[
'bargain_id'
]
=
$bargain_data
[
'id'
];
$save_data
[
'bargain_id'
]
=
$bargain_data
[
'id'
];
$save_data
[
'agent_id'
]
=
$bargain_data
[
'agent_id'
];
$save_data
[
'agent_id'
]
=
$bargain_data
[
'agent_id'
];
$save_data
[
'order_no'
]
=
$bargain_data
[
'order_no'
];
$save_data
[
'order_no'
]
=
$bargain_data
[
'order_no'
];
$save_data
[
'order_id'
]
=
$bargain_data
[
'order_id'
];
$save_data
[
'order_id'
]
=
$bargain_data
[
'order_id'
];
$save_data
[
'source'
]
=
$source
;
$save_data
[
'source'
]
=
$source
;
$save_data
[
'status'
]
=
1
;
$save_data
[
'status'
]
=
1
;
$save_data
[
'remark'
]
=
$data
[
'remark'
];
$save_data
[
'remark'
]
=
$data
[
'remark'
];
$save_data
[
'audit_id'
]
=
$data
[
'audit_id'
];
$save_data
[
'audit_id'
]
=
$data
[
'audit_id'
];
$save_data
[
'audit_name'
]
=
$data
[
'audit_name'
];
$save_data
[
'audit_name'
]
=
$data
[
'audit_name'
];
$return
=
0
;
$return
=
0
;
$audit_level
=
$data
[
'audit_level'
]
-
1
;
$audit_level
=
$data
[
'audit_level'
]
-
1
;
//是否有审核记录,只做一次审核。
//是否有审核记录,只做一次审核。
if
(
isset
(
$audit_data
[
'id'
]))
{
if
(
isset
(
$audit_data
[
'id'
]))
{
//第二、三审核
//第二、三审核
if
(
$audit_data
[
'audit_level'
]
==
$audit_level
)
{
if
(
$audit_data
[
'audit_level'
]
==
$audit_level
)
{
$save_data
[
'audit_level'
]
=
$data
[
'audit_level'
];
$save_data
[
'audit_level'
]
=
$data
[
'audit_level'
];
$return
=
$audit
->
addAudit
(
$save_data
);
$return
=
$audit
->
addAudit
(
$save_data
);
}
}
}
else
{
}
else
{
//第一步审核
//第一步审核
if
(
$data
[
'audit_level'
]
==
"0"
)
{
if
(
$data
[
'audit_level'
]
==
"0"
)
{
$save_data
[
'audit_level'
]
=
0
;
$save_data
[
'audit_level'
]
=
0
;
$return
=
$audit
->
addAudit
(
$save_data
);
$return
=
$audit
->
addAudit
(
$save_data
);
}
}
}
}
if
(
$return
)
{
if
(
$return
)
{
if
(
$data
[
'audit_level'
]
==
3
&&
$status
==
10
)
{
if
(
$data
[
'audit_level'
]
==
3
&&
$status
==
10
)
{
$update_data
[
'status'
]
=
11
;
$update_data
[
'status'
]
=
11
;
$update_data
[
'account_statement'
]
=
1
;
$update_data
[
'account_statement'
]
=
1
;
$update_data
[
'account_time'
]
=
time
();
$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
)
{
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
();
$this
->
commit
();
...
@@ -358,16 +365,17 @@ class OBargainModel extends Model
...
@@ -358,16 +365,17 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
getBargainInfo
(
$field
,
$params
)
{
public
function
getBargainInfo
(
$field
,
$params
)
{
$data
=
$this
->
field
(
$field
)
->
alias
(
'a'
)
$data
=
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
join
(
'o_report b'
,
'a.report_id = b.id'
,
'left'
)
->
join
(
'o_report b'
,
'a.report_id = b.id'
,
'left'
)
->
join
(
'o_order c'
,
'a.order_id = c.id'
,
'left'
)
->
join
(
'o_order c'
,
'a.order_id = c.id'
,
'left'
)
->
join
(
'g_houses d'
,
'c.house_id = d.id'
,
'left'
)
->
join
(
'g_houses d'
,
'c.house_id = d.id'
,
'left'
)
->
where
(
$params
)
->
where
(
$params
)
->
find
();
->
find
();
if
(
isset
(
$data
[
'id'
]))
{
if
(
isset
(
$data
[
'id'
]))
{
$m_fee
=
new
ORealIncome
();
$m_fee
=
new
ORealIncome
();
$data
[
'practical_fee'
]
=
$m_fee
->
getBargainTaxes
(
$data
[
'id'
]);
//获取实收佣金
$data
[
'practical_fee'
]
=
$m_fee
->
getBargainTaxes
(
$data
[
'id'
]);
//获取实收佣金
}
}
...
@@ -382,21 +390,22 @@ class OBargainModel extends Model
...
@@ -382,21 +390,22 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
getAddBargainNumGroupTime
(
$params
,
$type
){
public
function
getAddBargainNumGroupTime
(
$params
,
$type
)
$field
=
""
;
{
$field
=
""
;
$where_
=
[];
$where_
=
[];
if
(
$type
==
1
)
{
if
(
$type
==
1
)
{
$field
=
"sum(scale_fee) as num,DATE(create_time) as day"
;
$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"
;
$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"
;
$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"
];
$where_
[
"agent_id"
]
=
$params
[
"agent_id"
];
}
}
if
(
isset
(
$params
[
"create_time"
]))
{
if
(
isset
(
$params
[
"create_time"
]))
{
$where_
[
"create_time"
]
=
$params
[
"create_time"
];
$where_
[
"create_time"
]
=
$params
[
"create_time"
];
}
}
...
@@ -408,58 +417,59 @@ class OBargainModel extends Model
...
@@ -408,58 +417,59 @@ class OBargainModel extends Model
}
}
public
function
getAddBargainNum
(
$params
,
$type
)
public
function
getAddBargainNum
(
$params
,
$type
)
{
{
$where_
=
[];
$where_
=
[];
$field
=
""
;
$field
=
""
;
if
(
$type
==
1
)
{
if
(
$type
==
1
)
{
$field
=
"sum(scale_fee) as num"
;
$field
=
"sum(scale_fee) as num"
;
}
elseif
(
$type
==
2
)
{
}
elseif
(
$type
==
2
)
{
$field
=
"sum(practical_fee) as num"
;
$field
=
"sum(practical_fee) as num"
;
}
elseif
(
$type
==
3
)
{
}
elseif
(
$type
==
3
)
{
$field
=
"count(1) as num"
;
$field
=
"count(1) as num"
;
}
}
if
(
isset
(
$params
[
"agent_id"
]))
{
if
(
isset
(
$params
[
"agent_id"
]))
{
$where_
[
"a.agent_id"
]
=
$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"
];
$where_
[
"a.create_time"
]
=
$params
[
"create_time"
];
}
}
if
(
isset
(
$params
[
"house_ids"
]))
{
if
(
isset
(
$params
[
"house_ids"
]))
{
$where_
[
"b.house_id"
]
=
array
(
"in"
,
$params
[
"house_ids"
]
);
$where_
[
"b.house_id"
]
=
array
(
"in"
,
$params
[
"house_ids"
]
);
}
}
return
Db
::
table
(
$this
->
table
)
return
Db
::
table
(
$this
->
table
)
->
field
(
$field
)
->
field
(
$field
)
->
alias
(
"a"
)
->
alias
(
"a"
)
->
join
(
"o_order b"
,
"a.order_id = b.id"
,
"left"
)
->
join
(
"o_order b"
,
"a.order_id = b.id"
,
"left"
)
->
where
(
$where_
)
->
where
(
$where_
)
->
select
();
->
select
();
}
}
public
function
getAddBargainOrderList
(
$field
,
$params
){
public
function
getAddBargainOrderList
(
$field
,
$params
)
{
$where_
=
[];
$where_
=
[];
if
(
isset
(
$params
[
"agent_id"
]))
{
if
(
isset
(
$params
[
"agent_id"
]))
{
$where_
[
"a.agent_id"
]
=
$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"
];
$where_
[
"a.create_time"
]
=
$params
[
"create_time"
];
}
}
if
(
isset
(
$params
[
"house_ids"
]))
{
if
(
isset
(
$params
[
"house_ids"
]))
{
$where_
[
"b.house_id"
]
=
array
(
"in"
,
$params
[
"house_ids"
]
);
$where_
[
"b.house_id"
]
=
array
(
"in"
,
$params
[
"house_ids"
]
);
}
}
return
Db
::
table
(
$this
->
table
)
return
Db
::
table
(
$this
->
table
)
->
field
(
$field
)
->
field
(
$field
)
->
alias
(
"a"
)
->
alias
(
"a"
)
->
join
(
"o_order b"
,
"a.order_id = b.id"
,
"left"
)
->
join
(
"o_order b"
,
"a.order_id = b.id"
,
"left"
)
->
join
(
"o_report c"
,
"b.f_id = c.id"
,
"left"
)
->
join
(
"o_report c"
,
"b.f_id = c.id"
,
"left"
)
->
join
(
'g_houses d'
,
'b.house_id = d.id'
,
'left'
)
->
join
(
'g_houses d'
,
'b.house_id = d.id'
,
'left'
)
->
where
(
$where_
)
->
where
(
$where_
)
->
select
();
->
select
();
}
}
...
@@ -467,7 +477,8 @@ class OBargainModel extends Model
...
@@ -467,7 +477,8 @@ class OBargainModel extends Model
/**
/**
* 判断同一个订单是否有多个成交报告
* 判断同一个订单是否有多个成交报告
*/
*/
public
function
ifBargainNumByOrderId
(
$params
){
public
function
ifBargainNumByOrderId
(
$params
)
{
return
Db
::
table
(
$this
->
table
)
return
Db
::
table
(
$this
->
table
)
->
where
(
$params
)
->
where
(
$params
)
->
count
();
->
count
();
...
@@ -481,7 +492,8 @@ class OBargainModel extends Model
...
@@ -481,7 +492,8 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
getBargainDetail
(
$field
,
$params
){
public
function
getBargainDetail
(
$field
,
$params
)
{
return
Db
::
table
(
$this
->
table
)
return
Db
::
table
(
$this
->
table
)
->
field
(
$field
)
->
field
(
$field
)
->
where
(
$params
)
->
where
(
$params
)
...
@@ -503,7 +515,8 @@ class OBargainModel extends Model
...
@@ -503,7 +515,8 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @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
();
$this
->
startTrans
();
$bargain_data
=
$this
->
where
(
'id'
,
$id
)
->
find
();
$bargain_data
=
$this
->
where
(
'id'
,
$id
)
->
find
();
...
@@ -531,7 +544,7 @@ class OBargainModel extends Model
...
@@ -531,7 +544,7 @@ class OBargainModel extends Model
$insert_data
[
'account_statement'
]
=
$bargain_data
[
'account_statement'
];
$insert_data
[
'account_statement'
]
=
$bargain_data
[
'account_statement'
];
$insert_data
[
'is_commission'
]
=
$bargain_data
[
'is_commission'
];
$insert_data
[
'is_commission'
]
=
$bargain_data
[
'is_commission'
];
$insert_data
[
'content'
]
=
$bargain_data
[
'content'
];
$insert_data
[
'content'
]
=
$bargain_data
[
'content'
];
$result
=
$this
->
insert
(
$insert_data
);
$result
=
$this
->
insert
(
$insert_data
);
if
(
$result
==
1
)
{
if
(
$result
==
1
)
{
$this
->
commit
();
$this
->
commit
();
}
else
{
}
else
{
...
@@ -555,10 +568,11 @@ class OBargainModel extends Model
...
@@ -555,10 +568,11 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @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
)
$data
=
$this
->
field
(
$fields
)
->
alias
(
'a'
)
->
alias
(
'a'
)
->
join
(
'a_agents b'
,
'a.agent_id = b.id'
,
'left'
)
->
join
(
'a_agents b'
,
'a.agent_id = b.id'
,
'left'
)
->
where
(
$where
)
->
where
(
$where
)
->
order
(
$order_
)
->
order
(
$order_
)
->
limit
(
$pageSize
)
->
limit
(
$pageSize
)
...
@@ -567,38 +581,43 @@ class OBargainModel extends Model
...
@@ -567,38 +581,43 @@ class OBargainModel extends Model
$result
=
[];
$result
=
[];
$m_agent
=
new
AAgents
();
$m_agent
=
new
AAgents
();
$m_partial
=
new
OPartialCommission
();
$m_partial
=
new
OPartialCommission
();
$fields_str
=
'a.id,a.name,a.phone,b.store_name,c.district_name'
;
$fields_str
=
'a.id,a.name,a.phone,b.store_name,c.district_name'
;
foreach
(
$data
as
$k
=>
$v
)
{
foreach
(
$data
as
$k
=>
$v
)
{
$result
[
$k
]
=
$v
;
$result
[
$k
]
=
$v
;
if
(
isset
(
$v
[
'agent_id'
]))
{
if
(
isset
(
$v
[
'agent_id'
]))
{
$agent_data
=
$m_agent
->
getStoreDistrict
(
$fields_str
,
[
'a.id'
=>
$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
][
'agent'
]
=
$agent_data
[
'name'
]
.
'-'
.
$agent_data
[
'phone'
];
$result
[
$k
][
'district_store'
]
=
$agent_data
[
'district_name'
]
.
'-'
.
$agent_data
[
'store_name'
];
$result
[
$k
][
'district_store'
]
=
$agent_data
[
'district_name'
]
.
'-'
.
$agent_data
[
'store_name'
];
}
}
if
(
isset
(
$v
[
'role'
]))
{
if
(
isset
(
$v
[
'role'
]))
{
switch
(
$v
[
'role'
])
{
switch
(
$v
[
'role'
])
{
case
1
:
case
1
:
$result
[
$k
][
'role_name'
]
=
'盘方'
;
break
;
$result
[
$k
][
'role_name'
]
=
'盘方'
;
break
;
case
2
:
case
2
:
$result
[
$k
][
'role_name'
]
=
'客方'
;
break
;
$result
[
$k
][
'role_name'
]
=
'客方'
;
break
;
case
3
:
case
3
:
$result
[
$k
][
'role_name'
]
=
'反签'
;
break
;
$result
[
$k
][
'role_name'
]
=
'反签'
;
break
;
case
4
:
case
4
:
$result
[
$k
][
'role_name'
]
=
'独家'
;
break
;
$result
[
$k
][
'role_name'
]
=
'独家'
;
break
;
case
5
:
case
5
:
$result
[
$k
][
'role_name'
]
=
'合作方'
;
break
;
$result
[
$k
][
'role_name'
]
=
'合作方'
;
break
;
default
:
default
:
$result
[
$k
][
'role_name'
]
=
'无'
;
$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'
)
$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
(
'bargain_id'
,
$v
[
'id'
])
->
where
(
'is_del'
,
0
)
->
where
(
'is_del'
,
0
)
->
select
();
->
select
();
}
}
return
$result
;
return
$result
;
...
@@ -618,7 +637,8 @@ class OBargainModel extends Model
...
@@ -618,7 +637,8 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @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'
)
$data
=
$this
->
alias
(
'a'
)
->
field
(
$field
)
->
field
(
$field
)
->
join
(
'o_taxes b'
,
'a.id = b.bargain_id'
,
'left'
)
->
join
(
'o_taxes b'
,
'a.id = b.bargain_id'
,
'left'
)
...
@@ -637,8 +657,8 @@ class OBargainModel extends Model
...
@@ -637,8 +657,8 @@ class OBargainModel extends Model
$m_fee
=
new
OTaxes
();
$m_fee
=
new
OTaxes
();
foreach
(
$data
as
$k
=>
$v
)
{
foreach
(
$data
as
$k
=>
$v
)
{
if
(
isset
(
$v
[
'agent_id'
]))
{
if
(
isset
(
$v
[
'agent_id'
]))
{
$district_store
=
$m_agent
->
getStoreDistrict
(
'store_name,district_name'
,
[
'a.id'
=>
$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'
];
$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');
// $data[$k]['tax_fee'] = $m_fee->where('bargain_id', $v['id'])->sum('fee');
...
@@ -654,7 +674,8 @@ class OBargainModel extends Model
...
@@ -654,7 +674,8 @@ class OBargainModel extends Model
* @param array $whereOr
* @param array $whereOr
* @return int|string
* @return int|string
*/
*/
public
function
getCommissionTotalListTotal
(
$params
,
$whereOr
=
[])
{
public
function
getCommissionTotalListTotal
(
$params
,
$whereOr
=
[])
{
return
$this
->
alias
(
'a'
)
return
$this
->
alias
(
'a'
)
->
join
(
'o_taxes b'
,
'a.id = b.bargain_id'
,
'left'
)
->
join
(
'o_taxes b'
,
'a.id = b.bargain_id'
,
'left'
)
->
join
(
'o_partial_commission c'
,
'a.id = c.bargain_id'
,
'left'
)
->
join
(
'o_partial_commission c'
,
'a.id = c.bargain_id'
,
'left'
)
...
@@ -675,41 +696,48 @@ class OBargainModel extends Model
...
@@ -675,41 +696,48 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
getAgentTypeByBargainId
(
int
$bargain_id
)
:
array
{
public
function
getAgentTypeByBargainId
(
int
$bargain_id
)
:
array
{
$m_partial
=
new
OPartialCommission
();
$m_partial
=
new
OPartialCommission
();
$data
=
$m_partial
->
getBragainScale
(
$bargain_id
);
$data
=
$m_partial
->
getBragainScale
(
$bargain_id
);
if
(
empty
(
$data
))
{
if
(
empty
(
$data
))
{
$data
=
$this
->
field
(
'role,agent_id,scale'
)
$data
=
$this
->
field
(
'role,agent_id,scale
,scale_fee
'
)
->
where
(
'id'
,
$bargain_id
)
->
where
(
'id'
,
$bargain_id
)
->
whereOr
(
'father_id'
,
$bargain_id
)
->
whereOr
(
'father_id'
,
$bargain_id
)
->
select
();
->
select
();
}
}
$m_agent
=
new
AAgents
();
$m_agent
=
new
AAgents
();
$result
=
[];
$result
=
[];
foreach
(
$data
as
$k
=>
$v
)
{
foreach
(
$data
as
$k
=>
$v
)
{
if
(
isset
(
$v
[
'role'
]))
{
if
(
isset
(
$v
[
'role'
]))
{
$agent_name
=
$m_agent
->
getAgentInfo
(
'id,name,phone'
,
$v
[
'agent_id'
]);
$agent_name
=
$m_agent
->
getAgentInfo
(
'id,name,phone'
,
$v
[
'agent_id'
]);
$result
[
$k
][
'id'
]
=
$agent_name
[
'id'
];
$result
[
$k
][
'id'
]
=
$agent_name
[
'id'
];
$result
[
$k
][
'name'
]
=
$agent_name
[
'name'
];
$result
[
$k
][
'name'
]
=
$agent_name
[
'name'
];
$result
[
$k
][
'phone'
]
=
$agent_name
[
'phone'
];
$result
[
$k
][
'phone'
]
=
$agent_name
[
'phone'
];
$result
[
$k
][
'role'
]
=
$v
[
'role'
];
$result
[
$k
][
'role'
]
=
$v
[
'role'
];
$result
[
$k
][
'scale'
]
=
$v
[
'scale'
];
$result
[
$k
][
'scale'
]
=
$v
[
'scale'
];
$result
[
$k
][
'scale_fee'
]
=
$v
[
'scale_fee'
];
switch
(
$v
[
'role'
])
{
switch
(
$v
[
'role'
])
{
case
1
:
case
1
:
$result
[
$k
][
'role_name'
]
=
'盘方'
;
break
;
$result
[
$k
][
'role_name'
]
=
'盘方'
;
break
;
case
2
:
case
2
:
$result
[
$k
][
'role_name'
]
=
'客方'
;
break
;
$result
[
$k
][
'role_name'
]
=
'客方'
;
break
;
case
3
:
case
3
:
$result
[
$k
][
'role_name'
]
=
'反签'
;
break
;
$result
[
$k
][
'role_name'
]
=
'反签'
;
break
;
case
4
:
case
4
:
$result
[
$k
][
'role_name'
]
=
'独家'
;
break
;
$result
[
$k
][
'role_name'
]
=
'独家'
;
break
;
case
5
:
case
5
:
$result
[
$k
][
'role_name'
]
=
'合作方'
;
break
;
$result
[
$k
][
'role_name'
]
=
'合作方'
;
break
;
}
}
}
}
}
}
...
@@ -727,7 +755,8 @@ class OBargainModel extends Model
...
@@ -727,7 +755,8 @@ class OBargainModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
getCheckBargain
(
string
$field
,
int
$id
)
{
public
function
getCheckBargain
(
string
$field
,
int
$id
)
{
return
$this
->
field
(
$field
)
return
$this
->
field
(
$field
)
->
where
(
'status'
,
'in'
,
'10,11'
)
->
where
(
'status'
,
'in'
,
'10,11'
)
->
where
(
'id'
,
$id
)
->
where
(
'id'
,
$id
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment