|
@@ -6,6 +6,7 @@ import com.rongwe.zhsw.system.domain.SwBillManagementUnpaidDo;
|
|
|
import com.rongwe.zhsw.system.domain.SwUserManagementDo;
|
|
|
import com.rongwe.zhsw.system.domain.SwUserWechatDo;
|
|
|
import com.rongwe.zhsw.system.vo.AccountBindVo;
|
|
|
+import com.rongwe.zhsw.system.vo.AccountUnbindVo;
|
|
|
import com.rongwe.zhsw.system.vo.SwUserManagementVo;
|
|
|
import com.rongwe.zhsw.system.vo.WeChatHomePageVo;
|
|
|
import com.rongwei.rwcommon.base.BaseDo;
|
|
@@ -25,7 +26,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.Collections;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -56,16 +56,16 @@ public class AccountServiceImpl implements AccountService {
|
|
|
String bindWaterCompany = accountBindVo.getBindWaterCompany();
|
|
|
WeChatUtils.checkWater(bindWaterCompany);
|
|
|
SwUserManagementVo swUserManagementVo = swUserManagementService.getBaseMapper().getDataByAccountAndDsKey(accountBindVo.getAccountNum(), bindWaterCompany);
|
|
|
- if(swUserManagementVo==null){
|
|
|
- log.error("户号不存在:{}",accountBindVo.getAccountNum());
|
|
|
+ if (swUserManagementVo == null) {
|
|
|
+ log.error("户号不存在:{}", accountBindVo.getAccountNum());
|
|
|
throw new CustomException("户号不存在!");
|
|
|
}
|
|
|
if (!swUserManagementVo.getUsername().equals(accountBindVo.getAccountName())) {
|
|
|
log.error("户名错误");
|
|
|
throw new CustomException("户名错误!");
|
|
|
}
|
|
|
- String openId=WeChatUtils.getCurrentWeChatOpenId();
|
|
|
- if(swUserManagementVo.getWechatSign().contains(openId)){
|
|
|
+ String openId = WeChatUtils.getCurrentWeChatOpenId();
|
|
|
+ if (swUserManagementVo.getWechatSign().contains(openId)) {
|
|
|
log.error("当前户号已绑定");
|
|
|
throw new CustomException("户号已绑定!");
|
|
|
}
|
|
@@ -91,8 +91,8 @@ public class AccountServiceImpl implements AccountService {
|
|
|
// 如果是默认账户的 将其余租户的默认关系变为否
|
|
|
List<String> otherDsKey = accountBindVo.getOtherDsKey();
|
|
|
otherDsKey.remove(accountBindVo.getBindWaterCompany());
|
|
|
- if(swUserWechat.getDefaultaccount() && !otherDsKey.isEmpty()){
|
|
|
- swUserManagementService.getBaseMapper().updateDefaultAccount(otherDsKey,openId);
|
|
|
+ if (swUserWechat.getDefaultaccount() && !otherDsKey.isEmpty()) {
|
|
|
+ swUserManagementService.getBaseMapper().updateDefaultAccount(otherDsKey, openId);
|
|
|
}
|
|
|
// 更新缓存中的 业主信息
|
|
|
otherDsKey.add(accountBindVo.getBindWaterCompany());
|
|
@@ -102,12 +102,13 @@ public class AccountServiceImpl implements AccountService {
|
|
|
// 修改用户的绑定关系
|
|
|
swUserManagementService.update(new LambdaUpdateWrapper<SwUserManagementDo>()
|
|
|
.eq(SwUserManagementDo::getId, swUserManagementVo.getId())
|
|
|
- .set(SwUserManagementDo::getWechatbindstatus,1));
|
|
|
+ .set(SwUserManagementDo::getWechatbindstatus, 1));
|
|
|
return R.ok(allOwnerByOpenId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 切换默认账户
|
|
|
+ *
|
|
|
* @param accountBindVo
|
|
|
* @return
|
|
|
*/
|
|
@@ -118,6 +119,7 @@ public class AccountServiceImpl implements AccountService {
|
|
|
|
|
|
/**
|
|
|
* 获取当前账户的信息
|
|
|
+ *
|
|
|
* @param accountNumber
|
|
|
* @return
|
|
|
*/
|
|
@@ -126,7 +128,7 @@ public class AccountServiceImpl implements AccountService {
|
|
|
List<SwUserManagementDo> list = swUserManagementService.list(new LambdaQueryWrapper<SwUserManagementDo>()
|
|
|
.eq(BaseDo::getDeleted, "0")
|
|
|
.eq(SwUserManagementDo::getUsernumber, accountNumber));
|
|
|
- if(list.isEmpty()){
|
|
|
+ if (list.isEmpty()) {
|
|
|
throw new CustomException("当前户号不存在,请联系水务公司");
|
|
|
}
|
|
|
// 获取所有待缴费账单
|
|
@@ -146,4 +148,26 @@ public class AccountServiceImpl implements AccountService {
|
|
|
List<SwUserManagementVo> userByDsKey = weChatLoginService.getAllOwnerByOpenId(currentWeChatOpenId, null);
|
|
|
return R.ok(userByDsKey);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R unbind(AccountUnbindVo accountUnbindVo) {
|
|
|
+ String account = accountUnbindVo.getAccount();
|
|
|
+ String dsKey = accountUnbindVo.getDeKey();
|
|
|
+ if (StringUtils.isBlank(account)) {
|
|
|
+ throw new CustomException("解绑的户号为空");
|
|
|
+ }
|
|
|
+ String currentWeChatOpenId = WeChatUtils.getCurrentWeChatOpenId();
|
|
|
+ // 删除绑定关系
|
|
|
+ swUserManagementService.getBaseMapper().unbindAccount(dsKey, currentWeChatOpenId,account );
|
|
|
+ // 默认不刷新直接返回
|
|
|
+ if(!accountUnbindVo.getRefresh()){
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ List<String> otherDsKeys = accountUnbindVo.getOtherDsKeys();
|
|
|
+ if (otherDsKeys == null || otherDsKeys.isEmpty()) {
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ List<SwUserManagementVo> allOwnerByOpenId = weChatLoginService.getAllOwnerByOpenId(currentWeChatOpenId, otherDsKeys);
|
|
|
+ return R.ok(allOwnerByOpenId);
|
|
|
+ }
|
|
|
}
|