...
|
...
|
@@ -16,6 +16,7 @@ use think\Exception; |
|
|
use think\exception\PDOException;
|
|
|
use think\Validate;
|
|
|
use think\Cache;
|
|
|
use app\api\model\House;
|
|
|
use app\api\model\HouseJoin;
|
|
|
use app\api\model\UserHouse;
|
|
|
use app\api\model\UserMoneyLog;
|
...
|
...
|
@@ -118,7 +119,7 @@ class User extends Api |
|
|
public function index()
|
|
|
{
|
|
|
$user = $this->auth->getUser();
|
|
|
$house = \app\api\model\House::get($user['house_id']);
|
|
|
$house = House::get($user['house_id']);
|
|
|
$data = [
|
|
|
// 当前小区信息
|
|
|
'house' => !empty($house) ? $house->visible(['id','name'])->toArray() : [],
|
...
|
...
|
@@ -202,7 +203,7 @@ class User extends Api |
|
|
* @ApiTitle (个人中心-选择社区-切换)
|
|
|
* @ApiSummary (个人中心-选择社区-切换)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/user/houseUnbind)
|
|
|
* @ApiRoute (/api/user/houseChange)
|
|
|
*
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="house_id", type="inter", required=true, description="小区ID")
|
...
|
...
|
@@ -244,15 +245,27 @@ class User extends Api |
|
|
$user = $this->auth->getUser();
|
|
|
$house_id = $this->request->param('house_id');
|
|
|
empty($house_id) && $this->error('缺少必要参数');
|
|
|
|
|
|
$house = House::get($house_id);
|
|
|
empty($house) && $this->error('社区信息不存在');
|
|
|
|
|
|
$info = UserHouse::get(['user_id'=>$user['id'],'house_id'=>$house_id]);
|
|
|
empty($info) && $this->error('绑定信息不存在');
|
|
|
|
|
|
$info['status'] != 2 && $this->error('您还没有绑定该小区,无法解绑');
|
|
|
// 启动事务
|
|
|
Db::startTrans();
|
|
|
try{
|
|
|
$info->delete();
|
|
|
$user->house_id = 0;
|
|
|
$user->save();
|
|
|
// 解绑当前小区
|
|
|
if($user['house_id'] == $house_id){
|
|
|
$user->house_id = 0;
|
|
|
$user->save();
|
|
|
}
|
|
|
// 绑定数量减1
|
|
|
if($house['bindnum'] > 0){
|
|
|
House::where('id',$house_id)->setDec('bindnum');
|
|
|
}
|
|
|
// 提交事务
|
|
|
Db::commit();
|
|
|
} catch (\Exception $e) {
|
...
|
...
|
|