发表于: 2018-01-05 23:24:40
1 680
今天完成的事情:
1.完成了支付模块
2.完成资料与课程,课时,教材关系
public String getData(HttpServletRequest request, ModelMap model,Integer dataBelongType,Long dataBelongId) throws Exception {
// 验参
boolean isIllegal=CheckTheParameters.valueIsIllegal(dataBelongType,CheckTheParameters.typeOfCheck.DATA_BELONG);
List<Long> orderedId=new ArrayList <>();
List<Long> dataIdsOfLessonOrBook=new ArrayList <>();
List<Long> dataIdsOfPeriod=new ArrayList <>();
List<Long> unorderedIds=new ArrayList <>();
List<Long> ordereds=new ArrayList <>();
BigDecimal datasPrice=new BigDecimal(0);
try {
if (isIllegal){
model.addAttribute("code",-3);
}else {
log.info("=====获取用户ID=====");
// String token = CookieUtil.getCookie(request, "token");
// String[] mToken = DesUtil.getStrM(token).split(",");
// Long uid = Long.parseLong(mToken[0]);
Long uid=28L;
if (dataBelongType==1||dataBelongType==2){
// 取出课程或教材包含的课时的资料
Map<String,Object> params=DynamicSQL.getDataByIdAndType(dataBelongId,dataBelongType,null);
dataIdsOfLessonOrBook=dataService.getIdsByDynamicCondition(Data.class,params,0,Integer.MAX_VALUE);
// 取出已购买的资料
for (Long dataId:dataIdsOfLessonOrBook
) {
Map<String,Object> orderParams=DynamicSQL.getOrdered(4,dataId,uid);
orderedId=userOrderService.getIdsByDynamicCondition(UserOrder.class,orderParams,0,Integer.MAX_VALUE);
System.out.println(orderedId);
if (orderedId.size()==0){
unorderedIds.add(dataId);
datasPrice=datasPrice.add(dataService.getObjectById(dataId).getPrice());
}else {
ordereds.add(orderedId.get(0));
}
}
model.addAttribute("dataId",unorderedIds);
model.addAttribute("datasPrice",datasPrice);
if (dataIdsOfLessonOrBook.size()==0){
model.addAttribute("status",1);
}else if (ordereds.size()==0){
model.addAttribute("status",2);
}else if (ordereds.size()!=0){
model.addAttribute("status",3);
}
}else if (dataBelongType==3){
Map<String,Object> dataParams=DynamicSQL.getDataByIdAndType(null,null,dataBelongId);
dataIdsOfPeriod=dataService.getIdsByDynamicCondition(Data.class,dataParams,0,Integer.MAX_VALUE);
for (Long dataId:dataIdsOfPeriod
) {
Map<String,Object> orderParams=DynamicSQL.getOrdered(4,dataId,uid);
ordereds=userOrderService.getIdsByDynamicCondition(UserOrder.class,orderParams,0,Integer.MAX_VALUE);
}
if (dataIdsOfPeriod.size()==0){
model.addAttribute("status",1);
}else if(ordereds.size()==0){
datasPrice=dataService.getObjectById(dataIdsOfPeriod.get(0)).getPrice();
model.addAttribute("status",2);
model.addAttribute("dataId",dataIdsOfPeriod.get(0));
model.addAttribute("datasPrice",datasPrice);
}else if (ordereds.size()!=0){
model.addAttribute("status",3);
model.addAttribute("dataId",dataIdsOfPeriod.get(0));
}
}
model.addAttribute("code",0);
}
}catch (Exception e){
e.printStackTrace();
model.addAttribute("code",-1);
}
return "/jsps/course-jsp/lesson/json/dataStatus";
}
明天计划完成的事情:
1.测试
遇到的问题:写的接口不严谨,经常会有漏洞
收获:暂无
评论