| | |
| | | import com.taoke.autopay.entity.AdminUser; |
| | | import com.taoke.autopay.entity.WxUserInfo; |
| | | import com.taoke.autopay.entity.WxUserSettings; |
| | | import com.taoke.autopay.entity.credit.UserCreditBalance; |
| | | import com.taoke.autopay.factory.WxUserFactory; |
| | | import com.taoke.autopay.service.AdminUserService; |
| | | import com.taoke.autopay.service.WxUserService; |
| | | import com.taoke.autopay.service.WxUserSettingService; |
| | | import com.taoke.autopay.service.credit.UserCreditBalanceService; |
| | | import com.taoke.autopay.utils.TimeUtil; |
| | | import com.taoke.autopay.vo.WxUserOrderSettingVO; |
| | | import com.taoke.autopay.vo.WxUserVO; |
| | |
| | | @Resource |
| | | private WxUserSettingService wxUserSettingService; |
| | | |
| | | @Resource |
| | | private UserCreditBalanceService userCreditBalanceService; |
| | | |
| | | |
| | | /** |
| | | * @param key |
| | | * @param keyType 1-用户ID/昵称 2-地域 |
| | | * @param page |
| | | * @param limit |
| | | * @return |
| | | */ |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("list") |
| | | public String listWxUser(String uid, int page, int limit) { |
| | | public String listWxUser(String key, Integer keyType, int page, int limit) { |
| | | //先查询所有的数据 |
| | | WxUserInfoMapper.DaoQuery query = new WxUserInfoMapper.DaoQuery(); |
| | | query.sortList=Arrays.asList(new String[]{"login_time desc"}); |
| | | if (!StringUtil.isNullOrEmpty(uid) && NumberUtil.isNumeric(uid)) { |
| | | query.id = Long.parseLong(uid); |
| | | query.sortList = Arrays.asList(new String[]{"login_time desc"}); |
| | | if (keyType == null) { |
| | | keyType = 1; |
| | | } |
| | | switch (keyType) { |
| | | case 1: |
| | | if (!StringUtil.isNullOrEmpty(key)) { |
| | | if (NumberUtil.isNumeric(key)) { |
| | | query.id = Long.parseLong(key); |
| | | } else { |
| | | query.searchKey = key; |
| | | } |
| | | } |
| | | break; |
| | | case 2: |
| | | if (!StringUtil.isNullOrEmpty(key)) { |
| | | query.searchArea = key; |
| | | } |
| | | break; |
| | | |
| | | } |
| | | |
| | | List<WxUserInfo> userList = wxUserService.list(query, page, limit); |
| | | long count = wxUserService.count(query); |
| | | Map<Long, WxUserSettings> settingsMap = new HashMap<>(); |
| | | Map<Long, UserCreditBalance> creditBalanceMap = new HashMap<>(); |
| | | if (userList.size() > 0) { |
| | | List<Long> uids = new ArrayList<>(); |
| | | for (WxUserInfo u : userList) { |
| | |
| | | for (WxUserSettings setting : settings) { |
| | | settingsMap.put(setting.getId(), setting); |
| | | } |
| | | // 获取用户积分余额 |
| | | creditBalanceMap = userCreditBalanceService.getCreditBalancesByUserIds(uids); |
| | | |
| | | } |
| | | |
| | | |
| | | // 转vo |
| | | List<WxUserVO> voList = new ArrayList<>(); |
| | | for (WxUserInfo user : userList) { |
| | | voList.add(WxUserFactory.createVO(user, settingsMap.get(user.getId()))); |
| | | voList.add(WxUserFactory.createVO(user, settingsMap.get(user.getId()), creditBalanceMap.get(user.getId()))); |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | data.put("count", count); |
| | |
| | | @ResponseBody |
| | | @RequestMapping("getOrderSettings") |
| | | public String getOrderSettings(Long id) { |
| | | WxUserSettings settings = wxUserSettingService.selectByUid(id); |
| | | WxUserSettings settings = wxUserSettingService.getUserSettings(id); |
| | | return JsonUtil.loadTrueResult(WxUserFactory.createVO(settings)); |
| | | } |
| | | |
| | |
| | | settings.setTotalOrderCountPerDay(vo.getTotalSubmitCount()); |
| | | settings.setDyOrderCountPerDay(vo.getDyPayCount()); |
| | | settings.setKsOrderCountPerDay(vo.getKsPayCount()); |
| | | wxUserSettingService.updateSelective(settings); |
| | | wxUserSettingService.add(settings); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("getUser") |
| | | public String getUser(Long id) { |
| | | WxUserInfo user = wxUserService.selectById(id); |
| | | return JsonUtil.loadTrueResult(user); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("updateUser") |
| | | public String updateUser(WxUserInfo user) { |
| | | wxUserService.update(user); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } |
| | | |