|
@@ -16,6 +16,7 @@ use think\Db; |
|
@@ -16,6 +16,7 @@ use think\Db; |
16
|
use app\common\controller\Frontend;
|
16
|
use app\common\controller\Frontend;
|
17
|
use app\api\model\UserHouse;
|
17
|
use app\api\model\UserHouse;
|
18
|
use app\api\model\House;
|
18
|
use app\api\model\House;
|
|
|
19
|
+use app\api\model\HousePhone;
|
19
|
|
20
|
|
20
|
/**
|
21
|
/**
|
21
|
* 微信接口
|
22
|
* 微信接口
|
|
@@ -91,11 +92,20 @@ class Wechat extends Frontend |
|
@@ -91,11 +92,20 @@ class Wechat extends Frontend |
91
|
private function joinHouse($house_id,$openid){
|
92
|
private function joinHouse($house_id,$openid){
|
92
|
$user = WechatService::getUserByOpenid($openid);
|
93
|
$user = WechatService::getUserByOpenid($openid);
|
93
|
$house = House::get($house_id);
|
94
|
$house = House::get($house_id);
|
|
|
95
|
+ // 发送内容
|
|
|
96
|
+ $content = "欢迎关注{$house['name']}!"."\n\n";
|
|
|
97
|
+ $phoneList = HousePhone::where('house_id',$house_id)->select();
|
|
|
98
|
+ foreach ($phoneList as $v) {
|
|
|
99
|
+ $content .= "{$v['name']}:{$v['phone']}"."\n";
|
|
|
100
|
+ }
|
|
|
101
|
+ $content .= "\n"."业主账号:%u"
|
|
|
102
|
+ ."\n\n"."<a href='https://weixin.qq.com/'>查看物业公告</a>"
|
|
|
103
|
+ ."\n\n"."<a href='https://weixin.qq.com/'>给物业留言</a>";
|
94
|
//*------------------------已有账号,直接加入小区-----------------------*/
|
104
|
//*------------------------已有账号,直接加入小区-----------------------*/
|
95
|
if($user){
|
105
|
if($user){
|
96
|
$info = UserHouse::get(['user_id'=>$user['id'],'house_id'=>$house_id]);
|
106
|
$info = UserHouse::get(['user_id'=>$user['id'],'house_id'=>$house_id]);
|
97
|
if(!empty($info) && $info['status'] == 2){
|
107
|
if(!empty($info) && $info['status'] == 2){
|
98
|
- return "您已加入【{$house['name']}】社区";
|
108
|
+ return sprintf($content,$user['id_num']);
|
99
|
}
|
109
|
}
|
100
|
Db::startTrans();
|
110
|
Db::startTrans();
|
101
|
try {
|
111
|
try {
|
|
@@ -128,7 +138,7 @@ class Wechat extends Frontend |
|
@@ -128,7 +138,7 @@ class Wechat extends Frontend |
128
|
Db::rollback();
|
138
|
Db::rollback();
|
129
|
return $e->getMessage();
|
139
|
return $e->getMessage();
|
130
|
}
|
140
|
}
|
131
|
- return "您已成功加入【{$house['name']}】社区";
|
141
|
+ return sprintf($content,$user['id_num']);
|
132
|
}
|
142
|
}
|
133
|
/*------------------------没有账号,先注册,后加入小区-----------------------*/
|
143
|
/*------------------------没有账号,先注册,后加入小区-----------------------*/
|
134
|
$access_token = WechatService::getAccessToken();
|
144
|
$access_token = WechatService::getAccessToken();
|
|
@@ -180,7 +190,7 @@ class Wechat extends Frontend |
|
@@ -180,7 +190,7 @@ class Wechat extends Frontend |
180
|
Db::rollback();
|
190
|
Db::rollback();
|
181
|
return $e->getMessage();
|
191
|
return $e->getMessage();
|
182
|
}
|
192
|
}
|
183
|
- return "您已加入【{$house['name']}】社区";
|
193
|
+ return sprintf($content,$user['id_num']);
|
184
|
}
|
194
|
}
|
185
|
|
195
|
|
186
|
} |
196
|
} |