Commit 2d8f2796 authored by hujun's avatar hujun

Merge remote-tracking branch 'origin/0702-v.2.2.0' into 0702-v.2.2.0

parents 3547743f 5a289903
......@@ -108,6 +108,7 @@ class Broker extends Basic
/*$params = array(
"phone" => "15002102357",
"pwd" => "123456",
"push_id" => "123123",
"device_id" => "qweqweqweqweqw123123",
"model" => "iphone7",//手机型号
);*/
......@@ -136,7 +137,7 @@ class Broker extends Basic
return $this->response(101, '密码错误');
}
//判断设备id是否存在
$is_login = $this->judgeBand($params["device_id"], $agents_data['id'], $params["model"], 0);
$is_login = $this->judgeBand($params["device_id"], $agents_data['id'], $params["model"], 0, $params["push_id"]);
if (!$is_login) {
return $this->response("101", "该账号没有绑定该手机,请致电人事进行绑定。");
}
......@@ -179,11 +180,11 @@ class Broker extends Basic
return $this->response("101", $checkResult);
}
$is_visit = $this->judgeBand($params["device_id"], $params["agent_id"], "", 1);
$is_visit = $this->judgeBand($params["device_id"], $params["agent_id"], "", 1, "");
if ($is_visit) {
return $this->response("200", "success", []);
} else {
return $this->response("101", "该账号没有绑定该手机,请致电人事进行绑定。");
return $this->response("102", "该账号没有绑定该手机,请致电人事进行绑定。");
}
}
......@@ -193,33 +194,46 @@ class Broker extends Basic
* @param int $agent_id
* @param string $model
* @param int $type 0提交记录到后台, 1仅仅判断
* @param string $push_id
* @return bool
*/
private function judgeBand(string $device_id, int $agent_id, string $model, int $type): bool
private function judgeBand(string $device_id, int $agent_id, string $model, int $type, string $push_id): bool
{
$params["agent_id"] = $agent_id;
$result = $this->aBD->getDeviceByAgentId($params);
if (count($result) <= 0) {
//新增设备绑定关系
//新增设备绑定关系 默认直接登陆
if ($type == 0)
$this->aBD->addDevice([ "device_id" => $device_id, "agent_id" => $agent_id, "model" => $model, "is_forbidden" => 0 ]);
$this->aBD->addDevice([ "device_id" => $device_id,
"agent_id" => $agent_id,
"model" => $model,
"push_id" => $push_id,
"is_forbidden" => 0 ]);
return true;
}
$is_exits = false;
foreach ($result as $item) {
if ($device_id == $item["device_id"] && $item["is_forbidden"] == 0) {
return true;
}
if ($device_id == $item["device_id"] && $item["is_forbidden"] == 1) {
$is_exits = true;
}
if ($device_id == $item["device_id"]) {
if ($item["is_forbidden"] == 0) {
return true;
} elseif ($item["is_forbidden"] == 1) { //已存在申请关系
$is_exits = true;
}
//当个推返回的id改变时则更新记录
if ($push_id && $push_id != $item["push_id"])
$this->aBD->updateDevice([ "id" => $item["id"], "push_id" => $push_id ]);
}
}
if (!$is_exits && $type == 0) {
//新增申请绑定关系
$this->aBD->addDevice([ "device_id" => $device_id, "agent_id" => $agent_id, "model" => $model, "is_forbidden" => 1 ]);
}
if (!$is_exits && $type == 0)
//新增申请绑定关系,需要后台同意登陆
$this->aBD->addDevice([ "device_id" => $device_id,
"agent_id" => $agent_id,
"model" => $model,
"push_id" => $push_id,
"is_forbidden" => 1 ]);
return false;
}
......@@ -228,7 +242,8 @@ class Broker extends Basic
* 绑定或者解绑
* @return \think\Response
*/
public function updateDevice()
public
function updateDevice()
{
$params = $this->params;
/* $params = array(
......@@ -264,7 +279,8 @@ class Broker extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getBroker()
public
function getBroker()
{
$data['status'] = 200;
$data['data'] = '';
......@@ -297,7 +313,8 @@ class Broker extends Basic
*
* @return \think\Response
*/
public function add_phone_follow_up()
public
function add_phone_follow_up()
{
header('Access-Control-Allow-Origin:*');
$params = $this->params;
......@@ -346,7 +363,8 @@ class Broker extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function user_search()
public
function user_search()
{
$Two_days_ago = date("Y-m-d h:i:s", strtotime("-2 day"));
//dump($Two_days_ago);
......@@ -408,7 +426,8 @@ class Broker extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function useraction_search()
public
function useraction_search()
{
header('Access-Control-Allow-Origin:*');
$params = $this->params;
......@@ -468,7 +487,8 @@ class Broker extends Basic
* 搜索动态
* @return \think\Response
*/
public function userStateSearch()
public
function userStateSearch()
{
$params = $this->params;
/* $params = array(
......@@ -487,7 +507,8 @@ class Broker extends Basic
/**
* 编辑密码
*/
public function editAgent()
public
function editAgent()
{
$data['code'] = 200;
$data['msg'] = "";
......@@ -515,7 +536,8 @@ class Broker extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function forgetPwd()
public
function forgetPwd()
{
$data['code'] = 101;
$data['msg'] = "";
......@@ -565,7 +587,8 @@ class Broker extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function uploadHeadImg()
public
function uploadHeadImg()
{
$data['status'] = 101;
$data['msg'] = '';
......@@ -608,7 +631,8 @@ class Broker extends Basic
*
* @return \think\Response
*/
public function token()
public
function token()
{
header('Access-Control-Allow-Origin:*');
$jwt = new JwtUntils();
......@@ -625,7 +649,8 @@ class Broker extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAgentsByPhone()
public
function getAgentsByPhone()
{
header('Access-Control-Allow-Origin:*');
$agents = new AAgents();
......@@ -643,7 +668,8 @@ class Broker extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function sendSms()
public
function sendSms()
{
$data['data'] = [];
$data['status'] = 101;
......@@ -705,7 +731,8 @@ class Broker extends Basic
* @throws \Endroid\QrCode\Exception\InvalidPathException
* @throws \Endroid\QrCode\Exception\InvalidWriterException
*/
public function qrCode()
public
function qrCode()
{
$parms = $this->params;
......
......@@ -75,4 +75,45 @@ class CollectHouse extends Basic
}
}
/**
* 查询收藏数据
* User: 朱伟
* Date: 2018-07-04
* Time: 15:35:40
*/
public function getCollectHouseList()
{
$params = $this->params;
/*$params = array(
"agents_id" => 2,
);*/
if (!isset($params["agents_id"])) {
return $this->response("101", "请求参数错误");
}
$field = 'CollectUser.id,';
$field .= 'Houses.internal_title,';
$field .= 'Houses.market_area,';
$field .= 'Houses.rent_type,';
$field .= 'Houses.rent_price,';
$field .= 'Houses.shop_area_start,';
$field .= 'Houses.shop_area_end,';
$field .= 'Houses.shop_sign';
$get_params['agents_id'] = $params["agents_id"];
$res = $this->aCollectHouse->getCollectList($field,$get_params);
//dump($res);
if ($res) {
return $this->response("200", "成功",$res);
} else {
return $this->response("101", "失败");
}
}
}
\ No newline at end of file
......@@ -78,4 +78,57 @@ class CollectUser extends Basic
}
}
/**
* 查询收藏数据
* User: 朱伟
* Date: 2018-07-04
* Time: 15:35:40
*/
public function getCollectUserList()
{
$params = $this->params;
/*$params = array(
"agents_id" => 2,
);*/
if (!isset($params["agents_id"])) {
return $this->response("101", "请求参数错误");
}
$field = 'CollectUser.id,';
$field .= 'CollectUser.status,';
$field .= 'Users.id AS user_id,';
$field .= 'Users.user_nick,';
$field .= 'Users.user_phone,';
$field .= 'Users.agent_id,';
$field .= 'Users.user_status,';
$field .= 'Users.industry_type,';
$field .= 'Users.price_demand,';
$field .= 'Users.area_demand';
$get_params['agents_id'] = $params["agents_id"];
$res = $this->aCollectUser->getCollectList($field,$get_params);
foreach($res as $k=>$v)
{
$label = [];
if($params["agents_id"] == $v['agent_id'])
{
$label[] = '我的';
}
//无效客户不显示标签
if($v['user_status'] != -1){
$res[$k]['label'] = implode(',',$label);
}
}
//dump($res);
if ($res) {
return $this->response("200", "成功",$res);
} else {
return $this->response("101", "失败");
}
}
}
\ No newline at end of file
......@@ -35,7 +35,7 @@ class UploadImg extends Basic
set_time_limit(0);
$file = $_FILES['image'];
$type = request()->param('type');
// Log::record("upload img info :" . json_encode($file) );
Log::record("upload img info :" . json_encode($file) );
$uploadResult = $this->uFService->upload($file, $type);
......
......@@ -345,6 +345,7 @@ class OrderLogService
$trees[$i]["create_time"] = $v[0]["create_time"];
}
unset($tree);
sort($trees);
return $trees;
}
......
......@@ -19,6 +19,7 @@ class PerformanceValidate extends Validate
'phone' => 'require|number',
'pwd' => 'require|min:6',
'device_id' => 'require',
'push_id' => 'require',
'is_forbidden' => 'require|in:0,1',
'operator_id' => 'require|number',
];
......@@ -33,6 +34,7 @@ class PerformanceValidate extends Validate
'pwd.require' => '密码不能为空',
'pwd.min' => '密码小于6位',
'device_id.require' => '设备号获取失败,请联系管理员',
'push_id.require' => '个推帐号获取失败,请联系管理员',
'is_forbidden.require' => '是否绑定字段必填',
'is_forbidden.in' => '是否绑定字段值只能为0或1',
'operator_id.require' => '操作人为必填字段',
......@@ -42,7 +44,7 @@ class PerformanceValidate extends Validate
protected $scene = [
'verify' => [ 'type', 'agent_id' ],
'verifyOther' => [ 'agent_id' ],
'login' => [ 'phone', 'pwd', 'device_id' ],
'login' => [ 'phone', 'pwd', 'device_id', "push_id" ],
'verifyStatus' => [ 'agent_id', 'device_id' ],
'verifyIsForbidden' => [ 'phone', 'device_id', 'is_forbidden', 'operator_id' ],
];
......
......@@ -311,22 +311,35 @@ class Agent extends Basic
public function agentEvaluateNumAndFraction()
{
$data = $this->request->param();
$agents_id = $data['agents_id'];
/*$data = array(
"agents_id" => '869,5758,5757,5756,5755,5754,5753,5752,5751,5750,5749,5748,5747,5746,5745'
);*/
$agents_ids = $data['agents_id'];
if (!isset($agents_id)) {
if (!isset($agents_ids)) {
return $this->response("300", "参数不全");
}
$params['agents_id'] = $agents_id;
$field='sum(evaluate_grade) as agent_evaluate_fraction';
$model = new Evaluate();
$agent_evaluate_num = $model->getAgentEvaluateNum($params);
$agent_evaluate_fraction_res = $model->getAgentEvaluateFraction($field,$params);
$agent_evaluate_fraction = round($agent_evaluate_fraction_res[0]['agent_evaluate_fraction']/2 /$agent_evaluate_num,1);
if ($agent_evaluate_num && $agent_evaluate_fraction_res) {
$result['agent_evaluate_num'] = $agent_evaluate_num;
$result['agent_evaluate_fraction'] = $agent_evaluate_fraction;
foreach (explode(',',$agents_ids) as $k => $v){
$params['agents_id'] = $v;
//dump($v);
$field='sum(evaluate_grade) as agent_evaluate_fraction';
$agent_evaluate_num = $model->getAgentEvaluateNum($params);
$agent_evaluate_fraction_res = $model->getAgentEvaluateFraction($field,$params);
$agent_evaluate_fraction = 0;
if($agent_evaluate_fraction_res[0]['agent_evaluate_fraction']){
$agent_evaluate_fraction = round($agent_evaluate_fraction_res[0]['agent_evaluate_fraction']/2 /$agent_evaluate_num,1);
}
$res['agents_id'] = $v;
$res['agent_evaluate_num'] = $agent_evaluate_num;
$res['agent_evaluate_fraction'] = $agent_evaluate_fraction;
$result[] = $res;
}
if ($result) {
return $this->response(200, '成功', $result);
} else {
return $this->response(100, '失败');
......
......@@ -137,7 +137,7 @@ class Collection extends Basic
}
$export = new ExportExcelUntil();
$title = [ '收款时间', '客户姓名', '客户手机号', '约带看人姓名', '约带看人手机号', '约带看人所属部门', '收款金额(元)', '实付金额(元)', '入账类型','入账方式','商铺地址','商铺号' ];
$title = [ '收款时间', '客户姓名', '客户手机号', '约带看人姓名', '约带看人手机号', '约带看人所属门店', '约带看人所属部门', '收款金额(元)', '实付金额(元)', '入账类型','入账方式','商铺地址','商铺号' ];
$export->exportTable('收款记录', $data, 9, '收款记录', $title);
}
......@@ -228,16 +228,19 @@ class Collection extends Basic
if(!isset($params["img_name"])){
return $this->response("101","请求参数错误");
}
$time = date("Y-m-d H:i:s", time());
$save_data["img_id"] = $params["img_id"];//id根据img_type区分是收款还是进场还是其他'
$save_data["img_type"] = 2 ;//图片类型:1进场,2收款
$save_data["img_name"] = $params["img_name"];//图片名称
$save_data["img_status"] = 0 ;//删除状态 0正常 1删除
$save_data["update_time"] = $time;//更新时间
$save_data["create_time"] = $time;//创建时间
$order = new OImg();
$res = $order->addImgOnce($save_data);
foreach (explode(',',$params["img_name"]) as $k => $v){
$time = date("Y-m-d H:i:s", time());
$save_data["img_id"] = $params["img_id"];//id根据img_type区分是收款还是进场还是其他'
$save_data["img_type"] = 2 ;//图片类型:1进场,2收款
$save_data["img_name"] = $v;//图片名称
$save_data["img_status"] = 0 ;//删除状态 0正常 1删除
$save_data["update_time"] = $time;//更新时间
$save_data["create_time"] = $time;//创建时间
$res = $order->addImgOnce($save_data);
}
if($res){
return $this->response("200","成功");
}else{
......
......@@ -65,16 +65,16 @@ class ABindingDevice extends BaseModel
* @param string $field
* @return false|\PDOStatement|string|\think\Collection
*/
public function getDeviceByAgentId(array $params, string $field = "id,agent_id,device_id,is_forbidden")
public function getDeviceByAgentId(array $params, string $field = "id,agent_id,device_id,is_forbidden,push_id")
{
$where_ = [];
if(isset($params["agent_id"])){
if (isset($params["agent_id"])) {
$where_["agent_id"] = $params["agent_id"];
}
if(isset($params["device_id"])){
if (isset($params["device_id"])) {
$where_["device_id"] = $params["device_id"];
}
if(isset($params["is_forbidden"])){
if (isset($params["is_forbidden"])) {
$where_["is_forbidden"] = $params["is_forbidden"];
}
return $this
......@@ -103,6 +103,9 @@ class ABindingDevice extends BaseModel
if (isset($params["device_id"])) {
$arr["device_id"] = $params["device_id"];
}
if (isset($params["push_id"])) {
$arr["push_id"] = $params["push_id"];
}
if (isset($params["model"])) {
$arr["model"] = $params["model"];
}
......
......@@ -46,4 +46,21 @@ class ACollectHouse extends Model
}
/**
* 查询收藏数据
* 朱伟 2018-07-04
*/
public function getCollectList($field,$params)
{
$result = Db::table($this->table)
->field($field)
->alias('CollectUser')
->join('g_houses Houses', 'CollectUser.house_id = Houses.id', 'left')
->where($params)
->select();
//dump($this->getLastSql());
return $result;
}
}
......@@ -44,4 +44,22 @@ class ACollectUser extends Model
return $result;
}
/**
* 查询收藏数据
* 朱伟 2018-07-04
*/
public function getCollectList($field,$params)
{
$result = Db::table($this->table)
->field($field)
->alias('CollectUser')
->join('u_users Users', 'CollectUser.user_id = Users.id', 'left')
->where($params)
->select();
//dump($this->getLastSql());
return $result;
}
}
......@@ -501,8 +501,10 @@ Route::group('broker', [
'getComment' => [ 'api_broker/news/getComment', [ 'method' => 'GET' ] ], //商学院评论列表
'commentNews' => [ 'api_broker/news/commentNews', [ 'method' => 'POST' ] ], //评论商学院文章
'addCollectUser' => [ 'api_broker/CollectUser/addCollectUser', [ 'method' => 'POST|GET' ] ], //监督执行列表 朱伟 2018-06-15
'addCollectHouse' => [ 'api_broker/CollectHouse/addCollectHouse', [ 'method' => 'POST|GET' ] ], //新增-监督执行 朱伟 2018-06-20
'addCollectUser' => [ 'api_broker/CollectUser/addCollectUser', [ 'method' => 'POST|GET' ] ], //收藏或取消收藏客户 朱伟 2018-07-04
'addCollectHouse' => [ 'api_broker/CollectHouse/addCollectHouse', [ 'method' => 'POST|GET' ] ], //收藏或取消收藏商铺 朱伟 2018-07-04
'getCollectUserList' => [ 'api_broker/CollectUser/getCollectUserList', [ 'method' => 'POST|GET' ] ], //查询收藏数据 朱伟 2018-07-04
'getCollectHouseList' => [ 'api_broker/CollectHouse/getCollectHouseList', [ 'method' => 'POST|GET' ] ], //查询收藏数据 朱伟 2018-07-04
]);
......
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