Commit 7e4155f0 authored by clone's avatar clone

1

parent dbd693c2
......@@ -63,7 +63,7 @@ class ResultsSummaryOfficeTask
{
set_time_limit(0); // 取消脚本运行时间的超时上限
$day = date("Y-m-d", time());
Log::record("-------run_total_office----".$this->redis_->get("run_total_office" . $day),"info");
Log::record("-------run_total_office----" . $this->redis_->get("run_total_office" . $day), "info");
if ($this->redis_ && $this->redis_->get("run_total_office" . $day)) {
return;
}
......@@ -122,7 +122,7 @@ class ResultsSummaryOfficeTask
{
set_time_limit(0); // 取消脚本运行时间的超时上限
$total_time = date("Y-m-d",strtotime("-1 day"));
$total_time = date("Y-m-d", strtotime("-1 day"));
$total = $this->agentsModel->getAgentsCountByTask();
$pageSize = 20;
$pageTotal = ceil($total / $pageSize);
......@@ -152,17 +152,18 @@ class ResultsSummaryOfficeTask
* @param $end_time
* @return bool
*/
public function updateStoreByAgentId($agent_id,$store_id,$district_id,$start_time,$end_time){
$date = floor((strtotime($end_time)-strtotime($start_time))/86400);
if($date > 31) {
public function updateStoreByAgentId($agent_id, $store_id, $district_id, $start_time, $end_time)
{
$date = floor((strtotime($end_time) - strtotime($start_time)) / 86400);
if ($date > 31) {
return false;
}
$params["district_id"] = $district_id;
$params["store_id"] = $store_id;
$where["agent_id"] = $agent_id;
$where["total_time"] = array("between",array($start_time, $end_time));
$is_ok = $this->tAgentTotalModel->updateTotal($params,$where);
if($is_ok > 0 ){
$params["district_id"] = $district_id;
$params["store_id"] = $store_id;
$where["agent_id"] = $agent_id;
$where["total_time"] = array("between", array($start_time, $end_time));
$is_ok = $this->tAgentTotalModel->updateTotal($params, $where);
if ($is_ok > 0) {
return true;
}
return false;
......@@ -175,7 +176,7 @@ class ResultsSummaryOfficeTask
* @param $total_time string 比如修改了数据如成交报告,成交报告提交时间是昨天那么这里的时间就是昨天
* @param $site_id
*/
public function updateTotalByAgentId($agent_id, $store_id, $district_id, $total_time,$site_id)
public function updateTotalByAgentId($agent_id, $store_id, $district_id, $total_time, $site_id)
{
$params[0]["id"] = $agent_id;
$params[0]["store_id"] = $store_id;
......@@ -220,7 +221,7 @@ class ResultsSummaryOfficeTask
$store_id = $value["store_id"];
$site_id = $value["site_id"];
//todo 查询时间段的数据
$result = $this->selectTotal($agent_id, $district_id, $store_id, $start_total_time, $end_total_time,$site_id);
$result = $this->selectTotal($agent_id, $district_id, $store_id, $start_total_time, $end_total_time, $site_id);
if (empty($result)) continue;
if ($id > 0) {
......@@ -249,24 +250,22 @@ class ResultsSummaryOfficeTask
}
private function save(){
}
/* public function test()
{
$params = $this->selectTotal(1, 1, 1, "2018-02-02", "2018-03-15");
$this->tAgentTotalModel->addTotal($params);
// dump($params);
}*/
/* public function test()
{
$params = $this->selectTotal(6564, 31, 5298, "2019-06-25", "2019-06-25 23:59:59",10005);
$paramss[0] = $params;
$this->tAgentTotalModel->addTotal($paramss);
dump($paramss);
}*/
private function selectTotal($agent_id, $district_id, $store_id, $start_total_time, $end_total_time,$site_id)
private function selectTotal($agent_id, $district_id, $store_id, $start_total_time, $end_total_time, $site_id)
{
//todo 如果查询出这个时间段都为0 则给此经纪人插入条最后一个日期的为空的数据
$result_arr = [];
//房源
$params["agent_id"] = $agent_id;
$params['create_time'] = array( 'between', array( $start_total_time, $end_total_time ) );
$params['create_time'] = array('between', array($start_total_time, $end_total_time));
$addHouseNum = $this->houseModel->getAddHouseNumGroupTimeNew($params);
$result_arr["house_num"] = $addHouseNum[0]["num"];
//dump($addHouseNum);
......@@ -308,7 +307,7 @@ class ResultsSummaryOfficeTask
//电话跟进数
$uFollowModel = new OfficeUPhoneFollowUp($site_id);
$followUp = $uFollowModel->getFollowTotal($params);
$followUp = $uFollowModel->getFollowTotal($params);
$result_arr["followUp_sum"] = $followUp;
......@@ -351,22 +350,23 @@ class ResultsSummaryOfficeTask
* @param Request $request
* @return false|string
*/
public function updateBargainPerformance(Request $request) {
public function updateBargainPerformance(Request $request)
{
try {
$bargain_id = $request->get('bargain_id');
if (empty($bargain_id)) {
return json_encode([ 'code' => 101, 'msg' => 'params is error' ]);
return json_encode(['code' => 101, 'msg' => 'params is error']);
}
$data['msg'] = '';
$where = $update_data = [];
$where = $update_data = [];
if ($bargain_id) {
$where['b.id'] = $bargain_id;
}
if (!empty($where)) {
//获取被修改人信息
$agent_data = $this->agentsModel->agentBargainAll('a.id,a.store_id,a.district_id,b.create_time', $where);
foreach ($agent_data as $k=>$v) {
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);
}
......@@ -374,10 +374,10 @@ class ResultsSummaryOfficeTask
$data['code'] = 200;
} catch (\Exception $e) {
$data['code'] = 101;
$data['msg'] = '内部错误:'.$e->getMessage();
$data['msg'] = '内部错误:' . $e->getMessage();
}
return json_encode([ 'code' => $data['code'], 'msg' => $data['msg']]);
return json_encode(['code' => $data['code'], 'msg' => $data['msg']]);
}
/**
......@@ -391,42 +391,43 @@ class ResultsSummaryOfficeTask
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function totalOfficialReceipts($agent_id, $district_id, $store_id, $date) {
public function totalOfficialReceipts($agent_id, $district_id, $store_id, $date)
{
//获取被修改人信息
$date = date('Y-m-d', strtotime($date));
$update_data = [];
$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']];
$where_bargain['create_time'] = ['BETWEEN', [$date . ' 00:00:00', $date . ' 23:59:59']];
//实收
$receivedSum = $this->bargainModel->getAddBargainNumGroupTimeNew($where_bargain, 2); //1表示业绩 2表示实收
$received_sum = empty($receivedSum[0]["num"]) ? 0 : $receivedSum[0]["num"];
//业绩
$performanceSum = $this->bargainModel->getAddBargainNumGroupTimeNew($where_bargain, 1);//1表示业绩 2表示实收
$performance_sum = empty($performanceSum[0]["num"])? 0:$performanceSum[0]["num"];
$id = $this->tAgentTotalModel->getTotalEndTimeByAgentId('id', ['total_time'=>$date, 'agent_id'=>$where_bargain['agent_id']]);
$performanceSum = $this->bargainModel->getAddBargainNumGroupTimeNew($where_bargain, 1);//1表示业绩 2表示实收
$performance_sum = empty($performanceSum[0]["num"]) ? 0 : $performanceSum[0]["num"];
$id = $this->tAgentTotalModel->getTotalEndTimeByAgentId('id', ['total_time' => $date, 'agent_id' => $where_bargain['agent_id']]);
if (empty($id[0]['id'])) {
$insert_data[] = [
'store_id' => $store_id,
'district_id' => $district_id,
'agent_id' => $agent_id,
'store_id' => $store_id,
'district_id' => $district_id,
'agent_id' => $agent_id,
'official_receipts' => $received_sum,
'performance' => $performance_sum,
'total_time' => $date,
'create_time' => date('Y-m-d H:i:s')
'performance' => $performance_sum,
'total_time' => $date,
'create_time' => date('Y-m-d H:i:s')
];
$this->tAgentTotalModel->addTotal($insert_data);
} else {
$update_data[] = [
'official_receipts' => $received_sum,
'performance' => $performance_sum,
'id' => $id[0]['id'],
'update_time' => date('Y-m-d H:i:s')
'performance' => $performance_sum,
'id' => $id[0]['id'],
'update_time' => date('Y-m-d H:i:s')
];
$this->tAgentTotalModel->saveTotal($update_data);
}
return ;
return;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment