Commit fc6a635c authored by hujun's avatar hujun

Merge remote-tracking branch 'origin/wx0604' into wx0604

parents ae92e0d6 77c8ff51
...@@ -4,6 +4,7 @@ namespace app\api\controller; ...@@ -4,6 +4,7 @@ namespace app\api\controller;
use app\extra\RedisExt; use app\extra\RedisExt;
use think\cache\driver\Redis; use think\cache\driver\Redis;
use think\queue\Job;
/** /**
* Created by PhpStorm. * Created by PhpStorm.
......
...@@ -42,8 +42,8 @@ class Register extends Basic ...@@ -42,8 +42,8 @@ class Register extends Basic
"phone" => "13817616471", "phone" => "13817616471",
"device_id" => "86280603569236" "device_id" => "86280603569236"
);*/ );*/
if(!isset($params["phone"])){ if (!isset($params["phone"])) {
return $this->response("101","手机号为必填字段"); return $this->response("101", "手机号为必填字段");
} }
$checkResult = $this->validate($params, "RegisterValidate.verify"); $checkResult = $this->validate($params, "RegisterValidate.verify");
if (true !== $checkResult) { if (true !== $checkResult) {
...@@ -88,12 +88,36 @@ class Register extends Basic ...@@ -88,12 +88,36 @@ class Register extends Basic
$referrer_source = !empty($params["referrer_source"]) ? $params["referrer_source"] : 0; $referrer_source = !empty($params["referrer_source"]) ? $params["referrer_source"] : 0;
$last_login_ip = ip2long($this->request->ip()); $last_login_ip = ip2long($this->request->ip());
$msg = $this->service_->userRegister($phone, $referrer_id, $referrer_source, $wx_union_id,$last_login_ip); $msg = $this->service_->userRegister($phone, $referrer_id, $referrer_source, $wx_union_id, $last_login_ip);
if($msg["code"] == 101){ if ($msg["code"] == 101) {
return $this->response("101",$msg["data"]); return $this->response("101", $msg["data"]);
}else{ } else {
return $this->response("200","request success",$msg["data"]); return $this->response("200", "request success", $msg["data"]);
}
}
/**
* 解绑微信
* @return \think\Response
*/
public function removeBinding()
{
$params = $this->params;
/* $params = array(
"buyer_id" => 1,
"user_id" => 12,
);*/
$checkResult = $this->validate($params, "RegisterValidate.removeBind");
if (true !== $checkResult) {
return $this->response("101", $checkResult);
} }
$is_up = $this->service_->unbundling($params["buyer_id"], $params["user_id"]);
if ($is_up > 0) {
return $this->response("200", "解绑成功");
} else {
return $this->response("101", "解绑失败");
}
} }
} }
\ No newline at end of file
...@@ -23,6 +23,35 @@ class Sublet extends Basic ...@@ -23,6 +23,35 @@ class Sublet extends Basic
$this->subletMode = new SubletModel(); $this->subletMode = new SubletModel();
} }
/**
* 委托转铺列表
* @return \think\Response
*/
public function subletList()
{
$params = $this->params;
/* $params = array(
"user_id" => 1,
"page_no" => 1,
"page_size" => 15
);*/
$user_id = $params["user_id"];
if (!$user_id) {
return $this->response("101", "用户id不能为空");
}
$pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
$pageSize = empty($params['page_size']) ? 15 : $params['page_size'];
$select_["user_id"] = $user_id;
$fields = 'id,manage_type,address_detail,FORMAT(expected_rent/100,2) as expected_rent,create_time,status,house_id';
$result = $this->subletMode->getSublet($pageNo, $pageSize, "id desc", $fields, $select_);
if (count($result) > 0)
return $this->response("200", "success", $result);
return $this->response("101", "请求异常,请稍后再试");
}
public function addSublet() public function addSublet()
{ {
$params = $this->params; $params = $this->params;
...@@ -59,7 +88,7 @@ class Sublet extends Basic ...@@ -59,7 +88,7 @@ class Sublet extends Basic
if (!isset($params["expected_rent"])) { if (!isset($params["expected_rent"])) {
return $this->response("101", "期望租金不能为空"); return $this->response("101", "期望租金不能为空");
}else{ } else {
$params["expected_rent"] = $params["expected_rent"] * 100; $params["expected_rent"] = $params["expected_rent"] * 100;
} }
......
...@@ -52,6 +52,7 @@ class WxSdk extends Basic ...@@ -52,6 +52,7 @@ class WxSdk extends Basic
} }
$wx_union_id = $params["wx_union_id"]; $wx_union_id = $params["wx_union_id"];
$buyer_nick = $params["buyer_nick"];
// 验证open_id是否已经存在,存在则更新 // 验证open_id是否已经存在,存在则更新
$wxInfoObj = $this->wxInfoModel->getWxInfoByOpenId($wx_union_id); $wxInfoObj = $this->wxInfoModel->getWxInfoByOpenId($wx_union_id);
...@@ -84,11 +85,13 @@ class WxSdk extends Basic ...@@ -84,11 +85,13 @@ class WxSdk extends Basic
$data["id"] = $user_id; $data["id"] = $user_id;
$data["user_nick"] = $user_nick; $data["user_nick"] = $user_nick;
$data["buyer_id"] = $id;
$data["buyer_nick"] = $buyer_nick;
$data["user_phone"] = $user_phone; $data["user_phone"] = $user_phone;
$data["user_pic"] = !empty($user_pic) ? HEADERIMGURL . $user_pic : $other_pic; $data["user_pic"] = !empty($user_pic) ? HEADERIMGURL . $user_pic : $other_pic;
$data["AuthToken"] = $jwt->createToken($jwt_data);; $data["AuthToken"] = $jwt->createToken($jwt_data);;
return $this->response("200", "request success", $data ); return $this->response("200", "request success", $data);
} elseif ($id > 0 && count($user_info) <= 0) { } elseif ($id > 0 && count($user_info) <= 0) {
return $this->response("200", "request success"); return $this->response("200", "request success");
} else { } else {
......
...@@ -40,16 +40,11 @@ class RegisterService ...@@ -40,16 +40,11 @@ class RegisterService
//todo 1.判断是否有此用户,包涵未激活或者冻结, 2.无此用户则注册,返回AuthToken ,3有则登录返回AuthToken //todo 1.判断是否有此用户,包涵未激活或者冻结, 2.无此用户则注册,返回AuthToken ,3有则登录返回AuthToken
//判断用户是否注册 //判断用户是否注册
$conditions["user_phone"] = $phone; $conditions["user_phone"] = $phone;
$fields = "id,user_nick,user_pic,sex,agent_id,referrer_id,referrer_source,user_phone,status"; $fields = "id,buyer_id,user_nick,user_pic,other_pic,sex,agent_id,referrer_id,referrer_source,user_phone,status";
$user_info = $this->userModel->getUserByWhere($conditions, $fields); $user_info = $this->userModel->getUserByWhere($conditions, $fields);
$buyer_id = 0; $buyer_id = $sex = $id = $status = $agent_id = 0;
$user_nick = ""; $buyer_nick = $user_nick = $other_pic = "";
$sex = 0;
$id = 0;
$status = 0;
$agent_id = 0;
$other_pic = "";
if (count($user_info) > 0) { if (count($user_info) > 0) {
switch ((int)$user_info[0]["status"]) { switch ((int)$user_info[0]["status"]) {
...@@ -69,9 +64,11 @@ class RegisterService ...@@ -69,9 +64,11 @@ class RegisterService
return [ "code" => 101, "data" => "该帐号异常" ]; return [ "code" => 101, "data" => "该帐号异常" ];
} }
$user_nick = $user_info[0]["user_nick"]; $user_nick = $user_info[0]["user_nick"];
$buyer_id = $user_info[0]["buyer_id"];
$sex = $user_info[0]["sex"]; $sex = $user_info[0]["sex"];
$agent_id = $user_info[0]["agent_id"]; $agent_id = $user_info[0]["agent_id"];
$id = $user_info[0]["id"]; $id = $user_info[0]["id"];
$other_pic = $user_info[0]["other_pic"];
} }
// 验证union_id是否已经存在, // 验证union_id是否已经存在,
...@@ -81,12 +78,15 @@ class RegisterService ...@@ -81,12 +78,15 @@ class RegisterService
$wxInfoArr = $this->wxInfoModel->getWxInfoByOpenId($wx_union_id, $field); $wxInfoArr = $this->wxInfoModel->getWxInfoByOpenId($wx_union_id, $field);
if (count($wxInfoArr) > 0) { if (count($wxInfoArr) > 0) {
$buyer_id = $wxInfoArr[0]["id"]; $buyer_id = $wxInfoArr[0]["id"];
$buyer_nick = $wxInfoArr[0]["buyer_nick"];
$user_nick = !empty($user_nick) ? $user_nick : $wxInfoArr[0]["buyer_nick"]; $user_nick = !empty($user_nick) ? $user_nick : $wxInfoArr[0]["buyer_nick"];
$sex = !empty($sex) ? $sex : $wxInfoArr[0]["sex"]; $sex = !empty($sex) ? $sex : $wxInfoArr[0]["sex"];
$other_pic = $wxInfoArr[0]["buyer_img"]; $other_pic = $wxInfoArr[0]["buyer_img"];
} else { } else {
return [ "code" => 101, "data" => "没有找到授权信息" ]; return [ "code" => 101, "data" => "没有找到授权信息" ];
} }
//todo 此处有个关系,解绑上一个的id
$this->userModel->unbundlingWx([ "buyer_id" => $buyer_id ]);
} }
//判断邀请关系 if邀请人是用户的话则此客户的盘方修改为邀请人的盘方 //判断邀请关系 if邀请人是用户的话则此客户的盘方修改为邀请人的盘方
...@@ -94,8 +94,6 @@ class RegisterService ...@@ -94,8 +94,6 @@ class RegisterService
$agent_id = $this->inviteRelationship($referrer_id, $referrer_source); $agent_id = $this->inviteRelationship($referrer_id, $referrer_source);
} }
//todo 此处有个关系,解绑上一个的id
$this->userModel->unbundlingWx($buyer_id);
$userArr = $this->userBin($user_nick, $sex, $id, $buyer_id, $status, $agent_id, $phone, $referrer_id, $referrer_source, $last_login_ip, $other_pic); $userArr = $this->userBin($user_nick, $sex, $id, $buyer_id, $status, $agent_id, $phone, $referrer_id, $referrer_source, $last_login_ip, $other_pic);
...@@ -112,6 +110,8 @@ class RegisterService ...@@ -112,6 +110,8 @@ class RegisterService
$AuthToken = $jwt->createToken($jwt_data); $AuthToken = $jwt->createToken($jwt_data);
$data["id"] = $id; $data["id"] = $id;
$data["buyer_id"] = $buyer_id;
$data["buyer_nick"] = $buyer_nick;
$data["user_nick"] = $user_nick; $data["user_nick"] = $user_nick;
$data["user_phone"] = $phone; $data["user_phone"] = $phone;
$data["user_pic"] = !empty($user_info[0]["user_pic"]) ? HEADERIMGURL . $user_info[0]["user_pic"] : $other_pic; $data["user_pic"] = !empty($user_info[0]["user_pic"]) ? HEADERIMGURL . $user_info[0]["user_pic"] : $other_pic;
...@@ -120,6 +120,18 @@ class RegisterService ...@@ -120,6 +120,18 @@ class RegisterService
} }
/**
* @param $buyer_id
* @param $user_id
* @return int
*/
public function unbundling($buyer_id, $user_id)
{
$params["buyer_id"] = $buyer_id;
$params["user_id"] = $user_id;
return $this->userModel->unbundlingWx($params);
}
/** /**
* 组装bin * 组装bin
* @param $user_nick * @param $user_nick
...@@ -146,8 +158,8 @@ class RegisterService ...@@ -146,8 +158,8 @@ class RegisterService
$userParams["first_login_time"] = date("Y-m-d H:i:s", time()); //记录第一次登录时间排除邀请注册 $userParams["first_login_time"] = date("Y-m-d H:i:s", time()); //记录第一次登录时间排除邀请注册
$push = new PushMessageService(); $push = new PushMessageService();
$content = '你邀请的客户'.$user_nick.'-'.$phone.'手机号成功下载登录App'; $content = '你邀请的客户' . $user_nick . '-' . $phone . '手机号成功下载登录App';
$push->pushMessageById($referrer_id,'邀请注册', $content); $push->pushMessageById($referrer_id, '邀请注册', $content);
} }
} }
$userParams["buyer_id"] = $buyer_id; $userParams["buyer_id"] = $buyer_id;
...@@ -155,7 +167,10 @@ class RegisterService ...@@ -155,7 +167,10 @@ class RegisterService
$userParams["user_nick"] = $user_nick; $userParams["user_nick"] = $user_nick;
$userParams["sex"] = $sex; $userParams["sex"] = $sex;
$userParams["status"] = $status; $userParams["status"] = $status;
if ($other_pic) {
$userParams["other_pic"] = $other_pic; $userParams["other_pic"] = $other_pic;
}
$userParams["agent_id"] = $agent_id; $userParams["agent_id"] = $agent_id;
$userParams["referrer_id"] = $referrer_id; $userParams["referrer_id"] = $referrer_id;
$userParams["referrer_source"] = $referrer_source; $userParams["referrer_source"] = $referrer_source;
......
...@@ -14,6 +14,8 @@ use think\Validate; ...@@ -14,6 +14,8 @@ use think\Validate;
class RegisterValidate extends Validate class RegisterValidate extends Validate
{ {
protected $rule = [ protected $rule = [
'user_id' => 'require|number',
'buyer_id' => 'require|number',
'wx_union_id' => 'require|length:10,50', 'wx_union_id' => 'require|length:10,50',
'code' => 'require|number', 'code' => 'require|number',
'device_id' => 'require', 'device_id' => 'require',
...@@ -21,6 +23,10 @@ class RegisterValidate extends Validate ...@@ -21,6 +23,10 @@ class RegisterValidate extends Validate
]; ];
protected $message = [ protected $message = [
'user_id.require' => 'user_id为必填字段',
'user_id.number' => 'user_id只能为数字',
'buyer_id.require' => 'buyer_id为必填字段',
'buyer_id.number' => 'buyer_id只能为数字',
'wx_union_id.require' => '微信union_id不能为空', 'wx_union_id.require' => '微信union_id不能为空',
'wx_union_id.length:10,50' => '微信union_id错误', 'wx_union_id.length:10,50' => '微信union_id错误',
'phone.regex' => '手机号格式不正确', 'phone.regex' => '手机号格式不正确',
...@@ -32,5 +38,6 @@ class RegisterValidate extends Validate ...@@ -32,5 +38,6 @@ class RegisterValidate extends Validate
protected $scene = [ protected $scene = [
'verify' => [ 'phone', 'device_id' ], 'verify' => [ 'phone', 'device_id' ],
'register' => [ 'phone', 'device_id', 'code' ], 'register' => [ 'phone', 'device_id', 'code' ],
'removeBind' => [ 'user_id', 'buyer_id' ],
]; ];
} }
\ No newline at end of file
...@@ -71,7 +71,7 @@ class Evaluation extends Basic ...@@ -71,7 +71,7 @@ class Evaluation extends Basic
} }
//搜索条件 end //搜索条件 end
$fields_evaluate = 'user_nick,user_phone,evaluate_grade,evaluate_content,a.create_time,c.name,c.phone'; $fields_evaluate = 'user_nick,user_phone,evaluate_grade,evaluate_content,a.create_time,c.name,c.phone,IF(d.report_id>0, d.report_id, e.report_id) AS report_id';
$data['list'] = $this->evaluateModel->findEvaluationList($pageNo, $pageSize, 'a.id desc', $fields_evaluate, $where); $data['list'] = $this->evaluateModel->findEvaluationList($pageNo, $pageSize, 'a.id desc', $fields_evaluate, $where);
$data['total'] = $this->evaluateModel->findEvaluationListCount($fields_evaluate, $where); $data['total'] = $this->evaluateModel->findEvaluationListCount($fields_evaluate, $where);
......
...@@ -107,6 +107,11 @@ class Evaluate extends Model ...@@ -107,6 +107,11 @@ class Evaluate extends Model
->alias('a') ->alias('a')
->join('u_users b', 'a.user_id = b.id', 'left') ->join('u_users b', 'a.user_id = b.id', 'left')
->join('a_agents c', 'a.agents_id = c.id', 'left') ->join('a_agents c', 'a.agents_id = c.id', 'left')
->join('o_march_in d', 'a.record_id=d.id and a.source=10', 'left')
->join('o_bargain e', 'a.record_id=e.id and a.source =20', 'left')
->where('is_show', 0) ->where('is_show', 0)
->where($params) ->where($params)
->order($order_) ->order($order_)
......
...@@ -60,7 +60,7 @@ class Users extends Model ...@@ -60,7 +60,7 @@ class Users extends Model
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getUserForInviteList($pageNo, $pageSize,$param, $fields = 'id,user_phone') public function getUserForInviteList($pageNo, $pageSize, $param, $fields = 'id,user_phone')
{ {
$data = $this $data = $this
->field($fields) ->field($fields)
...@@ -453,7 +453,7 @@ class Users extends Model ...@@ -453,7 +453,7 @@ class Users extends Model
* @param $params * @param $params
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
*/ */
public function getAddUserList($params,$field,$page_no,$page_size) public function getAddUserList($params, $field, $page_no, $page_size)
{ {
$where_ = []; $where_ = [];
if (isset($params["agent_id"])) { if (isset($params["agent_id"])) {
...@@ -647,12 +647,22 @@ class Users extends Model ...@@ -647,12 +647,22 @@ class Users extends Model
} }
/** /**
* @param $buyer_id * @param $params
* @return int * @return int
*/ */
public function unbundlingWx($buyer_id) public function unbundlingWx($params)
{ {
return $this->where("buyer_id", $buyer_id)->setField("buyer_id", 0);
$where_ = [];
if (!isset($params["buyer_id"])) {
$where_["buyer_id"] = $params["buyer_id"];
}else{//防止传入错误参数修改掉大面积数据此字段必填
return 0;
}
if (!isset($params["user_id"])) {
$where_["id"] = $params["user_id"];
}
return $this->where($where_)->setField("buyer_id", 0);
} }
} }
...@@ -305,6 +305,7 @@ Route::group('api', [ ...@@ -305,6 +305,7 @@ Route::group('api', [
'addSublet' => [ 'api/Sublet/addSublet', [ 'method' => 'post|get' ] ], 'addSublet' => [ 'api/Sublet/addSublet', [ 'method' => 'post|get' ] ],
'subletList' => [ 'api/Sublet/subletList', [ 'method' => 'post|get' ] ],//委托转铺列表
//Version //Version
...@@ -316,6 +317,7 @@ Route::group('api', [ ...@@ -316,6 +317,7 @@ Route::group('api', [
'sendCode' => [ 'api/Register/registerSendCode', [ 'method' => 'POST' ] ], 'sendCode' => [ 'api/Register/registerSendCode', [ 'method' => 'POST' ] ],
'userVerify' => [ 'api/Register/registerVerify', [ 'method' => 'POST' ] ], 'userVerify' => [ 'api/Register/registerVerify', [ 'method' => 'POST' ] ],
'removeBind' => [ 'api/Register/removeBinding', [ 'method' => 'POST' ] ],
]); ]);
......
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