...
|
...
|
@@ -16,6 +16,7 @@ use think\Db; |
|
|
use app\common\controller\Frontend;
|
|
|
use app\api\model\UserHouse;
|
|
|
use app\api\model\House;
|
|
|
use app\api\model\HousePhone;
|
|
|
|
|
|
/**
|
|
|
* 微信接口
|
...
|
...
|
@@ -91,11 +92,23 @@ class Wechat extends Frontend |
|
|
private function joinHouse($house_id,$openid){
|
|
|
$user = WechatService::getUserByOpenid($openid);
|
|
|
$house = House::get($house_id);
|
|
|
// 发送内容
|
|
|
$content = "欢迎关注{$house['name']}!";
|
|
|
$phoneList = HousePhone::where('house_id',$house_id)->select();
|
|
|
if(!empty($phoneList)){
|
|
|
$content .= "\n";
|
|
|
foreach ($phoneList as $v) {
|
|
|
$content .= "\n"."{$v['name']}:{$v['phone']}";
|
|
|
}
|
|
|
}
|
|
|
$content .= "\n\n"."业主账号:%u"
|
|
|
."\n\n"."<a href='https://weixin.qq.com/'>查看物业公告</a>"
|
|
|
."\n\n"."<a href='https://weixin.qq.com/'>给物业留言</a>";
|
|
|
//*------------------------已有账号,直接加入小区-----------------------*/
|
|
|
if($user){
|
|
|
$info = UserHouse::get(['user_id'=>$user['id'],'house_id'=>$house_id]);
|
|
|
if(!empty($info) && $info['status'] == 2){
|
|
|
return "您已加入【{$house['name']}】社区";
|
|
|
return sprintf($content,$user['id_num']);
|
|
|
}
|
|
|
Db::startTrans();
|
|
|
try {
|
...
|
...
|
@@ -128,7 +141,7 @@ class Wechat extends Frontend |
|
|
Db::rollback();
|
|
|
return $e->getMessage();
|
|
|
}
|
|
|
return "您已成功加入【{$house['name']}】社区";
|
|
|
return sprintf($content,$user['id_num']);
|
|
|
}
|
|
|
/*------------------------没有账号,先注册,后加入小区-----------------------*/
|
|
|
$access_token = WechatService::getAccessToken();
|
...
|
...
|
@@ -180,7 +193,7 @@ class Wechat extends Frontend |
|
|
Db::rollback();
|
|
|
return $e->getMessage();
|
|
|
}
|
|
|
return "您已加入【{$house['name']}】社区";
|
|
|
return sprintf($content,$user['id_num']);
|
|
|
}
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|