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
c89a065b
Commit
c89a065b
authored
Jun 19, 2019
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
办公楼成功报告
parent
c8e25c62
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1198 additions
and
18 deletions
+1198
-18
OfficeBargain.php
application/index/controller/OfficeBargain.php
+951
-0
OfficeOBargainLogModel.php
application/model/OfficeOBargainLogModel.php
+87
-0
OfficeOBargainModel.php
application/model/OfficeOBargainModel.php
+0
-18
OfficeOFinancialAudit.php
application/model/OfficeOFinancialAudit.php
+137
-0
OfficeOReportModel.php
application/model/OfficeOReportModel.php
+10
-0
route.php
application/route.php
+13
-0
No files found.
application/index/controller/OfficeBargain.php
View file @
c89a065b
...
...
@@ -4,11 +4,25 @@
namespace
app\index\controller
;
use
app\api\service\ConvertCouponService
;
use
app\api_broker\service\OfficeOrderLogService
;
use
app\api_broker\service\OfficePayLogService
;
use
app\api_broker\service\RedisCacheService
;
use
app\api_broker\service\VipService
;
use
app\index\extend\Basic
;
use
app\index\untils\ExportExcelUntil
;
use
app\model\AAgents
;
use
app\model\OfficeOBargainLogModel
;
use
app\model\OfficeOBargainModel
;
use
app\model\OfficeOFinancialAudit
;
use
app\model\OfficeOMarchInModel
;
use
app\model\OfficeOPartialCommission
;
use
app\model\OfficeORealIncome
;
use
app\model\OfficeOReportModel
;
use
app\model\OfficeOTaxes
;
use
app\model\TAgentTotalModel
;
use
app\model\Users
;
use
app\task\controller\ResultsSummaryNewTask
;
use
think\Request
;
class
OfficeBargain
extends
Basic
...
...
@@ -319,4 +333,940 @@ class OfficeBargain extends Basic
return
$this
->
response
(
$data
[
'code'
],
$data
[
'msg'
],
$data
[
'data'
]);
}
/**
* 修改成交报告中佣金和备注
*
* @return \think\Response
* @throws \Exception
*/
public
function
editBargainInfo
()
{
$data
[
'code'
]
=
101
;
$data
[
'msg'
]
=
""
;
$data
[
'data'
]
=
[];
if
(
empty
(
$this
->
params
[
'id'
]))
{
$data
[
'msg'
]
=
'Id is null.'
;
return
$this
->
response
(
$data
[
'code'
],
$data
[
'msg'
],
$data
[
'data'
]);
}
if
(
count
(
$this
->
params
[
'practical_fee'
])
>
5
)
{
$data
[
'msg'
]
=
'实收佣金最多5条记录'
;
return
$this
->
response
(
$data
[
'code'
],
$data
[
'msg'
],
$data
[
'data'
]);
}
$update_data
=
$del_bargain_real
=
[];
//实收佣金
if
(
count
(
$this
->
params
[
'practical_fee'
])
>
5
)
{
return
$this
->
response
(
'101'
,
'实收佣金数量超过限制'
);
}
if
(
empty
(
$this
->
params
[
'estimated_receipt_date'
]))
{
return
$this
->
response
(
101
,
'预计收款时间为空'
);
}
//应收总佣金
if
(
!
empty
(
$this
->
params
[
'commission'
]))
{
$update_data
[
'commission'
]
=
$this
->
params
[
'commission'
];
}
if
(
!
empty
(
$this
->
params
[
'content'
]))
{
$update_data
[
'content'
]
=
$this
->
params
[
'content'
];
}
//是否开业
// if (isset($this->params['is_open'])) {
// $update_data['is_open'] = $this->params['is_open'];
// }
//成交类型 10出租 20 增佣 30 代理 40 好处费
if
(
!
empty
(
$this
->
params
[
'trade_type'
]))
{
$update_data
[
'trade_type'
]
=
$this
->
params
[
'trade_type'
];
}
//业态
if
(
!
empty
(
$this
->
params
[
'industry_type'
]))
{
$update_data
[
'industry_type'
]
=
$this
->
params
[
'industry_type'
];
}
//成交价格
if
(
!
empty
(
$this
->
params
[
'price'
]))
{
$update_data
[
'price'
]
=
$this
->
params
[
'price'
];
}
if
(
!
empty
(
$this
->
params
[
'house_number'
]))
{
$update_data
[
'house_number'
]
=
$this
->
params
[
'house_number'
];
}
$update_data
[
'estimated_receipt_date'
]
=
$this
->
params
[
'estimated_receipt_date'
];
//预计收款时间
$m_real
=
new
OfficeORealIncome
();
$data
[
'data'
]
=
$this
->
m_bargain
->
updateBargainById
(
$this
->
params
[
'id'
],
$update_data
);
if
(
$data
[
'data'
]
==
1
)
{
//新增实收佣金 array 5 todo feel_id 大于0 的表示新增 否则修改
// $m_real->addRealIncome($this->params['practical_fee'], $this->params['id'], $this->userId);
$practical_fee_arr
=
$this
->
params
[
"practical_fee"
];
$bargain_id
=
$this
->
params
[
"id"
];
$log_data
=
$add_real_arr
=
$update_real_arr
=
$del_real_id
=
[];
$i
=
$j
=
0
;
foreach
(
$practical_fee_arr
as
$item
)
{
if
(
empty
(
$item
[
'fee'
])
||
empty
(
$item
[
'operation_date'
]))
{
$update_real_arr
[
$i
][
'id'
]
=
$item
[
'fee_id'
];
$update_real_arr
[
$i
][
'is_del'
]
=
1
;
$log_data
[
$i
]
=
'[删除实收佣金:'
.
$item
[
'fee'
]
.
',收佣日期'
.
$item
[
'operation_date'
]
.
']'
;
//
$del_real_id
[]
=
$item
[
'fee_id'
];
$i
++
;
}
elseif
(
$item
[
"fee_id"
]
>
0
)
{
$update_real_arr
[
$i
][
'id'
]
=
$item
[
'fee_id'
];
$update_real_arr
[
$i
][
'bargain_id'
]
=
$bargain_id
;
$update_real_arr
[
$i
][
'operation_id'
]
=
$this
->
userId
;
$update_real_arr
[
$i
][
'money'
]
=
$item
[
'fee'
];
$update_real_arr
[
$i
][
'income_time'
]
=
$item
[
'operation_date'
];
$log_data
[
$i
]
=
'[编辑实收佣金:'
.
$item
[
'fee'
]
.
',收佣日期'
.
$item
[
'operation_date'
]
.
']'
;
//
$i
++
;
}
else
{
$add_real_arr
[
$j
][
'bargain_id'
]
=
$bargain_id
;
$add_real_arr
[
$j
][
'operation_id'
]
=
$this
->
userId
;
$add_real_arr
[
$j
][
'money'
]
=
$item
[
'fee'
];
$add_real_arr
[
$j
][
'income_time'
]
=
$item
[
'operation_date'
];
$log_data
[
$j
]
=
'[新增实收佣金:'
.
$item
[
'fee'
]
.
',收佣日期'
.
$item
[
'operation_date'
]
.
']'
;
$j
++
;
}
}
try
{
if
(
$i
>
0
)
{
$m_real
->
addRealIncome
(
$update_real_arr
);
}
if
(
$j
>
0
)
{
$m_real
->
addRealIncome
(
$add_real_arr
);
}
$content
=
'[应收总佣金:'
.
$update_data
[
'commission'
]
.
']'
.
implode
(
' '
,
$log_data
);
$this
->
editRecordLog
((
int
)
$this
->
params
[
"id"
],
$content
,
1
,
''
,
$update_data
[
'is_open'
]);
if
(
!
empty
(
$del_real_id
))
{
$m_partial
=
new
OfficeOPartialCommission
();
$m_partial
->
updateData
([
'real_income_id'
=>
0
],
[
'bargain_id'
=>
$bargain_id
,
'real_income_id'
=>
[
'in'
,
$del_real_id
]]);
}
}
catch
(
\Exception
$e
)
{
return
$this
->
response
(
101
,
'内部错误,修改成交报告失败!请联系运营。'
);
}
}
else
{
$data
[
'code'
]
=
101
;
$data
[
'msg'
]
=
'Modify the failure.'
;
}
return
$this
->
response
(
$data
[
'code'
],
$data
[
'msg'
],
$data
[
'data'
]);
}
/**
* 记录财务修改日志
*
* @param int $bargain_id
* @param string $step_content
* @param int $type
* @param string $house_number
* @param int $is_open
* @return int
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
editRecordLog
(
int
$bargain_id
,
string
$step_content
=
''
,
int
$type
=
1
,
string
$house_number
=
''
,
$is_open
=
0
)
{
$house_number_table
=
$this
->
m_bargain
->
getCheckBargain
(
'a.house_number,c.internal_address'
,
(
int
)
$bargain_id
,
'10,11,12,13,20,21,30'
);
if
(
!
empty
(
$house_number_table
[
'internal_address'
]))
{
$step_content
.=
"[
{
$house_number_table
[
'internal_address'
]
}
]"
;
}
if
(
empty
(
$house_number
))
{
$house_number
=
$house_number_table
[
'house_number'
];
}
$insert_data
=
[];
if
(
is_array
(
$step_content
))
{
foreach
(
$step_content
as
$k
=>
$v
)
{
$insert_data
[
$k
][
'bargain_id'
]
=
$bargain_id
;
$insert_data
[
$k
][
'step_content'
]
=
$step_content
;
$insert_data
[
$k
][
'type'
]
=
$type
;
$insert_data
[
$k
][
'operation_id'
]
=
$this
->
userId
;
$insert_data
[
$k
][
'operation_name'
]
=
$this
->
userName
;
$insert_data
[
$k
][
'house_number'
]
=
$house_number
;
// $insert_data[$k]['is_open'] = $is_open;
$insert_data
[
$k
][
'create_time'
]
=
date
(
'Y-m-d H:i:s'
);
}
}
else
{
$insert_data
[
0
][
'bargain_id'
]
=
$bargain_id
;
$insert_data
[
0
][
'step_content'
]
=
$step_content
;
$insert_data
[
0
][
'type'
]
=
$type
;
$insert_data
[
0
][
'operation_id'
]
=
$this
->
userId
;
$insert_data
[
0
][
'operation_name'
]
=
$this
->
userName
;
$insert_data
[
0
][
'house_number'
]
=
$house_number
;
// $insert_data[0]['is_open'] = $is_open;
$insert_data
[
0
][
'create_time'
]
=
date
(
'Y-m-d H:i:s'
);
}
$m_bargain_log
=
new
OfficeOBargainLogModel
();
return
$m_bargain_log
->
addLog
(
$insert_data
);
}
/**
* 检查是否有邀请人(客户邀请客户)
*
* @return \think\Response
*/
public
function
checkReferrer
()
{
$report_id
=
$this
->
params
[
'report_id'
];
if
(
empty
(
$report_id
))
{
return
$this
->
response
(
101
,
'参数错误'
);
}
$m_report
=
new
OfficeOReportModel
();
$m_user
=
new
Users
();
$user_id
=
$m_report
->
getFieldValue
(
'user_id'
,
[
'id'
=>
$report_id
]);
$id
=
$m_user
->
getUserByWhereValue
(
'id'
,
[
'id'
=>
$user_id
,
'referrer_source'
=>
10
,
'status'
=>
0
]);
$is_show
=
0
;
if
(
$id
)
{
$is_show
=
1
;
}
return
$this
->
response
(
200
,
''
,
[
'is_show'
=>
$is_show
]);
}
/**
* 根据成交报告order_id查询经纪人
* 1盘方,2客方,3反签,4独家,5合作方,6APP盘下载方,7APP客下载方
*
* @return \think\Response
*/
public
function
searchOrderAgents
()
{
$params
=
$this
->
params
;
/* $params = array(
"type" => 1,//1盘方,2客方,3反签,4独家,5合作方
"order_id" => 36,
);*/
if
(
!
isset
(
$params
[
"order_id"
]))
{
return
$this
->
response
(
"101"
,
"请求参数错误"
);
}
try
{
$order_service
=
new
OfficeOrderLogService
();
$list
=
$order_service
->
searchBargainAllAgents
(
$params
[
"order_id"
]);
if
(
count
(
$list
)
>
0
)
{
return
$this
->
response
(
"200"
,
"request success"
,
$list
);
}
else
{
return
$this
->
response
(
"200"
,
"request null"
);
}
}
catch
(
\Exception
$e
)
{
return
$this
->
response
(
"101"
,
"request error,msg:"
.
$e
);
}
}
/**
* 新增分佣提成
*
* @return \think\Response
*/
public
function
addBargain
()
{
$data
[
'code'
]
=
200
;
$data
[
'msg'
]
=
""
;
$data
[
'data'
]
=
[];
if
(
empty
(
$this
->
params
[
'id'
])
||
empty
(
$this
->
params
[
'agent_id'
])
||
empty
(
$this
->
params
[
'role'
]))
{
$data
[
'code'
]
=
101
;
$data
[
'msg'
]
=
'提交信息错误!'
;
}
else
{
try
{
$data
[
'data'
]
=
$this
->
m_bargain
->
addBargainCommission
(
$this
->
params
[
'id'
],
$this
->
userId
,
$this
->
params
[
'agent_id'
],
$this
->
params
[
'role'
],
$this
->
params
[
'scale_fee'
],
$this
->
params
[
'scale'
],
1
);
$this
->
updatePerformance
((
int
)
$this
->
params
[
'bargain_id'
],
(
int
)
$this
->
params
[
'agent_id'
]);
}
catch
(
\Exception
$e
)
{
return
$this
->
response
(
101
,
'内部错误,新增分佣提成失败!请联系运营。'
);
}
if
(
$data
[
'data'
]
==
0
)
{
$data
[
'code'
]
=
101
;
$data
[
'msg'
]
=
'Add the failure.'
;
}
}
return
$this
->
response
(
$data
[
'code'
],
$data
[
'msg'
],
$data
[
'data'
]);
}
/**
* 更新个人业绩
*
* @param int $bargain_id
* @param int $agent_id
* @return bool
*/
private
function
updatePerformance
(
int
$bargain_id
=
0
,
int
$agent_id
=
0
)
:
bool
{
$where
=
[];
if
(
$bargain_id
)
{
$where
[
'b.id'
]
=
$bargain_id
;
}
if
(
$agent_id
)
{
$where
[
'a.id'
]
=
$agent_id
;
}
if
(
!
empty
(
$where
))
{
//获取被修改人信息
$m_agent
=
new
AAgents
();
$agent_data
=
$m_agent
->
agentBargainDetail
(
'a.id,a.store_id,a.district_id,b.create_time'
,
$where
);
$this
->
updatePerformanceData
(
$agent_data
[
'id'
],
$agent_data
[
'create_time'
],
$agent_data
[
'store_id'
],
$agent_data
[
'district_id'
]);
}
return
true
;
}
/**
* 更新业绩统计
*
* @param $id
* @param $create_time
* @param $store_id
* @param $district_id
*/
private
function
updatePerformanceData
(
$id
,
$create_time
,
$store_id
,
$district_id
)
{
//更新业绩统计
$sum
=
new
ResultsSummaryNewTask
();
$date
=
date
(
'Y-m-d'
,
strtotime
(
$create_time
));
$sum
->
updateTotalByAgentId
(
$id
,
$store_id
,
$district_id
,
$date
,
$this
->
siteId
);
//被修改的人
}
/**
* 成交报告分佣方详情
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getBargainCommission
()
{
if
(
empty
(
$this
->
params
[
'bargain_id'
]))
{
return
$this
->
response
(
101
,
'成交报告id为空'
);
}
$field
=
'a.id,a.scale,a.agent_id,a.role,a.scale_fee,b.scale as new_scale,b.should_commission,a.create_time,a.father_id,a.create_time'
;
$data
=
$this
->
m_bargain
->
getBargainPartialDetail
(
$field
,
[
'id'
=>
$this
->
params
[
'bargain_id'
]
]);
//检查成交报告是否存在
if
(
empty
(
$data_arr
[
'id'
]))
{
return
$this
->
response
(
101
,
'没有成交报告信息'
);
}
if
(
$this
->
request
->
isGet
())
{
$data
[
'scale'
]
=
empty
(
$data
[
'new_scale'
])
?
$data
[
'scale'
]
:
$data
[
'new_scale'
];
$data
[
'scale_fee'
]
=
empty
(
$data
[
'should_commission'
])
?
$data
[
'scale_fee'
]
:
$data
[
'should_commission'
];
$redis
=
new
RedisCacheService
();
$agent_data
=
$redis
->
getRedisCache
(
2
,
$data
[
'agent_id'
]);
$data
[
'district_name'
]
=
$agent_data
[
'district_name'
];
$data
[
'store_name'
]
=
$agent_data
[
'store_name'
];
$data
[
'name'
]
=
$agent_data
[
'name'
];
$data
[
'phone'
]
=
$agent_data
[
'phone'
];
$data
[
'store_id'
]
=
$agent_data
[
'store_id'
];
$data
[
'district_id'
]
=
$agent_data
[
'district_id'
];
return
$this
->
response
(
200
,
''
,
$data
);
}
if
(
empty
(
$this
->
params
[
'agent_id'
]))
{
return
$this
->
response
(
101
,
'经纪人id为空'
);
}
if
(
empty
(
$this
->
params
[
'scale'
]))
{
return
$this
->
response
(
101
,
'分佣比例为空'
);
}
$update
[
'agent_id'
]
=
$this
->
params
[
'agent_id'
];
$update
[
'scale'
]
=
$this
->
params
[
'scale'
];
$update
[
'role'
]
=
$this
->
params
[
'role'
];
$update
[
'scale_fee'
]
=
$this
->
params
[
'scale_fee'
];
$data
=
$this
->
m_bargain
->
updateBargainById
(
$this
->
params
[
'bargain_id'
],
$update
);
//更改分佣方
$comm
=
new
OfficeOPartialCommission
();
$partial_data
[
'scale'
]
=
$this
->
params
[
'scale'
];
$partial_data
[
'role'
]
=
$this
->
params
[
'role'
];
$partial_data
[
'should_commission'
]
=
$this
->
params
[
'scale_fee'
];
$partial_data
[
'agent_id'
]
=
$this
->
params
[
'agent_id'
];
$comm
->
editData
(
$partial_data
,
$this
->
params
[
'bargain_id'
],
'bargain_id'
);
/*记录日志 start*/
$father_id
=
$this
->
params
[
'bargain_id'
];
if
(
$data_arr
[
'father_id'
]
==
0
)
{
$father_id
=
$data_arr
[
'father_id'
];
}
$content
=
''
;
if
(
$data_arr
[
'agent_id'
]
!=
$this
->
params
[
'agent_id'
])
{
$agent_id
[
0
]
=
$data_arr
[
'agent_id'
];
$agent_id
[
1
]
=
$this
->
params
[
'agent_id'
];
$m_agent
=
new
AAgents
();
$agent_data
=
$m_agent
->
getAgentById
(
'id,name,phone,district_id,store_id'
,
[
'in_id'
=>
$agent_id
]);
foreach
(
$agent_data
as
$v
)
{
if
(
$v
[
'id'
]
==
$data_arr
[
'agent_id'
])
{
$this
->
totalOfficialReceipts
(
$v
[
'id'
],
$v
[
'district_id'
],
$v
[
'store_id'
],
$data_arr
[
'create_time'
]);
$content
.=
'【分佣方:'
.
$v
[
'name'
]
.
'-'
.
$v
[
'phone'
]
.
'】'
;
}
if
(
$v
[
'id'
]
==
$this
->
params
[
'agent_id'
])
{
$this
->
totalOfficialReceipts
(
$v
[
'id'
],
$v
[
'district_id'
],
$v
[
'store_id'
],
$data_arr
[
'create_time'
]);
$content
.=
'【修改为:'
.
$v
[
'name'
]
.
'-'
.
$v
[
'phone'
]
.
'】'
;
}
}
}
if
(
$this
->
params
[
'scale'
]
!=
$data_arr
[
'scale'
])
{
$content
.=
'【分佣比例修改为:'
.
$this
->
params
[
'scale'
]
.
'】'
;
}
if
(
$this
->
params
[
'scale_fee'
]
!=
$data_arr
[
'scale_fee'
])
{
$content
.=
'【应分佣金修改为:'
.
$this
->
params
[
'scale_fee'
]
.
'】'
;
}
if
(
!
empty
(
$content
))
{
$this
->
editRecordLog
(
$father_id
,
'【编号:'
.
$father_id
.
'】'
.
$content
);
}
/*记录日志 end*/
return
$this
->
response
(
200
,
'修改成功'
,
$data
);
}
/**
* (临时处理)业绩统计-实收统计
*
* @param $agent_id
* @param $district_id
* @param $store_id
* @param $date
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
totalOfficialReceipts
(
$agent_id
,
$district_id
,
$store_id
,
$date
)
{
//获取被修改人信息
$m_agent_total
=
new
TAgentTotalModel
();
$date
=
date
(
'Y-m-d'
,
strtotime
(
$date
));
$update_data
=
[];
$where_bargain
[
'agent_id'
]
=
$agent_id
;
$where_bargain
[
'create_time'
]
=
[
'BETWEEN'
,
[
$date
.
' 00:00:00'
,
$date
.
' 23:59:59'
]];
//实收
$receivedSum
=
$this
->
m_bargain
->
getAddBargainNumGroupTimeNew
(
$where_bargain
,
2
);
//1表示业绩 2表示实收
$received_sum
=
empty
(
$receivedSum
[
0
][
"num"
])
?
0
:
$receivedSum
[
0
][
"num"
];
//业绩
$performanceSum
=
$this
->
m_bargain
->
getAddBargainNumGroupTimeNew
(
$where_bargain
,
1
);
//1表示业绩 2表示实收
$performance_sum
=
empty
(
$performanceSum
[
0
][
"num"
])
?
0
:
$performanceSum
[
0
][
"num"
];
$id
=
$m_agent_total
->
getTotalEndTimeByAgentId
(
'id'
,
[
'total_time'
=>
$date
,
'agent_id'
=>
$where_bargain
[
'agent_id'
]]);
//成交报告
$bargainSum
=
$this
->
m_bargain
->
getAddBargainNumGroupTimeNew
(
$where_bargain
,
3
);
//表示统计
$bargain_sum
=
empty
(
$bargainSum
[
0
][
"num"
])
?
0
:
$bargainSum
[
0
][
'num'
];
if
(
empty
(
$id
[
0
][
'id'
]))
{
$insert_data
[]
=
[
'store_id'
=>
$store_id
,
'district_id'
=>
$district_id
,
'agent_id'
=>
$agent_id
,
'official_receipts'
=>
$received_sum
,
'performance'
=>
$performance_sum
,
'total_time'
=>
$date
,
'bargain_sum'
=>
$bargain_sum
,
'create_time'
=>
date
(
'Y-m-d H:i:s'
)
];
$m_agent_total
->
addTotal
(
$insert_data
);
}
else
{
$update_data
[]
=
[
'official_receipts'
=>
$received_sum
,
'performance'
=>
$performance_sum
,
'bargain_sum'
=>
$bargain_sum
,
'id'
=>
$id
[
0
][
'id'
],
'update_time'
=>
date
(
'Y-m-d H:i:s'
)
];
$m_agent_total
->
saveTotal
(
$update_data
);
}
return
;
}
/**
* 更新多人业绩
*
* @param int $bargain_id
* @return array
*/
private
function
updatePerformanceAll
(
int
$bargain_id
=
0
,
$agent_id
=
0
)
:
array
{
$data
[
'status'
]
=
'fail'
;
try
{
$where
=
$update_data
=
[];
if
(
$bargain_id
)
{
$where
[]
=
[
'EXP'
,
'b.id = '
.
$bargain_id
.
' OR b.father_id='
.
$bargain_id
];
}
if
(
$agent_id
)
{
$where
[
'a.id'
]
=
$agent_id
;
}
if
(
!
empty
(
$where
))
{
//获取被修改人信息
$m_agent
=
new
AAgents
();
$agent_data
=
$m_agent
->
agentBargainAll
(
'a.id,a.store_id,a.district_id,b.create_time'
,
$where
);
foreach
(
$agent_data
as
$k
=>
$v
)
{
$create_time
=
date
(
'Y-m-d'
,
strtotime
(
$v
[
'create_time'
]));
$this
->
totalOfficialReceipts
(
$v
[
'id'
],
$v
[
'district_id'
],
$v
[
'store_id'
],
$create_time
);
}
$data
[
'status'
]
=
'successful'
;
}
}
catch
(
\Exception
$e
)
{
$data
[
'msg'
]
=
'内部错误:'
.
$e
->
getMessage
();
}
return
$data
;
}
/**
* 删除分佣方
*
* @return \think\Response
*/
public
function
delPartialCommission
()
{
if
(
empty
(
$this
->
params
[
'partial_id'
]))
{
return
$this
->
response
(
101
,
'参数错误'
);
}
$agent_id
=
$this
->
m_bargain
->
getFieldValue
(
'agent_id'
,
[
'id'
=>
$this
->
params
[
'partial_id'
],
'status'
=>
[
'<>'
,
30
]]);
if
(
empty
(
$agent_id
))
{
return
$this
->
response
(
101
,
'没有该记录'
);
}
$partial_id
=
$this
->
params
[
'partial_id'
];
$data
[
'status'
]
=
30
;
$num
=
$this
->
m_bargain
->
updateBargainById
(
$partial_id
,
$data
);
if
(
$num
>
0
)
{
$m_partial
=
new
OfficeOPartialCommission
();
$m_partial
->
editData
([
'is_del'
=>
1
],
$this
->
params
[
'partial_id'
],
'bargain_id'
);
$this
->
updatePerformanceAll
(
$this
->
params
[
'partial_id'
],
$agent_id
);
$m_tax
=
new
OfficeOTaxes
();
$m_tax
->
updateData
([
'is_del'
=>
1
],[
'agent_id'
=>
$agent_id
,
'bargain_id'
=>
$partial_id
]);
$result
[
'code'
]
=
200
;
$result
[
'msg'
]
=
'删除成功'
;
}
else
{
$result
[
'code'
]
=
101
;
$result
[
'msg'
]
=
'删除失败'
;
}
return
$this
->
response
(
$result
[
'code'
],
$result
[
'msg'
]);
}
/**
* 获取实收日期
*
* @return \think\Response
*/
public
function
getRealIncome
()
{
if
(
empty
(
$this
->
params
[
'bargain_id'
]))
{
return
$this
->
response
(
101
,
'参数错误'
);
}
$data
=
[];
try
{
$code
=
200
;
$msg
=
''
;
$m_real_income
=
new
OfficeORealIncome
();
$father_id
=
$this
->
m_bargain
->
getBargainDetail
(
'father_id'
,
[
'id'
=>
$this
->
params
[
'bargain_id'
]]);
if
(
empty
(
$father_id
[
0
][
'father_id'
]))
{
$bargain_id
=
$this
->
params
[
'bargain_id'
];
}
else
{
$bargain_id
=
$father_id
[
0
][
'father_id'
];
}
$data
=
$m_real_income
->
getBargainTaxes
(
$bargain_id
,
'id,income_time,money'
);
}
catch
(
\Exception
$e
)
{
$code
=
101
;
$msg
=
$e
->
getMessage
();
}
return
$this
->
response
(
$code
,
$msg
,
$data
);
}
/**
* 增加实收佣金
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
addRealIncome
()
{
if
(
empty
(
$this
->
params
[
'bargain_id'
])
||
!
isset
(
$this
->
params
[
'is_account_commission'
]))
{
return
$this
->
response
(
101
,
'请求参数错误'
);
}
$bargain_data
=
$this
->
m_bargain
->
getCheckBargain
(
'a.id,a.agent_id,a.role,a.create_time,d.store_id,d.district_id,a.report_id,a.order_id'
,
$this
->
params
[
'bargain_id'
]);
//排除成交报告其它状态
if
(
empty
(
$bargain_data
[
'id'
]))
{
return
$this
->
response
(
101
,
'新增失败,成交报告数据异常'
);
}
//todo 修改成交报告 判断id> 0
$m_partial
=
new
OfficeOPartialCommission
();
$check
=
new
VipService
();
$m_report
=
new
OfficeOReportModel
();
$data
=
$this
->
params
[
"commission_date"
];
$add_arr
=
$update_arr
=
$log_data
=
$real_income_id
=
$real_income_old
=
[];
$i
=
$j
=
$user_id
=
0
;
foreach
(
$data
as
$item
)
{
if
(
!
isset
(
$item
[
'practical_fee'
])
||
!
isset
(
$item
[
'cash'
])
||
!
isset
(
$item
[
'service_charge'
])
||
!
isset
(
$item
[
'charity_fund'
])
||
!
isset
(
$item
[
'real_fee'
]))
{
return
$this
->
response
(
101
,
'请求参数异常请检查后提交'
);
}
if
(
$item
[
"commission_id"
]
>
0
)
{
$update_arr
[
$i
][
'id'
]
=
$item
[
'commission_id'
];
$update_arr
[
$i
][
'practical_fee'
]
=
$item
[
"practical_fee"
];
$update_arr
[
$i
][
'cash'
]
=
$item
[
"cash"
];
$update_arr
[
$i
][
'service_charge'
]
=
$item
[
'service_charge'
];
$update_arr
[
$i
][
'charity_fund'
]
=
$item
[
'charity_fund'
];
$update_arr
[
$i
][
'real_fee'
]
=
$item
[
'real_fee'
];
$update_arr
[
$i
][
'scale'
]
=
$item
[
'scale'
];
$update_arr
[
$i
][
'should_commission'
]
=
$item
[
'should_commission'
];
$update_arr
[
$i
][
'operation_id'
]
=
$this
->
userId
;
$update_arr
[
$i
][
'real_income_id'
]
=
$item
[
'real_income_id'
];
//确认分佣加时间 否则 只是保存分佣数据
if
(
$this
->
params
[
'is_account_commission'
]
==
1
)
{
if
(
$check
->
vip
(
$this
->
userId
,
'account_commission'
))
{
return
$this
->
response
(
101
,
'没有权限!'
);
}
$partial_data
=
$m_partial
->
getPartialDetail
(
'confirm_date'
,
[
'id'
=>
$item
[
'commission_id'
]]);
if
(
empty
(
$partial_data
[
'confirm_date'
]))
{
$update_arr
[
$i
][
'confirm_date'
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$update_arr
[
$i
][
'confirm_status'
]
=
1
;
}
if
(
empty
(
$user_id
)
&&
$this
->
params
[
'report_id'
])
{
$user_id
=
$m_report
->
getFieldValue
(
'user_id'
,[
'id'
=>
$this
->
params
[
'report_id'
]]);
if
(
$user_id
)
{
$service
=
new
ConvertCouponService
();
$service
->
convertCoupon
(
$user_id
,
$bargain_data
[
'report_id'
],
$this
->
params
[
'bargain_id'
],
$bargain_data
[
'order_id'
]);
//核销红包
}
}
}
$i
++
;
$log_data
[]
=
"[分佣比例(%):
{
$item
[
'scale'
]
}
][应分佣金(元):
{
$item
[
'should_commission'
]
}
][实分佣金(元):
{
$item
[
'real_fee'
]
}
]"
.
"[手续费(元):
{
$item
[
'service_charge'
]
}
][慈善基金(元):
{
$item
[
'charity_fund'
]
}
]"
.
"[现金奖(元):
{
$item
[
'cash'
]
}
][实收佣金(元):
{
$item
[
'practical_fee'
]
}
]"
;
$bargain_update_data
[]
=
[
'bargain_id'
=>
$this
->
params
[
'bargain_id'
],
'scale_fee'
=>
$item
[
'should_commission'
],
'scale'
=>
$item
[
'scale'
],
'agent_id'
=>
$item
[
'agent_id'
],
'store_id'
=>
$bargain_data
[
'store_id'
],
'district_id'
=>
$bargain_data
[
'district_id'
],
'create_time'
=>
$bargain_data
[
'create_time'
],
'real_income_id'
=>
$item
[
'real_income_id'
]
];
//处理修改收佣日期
$real_income_old
=
$m_partial
->
getFieldValue
(
'real_income_id'
,
[
'id'
=>
$item
[
'commission_id'
]]);
if
(
$item
[
'real_income_id'
]
!=
$real_income_old
)
{
$real_income_arr
[]
=
[
'real_income_id'
=>
$real_income_old
,
'agent_id'
=>
$item
[
'agent_id'
],
'store_id'
=>
$bargain_data
[
'store_id'
],
'district_id'
=>
$bargain_data
[
'district_id'
],
];
}
}
else
{
$add_arr
[
$j
][
'bargain_id'
]
=
$this
->
params
[
'bargain_id'
];
$add_arr
[
$j
][
'practical_fee'
]
=
$item
[
'practical_fee'
];
$add_arr
[
$j
][
'cash'
]
=
$item
[
'cash'
];
$add_arr
[
$j
][
'service_charge'
]
=
$item
[
'service_charge'
];
$add_arr
[
$j
][
'charity_fund'
]
=
$item
[
'charity_fund'
];
$add_arr
[
$j
][
'real_fee'
]
=
$item
[
'real_fee'
];
$add_arr
[
$j
][
'operation_id'
]
=
$this
->
userId
;
$add_arr
[
$j
][
'should_commission'
]
=
$item
[
'should_commission'
];
$add_arr
[
$j
][
'scale'
]
=
$item
[
'scale'
];
$add_arr
[
$j
][
'role'
]
=
$item
[
'role'
];
$add_arr
[
$j
][
'agent_id'
]
=
$item
[
'agent_id'
];
$add_arr
[
$j
][
'real_income_id'
]
=
$item
[
'real_income_id'
];
//确认分佣加时间 否则 只是保存分佣数据
if
(
$this
->
params
[
'is_account_commission'
]
==
1
)
{
if
(
$check
->
vip
(
$this
->
userId
,
'account_commission'
))
{
return
$this
->
response
(
101
,
'没有权限!'
);
}
$add_arr
[
$j
][
'confirm_date'
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$add_arr
[
$j
][
'confirm_status'
]
=
1
;
if
(
empty
(
$user_id
)
&&
$this
->
params
[
'report_id'
])
{
$user_id
=
$m_report
->
getFieldValue
(
'user_id'
,[
'id'
=>
$this
->
params
[
'report_id'
]]);
if
(
$user_id
)
{
$service
=
new
ConvertCouponService
();
$service
->
convertCoupon
(
$user_id
,
$bargain_data
[
'report_id'
],
$this
->
params
[
'bargain_id'
],
$bargain_data
[
'order_id'
]);
//核销红包
}
}
}
$j
++
;
$bargain_update_data
[]
=
[
'bargain_id'
=>
$this
->
params
[
'bargain_id'
],
'scale_fee'
=>
$item
[
'should_commission'
],
'scale'
=>
$item
[
'scale'
],
'agent_id'
=>
$item
[
'agent_id'
],
'store_id'
=>
$bargain_data
[
'store_id'
],
'district_id'
=>
$bargain_data
[
'district_id'
],
'create_time'
=>
$bargain_data
[
'create_time'
],
'real_income_id'
=>
$item
[
'real_income_id'
]
];
}
}
if
(
$j
>
0
)
{
$m_partial
->
addCommission
(
$add_arr
);
}
if
(
$i
>
0
)
{
$m_partial
->
addCommission
(
$update_arr
);
$this
->
editRecordLog
(
$this
->
params
[
'bargain_id'
],
implode
(
','
,
$log_data
));
//log记录
}
if
(
$j
==
0
&&
$this
->
params
[
'is_account_commission'
]
>
0
)
{
//没有新增数据,则把最后一条数据的分佣比例和应分佣金改掉
$params
[
'id'
]
=
$this
->
params
[
'is_account_commission'
];
$params
[
'should_commission'
]
=
$data
[
0
][
'should_commission'
];
$params
[
'scale'
]
=
$data
[
0
][
'scale'
];
$m_partial
->
addCommission
(
$params
);
}
$m_real
=
new
OfficeORealIncome
();
if
(
!
empty
(
$bargain_update_data
))
{
foreach
(
$bargain_update_data
as
$k
=>
$v
)
{
$update_data
[
'scale_fee'
]
=
$v
[
'scale_fee'
];
$update_data
[
'scale'
]
=
$v
[
'scale'
];
$update_data
[
'agent_id'
]
=
$v
[
'agent_id'
];
$this
->
m_bargain
->
updateBargainById
(
$v
[
'bargain_id'
],
$update_data
);
$this
->
updatePerformanceData
(
$v
[
'agent_id'
],
$v
[
'create_time'
],
$v
[
'store_id'
],
$v
[
'district_id'
]);
if
(
!
empty
(
$v
[
'real_income_id'
]))
{
//todo 收佣日期统计
$income_time
=
$m_real
->
getFieldValue
(
'income_time'
,
[
'id'
=>
$v
[
'real_income_id'
]]);
$this
->
updatePerformanceData
(
$v
[
'agent_id'
],
$income_time
,
$v
[
'store_id'
],
$v
[
'district_id'
]);
}
}
}
if
(
!
empty
(
$real_income_arr
))
{
foreach
(
$real_income_arr
as
$v3
)
{
//todo 收佣日期统计
$income_time
=
$m_real
->
getFieldValue
(
'income_time'
,
[
'id'
=>
$v3
[
'real_income_id'
]]);
// $this->updatePerformanceData($v3['agent_id'], $income_time, $v3['store_id'], $v3['district_id']);
$this
->
totalOfficialReceipts
(
$v3
[
'agent_id'
],
$v3
[
'district_id'
],
$v3
[
'store_id'
],
$income_time
);
}
}
// $data = $m_partial->addCommission($this->params, $this->userId);
return
$this
->
response
(
"200"
,
"request success"
,
[]);
}
/**
* 新增开票
*
* @return \think\Response
* @throws \Exception
*/
public
function
addTallAge
()
{
if
(
empty
(
$this
->
params
[
'bargain_id'
]))
{
return
$this
->
response
(
101
,
'新增实收参数错误'
);
}
if
(
empty
(
$this
->
params
[
'total_fee'
]))
{
return
$this
->
response
(
101
,
'开票金额为空'
);
}
if
(
empty
(
$this
->
params
[
'operation_date'
]))
{
return
$this
->
response
(
101
,
'开票日期为空'
);
}
$tax
=
$this
->
params
[
'tax'
];
if
(
empty
(
$tax
[
0
][
'agent_id'
]))
{
return
$this
->
response
(
101
,
'分佣方为空'
);
}
if
(
empty
(
$tax
[
0
][
'role'
]))
{
return
$this
->
response
(
101
,
'分佣方角色为空'
);
}
$bargain_data
=
$this
->
m_bargain
->
getCheckBargain
(
'a.id'
,
$this
->
params
[
'bargain_id'
]);
//排除成交报告其它状态
if
(
empty
(
$bargain_data
[
'id'
]))
{
return
$this
->
response
(
101
,
'成交报告数据异常!'
);
}
$bargain_id
=
$this
->
params
[
'bargain_id'
];
$operation_date
=
$this
->
params
[
'operation_date'
];
$insert_data
[
'bargain_id'
]
=
$bargain_id
;
$insert_data
[
'total_fee'
]
=
$this
->
params
[
'total_fee'
];
//开票金额
$insert_data
[
'father_id'
]
=
0
;
$insert_data
[
'operation_id'
]
=
$this
->
userId
;
//操作人
$insert_data
[
'operation_date'
]
=
$operation_date
;
//开票日期
$m_fee
=
new
OfficeOTaxes
();
$m_fee
->
editData
(
$insert_data
,
$this
->
params
[
'id'
]);
//开票新增和编辑
$m_agent
=
new
AAgents
();
$log_data
=
[];
foreach
(
$tax
as
$k
=>
$v
)
{
$tax
[
$k
][
'agent_name'
]
=
$m_agent
->
getAgentsById
(
$v
[
'agent_id'
],
'name'
);
$log_data
[]
=
'[经纪人:id:'
.
$v
[
'agent_id'
]
.
',名字:'
.
$tax
[
$k
][
'agent_name'
]
.
',税费:'
.
$v
[
'fee'
]
.
'][开票比例:'
.
$v
[
'scale'
]
.
']'
;
}
if
(
$this
->
params
[
'id'
]
&&
$this
->
params
[
'id'
]
>
0
)
{
//编辑
$father_id
=
$this
->
params
[
'id'
];
}
else
{
$father_id
=
isset
(
$m_fee
->
id
)
?
$m_fee
->
id
:
0
;
}
$data
=
$m_fee
->
addTaxes
(
$tax
,
$bargain_id
,
$this
->
userId
,
$father_id
,
$this
->
params
[
'total_fee'
],
$operation_date
);
$log_data_string
=
implode
(
','
,
$log_data
);
$content
=
"[开票金额:
{
$this
->
params
[
'total_fee'
]
}
][开票日期:
{
$operation_date
}
][
{
$log_data_string
}
]"
;
$this
->
editRecordLog
(
$this
->
params
[
'bargain_id'
],
$content
);
return
$this
->
response
(
"200"
,
"request success"
,
$data
);
}
/**
* 编辑开票税费查询某一条记录
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getTaxesById
()
{
if
(
empty
(
$this
->
params
[
'taxes_id'
]))
{
return
$this
->
response
(
101
,
'查询开票税费参数错误!'
);
}
$m_fee
=
new
OfficeOTaxes
();
$field
=
'id,bargain_id,fee,total_fee,father_id,operation_id,operation_date,agent_id,agent_name,role,scale,is_del'
;
$data
=
$m_fee
->
getTaxesId
(
$this
->
params
[
'taxes_id'
],
$field
);
return
$this
->
response
(
"200"
,
"request success"
,
$data
);
}
/**
* 删除开票税费
*
* @return \think\Response
*/
public
function
delTaxes
()
{
if
(
empty
(
$this
->
params
[
'taxes_id'
]))
return
$this
->
response
(
101
,
'参数错误'
);
$m_taxes
=
new
OfficeOTaxes
();
$num
=
$m_taxes
->
updateTaxesById
([
'id_or_father_id'
=>
$this
->
params
[
'taxes_id'
]
],
[
'is_del'
=>
1
]);
if
(
$num
>
0
)
{
$result
[
'code'
]
=
200
;
$result
[
'msg'
]
=
'删除成功'
;
}
else
{
$result
[
'code'
]
=
101
;
$result
[
'msg'
]
=
'删除失败'
;
}
return
$this
->
response
(
$result
[
'code'
],
$result
[
'msg'
]);
}
/**
* 撤销成交报告
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
backOutToOne
()
{
if
(
empty
(
$this
->
params
[
'bargain_id'
]))
{
return
$this
->
response
(
101
,
'参数错误'
);
}
$service_pay
=
new
OfficePayLogService
();
$money
=
$service_pay
->
getPayLogRefundSurplusMoney
(
$this
->
params
[
'bargain_id'
]);
if
(
$money
>
0
)
{
return
$this
->
response
(
101
,
'存在收款或退款,不能撤销!'
);
}
$is_adjustment
=
$service_pay
->
checkPayLogAdjustment
(
$this
->
params
[
'bargain_id'
]);
if
(
$is_adjustment
)
{
return
$this
->
response
(
101
,
'收款存在调整,不能撤销!'
);
}
$params
[
'content'
]
=
trim
(
$this
->
params
[
'content'
]);
//撤销原因
$m_financial
=
new
OfficeOFinancialAudit
();
$result
=
$m_financial
->
backOutUpdate
(
$this
->
params
[
'bargain_id'
],
$params
);
if
(
$result
)
{
$check
=
$this
->
updatePerformanceAll
(
$this
->
params
[
'bargain_id'
]);
if
(
$check
[
'status'
]
==
'fail'
)
{
return
$this
->
response
(
101
,
'更新个人业绩失败,请重试!'
);
}
$code
=
200
;
$this
->
editRecordLog
(
$this
->
params
[
'bargain_id'
],
'[撤销成交报告]'
,
3
);
//日志记录
$bargain_data
=
$this
->
m_bargain
->
getBargainDetail
(
'order_id,order_no,agent_id'
,
[
'id'
=>
$this
->
params
[
'bargain_id'
]
]);
$financial_data
[
'bargain_id'
]
=
$this
->
params
[
'bargain_id'
];
$financial_data
[
'audit_name'
]
=
$this
->
userName
;
$financial_data
[
'audit_id'
]
=
$this
->
userId
;
$financial_data
[
'agent_id'
]
=
$bargain_data
[
0
][
'agent_id'
];
$financial_data
[
'order_no'
]
=
$bargain_data
[
0
][
'order_no'
];
$financial_data
[
'order_id'
]
=
$bargain_data
[
0
][
'order_id'
];
$financial_data
[
'status'
]
=
1
;
$financial_data
[
'source'
]
=
3
;
$financial_data
[
'audit_level'
]
=
0
;
$financial_data
[
'remark'
]
=
empty
(
$this
->
params
[
'content'
])
?
""
:
$this
->
params
[
'content'
];
$financial_data
[
'audit_id'
]
=
$this
->
userId
;
$m_financial
->
addAudit
(
$financial_data
);
$msg
=
'撤销成功'
;
}
else
{
$code
=
101
;
$msg
=
'操作失败!'
;
}
return
$this
->
response
(
$code
,
$msg
);
}
}
\ No newline at end of file
application/model/OfficeOBargainLogModel.php
0 → 100644
View file @
c89a065b
<?php
namespace
app\model
;
use
think\Db
;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/2/1
* Time : 17:15
* Intro:
*/
class
OfficeOBargainLogModel
extends
BaseModel
{
protected
$table
=
"office_o_bargain_log"
;
private
$db_
;
function
__construct
()
{
$this
->
db_
=
Db
::
name
(
$this
->
table
);
}
public
function
addLog
(
$params
)
{
Db
::
startTrans
();
try
{
$this
->
db_
->
insertAll
(
$params
);
Db
::
commit
();
return
1
;
}
catch
(
\Exception
$e
)
{
Db
::
rollback
();
return
0
;
}
}
public
function
insertLog
(
$params
)
{
Db
::
startTrans
();
try
{
$id
=
$this
->
db_
->
insertGetId
(
$params
);
Db
::
commit
();
return
$id
;
}
catch
(
\Exception
$e
)
{
Db
::
rollback
();
return
0
;
}
}
/**
* 查询列表
*
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param string $field
* @param string $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getLogAgent
(
$pageNo
=
1
,
$pageSize
=
15
,
$order_
=
'id desc'
,
$field
=
''
,
$params
=
''
)
{
return
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
join
(
'a_agents b'
,
'a.operation_id = b.id'
,
'left'
)
->
where
(
$params
)
->
order
(
$order_
)
->
limit
(
$pageSize
)
->
page
(
$pageNo
)
->
select
();
}
/**
* 查询列表
*
* @param $params
* @return int|string
*/
public
function
getLogAgentTotal
(
$params
)
{
return
$this
->
alias
(
'a'
)
->
join
(
'a_agents b'
,
'a.operation_id = b.id'
,
'left'
)
->
where
(
$params
)
->
count
();
}
}
\ No newline at end of file
application/model/OfficeOBargainModel.php
View file @
c89a065b
...
...
@@ -1330,7 +1330,6 @@ class OfficeOBargainModel extends Model
$where_
[
'a.id'
]
=
$params
[
'id'
];
}
try
{
$result
=
$this
->
db_
->
field
(
$filed
)
->
alias
(
"a"
)
...
...
@@ -1339,23 +1338,6 @@ class OfficeOBargainModel extends Model
->
whereOr
(
$whereOr_
)
->
order
(
"a.id asc"
)
->
find
();
$result
[
'scale'
]
=
empty
(
$result
[
'new_scale'
])
?
$result
[
'scale'
]
:
$result
[
'new_scale'
];
$result
[
'scale_fee'
]
=
empty
(
$result
[
'should_commission'
])
?
$result
[
'scale_fee'
]
:
$result
[
'should_commission'
];
$m_agent
=
new
AAgents
();
$filed_agent
=
'a.id,a.name,a.phone,b.store_name,c.district_name,a.store_id,a.district_id'
;
$agent_info
=
$m_agent
->
getStoreDistrict
(
$filed_agent
,
[
'a.id'
=>
$result
[
'agent_id'
]
]);
$result
[
'district_name'
]
=
$agent_info
[
'district_name'
];
$result
[
'store_name'
]
=
$agent_info
[
'store_name'
];
$result
[
'name'
]
=
$agent_info
[
'name'
];
$result
[
'phone'
]
=
$agent_info
[
'phone'
];
$result
[
'store_id'
]
=
$agent_info
[
'store_id'
];
$result
[
'district_id'
]
=
$agent_info
[
'district_id'
];
}
catch
(
\Exception
$ex
)
{
$result
=
$ex
->
getMessage
();
}
return
$result
;
}
...
...
application/model/OfficeOFinancialAudit.php
0 → 100644
View file @
c89a065b
<?php
/**
* Created by PhpStorm.
* User: hujun
* Date: 2018/3/22
* Time: 15:25
*/
namespace
app\model
;
class
OfficeOFinancialAudit
extends
BaseModel
{
/**
* 添加审核通过记录
*
* @param $data
* @return false|int
*/
public
function
addAudit
(
$data
)
{
$save_data
[
'bargain_id'
]
=
$data
[
'bargain_id'
];
$save_data
[
'agent_id'
]
=
$data
[
'agent_id'
];
$save_data
[
'order_no'
]
=
$data
[
'order_no'
];
$save_data
[
'order_id'
]
=
$data
[
'order_id'
];
$save_data
[
'source'
]
=
$data
[
'source'
];
$save_data
[
'status'
]
=
$data
[
'status'
];
$save_data
[
'remark'
]
=
$data
[
'remark'
];
$save_data
[
'audit_level'
]
=
$data
[
'audit_level'
];
$save_data
[
'audit_id'
]
=
$data
[
'audit_id'
];
$save_data
[
'audit_name'
]
=
$data
[
'audit_name'
];
return
$this
->
save
(
$save_data
);
}
/**
* 获取最新审核
*
* @param $bargain_id
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getLastStep
(
$bargain_id
,
$source
)
{
return
$this
->
field
(
'id,audit_level'
)
->
where
([
'bargain_id'
=>
$bargain_id
,
'status'
=>
1
,
'source'
=>
$source
,
'is_del'
=>
0
])
->
order
(
'id desc'
)
->
find
();
}
/**
* @param $id
* @param $params
* @return int
* @throws \think\exception\PDOException
*/
public
function
updateBargainById
(
$id
,
$params
)
{
$params
[
"update_time"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$this
->
startTrans
();
try
{
$this
->
where
(
'id'
,
$id
)
->
update
(
$params
);
$this
->
commit
();
return
1
;
}
catch
(
\Exception
$e
)
{
$this
->
rollback
();
return
0
;
}
}
/**
* 撤销数据
*
* @param int $bargain_id
* @param array $params
* @return bool
* @throws \think\exception\PDOException
*/
public
function
backOutUpdate
(
int
$bargain_id
,
array
$params
=
[])
:
bool
{
if
(
empty
(
$bargain_id
))
{
return
false
;
}
$this
->
startTrans
();
// $data['is_del'] = 1; //去除之前的审核记录
// $this->editData($data, $bargain_id, 'bargain_id');
$m_bargain
=
new
OBargainModel
();
$update_data
[
'status'
]
=
20
;
$update_data
[
'audit_level'
]
=
0
;
$update_data
[
'content'
]
=
$params
[
'content'
];
//撤销原因
// $result_bargain = $m_bargain->updateBargain($bargain_id, $update_data);
$where
[]
=
[
'EXP'
,
'id='
.
$bargain_id
.
' or father_id='
.
$bargain_id
];
$where
[
'status'
]
=
[
'in'
,
'10,11,12,13'
];
$result_bargain
=
$m_bargain
->
updateBargainByWhere
(
$update_data
,
$where
);
if
(
$result_bargain
)
{
$this
->
commit
();
$result
=
true
;
}
else
{
$this
->
rollback
();
$result
=
false
;
}
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
selectFinancialByOrderNo
(
$filed
,
$params
)
{
$where_
=
[];
if
(
isset
(
$params
[
"order_id"
]))
{
$where_
[
"order_id"
]
=
$params
[
"order_id"
];
}
$where_
[
"is_del"
]
=
0
;
$where_
[
"source"
]
=
3
;
$data
=
$this
->
field
(
$filed
)
->
where
(
$where_
)
->
select
();
return
$data
;
}
}
\ No newline at end of file
application/model/OfficeOReportModel.php
View file @
c89a065b
...
...
@@ -786,6 +786,16 @@ class OfficeOReportModel extends Model
->
count
(
'a.id'
);
return
$result
;
}
/**
* @param $field
* @param $where
* @return mixed
*/
public
function
getFieldValue
(
$field
,
$where
)
{
return
$this
->
db
->
where
(
$where
)
->
value
(
$field
);
}
}
...
...
application/route.php
View file @
c89a065b
...
...
@@ -1076,6 +1076,19 @@ Route::group('office_index', [
'reportListThree/:check_status'
=>
[
'index/OfficeBargain/reportList'
,
[
'method'
=>
'get'
],
[
'check_status'
=>
3
]],
//财务 成交报告-未结单-第三级审核
'reportListStatement/:check_status'
=>
[
'index/OfficeBargain/reportList'
,
[
'method'
=>
'get'
],
[
'check_status'
=>
4
]],
//财务 成交报告-已结单
'reportListAll/:check_status'
=>
[
'index/OfficeBargain/reportList'
,
[
'method'
=>
'get'
],
[
'check_status'
=>
10
]],
//财务 成交报告-全部
'editBargainInfo'
=>
[
'index/OfficeBargain/editBargainInfo'
,
[
'method'
=>
'post'
]],
//修改成交报告佣金
'checkReferrer'
=>
[
'index/OfficeBargain/checkReferrer'
,
[
'method'
=>
'get'
]],
//检查是否有邀请人(客户邀请客户)
'searchOrderAgents'
=>
[
'index/OfficeBargain/searchOrderAgents'
,
[
'method'
=>
'GET'
]],
//order_id获取盘方,客方,反签,独家,合作方
'addBargain'
=>
[
'index/OfficeBargain/addBargain'
,
[
'method'
=>
'post'
]],
//新增成交报告佣金(分佣提成)
'getBargainCommission'
=>
[
'index/OfficeBargain/getBargainCommission'
,
[
'method'
=>
'GET|POST'
]],
//获取成交报告分佣方佣金和修改
'delPartialCommission'
=>
[
'index/OfficeBargain/delPartialCommission'
,
[
'method'
=>
'POST'
]],
//删除分佣方
'getRealIncome'
=>
[
'index/OfficeBargain/getRealIncome'
,
[
'method'
=>
'GET'
]],
//获取实收日期
'addRealIncome'
=>
[
'index/OfficeBargain/addRealIncome'
,
[
'method'
=>
'POST'
]],
//增加和编辑实收佣金
'addTallAge'
=>
[
'index/OfficeBargain/addTallAge'
,
[
'method'
=>
'POST'
]],
//新增和编辑开票税费
'getTaxesById'
=>
[
'index/OfficeBargain/getTaxesById'
,
[
'method'
=>
'POST|GET'
]],
//财务结单
'delTaxes'
=>
[
'index/OfficeBargain/delTaxes'
,
[
'method'
=>
'POST'
]],
//删除开票税费
'backOutToOne'
=>
[
'index/OfficeBargain/backOutToOne'
,
[
'method'
=>
'POST'
]],
//财务 成交报告-撤销成交报告
]);
Route
::
group
(
'office_api'
,
[
...
...
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