@Log(message = "添加了transRecord,id:{0}。") @RequestMapping(value = "/create", method = RequestMethod.POST) public String create( @RequestParam MultipartFile[] myfiles1, @RequestParam MultipartFile[] myfiles2, HttpServletRequest request) { // 如果只是上传一个文件,则只需要MultipartFile类型接收文件即可,而且无需显式指定@RequestParam注解 // 如果想上传多个文件,那么这里就要用MultipartFile[]类型来接收文件,并且还要指定@RequestParam注解 // 并且上传多个文件时,前台表单中的所有<input // type="file"/>的name都应该是myfiles1,2,否则参数里的myfiles无法获取到所有上传的文件 BizTransRecord transRecord = buildBizTransRecord(request); // 设置为初始状态 transRecord.setStatus(TransStatusEnum.I.getValue()); HttpSession session = HttpReceiver.getHttpSession(); BizMember member = (BizMember) session.getAttribute("member"); transRecord.setMemberId(member.getId()); Map<String, String> extendMap = new HashMap<String, String>(); extendMap.put("memberNo", member.getMemberNo()); try { transRecordService.save(transRecord, myfiles1, myfiles2, extendMap); } catch (ServiceException e) { return "redirect:/personalPage?suc=false"; } return "redirect:/personalPage?suc=true"; }
@RequestMapping( value = "/findLastTransRecord2", method = {RequestMethod.GET, RequestMethod.POST}) public @ResponseBody String findLastTransRecord2( @RequestParam String type, @RequestParam String dateStr, @RequestParam Long id) { BizTransRecord record = transRecordService.get(id); Map<String, Object> paramMap = new HashMap<String, Object>(); // 得到上日权益 try { // 上日交易 BizTransRecordVO vo = transRecordService.findPreviousTransRecord( record.getMemberId(), type, DateUtil.string2Date(dateStr, DateUtil.PATTERN_DATE)); if (vo == null) { // 表示上日权益没有 paramMap.put("isHave", "false"); } else { paramMap.put("isHave", "true"); paramMap.put("lastDayValue", vo.getCurrValue() / 100.0); } BizTransRecordVO totalInfo = transRecordService.queryTotalInfoBeforeOneDate(record.getMemberId(), type, dateStr); paramMap.put( "totalInCome", totalInfo.getTotalIncome() == null ? 0 : totalInfo.getTotalIncome() / 100.0); paramMap.put( "totalOutCome", totalInfo.getTotalOutcome() == null ? 0 : totalInfo.getTotalOutcome() / 100.0); } catch (Exception e) { e.printStackTrace(); } return AjaxReturnInfo.returnSuc(paramMap); }
@RequestMapping(value = "/reviewTransRecord", method = RequestMethod.POST) public @ResponseBody String reviewTransRecord( TransRecordReviewForm form, HttpServletRequest request) { BizTransRecord transRecord = transRecordService.get(form.getTransRecordId()); // 后续应加上判断此刻该记录的状态,应先锁,后判断状态,再更新 if (isPass(form)) { transRecord.setStatus(TransStatusEnum.S.getValue()); transRecord.setGmtValidate(DateUtil.getNowDate()); } else { transRecord.setStatus(TransStatusEnum.F.getValue()); } transRecordService.saveWithStatisAndReview(transRecord, form); return new AjaxObject("审核成功").toString(); }
@RequestMapping(value = "/updateRecord", method = RequestMethod.POST) public String updateRecord( @RequestParam MultipartFile[] myfiles1, @RequestParam MultipartFile[] myfiles2, HttpServletRequest request) { String flag = "1"; try { BizTransRecord record = getRecord(request); record.setStatus("I"); transRecordService.update(record); } catch (Exception e) { logger.error("更新交易信息异常!", e); flag = "0"; } return "redirect:/myTransRecord?flag=" + flag; }
@Log(message = "删除了transRecord,ids:{0}。") @RequestMapping(value = "/delete", method = RequestMethod.POST) public @ResponseBody String deleteMany(Long[] ids) { evenName = "transRecord删除"; AjaxObject ajaxObject = new AjaxObject(evenName + "成功!"); String[] transRecordTypes = new String[ids.length]; for (int i = 0; i < ids.length; i++) { BizTransRecord transRecord = transRecordService.get(ids[i]); transRecordService.delete(transRecord.getId()); transRecordTypes[i] = transRecord.getId().toString(); } // 记录日志 LogUitl.putArgs( LogMessageObject.newWrite().setObjects(new Object[] {Arrays.toString(transRecordTypes)})); ajaxObject.setCallbackType(""); return ajaxObject.toString(); }
@RequestMapping( value = "/modifyLast1", method = {RequestMethod.GET, RequestMethod.POST}) public @ResponseBody String modifyLast1(HttpServletRequest request) { String type = request.getParameter("type"); String id = request.getParameter("id"); type = StringUtils.isBlank(type) ? InvestDirectionEnum.QI_HUO.getValue() : type; BizTransRecordVO vo; try { vo = transRecordService.findLastRecord(Long.parseLong(id), type); if (null != vo) { BizTransRecord record = transRecordService.get(vo.getId()); record.setInvestType( InvestDirectionEnum.getInvestDirectionEnum(record.getInvestType()).getName()); return AjaxReturnInfo.returnSuc(record); } else { return null; } } catch (Exception e) { e.printStackTrace(); } return null; }
/** * 组装交易对象 * * @param request * @return */ private BizTransRecord getRecord(HttpServletRequest request) { String id = request.getParameter("id"); if (StringUtils.isBlank(id)) { return null; } BizTransRecord record = transRecordService.get(Long.parseLong(id)); String fee = request.getParameter("fee"); String gainsAndLosses = request.getParameter("gainsAndLosses"); String currValue = request.getParameter("currValue"); String totleGainsAndLosses = request.getParameter("totleGainsAndLosses"); String currIncome = request.getParameter("currIncome"); String currOutcome = request.getParameter("currOutcome"); record.setFee(getRealLong(fee)); record.setCurrIncome(getRealLong(currIncome)); record.setCurrOutcome(getRealLong(currOutcome)); record.setTotalGainsAndLosses(totleGainsAndLosses); record.setGainsAndLosses(getRealLong(gainsAndLosses)); record.setCurrValue(getRealLong(currValue)); record.setGmtModified(DateUtil.getNowDate()); return record; }
@RequestMapping(value = "/update/{id}", method = RequestMethod.GET) public String preUpdate(@PathVariable Long id, Map<String, Object> map) { BizTransRecord transRecord = transRecordService.get(id); if (null == transRecord) { return UPDATE; } map.put("id", transRecord.getId() + ""); map.put("investType", transRecord.getInvestType()); map.put( "investTypeName", InvestDirectionEnum.getInvestDirectionEnum(transRecord.getInvestType()).getName()); map.put("fee", getRealValue(transRecord.getFee())); map.put("gainsAndLosses", getRealValue(transRecord.getGainsAndLosses())); map.put("currIncome", getRealValue(transRecord.getCurrIncome())); map.put("currOutcome", getRealValue(transRecord.getCurrOutcome())); map.put("currValue", getRealValue(transRecord.getCurrValue())); map.put("lastDayValue", getRealValue(transRecord.getLastDayValue())); map.put("totalGainsAndLosses", transRecord.getTotalGainsAndLosses()); map.put("origionValue", getRealValue(transRecord.getOrigionValue())); map.put("status", transRecord.getStatus()); map.put("importDate", transRecord.getImportDate()); BizReviewLog log = reviewLogService.getBizReviewLog(transRecord.getId(), "TRANS_RECORD"); if (null != log) { map.put("failReason", log.getComment()); } return UPDATE; }
/** * 通过request来进行交易对象的组装 * * @param request * @return */ private BizTransRecord buildBizTransRecord(HttpServletRequest request) { BizTransRecord record = new BizTransRecord(); String recordType = request.getParameter("recordType"); if (StringUtils.equals(recordType, BizTransRecordConstant.FIRST_RECORD_TYPE)) { String investTypeFirst = request.getParameter("investTypeFirst"); String importDateFirst = request.getParameter("importDateFirst"); String origionValueFirst = request.getParameter("origionValueFirst"); record.setInvestType(investTypeFirst); record.setImportDate(importDateFirst); long origionValue = Math.round(Double.parseDouble(origionValueFirst) * 100); record.setOrigionValue(origionValue); record.setCurrValue(origionValue); record.setRecordType(recordType); } else { String totleGainsAndLosses = request.getParameter("totleGainsAndLosses"); String investType = request.getParameter("investType"); String importDate = request.getParameter("importDate"); long fee = getLongValue(request, "fee"); long gainsAndLosses = getLongValue(request, "gainsAndLosses"); long currIncome = getLongValue(request, "currIncome"); long currOutcome = getLongValue(request, "currOutcome"); long currValue = getLongValue(request, "currValue"); long lastDayValue = getLongValue(request, "lastDayValue"); long origionValue = getLongValue(request, "origionValue"); record.setTotalGainsAndLosses(totleGainsAndLosses); record.setFee(fee); record.setGainsAndLosses(gainsAndLosses); record.setCurrIncome(currIncome); record.setCurrOutcome(currOutcome); record.setCurrValue(currValue); record.setLastDayValue(lastDayValue); record.setOrigionValue(origionValue); record.setInvestType(investType); record.setImportDate(importDate); } return record; }
@RequestMapping( value = "/showReviewed/{id}", method = {RequestMethod.GET, RequestMethod.POST}) public String showReviewed(@PathVariable Long id, Page page, Map<String, Object> map) { BizTransRecord transRecord = transRecordService.get(id); if (null != transRecord) { long memberId = transRecord.getMemberId(); List<BizTransRecord> list = transRecordService.findTransRrcordByMemberAndTypeAndStatus( page, memberId, transRecord.getInvestType(), TransStatusEnum.S.getValue()); List<Map<String, String>> temp = new ArrayList<Map<String, String>>(); double divi = 1000000.0; for (BizTransRecord recordVO : list) { Map<String, String> tempMap = new HashMap<String, String>(); tempMap.put("id", recordVO.getId() + ""); tempMap.put( "investTypeStr", InvestDirectionEnum.getInvestDirectionEnum(recordVO.getInvestType()).getName()); tempMap.put("importDate", recordVO.getImportDate()); tempMap.put( "currIncomeWYuan", (null == recordVO.getCurrIncome() ? 0 : recordVO.getCurrIncome()) / divi + ""); tempMap.put( "currOutcomeWYuan", (null == recordVO.getCurrOutcome() ? 0 : recordVO.getCurrOutcome()) / divi + ""); tempMap.put("currValueWYuan", recordVO.getCurrValue() / divi + ""); tempMap.put( "lastDayValueWYuan", (null == recordVO.getLastDayValue() ? 0 : recordVO.getLastDayValue()) / divi + ""); tempMap.put("status", recordVO.getStatus()); String statusName = ""; if (StringUtils.equals(recordVO.getStatus(), "I")) { statusName = "审核中"; } else if (StringUtils.equals(recordVO.getStatus(), "S")) { statusName = "审核通过"; } else if (StringUtils.equals(recordVO.getStatus(), "F")) { BizReviewLog log = reviewLogService.getBizReviewLog(recordVO.getId(), "TRANS_RECORD"); if (null != log) { tempMap.put("failReason", log.getComment()); } statusName = "审核退回"; } else { statusName = "莫名其妙"; } tempMap.put("statusName", statusName); temp.add(tempMap); } map.put("page", page); map.put("data", temp); } return SHOW_REVIEWED; }
@RequestMapping( value = "/modifyLast/{id}", method = {RequestMethod.GET, RequestMethod.POST}) public String modifyLast(@PathVariable Long id, String type, Map<String, Object> map, Page page) { type = StringUtils.isBlank(type) ? InvestDirectionEnum.QI_HUO.getValue() : type; BizTransRecordVO vo; try { vo = transRecordService.findLastRecord(id, type); if (null != vo) { BizTransRecord transRecord = transRecordService.get(vo.getId()); map.put("id", transRecord.getId() + ""); map.put("investType", transRecord.getInvestType()); map.put( "investTypeName", InvestDirectionEnum.getInvestDirectionEnum(transRecord.getInvestType()).getName()); map.put("fee", getRealValue(transRecord.getFee())); map.put("gainsAndLosses", getRealValue(transRecord.getGainsAndLosses())); map.put("currIncome", getRealValue(transRecord.getCurrIncome())); map.put("currOutcome", getRealValue(transRecord.getCurrOutcome())); map.put("currValue", getRealValue(transRecord.getCurrValue())); map.put("lastDayValue", getRealValue(transRecord.getLastDayValue())); map.put("totalGainsAndLosses", transRecord.getTotalGainsAndLosses()); map.put("origionValue", getRealValue(transRecord.getOrigionValue())); map.put("status", transRecord.getStatus()); map.put("importDate", transRecord.getImportDate()); map.put("memberId", transRecord.getMemberId() + ""); } else { return null; } } catch (Exception e) { e.printStackTrace(); } return MODIFY_LAST; }