Commit 7e4155f0 authored by clone's avatar clone

1

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