| @@ -42,9 +42,6 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private WxTagsService wxTagsService; | private WxTagsService wxTagsService; | ||||
| @Autowired | |||||
| private WxCUserService wxCUserService; | |||||
| @Autowired | @Autowired | ||||
| private WxCouponOrderService wxCouponOrderService; | private WxCouponOrderService wxCouponOrderService; | ||||
| @@ -54,6 +51,54 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| WxLevelConfigService wxLevelConfigService; | WxLevelConfigService wxLevelConfigService; | ||||
| private void setUserInfoLevel(WxCUserBasicInfo info) { | |||||
| if (info.getPoins() == null || info.getPoins() == 0) { | |||||
| info.setLevel("无"); | |||||
| } else { | |||||
| info.setLevel("无"); | |||||
| List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantId(info.getTenantId()); | |||||
| for(WxLevelConfig levelConfig: levelList) { | |||||
| if (info.getPoins() >= levelConfig.getPoints()) { | |||||
| info.setLevel(levelConfig.getLevel()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| private void setUserInfoTag(WxCUserBasicInfo info) { | |||||
| if (info.getTagId() != null) { | |||||
| WxCUserTags uTag = wxCUserTagsService.getById(info.getTagId()); | |||||
| if (StringUtils.isNotBlank(uTag.getTags())) { | |||||
| List<Long> ids = JSONObject.parseArray(uTag.getTags(), Long.class); | |||||
| if (!ids.isEmpty()) { | |||||
| WxTags wxTags = new WxTags(); | |||||
| wxTags.setIds(ids); | |||||
| PageInfo<WxTags> page = wxTagsService.listAsPage(wxTags, 1, 256); | |||||
| String tagNames = ""; | |||||
| String tagIds = ""; | |||||
| List<Long> tagIdList = new ArrayList<>(); | |||||
| for (WxTags wt : page.getList()) { | |||||
| tagNames += wt.getName() + "/"; | |||||
| tagIds += wt.getId() + ","; | |||||
| tagIdList.add(wt.getId()); | |||||
| } | |||||
| if (StringUtils.isNotBlank(tagNames)) { | |||||
| info.setTagNames(tagNames.substring(0, tagNames.length() - 1)); | |||||
| } | |||||
| if (StringUtils.isNoneBlank(tagIds)) { | |||||
| info.setTagIds(tagIds.substring(0, tagIds.length() - 1)); | |||||
| } | |||||
| long count = wxCUserTagsService.findCountByTag(getTenantId(), tagIdList); | |||||
| info.setCount(count); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @ApiOperation("分页列表接口") | @ApiOperation("分页列表接口") | ||||
| @GetMapping("list") | @GetMapping("list") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @@ -74,35 +119,15 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| wxCUserBasicInfo.setTenantId(tenantId); | wxCUserBasicInfo.setTenantId(tenantId); | ||||
| wxCUserBasicInfo.setSortColumns(WxCUserBasicInfo.Field.Id_DESC); | wxCUserBasicInfo.setSortColumns(WxCUserBasicInfo.Field.Id_DESC); | ||||
| PageInfo<WxCUserBasicInfo> page = wxCUserBasicInfoService.listAsPage(wxCUserBasicInfo, pageNum, pageSize); | PageInfo<WxCUserBasicInfo> page = wxCUserBasicInfoService.listAsPage(wxCUserBasicInfo, pageNum, pageSize); | ||||
| return new ResultData(page); | |||||
| } | |||||
| private void createUserBasicInfo(WxCUser wxCUser) { | |||||
| String phone = wxCUser.getPhone(); | |||||
| if (phone != null && phone.contains("*")) { | |||||
| phone = wxCUser.getVerifyCodePhone(); | |||||
| if (page.getSize() > 0) { | |||||
| for (WxCUserBasicInfo info : page.getList()) { | |||||
| setUserInfoLevel(info); | |||||
| } | |||||
| } | } | ||||
| if (StringUtils.isBlank(phone)) | |||||
| return; | |||||
| WxCUserBasicInfo wxCUserBasicInfo = new WxCUserBasicInfo(); | |||||
| wxCUserBasicInfo.setId(wxCUser.getId()); | |||||
| wxCUserBasicInfo.setPhone(wxCUser.getPhone()); | |||||
| wxCUserBasicInfo.setTenantId(wxCUser.getTenantId()); | |||||
| wxCUserBasicInfo.setNickName(wxCUser.getNickName()); | |||||
| wxCUserBasicInfoService.save(wxCUserBasicInfo); | |||||
| return new ResultData(page); | |||||
| } | } | ||||
| // @ApiOperation("新增接口") | |||||
| // @PostMapping("add") | |||||
| // public ResultData add(@RequestBody WxCUserBasicInfo wxCUserBasicInfo) { | |||||
| // //Assert.notNull(wxCUserBasicInfo.getName(), "角色名不能为空"); | |||||
| // //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| // wxCUserBasicInfoService.saveOrUpdate(wxCUserBasicInfo); | |||||
| // return new ResultData(); | |||||
| // } | |||||
| private int checkUniquePhone(String phone, String tenantId) { | private int checkUniquePhone(String phone, String tenantId) { | ||||
| WxCUserBasicInfo baseInfoQ = new WxCUserBasicInfo(); | WxCUserBasicInfo baseInfoQ = new WxCUserBasicInfo(); | ||||
| baseInfoQ.setPhone(phone); | baseInfoQ.setPhone(phone); | ||||
| @@ -157,56 +182,14 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | ||||
| public ResultData findById(Long id) { | public ResultData findById(Long id) { | ||||
| WxCUserBasicInfo info = wxCUserBasicInfoService.getById(id); | WxCUserBasicInfo info = wxCUserBasicInfoService.getById(id); | ||||
| if (info != null) { | |||||
| if (info.getTagId() != null) { | |||||
| WxCUserTags uTag = wxCUserTagsService.getById(info.getTagId()); | |||||
| if (StringUtils.isNotBlank(uTag.getTags())) { | |||||
| List<Long> ids = JSONObject.parseArray(uTag.getTags(), Long.class); | |||||
| if (!ids.isEmpty()) { | |||||
| WxTags wxTags = new WxTags(); | |||||
| wxTags.setIds(ids); | |||||
| PageInfo<WxTags> page = wxTagsService.listAsPage(wxTags, 1, 5000); | |||||
| String tagNames = ""; | |||||
| String tagIds = ""; | |||||
| List<Long> tagIdList = new ArrayList<>(); | |||||
| for (WxTags wt : page.getList()) { | |||||
| tagNames += wt.getName() + "/"; | |||||
| tagIds += wt.getId() + ","; | |||||
| tagIdList.add(wt.getId()); | |||||
| } | |||||
| if (StringUtils.isNotBlank(tagNames)) { | |||||
| info.setTagNames(tagNames.substring(0, tagNames.length() - 1)); | |||||
| } | |||||
| if (StringUtils.isNoneBlank(tagIds)) { | |||||
| info.setTagIds(tagIds.substring(0, tagIds.length() - 1)); | |||||
| } | |||||
| long count = wxCUserTagsService.findCountByTag(getTenantId(), tagIdList); | |||||
| info.setCount(count); | |||||
| } | |||||
| } | |||||
| } | |||||
| if (info.getPoins() == null || info.getPoins() == 0) { | |||||
| info.setLevel("无"); | |||||
| } else { | |||||
| info.setLevel("无"); | |||||
| List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantId(info.getTenantId()); | |||||
| for(WxLevelConfig levelConfig: levelList) { | |||||
| if (info.getPoins() >= levelConfig.getPoints()) { | |||||
| info.setLevel(levelConfig.getLevel()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } else { | |||||
| info = new WxCUserBasicInfo(); | |||||
| info.setId(id); | |||||
| WxCUser user = wxCUserService.getById(id); | |||||
| if (user != null) { | |||||
| info.setTenantId(user.getTenantId()); | |||||
| info.setPhone(user.getPhone()); | |||||
| info.setSex(user.getGender()); | |||||
| } | |||||
| } | |||||
| return new ResultData(Result.SUCCESS, "查询成功", info); | |||||
| if (info == null) | |||||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
| setUserInfoTag(info); | |||||
| setUserInfoLevel(info); | |||||
| return new ResultData(info); | |||||
| } | } | ||||
| @ApiOperation("根据userId查询交易记录接口") | @ApiOperation("根据userId查询交易记录接口") | ||||