发表于: 2017-12-22 21:39:45
1 586
一.今天完成的主要事情
1.完成查询收支/结算/订单详情接口
接口代码如下
@RequestMapping(value = "/a/u/finance/record/detail/list", method = RequestMethod.GET)
public String getFinanceRecordDetailList(HttpServletRequest request, HttpServletResponse response, ModelMap model,
Integer page, Integer size, Long id, Integer type) throws Exception {
log.info("Interface /a/u/fainance/record/detail/list, Method getFinanceRecordDetailList() parameters: " +
"id: " + id + ", type: " + type);
if (page == null) {
page = 1;
}
if (size == null) {
size = 10;
}
int start = (page - 1) * size;
if (start < 0) {
start = 0;
}
if (DataUtils.isNullOrEmpty(id)) {
log.info("Parameter id can not be null, id: " + id);
model.addAttribute("code", -1000);
return "/common/failure";
}
if (DataUtils.isNullOrEmpty(type)) {
log.info("Parameter type can not be null, type: " + type);
model.addAttribute("code", -1000);
return "/common/failure";
}
if (type < 0 || type > 3) {
log.info("Error value of parameter type, type: " + type);
model.addAttribute("code", -1001);
return "/common/failure";
}
try {
Map<String, Object> queryFinanceRecordDetailMap = DynamicUtil.getFinanceRecordDetailListParams(id, type, false);
log.info("query finance record detail map is : " + queryFinanceRecordDetailMap);
List<Long> enrollmentDetailIdList = enrollmentDetailService.getIdsByDynamicCondition(EnrollmentDetail.class,
queryFinanceRecordDetailMap, start, size);
log.info("get enrollment id list, list is : " + enrollmentDetailIdList);
List<EnrollmentDetail> enrollmentDetailList = null;
Long total = 0L;
if (CollectionUtils.isNotEmpty(enrollmentDetailIdList)) {
enrollmentDetailList = enrollmentDetailService.getObjectsByIds(enrollmentDetailIdList);
log.info("get enrollmentDetailList data, list size is : " + enrollmentDetailList.size());
Map<String, Object> countFinanceRecordDetailMap = DynamicUtil.getFinanceRecordDetailListParams(id, type, true);
log.info("count finance record detail map is : " + countFinanceRecordDetailMap);
total = enrollmentDetailService.getIdsByDynamicCondition(EnrollmentDetail.class,
countFinanceRecordDetailMap, 0, Integer.MAX_VALUE).get(0);
log.info("count enrollmentDetailList total is:" + total);
}
switch (type) {
case 0:
case 1:
model.addAttribute("enrollmentDetailListRecord", enrollmentDetailList);
break;
case 2:
model.addAttribute("enrollmentDetailListSettlement", enrollmentDetailList);
break;
case 3:
model.addAttribute("enrollmentDetailListWithdraw", enrollmentDetailList);
break;
default:
break;
}
model.addAttribute("code", 0);
model.addAttribute("size", size);
model.addAttribute("total", total);
return "/yi-nucleus-service/enrollmentDetail/json/financeRecordDetailList";
} catch (Throwable t) {
log.error(t.getMessage());
log.error("Method getFinanceRecordDetailList() failed, page is:" + page + ", size: " + size);
model.addAttribute("code", -1);
return "/common/failure";
}
}
依然是只完成了功能,第一时间提供数据给前端使用,具体代码还没有重构
2.完成查询提现订单列表接口
接口代码如下
@RequestMapping(value = "/a/u/withdrawal", method = RequestMethod.POST)
public String addWithdrawOrder(HttpServletRequest request, HttpServletResponse response, ModelMap model,
@RequestParam Long[] idArray, Long schoolId, String schoolName, BigDecimal withdrawAmount) throws Exception {
//打印参数
log.info("Inteface POST /a/u/withdrawal, Method addWithdrawOrder() parameters: schoolId is : " + schoolId +
", schoolName: " + schoolName + ", withdrawAmount: " + withdrawAmount + ", idArray: " + idArray);
//校验参数
if (DataUtils.isNullOrEmpty(schoolId)) {
log.info("parameter schoolId can not be null, schoolId: " + schoolId);
model.addAttribute("code", -1000);
return "/common/failure";
}
if (DataUtils.isNullOrEmpty(schoolName)) {
log.info("parameter schoolName can not be null, schoolName: " + schoolName);
model.addAttribute("code", -1000);
return "/common/failure";
}
if (DataUtils.isNullOrEmpty(withdrawAmount)) {
log.info("parameter withdrawAmount can not be null, withdrawAmount: " + withdrawAmount);
model.addAttribute("code", -1000);
return "/common/failure";
}
if (DataUtils.isNullOrEmpty(idArray)) {
log.info("parameter idArray can not be null or empty, idArray: " + idArray);
model.addAttribute("code", -1000);
return "/common/failure";
}
//实现逻辑
//TODO 该部分功能写好后打开注释
/*String managerIdStr = CookieUtil.getKeyIdentity(request, CookieUtil.UserID);
Long managerId = Long.parseLong(managerIdStr);
*/
//1.先生成Withdraw对象
Withdraw withdraw = new Withdraw();
withdraw.setSchoolId(schoolId);
withdraw.setSchoolName(schoolName);
withdraw.setWithdrawAmount(withdrawAmount);
withdraw.setStatus(1);
withdraw.setCreateBy(-1L);
withdraw.setUpdateBy(-1L);
/*withdraw.setCreateBy(managerId);
withdraw.setUpdateBy(managerId);*/
try {
//2.将该对象插入的withdrw表中,获取该条记录的withdrawId
Long withdrawId = withdrawService.insert(withdraw);
log.info("insert withdraw success, withdraw Id is : " + withdrawId);
//3.根据传入进来的IdList,查enrollment_detail表,获取enrollmentDetail对象List.
List<EnrollmentDetail> enrollmentDetailList = new ArrayList<>();
List<Long> idList = Arrays.asList(idArray);
enrollmentDetailList = enrollmentDetailService.getObjectsByIds(idList);
if (CollectionUtils.isEmpty(enrollmentDetailList)) {
log.info("Can not query data by idList, idList is : " + idList);
model.addAttribute("code", -1001);
return "/common/failure";
}
log.info("get enrollmentDetail list by idList, list size is : " + enrollmentDetailList.size());
//4.将该List中的每个元素的withdrawId的值改为withdrawId
for (int i = 0; i < enrollmentDetailList.size(); i++) {
enrollmentDetailList.get(i).setWithdrawId(withdrawId);
/* enrollmentDetailList.get(i).setUpdateBy(managerId);*/
}
//5.批量更新enrollment_detail表
enrollmentDetailService.updateList(enrollmentDetailList);
log.info("update enrollmentDetailList success, list size is " + enrollmentDetailList.size());
model.addAttribute("code", 0);
model.addAttribute("id", withdrawId);
return "/common/insert";
} catch (Throwable t) {
log.error(t.getMessage());
log.error("Method addWithdrawOrder() failed, schoolId: " + schoolId + ", schoolName: " +
schoolName + ", withdrawAmount: " + withdrawAmount + ", idArray: " + idArray);
model.addAttribute("code", -1);
return "/common/failure";
}
}
二.明天计划完成的主要事情
1.继续按照计划完成剩余的接口,目前还剩下最后一个接口,这个接口业务比较复杂,可能需要花费点时间
三.遇到的问题
暂无
四.收获
以上
五.项目进度情况
暂无延期风险
评论