From d46c0a9645b58f52386fd43704484f9bae5abbb9 Mon Sep 17 00:00:00 2001 From: xhxu Date: Mon, 17 May 2021 10:17:24 +0800 Subject: [PATCH] tt --- .../controller/UserBasicInfoController.java | 73 +++++++++++++++++-- .../service/WxCUserBasicInfoService.java | 2 +- .../AliBusinessCircleOrderServiceImpl.java | 2 +- .../impl/WxCUserBasicInfoServiceImpl.java | 16 +++- .../impl/WxThirdPartyOrdersServiceImpl.java | 2 +- .../main/resources/mapper/WxCUserMapper.xml | 6 +- 6 files changed, 88 insertions(+), 13 deletions(-) diff --git a/mallinkPublicApi/src/main/java/com/iformall/controller/UserBasicInfoController.java b/mallinkPublicApi/src/main/java/com/iformall/controller/UserBasicInfoController.java index 227def7c5..0f380d2c0 100644 --- a/mallinkPublicApi/src/main/java/com/iformall/controller/UserBasicInfoController.java +++ b/mallinkPublicApi/src/main/java/com/iformall/controller/UserBasicInfoController.java @@ -2,10 +2,12 @@ package com.iformall.controller; import com.iformall.common.ErrorCode; import com.iformall.common.ResultData; +import com.iformall.domain.po.WxCUser; import com.iformall.domain.po.WxCUserBasicInfo; import com.iformall.domain.po.WxLevelConfig; import com.iformall.domain.po.base.TenantEntity; import com.iformall.service.WxCUserBasicInfoService; +import com.iformall.service.WxCUserService; import com.iformall.service.WxLevelConfigService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -26,6 +28,9 @@ public class UserBasicInfoController extends BaseController { private final Logger logger = LoggerFactory.getLogger(this.getClass()); + @Autowired + private WxCUserService wxCUserService; + @Autowired private WxCUserBasicInfoService wxCUserBasicInfoService; @@ -42,6 +47,9 @@ public class UserBasicInfoController extends BaseController { public ResultData userRegister(@RequestBody Map map) { logger.info("UserBasicInfoController >>>>>>>>>>>> userRegister >>>>>>>>>>>>>"+map.toString()); String phone = (String) map.get("phone"); + String nickName = (String) map.get("nickName"); + String sexStr = (String) map.get("sex"); + String avatarUrl = (String) map.get("avatarUrl"); if(StringUtils.isBlank(phone)){ return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"手机号不能为空"); } @@ -49,22 +57,71 @@ public class UserBasicInfoController extends BaseController { return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"手机号格式不正确"); } + Integer sex = 0; + if(StringUtils.isNotBlank(sexStr)){ + try { + sex = Integer.parseInt(sexStr); + } catch (NumberFormatException e) { +// e.printStackTrace(); + } + } + TenantEntity tenantEntity = getTenantInfo(); - WxCUserBasicInfo userBasicInfo = wxCUserBasicInfoService.registerByPhone(tenantEntity, phone); + WxCUserBasicInfo userBasicInfo = wxCUserBasicInfoService.registerByPhone(tenantEntity, phone,nickName,sex,avatarUrl); + + this.setLevel(userBasicInfo,tenantEntity); + + return new ResultData(userBasicInfo); + } + /** + * + * @param + * @return + */ + @PostMapping("/get") + @ApiOperation(value = "会员", notes = "") + public ResultData getUserInfo(@RequestBody Map map) { + logger.info("UserBasicInfoController >>>>>>>>>>>> getUserInfo >>>>>>>>>>>>>"+map.toString()); + String phone = (String) map.get("phone"); + String openId = (String) map.get("openId"); + WxCUserBasicInfo basicInfo = null; + if(StringUtils.isBlank(phone) && StringUtils.isBlank(openId)){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); + } + if(StringUtils.isNotBlank(phone)){ + basicInfo = wxCUserBasicInfoService.findInfoByPhone(getTenantInfo(), phone); + } + if(basicInfo == null && StringUtils.isNotBlank(openId)){ + WxCUser wxCUserQ = new WxCUser(); + wxCUserQ.updateTenantInfo(getTenantInfo()); + wxCUserQ.setOpenId(openId); + WxCUser byOpenId = wxCUserService.getByOpenId(wxCUserQ); + if(byOpenId != null && byOpenId.basicInfoIs()){ + basicInfo = wxCUserBasicInfoService.getById(byOpenId.getUserId(),getTenantInfo().getFinalTenantId()); + } + } + if(basicInfo == null){ + return new ResultData(ErrorCode.USER_IS_EMPTY); + } + + this.setLevel(basicInfo,getTenantInfo()); + + return new ResultData(basicInfo); + } + + private void setLevel(WxCUserBasicInfo basicInfo,TenantEntity tenantEntity){ List levelList = wxLevelConfigService.getByTenantInfo(tenantEntity); - userBasicInfo.setLevelList(levelList); - userBasicInfo.setLevel(WxLevelConfigService.DEFAULT_LEVEL); - if(userBasicInfo.getPoins() != null && userBasicInfo.getPoins() > 0){ + basicInfo.setLevelList(levelList); + basicInfo.setLevel(WxLevelConfigService.DEFAULT_LEVEL); + if(basicInfo.getPoins() != null && basicInfo.getPoins() > 0){ for (WxLevelConfig levelConfig : levelList) { - if (userBasicInfo.getPoins() >= levelConfig.getPoints()) { - userBasicInfo.setLevel(levelConfig.getLevel()); + if (basicInfo.getPoins() >= levelConfig.getPoints()) { + basicInfo.setLevel(levelConfig.getLevel()); } } } - - return new ResultData(userBasicInfo); } } diff --git a/mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java b/mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java index 6ddbadcef..5bcc4ab3c 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java @@ -175,7 +175,7 @@ public interface WxCUserBasicInfoService { void updateQrCode(WxCUserBasicInfo wxCUserBasicInfo); - WxCUserBasicInfo registerByPhone(TenantEntity tenantEntity, String phone); + WxCUserBasicInfo registerByPhone(TenantEntity tenantEntity, String phone, String nickName, Integer sex, String avatarUrl); int addCredit(Long userId, TenantEntity tenantInfo, EnumScoreType wechatPhone); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/AliBusinessCircleOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/AliBusinessCircleOrderServiceImpl.java index 05eebad67..a6c058d9d 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/AliBusinessCircleOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/AliBusinessCircleOrderServiceImpl.java @@ -117,7 +117,7 @@ public class AliBusinessCircleOrderServiceImpl implements AliBusinessCircleOrder AliPayCUser aliUser = aliPayCUserService.getByAliPayUserId(userQ); if(aliUser != null){ // WxCUserBasicInfo infoByPhone = wxCUserBasicInfoService.findInfoByPhone(aliUser, aliUser.getPhone()); - WxCUserBasicInfo infoByPhone = wxCUserBasicInfoService.registerByPhone(aliUser, aliUser.getPhone()); + WxCUserBasicInfo infoByPhone = wxCUserBasicInfoService.registerByPhone(aliUser, aliUser.getPhone(),aliUser.getName(),null,null); if(infoByPhone != null ){ record.setCUserId(infoByPhone.getId()); }else{ diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java index d9cac6379..8de95cd9e 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java @@ -638,7 +638,7 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc } @Override - public WxCUserBasicInfo registerByPhone(TenantEntity tenantEntity, String phone) { + public WxCUserBasicInfo registerByPhone(TenantEntity tenantEntity, String phone, String nickName, Integer sex, String avatarUrl) { if (StringUtils.isBlank(phone)) return null; @@ -648,7 +648,21 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc basicInfo.setTenantId("," + tenantEntity.getTenantId() + ","); basicInfo.setFinalTenantId(tenantEntity.getFinalTenantId()); basicInfo.setPhone(phone); + basicInfo.setNickName(nickName); + basicInfo.setSex(sex); + basicInfo.setAvatarUrl(avatarUrl); this.save(basicInfo); + }else{ + if(StringUtils.isNotBlank(nickName)){ + basicInfo.setNickName(nickName); + } + if(sex != null){ + basicInfo.setSex(sex); + } + if(StringUtils.isNotBlank(avatarUrl)){ + basicInfo.setAvatarUrl(avatarUrl); + } + wxCUserBasicInfoMapper.updateById(basicInfo); } return basicInfo; diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxThirdPartyOrdersServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxThirdPartyOrdersServiceImpl.java index 7e7bb4914..e49f86517 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxThirdPartyOrdersServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxThirdPartyOrdersServiceImpl.java @@ -131,7 +131,7 @@ public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService basicInfo = wxCUserBasicInfoService.getById(userId, record.getFinalTenantId()); } if(basicInfo == null){ - basicInfo = wxCUserBasicInfoService.registerByPhone(record, record.getUserPhone()); + basicInfo = wxCUserBasicInfoService.registerByPhone(record, record.getUserPhone(),null,null,null); } if(basicInfo != null){ diff --git a/mallinkService/src/main/resources/mapper/WxCUserMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserMapper.xml index cd4ca2b36..091a26c95 100644 --- a/mallinkService/src/main/resources/mapper/WxCUserMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCUserMapper.xml @@ -269,7 +269,11 @@