Commit 4aa55ac8 authored by clone's avatar clone

Merge branch 'test' into test-hujun1.15

# Conflicts: # application/api_broker/controller/Broker.php # application/api_broker/controller/Client.php # application/api_broker/controller/OrderLog.php # application/api_broker/extend/Basic.php # application/api_broker/service/ReportService.php # application/index/controller/CellPhone.php # application/index/controller/Member.php # application/index/extend/Basic.php # application/index/view/global/navigation.html # application/index/view/member/users_list.html # application/index/view/remark/remark_follow_index.html # application/model/OrderModel.php # application/model/SecretReport.php # application/model/Users.php # application/route.php # public/resource/js/RemarkFollowIndex.js # public/resource/js/user.js # public/resource/template/user_template_tpl.html
parents 45cdfe7a f0e849c1
File mode changed from 100755 to 100644
......@@ -73,7 +73,8 @@ class AttentionShop extends Basic
$order_ = 'a.create_time desc';
//b.room_num_left 前端显示已下架,不可点击到详情
$field = "a.id,a.house_id,b.title,b.area,b.room_area2,b.price,b.shangpu_tags,b.room_num_left,c.foreign_name";
$field = "a.id,a.house_id,b.title,b.room_area,b.room_area2,b.price,b.shangpu_tags,b.shangpu_type,b.room_num_left
,b.rent_type,c.foreign_name";
if (!isset($params["user_id"])) {
return $this->response("101", "用户id不能为空");
......@@ -92,6 +93,7 @@ class AttentionShop extends Basic
$result[$key]["images"] = $imgArr;
}
return $this->response("200", "request success", $result);
}
......
......@@ -48,10 +48,11 @@ class Banner extends Basic
*/
public function addOrSave()
{
$params = array(
/* $params = array(
"id" => 2,
"is_show" => 0
);
);*/
$params = $this->params;
$msg = isset($params['id']) ? "修改" : "新增";
$result = $this->bannerModel->addOrUpdate($params);
if ($result['code'] == 200) {
......@@ -67,10 +68,11 @@ class Banner extends Basic
*/
public function upIsShow()
{
$params = array(
/* $params = array(
"id" => 1,
"is_show" => 1
);
);*/
$params = $this->params;
$result = $this->bannerModel->upIsShow($params);
if ($result['code'] == 200) {
return $this->response("200", "update success", $result["msg"]);
......
......@@ -5,8 +5,8 @@ use app\api\extend\Basic;
use app\model\Agents;
use app\model\Evaluate;
use app\model\EvaluateSign;
use app\model\JournalAccounts;
use think\Db;
use app\model\Remarks;
/**
* Description of Agents
*
......@@ -133,11 +133,13 @@ class Broker extends Basic{
return $this->response($data['status'], $data['msg'], $data['data']);
}
/**
* 查询评论和成交记录
*
* @return type
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function commentAndDeal() {
$params = $this->params;
......@@ -150,16 +152,18 @@ class Broker extends Basic{
$pageSize = empty($params['pageSize']) ? PAGESIZE : $params['pageSize'];
$evalutate = new Evaluate();
$journal = new JournalAccounts();
$remarks = new Remarks();
$fields_evaluate = 'house_id,user_id,user_nick,user_phone,user_pic,evaluate_grade,evaluate_content,evaluate_sign,a.create_time,record_id,a.source';
$fields_journal = 'a.house_id,j.singntime';
$fields_journal = 'house_id,apply_id,created';
$where['shopuser_id'] = $params['agent_id'];
$where['transaction_status'] = 3;
switch ($params['type']) {
case 0:
//评价列表信息
$result['evaluate'] = $evalutate->getEvaluate($pageNo, $pageSize, 'a.id desc', $fields_evaluate, '', $params['agent_id']);
//成交记录
$result['journalAccounts'] = $journal->getJournalHouseInfo($pageNo, $pageSize, 'j.id desc', $fields_journal, 'j.transaction_status = 3', $params['agent_id']);
$result['journalAccounts'] = $remarks->getJournalHouseInfo($pageNo, $pageSize, 'id desc', $fields_journal, $where, $params['agent_id']);
$data['data'] = $result;
break;
case 1:
......@@ -169,7 +173,7 @@ class Broker extends Basic{
break;
case 2:
//成交记录
$result['journalAccounts'] = $journal->getJournalHouseInfo($pageNo, $pageSize, 'j.id desc', $fields_journal, 'j.transaction_status = 3', $params['agent_id']);
$result['journalAccounts'] = $remarks->getJournalHouseInfo($pageNo, $pageSize, 'id desc', $fields_journal, $where, $params['agent_id']);
$data['data'] = $result;
break;
default:
......
......@@ -264,8 +264,8 @@ class Member extends Basic
}
}
}
$insert_data['referrer_id'] = $referrer_id;
}
$insert_data['referrer_id'] = $referrer_id;
$insert_data['referrer_source'] = $referrer_source;
$insert_data['status'] = 0;
$insert_data['create_time'] = $date;
......
......@@ -55,7 +55,7 @@ class Shop extends Basic
$params = $this->params;
$field = "a.id,a.agent_id,a.title,a.address,a.city,disc,a.disccircles,a.sales,a.yetai,a.room_area,a.room_area2,
a.shangpu_type,a.is_test,a.room_num_left,a.shangpu_tags,a.carefully_chosen,a.price,b.foreign_name,b.address_detail_c,
a.shangpu_type,a.is_test,a.room_num_left,a.shangpu_tags,a.carefully_chosen,a.price,a.rent_type,b.foreign_name,b.address_detail_c,
b.foreign_advantage";
$conditions = [];
......@@ -90,14 +90,21 @@ class Shop extends Basic
$conditions['a.shangpu_type'] = array( "eq", $params['shangpu_type'] );
}
//面积 room_area最小面积 room_area2最大面积 参考老版本
//面积 room_area最小面积 room_area2最大面积 参考老版本
if (isset($params['area_start']) && isset($params['area_end'])) {
$conditions['a.room_area'] = array( 'between', array( $params['area_start'], $params['area_end'] ) );
//街铺只有一个room_area
if ($params['shangpu_type'] == 0) {
$conditions['a.room_area2'] = array( 'between', array( $params['area_start'], $params['area_end'] ) );
}
} else if (isset($params['area_start']) && !isset($params['area_end'])) { //100米以上不用传结束面积
$conditions['a.room_area'] = array( 'egt', $params['area_start'] );
if ($params['shangpu_type'] == 0) {
$conditions['a.room_area2'] = array( 'egt', $params['area_start'] );
}
}
if (isset($params['money_start']) && isset($params['money_end'])) { //面积
$conditions['a.price'] = array( 'between', array( $params['money_start'], $params['money_end'] ) );
......@@ -155,7 +162,7 @@ class Shop extends Basic
$field = "a.id,a.management_fee,a.title,a.address,a.city,a.room_area,a.room_area2,a.business_area,a.disc,a.disccircles,
a.sales,a.slotting_fee,a.transfer_fee, a.yetai,a.room_area2,a.shangpu_type,a.is_test,a.sellingpoint,a.singn_rule,
a.business_date,a.start_business_date,a.opentime,a.has_gas,a.traffic,a.has_moved,a.room_num_left,a.room_num_total,
a.shangpu_tags,a.carefully_chosen,a.price,a.dish,a.file_path,b.foreign_name,b.address_detail_c,
a.shangpu_tags,a.carefully_chosen,a.price,a.dish,a.file_path,a.rent_type,b.foreign_name,b.address_detail_c,
b.foreign_advantage";
$conditions = [];
......@@ -171,7 +178,7 @@ class Shop extends Basic
$result["api_path"] = IMG_PATH;
$param["house_id"] = $params['id'];
//todo 这里的是否要更改成b端后台上传的类型
//$param["imgtype"] = 2;
$param["imgtype"] = 2;
$result["images"] = $this->dbImg->getHouseImages($param, 15);
$param["imgtype"] = 4;//图片类型:1效果图,2实景图,3样板图,4户型图,5交通图
$result["plan_images"] = $this->dbImg->getHouseImages($param, 4);
......@@ -186,7 +193,7 @@ class Shop extends Basic
$attention["is_del"] = array( "eq", 0 );;
$attResult = $this->attentionModel->getAttentionByUserIdAndHouseId($attention);
if (count($attResult) > 0)
$result ["attention"] = $attResult["id"];
$result ["attention"] = $attResult[0]["id"];
}
......
......@@ -234,7 +234,7 @@ class Broker extends Basic
return $this->response("300", "参数不全", [ 'remote_groupid' => '' ]);
}
$searchdate = $params['searchdate'];
$searchdate = empty($params['searchdate']) ? '':$params['searchdate'];
$pagenum = isset($params['pagenum']) ? $params['pagenum'] : 1;
$pagesize = 15;
$user_id = $params['user_id'];
......
......@@ -68,11 +68,11 @@ class CellPhone extends Basic
$this->data = ['phone' => $phone_x['phone_x']];
} else {
$this->code = 101;
$this->msg = 'Binding failure.';
$this->msg = '绑定失败,请重试!';
}
} else {
$this->code = 102;
$this->msg = 'Number pool run out.';
$this->msg = '号码使用完,请联系运营人员。';
}
}
} else {
......
......@@ -42,17 +42,19 @@ class Client extends Basic
*/
public function editClient() {
header('Access-Control-Allow-Origin:*');
$table=New Agents();
$data=array();
if ($this->params['user_nick'] || $this->params['user_nick'] || $this->params['id']) {
if (!empty($this->params['user_nick']) || !empty($this->params['id'])) {
if ($this->request->isPost()) {
if ($this->params['id']) {
if (!empty($this->params['id'])) {
//编辑
//编辑
$data['start'] = $this->user->edit($this->params, $this->params['id']);
$this->operating_records($this->params['ccr_id'], $type=3, $remark='用户编辑',0,$this->params['id']);
} else {
//添加
$data['start'] = $this->user->edit($this->params);
if ($data['start'] == -1) {
if ($data['start'] != 1) {
$this->code = 101;
$this->msg = '该用户已存在';
}
......@@ -61,11 +63,16 @@ class Client extends Basic
$data['id']= $this->user->id;
$this->operating_records($this->params['ccr_id'], $type=3, $remark='用户添加',0,$data['id']);
}else{
$this->code = 101;
$this->msg = '提交重复!';
$data['id']= $this->user->id;
//获取客方数据
$name=$table->where('id',$this->params['agents_id'])->value('realname');
//var_dump($name);
$remark='客方添加为 '.$name;
$this->operating_records($this->params['ccr_id'], $type=3, $remark,0,$data['id']);
}
}
} else {
$data['start'] = $this->user->getClient($this->params['id']);
......@@ -105,7 +112,6 @@ class Client extends Basic
return $this->response(200,'成功',$data);
}
/**app 经纪人用户列表
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
......@@ -113,11 +119,10 @@ class Client extends Basic
*/
public function agentUserTb(){
header('Access-Control-Allow-Origin:*');
$table= new Users;
$table = new Users;
$data['msg'] = '';
$time=date("Y-m-d H:i:s",time());//当前时间
$time = date("Y-m-d H:i:s",time());//当前时间
$params = $this->request->param();
$search=$params['search'];
if(empty($params['agent_id'])){
return $this->response(100,'参数不全');
}
......@@ -126,31 +131,21 @@ class Client extends Basic
//条件
//time_minute_diff 时间差(分)48小时内增加的【拥有经纪人】的客户为--受保护客户
$field = ['id as user_id','user_nick','user_phone','agent_id','referrer_id','create_time',"TIMESTAMPDIFF(MINUTE,create_time,'{$time}')as time_minute_diff"];
$where = " agent_id in({$params['agent_id']}) ";
$field=['id as user_id',
'user_nick',
'user_phone',
'agent_id',
'referrer_id',
'create_time',
"TIMESTAMPDIFF(MINUTE,create_time,'{$time}')as time_minute_diff"];
$where=" ( agent_id in(0,{$params['agent_id']})
or TIMESTAMPDIFF(MINUTE,create_time,'{$time}') > 2880 )";
if(!empty($search)){
$where.=" and user_nick like '%$search%' or user_phone like '%$search%' ";
$data['search']=$search;
if(!empty($params['search'])){
//搜索客户--可以搜索自己的客户and 不在保护期的客户
$where = " (agent_id in(0,{$params['agent_id']}) or agent_id is null or TIMESTAMPDIFF(MINUTE,create_time,'{$time}') > 2880 )
and ( user_nick like '%{$params['search']}%' or user_phone like '%{$params['search']}%' ) ";
$data['search'] = $params['search'];
}
// echo $where;exit;
$order="id desc";
$data['list']=$table->getAgentUserTb($pageNo, $pageSize,$order,$field, $where);
$total=$table->getUserAgentTotal($where);
$data['total']= ceil($total / $pageSize);
$data['page']=$pageNo;
$data['list'] = $table->getAgentUserTb($pageNo, $pageSize,'id desc',$field, $where);
$total = $table->getMyUserCount($where);
$data['total'] = ceil($total / $pageSize);
$data['page'] = $pageNo;
return $this->response(200,'成功',$data);
}
......
<?php
namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\api_broker\service\FollowUpService;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/24
* Time : 14:24
* Intro:
*/
class FollowUp extends Basic
{
private $service_;
private $followUpModel;
public function __construct($request = null)
{
parent::__construct($request);
$this->service_ = new FollowUpService();
$this->followUpModel = new OFollowUp();
}
/**
* 报备
* @return \think\Response
*/
public function report()
{
/* $params = $this->params;
if (!isset($params['report_agent_id']) || !isset($params['report_store_id']) || !isset($params['user_id']) ||
!isset($params['house_ids']) || !isset($params['vehicle']) ) {
return $this->response("101", "请求参数错误");
}*/
$params = array(
"report_agent_id" => 1,
"report_store_id" => 1,
"user_id" => 1,
"house_ids" => "1,2,3",
"vehicle" => 10,
"intro" => "123123123",
"to_see_time" => date("Y-m-d H:i:s", time()),
);
$result = $this->followUpModel->addFollowUp($params);
if($result["code"] == 200){
return $this->response("200", "request success", ["id",$result["msg"]]);
}else{
return $this->response("101", "request faild");
}
}
}
\ No newline at end of file
......@@ -19,6 +19,8 @@ class Report extends Basic
{
private $service_;
private $fulModel;
private $oReportModel;
public function __construct($request = null)
......
......@@ -39,6 +39,7 @@ class Basic extends Controller
protected $agentPhone;
protected $timeStamp_;
protected $filterVerify = array(
'broker/login',
'broker/token',
'broker/getShopList',
'broker/getShopDetail',
......@@ -69,8 +70,19 @@ class Basic extends Controller
$jwt = new JWT();
$this->authToken = $this->params['AuthToken'];
$result = $jwt->decode($this->authToken, config('jwt_key'), array('HS256')); //解码token
if (isset($result->data)) {
$this->timeStamp_ = $result->timeStamp_;
$this->agentPhone = $result->data->phone;
$is = Db::table('agents')->where('phone', $this->agentPhone)->count();
} else {
$is = 0;
}
if ($is == 0) {
echo json_encode(array("code" => "300", "msg" => "用户验证失败,重新登录!", "data" => [], "type" => "json"));
exit;
}
$this->agentPhone = $result->data->phone;
$is = Db::table('agents')->where('phone', $result->data->phone)->count();
if ($is == 0) {
......@@ -120,8 +132,8 @@ class Basic extends Controller
public function verifyTime()
{
//authToken有效期为30天
if ((time() - $this->timeStamp_) > 2592000) {
//authToken有效期为30天2592000,1年31449601
if ((time() - $this->timeStamp_) > 31449601) {
echo json_encode(array( "code" => "300", "msg" => "AuthToken失效,请重新登录!", "data" => [], "type" => "json" ));
exit;
}
......
<?php
namespace app\api_broker\service;
use app\model\OFollowUp;
use app\model\OrderModel;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/26
* Time : 16:41
* Intro:
*/
class FollowUpService {
private $followUpModel;
private $orderModel;
function __construct()
{
$this->followUpModel = new OFollowUp();
$this->orderModel = new OrderModel();
}
/**
* 生成报备和保存订单
* @param $agent_id
* @param $store_id
* @param $user_id
* @param $house_ids
* @param $vehicle
* @param $intro
* @param $predict_see_time
* @return int
*/
public function verifyReport($agent_id,$store_id,$user_id,$house_ids,$vehicle,$intro,$predict_see_time){
$id = $this->oFollowUpBin($agent_id,$store_id,$user_id,$vehicle,$intro,$predict_see_time);
if($id > 0){
$house_arr = explode(",",$house_ids);
$order_arr = [];
foreach($house_arr as $k => $v ){
//todo 批量插入到数据库
$order_no = $this->createOrderNumber();
array_push($order_arr,$this->orderBin($order_no,$id,$v));
}
//todo 保存order表
return $this->orderModel->insertOrderByAll($order_arr);
}
}
/**
* 订单号
* @return string
*/
private function createOrderNumber(){
return time() . mt_rand(100000,999999);
}
/**
* 报备主表
* @param $report_agent_id
* @param $report_store_id
* @param $user_id
* @param $vehicle
* @param $intro
* @param $predict_see_time
* @return array
*/
private function oFollowUpBin($report_agent_id,$report_store_id,$user_id,$vehicle,$intro,$predict_see_time){
$param["report_agent_id"] = $report_agent_id;
$param["report_store_id"] = $report_store_id;
$param["user_id"] = $user_id;
$param["vehicle"] = $vehicle;
$param["status"] = 0;
$param["intro"] = $intro;
$param["predict_see_time"] = date("Y-m-d H:i:s",$predict_see_time);
$param["create_time"] = date("Y-m-d H:i:s",time());
$param["update_time"] = date("Y-m-d H:i:s",time());
return $this->followUpModel->addFollowUp($param);
}
private function orderBin($order_no,$f_id,$house_id){
$param["order_no"] = $order_no;
$param["f_id"] = $f_id;
$param["house_id"] = $house_id;
return $param;
}
}
\ No newline at end of file
......@@ -78,7 +78,7 @@ class Index
$field = "a.id,a.management_fee,a.title,a.address,a.city,a.room_area,a.room_area2,a.business_area,a.disc,a.disccircles,
a.sales,a.slotting_fee,a.transfer_fee, a.yetai,a.room_area2,a.shangpu_type,a.is_test,a.sellingpoint,a.singn_rule,
a.business_date,a.start_business_date,a.opentime,a.has_gas,a.traffic,a.has_moved,a.room_num_left,a.room_num_total,
a.shangpu_tags,a.carefully_chosen,a.price,a.dish,a.file_path,b.foreign_name,b.address_detail_c,
a.shangpu_tags,a.carefully_chosen,a.price,a.dish,a.file_path,a.rent_type,b.foreign_name,b.address_detail_c,
b.foreign_advantage";
$conditions = [];
if (empty($id)) {
......
......@@ -59,41 +59,26 @@
<span class="b1_span">
剩余铺数
</span>
<span class="b1_span_totl">
<span class="balance_num">
</span>/
<span class="balance_num2">
</span>
<span class="b1_span_totl pu_num">
</span>
</li>
<li class="ul_b2">
<span class="b1_span">
商铺面积
</span>
<span class="b1_span2">
<span class="b1_span3">
</span>
-
<span class="b1_span34">
</span>
<span class="b1_span_totl pu_area">
<font class="b1_font">
</font>
</span>
</li>
<li class="ul_b3">
<span class="b1_span">
商业面积
</span>
<span class="b1_span2">
<span class="b1_span4">
<span class="b1_span_totl shy_area">
</span>
<font class="b1_font">
</font>
</span>
</li>
</ul>
</div>
......
......@@ -47,7 +47,8 @@
</div>
<script src="/app/js/jquery.js"></script>
<!--<script src="/app/js/jquery.js"></script>-->
<script src="/app/js/jquery-1122-min.js" charset="UTF-8"></script>
<script src="/app/js/common.js" charset="UTF-8"></script>
<script src="/app/js/share_register.js"></script>
</body>
......
<?php
//配置文件
return [
];
\ No newline at end of file
<?php
namespace app\chat\consts;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/9
* Time : 13:27
* Intro:
*/
class ConfigConst
{
const CLIENT_ID = "YXA6hqlTwLr0EeeNFrlhHiI-Xg";
const CLIENT_SECRET = "YXA6BkraoPZqZYJoLce4sCyRebXMC48";
const API_PATH = "https://a1.easemob.com/";
const ORG_NAME = "1157170531115254";
const APP_NAME = "tonglianjituan";
}
\ No newline at end of file
<?php
namespace app\chat\consts;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/9
* Time : 16:54
* Intro:
*/
class ErrorCodeConst
{
//聊天
const ERROR_CODE_PARAM_NOT_EXIST = 110001;
const ERROR_CODE_TARGET_TYPE_ERROR = 110002;
}
\ No newline at end of file
<?php
namespace app\chat\controller;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/8
* Time : 16:54
* Intro:
*/
use app\chat\consts\ErrorCodeConst;
use app\chat\extend\Basic;
use app\chat\service\ChatService;
use app\chat\utils\RPush;
use app\extra\RedisPackage;
use app\model\ChatMsg;
use app\model\GHousesExt;
use app\model\HouseImgs;
use app\model\HouseinfoExts;
use app\model\HouseInfos;
use think\Cache;
use Think\Log;
class AppChat extends Basic
{
/**
* @var RPush
*/
private $_push;//环信接口消息推送
/**
* @var ChatService
*/
private $_chat;
public function __construct($request = null)
{
parent::__construct($request);
$this->_push = new RPush();
$this->_chat = new ChatService();
}
public function index()
{
/*
log 常规日志,用于记录日志
error 错误,一般会导致程序的终止
notice 警告,程序可以运行但是还不够完美的错误
info 信息,程序输出信息
debug 调试,用于调试信息
sql SQL语句,用于SQL记录,只在数据库的调试模式开启时有效
*/
Cache::set('name', '121212');
echo Cache::get('name');
$redis = new RedisPackage();
$redis::set('test', 'hello redis');
echo $redis::get('test');
Log::record('日志', 'notice');
return null;
}
/**
* 验证用户角色,生成唯一id
*
* @return \think\Response
*/
public function userChat()
{
/* $params = array(
"user_id" => 10,
"mobile" => "15821506182",
"source" => 1 //1经纪人 2用户
);*/
$params = $this->params;
if (!isset($params['user_id']) || !isset($params['mobile']) || !isset($params['source'])) {
return $this->response(ErrorCodeConst::ERROR_CODE_PARAM_NOT_EXIST, "请求参数错误");
}
$user_id = $params['user_id'];
$mobile = $params['mobile'];
$source = $params['source'];
if (!$user_id || !$mobile || !$source) {
return $this->response(ErrorCodeConst::ERROR_CODE_PARAM_NOT_EXIST, "请求参数错误");
}
$only_arr = $this->_chat->register($user_id, $mobile, $source);
if ($only_arr["code"] == 200) {
return $this->response("200", "success", [ "only_id" => $only_arr["only_id"] ]);
} else {
return $this->response("101", $only_arr["msg"]);
}
}
/**
* 获取经纪人或用户的信息
* @return \think\Response
*/
public function getUserOrAgentInfo()
{
$params = $this->params;
if (!isset($params['only_id']) || !isset($params['source'])) {
return $this->response(ErrorCodeConst::ERROR_CODE_PARAM_NOT_EXIST, "请求参数错误");
}
/* $params = array(
"only_id" => "agent_9",
"source" => 2,// 1经纪人 or 2用户
);*/
$result = $this->_chat->getUserInfo($params['only_id'], $params["source"]);
if ($result) {
return $this->response("200", "request success", $result);
}
return $this->response("101", "request error ,not fund list", []);
}
/**
* 发送消息接口
* @return \think\Response
*/
public function pushMsg()
{
$params = $this->params;
if (!isset($params['target_type']) || !isset($params['target']) || !isset($params['type'])
|| !isset($params['msg_content']) || !isset($params['source']) || !isset($params['is_user']) || !isset($params['from'])) {
return $this->response(ErrorCodeConst::ERROR_CODE_PARAM_NOT_EXIST, "请求参数错误");
}
/* $params = array(
'user_name' => 'cesh',
'msg_content' => 'ceshi666',
'target_type' => 'users',
'source' => '1',
'from' => 'admin',
'type' => '1',
'is_user' => '0',
'target' => '18112347151',
);*/
$user_name = isset($params['user_name']) ? $params['user_name'] : $params['from'];//用户昵称
$target_type = $params['target_type']; // 消息类型 users 给用户发消息。chatgroups: 给群发消息,chatrooms: 给聊天室发消息
$target = $params['target']; //接受人 if target_type 群 者表示群id
$source = $params['source']; //消息来源 1c端app 2b端app 3其他
$is_user = $params['is_user']; //发送人是否是会员 0是1经济人
$type = $params['type']; //消息类型 1文字 2图片 3楼盘
$msg_content = $params['msg_content'];
$from = $params['from']; //消息发送人
if ($target_type != "users" && $target_type != "chatgroups" && $target_type != "chatrooms") {
return $this->response(ErrorCodeConst::ERROR_CODE_TARGET_TYPE_ERROR, "错误的消息类型");
}
$result = $this->_chat->sendMsg($user_name,$target_type, $target, $source, $is_user, $type, $msg_content, $from, $this->accessToken);
if ($result) {
return $this->response("200", "", [ "msg" => "消息发送成功" ]);
} else {
return $this->response("101", "", [ "msg" => "消息内容错误" ]);
}
}
/**
* 查询历史和搜索历史
* @return \think\Response
*/
public function getChatHistory()
{
$params = $this->params;
if (!isset($params['target_type']) || !isset($params['from']) || !isset($params['target'])) {
return $this->response(ErrorCodeConst::ERROR_CODE_PARAM_NOT_EXIST, "请求参数错误");
}
/* $params = array(
'target_type' => 'users', // 消息类型 users 用户消息。chatgroups: 群消息,chatrooms: 聊天室消息
'from' => 'app_64', //发送人
'target' => '18112347151', //接受人
'page_no' => '1', //第几页
'page_size' => '15' //每页多少条
);*/
$page_no = empty($params['page_no']) ? 1 : $params['page_no'];
$page_size = empty($params['page_size']) ? 15 : $params['page_size'];
$field = "a.id,a.to_id,a.from_id,a.created_at,b.type,b.body";
$msgModel = new ChatMsg();
$history_result = $msgModel->getChatHistory($params, $field, $page_no, $page_size);
return $this->response("200", "request success", array_reverse($history_result));
}
/**
* 上传聊天图片
* @return \think\Response
*/
public function uploadImg()
{
$file = request()->file('image');
$data = [];
if ($file) {
$path = ROOT_PATH . 'public' . DS . 'static' . DS . 'chat_image';
$info = $file->validate([ 'size' => 512000, 'ext' => 'jpg,png' ])//限制500KB
->move($path);
if ($info) {
$img_path = $info->getSaveName(); //生成的图片路径
$static_path = $path . DS . $img_path; //生成图片的绝对路径
$image = \think\Image::open($static_path);
$image->thumb(500, 500)->save($static_path); //生成缩略图
$data = [ 'name' => $img_path ];
} else {
// 上传失败获取错误信息
return $this->response("101", $file->getError());
}
} else {
return $this->response("101", "没有该文件");
}
return $this->response("200", "request success", $data);
}
/**
* 聊天页面获取三个商铺信息
* @return \think\Response
*/
public function pushMsg_gethouseinfo()
{
$homeurl = IMG_PATH;
$params = $this->params;
/*$params['id']=4762;
$params['from']='b';*/
if (!isset($params['id']) || !isset($params['from'])) {
return $this->response("300", "参数不全", [ 'remote_groupid' => '' ]);
}
$id = $params['id'];
$from = $params['from'];
//主表查询商铺详细信息
$HouseInfos = new HouseInfos();
$HouseInfosre = $HouseInfos->getHousepusmessage($id);
//dump($HouseInfosre);
if ($HouseInfosre) {
$data['title'] = $HouseInfosre[0]['title'];
if ($from == 'c') {
//副表查询c端显示名称
$HouseinfoExts = new HouseinfoExts();
$HouseinfoExtsInfosre = $HouseinfoExts->getHouse_ext($id);
//dump($HouseinfoExtsInfosre);
$data['title'] = $HouseinfoExtsInfosre[0]['foreign_name'] ? $HouseinfoExtsInfosre[0]['foreign_name'] : '未知商铺';
}
//dump($HouseInfosre[0]['room_area']);
//dump($HouseInfosre[0]['room_area2']);
$room_area = $HouseInfosre[0]['room_area'] ? $HouseInfosre[0]['room_area'] : '';
$room_area2 = $HouseInfosre[0]['room_area2'] ? '-' . $HouseInfosre[0]['room_area2'] : '';
$data['room_area_all'] = '暂无!';
if ($room_area || $room_area2) {
$data['room_area_all'] = $room_area . $room_area2 . 'm²';
}
$data['price'] = '暂无!';
if ($HouseInfosre[0]['rent_type']) {
//rent_type COMMENT '1.月租金 2.营业额扣点 3.每平方米租金',
$message[1] = '月租金:' . $HouseInfosre[0]['price'] . '元/月';
$message[2] = '营业额扣点:' . $HouseInfosre[0]['price'] . '%';
$message[3] = '每平方米租金:' . $HouseInfosre[0]['price'] . '元/天/㎡';
$data['price'] = $message[$HouseInfosre[0]['rent_type']];
}
//同联默认图片,如果用户没上传的话/img/houseinfobackgroundimg.png
$data['imagename'] = $homeurl . '/img/houseinfobackgroundimg_new.png';
$HouseImgs = new HouseImgs();
$HouseImgsre = $HouseImgs->getHouseImgs($id, 1);
//用户上传了就用上传的
if ($HouseImgsre) {
$data['imagename'] = $homeurl . '/small_' . $HouseImgsre[0]['imagename'];
}
// dump($HouseInfosre);
// dump($data);
// exit;
return $this->response("200", "success!", $data);
} else {
return $this->response("400", "暂无数据!");
}
}
}
<?php
namespace app\chat\controller;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/23
* Time : 13:47
* Intro:
*/
use app\chat\extend\Basic;
use app\chat\utils\UGroup;
use app\model\ChatGroup;
use app\model\ChatGroupMember;
use phpDocumentor\Reflection\DocBlock\Tags\Return_;
use think\Db;
class Group extends Basic
{
public function createGroupByOnlyId()
{
//todo 组群创建 1.存表,2调用环信接口
$params = $this->params;
//exit;
/*$params['group_name']='雷神先锋';
$params['group_users']=["18112347151"];
$params['group_users_admin']="admin";*/
if (!isset($params['group_name']) || !isset($params['group_users']) || !isset($params['group_users_admin'])) {
return $this->response("300", "参数不全", ['remote_groupid'=>'']);
}
$group_name = $params['group_name'];
$group_users = $params['group_users'];
$group_users_admin = $params['group_users_admin'];
$UGroup= new UGroup();
$result = $UGroup->createGroup($group_name, $group_users, $group_users_admin,$this->accessToken);
$result=json_decode($result,true);
//var_dump($result);
//判断环信群是否建立成功
if(isset($result['data']['groupid'])){
//群表记录数据
$user = new ChatGroup;
$user->group_name = $group_name;
$user->platform_group_id = $result['data']['groupid'];
$user->type = 0;
$user->is_close = 0;
$user->save();
//群id
$group_id = $user->id;
//var_dump($user->id);
//群成员表表记录数据
$group_users[]=$group_users_admin;
$msgModel = new ChatGroupMember();
foreach ($group_users as $k => $v) {
$msgModel->addChatMsgExt([
'unique_id' => $v,
'group_id' => $group_id,
"type" => ($v == $group_users_admin) ? 1 : 0 ,
"is_close" => 0]);
}
return $this->response("200", "request success", ['remote_groupid'=>$result['data']['groupid']]);
}else{
return $this->response("400", "建群失败", ['remote_groupid'=>'']);
}
}
public function updateGroup()
{
//todo 修改组群信息 1.群信息完善到后台表 无需调用环信接口
}
public function delGroup()
{
//todo 删除群组 1.改变我们group表的状态2.调用环信删群接口
//是否隐藏 0正常 1删除
$params = $this->params;
/*exit;
$params['group_id']='39285903392772';*/
if (!isset($params['group_id'])) {
return $this->response("300", "参数不全", ['remote_groupid'=>'']);
}
$group_id = $params['group_id'];
$UGroup = new UGroup();
$result = $UGroup->deleteGroup($group_id,$this->accessToken);
$result=json_decode($result,true);
//判断环信群是否建立成功
if(isset($result['data']['success']) and $result['data']['success']){
//更新ChatGroup数据
$ChatGroup = new ChatGroup;
$ChatGroupre=$ChatGroup->save(['is_close' => 1],['platform_group_id' => $group_id]);
//更新ChatGroupMember表
$ChatGroup1 = ChatGroup::get(['platform_group_id' => $group_id]);
Db::table('chat_group_member')
->where('group_id',$ChatGroup1['id'])
->update(['is_close' => 1]);
return $this->response("200", "request success");
}else{
return $this->response("400", "删除群组失败", ['remote_groupid'=>'']);
}
}
/**
* 群组管理
*/
public function getGroupUser()
{
//todo 获取群组成员/管理员 我们的数据库获取
$params = $this->params;
// exit;
/*$params['group_id']='39285903392772';
$params['pagenum']=1;//页码,从1开始
$params['pagesize']=10;//每页显示数量,最大不超过1000*/
if (!isset($params['group_id']) and !isset($params['pagenum'])) {
return $this->response("300", "参数不全", ['remote_groupid'=>'']);
}
$group_id = $params['group_id'];
$pagenum = isset($params['pagenum']) ? $params['pagenum'] : 1;
$pagesize = $params['pagesize'];
/* $UGroup = new UGroup();
$result = $UGroup->getGroupUser($group_id,$pagenum,$pagesize,$this->accessToken);
$result=json_decode($result,true);*/
$pre = ($pagenum-1)*$pagesize;
$GroupUser=Db::query("SELECT * FROM chat_group_member WHERE group_id=(SELECT id FROM chat_group WHERE platform_group_id={$group_id}) AND is_close=0 LIMIT {$pre},{$pagesize} ");
//var_dump($GroupUser) ;
$total=Db::query("SELECT count(*) as total FROM chat_group_member WHERE group_id=(SELECT id FROM chat_group WHERE platform_group_id={$group_id}) AND is_close=0");
//var_dump($total[0]['total']) ;
$total = $total[0]['total'];
$total = intval($total / $pagesize) + (($total % $pagesize == 0) ? 0 : 1);
//判断环信群是否建立成功
if($GroupUser){
return $this->response("200", "request success",['user_date'=>$GroupUser,'pagenum'=>$pagenum,'total'=>$total]);
}else{
return $this->response("400", "获取失败");
}
}
public function addGroupUserByIds()
{
//todo 添加群组成员 1.单个/多个到表中,2.调用环信接口更新进去
$params = $this->params;
//exit;
/*$params['group_users']=["18112347151"];
$params['group_id']="39285903392772";*/
if (!isset($params['group_id']) and !isset($params['group_users'])) {
return $this->response("300", "参数不全", ['remote_groupid'=>'']);
}
$group_users = $params['group_users'];
$group_id = $params['group_id'];
$UGroup = new UGroup();
foreach ($group_users as $k => $v) {
$result = $UGroup->addGroupUserByIds($group_id,$v,$this->accessToken);
$result=json_decode($result,true);
//var_dump($result) ;
if(isset($result['data']['result']) and $result['data']['result']){
$Dbreturn=Db::query("SELECT id FROM chat_group WHERE platform_group_id={$group_id}");
$chat_group_group_id=$Dbreturn[0]['id'];
//先查询是否已经存在
$chat_group_member=Db::query("SELECT * FROM chat_group_member WHERE unique_id={$v} AND group_id={$chat_group_group_id}");
if($chat_group_member){
//var_dump($chat_group_group_id) ;
$msgModel = new ChatGroupMember();
$msgModel ->where(['unique_id'=>$v,'group_id'=>$chat_group_group_id])
->update(['is_close' => 0]);
}else{
//var_dump($chat_group_group_id) ;
$msgModel = new ChatGroupMember();
$msgModel ->addChatMsgExt([
'unique_id' => $v,
'group_id' => $chat_group_group_id,
"type" => 0 ,
"is_close" => 0]);
}
}
}
return $this->response("200", "request success");
}
public function delGroupUserByIds()
{
//todo 移除群组成员 1.单个或多个跟新到库, 2.调用环信接口更新
$params = $this->params;
//exit;
/*$params['group_users']=["18112347151"];
$params['group_id']="39285903392772";*/
if (!isset($params['group_id']) and !isset($params['group_users'])) {
return $this->response("300", "参数不全", ['remote_groupid'=>'']);
}
$group_users = $params['group_users'];
$group_id = $params['group_id'];
$UGroup = new UGroup();
foreach ($group_users as $k => $v) {
$result = $UGroup->delGroupUserByIds($group_id,$v,$this->accessToken);
$result=json_decode($result,true);
//var_dump($result) ;
if(isset($result['data']['result']) and $result['data']['result']){
$Dbreturn=Db::query("SELECT id FROM chat_group WHERE platform_group_id={$group_id}");
$chat_group_group_id=$Dbreturn[0]['id'];
//var_dump($chat_group_group_id) ;
$msgModel = new ChatGroupMember();
$msgModel ->where(['unique_id'=>$v,'group_id'=>$chat_group_group_id])
->update(['is_close' => 1]);
}
}
return $this->response("200", "request success");
}
public function addGroupManage()
{
//todo 添加群组管理员 1.单个更新到库, 2.调用环信接口更新
$params = $this->params;
//exit;
/*$params['group_user']="18112347151";
$params['group_id']="39285903392772";*/
if (!isset($params['group_id']) and !isset($params['group_user'])) {
return $this->response("300", "参数不全", ['remote_groupid'=>'']);
}
$group_user = $params['group_user'];
$group_id = $params['group_id'];
$UGroup = new UGroup();
$result = $UGroup->addGroupManage($group_id,$group_user,$this->accessToken);
$result=json_decode($result,true);
//var_dump($result) ;
if(isset($result['data']['result']) and $result['data']['result']=='success'){
$Dbreturn=Db::query("SELECT id FROM chat_group WHERE platform_group_id={$group_id}");
$chat_group_group_id=$Dbreturn[0]['id'];
//先查询是否已经存在
$chat_group_member=Db::query("SELECT * FROM chat_group_member WHERE unique_id={$group_user} AND group_id={$chat_group_group_id}");
if($chat_group_member){
//var_dump($chat_group_group_id) ;
$msgModel = new ChatGroupMember();
$msgModel ->where(['unique_id'=>$group_user,'group_id'=>$chat_group_group_id])
->update(['type' => 1]);
}
return $this->response("200", "request success");
}else{
return $this->response("400", "添加失败!");
}
}
public function delGroupManage()
{
//todo 移除群组管理员 1.单个更新到库, 2.调用环信接口更新
$params = $this->params;
//exit;
/*$params['group_user']="18112347151";
$params['group_id']="39285903392772";*/
if (!isset($params['group_id']) and !isset($params['group_user'])) {
return $this->response("300", "参数不全", ['remote_groupid'=>'']);
}
$group_user = $params['group_user'];
$group_id = $params['group_id'];
$UGroup = new UGroup();
$result = $UGroup->delGroupManage($group_id,$group_user,$this->accessToken);
$result=json_decode($result,true);
//var_dump($result) ;
if(isset($result['data']['result']) and $result['data']['result']=='success'){
$Dbreturn=Db::query("SELECT id FROM chat_group WHERE platform_group_id={$group_id}");
$chat_group_group_id=$Dbreturn[0]['id'];
//先查询是否已经存在
$chat_group_member=Db::query("SELECT * FROM chat_group_member WHERE unique_id={$group_user} AND group_id={$chat_group_group_id}");
if($chat_group_member){
//var_dump($chat_group_group_id) ;
$msgModel = new ChatGroupMember();
$msgModel ->where(['unique_id'=>$group_user,'group_id'=>$chat_group_group_id])
->update(['type' => 0]);
}
return $this->response("200", "request success");
}else{
return $this->response("400", "添加失败!");
}
}
}
\ No newline at end of file
<?php
namespace app\chat\extend;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/8
* Time : 16:54
* Intro:
*/
use app\chat\consts\ConfigConst;
use app\chat\utils\CurlUtil;
use http\Exception;
use think\Cache;
use think\Controller;
use Think\Log;
use think\Request;
use think\Response;
class Basic extends Controller
{
/**
* 访问请求对象
* @var Request
*/
public $request;
/**
* 请求参数
* @var mixed|null
*/
public $params;
/**
* app通讯接口授权token
* @var
*/
public $accessToken;
/**
* 基础接口SDK
* @param Request|null $request
*/
public function __construct(Request $request = null)
{
// CORS 跨域 Options 检测响应
$this->corsOptionsHandler();
// 输入对象
$this->request = is_null($request) ? Request::instance() : $request;
if (strtoupper($this->request->method()) === "GET") {
$this->params = $this->request->param();
} elseif (strtoupper($this->request->method()) === "POST") {
$this->params = $this->request->param() != null ? $this->request->param() : null;
}
$this->accessToken = Cache::get('access_token');
$expires_in = Cache::get('expires_in');
$application = Cache::get('application');
$accredit_time = Cache::get('accredit_time');
if (!$this->accessToken || !$expires_in || !$application || !$accredit_time || (time() - $accredit_time) > $expires_in) {
//todo 这里加个验证 多少时间内不能重复请求
$this->getToken();
if (Cache::get('access_token')) {
$this->accessToken = Cache::get('access_token');
} else {
echo json_encode(array( "code" => "300", "msg" => "accessToken拉取失败,请稍后再试!", "data" => [], "type" => "json" ));
exit;
}
}
}
/**
* 输出返回数据
* @param string $msg 提示消息内容
* @param string $code 业务状态码
* @param mixed $data 要返回的数据
* @param string $type 返回类型 JSON XML
* @return Response
*/
public function response($code = 'SUCCESS', $msg, $data = [], $type = 'json')
{
$result = [ 'code' => $code, 'msg' => $msg, 'data' => $data, 'type' => strtolower($type) ];
return Response::create($result, $type);
}
public function getApiPath()
{
return ConfigConst::API_PATH . ConfigConst::ORG_NAME . "/" . ConfigConst::APP_NAME;
}
/**
* Cors Options 授权处理
*/
public static function corsOptionsHandler()
{
if (request()->isOptions()) {
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Headers:Accept,Referer,Host,Keep-Alive,User-Agent,X-Requested-With,Cache-Control,Content-Type,Cookie,token');
header('Access-Control-Allow-Credentials:true');
header('Access-Control-Allow-Methods:GET,POST,OPTIONS');
header('Access-Control-Max-Age:1728000');
header('Content-Type:text/plain charset=UTF-8');
header('Content-Length: 0', true);
header('status: 204');
header('HTTP/1.0 204 No Content');
exit;
}
}
/**
* 获取调取接口的access_token
*/
public function getToken()
{
$url = "/token";
$data = [
"grant_type" => "client_credentials",
"client_id" => ConfigConst::CLIENT_ID,
"client_secret" => ConfigConst::CLIENT_SECRET
];
$curl = new CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
$apiUrl = $this->getApiPath() . $url;
try {
$response = $curl->post($apiUrl, json_encode($data));
$response = json_decode($response,true);
if ($response) {
Cache::set('access_token', $response["access_token"]);
Cache::set('expires_in', $response["expires_in"]);
Cache::set('application', $response["application"]);
Cache::set('accredit_time', time());
}
} catch (Exception $e) {
Log::record('class:Basic,function:getToken get token ,Exception :' . $e, "error");
}
Log::record('class:Basic,function:getToken get token' , "info");
}
}
<?php
namespace app\chat\service;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/8
* Time : 16:54
* Intro:
*/
use app\chat\utils\RegisterUtil;
use app\chat\utils\RPush;
use app\model\Agents;
use app\model\ChatMsg;
use app\model\ChatMsgExt;
use app\model\ChatMsgStatus;
use app\model\ChatRelation;
use app\model\ChatUser;
use app\model\HouseInfos;
use app\model\Users;
use http\Exception;
class ChatService
{
public $connection;
public $logs;
const MSG_CONTENT_TYPE_TEXT = 1; //文字
const MSG_CONTENT_TYPE_VOICE = 2; //语音
const MSG_CONTENT_TYPE_VIDEO = 3; //视频
const MSG_TYPE_USERS = "users"; //给用户发消息
const MSG_TYPE_CHAT_GROUPS = "chatgroups"; //给群发消息
const MSG_TYPE_CHAT_CHAT_ROOMS = "chatrooms"; //给聊天室发消息
const SOURCE_TYPE_APP = 'user_'; // 用户 c端
const SOURCE_TYPE_AGENT = 'agent_';//经纪人 b端
protected $userModel;
protected $agentsModel;
protected $chatUserModel;
public function __construct()
{
$this->userModel = new Users();
$this->agentsModel = new Agents();
$this->chatUserModel = new ChatUser();
}
/**
* @param $user_id
* @param $mobile
* @param $source
* @return array
*/
public function register($user_id, $mobile, $source)
{
//todo
$params["type"] = $source;
$params["user_id"] = $user_id;
$params["phone"] = $mobile;
$fields = "id,type,phone,only_id,password";
$chatUser = $this->chatUserModel->getChatUser($params, $fields);
if (count($chatUser) > 0) {
return [ "code" => "200", "only_id" => $chatUser[0]["only_id"] ];
} else {
$reg = new RegisterUtil();
$only_id = $this->createOnlyId($user_id, $source);
if (!$only_id) {
return [ "code" => "101", "msg" => "user msg not found" ];
}
$response = $reg->registerByCurl($only_id, $mobile);
if ($response) {
//todo insert
$this->insertChatUser($source, $user_id, $mobile, $only_id);
}
return [ "code" => 200, "only_id" => $only_id ];
}
}
/**
* 生成唯一id
* @param $userId integer 用户id
* @param $source integer 来源 '1经纪人 2用户'
* @return string
*/
public function createOnlyId($userId, $source)
{
$onlyId = "";
switch ($source) {
case 1:
$where_["inuse"] = 1;
$where_["id"] = $userId;
$agentsResult = $this->agentsModel->getAgentsById("id", $where_);
if (count($agentsResult) > 0 && $agentsResult[0]['id'] > 0)
$onlyId = self::SOURCE_TYPE_AGENT . $userId;
break;
case 2:
$userResult = $this->userModel->selectUser($userId);
if ($userResult->id)
$onlyId = self::SOURCE_TYPE_APP . $userResult->id;
break;
}
if (!$onlyId) {
//return array( "code" => 101, "msg" => "没找到用户信息" );
return null;
}
return $onlyId;
}
/**
* 删除注册用户
* @param $only_id
* @param $access_token
* @return bool
*/
public function deleteUser($only_id, $access_token)
{
$reg = new RegisterUtil();
$reg->deleteByCurl($only_id, $access_token);
return true;
}
/**
* 发送消息
* @param $user_name
* @param $target_type
* @param $target
* @param $source
* @param $is_user
* @param $type
* @param $msg_content
* @param $from
* @param $accessToken
* @return bool
*/
public function sendMsg($user_name,$target_type, $target, $source, $is_user, $type, $msg_content, $from, $accessToken)
{
//fixme 之后扩展 此处有bug
/* if ($type == 3) {
try {
$house_id = (integer)trim($msg_content);
$HouseInfoModel = new HouseInfos();
$houseResult = $HouseInfoModel->getHousepusmessage($house_id);
if (count($houseResult) == 0)
return false;
} catch (Exception $e) {
return false;
}
}
//todo 判断是否创建关系没有则保存
$this->verifyRelation($target, $from);*/
$this->insertMsg($target_type, $target, $source, $is_user, $type, $msg_content, $from);
$rPush = new RPush();
//todo 消息接收人必须是数据
$rPush->send($user_name,$target_type, [ $target ], $msg_content, $from, $type, $accessToken, [ $this, 'saveSendStatus' ]);
return true;
}
/**
* 保存推送到环信的消息状态 往msg_status中插入数据
* @param $response
* @param $target
* @param $sender
* @param $msg_content
*/
public function saveSendStatus($response, $target, $from, $msg_content)
{
$response = json_decode($response, true);
//目前没有针对多人聊天
$status = isset($response["data"][$target[0]]) ? $response["data"][$target[0]] : "faild";
$error_reason = "";
if ($status != "success") {
$error_reason = "环信发送异常";
}
$this->insertPushLog($from, $target[0], $msg_content, $status, $error_reason);
}
/**
* 根据手机号或者onlyId获取用户信息
* @param $only_id
* @param $type 之后扩展
* @return array|false|\PDOStatement|string|\think\Model
*
*/
public function getUserInfo($only_id, $type)
{
$user_phone = $agent_phone = [];
$chat_user_arr = [];
if ($only_id) {
$only_id_arr = explode(",", $only_id);
$where_["only_id"] = array( "in", $only_id_arr );
$where_["status"] = 0;
$field = "type,user_id,phone,only_id";
$chat_user = $this->chatUserModel->getChatUser($where_, $field);
foreach ($chat_user as $v) {
if ($v["type"] == 1) {
array_push($agent_phone, $v["phone"]);
} else {
array_push($user_phone, $v["phone"]);
}
$chat_user_arr[$v["phone"]] = $v["only_id"];
}
}
$info_arr = [];
if (count($agent_phone) > 0) {
$field = "id,realname as user_nick,phone as user_phone,head_portrait as user_pic,CONCAT(agentshopname,'-',sub_shopname) as shop_name";
$where_agent["phone"] = array( "in", $agent_phone );
$where_agent["inuse"] = 1;
$where_agent["level"] = array( "in", [ 2, 5 ] );
$agentsResult = $this->agentsModel->getAgentsById($field, $where_agent);
foreach ($agentsResult as $v) {
if ($v["user_pic"]) {
$v["user_pic"] = ADMIN_URL_TL . 'user_header/' . $v["user_pic"];
}
$v["only_id"] = $chat_user_arr [$v["user_phone"]];
array_push($info_arr, $v);
}
}
if (count($user_phone) > 0) {
$fields = "id,user_nick,user_phone,user_pic";
$param["status"] = 0;
$param["user_phone"] = array( "in", $user_phone );
$userResult = $this->userModel->getUserByWhere($param, $fields);
foreach ($userResult as $v) {
if ($v["user_pic"]) {
$v["user_pic"] = HEADERIMGURL . $v["user_pic"];
}
$v["only_id"] = $chat_user_arr [$v["user_phone"]];
$v["shop_name"] = "";
array_push($info_arr, $v);
}
}
return $info_arr;
}
/**
* 保存用户发送的消息
* @param $target_type
* @param $target
* @param $source
* @param $is_user
* @param $type
* @param $msg_content
* @param $from
*/
private function insertMsg($target_type, $target, $source, $is_user, $type, $msg_content, $from)
{
//todo
$params["msg_type"] = 1; //目前只用到了环信的文本消息
$params["to_id"] = $target;
$params["from_id"] = $from;
$params["is_group"] = $target_type == "users" ? 0 : 1;
$params["account_type"] = 1;
$params["source"] = $source;
$params["is_user"] = $is_user;
$params["created_at"] = date("Y-m-d H:i:s", time());
$params["updated_at"] = date("Y-m-d H:i:s", time());
$msgModel = new ChatMsg();
$id = $msgModel->addChatMsg($params);
if ($id > 0) {
//todo 插入msg_ext
$group_id = 0;
if ($target_type != "users") {
$group_id = $from;
}
$this->insetMsgExt($id, $type, $msg_content, $params["is_group"], $group_id);
}
}
/**
* @param $target
* @param $from
*/
private function verifyRelation($target, $from)
{
$chatRelationModel = new ChatRelation();
$params["target"] = $target;
$params["from"] = $from;
$relationResult = $chatRelationModel->getChatRelation($params);
if (count($relationResult) == 0) {
//如果没有记录则记录聊天关系
$chatRelationModel->addChatRelation($params);
}
}
/**
* 记录消息body
* @param $id
* @param $type
* @param $msg_content
* @param $is_group
* @param $group_id
*/
private function insetMsgExt($id, $type, $msg_content, $is_group, $group_id)
{
$param["msg_id"] = $id;
$param["type"] = $type;
$param["body"] = $msg_content;
$param["send_type"] = $is_group;
$param["group_id"] = $group_id;
$param["create_at"] = date("Y-m-d H:i:s", time());
$param["updated_at"] = date("Y-m-d H:i:s", time());
$msgExtModel = new ChatMsgExt();
$msgExtModel->addChatMsgExt($param);
}
/** 获取聊天记录
* @param $sender
* @param $start
* @param $limit
* @param $site_id
* @return array
*/
public function getHistoryChatList($sender, $start, $limit, $site_id)
{
//todo
}
/**
* 往chat_msg_status中插入数据,记录推送的状态
* @param $from
* @param $target
* @param $content
* @param $status
* @param $error_reason
* @return bool
*/
public function insertPushLog($from, $target, $content, $status, $error_reason)
{
$param["from"] = $from;
$param["target"] = $target;
$param["content"] = $content;
$param["status"] = $status;
$param["error_reason"] = $error_reason;
$param["create_time"] = date("Y-m-d H:i:s", time());
$model_ = new ChatMsgStatus();
$model_->addChatMsgStatus($param);
return true;
}
/**
* @param $type
* @param $user_id
* @param $phone
* @param $only_id
* @return bool
*/
public function insertChatUser($type, $user_id, $phone, $only_id)
{
$params["type"] = $type;
$params["user_id"] = $user_id;
$params["phone"] = $phone;
$params["only_id"] = $only_id;
$params["password"] = $phone;
$params["last_login_time"] = date("Y-m-d H:i:s", time());
$params["created_at"] = date("Y-m-d H:i:s", time());
$params["updated_at"] = date("Y-m-d H:i:s", time());
$this->chatUserModel->addChatUser($params);
return true;
}
}
\ No newline at end of file
<?php
namespace app\chat\service;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/23
* Time : 14:15
* Intro:
*/
class GroupService
{
//todo
}
\ No newline at end of file
<?php
namespace app\chat\utils;
/**
* Parses the response from a Curl request into an object containing
* the response body and an associative array of headers
*
* @author qianfunian <qianfunian@51jk.com>
**/
class CurlResponse {
/**
* The body of the response without the headers block
*
* @var string
**/
public $body = '';
/**
* An associative array containing the response's headers
*
* @var array
**/
public $headers = array();
/**
* Accepts the result of a curl request as a string
*
* <code>
* $response = new CurlResponse(curl_exec($curl_handle));
* echo $response->body;
* echo $response->headers['Status'];
* </code>
*
* @param string $response
**/
function __construct($response) {
# Headers regex
$pattern = '#HTTP/\d\.\d.*?$.*?\r\n\r\n#ims';
# Extract headers from response
preg_match_all($pattern, $response, $matches);
$headers_string = array_pop($matches[0]);
$headers = explode("\r\n", str_replace("\r\n\r\n", '', $headers_string));
# Remove headers from the response body
$this->body = str_replace($headers_string, '', $response);
# Extract the version and status from the first header
$version_and_status = array_shift($headers);
preg_match('#HTTP/(\d\.\d)\s(\d\d\d)\s(.*)#', $version_and_status, $matches);
$this->headers['Http-Version'] = $matches[1];
$this->headers['Status-Code'] = $matches[2];
$this->headers['Status'] = $matches[2].' '.$matches[3];
# Convert headers into an associative array
foreach ($headers as $header) {
preg_match('#(.*?)\:\s(.*)#', $header, $matches);
$this->headers[$matches[1]] = $matches[2];
}
}
/**
* Returns the response body
*
* <code>
* $curl = new Curl;
* $response = $curl->get('google.com');
* echo $response; # => echo $response->body;
* </code>
*
* @return string
**/
function __toString() {
return $this->body;
}
}
\ No newline at end of file
<?php
namespace app\chat\utils;
/**
* A basic CURL wrapper
*
* @author qianfunian <qianfunian@51jk.com>
**/
class CurlUtil {
/**
* The file to read and write cookies to for requests
*
* @var string
**/
public $cookie_file;
/**
* Determines whether or not requests should follow redirects
*
* @var boolean
**/
public $follow_redirects = true;
/**
* An associative array of headers to send along with requests
*
* @var array
**/
public $headers = array();
/**
* An associative array of CURLOPT options to send along with requests
*
* @var array
**/
public $options = array();
/**
* The referer header to send along with requests
*
* @var string
**/
public $referer;
/**
* The user agent to send along with requests
*
* @var string
**/
public $user_agent;
/**
* Stores an error string for the last request if one occurred
*
* @var string
* @access protected
**/
protected $error = '';
/**
* Stores resource handle for the current CURL request
*
* @var resource
* @access protected
**/
protected $request;
/**
* Initializes a Curl object
*
* Sets the $cookie_file to "curl_cookie.txt" in the current directory
* Also sets the $user_agent to $_SERVER['HTTP_USER_AGENT'] if it exists, 'Curl/PHP '.PHP_VERSION.' (http://github.com/shuber/curl)' otherwise
**/
function __construct() {
$this->cookie_file = dirname(__FILE__).DIRECTORY_SEPARATOR.'curl_cookie.txt';
$this->user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'Curl/PHP ' . PHP_VERSION;
}
/**
* Makes an HTTP DELETE request to the specified $url with an optional array or string of $vars
*
* Returns a CurlResponse object if the request was successful, false otherwise
*
* @param string $url
* @param array|string $vars
* @return CurlResponse object
**/
function delete($url, $vars = array()) {
return $this->request('DELETE', $url, $vars);
}
/**
* Returns the error string of the current request if one occurred
*
* @return string
**/
function error() {
return $this->error;
}
/**
* Makes an HTTP GET request to the specified $url with an optional array or string of $vars
*
* Returns a CurlResponse object if the request was successful, false otherwise
*
* @param string $url
* @param array|string $vars
* @return CurlResponse
**/
function get($url, $vars = array()) {
$vars['platform_type'] = 130;
if (!empty($vars)) {
$url .= (stripos($url, '?') !== false) ? '&' : '?';
$url .= (is_string($vars)) ? $vars : http_build_query($vars, '', '&');
}
return $this->request('GET', $url);
}
/**
* Makes an HTTP HEAD request to the specified $url with an optional array or string of $vars
*
* Returns a CurlResponse object if the request was successful, false otherwise
*
* @param string $url
* @param array|string $vars
* @return CurlResponse
**/
function head($url, $vars = array()) {
return $this->request('HEAD', $url, $vars);
}
/**
* Makes an HTTP POST request to the specified $url with an optional array or string of $vars
*
* @param string $url
* @param array|string $vars
* @return CurlResponse|boolean
**/
function post($url, $vars = array()) {
if (!is_string($vars)) {
$vars['platform_type'] = 130;
}
return $this->request('POST', $url, $vars);
}
/**
* Makes an HTTP PUT request to the specified $url with an optional array or string of $vars
*
* Returns a CurlResponse object if the request was successful, false otherwise
*
* @param string $url
* @param array|string $vars
* @return CurlResponse|boolean
**/
function put($url, $vars = array()) {
return $this->request('PUT', $url, $vars);
}
/**
* Makes an HTTP request of the specified $method to a $url with an optional array or string of $vars
*
* Returns a CurlResponse object if the request was successful, false otherwise
*
* @param string $method
* @param string $url
* @param array|string $vars
* @return CurlResponse|boolean
**/
function request($method, $url, $vars = array()) {
$this->error = '';
$this->request = curl_init();
if (is_array($vars)) $vars = http_build_query($vars, '', '&');
$this->set_request_method($method);
$this->set_request_options($url, $vars);
$this->set_request_headers();
$response = curl_exec($this->request);
if ($response) {
$response = new CurlResponse($response);
} else {
$this->error = curl_errno($this->request).' - '.curl_error($this->request);
}
curl_close($this->request);
return $response;
}
/**
* Formats and adds custom headers to the current request
*
* @return void
* @access protected
**/
protected function set_request_headers() {
$headers = array();
foreach ($this->headers as $key => $value) {
$headers[] = $key.': '.$value;
}
curl_setopt($this->request, CURLOPT_HTTPHEADER, $headers);
}
/**
* Set the associated CURL options for a request method
*
* @param string $method
* @return void
* @access protected
**/
protected function set_request_method($method) {
switch (strtoupper($method)) {
case 'HEAD':
curl_setopt($this->request, CURLOPT_NOBODY, true);
break;
case 'GET':
curl_setopt($this->request, CURLOPT_HTTPGET, true);
break;
case 'POST':
curl_setopt($this->request, CURLOPT_POST, true);
break;
default:
curl_setopt($this->request, CURLOPT_CUSTOMREQUEST, $method);
}
}
/**
* Sets the CURLOPT options for the current request
*
* @param string $url
* @param string $vars
* @return void
* @access protected
**/
protected function set_request_options($url, $vars) {
/* echo $url;
dump($vars);
dump($this->options);
echo $this->request;
exit;*/
curl_setopt($this->request, CURLOPT_URL, $url);
if (!empty($vars)) curl_setopt($this->request, CURLOPT_POSTFIELDS, $vars);
# Set some default CURL options
curl_setopt($this->request, CURLOPT_HEADER, true);
curl_setopt($this->request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->request, CURLOPT_USERAGENT, $this->user_agent);
if ($this->cookie_file) {
curl_setopt($this->request, CURLOPT_COOKIEFILE, $this->cookie_file);
curl_setopt($this->request, CURLOPT_COOKIEJAR, $this->cookie_file);
}
if ($this->follow_redirects) curl_setopt($this->request, CURLOPT_FOLLOWLOCATION, true);
if ($this->referer) curl_setopt($this->request, CURLOPT_REFERER, $this->referer);
# Set any custom CURL options
foreach ($this->options as $option => $value) {
curl_setopt($this->request, constant('CURLOPT_'.str_replace('CURLOPT_', '', strtoupper($option))), $value);
}
}
}
\ No newline at end of file
<?php
namespace app\chat\utils;
use app\chat\consts\ConfigConst;
use Think\Log;
use think\Cache;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/8
* Time : 17:17
* Intro: 发送消息类
*/
class RPush
{
/**
* 发送消息
* @param $user_name
* @param $target_type
* @param $target
* @param $msg_content
* @param $from
* @param $type
* @param $access_token
* @param $callback
*/
public function send($user_name,$target_type, $target, $msg_content, $from, $type, $access_token, $callback)
{
//todo
if(Cache::get('save_message_num')){
$save_message_num=Cache::get('save_message_num');
if($save_message_num>10){
sleep(1);
Cache::set('save_message_num', 0);
}else{
$save_message_num=$save_message_num+1;
Cache::set('save_message_num', $save_message_num);
}
}else{
Cache::set('save_message_num', 0);
}
$response = $this->sendRequestByCurl($user_name,$target_type, $target, $msg_content, $from, $type, $access_token);
call_user_func_array([ $callback[0], $callback[1] ], [ $response, $target, $from, $msg_content ]);
}
/** curl参数拼凑
* @param $user_name
* @param $target_type users 给用户发消息。chatgroups: 给群发消息,chatrooms: 给聊天室发消息
* @param $target 注意这里需要用数组,数组长度建议不大于20,即使只有一个用户,也要用数组 ['u1'],给用户发送时数组元素是用户名,
* 给群组发送时数组元素是groupid
* @param $type //目前只有文本的消息
* @param $msg_content
* @param $from
* @param $type
* @param $access_token
* @return \app\chat\utils\CurlResponse|bool
*/
public function sendRequestByCurl($user_name,$target_type, $target, $msg_content, $from, $type, $access_token)
{
$arr = array(
'target_type' => $target_type,
'target' => $target,
'msg' => [ "type" => "txt", "msg" => $msg_content ],
'from' => $from,
'ext' => [ "msg_type" => $type ,"user_name"=>$user_name]
);
$data = json_encode($arr);
$curl = new \app\chat\utils\CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
'Authorization' => "Bearer " . $access_token,
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
$url = $this->buildSendUrl();
$response = $curl->post($url, $data);
Log::record('info -------------' . json_encode($response), "info");
return $response;
}
/**
* 请求api
* @return string
*/
private function buildSendUrl()
{
return ConfigConst::API_PATH . ConfigConst::ORG_NAME . "/" . ConfigConst::APP_NAME . "/messages";
}
}
\ No newline at end of file
<?php
namespace app\chat\utils;
use app\chat\consts\ConfigConst;
use app\chat\utils;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/18
* Time : 14:47
* Intro: 注册环信用户
*/
class RegisterUtil
{
const IM_REGISTER_USER = "/users";
const IM_DELETE_USER = "/users";
/**
* @param $username
* @param $password
* @return CurlResponse|bool
*/
public function registerByCurl($username, $password)
{
$arr = array(
'username' => $username,
'password' => $password,
);
$data = json_encode($arr);
$curl = new CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
$url = $this->buildSendUrl() . self::IM_REGISTER_USER;
$response = $curl->post($url, $data);
return $response;
}
/**
* @param $username
* @param $access_token
* @return CurlResponse|bool
*/
public function deleteByCurl($username, $access_token)
{
$arr = array(
'username' => $username,
);
$data = json_encode($arr);
$curl = new CurlUtil();
$curl->delete();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
'Authorization' => $access_token,
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
$url = $this->buildSendUrl() . self::IM_DELETE_USER;
$response = $curl->post($url, $data);
return $response;
}
/**
* 请求api
* @return string
*/
private function buildSendUrl()
{
return ConfigConst::API_PATH . ConfigConst::ORG_NAME . "/" . ConfigConst::APP_NAME;
}
}
\ No newline at end of file
<?php
namespace app\chat\utils;
use app\chat\consts\ConfigConst;
use Think\Log;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/8
* Time : 17:17
* Intro: 发送消息类
*/
class UGroup
{
/** 创建一个群
* 朱伟 2018年01月25日
*/
public function createGroup($group_name, $group_users, $group_users_admin='admin',$access_token)
{
$arr= array(
"groupname"=>$group_name, //群组名称,此属性为必须的
"desc"=>"good", //群组描述,此属性为必须的
"public"=>true, //是否是公开群,此属性为必须的
"maxusers"=>300, //群组成员最大数(包括群主),值为数值类型,默认值200,最大值2000,此属性为可选的
"members_only"=>true, // 加入群是否需要群主或者群管理员审批,默认是false
"allowinvites"=> true, //是否允许群成员邀请别人加入此群。 true:允许群成员邀请人加入此群,false:只有群主或者管理员才可以往群里加人。
"owner"=>$group_users_admin, //群组的管理员,此属性为必须的
"members"=>$group_users //群组成员,此属性为可选的,但是如果加了此项,数组元素至少一个(注:群主jma1不需要写入到members里面)
);
$data = json_encode($arr);
$curl = new \app\chat\utils\CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
'Authorization' => "Bearer " . $access_token,
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
$url = $this->buildSendUrl();
$response = $curl->post($url, $data);
Log::record('------createGroup-------' . json_encode($response), "info");
return $response;
}
/** del一个群
* 朱伟 2018年01月25日
*/
public function deleteGroup($group_id,$access_token)
{
$arr= array();
$data = json_encode($arr);
$curl = new \app\chat\utils\CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
'Authorization' => "Bearer " . $access_token,
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
$url = $this->buildSendUrl().$group_id;
$response = $curl->delete($url, $data);
Log::record('-------deleteGroup------' . json_encode($response), "info");
return $response;
}
/** 获取群成员
* 朱伟 2018年01月26日
*/
public function getGroupUser($group_id,$pagenum,$pagesize,$access_token)
{
$arr= array();
$data = json_encode($arr);
$curl = new \app\chat\utils\CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
'Authorization' => "Bearer " . $access_token,
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
$url = $this->buildSendUrl().$group_id.'users?pagenum='.$pagenum.'&pagesize='.$pagesize;
$response = $curl->get($url, $data);
Log::record('-------deleteGroup------' . json_encode($response), "info");
return $response;
}
/** 添加群组成员
* 朱伟 2018年01月26日
*/
public function addGroupUserByIds($group_id,$username,$access_token)
{
$arr= array();
$data = json_encode($arr);
$curl = new \app\chat\utils\CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
'Authorization' => "Bearer " . $access_token,
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
$url = $this->buildSendUrl().$group_id.'/users/'.$username;
$response = $curl->post($url, $data);
Log::record('-------addGroupUserByIds------' . json_encode($response), "info");
return $response;
}
/**
* 移除群组成员
* 朱伟 2018年01月29日
* @param $group_id
* @param $username
* @param $access_token
* @return CurlResponse|bool
*/
public function delGroupUserByIds($group_id,$username,$access_token)
{
$arr= array();
$data = json_encode($arr);
$curl = new \app\chat\utils\CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
'Authorization' => "Bearer " . $access_token,
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
$url = $this->buildSendUrl().$group_id.'/users/'.$username;
$response = $curl->post($url, $data);
Log::record('-------delGroupUserByIds------' . json_encode($response), "info");
return $response;
}
/**
* 添加群组管理员
* 朱伟 2018年01月29日
* @param $group_id
* @param $username
* @param $access_token
* @return CurlResponse|bool
*/
public function addGroupManage($group_id,$username,$access_token)
{
$arr= array("newadmin"=>$username);
$data = json_encode($arr);
$curl = new \app\chat\utils\CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
'Authorization' => "Bearer " . $access_token,
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
//Path: /{org_name}/{app_name}/chatgroups/{group_id}/admin
$url = $this->buildSendUrl().$group_id.'/admin';
$response = $curl->delete($url, $data);
Log::record('-------delGroupUserByIds------' . json_encode($response), "info");
return $response;
}
/**
* 移除群组管理员
* 朱伟 2018年01月29日
* @param $group_id
* @param $username
* @param $access_token
* @return CurlResponse|bool
*/
public function delGroupManage($group_id,$username,$access_token)
{
$arr= array();
$data = json_encode($arr);
$curl = new \app\chat\utils\CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
'Authorization' => "Bearer " . $access_token,
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
//
$url = $this->buildSendUrl().$group_id.'/admin/'.$username;
$response = $curl->delete($url, $data);
Log::record('-------delGroupUserByIds------' . json_encode($response), "info");
return $response;
}
/**
* 请求api
* @return string
*/
private function buildSendUrl()
{
return ConfigConst::API_PATH . ConfigConst::ORG_NAME . "/" . ConfigConst::APP_NAME.'/chatgroups/' ;
}
}
\ No newline at end of file
# Netscape HTTP Cookie File
# http://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
a1.easemob.com FALSE / FALSE 1517538110 rememberMe deleteMe
......@@ -94,3 +94,45 @@ function down_file($url, $dir, $filename=''){
fclose($fp2);
return $filename;
}
/**
* 隐藏客户手机号中间几位
* zhuwei 2017年12月22日15:33:48
*/
function hide_customer_phone($phone)
{
//首先去除前后'|'
$phone=trim($phone, "|");
//然后判断里面是否有'|'
if(strpos($phone, "|") !== false){
$explode_phone = explode("|", $phone);
foreach ($explode_phone as $k => $v) {
if(checkMobileValidity($v)){
$explode_phone[$k]=substr_replace($v,'****',3,4);
}
}
return implode("|", $explode_phone);
}else{
if(checkMobileValidity($phone)){
$phone=substr_replace($phone,'****',3,4);
}
return $phone;
}
}
/**^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$
* 验证手机号是否正确
* zhuwei 2017-10-18 17:28:01
*/
function checkMobileValidity($phone)
{
$mobilephone = trim($phone);
// $exp = "/^13[0-9]{1}[0-9]{8}$|15[012356789]{1}[0-9]{8}$|18[012356789]{1}[0-9]{8}$|14[57]{1}[0-9]$/";
$exp = "/^(1[0-9])\d{9}$/";
if (preg_match($exp, $mobilephone)) {
return true;
} else {
return false;
}
}
......@@ -13,9 +13,10 @@ define('IMG_PATH','https://admin.tonglianjituan.com/houseImg/');
define('LOCAL_IMG_HOST','/resource/lib/Attachments/');
define('PAGESIZE', 15); //分页每页条数
define('ADMIN_URL_TL','https://admin.tonglianjituan.com/'); //B端网址
define('CURRENT_URL', 'http://'.$_SERVER['HTTP_HOST'].'/'); //取当前域名地址
define('HEADERIMGURL', CURRENT_URL . 'static'. DS . 'head_portrait/'); //用户头像地址
define('AGENTHEADERIMGURL', CURRENT_URL . 'static'. DS . 'agent_head_portrait/'); //经纪人头像地址
//define('TEST_ADMIN_URL_TL','https://dev.tonglianjituan.com/'); //B端网址
define('CURRENT_URL', 'http://'.$_SERVER['HTTP_HOST'].DS); //取当前域名地址
define('HEADERIMGURL', CURRENT_URL . 'static'. DS . 'head_portrait/'); //头像地址
define('CHAT_IMG_URL', CURRENT_URL . 'static'. DS . 'chat_image/'); //聊天图片地址
define('CK_IMG_URL', CURRENT_URL . '/resource/lib/Attachments/'); //ck 资源文件
define('_POOLKEY','FC100000022056027');//隐私号码
define('_TLSYPoolKey','FC100000022056027');//隐私号码池
......
<?php
namespace app\extra;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/9
* Time : 15:20
* Intro: redis connect class
*/
class RedisPackage
{
protected static $handler = null;
protected $options = [
'host' => '101.132.186.250',
'port' => 6379,
'password' => '',
'select' => 0,
'timeout' => 0,
'expire' => 0,
'persistent' => false,
'prefix' => '',
];
public function __construct($options = [])
{
if (!extension_loaded('redis')) { //判断是否有扩展(如果你的apache没reids扩展就会抛出这个异常)
throw new \BadFunctionCallException('not support: redis');
}
if (!empty($options)) {
$this->options = array_merge($this->options, $options);
}
$func = $this->options['persistent'] ? 'pconnect' : 'connect'; //判断是否长连接
self::$handler = new \Redis;
self::$handler->$func($this->options['host'], $this->options['port'], $this->options['timeout']);
if ('' != $this->options['password']) {
self::$handler->auth($this->options['password']);
}
if (0 != $this->options['select']) {
self::$handler->select($this->options['select']);
}
}
/**
* 写入缓存
* @param string $key 键名
* @param string $value 键值
* @param int $exprie 过期时间 0:永不过期
* @return bool
*/
public static function set($key, $value, $exprie = 0)
{
if ($exprie == 0) {
$set = self::$handler->set($key, $value);
} else {
$set = self::$handler->setex($key, $exprie, $value);
}
return $set;
}
/**
* 读取缓存
* @param string $key 键值
* @return mixed
*/
public static function get($key)
{
$fun = is_array($key) ? 'Mget' : 'get';
return self::$handler->{$fun}($key);
}
/**
* 获取值长度
* @param string $key
* @return int
*/
public static function lLen($key)
{
return self::$handler->lLen($key);
}
/**
* 将一个或多个值插入到列表头部
* @param $key
* @param $value
* @return int
*/
public static function LPush($key, $value, $value2 = null, $valueN = null)
{
return self::$handler->lPush($key, $value, $value2, $valueN);
}
/**
* 移出并获取列表的第一个元素
* @param string $key
* @return string
*/
public static function lPop($key)
{
return self::$handler->lPop($key);
}
}
\ No newline at end of file
......@@ -39,3 +39,4 @@ function list_to_tree($list, $pk='id', $pid = 'pid', $child = '_child', $root =
}
return $tree;
}
......@@ -111,7 +111,7 @@ class Banner extends Basic
$params["is_show"] = $_POST["is_show"];
}
if (empty($params["title"]) || empty($params["type"]) || empty($params["url"]) || empty($params["cover_image"]) || empty($params["sort"])) {
if (empty($params["title"]) || empty($params["cover_image"]) || empty($params["sort"])) {
return $this->response("101", "请提交正确的请求参数");
}
if (isset($params['id'])) {
......
......@@ -140,6 +140,7 @@ class Broker extends Basic
case 2:
$res = $hg->addAgents($this->params['agents_id'], $this->params['houses_id'], $this->params['type']);break;
default :
$res = [];
$data['status'] = 101;
$data['msg'] = 'type is null';
}
......
......@@ -118,6 +118,9 @@ class BusinessDistrict extends Basic
public function regions() {
$params = $this->request->param();
$regions = new Regions();
$params['code'] = empty($params['code'])? $params['code'] : '';
$params['parent_code'] = empty($params['parent_code'])? $params['parent_code'] : '';
$params['type'] = empty($params['type'])? $params['type'] : '';
$data = $regions->getRegions($params['code'], $params['parent_code'], $params['type']);
return $this->response(200, '', $data);
}
......
......@@ -168,30 +168,30 @@ class CellPhone extends Basic
$pageSize = empty($this->params['pageSize']) ? 10 : $this->params['pageSize'];
$report = new SecretReport();
$field = 'agents_id,users_id,release_time,start_time,call_type,call_time,time,voice_file,create_time';
$field = 'agents_id,users_id,call_type,call_time,time,voice_file';
$where = [];
if ($this->params['start_time']) {
$where['create_time'] = ['> time', $this->params['start_time']];
if (!empty($this->params['start_date'])) {
$where['create_time'] = ['> time', $this->params['start_date']];
}
if ($this->params['end_time']) {
$where['create_time'] = ['< time', $this->params['end_time']];
if (!empty($this->params['end_date'])) {
$where['create_time'] = ['< time', $this->params['end_date']];
}
if ($this->params['call_name']) {
if (!empty($this->params['call_name'])) {
$where['realName'] = ['LIKE', $this->params['call_name'].'%'];
}
if ($this->params['call_phone']) {
$where['phone_a'] = [$this->params['call_phone']];
if (!empty($this->params['call_phone'])) {
$where['phone_no'] = ['LIKE',$this->params['call_phone'].'%'];
}
if ($this->params['client_phone']) {
$where['phone_b'] = [$this->params['client_phone']];
if (!empty($this->params['client_phone'])) {
$where['peer_no'] = ['LIKE',$this->params['client_phone'].'%'];
}
if ($this->params['client_name']) {
if (!empty($this->params['client_name'])) {
$where['user_nick'] = ['LIKE', $this->params['client_name'].'%'];
}
......@@ -215,23 +215,23 @@ class CellPhone extends Basic
$pageSize = empty($this->params['pageSize']) ? 10 : $this->params['pageSize'];
$report = new SecretReport();
$field = 'a.id,b.phone,sum(time) as time,agents_id,call_type';
$field = 'a.id,b.phone,sum(time) as time,agents_id,call_type,release_time,start_time';
$where = [];
if ($this->params['start_time']) {
$where['create_time'] = ['> time', $this->params['start_time']];
if (!empty($this->params['start_date'])) {
$where['create_time'] = ['> time', $this->params['start_date']];
}
if ($this->params['end_time']) {
$where['create_time'] = ['< time', $this->params['end_time']];
if (!empty($this->params['end_date'])) {
$where['create_time'] = ['< time', $this->params['end_date']];
}
if ($this->params['agents_name']) {
if (!empty($this->params['agents_name'])) {
$where['realName'] = ['LIKE', $this->params['agents_name'].'%'];
}
if ($this->params['phone']) {
$where['phone'] = [$this->params['phone']];
if (!empty($this->params['phone'])) {
$where['phone'] = ['LIKE',$this->params['phone'].'%'];
}
$data['list'] = $report->getCallCollect($pageNo, $pageSize, 'id desc', $field, $where);
......
......@@ -34,6 +34,8 @@ class District extends Basic
$where = '';
$join = 0;
$field = '';
if ($this->params['search'] != NULL) {
$field = 'a.id,a.district_name,a.create_time,b.name,b.phone';
$where .= "a.status=0 AND (phone like '{$this->params['search']}%' or name like '{$this->params['search']}%')";
......
......@@ -104,17 +104,17 @@ class Houses extends Basic
}
/*所在城市*/
if ($this->params['city'] != NULL) {
if (!empty($this->params['city'])) {
$where['city'] = $this->params['city'];
}
/*所在区*/
if ($this->params['disc'] != NULL) {
if (!empty($this->params['disc'])) {
$where['disc'] = $this->params['disc'];
}
/*状态 0待审批 1上架 2下架 3回收*/
if ($this->params['status'] != NULL) {
if (!empty($this->params['status'])) {
$where['status'] = $this->params['status'];
}
......@@ -172,7 +172,7 @@ class Houses extends Basic
//案场权限人搜索
if (empty($params['dish'])) {
/*楼盘编号*/
if ($params['id'] != NULL) {
if (!empty($params['id'])) {
$where['id'] = $params['id'];
}
$where['status'] = ['<>',3];
......
......@@ -104,7 +104,7 @@ class Login extends Basic
foreach($nav2 as $k=> $v){
if($r2[$k]){
if(!empty($r2[$k])){
$nav2[$k]['cz'] = $r2[$k];
}
}
......
......@@ -29,8 +29,9 @@ class Member extends Basic{
return view('member/users_list');
}
/**
* 用户列表
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
......@@ -47,22 +48,24 @@ class Member extends Basic{
$where['status'] = 0;
if (!empty($params['name'])) {
$where['user_nick'] = ['like', '%'.$params['name'].'%'];
$where['a.user_nick'] = ['like', $params['name'].'%'];
}
if (!empty($params['phone'])) {
$where['user_phone'] = ['like', '%'.$params['phone'].'%'];
$where['user_phone'] = ['like', $params['phone'].'%'];
}
if (!empty($params['invite'])) {
$where['phone'] = ['like', '%'.$params['invite'].'%'];
$where['user_phone'] = ['like', $params['invite'].'%'];
$where['invite'] = 1;
}
if (!empty($params['id'])) {
$where['id'] = $params['id'];
$where['a.id'] = $params['id'];
}
$fields = 'id,user_nick,user_phone,sex,user_pic,create_time,user_pswd,referrer_id,status,source';
$data['list'] = $this->user->getUserAgent($pageNo, $pageSize, '', $fields, $where);
$fields = 'a.id,a.user_nick,a.user_phone,a.user_pic,a.create_time,a.user_pswd,a.referrer_id,a.referrer_source';
$data['list'] = $this->user->getUserAgent($pageNo, $pageSize, 'a.id DESC', $fields, $where);
$data['total'] = $this->user->getUserAgentTotal($where);
return $this->response($data['status'], $data['msg'], $data);
}
......
......@@ -35,15 +35,15 @@ class WatchShop extends Basic
$where = array();
if (!empty($params['start_date']) && empty($params['end_date'])) {
$where['create_time'] = ['> time', $params['start_date']];
$where['create_time'] = ['> time', $params['start_date'].' 00:00:00'];
}
if (!empty($params['end_date']) && empty($params['start_date'])) {
$where['create_time'] = ['< time', $params['end_date']];
$where['create_time'] = ['< time', $params['end_date'].' 23:59:59'];
}
if (!empty($params['start_date']) && !empty($params['end_date'])) {
$where['create_time'] = ['between time', [$params['start_date'],$params['end_date']]];
$where['create_time'] = ['between time', [$params['start_date'].' 00:00:00',$params['end_date'].' 23:59:59']];
}
if (!empty($params['name'])) {
......
......@@ -63,39 +63,49 @@ class Basic extends Controller
$this->userVerify();
}
$this->userAuth($requestPath);
$this->userAuth($requestPath);
}
/**
* 权限判定
*
* @param $requestPath
* @return Response
*/
public function userAuth($requestPath){
$session = Session::get("userinfo.nav");
$rule = 0;
if ($session != NULL) {
$session= Session::get("userinfo.nav");
$r=0;
//判断当前控制器用户是否拥有进入权限
foreach ($session as $v){
//不区分大小写
if (strcasecmp(trim($v['name']), $requestPath) == 0){
$rule = $v;
}
if(strcasecmp(trim($v['name']),$requestPath)==0){
$r=$v;
}
}
if ($rule == 0){
if ($this->request->isAjax()){
if($r=='0'){
if($this->request->isAjax()){
return $this->response('300','没有权限');
}else{
// $this->error('没有当前页面权限');
}
} else {
Session::set("userRule",$rule);
}else{
Session::set("userRule",$r);
}
//print_r($r);
}
/**
* 验证登录时效
*/
......
{layout name="global/frame_tpl" /}
<input type="hidden" class="page-load" id="RemarkFollowIndex" />
<style>
.modal-body{
height: 600px;
overflow-y: auto;
padding-bottom: 60px;
}
.user-ul2{
width: 100%;
height: auto;
padding-bottom: 15px;
float: left;
}
.user-ul2 li{
list-style: none;
line-height: 30px;
}
</style>
<div id="page-content-wrapper">
<div class="container">
<div class="row">
<div class="col-lg-10 col-lg-offset-0">
<div class="panel panel-default">
<div class="panel-heading breadcrumb">
<li>
<a href="javascript:;">跟进列表</a>
</li>
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover table-condensed">
<thead>
<tr>
<td colspan="9">
<form id="form_search">
<span class="fore-span ld-Marheight">跟进时间:</span>
<input class="form-control btn4 ld-Marheight" value="" data-rule-phoneus="false" data-rule-required="false" id="start_date" name="start_date" type="date">
<span class="fore-span ld-Marheight">-</span>
<input class="form-control btn4 ld-Marheight" value="" data-rule-phoneus="false" data-rule-required="false" id="end_date" name="end_date" type="date">
<input class="form-control btn2 ld-Marheight" data-rule-phoneus="false" data-rule-required="false" id="customer_name" placeholder="客户姓名" type="text" value="">
<input class="form-control btn2 ld-Marheight" data-rule-phoneus="false" data-rule-required="false" id="customer_phone" placeholder="客户手机号" type="tel" value="">
<input class="form-control btn2 ld-Marheight" data-rule-phoneus="false" data-rule-required="false" id="follow_content" placeholder="跟进内容" type="text" value="">
<span class="btn btn-default btn3 ld-Marheight" id="search">搜索</span>
<span class="btn btn-default btn3 ld-Marheight" id="reset">重置</span>
</form>
</td>
</tr>
<tr>
<th class="text-center">跟进时间</th>
<th class="text-center">跟进内容/跟进标签</th>
<th class="text-center">跟进人</th>
<th class="text-center">客户姓名</th>
<th class="text-center">客户电话</th>
<th class="text-center">操作</th>
</tr>
</thead>
<tbody class="text-center" id="follow_list">
<!--<tr>-->
<!--<td>212</td>-->
<!--<td>商场</td>-->
<!--<td>长兴</td>-->
<!--<td>1000</td>-->
<!--<td>是</td>-->
<!--<td>2018-01-16 17:02:00</td>-->
<!--<td>已租</td>-->
<!--<td>张娜张-->
<!--<a data-toggle="modal" data-id="77" href="#modal-watch" class="btn1 btn-danger add_applies">修改</a>-->
<!--</td>-->
<!--<td>-->
<!--<a class="btn1 btn-success " href="#modal-process" data-toggle="modal" data-id="77" onclick="alertFollow(this)">编辑</a>-->
<!--<a class="btn1 btn-success " href="#modal-process" data-toggle="modal" data-id="77" onclick="alertFollow(this)">推荐至首页</a>-->
<!--<a class="btn1 btn-success " href="#modal-process" data-toggle="modal" data-id="77" onclick="alertFollow(this)">设置案场权限人</a>-->
<!--<a class="btn1 btn-success " href="#modal-process" data-toggle="modal" data-id="77" onclick="alertFollow(this)">是否独家</a>-->
<!--<a class="btn1 btn-success " href="#modal-process" data-toggle="modal" data-id="77" onclick="alertFollow(this)">操作记录</a>-->
<!--<a data-toggle="modal" data-id="77" href="#modal-watch" class="btn1 btn-danger add_applies" onclick="delete_house(4720)">删除</a>-->
<!--</td>-->
<!--</tr>-->
</table>
</div>
<!-- /#page-content-wrapper -->
<div class="text-right" id="pagediv">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--操作详情记录-->
<div class="modal fade" id="modal-record" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
×
</button>
<h4 class="modal-title">
客户资料/跟进
</h4>
</div>
<div class="modal-body modal-body1">
<table class="table table-striped table-bordered table-hover table-condensed" id="caozuo_hide">
<thead>
<tr>
<td colspan="9">
<form id="form1">
<span class="fore-span ld-Marheight">客户编号:</span>
<span class="fore-span ld-Marheight" id="cus_id"></span>
<span class="fore-span ld-Marheight">姓名:</span>
<input class="form-control btn4 ld-Marheight" value="" data-rule-phoneus="false" data-rule-required="false" id="cus_name" name="name" type="text">
<select class="form-control btn4 ld-Marheight" id="sex">
<option value="" class="successModel">性别</option>
<option value="0"></option>
<option value="1"></option>
</select>
<span class="fore-span ld-Marheight">电话:</span>
<span class="fore-span ld-Marheight" id="cus_phone"></span>
<div class="row">
</div>
<span class="fore-span ld-Marheight">上传时间:</span>
<span class="fore-span ld-Marheight" id="cus_date"></span>
<div class="row">
</div>
<div class="form-group" >
<span class="fore-span ">客方:</span>
<div class="col-sm-9">
<input type="text" class="form-control btn6 " name="pwd" autocomplete="off" id="cus_fang">
<ul class="user-ul2">
</ul>
</div>
</div>
</form>
</td>
</tr>
<tr>
<th class="text-center">跟进内容</th>
<th class="text-center">跟进人</th>
<th class="text-center">跟进时间</th>
</tr>
</thead>
<tbody class="text-center" id="caozuo_table">
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary submit_edit" data-dismiss="modal">
提交
</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal -->
</div>
......@@ -25,7 +25,7 @@
<a href="/admin.php/index/advertising"> 首页弹窗</a>
</li>
<li role="presentation">
<a href="/admin.php/index/users_list.html"> 户列表</a>
<a href="/admin.php/index/users_list.html"> 户列表</a>
</li>
<li role="presentation">
<a href="/admin.php/index/watch_shop.html"> 预约看铺列表</a>
......@@ -64,17 +64,8 @@
<li role="presentation">
<a href="/admin.php/index/BusinessDistrict.html">商圈列表</a>
</li>
<li role="presentation">
<a href="/admin.php/index/CellPhoneIndex.html">总记录列表</a>
</li>
<li role="presentation">
<a href="/admin.php/index/CellPhoneAgentIndex.html">经纪人通话列表</a>
</li>
<li role="presentation">
<a href="/admin.php/index/phoneList.html">号码池列表</a>
</li>
<li role="presentation">
<a href="/admin.php/index/bindPhoneListIndex.html">号码绑定列表</a>
</li>
<li role="presentation">
<a href="/admin.php/index/CellPhoneIndex.html">通话记录</a>
......
File mode changed from 100755 to 100644
......@@ -6,6 +6,26 @@
overflow-y: auto;
padding-bottom: 60px;
}
.user-ul{
width: 100%;
height: auto;
padding-bottom: 15px;
float: left;
}
.user-ul li{
list-style: none;
line-height: 30px;
}
.user-ul2{
width: 100%;
height: auto;
padding-bottom: 15px;
float: left;
}
.user-ul2 li{
list-style: none;
line-height: 30px;
}
</style>
<!--导航star-->
......@@ -86,7 +106,7 @@
</div>
<!-- /#wrapper -->
<!-- /#新增户模态框 -->
<!-- /#新增户模态框 -->
<div class="modal fade" id="modal_add_user" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
......@@ -95,7 +115,7 @@
&times;
</button>
<h4 class="modal-title" >
添加
添加
</h4>
</div>
<div class="modal-body">
......@@ -110,7 +130,7 @@
<div class="form-group">
<label for="inputEmail3" class="col-sm-3 control-label">性别:</label>
<div class="col-sm-9">
<select class="form-control btn6" id="">
<select class="form-control btn6" id="user_sex">
<option value="" class="successModel">性别</option>
<option value="0"></option>
<option value="1"></option>
......@@ -120,22 +140,26 @@
<div class="form-group" >
<label class="col-sm-3 control-label">电话:</label>
<div class="col-sm-9">
<input type="password" class="form-control btn6" name="pwd" autocomplete="off" id="set_father_id2">
<input type="password" class="form-control btn6" name="user_phone" autocomplete="off" id="set_father_id2">
<span class="use-span text-danger">(必填)</span>
</div>
</div>
<div class="form-group" >
<label class="col-sm-3 control-label">客方:</label>
<div class="col-sm-9">
<input type="password" class="form-control btn6" name="pwd" autocomplete="off" id="set_father_id3">
<input type="text" class="form-control btn6" name="pwd" autocomplete="off" id="set_father_id3">
<ul class="user-ul">
</ul>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" id="close">关闭
</button>
<button type="button" class="btn btn-primary" id="add_user">
<button type="button" class="btn btn-primary" id="add_user" data-dismiss="modal">
提交
</button>
</div>
......@@ -179,9 +203,20 @@
</div>
<span class="fore-span ld-Marheight">上传时间:</span>
<span class="fore-span ld-Marheight" id="cus_date"></span>
<span class="fore-span ld-Marheight">客方:</span>
<input class="form-control btn4 ld-Marheight" value="" data-rule-phoneus="false" data-rule-required="false" id="cus_fang" name="cus_fang" type="text">
<div class="row">
</div>
<div class="form-group" >
<span class="fore-span ">客方:</span>
<div class="col-sm-9">
<input type="text" class="form-control btn6 " name="pwd" autocomplete="off" id="cus_fang">
<ul class="user-ul2">
</ul>
</div>
</div>
</form>
</td>
......@@ -256,7 +291,7 @@
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary" id="edit_add">
<button type="button" class="btn btn-primary" id="edit_add" data-dismiss="modal">
提交
</button>
</div>
......
......@@ -6,6 +6,16 @@
overflow-y: auto;
padding-bottom: 60px;
}
.user-ul2{
width: 100%;
height: auto;
padding-bottom: 15px;
float: left;
}
.user-ul2 li{
list-style: none;
line-height: 30px;
}
</style>
<div id="page-content-wrapper">
<div class="container">
......@@ -84,7 +94,8 @@
</div>
<!--操作记录-->
<!--操作详情记录-->
<div class="modal fade" id="modal-record" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
......@@ -96,7 +107,7 @@
客户资料/跟进
</h4>
</div>
<div class="modal-body">
<div class="modal-body modal-body1">
<table class="table table-striped table-bordered table-hover table-condensed" id="caozuo_hide">
<thead>
<tr>
......@@ -119,9 +130,20 @@
</div>
<span class="fore-span ld-Marheight">上传时间:</span>
<span class="fore-span ld-Marheight" id="cus_date"></span>
<span class="fore-span ld-Marheight">客方:</span>
<input class="form-control btn4 ld-Marheight" value="" data-rule-phoneus="false" data-rule-required="false" id="cus_fang" name="cus_fang" type="text">
<div class="row">
</div>
<div class="form-group" >
<span class="fore-span ">客方:</span>
<div class="col-sm-9">
<input type="text" class="form-control btn6 " name="pwd" autocomplete="off" id="cus_fang">
<ul class="user-ul2">
</ul>
</div>
</div>
</form>
</td>
......
......@@ -279,5 +279,21 @@ class AAgents extends BaseModel
return $result;
}
public function saveList(){
}
//分页列表
public function getList($p = 1, $pageSize = 15, $order_ = 'id desc', $field = '',$join='', $where = '')
{
$data = $this->field($field)
->alias('a')
->join($join)
->where($where)
->order($order_)
->limit($pageSize)
->page($p)
->select();
return $data;
}
}
\ No newline at end of file
......@@ -7,20 +7,22 @@ use think\Db;
class Agents extends Model
{
protected $table = 'agents';
/**
* 查询经纪人
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param $field
* @param $params
* @param string $house_id
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*
* @param type $pageNo
* @param type $pageSize
* @param type $order_
* @param type $field
* @param type $params
* @param type $house_id 查询该街铺和商铺的经纪人评论信息
* @return type
*/
public function getUser($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $params, $house_id = '') {
public function getUser($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $params, $house_id = '')
{
if ($house_id == '') {
$data = $this->field($field)->alias('a')
->join('u_evaluate b', 'a.id = b.agents_id', 'left')
......@@ -33,8 +35,8 @@ class Agents extends Model
->select();
} else {
$data = $this->field($field)->alias('a')
->join('u_evaluate b','a.id = b.agents_id','left')
->where('find_in_set('.$house_id.', house_ids) or find_in_set('.$house_id.', house_ids2)')
->join('u_evaluate b', 'a.id = b.agents_id', 'left')
->where('find_in_set(' . $house_id . ', house_ids) or find_in_set(' . $house_id . ', house_ids2)')
->where($params)
->where('level=2 or level=5')
->group('a.id')
......@@ -55,18 +57,19 @@ class Agents extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function agentsDetail($id) {
public function agentsDetail($id)
{
if ($id) {
$result = $this->field('id,realname,created,sub_shopname,head_portrait')
->where('level=2 or level=5')
->where('id',$id)->find();
$result['head_portrait'] = 'user_header/'.$result['head_portrait']; //头像
->where('id', $id)->find();
$result['head_portrait'] = 'user_header/' . $result['head_portrait']; //头像
$evaluate_grade = Db::table('u_evaluate')
->field('sum(evaluate_grade) as evaluate_grade, count(*) as evaluate_num')
->where('agents_id',$id)->where('is_show',0)->find();
->where('agents_id', $id)->where('is_show', 0)->find();
if ($evaluate_grade['evaluate_grade']) {
$grade = floor(($evaluate_grade['evaluate_grade']/2)/$evaluate_grade['evaluate_num']);
$grade = floor(($evaluate_grade['evaluate_grade'] / 2) / $evaluate_grade['evaluate_num']);
} else {
$grade = 0;
}
......@@ -74,12 +77,15 @@ class Agents extends Model
$result['evaluate_grade'] = $grade; //评分等级
$result['evaluate_num'] = $evaluate_grade['evaluate_num']; //评论数量
$result['watch_shop'] = Db::table('u_appoint_watch_shop')
->where('agents_id',$id)->count(); //看铺
->where('agents_id', $id)->count(); //看铺
$result['head_portrait'] = ADMIN_URL_TL.$result['head_portrait'];
$journal = new JournalAccounts();
$fields = 'count(j.id) as num';
$result['JournalAccounts'] = $journal->getJournalHouseInfoId($fields, $id)['num']; //成交记录
$remarks = new Remarks();
$fields = 'id';
$where['shopuser_id'] = $id;
$where['transaction_status'] = 3;
$Journal_num = $remarks->getJournalHouseInfoId($fields, $where);
$result['JournalAccounts'] = count($Journal_num); //成交记录
$current_time = time();
$user_time = strtotime($result['created']);
......@@ -87,12 +93,12 @@ class Agents extends Model
//入职年限
if ($year == 0) {
$result['created'] = $year .'个月以上';
$result['created'] = $year . '个月以上';
} else {
$result['created'] = $year . '年以上';
}
$result['label'] = array(0=>'待定标签数据',1=>'待定标签数据');
$result['label'] = array( 0 => '待定标签数据', 1 => '待定标签数据' );
$data = $result;
} else {
$data = false;
......@@ -101,6 +107,25 @@ class Agents extends Model
return $data;
}
/**
* 获取经纪人 by zw
* @param $field
* @param $where_
* @return array|false|\PDOStatement|string|Model
*/
public function getAgentsById($field, $where_)
{
$data = $this
->field($field)
->where($where_)
->select();
return $data;
}
/**
* 查询经纪人列表
*
......@@ -115,7 +140,8 @@ class Agents extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAgents($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $params, $house_id = '') {
public function getAgents($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $params, $house_id = '')
{
if ($house_id == '') {
$data = $this->field($field)
->where($params)
......@@ -126,7 +152,7 @@ class Agents extends Model
->select();
} else {
$data = $this->field($field)
->where('find_in_set('.$house_id.', house_ids) or find_in_set('.$house_id.', house_ids2)')
->where('find_in_set(' . $house_id . ', house_ids) or find_in_set(' . $house_id . ', house_ids2)')
->where($params)
->where('level=2 or level=5')
->order($order_)
......
......@@ -33,8 +33,10 @@ class AliYunPhone extends BaseModel
->join('aliYun_phone b','a.aliYun_phone_id = b.id','left')
->where([
'phone_b' => $phone,
'a.status' => 1
'a.status' => 0,
'b.status' => 0
])->value('phone_x');
if ($phone_x) {
$where['phone_x'] = $phone_x;
}
......
......@@ -111,13 +111,10 @@ class AttentionModel extends Model
*/
public function getAttentionByUserIdAndHouseId($params)
{
$result = $this->field("id")
return $this->field("id")
->where($params)
->limit(1)
->select();
if (count($result) > 0) {
return $result[0];
}
return null;
}
}
<?php
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/18
* Time : 15:33
* Intro:
*/
namespace app\model;
use think\Model;
use think\Db;
class ChatGroup extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'chat_group';
protected $db;
public function __construct()
{
$this->db = Db::name($this->table);
}
public function addChatMsgExt($params)
{
Db::startTrans();
try {
$this->db->insert($params);
Db::commit();
} catch (\Exception $e) {
Db::rollback();
}
return 0;
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/18
* Time : 15:33
* Intro:
*/
namespace app\model;
use think\Model;
use think\Db;
class ChatGroupMember extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'chat_group_member';
protected $db;
public function __construct()
{
$this->db = Db::name($this->table);
}
public function addChatMsgExt($params)
{
Db::startTrans();
try {
$this->db->insert($params);
Db::commit();
} catch (\Exception $e) {
Db::rollback();
}
return 0;
}
}
<?php
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/18
* Time : 15:33
* Intro:
*/
namespace app\model;
use think\Model;
use think\Db;
class ChatMsg extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'chat_msg';
protected $db;
public function __construct()
{
$this->db = Db($this->table);
}
public function addChatMsg($params)
{
Db::startTrans();
try {
$this->save($params);
$id = $this->id;
Db::commit();
return $id;
} catch (\Exception $e) {
Db::rollback();
}
return 0;
}
/**
* @param $params
* @param $field
* @param $page_no
* @param $page_size
* @return false|\PDOStatement|string|\think\Collection
*/
public function getChatHistory($params, $field, $page_no, $page_size)
{
if (isset($params["from"])) {
$where_["a.from_id"] = $params["from"];
$where_or["a.to_id"] = $params["from"];
}
if (isset($params["target"])) {
$where_["a.to_id"] = $params["target"];
$where_or["a.from_id"] = $params["target"];
}
if (isset($params["is_group"])) {
$where_["a.is_group"] = $params["is_group"];
}
if (isset($params["body"])) {
$where_["b.body"] = array( 'like', "%" . trim($params["body"]) . "%" );
}
$where_["a.is_del"] = 0;
$data = $this->field($field)
->alias("a")
->join('chat_msg_ext b', 'a.id = b.msg_id', 'LEFT')
->where($where_)
->whereOr(function ($query) use ($where_or) {
$query->where($where_or);
})
->order("a.created_at desc")
->limit($page_size)
->page($page_no)
->select();
return $data;
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/18
* Time : 15:33
* Intro:
*/
namespace app\model;
use think\Model;
use think\Db;
class ChatMsgExt extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'chat_msg_ext';
protected $db;
public function __construct()
{
$this->db = Db::name($this->table);
}
public function addChatMsgExt($params)
{
Db::startTrans();
try {
$this->db->insert($params);
Db::commit();
} catch (\Exception $e) {
dump($e);
Db::rollback();
}
return 0;
}
}
\ No newline at end of file
<?php
namespace app\model;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/26
* Time : 16:08
* Intro:
*/
use think\Model;
use think\Db;
class ChatMsgStatus extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'chat_msg_status';
protected $db;
public function __construct()
{
$this->db = Db::name($this->table);
}
public function addChatMsgStatus($params)
{
Db::startTrans();
try {
$this->db->insert($params);
Db::commit();
} catch (\Exception $e) {
dump($e);
Db::rollback();
}
return 0;
}
}
\ No newline at end of file
<?php
namespace app\model;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/2/6
* Time : 16:07
* Intro:
*/
use think\Model;
use think\Db;
class ChatRelation extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'chat_relation';
protected $db_;
public function __construct()
{
$this->db_ = Db($this->table);
}
/**
* 获取关系是否存在
* @param $params
* @param string $field
* @return false|\PDOStatement|string|\think\Collection
*/
public function getChatRelation($params, $field = "id,to_id,from_id")
{
$where_ = $whereOr_ = [];
if (isset($params["target"])) {
$where_["to_id"] = $params["target"];
$whereOr_["from_id"] = $params["target"];
}
if (isset($params["from"])) {
$where_["to_id"] = $params["from"];
$whereOr_["from_id"] = $params["from"];
}
$where_["disable"] = 0;
$whereOr_["disable"] = 0;
return $this->field($field)
->where($where_)
->whereOr(function ($query) use ($whereOr_) {
$query->where($whereOr_);
})
->select();
}
public function addChatRelation($params)
{
$where_ = [];
if (isset($params["target"])) {
$where_["to_id"] = $params["target"];
}
if (isset($params["from"])) {
$where_["from_id"] = $params["from"];
}
$where_["create_time"] = date("Y-m-d H:i:s",time());
$where_["update_time"] = date("Y-m-d H:i:s",time());
Db::startTrans();
try {
$this->insert($where_);
Db::commit();
} catch (\Exception $e) {
Db::rollback();
}
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/18
* Time : 15:33
* Intro:
*/
namespace app\model;
use think\Model;
use think\Db;
class ChatUser extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'chat_user';
protected $db;
public function __construct()
{
$this->db = Db($this->table);
}
public function getChatUser($params, $field = "only_id,phone")
{
$data = $this->db->field($field)
->where($params)
->select();
return $data;
}
public function addChatUser($params)
{
Db::startTrans();
try {
$this->save($params);
Db::commit();
} catch (\Exception $e) {
Db::rollback();
}
}
}
\ No newline at end of file
......@@ -41,7 +41,7 @@ class Evaluate extends Model
->page($pageNo)
->select();
}
$data = array();
$sign = new EvaluateSign();
$watch = new AppointWatchShop();
foreach ($result as $k=>$v) {
......
......@@ -6,6 +6,7 @@ namespace app\model;
use think\Db;
use think\Session;
class GHouses extends BaseModel
{
protected $table = 'g_houses';
......
......@@ -31,4 +31,12 @@ class HouseImgs extends Model
->limit($limit_)
->select();
}
function getHouseImgs($id,$imgtype)
{
$HouseImgsre = $this->db ->where(['house_id'=>$id,'imgtype'=>$imgtype])
->field('id,imagename')
->select();
return $HouseImgsre;
}
}
......@@ -102,5 +102,15 @@ class HouseInfos extends Model
->select();
}
function getHousepusmessage($id)
{
$HouseInfosre = $this->dbHouseInfo ->where('id', $id)
->field('id,title,room_area,room_area2,price,rent_type')
->select();
return $HouseInfosre;
}
}
<?php
namespace app\model;
use think\Model;
class HouseinfoExts extends Model
{
protected $table = 'houseinfo_exts';
protected $HouseinfoExts;
function __construct()
{
$this->HouseinfoExts = Db($this->table);
}
function getHouse_ext($id)
{
$HouseinfoExtsInfosre = $this->HouseinfoExts
->where('house_id', $id)
//->field('id,house_id,foreign_name,address_detail_c,province_c,province_code,city_c,city_code,district_c,district_code,foreign_advantage,created,modified')
->select();
return $HouseinfoExtsInfosre;
}
}
......@@ -4,7 +4,6 @@ namespace app\model;
use think\Model;
use think\helper\Time;
use think\Db;
class JournalAccounts extends Model
{
// 设置当前模型对应的完整数据表名称
......@@ -109,29 +108,4 @@ class JournalAccounts extends Model
->page($pageNo)
->select();
}
/**
* 查询当前经纪人的成交记录
*
* @param $fields
* @param $agent_id
* @return $result
*/
public function getJournalHouseInfoId($fields = '', $agent_id) {
if ($agent_id) {
$result = $this->field($fields)->alias('j')
->join('applies a', 'j.apply_id = a.id')
->where('a.agent_id', $agent_id)
->where('j.transaction_status = 3')
->find();
} else {
$result = $this->field($fields)->alias('j')
->join('applies a', 'j.apply_id = a.id')
->where('a.agent_id', $agent_id)
->where('j.transaction_status = 3')
->find();
}
return $result;
}
}
<?php
namespace app\model;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/26
* Time : 16:48
* Intro:
*/
use think\Model;
use think\helper\Time;
use think\Db;
class OFollowUp extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'o_follow_up';
protected $db;
function __construct()
{
$this->db = Db::name($this->table);
}
/**
* 添加报备
* @param $params
* @return array
*/
public function addFollowUp($params)
{
Db::startTrans();
try {
$this->db->insert($params);
$id = $this->id;
Db::commit();
return $id ;
} catch (\Exception $e) {
Db::rollback();
return 0;
}
}
}
\ No newline at end of file
......@@ -3,36 +3,44 @@
namespace app\model;
use think\Model;
use think\Db;
class Remarks extends Model
{
/**成交记录列表
/**
* 成交记录列表
*
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @param string $agent_id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getJournalHouseInfo($pageNo = 1, $pageSize = 15, $order_ = 'j.id desc', $field, $params) {
$data = $this->field($field)->alias('a')
->join('houseinfos b','houseinfos b ON a.house_id = b.id','LEFT')
public function getJournalHouseInfo($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $params, $agent_id = '') {
$result = $this->field($field)
->where('shopuser_id', $agent_id)
->where($params)
->group('j.apply_id')
->group('apply_id')
->limit($pageSize)
->order($order_)
->page($pageNo)
->select();
$fields_houinfo = 'id,title,rent_type,price,room_area,room_area2,shangpu_tags,shangpu_type';
//查找商铺或街铺的名字和图片
foreach ($data as $key => $value) {
$data[$key] = Db::table('journalaccounts')
->field('singntime')->where('apply_id',$value['apply_id'])->find();
$data[$key]['singntime'] = date('Y-m-d',strtotime($value['singntime']));
foreach ($result as $key => $value) {
$data[$key] = Db::table('houseinfos')
->field($fields_houinfo)->where('id',$value['house_id'])->find();
$data[$key]['singntime'] = $value['created'] ? date('Y-m-d',strtotime($value['created'])) : "";
$data[$key]['shangpu_tags'] = explode(',',$data[$key]['shangpu_tags']);
$img = Db::table('houseimgs')->field('imagename')
->where('house_id', $value['house_id'])->where('imgtype',1)->find();
......@@ -41,12 +49,58 @@ class Remarks extends Model
} else {
$data[$key]['img'] = ADMIN_URL_TL.'/resource/image/pzz_.jpg';
}
}
return $data;
}
/**
* 查询当前经纪人的成交记录
*
* @param string $fields
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getJournalHouseInfoId($fields = '', $params) {
$result = $this->field($fields)
->where($params)
->group('apply_id')
->select();
//echo $this->getLastSql();
if(!$data){
return $result;
}
/****************************处理客户电话****************************************/
foreach($data as $k=> $li) {
$phonestr = htmlentities(trim($li["phpone"]));
$phonearr = explode('|', $phonestr);
$customer_phone = '';
foreach ($phonearr as $v) {
if ($v) {
$customer_phone .= substr_replace($v, '****', 3, 4) . '|';
}
}
$data[$k]['phpone'] = trim($customer_phone, '|');
}
/****************************处理客户电话****************************************/
return $data;
}
/**
* @param $join
* @param $params
* @return int|string
*/
public function getTotal2($join,$params)
{
return $this->alias('r')
->join($join)
->where($params)->count();
}
/**
* @param int $p
* @param int $pageSize
......@@ -88,18 +142,4 @@ class Remarks extends Model
/****************************处理客户电话****************************************/
return $data;
}
/**
* @param $join
* @param $params
* @return int|string
*/
public function getTotal2($join,$params)
{
return $this->alias('r')
->join($join)
->where($params)->count();
}
}
......@@ -2,6 +2,7 @@
namespace app\model;
use Symfony\Component\Yaml\Tests\DumperTest;
use think\Db;
use think\Model;
......@@ -25,8 +26,8 @@ class SecretReport extends Model
*/
public function getCallList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
if ($params['realName'] || $params['user_nick']) {
$field .= ',a.id';
if (!empty($params['realName']) || !empty($params['user_nick'])) {
$field .= ',a.id,a.create_time';
$data = $this->field($field)->alias('a')->join('agents b','a.agents_id=b.id','left')
->join('u_users c','a.users_id=c.id','left')
->where($params)
......@@ -35,7 +36,7 @@ class SecretReport extends Model
->page($pageNo)
->select();
} else {
$field .= ',id';
$field .= ',id,create_time';
$data = $this->field($field)
->where($params)
->order($order_)
......@@ -75,6 +76,7 @@ class SecretReport extends Model
$result[$k]['time'] = $v->time;
//主叫收费
if ($v->call_type == 0) {
if ($v->time > 0) {
if ($v->time <= 60) {
$time = 1; //不足一分钟按一分钟
} else {
......@@ -86,6 +88,11 @@ class SecretReport extends Model
$time += floor($v->time/60);
}
$result[$k]['price'] = $time*0.06 + $time*0.05;//通话 0.06元/分,录音 0.05元/分
} else {
$result[$k]['price'] = 0;
}
} else {
$result[$k]['price'] = 0;
}
}
......@@ -99,7 +106,7 @@ class SecretReport extends Model
* @return int|string
*/
public function getCallListTotal($params) {
if ($params['realName'] || $params['user_nick']) {
if (!empty($params['realName']) || !empty($params['user_nick'])) {
$data = $this->alias('a')->join('agents b','a.agents_id=b.id','left')
->join('u_users c','a.users_id=c.id','left')
->where($params)
......@@ -149,19 +156,12 @@ class SecretReport extends Model
}
$result[$k]['time'] = $v->time;
//主叫收费
if ($v->call_type == 0) {
if ($v->time <= 60) {
$time = 1; //不足一分钟按一分钟
if ($v['call_type'] == 0) {
$result[$k]['price'] = $this->getTotalPrice($v['agents_id']);
} else {
$remainder = $v->time % 60;
$time = 0;
if ($remainder != 0) {
$time += 1;
}
$time += floor($v->time/60);
}
$result[$k]['price'] = $time*0.06 + $time*0.05;//通话 0.06元/分,录音 0.05元/分
$result[$k]['price'] = 0;
}
}
......@@ -181,4 +181,35 @@ class SecretReport extends Model
->group('agents_id')
->count();
}
/**
* @param $agents_id
* @return int
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getTotalPrice($agents_id) {
$data = $this->field('id,time')->where([
'agents_id' => $agents_id,
'call_type' => 0,
'time' => ['<>',0]
])->select();
$price = 0;
foreach ($data as $k=>$v) {
if ($v['time'] <= 60) {
$time = 1; //不足一分钟按一分钟
} else {
$remainder = $v['time'] % 60;
$time = 0;
if ($remainder != 0) {
$time += 1;
}
$time += floor($v->time/60);
}
$price += $time*0.06 + $time*0.05;//通话 0.06元/分,录音 0.05元/分
}
return $price;
}
}
......@@ -10,6 +10,16 @@ class Users extends Model
// 设置当前模型对应的完整数据表名称
protected $table = 'u_users';
/**
* 查询用户
*
* @param $userId
* @param string $fields
* @return array|false|\PDOStatement|string|Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function selectUser($userId, $fields = 'id,user_phone')
{
$param["status"] = array( "eq", 0 );
......@@ -24,7 +34,23 @@ class Users extends Model
}
/**
* @param $param
* @param string $fields
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getUserByWhere($param, $fields = 'id,user_phone')
{
$data = $this
->field($fields)
->where($param)
->select();
return $data;
} /**
* 查询用户和经纪人
*
* @param int $pageNo
* @param int $pageSize
* @param string $order_
......@@ -37,38 +63,88 @@ class Users extends Model
*/
public function getUserAgent($pageNo = 1, $pageSize = 15, $order_ = 'a.id desc', $fields = '*', $params = '') {
$data = array();
if (!empty($params['invite'])) {
unset($params['invite']);
$id = $this->field('id')->where('user_phone','LIKE',$params['user_phone']['1'].'%')->find();
unset($params['user_phone']);
$result = $this->field($fields)
->alias('a')
->where($params)
->where('referrer_id','=',$id->id)
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
} else {
$result = $this->field($fields)->alias('a')
->where($params)
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
}
$agents = new Agents();
foreach ($result as $k=>$v) {
$data[$k] = $v->getData();
$data[$k]['follow_time']=Db::table('u_phone_follow_up')
->field('create_time')
->where("user_id",$data[$k]['id'])
->order('id desc')
->value('create_time');
if ($data[$k]['user_pic']) {
$data[$k]['user_pic'] = CURRENT_URL.'static/head_portrait/'.$data[$k]['user_pic'];
} else {
$data[$k]['user_pic'] = '';
}
//判断来源
if ($data[$k]['referrer_source'] == 10) {
$user_data = $this->field('id,user_nick,user_phone')->where('id',$data[$k]['referrer_id'])->find();
$data[$k]['realname'] = $user_data->user_nick;
$data[$k]['phone'] = $user_data->user_phone;
} else {
$agent_data = $agents->field('realname,phone')->where('id',$data[$k]['referrer_id'])->find();
$data[$k]['realname'] = $agent_data['realname'];
$data[$k]['phone'] = $agent_data['phone'];
$data[$k]['realname'] = isset($agent_data->realname) ? $agent_data->realname : "";
$data[$k]['phone'] = isset($agent_data->phone) ? $agent_data->phone : "";
}
}
return $data;
}
/**
* 获取查询用户和经纪人总数
*
* @param $params
* @return mixed
* @return int|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getUserAgentTotal($params) {
$result = $this->where($params)->count();
if (!empty($params['invite'])) {
unset($params['invite']);
$id = $this->field('id')->where('user_phone','LIKE',$params['user_phone']['1'].'%')->find();
unset($params['user_phone']);
$result = $this->alias('a')
->where($params)
->where('referrer_id','=',$id->id)
->count();
} else {
$result = $this->alias('a')
->where($params)
->count();
}
return $result;
}
/**
* @param $params
* @return int|string
*/
public function getMyUserCount($params){
$result = $this->alias('a')
->where($params)
->count();
return $result;
}
......@@ -106,16 +182,19 @@ class Users extends Model
*/
public function edit($data, $id = 0) {
$insert_data['user_nick'] = $data['user_nick'];
if($data['user_phone']){
if(!empty($data['user_phone'])){
$insert_data['user_phone'] = $data['user_phone'];
}
$insert_data['sex'] = $data['sex'];
if ($id) {
//修改
$insert_data['agent_id']= $data['agents_id'];
$insert_data['update_time']= date('Y-m-d H:i:s');
$this->save($insert_data,['id'=>$id]);
$return_id = $id;
} else {
//新增
$is_exist = $this->where('user_phone',$data['user_phone'])->count();
if (empty($is_exist)) {
$insert_data['referrer_id'] = $data['agents_id'];
......@@ -178,6 +257,13 @@ class Users extends Model
return $r;
}
/**
* @param $user_id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function useraction_search_user_res($user_id)
{
return db('u_users')
......
......@@ -225,7 +225,6 @@ Route::group('api', [
//Version
'getVersionNo' => [ 'api/Version/getVersionNo', [ 'method' => 'post' ] ],
'agentUserTb' => [ 'api_broker/Client/agentUserTb', [ 'method' => 'get' ] ],//客户列表
'agentUserFollow' => [ 'api_broker/Client/agentUserFollow', [ 'method' => 'get' ] ],//客户列表
'agentSearch' => [ 'api_broker/Client/agentSearch', [ 'method' => 'get' ] ],//经纪人搜索
......@@ -233,6 +232,23 @@ Route::group('api', [
]);
Route::group('chat', [
'index' => [ 'chat/AppChat/index', [ 'method' => 'get' ] ],
'userChat' => [ 'chat/AppChat/userChat', [ 'method' => 'post|get' ] ],
'pushMsg' => [ 'chat/AppChat/pushMsg', [ 'method' => 'post|get' ] ],
'getChatHistory' => [ 'chat/AppChat/getChatHistory', [ 'method' => 'post|get' ] ],
'getUserOrAgentInfo' => [ 'chat/AppChat/getUserOrAgentInfo', [ 'method' => 'post|get' ] ],
'uploadImg' => [ 'chat/AppChat/uploadImg', [ 'method' => 'post|get' ] ],
'createGroupByOnlyId' => [ 'chat/Group/createGroupByOnlyId', [ 'method' => 'post|get' ] ],
'delGroup' => [ 'chat/Group/delGroup', [ 'method' => 'post|get' ] ],
'getGroupUser' => [ 'chat/Group/getGroupUser', [ 'method' => 'post|get' ] ],
'addGroupUserByIds' => [ 'chat/Group/addGroupUserByIds', [ 'method' => 'post|get' ] ],
'delGroupUserByIds' => [ 'chat/Group/delGroupUserByIds', [ 'method' => 'post|get' ] ],
'addGroupManage' => [ 'chat/Group/addGroupManage', [ 'method' => 'post|get' ] ],
'delGroupManage' => [ 'chat/Group/delGroupManage', [ 'method' => 'post|get' ] ],
'pushMsg_gethouseinfo' => [ 'chat/AppChat/pushMsg_gethouseinfo', [ 'method' => 'post|get' ] ],
]);
Route::group('task',[
'exclusiveExpirationTime' => [ 'task/exclusive/exclusiveExpirationTime', [ 'method' => 'get' ]], //独家过期时间
'addReport' => [ 'task/PrivacyNumber/addReport', [ 'method' => 'get|post' ]], //阿里大于隐私号码回调
......
......@@ -9,29 +9,40 @@
*/
namespace app\task\controller;
use app\model\HouseInfos;
use think\Log;
class Exclusive {
/**
* 独家时间过期下架商铺
*
* @return type
* @return string
* @throws \Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function exclusiveExpirationTime() {
$house = new HouseInfos();
$house_data = $house->field('id,room_num_left,exclusive_end')->where('exclusive_type', 1)->where('is_delete', 0)->select();
$house_data = $house->field('id,room_num_left,exclusive_end')
->where('exclusive_type', 1)
->where('is_delete', 0)
->where('room_num_left','<>', 0)
->select();
$result = array();
if ($house_data) {
$insert = array();
foreach ($house_data as $k => $v) {
if (strtotime($v['exclusive_end'] . '23:59:59') > time() && $v['exclusive_end'] != NULL) {
if ((strtotime($v['exclusive_end'] . '23:59:59') > time()) && ($v['exclusive_end'] != NULL)) {
continue;
}
$insert[$k]['id'] = $v['id'];
$insert[$k]['room_num_left'] = 0;
}
$result = $house->saveAll($insert);
}
return;
Log::record('exclusiveExpirationTime:'.json_encode($result),'TASK');
return ;
}
}
File mode changed from 100755 to 100644
......@@ -128,3 +128,211 @@ response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>15505625080</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>4796</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=F413CF2011A6A1505C3B9F4FDD6A2258
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>15505625090</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>8999</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=F41DBC75A64B489C3754C87B65A2E09E
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18205625070</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>7889</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=905D65B26C5DEF1EC630B0F5AA17A509
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>15505625060</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>3182</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=76D08F08B4D1BAD08457BC638BBDB484
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18805625020</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>2071</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=7058E44B5B45924D7B11C38F5D534306
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756252570</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>9183</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=1A0FD455A35089B0EB5E6723190A15FB
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756258888</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>7572</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=1566AAB75F25B6DD28A4902FA26AEC0F
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756259999</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>3479</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=DE9865EE495BD9B0D85EDAF249CDA24F
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756257777</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>7094</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=7977CEC21F534DD1E5D675D792595DC9
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>15038133185</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>1323</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=A83C2D00731E2A9F65F7CAC298B44B09
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756256666</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>3450</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=40EE1C43A1B08B698B610DC95026AF74
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756255555</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>5919</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=8DABD7C3A3D79365F4AA65E92613F6A1
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>15032323232</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>4355</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=157B3CA0CF0C1D232FE6D6758A6F9E77
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756254444</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>8064</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=EA2BC31B5B5662AD292223DC686FA26D
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756253333</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>7687</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=00F01FFDBFD51AA503BB5585E4D2DC21
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>13112341234</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>8858</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=873B52C43862749A39926C652B5834DC
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
......@@ -207,6 +207,7 @@ body{
font-size: .3rem;
color: #333;
line-height: .44rem;
word-break: break-all;
}
.see-all-area{
......
......@@ -106,8 +106,8 @@
color: #ff9419;
font-size: 0.4rem;
text-align: center;
margin-top: 0.3rem;
margin-left: 0.15rem;
width: 100%;
float: left;
}
.ul_b2{
width: 35%;
......@@ -293,4 +293,3 @@
......@@ -44,6 +44,7 @@ body{
background: none;
margin-top: 0.18rem;
border: none;
width: 3.3rem;
}
input::-webkit-input-placeholder{
color: #ccc;
......@@ -65,6 +66,7 @@ input::-webkit-input-placeholder{
background: none;
margin-top: 0.18rem;
border: none;
width: 3rem;
}
.send1{
font-size: 0.26rem;
......
......@@ -47,7 +47,7 @@ $(function() {
$('#name_jingjiren').html(data['data']['realname']);
$('#time_ruzhi').html(data['data']['created']);
$('#name_store').html(data['data']['sub_shopname']);
$('.portrait-area>img').attr('src', data['data']['head_portrait']);
$('.portrait-area>div>img').attr('src', data['data']['head_portrait']);
var _fenNum = parseInt(Number(data['data']['evaluate_grade']));
var _pingNum = Number(data['data']['evaluate_num']) > 99 ? '99+' : Number(data['data']['evaluate_num']);
$('#pingjia_fen').html(_fenNum);
......@@ -177,7 +177,7 @@ $(function() {
'3': item['created'],
'4': (item['receptiontime'] != ''||item['houserAddress'] != '')?(dealTimeKf(item['receptiontime'])+'在'+item['houserAddress']['address']+'看房'):'暂无看房数据',
'5': item['evaluate_content'],
'6': location.protocol+'//'+item['user_pic'],
'6': item['user_pic'],
'7': ServerHost+'/app/images/ic_default_headpic.png'
});
};
......@@ -193,13 +193,15 @@ $(function() {
var _html2 = "";
$.each(data['data']['journalAccounts'], function(i, item) {
if(i < 2) {
_html2 += '<li class="oh"><div class="fl oh"><img src="{5}" onerror="javascript:this.src=\'{6}\'"></div><div class="fl"><h3 class="shangpu-name ellipsis">{0}</h3><p class="qianyue-time">签约时间:{1}</p><p class="mianji-scale">{2}</p><p class="zuji-price">租金均价:<span>{3}</span>元/月</p><p class="sp-text ellipsis oh">{4}</p></div></li>'.stringFormatObj({
_html2 += '<li class="oh"><div class="fl oh"><img src="{5}" onerror="javascript:this.src=\'{6}\'"></div><div class="fl"><h3 class="shangpu-name ellipsis">{0}</h3><p class="qianyue-time">签约时间:{1}</p><p class="mianji-scale">{2}</p><p class="zuji-price">{t1}{3}{t2}</p><p class="sp-text ellipsis oh">{4}</p></div></li>'.stringFormatObj({
'0': item['title'],
'1': item['singntime'],
'2': dealScale(item),
'3': item['price'],
't1': (item['rent_type'] == 2?'营业额扣点':'租金均价:'),
'3': '<span>'+item['price']+'</span>',
't2': (item['rent_type'] == 2?'%':(item['rent_type'] == 1?'元/月':'元/天/m²')),
'4': dealTags(item['shangpu_tags']),
'5': location.protocol+'//'+item['img'],
'5': item['img'],
'6': ServerHost+'/resource/image/pzz_.jpg'
});
};
......
......@@ -31,16 +31,27 @@
var shanpu=' ';
if(shang=="0"){
shanpu='<span class="a_fontd">进场费:'+response.data.slotting_fee+'元</span>';
$(".pu_area").html(response.data.room_area+'-'+response.data.room_area2+'㎡');
$(".b3_span").html("商场");
}else if(shang=="1"){
shanpu='<span class="a_fontd">转让费:'+response.data.transfer_fee+'元</span>';
$(".pu_area").html(response.data.room_area+'㎡');
$(".b3_span").html("街铺");
}
var title = response.data.foreign_name ?response.data.foreign_name : "";
var _tempStr = '';
if(response.data.rent_type == '1'){
_tempStr = '租金均价 :'+response.data.price+'元/月';
}else if(response.data.rent_type == '2'){
_tempStr = '营业额扣点'+response.data.price+'%';
}else if(response.data.rent_type == '3'){
_tempStr = '租金均价 :'+response.data.price+'元/天/m²';
};
var fff = '租金均价 :'+response.data.price+'元/月</p>';
line_a='<p class="a_fonta">'+ title +'</p>'+
'<p class="a_fontb">租金均价 :'+response.data.price+'元/月</p>'+
'<span class="a_fontc">物业管理费:'+response.data.management_fee+'元/月</span>'+
'<p class="a_fontb">'+_tempStr+
'</p><span class="a_fontc">物业管理费:'+response.data.management_fee+'元/月</span>'+
shanpu;
$(".line_a").html(line_a);
var shangpu_tag=response.data.shangpu_tags;
......@@ -58,11 +69,9 @@
has_gas="否";
}
$(".balance_num").html(response.data.room_num_left);
$(".balance_num2").html(response.data.room_num_total);
$(".b1_span3").html(response.data.room_area);
$(".b1_span34").html(response.data.room_area2);
$(".b1_span4").html(response.data.business_area);
$(".pu_num").html(response.data.room_num_left+'/'+response.data.room_num_total);
$(".shy_area").html(response.data.business_area+'㎡');
$(".b3_span2").html(response.data.yetai);
$(".b3_spanhao").html(response.data.id);
$(".b3_span3").html(response.data.has_moved);
......
......@@ -66,13 +66,15 @@ $(function() {
pageInit++; //页数+1
var _html = "";
$.each(data['data']['journalAccounts'], function(i, item) {
_html += '<li class="oh"><div class="fl oh"><img src="{5}" onerror="javascript:this.src=\'{6}\'"></div><div class="fl"><h3 class="shangpu-name ellipsis">{0}</h3><p class="qianyue-time">签约时间:{1}</p><p class="mianji-scale">{2}</p><p class="zuji-price">租金均价:<span>{3}</span>元/月</p><p class="sp-text ellipsis oh">{4}</p></div></li>'.stringFormatObj({
_html += '<li class="oh"><div class="fl oh"><img src="{5}" onerror="javascript:this.src=\'{6}\'"></div><div class="fl"><h3 class="shangpu-name ellipsis">{0}</h3><p class="qianyue-time">签约时间:{1}</p><p class="mianji-scale">{2}</p><p class="zuji-price">{t1}{3}{t2}</p><p class="sp-text ellipsis oh">{4}</p></div></li>'.stringFormatObj({
'0': item['title'],
'1': item['singntime'],
'2': dealScale(item),
'3': item['price'],
't1': (item['rent_type'] == 2?'营业额扣点':'租金均价:'),
'3': '<span>'+item['price']+'</span>',
't2': (item['rent_type'] == 2?'%':(item['rent_type'] == 1?'元/月':'元/天/m²')),
'4': dealTags(item['shangpu_tags']),
'5': location.protocol+'//'+item['img'],
'5': item['img'],
'6': ServerHost + '/resource/image/pzz_.jpg'
});
});
......
......@@ -92,7 +92,7 @@ $(function() {
'3': item['created'],
'4': (item['receptiontime'] != ''||item['houserAddress'] != '')?(dealTimeKf(item['receptiontime'])+'在'+item['houserAddress']['address']+'看房'):'暂无看房数据',
'5': item['evaluate_content'],
'6': location.protocol+'//'+item['user_pic'],
'6': item['user_pic'],
'7': ServerHost+'/app/images/ic_default_headpic.png'
});
});
......
<?php
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/8
* Time : 15:56
* Intro:
*/
// [ 应用入口文件 ]
// 定义应用目录
define('APP_PATH', __DIR__ . '/../application/');
// 加载框架引导文件
require __DIR__ . '/../thinkphp/start.php';
// 读取自动生成定义文件
/*$build = include './../build.php';
// 运行自动生成
\think\Build::run($build);*/
\ No newline at end of file
......@@ -221,4 +221,3 @@ body{
width: 100%;
height: 40px;
line-height: 40px;
}
\ No newline at end of file
......@@ -33,7 +33,48 @@ define(['doT', 'text!temp/remark_follow_template_tpl.html', 'css!style/home.css'
follow.house_id = $ (this).attr ("data-id");
follow.Submit_follow();
});
$ (document).on ("input","#cus_fang", function () {//手机号搜索客方2
if($("#cus_fang").val()==''){
$(".user-ul2").html('');
}else{
follow.search_phone2();
}
});
$ (document).delegate (".addphone2", "click", function () {//list2消失
follow.addphone2(this);
});
},
addphone2:function(obj){
var user_ht=$(obj).html();
$("#cus_fang").val(user_ht);
$(".user-ul2").html('');
follow.agent_id = $ (obj).attr ("data-id");
},
search_phone2:function(){//手机号
$.ajax ({
url: '/index/select_by_phone',
type: 'POST',
async: true,
data: {
"phone":$("#cus_fang").val()
},
dataType: 'json',
success: function (data) {
if (data.code == 200) {
var user_ul2 = "";
$.each(data.data, function(i,item) {
user_ul2+='<li class="addphone2" data-id="'+item.id+'">'+item.id+'-'+item.realname+'-'+item.phone+'</li>';
});
$(".user-ul2").html(user_ul2);
} else {
alert(data.msg);
}
}
});
},
Caozuo:function(){//获取跟进详情的数据
$.ajax({
......@@ -72,7 +113,7 @@ define(['doT', 'text!temp/remark_follow_template_tpl.html', 'css!style/home.css'
"id": follow.house_id,
"user_nick": $("#cus_name").val(),
"user_phone": $("#cus_phone").html(),
"agent_id": "",//客方
"agent_id":follow.agent_id,//客方
"sex": $("#sex").val()
},
dataType: "json",
......
/**
* Created by 刘丹 on 2018/3/1.
*/
define (['doT', 'text!temp/agentIndex_template_tpl.html', 'css!style/home.css','ckfinder','ckfinderStart','pagination','bootstrapJs'], function (doT, template) {
agentIndex = {
pageNo: 1, /*第几页*/
pageSize: 10, /*每页显示多少条*/
id : '',
house_id:'',
type:'',
valueCurrent:'',
ajaxObj:'',
stopstatus:true,
boxphoto:'',
init: function () {
//初始化dot
$ ("body").append (template);
agentIndex.getList ();
agentIndex.event ();
},
event: function () {
$("#search").click(function () {
agentIndex.getList(1);
});
$("#reset").click(function () {//重置
document.getElementById("form_search").reset();
});
},
getList: function (pageNo) {
agentIndex.pageNo = pageNo;
var params = {};
params.pageNo = agentIndex.pageNo;
params.pageSize = agentIndex.pageSize;
params.agents_name = $('#industry_type') .val();//经纪人姓名
params.phone = $('#dish') .val();//经纪人手机号
params.start_date = $('#start_date') .val();//时间1
params.end_date = $('#end_date') .val();//时间2
$.ajax ({
url: '/index/callCollectList',//获取列表
type: 'GET',
async: true,
data: params,
dataType: 'json',
success: function (data) {
var temp = document.getElementById ('agentIndex_list_tpl').innerHTML;
var doTtmpl = doT.template (temp);
$ ("#agentIndex_list").html (doTtmpl (data.data.list));
/*分页代码*/
$ ("#pagediv").pagination ({
length: data.data.total,
current: pageNo,
every: agentIndex.pageSize,
onClick: function (el) {
agentIndex.getList (el.num.current);
}
});
}
});
}
};
return agentIndex;
});
\ No newline at end of file
......@@ -64,6 +64,26 @@ define (['doT', 'text!temp/auth_rule_box_template_tpl.html', 'css!style/home.css
}
}
});
var id= getUrlParam('id');
$.ajax({
url: '/index/updateAuthRule/group_id/'+id,
type: 'post',
async: true,
dataType: 'json',
success: function (data) {
$("input[name = id]").val(data.data.id);
$("input[name = title]").val(data.data.title);
$("input[name = name]").val(data.data.name);
$("input[name = sort]").val(data.data.sort);
$("#pid").val(data.data.pid);
if(data.data.is_menu==0){
$("#is_menu2").attr('checked',true);
}else{
$("#is_menu1").attr('checked',true);
}
}
})
}
......
......@@ -17,6 +17,7 @@ define (['ckfinder','ckfinderStart', 'bootstrapJs'], function () {
_landlordPhoneObj = $('#landlordPhone'),//房东手机号
_internalNameObj = $('#internalName'),//对内商铺名称
_foreignNameObj = $('#foreignName'),//对外商铺名称
_landlordPhoneObj = $('#landlordPhone'),//房东手机号
_zujinTypeObj = $('#zujinType'),//租金模式
_moonPriceObj = $('#moonPrice'),//月租均价
_wuyePriceObj = $('#wuyePrice'),//物业管理费
......@@ -911,6 +912,11 @@ define (['ckfinder','ckfinderStart', 'bootstrapJs'], function () {
_data['external_address'] = $.trim(_addressExternalObj.val());
_data['external_item_advantage'] = $.trim(_foreignYoushiObj.val());
};
if(_showCdObj.val() == '0'){
_data['external_title'] = $.trim(_foreignNameObj.val());
_data['external_address'] = $.trim(_addressExternalObj.val());
_data['external_item_advantage'] = $.trim(_foreignYoushiObj.val());
};
if(_exclusiveTypeObj.val() == '1'){
_data['agent_start_time'] = _exclusiveDate1Obj.val();
_data['agent_end_time'] = _exclusiveDate2Obj.val();
......
......@@ -30,9 +30,6 @@ define (['doT', 'text!temp/user_template_tpl.html','ckfinder','ckfinderStart', '
document.getElementById("form_search").reset();
});
$("#add_user").click(function () {
user.add_user();
});
$("#close").click(function () {
document.getElementById("add_user_form").reset();
......@@ -51,6 +48,10 @@ define (['doT', 'text!temp/user_template_tpl.html','ckfinder','ckfinderStart', '
$ (document).delegate (".genj_ure", "click", function () {
user.house_id = $ (this).attr ("data-id");
});
$ (document).delegate ("#add_user", "click", function () {//新增客户
user.house_id = $ (this).attr ("data-id");
user.add_user();
});
$ (document).delegate ("#edit_add", "click", function () {
user.edit_add();
});
......@@ -58,19 +59,118 @@ define (['doT', 'text!temp/user_template_tpl.html','ckfinder','ckfinderStart', '
user.house_id = $ (this).attr ("data-id");
user.Caozuo();
});
$ (document).on ("input","#set_father_id3", function () {//手机号搜索客方
if($("#set_father_id3").val()==''){
$(".user-ul").html('');
}else{
user.search_phone();
}
});
$ (document).on ("input","#cus_fang", function () {//手机号搜索客方2
if($("#cus_fang").val()==''){
$(".user-ul2").html('');
}else{
user.search_phone2();
}
});
$ (document).delegate (".addphone", "click", function () {//list消失
user.addphone(this);
});
$ (document).delegate (".addphone2", "click", function () {//list2消失
user.addphone2(this);
});
$ (document).delegate (".submit_edit", "click", function () {//提交
user.house_id = $ (this).attr ("data-id");
user.Submit_follow();
});
$("#edit_user").click(function () {
var params = {};
params.id = $ ("#edit_id").val ();
params.user_nick = $("#inputEmail3").val();
params.user_nick = $("#inputEmail3").val();
params.pwd = $("#edit_user_form input[name='password']").val();
user.edit_user(params);
},
addphone:function(obj){
var user_ht=$(obj).html();
$("#set_father_id3").val(user_ht);
$(".user-ul").html('');
user.agent_id = $ (obj).attr ("data-id");
},
addphone2:function(obj){
var user_ht=$(obj).html();
$("#cus_fang").val(user_ht);
$(".user-ul2").html('');
user.agent_id2 = $ (obj).attr ("data-id");
},
search_phone:function(){//手机号
$.ajax ({
url: '/index/select_by_phone',
type: 'POST',
async: true,
data: {
"phone":$("#set_father_id3").val()
},
dataType: 'json',
success: function (data) {
if (data.code == 200) {
var user_ul = "";
$.each(data.data, function(i,item) {
user_ul+='<li class="addphone" data-id="'+item.id+'">'+item.id+'-'+item.realname+'-'+item.phone+'</li>';
});
$(".user-ul").html(user_ul);
} else {
alert(data.msg);
}
}
});
},
search_phone2:function(){//手机号
$.ajax ({
url: '/index/select_by_phone',
type: 'POST',
async: true,
data: {
"phone":$("#cus_fang").val()
},
dataType: 'json',
success: function (data) {
if (data.code == 200) {
var user_ul2 = "";
$.each(data.data, function(i,item) {
user_ul2+='<li class="addphone2" data-id="'+item.id+'">'+item.id+'-'+item.realname+'-'+item.phone+'</li>';
});
$(".user-ul2").html(user_ul2);
} else {
alert(data.msg);
}
}
});
},
Submit_follow: function() { //提交
$.ajax({
'type': 'POST',
'url': '/index/pcEditClient',
data: {
"id": user.house_id,
"user_nick": $("#cus_name").val(),
"user_phone": $("#cus_phone").html(),
"agent_id":user.agent_id2,//客方
"sex": $("#sex").val()
},
dataType: "json",
success: function(data) {
if(data.code == 200) {
if(data.data) {
}
} else {
}
}
});
},
edit_add : function () {//提交跟进
$.ajax ({
url: '/index/pcAdduser',
url: '/index/pcAddFollow',
type: 'POST',
async: true,
data: {
......@@ -104,7 +204,6 @@ define (['doT', 'text!temp/user_template_tpl.html','ckfinder','ckfinderStart', '
$("#cus_fang").val(data.data.user_info.agentinfo);//客方
var caozuo_table="";
$.each(data['data']['user_date'], function(i, item) {
console.log(item)
caozuo_table +='<tr><td>'+item.content+'</td><td>'+item.agentinfo+'</td><td>'+item.create_time+'</td></tr>';
});
$("#caozuo_table").html(caozuo_table);
......@@ -149,10 +248,11 @@ define (['doT', 'text!temp/user_template_tpl.html','ckfinder','ckfinderStart', '
},
add_user : function () {
var params = {};
params.realname = $("#add_user_form input[name='realname']").val();
params.id = user.house_id;
params.user_nick = $("#add_user_form input[name='realname']").val();
params.user_phone = $("#add_user_form input[name='user_phone']").val();
params.pwd = $("#add_user_form input[name='pwd']").val();
params.type = 'add';
params.sex = $("#user_sex option:selected").val();
params.agent_id=user.agent_id;
if (params.realname == '') {
alert('姓名不能为空');
$("input[name='realname']").focus();
......@@ -169,23 +269,6 @@ define (['doT', 'text!temp/user_template_tpl.html','ckfinder','ckfinderStart', '
return ;
}
$.ajax ({
url: '/index/user_add',
type: 'POST',
async: true,
data: params,
dataType: 'json',
success: function (data) {
if (data.code == 200) {
$ ("#modal_add_user").modal ('hide');
alert(data.msg);
} else {
alert(data.msg);
}
}
});
},
edit_user : function (params) {//添加客户
$.ajax ({
url: '/index/pcEditClient',
type: 'POST',
......@@ -193,14 +276,10 @@ define (['doT', 'text!temp/user_template_tpl.html','ckfinder','ckfinderStart', '
data: params,
dataType: 'json',
success: function (data) {
$ ("#modal-delete").modal ('hide');
if (data.code == 200) {
$ ("#modal-do").modal ('hide');
alert(data.msg);
} else {
alert(data.msg);
}
user.getList (user.pageNo);
}
});
},
......
......@@ -196,7 +196,7 @@ define (['doT', 'text!temp/watch_template_tpl.html', 'css!style/home.css','pagin
params.end_date = $("#end_date").val();
params.name = $("#name").val();
params.phone = $("#phone").val();
params.shop_name = $("#shop_name").val();
params.house_title = $("#house_title").val();
params.pageNo = user.pageNo;
params.pageSize = user.pageSize;
......
......@@ -39,10 +39,10 @@
[% } %]
</td>
<td>
<a class="btn1 btn-success caozuo" href="#modal_add_user" data-toggle="modal" data-id='[%= it[item]["id"] %]'>
<a class="btn1 btn-success caozuo" href="#modal-record" data-toggle="modal" data-id='[%= it[item]["id"] %]'>
编辑
</a>
<a class="btn1 btn-success genj_ure" href="#modal-add" data-toggle="modal" data-toggle="modal" data-id='[%= it[item]["id"] %]'>
<a class="btn1 btn-success genj_ure" href="#modal-add" data-toggle="modal" data-id='[%= it[item]["id"] %]'>
跟进
</a>
<!--<a class="btn1 btn-danger " href="#modal-delete" data-toggle="modal" onclick="delete_user(this)" data-id='[%= it[item]["id"] %]'>-->
......
*
!.gitignore
\ 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