Commit 9b22d9f8 authored by hujun's avatar hujun

11

parent 8c94811a
......@@ -39,7 +39,7 @@ class UploadWorkLearning extends Basic
$tmp_file = time();
$img_name = md5(uniqid($tmp_file)) . '.' . $img_title;//图片名
$url = 'static/week_work_img/' . $img_name;
$url = 'static/week_work_img/' .date('Ymd').'/'. $img_name;
$code = 200;
$msg = '';
......
......@@ -20,6 +20,7 @@ use app\model\AAgents;
use app\model\ChatMsg;
use app\model\GHouses;
use app\model\GHousesImgs;
use app\model\MPushCheckMessage;
use app\model\MPushMessage;
use app\model\OfficeGImg;
use app\model\OfficeGRoom;
......@@ -647,14 +648,11 @@ class AppChat extends Basic
$page_no = empty($params['page_no']) ? 1 : $params['page_no'];
$page_size = empty($params['page_size']) ? 15 : $params['page_size'];
$field = "id,addressee_id,type,message,user_id,create_time,is_read,order_id,house_id as square_id";
$param["addressee_id"] = $params["agent_id"];
$param["type"] = array('in','13,14,16,17,18,19,20');
$msgModel = new MPushMessage();
$history_result = $msgModel->getListByWhere($field, $param, $page_no, $page_size);
$field = "id,addressee_id,title,type,message,create_time,is_read,order_id";
$where["addressee_id"] = $params["agent_id"];
$msgModel = new MPushCheckMessage();
$history_result = $msgModel->getListByWhere($field, $where, $page_no, $page_size);
return $this->response("200", "request success", $history_result);
}
......
<?php
/**
* Created by PhpStorm.
* User: hu jun
* Date: 2018/8/27
* Time: 17:24
*/
namespace app\model;
use think\Db;
class MPushCheckMessage extends BaseModel
{
protected $table = "m_push_check_message";
private $db_;
public function __construct()
{
$this->db_ = Db::name($this->table);
}
/**
* @param $data
* @param $operation_id
* @param $type
* @return bool
*/
public function addData($data, $operation_id, $type)
{
if (isset($data['agent_id'])) {
$insert_data['addressee_id'] = $data['agent_id'];
}
if (isset($data['house_id'])) {
$insert_data['house_id'] = $data['house_id'];
}
if (isset($data['message'])) {
$insert_data['message'] = $data['message'];
}
if (isset($data['title'])) {
$insert_data['title'] = $data['title'];
}
if (isset($data['user_id'])) {
$insert_data['user_id'] = $data['user_id'];
}
if (isset($data['addressee_id'])) {
$insert_data['addressee_id'] = $data['addressee_id'];
}
$insert_data['type'] = $type;
$insert_data['status'] = 0;
$insert_data['operation_id'] = $operation_id;
$num = $this->db_->insert($insert_data);
if ($num > 0) {
$result = true;
} else {
$result = false;
}
return $result;
}
/**
* 根据楼盘id批量插入数据
*
* @param array $house_id 楼盘id
* @param int $operation_id 操作人id
* @param int $type 消息类型:0群推 1商铺下架 2修改客方 3盘方修改
* @param $data
* @return bool
*/
public function addHouseIdArray(array $house_id, $operation_id, int $type)
{
if (!is_array($house_id)) {
return false;
}
$m_house = new GHouses();
$insert_data = [];
foreach ($house_id as $k => $v) {
$agent_id = $this->selectAgentHouse($v);
foreach ($agent_id as $k2 => $v2) {
$insert_data[$k2]['house_id'] = $v;
$internal_title = $m_house->where('id', $v)->value('internal_title');
$insert_data[$k2]['message'] = '你的【' . $internal_title . '】商铺下架,如需要上架,请编辑提交该商铺.';
$insert_data[$k2]['addressee_id'] = $v2;
$insert_data[$k2]['addressee_id'] = $v2;
$insert_data[$k2]['type'] = $type;
$insert_data[$k2]['status'] = 0;
$insert_data[$k2]['operation_id'] = $operation_id;
}
}
$num = $this->db_->insertAll($insert_data);
if (count($num) > 0) {
$result = true;
} else {
$result = false;
}
return $result;
}
/**
* 根据经纪人id批量插入数据
*
* @param array $agent_id 楼盘id
* @param int $operation_id 操作人id
* @param int $type 消息类型:0群推 1商铺下架 2修改客方 3盘方修改
* @param $data
* @return bool
*/
public function addAgentIdArray(array $agent_id, int $operation_id, int $type, $data)
{
if (!is_array($agent_id)) {
return false;
}
$insert_data = [];
foreach ($agent_id as $k => $v) {
$insert_data[$k]['addressee_id'] = $v;
if (isset($data['message'])) {
$insert_data[$k]['message'] = $data['message'];
}
if (isset($data['user_id'])) {
$insert_data[$k]['user_id'] = $data['user_id'];
}
if (isset($data['house_id'])) {
$insert_data[$k]['house_id'] = $data['house_id'];
}
if (isset($data['order_id'])) {
$insert_data[$k]['order_id'] = $data['order_id'];
}
if (isset($data['status'])) {
$insert_data[$k]['status'] = $data['status'];
} else {
$insert_data[$k]['status'] = 0;
}
$insert_data[$k]['type'] = $type;
$insert_data[$k]['operation_id'] = $operation_id;
}
$num = $this->db_->insertAll($insert_data);
if (count($num) > 0) {
$result = true;
} else {
$result = false;
}
return $result;
}
/**
* @param $house_id
* @return array
*/
public function selectAgentHouse($house_id)
{
$m_house = new GHousesToAgents();
$where['a.houses_id'] = $house_id;
$where['a.type'] = 2;
$result = $m_house->getHouseAgent('agents_id', $where);
$agent_id = [];
if ($result['status'] != 'fail') {
foreach ($result['data'] as $k => $v) {
$agent_id[] = $v['agents_id'];
}
}
return $agent_id;
}
/**
* 获取指定条数
*
* @param $field
* @param $where
* @param $limit
* @return mixed
*/
public function getDateLimit($field, $where, $limit)
{
try {
$result['data'] = $this->db_->field($field)
->where($where)
->limit($limit)
->select();
$result['status'] = 'successful';
} catch (\Exception $e) {
$result['status'] = 'fail';
$result['msg'] = $e->getMessage();
}
return $result;
}
/**
* @param $data
* @param $where
* @return int|string
*/
public function updateData($data, $where) {
try {
$this->db_->where($where)->update($data);
$result['status'] = 'successful';
} catch (\Exception $e) {
$result['status'] = 'fail';
$result['msg'] = $e->getMessage();
}
return $result;
}
/**
* @param string $field
* @param array $params
* @param int $page_no
* @param int $page_size
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getListByWhere(string $field, array $params,int $page_no = 1,int $page_size = 15)
{
return $this->db_
->field($field)
->where($params)
->order(" id desc")
->page($page_no)
->limit($page_size)
->select();
}
/**
* 获取未读个数
* @param array $params
* @return int|string
*/
public function getListCountByWhere(array $params)
{
return $this->db_
->where($params)
->count();
}
/** 批量更新已看记录
* @param array $where_arr
* @param array $update_arr
* @return array
*/
public function updateIsRead(array $where_arr,array $update_arr){
$result= [];
try {
$this->db_->where($where_arr)
->update($update_arr);
$result['code'] = true;
} catch (\Exception $e) {
$result['code'] = false;
$result['msg'] = $e->getMessage();
}
return $result;
}
}
\ 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