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
9263102a
Commit
9263102a
authored
Jun 28, 2019
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
商铺同步修改
parent
e104e033
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
163 additions
and
11 deletions
+163
-11
Finance.php
application/index/controller/Finance.php
+144
-10
OfficeBargain.php
application/index/controller/OfficeBargain.php
+0
-1
OBargainModel.php
application/model/OBargainModel.php
+19
-0
No files found.
application/index/controller/Finance.php
View file @
9263102a
...
...
@@ -557,6 +557,7 @@ class Finance extends Basic
//通过实收日期,更新业绩统计和实收统计。
if
(
isset
(
$update_total
))
{
$create_time
=
$this
->
m_bargain
->
getFieldValue
(
'create_time'
,
[
'id'
=>
$this
->
params
[
'id'
]]);
foreach
(
$update_total
as
$v
)
{
if
(
empty
(
$v
[
'income_time'
]))
{
continue
;
...
...
@@ -564,7 +565,7 @@ class Finance extends Basic
$real_where
[
'a.id'
]
=
$v
[
'fee_id'
];
$real_data
=
$m_real
->
getIncomePartialList
(
'b.agent_id,c.store_id,c.district_id'
,
$real_where
);
foreach
(
$real_data
as
$key
)
{
$this
->
totalOfficialReceipts
(
$key
[
'agent_id'
],
$key
[
'district_id'
],
$key
[
'store_id'
]
,
$v
[
'income_time'
]);
$this
->
totalOfficialReceipts
V2
(
$key
[
'agent_id'
],
$key
[
'district_id'
],
$key
[
'store_id'
],
$create_time
,
$v
[
'income_time'
]);
}
}
}
...
...
@@ -1646,7 +1647,7 @@ class Finance extends Basic
//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
);
$this
->
totalOfficialReceipts
V2
(
$v3
[
'agent_id'
],
$v3
[
'district_id'
],
$v3
[
'store_id'
],
''
,
$income_time
);
}
}
// $data = $m_partial->addCommission($this->params, $this->userId);
...
...
@@ -2605,7 +2606,7 @@ class Finance extends Basic
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.creat
e_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.incom
e_time'
;
if
(
$this
->
request
->
isGet
())
{
$data
=
$this
->
m_bargain
->
getBargainPartialDetail
(
$field
,
[
'id'
=>
$this
->
params
[
'bargain_id'
]
]);
return
$this
->
response
(
200
,
''
,
$data
);
...
...
@@ -2655,12 +2656,12 @@ class Finance extends Basic
foreach
(
$agent_data
as
$v
)
{
if
(
$v
[
'id'
]
==
$data_arr
[
'agent_id'
])
{
$this
->
totalOfficialReceipts
(
$v
[
'id'
],
$v
[
'district_id'
],
$v
[
'store_id'
],
$data_arr
[
'creat
e_time'
]);
$this
->
totalOfficialReceipts
V2
(
$v
[
'id'
],
$v
[
'district_id'
],
$v
[
'store_id'
],
$data
[
'create_time'
],
$data
[
'incom
e_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
[
'creat
e_time'
]);
$this
->
totalOfficialReceipts
V2
(
$v
[
'id'
],
$v
[
'district_id'
],
$v
[
'store_id'
],
$data
[
'create_time'
],
$data
[
'incom
e_time'
]);
$content
.=
'【修改为:'
.
$v
[
'name'
]
.
'-'
.
$v
[
'phone'
]
.
'】'
;
}
}
...
...
@@ -2790,10 +2791,11 @@ class Finance extends Basic
if
(
!
empty
(
$where
))
{
//获取被修改人信息
$m_agent
=
new
AAgents
();
$agent_data
=
$m_agent
->
agentBargain
All
(
'a.id,a.store_id,a.district_id,d.incom
e_time'
,
$where
);
$agent_data
=
$m_agent
->
agentBargain
OfficeAll
(
'a.id,a.store_id,a.district_id,d.income_time,b.creat
e_time'
,
$where
);
foreach
(
$agent_data
as
$k
=>
$v
)
{
$create_time
=
date
(
'Y-m-d'
,
strtotime
(
$v
[
'income_time'
]));
$this
->
totalOfficialReceipts
(
$v
[
'id'
],
$v
[
'district_id'
],
$v
[
'store_id'
],
$create_time
);
$income_time
=
date
(
'Y-m-d'
,
strtotime
(
$v
[
'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'
;
}
...
...
@@ -2899,6 +2901,138 @@ class Finance extends Basic
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
TAgentTotalModel
();
$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
;
}
/**
* 收款记录
*
...
...
@@ -4800,7 +4934,7 @@ class Finance extends Basic
$msg
=
''
;
$where
[
'a.status'
]
=
[
'in'
,
'20,21'
];
$where
[]
=
[
'EXP'
,
'a.id ='
.
$this
->
params
[
'id'
]
.
' OR a.father_id='
.
$this
->
params
[
'id'
]];
$agent_arr
=
$this
->
m_bargain
->
agentBargain
All
(
'a.create_time,a.agent_id,b.store_id,b.district_id
'
,
$where
);
$agent_arr
=
$this
->
m_bargain
->
agentBargain
Income
(
'a.agent_id,b.store_id,b.district_id,a.create_time,d.income_time
'
,
$where
);
if
(
empty
(
$agent_arr
))
{
return
$this
->
response
(
$code
,
'没有该记录'
);
...
...
@@ -4814,7 +4948,7 @@ class Finance extends Basic
if
(
$is_ok
)
{
foreach
(
$agent_arr
as
$k
=>
$v
)
{
try
{
$this
->
totalOfficialReceipts
(
$v
[
'agent_id'
],
$v
[
'district_id'
],
$v
[
'store_id'
],
$v
[
'creat
e_time'
]);
$this
->
totalOfficialReceipts
V2
(
$v
[
'agent_id'
],
$v
[
'district_id'
],
$v
[
'store_id'
],
$v
[
'create_time'
],
$v
[
'incom
e_time'
]);
$code
=
200
;
}
catch
(
\Exception
$e
)
{
$msg
=
'恢复失败:'
.
$e
->
getMessage
();
...
...
application/index/controller/OfficeBargain.php
View file @
9263102a
...
...
@@ -778,7 +778,6 @@ class OfficeBargain extends Basic
}
if
(
!
empty
(
$content
))
{
dump
(
$father_id
);
die
;
$this
->
editRecordLog
(
$father_id
,
'【编号:'
.
$father_id
.
'】'
.
$content
);
}
/*记录日志 end*/
...
...
application/model/OBargainModel.php
View file @
9263102a
...
...
@@ -1367,6 +1367,7 @@ class OBargainModel extends Model
->
field
(
$filed
)
->
alias
(
"a"
)
->
join
(
"o_partial_commission b"
,
"a.id = b.bargain_id"
,
"left"
)
->
join
(
"o_real_income c"
,
"b.real_income_id = c.id"
,
"left"
)
->
where
(
$where_
)
->
whereOr
(
$whereOr_
)
->
order
(
"a.id asc"
)
...
...
@@ -1631,6 +1632,24 @@ class OBargainModel extends Model
->
select
();
}
/**
* @param $field
* @param $where
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
agentBargainIncome
(
$field
,
$where
)
{
return
$this
->
db_
->
alias
(
'a'
)
->
field
(
$field
)
->
join
(
'a_agents b'
,
'a.agent_id = b.id'
,
'left'
)
->
join
(
'office_o_partial_commission c'
,
'a.id = c.bargain_id'
,
'left'
)
->
join
(
'office_o_real_income d'
,
'c.real_income_id = d.id'
,
'left'
)
->
where
(
$where
)
->
select
();
}
/**
* @param $field
* @param $where
...
...
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