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
2caf67ba
Commit
2caf67ba
authored
Jun 27, 2019
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改收佣日期更新业绩
parent
eb4e530b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
155 additions
and
21 deletions
+155
-21
OfficeBargain.php
application/index/controller/OfficeBargain.php
+155
-21
No files found.
application/index/controller/OfficeBargain.php
View file @
2caf67ba
...
@@ -459,7 +459,7 @@ class OfficeBargain extends Basic
...
@@ -459,7 +459,7 @@ class OfficeBargain extends Basic
}
}
}
}
try
{
//
try {
if
(
$i
>
0
)
{
if
(
$i
>
0
)
{
$m_real
->
addRealIncome
(
$update_real_arr
);
$m_real
->
addRealIncome
(
$update_real_arr
);
}
}
...
@@ -477,6 +477,7 @@ class OfficeBargain extends Basic
...
@@ -477,6 +477,7 @@ class OfficeBargain extends Basic
//通过实收日期,更新业绩统计和实收统计。
//通过实收日期,更新业绩统计和实收统计。
if
(
isset
(
$update_total
))
{
if
(
isset
(
$update_total
))
{
$create_time
=
$this
->
m_bargain
->
getFieldValue
(
'create_time'
,
[
'id'
=>
$this
->
params
[
'id'
]]);
foreach
(
$update_total
as
$v
)
{
foreach
(
$update_total
as
$v
)
{
if
(
empty
(
$v
[
'income_time'
]))
{
if
(
empty
(
$v
[
'income_time'
]))
{
continue
;
continue
;
...
@@ -484,13 +485,13 @@ class OfficeBargain extends Basic
...
@@ -484,13 +485,13 @@ class OfficeBargain extends Basic
$real_where
[
'a.id'
]
=
$v
[
'fee_id'
];
$real_where
[
'a.id'
]
=
$v
[
'fee_id'
];
$real_data
=
$m_real
->
getIncomePartialList
(
'b.agent_id,c.store_id,c.district_id'
,
$real_where
);
$real_data
=
$m_real
->
getIncomePartialList
(
'b.agent_id,c.store_id,c.district_id'
,
$real_where
);
foreach
(
$real_data
as
$key
)
{
foreach
(
$real_data
as
$key
)
{
$this
->
totalOfficialReceipts
(
$key
[
'agent_id'
],
$key
[
'district_id'
],
$key
[
'store_id'
],
$v
[
'income_time'
]);
$this
->
totalOfficialReceiptsV2
(
$key
[
'agent_id'
],
$key
[
'district_id'
],
$key
[
'store_id'
],
$create_time
,
$v
[
'income_time'
]);
}
}
}
}
}
}
catch
(
\Exception
$e
)
{
return
$this
->
response
(
101
,
'内部错误,修改成交报告失败!请联系运营。'
);
}
}
// } catch (\Exception $e) {
// return $this->response(101, '内部错误,修改成交报告失败!请联系运营。');
// }
$data
[
'code'
]
=
200
;
$data
[
'code'
]
=
200
;
}
else
{
}
else
{
$data
[
'msg'
]
=
'Modify the failure.'
;
$data
[
'msg'
]
=
'Modify the failure.'
;
...
@@ -696,11 +697,11 @@ class OfficeBargain extends Basic
...
@@ -696,11 +697,11 @@ class OfficeBargain extends Basic
if
(
empty
(
$this
->
params
[
'bargain_id'
]))
{
if
(
empty
(
$this
->
params
[
'bargain_id'
]))
{
return
$this
->
response
(
101
,
'成交报告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.father_id,c.income_time'
;
$field
=
'a.id,a.scale,a.agent_id,a.role,a.scale_fee,b.scale as new_scale,b.should_commission,a.father_id,
a.create_time,
c.income_time'
;
$data
=
$this
->
m_bargain
->
getBargainPartialDetail
(
$field
,
[
'id'
=>
$this
->
params
[
'bargain_id'
]
]);
$data
=
$this
->
m_bargain
->
getBargainPartialDetail
(
$field
,
[
'id'
=>
$this
->
params
[
'bargain_id'
]
]);
//检查成交报告是否存在
//检查成交报告是否存在
if
(
empty
(
$data
_arr
[
'id'
]))
{
if
(
empty
(
$data
[
'id'
]))
{
return
$this
->
response
(
101
,
'没有成交报告信息'
);
return
$this
->
response
(
101
,
'没有成交报告信息'
);
}
}
...
@@ -744,35 +745,35 @@ class OfficeBargain extends Basic
...
@@ -744,35 +745,35 @@ class OfficeBargain extends Basic
/*记录日志 start*/
/*记录日志 start*/
$father_id
=
$this
->
params
[
'bargain_id'
];
$father_id
=
$this
->
params
[
'bargain_id'
];
if
(
$data
_arr
[
'father_id'
]
==
0
)
{
if
(
$data
[
'father_id'
]
==
0
)
{
$father_id
=
$data
_arr
[
'father_id'
];
$father_id
=
$data
[
'father_id'
];
}
}
$content
=
''
;
$content
=
''
;
if
(
$data
_arr
[
'agent_id'
]
!=
$this
->
params
[
'agent_id'
])
{
if
(
$data
[
'agent_id'
]
!=
$this
->
params
[
'agent_id'
])
{
$agent_id
[
0
]
=
$data
_arr
[
'agent_id'
];
$agent_id
[
0
]
=
$data
[
'agent_id'
];
$agent_id
[
1
]
=
$this
->
params
[
'agent_id'
];
$agent_id
[
1
]
=
$this
->
params
[
'agent_id'
];
$m_agent
=
new
AAgents
();
$m_agent
=
new
AAgents
();
$agent_data
=
$m_agent
->
getAgentById
(
'id,name,phone,district_id,store_id'
,
[
'in_id'
=>
$agent_id
]);
$agent_data
=
$m_agent
->
getAgentById
(
'id,name,phone,district_id,store_id'
,
[
'in_id'
=>
$agent_id
]);
foreach
(
$agent_data
as
$v
)
{
foreach
(
$agent_data
as
$v
)
{
if
(
$v
[
'id'
]
==
$data
_arr
[
'agent_id'
])
{
if
(
$v
[
'id'
]
==
$data
[
'agent_id'
])
{
$this
->
totalOfficialReceipts
(
$v
[
'id'
],
$v
[
'district_id'
],
$v
[
'store_id'
],
$data_arr
[
'income_time'
]);
$this
->
totalOfficialReceipts
V2
(
$v
[
'id'
],
$v
[
'district_id'
],
$v
[
'store_id'
],
$data
[
'create_time'
],
$data
[
'income_time'
]);
$content
.=
'【分佣方:'
.
$v
[
'name'
]
.
'-'
.
$v
[
'phone'
]
.
'】'
;
$content
.=
'【分佣方:'
.
$v
[
'name'
]
.
'-'
.
$v
[
'phone'
]
.
'】'
;
}
}
if
(
$v
[
'id'
]
==
$this
->
params
[
'agent_id'
])
{
if
(
$v
[
'id'
]
==
$this
->
params
[
'agent_id'
])
{
$this
->
totalOfficialReceipts
(
$v
[
'id'
],
$v
[
'district_id'
],
$v
[
'store_id'
],
$data_arr
[
'income_time'
]);
$this
->
totalOfficialReceipts
V2
(
$v
[
'id'
],
$v
[
'district_id'
],
$v
[
'store_id'
],
$data
[
'create_time'
],
$data
[
'income_time'
]);
$content
.=
'【修改为:'
.
$v
[
'name'
]
.
'-'
.
$v
[
'phone'
]
.
'】'
;
$content
.=
'【修改为:'
.
$v
[
'name'
]
.
'-'
.
$v
[
'phone'
]
.
'】'
;
}
}
}
}
}
}
if
(
$this
->
params
[
'scale'
]
!=
$data
_arr
[
'scale'
])
{
if
(
$this
->
params
[
'scale'
]
!=
$data
[
'scale'
])
{
$content
.=
'【分佣比例修改为:'
.
$this
->
params
[
'scale'
]
.
'】'
;
$content
.=
'【分佣比例修改为:'
.
$this
->
params
[
'scale'
]
.
'】'
;
}
}
if
(
$this
->
params
[
'scale_fee'
]
!=
$data
_arr
[
'scale_fee'
])
{
if
(
$this
->
params
[
'scale_fee'
]
!=
$data
[
'scale_fee'
])
{
$content
.=
'【应分佣金修改为:'
.
$this
->
params
[
'scale_fee'
]
.
'】'
;
$content
.=
'【应分佣金修改为:'
.
$this
->
params
[
'scale_fee'
]
.
'】'
;
}
}
...
@@ -839,6 +840,138 @@ class OfficeBargain extends Basic
...
@@ -839,6 +840,138 @@ class OfficeBargain extends Basic
return
;
return
;
}
}
/**
* (临时处理)业绩统计-实收统计
*
*
* @param $agent_id
* @param $district_id
* @param $store_id
* @param string $create_time
* @param string $income_time
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
totalOfficialReceiptsV2
(
$agent_id
,
$district_id
,
$store_id
,
$create_time
=
''
,
$income_time
=
''
)
{
//获取被修改人信息
$m_agent_total
=
new
OfficeTAgentTotalModel
();
$where_bargain
[
'agent_id'
]
=
$agent_id
;
if
(
!
empty
(
$create_time
)
&&
$income_time
==
$create_time
)
{
//处理同一天
$date
=
date
(
'Y-m-d'
,
strtotime
(
$create_time
));
$where_bargain
[
'create_time'
]
=
[
'BETWEEN'
,
[
$date
.
' 00:00:00'
,
$date
.
' 23:59:59'
]];
//实收
$receivedSum
=
$this
->
m_bargain
->
getReceivedGroupTimeNew
(
$where_bargain
);
//1表示业绩 2表示实收
$received_sum
=
empty
(
$receivedSum
[
0
][
"num"
])
?
'0.00'
:
$receivedSum
[
0
][
"num"
];
//业绩
$performanceSum
=
$this
->
m_bargain
->
getAddBargainNumGroupTimeNew
(
$where_bargain
,
1
);
//1表示业绩 2表示实收
$performance_sum
=
empty
(
$performanceSum
[
0
][
"num"
])
?
'0.00'
:
$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.00'
:
$bargainSum
[
0
][
'num'
];
if
(
empty
(
$id
[
0
][
'id'
]))
{
if
(
$received_sum
!=
'0.00'
||
$performance_sum
!=
'0.00'
||
$bargain_sum
!=
'0.00'
)
{
$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'
)
];
}
}
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'
)
];
}
}
else
{
//处理时间不一致
if
(
$create_time
)
{
$date
=
date
(
'Y-m-d'
,
strtotime
(
$create_time
));
$where_bargain
[
'create_time'
]
=
[
'BETWEEN'
,
[
$date
.
' 00:00:00'
,
$date
.
' 23:59:59'
]];
//业绩
$performanceSum
=
$this
->
m_bargain
->
getAddBargainNumGroupTimeNew
(
$where_bargain
,
1
);
//1表示业绩 2表示实收
$performance_sum
=
empty
(
$performanceSum
[
0
][
"num"
])
?
0.00
:
$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.00'
:
$bargainSum
[
0
][
'num'
];
if
(
empty
(
$id
[
0
][
'id'
]))
{
if
(
$performance_sum
!=
'0.00'
||
$bargain_sum
!=
'0.00'
)
{
$insert_data
[]
=
[
'store_id'
=>
$store_id
,
'district_id'
=>
$district_id
,
'agent_id'
=>
$agent_id
,
'official_receipts'
=>
0
,
'performance'
=>
$performance_sum
,
'total_time'
=>
$date
,
'bargain_sum'
=>
$bargain_sum
,
'create_time'
=>
date
(
'Y-m-d H:i:s'
)
];
}
}
else
{
$update_data
[]
=
[
'performance'
=>
$performance_sum
,
'bargain_sum'
=>
$bargain_sum
,
'id'
=>
$id
[
0
][
'id'
],
'update_time'
=>
date
(
'Y-m-d H:i:s'
)
];
}
}
//实收
if
(
$income_time
)
{
$date
=
date
(
'Y-m-d'
,
strtotime
(
$income_time
));
$where_bargain
[
'create_time'
]
=
[
'BETWEEN'
,
[
$date
.
' 00:00:00'
,
$date
.
' 23:59:59'
]];
$receivedSum
=
$this
->
m_bargain
->
getReceivedGroupTimeNew
(
$where_bargain
);
$received_sum
=
empty
(
$receivedSum
[
0
][
"num"
])
?
'0.00'
:
$receivedSum
[
0
][
"num"
];
$id
=
$m_agent_total
->
getTotalEndTimeByAgentId
(
'id'
,
[
'total_time'
=>
$date
,
'agent_id'
=>
$where_bargain
[
'agent_id'
]]);
if
(
empty
(
$id
[
0
][
'id'
]))
{
if
(
$received_sum
!=
'0.00'
)
{
$insert_data
[]
=
[
'store_id'
=>
$store_id
,
'district_id'
=>
$district_id
,
'agent_id'
=>
$agent_id
,
'official_receipts'
=>
$received_sum
,
'performance'
=>
0
,
'total_time'
=>
$date
,
'bargain_sum'
=>
0
,
'create_time'
=>
date
(
'Y-m-d H:i:s'
)
];
}
}
else
{
$update_data
[]
=
[
'official_receipts'
=>
$received_sum
,
'id'
=>
$id
[
0
][
'id'
],
'update_time'
=>
date
(
'Y-m-d H:i:s'
)
];
}
}
}
if
(
isset
(
$insert_data
))
{
$m_agent_total
->
addTotal
(
$insert_data
);
}
if
(
isset
(
$update_data
))
{
$m_agent_total
->
saveTotal
(
$update_data
);
}
return
;
}
/**
/**
* 更新多人业绩
* 更新多人业绩
*
*
...
@@ -861,10 +994,11 @@ class OfficeBargain extends Basic
...
@@ -861,10 +994,11 @@ class OfficeBargain extends Basic
if
(
!
empty
(
$where
))
{
if
(
!
empty
(
$where
))
{
//获取被修改人信息
//获取被修改人信息
$m_agent
=
new
AAgents
();
$m_agent
=
new
AAgents
();
$agent_data
=
$m_agent
->
agentBargainOfficeAll
(
'a.id,a.store_id,a.district_id,d.income_time'
,
$where
);
$agent_data
=
$m_agent
->
agentBargainOfficeAll
(
'a.id,a.store_id,a.district_id,d.income_time
,b.create_time
'
,
$where
);
foreach
(
$agent_data
as
$k
=>
$v
)
{
foreach
(
$agent_data
as
$k
=>
$v
)
{
$income_time
=
date
(
'Y-m-d'
,
strtotime
(
$v
[
'income_time'
]));
$income_time
=
date
(
'Y-m-d'
,
strtotime
(
$v
[
'income_time'
]));
$this
->
totalOfficialReceipts
(
$v
[
'id'
],
$v
[
'district_id'
],
$v
[
'store_id'
],
$income_time
);
$create_time
=
date
(
'Y-m-d'
,
strtotime
(
$v
[
'create_time'
]));
$this
->
totalOfficialReceiptsV2
(
$v
[
'id'
],
$v
[
'district_id'
],
$v
[
'store_id'
],
$create_time
,
$income_time
);
}
}
$data
[
'status'
]
=
'successful'
;
$data
[
'status'
]
=
'successful'
;
}
}
...
@@ -1122,7 +1256,7 @@ class OfficeBargain extends Basic
...
@@ -1122,7 +1256,7 @@ class OfficeBargain extends Basic
//todo 收佣日期统计
//todo 收佣日期统计
$income_time
=
$m_real
->
getFieldValue
(
'income_time'
,
[
'id'
=>
$v3
[
'real_income_id'
]]);
$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->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
);
$this
->
totalOfficialReceipts
V2
(
$v3
[
'agent_id'
],
$v3
[
'district_id'
],
$v3
[
'store_id'
],
''
,
$income_time
);
}
}
}
}
// $data = $m_partial->addCommission($this->params, $this->userId);
// $data = $m_partial->addCommission($this->params, $this->userId);
...
@@ -1315,7 +1449,7 @@ class OfficeBargain extends Basic
...
@@ -1315,7 +1449,7 @@ class OfficeBargain extends Basic
$msg
=
''
;
$msg
=
''
;
$where
[
'a.status'
]
=
[
'in'
,
'20,21'
];
$where
[
'a.status'
]
=
[
'in'
,
'20,21'
];
$where
[]
=
[
'EXP'
,
'a.id ='
.
$this
->
params
[
'id'
]
.
' OR a.father_id='
.
$this
->
params
[
'id'
]];
$where
[]
=
[
'EXP'
,
'a.id ='
.
$this
->
params
[
'id'
]
.
' OR a.father_id='
.
$this
->
params
[
'id'
]];
$agent_arr
=
$this
->
m_bargain
->
agentBargainIncome
(
'a.agent_id,b.store_id,b.district_id,d.income_time'
,
$where
);
$agent_arr
=
$this
->
m_bargain
->
agentBargainIncome
(
'a.agent_id,b.store_id,b.district_id,
a.create_time,
d.income_time'
,
$where
);
if
(
empty
(
$agent_arr
))
{
if
(
empty
(
$agent_arr
))
{
return
$this
->
response
(
$code
,
'没有该记录'
);
return
$this
->
response
(
$code
,
'没有该记录'
);
...
@@ -1329,7 +1463,7 @@ class OfficeBargain extends Basic
...
@@ -1329,7 +1463,7 @@ class OfficeBargain extends Basic
if
(
$is_ok
)
{
if
(
$is_ok
)
{
foreach
(
$agent_arr
as
$k
=>
$v
)
{
foreach
(
$agent_arr
as
$k
=>
$v
)
{
try
{
try
{
$this
->
totalOfficialReceipts
(
$v
[
'agent_id'
],
$v
[
'district_id'
],
$v
[
'store_id
'
],
$v
[
'income_time'
]);
$this
->
totalOfficialReceipts
V2
(
$v
[
'agent_id'
],
$v
[
'district_id'
],
$v
[
'store_id'
],
$v
[
'create_time
'
],
$v
[
'income_time'
]);
$code
=
200
;
$code
=
200
;
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
$msg
=
'恢复失败:'
.
$e
->
getMessage
();
$msg
=
'恢复失败:'
.
$e
->
getMessage
();
...
...
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