Commit 5a55c32a authored by hujun's avatar hujun

盘方操作记录

parent d2d75ee8
...@@ -955,21 +955,21 @@ class Finance extends Basic ...@@ -955,21 +955,21 @@ class Finance extends Basic
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo']; $pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize']; $pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
$fields = 'a.id,a.create_time,e.name,e.phone,a.fee,b.house_number,d.internal_address,a.agent_id,b.father_id,b.id as bargain_id,b.order_id'; $fields = 'a.id,a.operation_date,e.name,e.phone,a.fee,b.house_number,d.internal_address,a.agent_id,b.father_id,b.id as bargain_id,b.order_id';
$where['c.is_del'] = 0; $where['c.is_del'] = 0;
$where['b.status'] = [ 'in', [10,11,13] ]; //10已提交 11审核成功 $where['b.status'] = [ 'in', [10,11,13] ]; //10已提交 11审核成功
$where['a.father_id'] = ['neq', 0]; $where['a.father_id'] = ['neq', 0];
if (!empty($this->params['create_time']) && empty($this->params['end_time'])) { if (!empty($this->params['create_time']) && empty($this->params['end_time'])) {
$where['a.create_time'] = [ '> time', $this->params['create_time'] . ' 00:00:00' ]; $where['a.operation_date'] = [ '> time', $this->params['create_time'] . ' 00:00:00' ];
} }
if (!empty($this->params['end_time']) && empty($this->params['create_time'])) { if (!empty($this->params['end_time']) && empty($this->params['create_time'])) {
$where['a.create_time'] = [ '< time', $this->params['create_time'] . ' 23:59:59' ]; $where['a.operation_date'] = [ '< time', $this->params['create_time'] . ' 23:59:59' ];
} }
if (!empty($this->params['end_time']) && !empty($this->params['create_time'])) { if (!empty($this->params['end_time']) && !empty($this->params['create_time'])) {
$where['a.create_time'] = [ 'between time', [ $this->params['create_time'] . ' 00:00:00', $this->params['create_time'] . ' 23:59:59' ] ]; $where['a.operation_date'] = [ 'between time', [ $this->params['create_time'] . ' 00:00:00', $this->params['create_time'] . ' 23:59:59' ] ];
} }
if (!empty($this->params['internal_address'])) { if (!empty($this->params['internal_address'])) {
......
...@@ -21,9 +21,9 @@ class GHousesToAgents extends BaseModel ...@@ -21,9 +21,9 @@ class GHousesToAgents extends BaseModel
*/ */
public function addAgents($agents_id, $houses_id, $type) public function addAgents($agents_id, $houses_id, $type)
{ {
$agent_arr = array(); $agent_arr = [];
$agents_id = array_unique(explode(',', $agents_id)); $agents_id = array_unique(explode(',', $agents_id));
$del_agents_id = $record_agents_id = []; $record_agents_id = [];
$where['type'] = $type; $where['type'] = $type;
$where['houses_id'] = $houses_id; $where['houses_id'] = $houses_id;
$where['is_del'] = 0; $where['is_del'] = 0;
...@@ -34,7 +34,7 @@ class GHousesToAgents extends BaseModel ...@@ -34,7 +34,7 @@ class GHousesToAgents extends BaseModel
if (empty($agents_id[0])) { if (empty($agents_id[0])) {
if ($type == 2) { if ($type == 2) {
$house_agents = $this->field('agents_id')->where('houses_id', $houses_id)->where('is_del', 0)->select(); $house_agents = $this->field('agents_id')->where('houses_id', $houses_id)->where('is_del', 0)->select();
$name = array(); $name = [];
foreach ($house_agents as $k2 => $v2) { foreach ($house_agents as $k2 => $v2) {
$name[] = $agents->where('id', $v2['agents_id'])->value('name'); $name[] = $agents->where('id', $v2['agents_id'])->value('name');
} }
...@@ -45,53 +45,57 @@ class GHousesToAgents extends BaseModel ...@@ -45,53 +45,57 @@ class GHousesToAgents extends BaseModel
$houses_data = $this->where($where)->select(); $houses_data = $this->where($where)->select();
$key = 0; $key = 0;
foreach ($houses_data as $k => $v) { foreach ($houses_data as $k => $v) {
if (!in_array($v['agents_id'], $agents_id) && ($type == $v['type']) && ($v['agents_id'] != NULL)) { if (!in_array($v['agents_id'], $agents_id) && ($type == $v['type']) && ($v['agents_id'] != NULL)) {
//伪删除
$agent_arr[$key]['id'] = $v['id']; $agent_arr[$key]['id'] = $v['id'];
$agent_arr[$key]['is_del'] = 1; $agent_arr[$key]['is_del'] = 1;
$key++; $key++;
if ($type == 2) {
$del_agents_id[] = $v['agents_id'];
}
} }
} }
foreach ($agents_id as $k => $v) { foreach ($agents_id as $k => $v) {
//去除重复
$check = $this->where([ $check = $this->where([
'houses_id' => $houses_id, 'houses_id' => $houses_id,
'agents_id' => $v, 'agents_id' => $v,
'is_del' => 0, 'is_del' => 0,
'type' => $type 'type' => $type
])->find(); ])->find();
if ($type == 2) {
$record_agents_id[] = $v;
}
if ($check) { if ($check) {
continue; continue;
} }
$agent_arr[$key]['agents_id'] = $v; $agent_arr[$key]['agents_id'] = $v;
$agent_arr[$key]['houses_id'] = $houses_id; $agent_arr[$key]['houses_id'] = $houses_id;
$agent_arr[$key]['type'] = $type; $agent_arr[$key]['type'] = $type;
$key++; $key++;
if ($type == 2) {
$record_agents_id[] = $v;
}
}
if (count($del_agents_id) > 0) {
$name = array();
foreach ($del_agents_id as $k2 => $v2) {
$name[] = $agents->where('id', $v2)->value('name');
}
$records->record('', 2, '删除盘方:' . implode(',', $name), $houses_id);
} }
if (count($record_agents_id) > 0) { if (count($record_agents_id) > 0) {
$records = new GOperatingRecords(); $records = new GOperatingRecords();
$name = array(); $name = [];
foreach ($record_agents_id as $k2 => $v2) { foreach ($record_agents_id as $k2 => $v2) {
$name[] = $agents->where('id', $v2)->value('name'); $name[] = $agents->where('id', $v2)->value('name');
} }
$records->record('', 2, '新增盘方:' . implode(',', $name), $houses_id);
$num = $this->where('houses_id', $houses_id)->count();
if ($num > 0) {
$str = '修改为:';
} else {
$str = '新增为:';
}
$records->record('', 2, $str . implode(',', $name), $houses_id);
} }
$res = $this->saveAll($agent_arr); $res = $this->saveAll($agent_arr);
...@@ -165,7 +169,14 @@ class GHousesToAgents extends BaseModel ...@@ -165,7 +169,14 @@ class GHousesToAgents extends BaseModel
return $result; return $result;
} }
/**
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAgentsByHouseId($field, $params) public function getAgentsByHouseId($field, $params)
{ {
$result = Db::name($this->table) $result = Db::name($this->table)
...@@ -203,6 +214,13 @@ class GHousesToAgents extends BaseModel ...@@ -203,6 +214,13 @@ class GHousesToAgents extends BaseModel
return $select_data; return $select_data;
} }
/**
* @param $houses_id
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHousesUpdateAgents($houses_id) public function getHousesUpdateAgents($houses_id)
{ {
$select_data = $this->field('b.id,name,a.type,b.phone')->alias('a') $select_data = $this->field('b.id,name,a.type,b.phone')->alias('a')
...@@ -246,7 +264,8 @@ class GHousesToAgents extends BaseModel ...@@ -246,7 +264,8 @@ class GHousesToAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getHouseAgent(string $field = '', array $where = []) : array { public function getHouseAgent(string $field = '', array $where = []): array
{
return $this->alias('a') return $this->alias('a')
->field($field) ->field($field)
->join('a_agents b', 'a.agents_id=b.id', 'left') ->join('a_agents b', 'a.agents_id=b.id', 'left')
...@@ -259,11 +278,21 @@ class GHousesToAgents extends BaseModel ...@@ -259,11 +278,21 @@ class GHousesToAgents extends BaseModel
* @return array|false * @return array|false
* @throws \Exception * @throws \Exception
*/ */
public function updateUserAll($data) { public function updateUserAll($data)
{
return $this->saveAll($data); return $this->saveAll($data);
} }
public function getHouseToAgents($field,$params){ /**
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHouseToAgents($field, $params)
{
return Db::table($this->table) return Db::table($this->table)
->field($field) ->field($field)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
[% if(it) { %] [% if(it) { %]
[% for(var item in it){ %] [% for(var item in it){ %]
<tr class="text-center" data-id="[%= it[item]['bargain_id'] %]" data-orderid="[%= it[item]['order_id'] %]" data-fatherid="[%= it[item]['father_id'] %]"> <tr class="text-center" data-id="[%= it[item]['bargain_id'] %]" data-orderid="[%= it[item]['order_id'] %]" data-fatherid="[%= it[item]['father_id'] %]">
<td>[%= it[item]['create_time'] %]</td> <td>[%= it[item]['operation_date'] %]</td>
<td>[%= it[item]['district_store'] %]</td> <td>[%= it[item]['district_store'] %]</td>
<td>[%= it[item]['name'] %]</td> <td>[%= it[item]['name'] %]</td>
<td>[%= it[item]['internal_address'] %]</td> <td>[%= it[item]['internal_address'] %]</td>
......
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