Commit 5a55c32a authored by hujun's avatar hujun

盘方操作记录

parent d2d75ee8
......@@ -955,21 +955,21 @@ class Finance extends Basic
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$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['b.status'] = [ 'in', [10,11,13] ]; //10已提交 11审核成功
$where['a.father_id'] = ['neq', 0];
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'])) {
$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'])) {
$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'])) {
......
......@@ -21,9 +21,9 @@ class GHousesToAgents extends BaseModel
*/
public function addAgents($agents_id, $houses_id, $type)
{
$agent_arr = array();
$agent_arr = [];
$agents_id = array_unique(explode(',', $agents_id));
$del_agents_id = $record_agents_id = [];
$record_agents_id = [];
$where['type'] = $type;
$where['houses_id'] = $houses_id;
$where['is_del'] = 0;
......@@ -34,7 +34,7 @@ class GHousesToAgents extends BaseModel
if (empty($agents_id[0])) {
if ($type == 2) {
$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) {
$name[] = $agents->where('id', $v2['agents_id'])->value('name');
}
......@@ -45,53 +45,57 @@ class GHousesToAgents extends BaseModel
$houses_data = $this->where($where)->select();
$key = 0;
foreach ($houses_data as $k => $v) {
if (!in_array($v['agents_id'], $agents_id) && ($type == $v['type']) && ($v['agents_id'] != NULL)) {
//伪删除
$agent_arr[$key]['id'] = $v['id'];
$agent_arr[$key]['is_del'] = 1;
$key++;
if ($type == 2) {
$del_agents_id[] = $v['agents_id'];
}
}
}
foreach ($agents_id as $k => $v) {
//去除重复
$check = $this->where([
'houses_id' => $houses_id,
'agents_id' => $v,
'is_del' => 0,
'type' => $type
'is_del' => 0,
'type' => $type
])->find();
if ($type == 2) {
$record_agents_id[] = $v;
}
if ($check) {
continue;
}
$agent_arr[$key]['agents_id'] = $v;
$agent_arr[$key]['houses_id'] = $houses_id;
$agent_arr[$key]['type'] = $type;
$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) {
$records = new GOperatingRecords();
$name = array();
$name = [];
foreach ($record_agents_id as $k2 => $v2) {
$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);
......@@ -161,11 +165,18 @@ class GHousesToAgents extends BaseModel
->group("houses_id")
->select();
//echo Db::name($this->table)->getLastSql();
//echo Db::name($this->table)->getLastSql();
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)
{
$result = Db::name($this->table)
......@@ -195,7 +206,7 @@ class GHousesToAgents extends BaseModel
->join('a_agents b', 'a.agents_id = b.id', 'LEFT')
->where([
'houses_id' => $houses_id,
'is_del' => 0
'is_del' => 0
])
->where($where)
->select();
......@@ -203,14 +214,21 @@ class GHousesToAgents extends BaseModel
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)
{
$select_data = $this->field('b.id,name,a.type,b.phone')->alias('a')
->join('a_agents b', 'a.agents_id = b.id', 'LEFT')
->where([
'houses_id' => $houses_id,
'type' => 2,
'is_del' => 0
'type' => 2,
'is_del' => 0
])->select();
return $select_data;
......@@ -246,7 +264,8 @@ class GHousesToAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHouseAgent(string $field = '', array $where = []) : array {
public function getHouseAgent(string $field = '', array $where = []): array
{
return $this->alias('a')
->field($field)
->join('a_agents b', 'a.agents_id=b.id', 'left')
......@@ -259,11 +278,21 @@ class GHousesToAgents extends BaseModel
* @return array|false
* @throws \Exception
*/
public function updateUserAll($data) {
public function updateUserAll($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)
->field($field)
......
......@@ -2,7 +2,7 @@
[% if(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'] %]">
<td>[%= it[item]['create_time'] %]</td>
<td>[%= it[item]['operation_date'] %]</td>
<td>[%= it[item]['district_store'] %]</td>
<td>[%= it[item]['name'] %]</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