developrelease_toaliyun_real
| @@ -39,6 +39,8 @@ import static com.iformall.domain.po.WxCouponOrder.Field.CreateDate_DESC; | |||||
| public class WxCUserBasicInfoController extends BaseController { | public class WxCUserBasicInfoController extends BaseController { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| private String importMemPrev = "importmem/"; | |||||
| @Autowired | @Autowired | ||||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | private WxCUserBasicInfoService wxCUserBasicInfoService; | ||||
| @@ -222,11 +224,23 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| return new ResultData(Result.SUCCESS, "查询成功", page); | return new ResultData(Result.SUCCESS, "查询成功", page); | ||||
| } | } | ||||
| @RequestMapping("/exportData") | |||||
| public void exportData(HttpServletRequest request, HttpServletResponse response) { | |||||
| @ApiOperation("会员记录导出") | |||||
| @GetMapping("/exportData") | |||||
| public void exportData(@ModelAttribute WxCUserBasicInfo basicInfo, HttpServletRequest request, HttpServletResponse response) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::exportData"); | logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::exportData"); | ||||
| if(basicInfo == null) { | |||||
| basicInfo = new WxCUserBasicInfo(); | |||||
| } else { | |||||
| if (StringUtils.isBlank(basicInfo.getPhone())) { | |||||
| basicInfo.setPhone(null); | |||||
| } | |||||
| if (StringUtils.isBlank(basicInfo.getName())) { | |||||
| basicInfo.setName(null); | |||||
| } | |||||
| } | |||||
| wxCUserBasicInfoService.exportData(request, response, getTenantId()); | |||||
| basicInfo.setTenantId(getTenantId()); | |||||
| wxCUserBasicInfoService.exportData(basicInfo, request, response); | |||||
| } | } | ||||
| @@ -242,27 +256,28 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| public ResultData importTemplate(@RequestParam("file") MultipartFile file) { | public ResultData importTemplate(@RequestParam("file") MultipartFile file) { | ||||
| logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::importTemplate"); | logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::importTemplate"); | ||||
| if (file.isEmpty()) { | if (file.isEmpty()) { | ||||
| throw new MallinkException(500, "上传文件不能为空"); | |||||
| throw new MallinkException(Result.ERROR, "上传文件不能为空"); | |||||
| } | } | ||||
| //得到当前用户ID | //得到当前用户ID | ||||
| String userId = getUser().getId().toString(); | |||||
| String userId = "" + getUser().getId(); | |||||
| String importKey = importMemPrev + userId; | |||||
| //查询当前用户得到的值是否为空,为空继续,不为空,返回模板正在导入 | //查询当前用户得到的值是否为空,为空继续,不为空,返回模板正在导入 | ||||
| Boolean allCount = stringRedisTemplate.opsForHash().hasKey(userId, "allCount"); | |||||
| Boolean allCount = stringRedisTemplate.opsForHash().hasKey(importKey, "allCount"); | |||||
| if (allCount) { | if (allCount) { | ||||
| return new ResultData(Result.SUCCESS, "模板正在导入"); | return new ResultData(Result.SUCCESS, "模板正在导入"); | ||||
| } | } | ||||
| stringRedisTemplate.opsForHash().putIfAbsent(userId, "allCount", 0 + ""); | |||||
| stringRedisTemplate.opsForHash().putIfAbsent(userId, "allSuccessCount", 0 + ""); | |||||
| stringRedisTemplate.opsForHash().putIfAbsent(userId, "successCount", ""); | |||||
| stringRedisTemplate.opsForHash().putIfAbsent(userId, "failCount", ""); | |||||
| wxCUserBasicInfoService.importTemplate(file, getTenantId(), userId); | |||||
| stringRedisTemplate.expire(userId,30,TimeUnit.MINUTES); | |||||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", 0 + ""); | |||||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allSuccessCount", 0 + ""); | |||||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "processCount", ""); | |||||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", ""); | |||||
| wxCUserBasicInfoService.importTemplate(file, getTenantId(), importKey); | |||||
| stringRedisTemplate.expire(importKey,30,TimeUnit.MINUTES); | |||||
| return new ResultData(Result.SUCCESS, "模板正在导入"); | return new ResultData(Result.SUCCESS, "模板正在导入"); | ||||
| } | } | ||||
| @GetMapping("/queryTemplateCount") | @GetMapping("/queryTemplateCount") | ||||
| public ResultData queryTemplateCount() { | public ResultData queryTemplateCount() { | ||||
| String importKey = "import-" + getUser().getId(); | |||||
| String importKey = importMemPrev + getUser().getId(); | |||||
| Map entries = stringRedisTemplate.opsForHash().entries(importKey); | Map entries = stringRedisTemplate.opsForHash().entries(importKey); | ||||
| logger.info(JSONArray.toJSONString(entries) + ">>>>>>>>>>>>>>>>>>>>>1"); | logger.info(JSONArray.toJSONString(entries) + ">>>>>>>>>>>>>>>>>>>>>1"); | ||||
| if (entries.size() < 4) { | if (entries.size() < 4) { | ||||
| @@ -271,7 +286,7 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| } | } | ||||
| String allCount = entries.get("allCount").toString(); | String allCount = entries.get("allCount").toString(); | ||||
| String allSuccessCount = entries.get("allSuccessCount").toString(); | String allSuccessCount = entries.get("allSuccessCount").toString(); | ||||
| String successCount = entries.get("successCount").toString(); | |||||
| String processCount = entries.get("processCount").toString(); | |||||
| String failCount = entries.get("failCount").toString(); | String failCount = entries.get("failCount").toString(); | ||||
| if (StringUtils.isNotBlank(failCount) && allCount.equals(failCount)) {//stringRedisTemplate.expire(userId,1,TimeUnit.SECONDS); | if (StringUtils.isNotBlank(failCount) && allCount.equals(failCount)) {//stringRedisTemplate.expire(userId,1,TimeUnit.SECONDS); | ||||
| @@ -279,16 +294,16 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| //完全失败 | //完全失败 | ||||
| stringRedisTemplate.opsForHash().delete(importKey, "allCount"); | stringRedisTemplate.opsForHash().delete(importKey, "allCount"); | ||||
| stringRedisTemplate.opsForHash().delete(importKey, "allSuccessCount"); | stringRedisTemplate.opsForHash().delete(importKey, "allSuccessCount"); | ||||
| stringRedisTemplate.opsForHash().delete(importKey, "successCount"); | |||||
| stringRedisTemplate.opsForHash().delete(importKey, "processCount"); | |||||
| stringRedisTemplate.opsForHash().delete(importKey, "failCount"); | stringRedisTemplate.opsForHash().delete(importKey, "failCount"); | ||||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR); | return new ResultData(ErrorCode.MEM_IMPORT_ERR); | ||||
| } | } | ||||
| //导入完成 | //导入完成 | ||||
| if (StringUtils.isNotBlank(allSuccessCount) && allSuccessCount.equals(successCount)) { | |||||
| if (StringUtils.isNotBlank(allSuccessCount) && allSuccessCount.equals(processCount)) { | |||||
| ResultData ok = new ResultData(Result.SUCCESS, "ok", entries); | ResultData ok = new ResultData(Result.SUCCESS, "ok", entries); | ||||
| stringRedisTemplate.opsForHash().delete(importKey, "allCount"); | stringRedisTemplate.opsForHash().delete(importKey, "allCount"); | ||||
| stringRedisTemplate.opsForHash().delete(importKey, "allSuccessCount"); | stringRedisTemplate.opsForHash().delete(importKey, "allSuccessCount"); | ||||
| stringRedisTemplate.opsForHash().delete(importKey, "successCount"); | |||||
| stringRedisTemplate.opsForHash().delete(importKey, "processCount"); | |||||
| stringRedisTemplate.opsForHash().delete(importKey, "failCount"); | stringRedisTemplate.opsForHash().delete(importKey, "failCount"); | ||||
| return ok; | return ok; | ||||
| } | } | ||||
| @@ -253,7 +253,7 @@ public enum ErrorCode{ | |||||
| /** | /** | ||||
| * 会员 | * 会员 | ||||
| */ | */ | ||||
| MEM_IMPORT_ERR(13000, "模板导入失败,请尝试重新导入"), | |||||
| MEM_IMPORT_ERR(13000, "模板导入失败,请检查数据,尝试重新导入"), | |||||
| MEM_SCORE_NOT_ENOUGH(13001, "成长值不够扣减值"), | MEM_SCORE_NOT_ENOUGH(13001, "成长值不够扣减值"), | ||||
| /** | /** | ||||
| @@ -99,11 +99,11 @@ public interface WxCUserBasicInfoService { | |||||
| long findCountByScore(WxCUserBasicInfoDto dto); | long findCountByScore(WxCUserBasicInfoDto dto); | ||||
| void exportData(HttpServletRequest request, HttpServletResponse response, String tenantId); | |||||
| void exportData(WxCUserBasicInfo basicInfo, HttpServletRequest request, HttpServletResponse response); | |||||
| void exportTemplate(HttpServletRequest request, HttpServletResponse response, String tenantId); | void exportTemplate(HttpServletRequest request, HttpServletResponse response, String tenantId); | ||||
| ResultData importTemplate(MultipartFile file, String tenantId, String userId); | |||||
| ResultData importTemplate(MultipartFile file, String tenantId, String importKey); | |||||
| long findCount(WxCUserBasicInfoDto dto); | long findCount(WxCUserBasicInfoDto dto); | ||||
| @@ -8,12 +8,12 @@ import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; | |||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.dto.WxCUserBasicInfoDto; | import com.iformall.domain.dto.WxCUserBasicInfoDto; | ||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| import com.iformall.domain.po.WxCUserBasicInfo; | import com.iformall.domain.po.WxCUserBasicInfo; | ||||
| import com.iformall.domain.po.WxCUserTags; | |||||
| import com.iformall.domain.po.WxTags; | import com.iformall.domain.po.WxTags; | ||||
| import com.iformall.domain.vo.CUserBaseInfoT; | import com.iformall.domain.vo.CUserBaseInfoT; | ||||
| import com.iformall.domain.vo.CUserBaseVo; | import com.iformall.domain.vo.CUserBaseVo; | ||||
| @@ -153,10 +153,8 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||||
| @Override | @Override | ||||
| public void exportData(HttpServletRequest request, HttpServletResponse response, String tenantId) { | |||||
| WxCUserBasicInfo basicInfoQ = new WxCUserBasicInfo(); | |||||
| basicInfoQ.setTenantId(tenantId); | |||||
| List<WxCUserBasicInfoVo> memberlist = wxCUserBasicInfoMapper.findVoList(basicInfoQ); | |||||
| public void exportData(WxCUserBasicInfo basicInfo, HttpServletRequest request, HttpServletResponse response) { | |||||
| List<WxCUserBasicInfoVo> memberlist = wxCUserBasicInfoMapper.findVoList(basicInfo); | |||||
| XSSFWorkbook workbook; | XSSFWorkbook workbook; | ||||
| String filepath = Constant.fileDirectory; | String filepath = Constant.fileDirectory; | ||||
| @@ -514,38 +512,65 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||||
| @Async | @Async | ||||
| @Override | @Override | ||||
| public ResultData importTemplate(MultipartFile file, String tenantId, String userId) { | |||||
| public ResultData importTemplate(MultipartFile file, String tenantId, String importKey) { | |||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| String importKey = "import-" + userId; | |||||
| //默认添加到redis里 | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", ""); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", "0"); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "successCount", "0"); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "failCount", "0"); | |||||
| ImportParams params = new ImportParams(); | ImportParams params = new ImportParams(); | ||||
| // 需要验证 | // 需要验证 | ||||
| params.setImportFields(new String[]{"姓名", "性别", "手机号", "微信昵称", "学历", "生日", "地址", "上次活跃时间", "注册时间", "标签", "成长值"}); | params.setImportFields(new String[]{"姓名", "性别", "手机号", "微信昵称", "学历", "生日", "地址", "上次活跃时间", "注册时间", "标签", "成长值"}); | ||||
| IExcelDataHandler<CUserBaseInfoT> handler = new UserExcelHandler(); | |||||
| handler.setNeedHandlerFields(new String[] { "手机号" }); | |||||
| params.setNeedVerify(true); | params.setNeedVerify(true); | ||||
| ExcelImportResult<CUserBaseInfoT> datalist = null; | |||||
| try { | try { | ||||
| ExcelImportResult<CUserBaseInfoT> datalist = ExcelImportUtil.importExcelMore(file.getInputStream(), CUserBaseInfoT.class, params); | |||||
| List<CUserBaseInfoT> successList = datalist.getList(); | |||||
| List<CUserBaseInfoT> failList = datalist.getFailList(); | |||||
| logger.info("验证通过的数量: " + successList.size()); | |||||
| logger.info("验证未通过的数量: " + failList.size()); | |||||
| datalist = ExcelImportUtil.importExcelMore(file.getInputStream(), CUserBaseInfoT.class, params); | |||||
| } catch (Exception e) { | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", "1"); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", "0"); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "processCount", "0"); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "failCount", "1"); | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR); | |||||
| } | |||||
| if(datalist == null) { | |||||
| logger.error("导入模板失败: 模板数据解析失败"); | |||||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR); | |||||
| } | |||||
| List<CUserBaseInfoT> successList = datalist.getList(); | |||||
| List<CUserBaseInfoT> failList = datalist.getFailList(); | |||||
| int total = successList.size() + failList.size(); | |||||
| int all_success = successList.size(); | |||||
| int all_fail = failList.size(); | |||||
| //添加到redis里 | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", "" + total); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", "" + all_success); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "processCount", "0"); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "failCount", "" + all_fail); | |||||
| successList.parallelStream().forEach(uBase->{ | |||||
| logger.info("验证通过的数量: " + successList.size()); | |||||
| logger.info("验证未通过的数量: " + failList.size()); | |||||
| WxTags wxTagsQ = new WxTags(); | |||||
| List<WxTags> tagList = wxTagsMapper.findList(wxTagsQ); | |||||
| try { | |||||
| successList.parallelStream().forEach(uBase -> { | |||||
| if (StringUtils.isBlank(uBase.getPhone())) { | if (StringUtils.isBlank(uBase.getPhone())) { | ||||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||||
| logger.error("手机号为空", uBase.toString()); | logger.error("手机号为空", uBase.toString()); | ||||
| return; | return; | ||||
| } | } | ||||
| WxCUserBasicInfo userBase = InitUserBaseInfo(uBase, tenantId); | WxCUserBasicInfo userBase = InitUserBaseInfo(uBase, tenantId); | ||||
| if (userBase == null) { | if (userBase == null) { | ||||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||||
| logger.error("userBase为null", uBase.toString()); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -568,24 +593,12 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||||
| oldUserBase.setUpdateDate(new Date()); | oldUserBase.setUpdateDate(new Date()); | ||||
| oldUserBase.setCreateDate(userBase.getCreateDate()); | oldUserBase.setCreateDate(userBase.getCreateDate()); | ||||
| } else { | } else { | ||||
| // check c_user 是否存在 | |||||
| WxCUser cUserQ = new WxCUser(); | |||||
| cUserQ.setTenantId(tenantId); | |||||
| cUserQ.setPhone(userBase.getPhone()); | |||||
| List<WxCUser> cUsers = wxCUserMapper.findList(cUserQ); | |||||
| if (cUsers.size() > 0) { | |||||
| WxCUser wUser = cUsers.get(0); | |||||
| if (wUser != null) { | |||||
| userBase.setId(wUser.getId()); | |||||
| userBase.setNickName(wUser.getNickName()); | |||||
| } | |||||
| } else { | |||||
| userBase.setId(idWorker.nextId()); | |||||
| } | |||||
| userBase.setId(idWorker.nextId()); | |||||
| } | } | ||||
| // update 昵称 | // update 昵称 | ||||
| if (oldUserBase != null) { | |||||
| { | |||||
| // check c_user 是否存在 | |||||
| WxCUser cUserQ = new WxCUser(); | WxCUser cUserQ = new WxCUser(); | ||||
| cUserQ.setTenantId(tenantId); | cUserQ.setTenantId(tenantId); | ||||
| cUserQ.setPhone(userBase.getPhone()); | cUserQ.setPhone(userBase.getPhone()); | ||||
| @@ -594,8 +607,13 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||||
| WxCUser user = userList.get(0); | WxCUser user = userList.get(0); | ||||
| if (user != null) { | if (user != null) { | ||||
| if (oldUserBase != null) { | if (oldUserBase != null) { | ||||
| oldUserBase.setNickName(user.getNickName()); | |||||
| if(oldUserBase != null) { | |||||
| oldUserBase.setNickName(user.getNickName()); | |||||
| } | |||||
| userBase.setId(user.getId()); | |||||
| userBase.setNickName(user.getNickName()); | |||||
| } else { | } else { | ||||
| userBase.setNickName(user.getNickName()); | userBase.setNickName(user.getNickName()); | ||||
| } | } | ||||
| } | } | ||||
| @@ -603,55 +621,66 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||||
| } | } | ||||
| if (oldUserBase != null) { | if (oldUserBase != null) { | ||||
| logger.info("update user base: " + oldUserBase.getId()); | |||||
| wxCUserBasicInfoMapper.updateByPrimaryKeySelective(oldUserBase); | wxCUserBasicInfoMapper.updateByPrimaryKeySelective(oldUserBase); | ||||
| } else { | } else { | ||||
| wxCUserBasicInfoMapper.insertSelective(userBase); | |||||
| logger.info("insert user base: " + userBase.getId()); | |||||
| try { | |||||
| wxCUserBasicInfoMapper.insertSelective(userBase); | |||||
| } catch (Exception e) { | |||||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||||
| logger.error(e.getMessage()); | |||||
| return; | |||||
| } | |||||
| } | } | ||||
| // update tags | // update tags | ||||
| if (StringUtils.isNotBlank(userBase.getTagNames())) { | |||||
| // get tag ids | |||||
| String tagNames = userBase.getTagNames(); | |||||
| List<Long> tagIdList = new ArrayList<>(); | |||||
| for (String tagName : tagNames.split("/")) { | |||||
| List<WxTags> wxTagsList = wxTagsMapper.getByName(tagName); | |||||
| if (wxTagsList.size()==1) { | |||||
| WxTags wxTags = wxTagsList.get(0); | |||||
| tagIdList.add(Long.valueOf(wxTags.getId())); | |||||
| try { | |||||
| if (StringUtils.isNotBlank(userBase.getTagNames())) { | |||||
| // get tag ids | |||||
| String tagNames = userBase.getTagNames(); | |||||
| List<Long> tagIdList = new ArrayList<>(); | |||||
| for (String tagName : tagNames.split("/")) { | |||||
| for(WxTags tag: tagList) { | |||||
| if(tagName.equals(tag.getName())) { | |||||
| tagIdList.add(Long.valueOf(tag.getId())); | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| } | |||||
| if (oldUserBase != null){ | |||||
| wxCUserTagsService.assignTags(tagIdList,oldUserBase); | |||||
| }else{ | |||||
| wxCUserTagsService.assignTags(tagIdList,userBase); | |||||
| if (oldUserBase != null){ | |||||
| wxCUserTagsService.assignTags(tagIdList,oldUserBase); | |||||
| }else{ | |||||
| wxCUserTagsService.assignTags(tagIdList,userBase); | |||||
| } | |||||
| } | } | ||||
| } | |||||
| //触发自动打标签 | |||||
| if (oldUserBase != null) { | |||||
| wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT,oldUserBase); | |||||
| } | |||||
| else{ | |||||
| wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT,userBase); | |||||
| } | |||||
| // 成长值 | |||||
| if (StringUtils.isNotBlank(uBase.getPoins())) { | |||||
| //触发自动打标签 | |||||
| if (oldUserBase != null) { | if (oldUserBase != null) { | ||||
| wxScoreRulesService.addScore2(EnumScoreType.MEM_IMPORT, oldUserBase, uBase.getPoins()); | |||||
| } else { | |||||
| wxScoreRulesService.addScore2(EnumScoreType.MEM_IMPORT, userBase, uBase.getPoins()); | |||||
| wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT,oldUserBase); | |||||
| } | |||||
| else{ | |||||
| wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT,userBase); | |||||
| } | } | ||||
| // 成长值 | |||||
| if (StringUtils.isNotBlank(uBase.getPoins())) { | |||||
| if (oldUserBase != null) { | |||||
| wxScoreRulesService.addScore2(EnumScoreType.MEM_IMPORT, oldUserBase, uBase.getPoins()); | |||||
| } else { | |||||
| wxScoreRulesService.addScore2(EnumScoreType.MEM_IMPORT, userBase, uBase.getPoins()); | |||||
| } | |||||
| } | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| logger.error("打标签+成长值失败--继续导入"); | |||||
| } | } | ||||
| //记数 | //记数 | ||||
| stringRedisTemplate.opsForHash().increment(userId,"successCount",1); | |||||
| stringRedisTemplate.opsForHash().increment(importKey,"processCount",1); | |||||
| }); | }); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", "1"); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", "0"); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "successCount", "0"); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "failCount", "1"); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", "" + all_fail); | |||||
| e.printStackTrace(); | e.printStackTrace(); | ||||
| logger.error("导入模板失败:"+e.getMessage()); | logger.error("导入模板失败:"+e.getMessage()); | ||||
| } | } | ||||
| @@ -116,18 +116,22 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| if(record.getType().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) || | if(record.getType().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) || | ||||
| record.getType().equals(EnumCouponType.CARD_MULTIMCH.getCode())) { | record.getType().equals(EnumCouponType.CARD_MULTIMCH.getCode())) { | ||||
| Integer subsidyType = record.getSubsidyType(); | Integer subsidyType = record.getSubsidyType(); | ||||
| Integer subsidyNum = record.getSubsidyNum(); | |||||
| if(subsidyType == null) { | if(subsidyType == null) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "请填写补贴类型"); | return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "请填写补贴类型"); | ||||
| } | } | ||||
| if(subsidyNum == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "请填写补贴金额"); | |||||
| } | |||||
| if(subsidyType.equals(EnumCouponSubsidyType.WECHAT_COUPON.getCode())) { | if(subsidyType.equals(EnumCouponSubsidyType.WECHAT_COUPON.getCode())) { | ||||
| // 微信 立减 | // 微信 立减 | ||||
| if(record.getSubsidyNum() > record.getSalePrice()) { | |||||
| if(subsidyNum > record.getSalePrice()) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "补贴额大于售价"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "补贴额大于售价"); | ||||
| } | } | ||||
| } else if(subsidyType.equals(EnumCouponSubsidyType.OFFLINE_SUBSIDY.getCode())) { | } else if(subsidyType.equals(EnumCouponSubsidyType.OFFLINE_SUBSIDY.getCode())) { | ||||
| // 线下补贴 | // 线下补贴 | ||||
| int subsidy_num = record.getPrice() - record.getSalePrice(); | int subsidy_num = record.getPrice() - record.getSalePrice(); | ||||
| if(record.getSubsidyNum() > subsidy_num) { | |||||
| if(subsidyNum > subsidy_num) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "补贴额大于面额与售价的差值"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "补贴额大于面额与售价的差值"); | ||||
| } | } | ||||
| } else if(subsidyType.equals(EnumCouponSubsidyType.WECHAT_MCHPAY.getCode())) { | } else if(subsidyType.equals(EnumCouponSubsidyType.WECHAT_MCHPAY.getCode())) { | ||||
| @@ -91,7 +91,7 @@ public class HashUtil { | |||||
| } | } | ||||
| try { | try { | ||||
| String enc = hash("md5", str); | String enc = hash("md5", str); | ||||
| enc = new String(Base64.getUrlEncoder().encode(enc.getBytes("utf-8"))); | |||||
| enc = new String(Base64.getUrlEncoder().encode(enc.getBytes("utf-8")), "utf-8"); | |||||
| return enc; | return enc; | ||||
| } catch (UnsupportedEncodingException e) { | } catch (UnsupportedEncodingException e) { | ||||
| return null; | return null; | ||||
| @@ -102,7 +102,13 @@ public class HashUtil { | |||||
| if (str == null) { | if (str == null) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| String dec = new String(Base64.getUrlDecoder().decode(str)); | |||||
| return dec; | |||||
| try { | |||||
| String dec = new String(Base64.getUrlDecoder().decode(str), "utf-8"); | |||||
| return dec; | |||||
| } catch (Exception e) { | |||||
| System.out.println(str); | |||||
| System.out.println(e.getMessage()); | |||||
| return null; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||