| | |
| | | |
| | | |
| | | import cn.mb.cloud.common.data.controller.BaseController; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.dsh.course.entity.TCourse; |
| | | import com.dsh.course.entity.TCoursePackagePayment; |
| | | import com.dsh.course.entity.TCoursePackageType; |
| | | import com.dsh.course.entity.*; |
| | | import com.dsh.course.entity.dto.SelectDto; |
| | | import com.dsh.course.feignclient.model.ExerciseVideo; |
| | | import com.dsh.course.model.*; |
| | | import com.dsh.course.service.TCoursePackagePaymentService; |
| | | import com.dsh.course.service.TCoursePackageService; |
| | | import com.dsh.course.service.TCoursePackageTypeService; |
| | | import com.dsh.course.service.TCourseService; |
| | | import com.dsh.course.util.PageFactory; |
| | | import com.dsh.course.util.PayMoneyUtil; |
| | | import com.dsh.course.util.ResultUtil; |
| | | import com.dsh.course.util.TokenUtil; |
| | | import com.dsh.course.model.dto.CourseChangeStateDTO; |
| | | import com.dsh.course.model.dto.TQueryBenefitsVideosDTO; |
| | | import com.dsh.course.model.vo.TQueryBenefitsVideosVO; |
| | | import com.dsh.course.service.*; |
| | | import com.dsh.course.util.*; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.PrintWriter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Api |
| | | @CrossOrigin |
| | |
| | | @Autowired |
| | | private TCoursePackagePaymentService coursePackagePaymentService; |
| | | |
| | | @Autowired |
| | | private TCoursePackageDiscountService discountService; |
| | | |
| | | /** |
| | | * 上/下架 1为上架 2为下架 3为删除 |
| | | * |
| | | * @return |
| | | */ |
| | | @RequestMapping("/base/course/changeState") |
| | | @ResponseBody |
| | | public Object changeState(@RequestBody CourseChangeStateDTO dto){ |
| | | return courseService.changeState(dto); |
| | | } |
| | | |
| | | /** |
| | | * 通过课程ids获取课程 |
| | | * @return |
| | | */ |
| | | @RequestMapping("/base/course/getCourseByCourseIds") |
| | | public List<TQueryBenefitsVideosVO> getCourseByCourseIds(@RequestBody TQueryBenefitsVideosDTO query){ |
| | | |
| | | |
| | | return courseService.getCourseByCourseIds(query); |
| | | } |
| | | |
| | | @PostMapping("/base/course/queryList") |
| | | public List<ExerciseVideo> queryStuCourseAfterVideos(@RequestBody List<Integer> courseIds){ |
| | |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/course/queryCourseList") |
| | | @ApiOperation(value = "获取课程列表", tags = {"APP-课程列表"}) |
| | |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/course/queryCourseListOne") |
| | | @ApiOperation(value = "获取课程列表", tags = {"APP-课程列表"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<List<CoursePackageListVo>> queryCourseListOne(CoursePackageList coursePackageList){ |
| | | try { |
| | | List<CoursePackageListVo> coursePackageListVos = coursePackageService.queryCourseListOne( coursePackageList); |
| | | return ResultUtil.success(coursePackageListVos); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/course/paymentCourse") |
| | | @ApiOperation(value = "支付课程", tags = {"APP-课程列表"}) |
| | |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | Long couponId = paymentCourseVo.getCouponId(); |
| | | if(couponId==null || couponId==0){ |
| | | paymentCourseVo.setCouponId(null); |
| | | } |
| | | return coursePackageService.paymentCourse(uid, paymentCourseVo); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | } |
| | | } |
| | | |
| | | // 2.0 |
| | | @ResponseBody |
| | | @PostMapping("/api/course/paymentCourseCouponList") |
| | | @ApiOperation(value = "支付课程--完成后优惠券列表", tags = {"APP-课程列表"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil paymentCourseCouponList(Integer coursePackagePaymentConfigId){ |
| | | try { |
| | | Integer uid = tokenUtil.getUserIdFormRedis(); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return coursePackageService.paymentCourseCouponList(uid, coursePackagePaymentConfigId); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 购买课程微信支付回调 |
| | |
| | | @PostMapping("/base/course/aliPaymentCourseCallback") |
| | | public void aliPaymentCourseCallback(HttpServletRequest request, HttpServletResponse response){ |
| | | try { |
| | | System.err.println("=====支付宝回调======="); |
| | | Map<String, String> map = payMoneyUtil.alipayCallback(request); |
| | | if(null != map){ |
| | | String code = map.get("out_trade_no"); |
| | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | //分账 |
| | | public void moneyOut(){ |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @PostMapping("/course/getPageageType") |
| | | public List<Map<String, Object>> getPageageType(){ |
| | | List<TCoursePackageType> list = coursePackageTypeService.list(new LambdaQueryWrapper<TCoursePackageType>().eq(TCoursePackageType::getState, 1)); |
| | | ArrayList<Map<String, Object>> objects = new ArrayList<>(); |
| | | for (TCoursePackageType tCoursePackageType : list) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("id",tCoursePackageType.getId()); |
| | | map.put("name",tCoursePackageType.getName()); |
| | | objects.add(map); |
| | | } |
| | | return objects; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取课程管理列表数据 |
| | | * @param queryCourseList |
| | |
| | | @ResponseBody |
| | | @PostMapping("/course/addCourse") |
| | | public void addCourse(@RequestBody TCourse course){ |
| | | course.setState(1); |
| | | course.setInsertTime(new Date()); |
| | | courseService.save(course); |
| | | } |
| | | |
| | |
| | | public List<TCourse> queryCourseByType(@RequestBody Integer type){ |
| | | return courseService.list(new QueryWrapper<TCourse>().eq("type", type).eq("state", 1)); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/course/queryPackageById") |
| | | public List<String> queryPackageById(@RequestBody Integer coursePackageId){ |
| | | ArrayList<String> strings = new ArrayList<>(); |
| | | TCoursePackage byId = coursePackageService.getById(coursePackageId); |
| | | Integer coursePackageTypeId = byId.getCoursePackageTypeId(); |
| | | strings.add(coursePackageTypeService.getById(coursePackageTypeId).getName()); |
| | | strings.add(byId.getName()); |
| | | |
| | | return strings; |
| | | |
| | | } |
| | | |
| | | @PostMapping("/course/getHours") |
| | | public List<Integer> getHours(@RequestBody Integer coursePackageId1){ |
| | | return coursePackageService.getHours(coursePackageId1); |
| | | } |
| | | |
| | | @PostMapping("/course/queryByDiscountId") |
| | | public TCoursePackage queryByDiscountId(@RequestBody Integer id){ |
| | | TCoursePackageDiscount byId = discountService.getById(id); |
| | | TCoursePackage byId1 = coursePackageService.getById(byId.getCoursePackageId()); |
| | | return byId1; |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/course/queryByDiscountId1") |
| | | public TCoursePackage queryByDiscountId1(@RequestBody Integer id){ |
| | | TCoursePackageDiscount byId = discountService.getById(id); |
| | | TCoursePackage byId1 = coursePackageService.getById(byId.getCoursePackageId()); |
| | | return byId1; |
| | | } |
| | | |
| | | |
| | | @PostMapping("/course/queryDiscountById") |
| | | public Integer queryDiscountById(@RequestBody Integer id){ |
| | | TCoursePackageDiscount byId = discountService.getById(id); |
| | | return byId.getAuditStatus(); |
| | | } |
| | | @PostMapping("/course/queryDiscountList") |
| | | public List<DiscountList> queryDiscountList(@RequestBody QueryDiscountList queryDiscountList){ |
| | | return discountService.queryDiscountList(queryDiscountList); |
| | | } |
| | | |
| | | @PostMapping("/course/queryDiscountListAudit") |
| | | public List<DiscountList> queryDiscountListAudit(@RequestBody QueryDiscountList queryDiscountList){ |
| | | return discountService.queryDiscountListAudit(queryDiscountList); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/course/updateState") |
| | | public Boolean updateState( @RequestBody DiscountUpdateState discountUpdateState){ |
| | | TCoursePackageDiscount byId = discountService.getById(discountUpdateState.getId()); |
| | | List<TCoursePackageDiscount> list = discountService.list(new LambdaQueryWrapper<TCoursePackageDiscount>().eq(TCoursePackageDiscount::getCoursePackageId, byId.getCoursePackageId())); |
| | | list.forEach(e->e.setStatus(discountUpdateState.getStatus())); |
| | | return discountService.updateBatchById(list); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/course/auditDiscount") |
| | | public Boolean auditDiscount( @RequestBody AuditDiscount auditDiscount){ |
| | | |
| | | List<TCoursePackageDiscount> list = discountService.list(new LambdaQueryWrapper<TCoursePackageDiscount>() |
| | | .eq(TCoursePackageDiscount::getCoursePackageId, auditDiscount.getId())); |
| | | for (TCoursePackageDiscount tCoursePackageDiscount : list) { |
| | | tCoursePackageDiscount.setAuditStatus(auditDiscount.getType()); |
| | | tCoursePackageDiscount.setAuditRemark(auditDiscount.getText()); |
| | | } |
| | | |
| | | return discountService.updateBatchById(list); |
| | | } |
| | | @Autowired |
| | | private ICoursePackagePaymentConfigService packagePaymentConfigService; |
| | | @PostMapping("/course/times") |
| | | public List<SelectDto> times(@RequestBody Integer oneId){ |
| | | List<CoursePackagePaymentConfig> list = packagePaymentConfigService.list(new QueryWrapper<CoursePackagePaymentConfig>().eq("coursePackageId",oneId)); |
| | | List<SelectDto> integerList = new ArrayList<>(); |
| | | for (CoursePackagePaymentConfig coursePackagePaymentConfig : list) { |
| | | // integerList.add(coursePackagePaymentConfig.getClassHours()); |
| | | SelectDto selectDto = new SelectDto(); |
| | | selectDto.setId(coursePackagePaymentConfig.getId()); |
| | | selectDto.setValue(String.valueOf(coursePackagePaymentConfig.getClassHours())); |
| | | integerList.add(selectDto); |
| | | } |
| | | |
| | | |
| | | return integerList; |
| | | } |
| | | |
| | | @PostMapping("/course/queryFee") |
| | | public HashMap<String, Object> queryFee(@RequestBody QueryDataFee queryDataFee){ |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | String data = queryDataFee.getData(); |
| | | List<Integer> ids = queryDataFee.getIds(); |
| | | if(ids.size()==0){ |
| | | ids.add(-1); |
| | | } |
| | | |
| | | LambdaQueryWrapper<TCoursePackagePayment> wrapper = new LambdaQueryWrapper<>(); |
| | | if(ToolUtil.isNotEmpty(data)){ |
| | | String stime = data.split(" - ")[0]+" 00:00:00"; |
| | | String etime = data.split(" - ")[1]+" 23:59:59"; |
| | | wrapper.between(TCoursePackagePayment::getInsertTime,stime,etime); |
| | | } |
| | | wrapper.in(TCoursePackagePayment::getAppUserId,ids); |
| | | wrapper.eq(TCoursePackagePayment::getPayStatus,2); |
| | | ArrayList<Integer> objects = new ArrayList<>(); |
| | | objects.add(1); |
| | | objects.add(2); |
| | | objects.add(5); |
| | | objects.add(6); |
| | | wrapper.in(TCoursePackagePayment::getPayType,objects); |
| | | List<TCoursePackagePayment> list = coursePackagePaymentService.list(wrapper); |
| | | double v = list.stream().map(TCoursePackagePayment::getCashPayment).reduce(BigDecimal.ZERO, BigDecimal::add).doubleValue(); |
| | | List<Integer> collect = list.stream().map(TCoursePackagePayment::getCoursePackageId).collect(Collectors.toList()); |
| | | if(collect.size()==0){ |
| | | collect.add(-1); |
| | | } |
| | | // |
| | | List<TCoursePackage> list2 = coursePackageService.list(new LambdaQueryWrapper<TCoursePackage>().in(TCoursePackage::getId, collect)); |
| | | // 课类型 |
| | | List<TCoursePackageType> list1 = coursePackageTypeService.list(); |
| | | |
| | | for (TCoursePackagePayment tCoursePackagePayment : list) { |
| | | for (TCoursePackage tCoursePackage : list2) { |
| | | if(tCoursePackagePayment.getCoursePackageId().equals(tCoursePackage.getId())){ |
| | | tCoursePackagePayment.setType(tCoursePackage.getCoursePackageTypeId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | ArrayList<HashMap<String, Object>> hashMaps = new ArrayList<>(); |
| | | |
| | | for (TCoursePackageType tCoursePackageType : list1) { |
| | | HashMap<String, Object> objectObjectHashMap = new HashMap<>(); |
| | | objectObjectHashMap.put("name",tCoursePackageType.getName()); |
| | | double a= 0; |
| | | for (TCoursePackagePayment tCoursePackagePayment : list) { |
| | | if(tCoursePackagePayment.getType().equals(tCoursePackageType.getId())){ |
| | | a += tCoursePackagePayment.getCashPayment().doubleValue(); |
| | | } |
| | | } |
| | | objectObjectHashMap.put("value",a); |
| | | hashMaps.add(objectObjectHashMap); |
| | | } |
| | | |
| | | HashMap<String, Object> map1 = new HashMap<>(); |
| | | map1.put("fee",v); |
| | | map1.put("data",hashMaps); |
| | | |
| | | return map1; |
| | | } |
| | | } |