| | |
| | | package com.dsh.course.controller; |
| | | |
| | | import com.dsh.course.entity.TCoursePackage; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.dsh.course.entity.*; |
| | | import com.dsh.course.feignclient.model.StoreOfCourseVo; |
| | | import com.dsh.course.feignclient.other.StoreClient; |
| | | import com.dsh.course.feignclient.other.model.Store; |
| | | import com.dsh.course.model.BaseVo; |
| | | import com.dsh.course.model.QueryCoursePackageLists; |
| | | import com.dsh.course.model.QueryExamineCoursePackageLists; |
| | | import com.dsh.course.model.vo.response.Details; |
| | | import com.dsh.course.model.vo.response.ExchangeCoursePackageResponse; |
| | | import com.dsh.course.service.TCoursePackageDiscountService; |
| | | import com.dsh.course.service.TCoursePackageService; |
| | | import com.dsh.course.service.*; |
| | | import com.dsh.course.util.PageFactory; |
| | | import com.dsh.course.util.ResultUtil; |
| | | import com.dsh.course.util.TokenUtil; |
| | | import com.dsh.course.util.ToolUtil; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.bouncycastle.math.Primes; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | @Autowired |
| | | private TCoursePackageDiscountService tcpdService; |
| | | |
| | | @Resource |
| | | private StoreClient storeClient; |
| | | |
| | | @Resource |
| | | private TCoursePackagePaymentService tcppmenService; |
| | | |
| | | @Resource |
| | | private ICoursePackagePaymentConfigService icppconfigService; |
| | | |
| | | |
| | | @Autowired |
| | | private TokenUtil tokenUtil; |
| | | |
| | | |
| | | /** |
| | | * 根据门店ids获取课包ids 根据课包ids 获取购课记录的用户ids |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/coursePackage/getCoursePackageByStoreIds") |
| | | public List<Integer> getCoursePackageByStoreIds(@RequestBody List<Integer> storeIds) { |
| | | try { |
| | | // 获取当前课包的ids |
| | | List<Integer> courseIds = coursePackageService.list(new QueryWrapper<TCoursePackage>().in("storeId", storeIds)) |
| | | .stream().map(TCoursePackage::getId).collect(Collectors.toList()); |
| | | if (courseIds.size() == 0) { |
| | | return new ArrayList<>(); |
| | | } else { |
| | | List<Integer> userIds = tcppmenService.list(new QueryWrapper<TCoursePackagePayment>().in("coursePackageId", courseIds)) |
| | | .stream().map(TCoursePackagePayment::getAppUserId).collect(Collectors.toList()); |
| | | return userIds; |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据id获取课包 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/coursePackage/queryCoursePackageById") |
| | | public TCoursePackage queryCoursePackageById(@RequestBody Integer id){ |
| | | @PostMapping("/base/coursePackage/queryCoursePackageById") |
| | | public TCoursePackage queryCoursePackageById(@RequestBody Integer id) { |
| | | try { |
| | | TCoursePackage coursePackage = coursePackageService.getById(id); |
| | | return coursePackage; |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/coursePackage/queryByStoreId") |
| | | public List<TCoursePackage> queryByStoreId(@RequestBody Integer shopId) { |
| | | try { |
| | | List<TCoursePackage> shopId1 = coursePackageService.list(new QueryWrapper<TCoursePackage>().eq("storeId", shopId)); |
| | | return shopId1; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @Autowired |
| | | private TCoursePackagePaymentService packagePaymentService; |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/coursePackage/queryByCode") |
| | | public Integer queryByCode(@RequestBody String code) { |
| | | |
| | | |
| | | return packagePaymentService.listStoreId(code); |
| | | } |
| | | |
| | | @Autowired |
| | | private CoursePackageStudentService coursePackageStudentService; |
| | | |
| | | @Autowired |
| | | private UserVideoDetailsService userVideoDetailsService; |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/coursePackage/counts") |
| | | public Integer counts(@RequestBody Integer stuId) { |
| | | return coursePackageStudentService.count(new QueryWrapper<CoursePackageStudent>().eq("signInOrNot", 1).eq("studentId", stuId)); |
| | | |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/coursePackage/counts1") |
| | | public Integer counts1(@RequestBody Integer stuId) { |
| | | return userVideoDetailsService.count(new QueryWrapper<UserVideoDetails>().eq("appUserId", stuId)); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 根据id获取课包 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/coursePackage/getCoursePackageByStoreId") |
| | | public List<TCoursePackage> getCoursePackageByStoreId(@RequestBody Integer storeId) { |
| | | |
| | | return coursePackageService.list(new QueryWrapper<TCoursePackage>().eq("storeId", storeId)); |
| | | } |
| | | |
| | | /** |
| | | * 根据课包类型获取课包 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/coursePackage/getCoursePackageByType/{typeId}/{storeId}") |
| | | public List<TCoursePackage> getCoursePackageByType(@PathVariable("typeId") Integer typeId, @PathVariable("storeId") Integer storeId) { |
| | | |
| | | return coursePackageService.list(new QueryWrapper<TCoursePackage>().eq("coursePackageTypeId", typeId).eq("storeId", storeId)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation(value = "本周福利-限时折扣列表", tags = {"APP-使用福利"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | @ApiImplicitParam(name = "discountType",value = "默认显示 限时折扣 (1限时折扣 2赠送课时)",dataType = "int"), |
| | | @ApiImplicitParam(name = "lon",value = "经度",dataType = "String"), |
| | | @ApiImplicitParam(name = "lat",value = "纬度",dataType = "String"), |
| | | @ApiImplicitParam(name = "discountType", value = "默认显示 限时折扣 (1限时折扣 2赠送课时)", dataType = "int"), |
| | | @ApiImplicitParam(name = "lon", value = "经度", dataType = "String"), |
| | | @ApiImplicitParam(name = "lat", value = "纬度", dataType = "String"), |
| | | }) |
| | | public ResultUtil<List<Details>> thisWeeksBenefitList(Integer discountType, String lon, String lat){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | if(null == appUserId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return ResultUtil.success(tcpdService.getWeeksBenefitCourse(appUserId,discountType,lon,lat)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | public ResultUtil<List<Details>> thisWeeksBenefitList(Integer discountType, String lon, String lat) throws Exception { |
| | | // try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | if (null == appUserId) { |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | String[] strings = {"今日", "明日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"}; |
| | | List<String> stringList = new ArrayList<>(Arrays.asList(strings)); |
| | | |
| | | List<Details> weeksBenefitCourse = tcpdService.getWeeksBenefitCourse(appUserId, discountType, lon, lat); |
| | | |
| | | weeksBenefitCourse.sort(new Comparator<Details>() { |
| | | @Override |
| | | public int compare(Details o1, Details o2) { |
| | | return stringList.indexOf(o1.getDataTime()) - stringList.indexOf(o2.getDataTime()); |
| | | } |
| | | }); |
| | | |
| | | |
| | | // return ResultUtil.success(tcpdService.getWeeksBenefitCourse(appUserId,discountType,lon,lat)); |
| | | return ResultUtil.success(weeksBenefitCourse); |
| | | // }catch (Exception e){ |
| | | // return ResultUtil.runErr(); |
| | | // } |
| | | } |
| | | |
| | | |
| | |
| | | @ApiOperation(value = "本周福利-折扣课包详情", tags = {"APP-使用福利"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | @ApiImplicitParam(name = "coursePackageDiscountId",value = "限时折扣配置id/赠送课时配置id",dataType = "int"), |
| | | @ApiImplicitParam(name = "lon",value = "经度",dataType = "String"), |
| | | @ApiImplicitParam(name = "lat",value = "纬度",dataType = "String"), |
| | | @ApiImplicitParam(name = "coursePackageDiscountId", value = "限时折扣配置id/赠送课时配置id", dataType = "int"), |
| | | @ApiImplicitParam(name = "lon", value = "经度", dataType = "String"), |
| | | @ApiImplicitParam(name = "lat", value = "纬度", dataType = "String"), |
| | | }) |
| | | public ResultUtil<ExchangeCoursePackageResponse> discountCourseDatas(Integer coursePackageDiscountId,String lon,String lat){ |
| | | try { |
| | | return ResultUtil.success(tcpdService.getWeekFreeCourseDetails(coursePackageDiscountId,lat,lon)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | public ResultUtil<ExchangeCoursePackageResponse> discountCourseDatas(Integer coursePackageDiscountId, String lon, String lat) { |
| | | // try { |
| | | return ResultUtil.success(tcpdService.getWeekFreeCourseDetails(coursePackageDiscountId, lat, lon)); |
| | | // }catch (Exception e){ |
| | | // return ResultUtil.runErr(); |
| | | // } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/coursePack/courseList") |
| | | public List<StoreOfCourseVo> getStoreOfCourseList(@RequestBody Integer storeId) { |
| | | List<StoreOfCourseVo> courseVoList = new ArrayList<>(); |
| | | Store store = storeClient.queryStoreById(storeId); |
| | | List<TCoursePackage> list = coursePackageService.list(new QueryWrapper<TCoursePackage>() |
| | | .eq("storeId", storeId) |
| | | .eq("auditStatus", 2) |
| | | .eq("state", 1).orderByDesc("insertTime")); |
| | | if (list.size() > 0) { |
| | | for (TCoursePackage coursePackage : list) { |
| | | int count = tcppmenService.count(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("coursePackageId", coursePackage.getId())); |
| | | StoreOfCourseVo courseVo = new StoreOfCourseVo(); |
| | | courseVo.setCourseId(coursePackage.getId()); |
| | | courseVo.setName(coursePackage.getName() + "(" + store.getName() + ")"); |
| | | |
| | | |
| | | String classStartTime = coursePackage.getClassStartTime(); |
| | | String classEndTime = coursePackage.getClassEndTime(); |
| | | ArrayList<String> classTime = new ArrayList<>(); |
| | | String[] split4 = classStartTime.split(","); |
| | | String[] split3 = classEndTime.split(","); |
| | | if (ToolUtil.isNotEmpty(classStartTime)) { |
| | | for (int i = 0; i < split4.length; i++) { |
| | | String s = split4[i].substring(0, 5) + "-" + split3[i].substring(0, 5); |
| | | classTime.add(s); |
| | | } |
| | | } |
| | | |
| | | // coursePackageInfo.setTimes(classTime); |
| | | String classTimeAsString = String.join("|", classTime); |
| | | |
| | | |
| | | courseVo.setClassStartTime(classTimeAsString); |
| | | courseVo.setCoverDrawing(coursePackage.getCoverDrawing()); |
| | | courseVo.setApplicantsNumber(count); |
| | | List<CoursePackagePaymentConfig> list1 = icppconfigService.list(new QueryWrapper<CoursePackagePaymentConfig>() |
| | | .eq("coursePackageId", coursePackage.getId())); |
| | | // 取价格最低的课时 |
| | | CoursePackagePaymentConfig minConfig = list1.stream() |
| | | .min(Comparator.comparingDouble(CoursePackagePaymentConfig::getCashPayment)) |
| | | .orElse(null); |
| | | List<Integer> classHours = new ArrayList<>(); |
| | | for (CoursePackagePaymentConfig coursePackagePaymentConfig : list1) { |
| | | classHours.add(coursePackagePaymentConfig.getClassHours()); |
| | | } |
| | | |
| | | if (minConfig != null) { |
| | | courseVo.setClassHours(classHours); |
| | | courseVo.setOriginalPrice(minConfig.getCashPayment()); |
| | | courseVo.setCoin(minConfig.getPlayPaiCoin()); |
| | | } |
| | | |
| | | courseVoList.add(courseVo); |
| | | } |
| | | } |
| | | return courseVoList; |
| | | } |
| | | |
| | | /** |
| | | * 根据id获取课包 |
| | | * |
| | | * @param coursePackConfigId |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/coursePackage/queryConfigCoursePackData") |
| | | public CoursePackagePaymentConfig queryConfigCoursePackData(@RequestBody Integer coursePackConfigId) { |
| | | return icppconfigService.getById(coursePackConfigId); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 折扣课包支付 |
| | | * 获取课包管理列表数据 |
| | | * |
| | | * @param queryCoursePackageLists |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/useBenefit/paymentOfDiscountCoursePack") |
| | | @ApiOperation(value = "本周福利-折扣课包支付", tags = {"APP-使用福利"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | @ApiImplicitParam(name = "coursePackageDiscountId",value = "限时折扣配置id/赠送课时配置id",dataType = "int"), |
| | | @ApiImplicitParam(name = "lon",value = "经度",dataType = "String"), |
| | | @ApiImplicitParam(name = "lat",value = "纬度",dataType = "String"), |
| | | }) |
| | | public ResultUtil paymentWeeksFreeCourse(Integer coursePackageDiscountId){ |
| | | try { |
| | | Integer appuserId = tokenUtil.getUserIdFormRedis(); |
| | | if(null == appuserId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return tcpdService.paymentDiscountCoursePack(coursePackageDiscountId,appuserId); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | @PostMapping("/coursePackage/queryCoursePackageLists") |
| | | public Page<Map<String, Object>> queryCoursePackageLists(@RequestBody QueryCoursePackageLists queryCoursePackageLists) { |
| | | Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(queryCoursePackageLists.getLimit(), queryCoursePackageLists.getOffset(), queryCoursePackageLists.getSort(), queryCoursePackageLists.getOrder()); |
| | | Page<Map<String, Object>> mapPage = page.setRecords(coursePackageService.queryCoursePackageLists(page, queryCoursePackageLists)); |
| | | return mapPage; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加数据 |
| | | * |
| | | * @param coursePackage |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/coursePackage/addCoursePackage") |
| | | public Integer addCoursePackage(@RequestBody TCoursePackage coursePackage) { |
| | | coursePackage.setInsertTime(new Date()); |
| | | coursePackage.setNeedNum(coursePackage.getCodeTime()); |
| | | return coursePackageService.addCoursePackage(coursePackage); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改数据 |
| | | * |
| | | * @param coursePackage |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/coursePackage/updateCoursePackageById") |
| | | public void updateCoursePackageById(@RequestBody TCoursePackage coursePackage) { |
| | | coursePackageService.updateCoursePackageById(coursePackage); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取课包审核列表 |
| | | * |
| | | * @param queryExamineCoursePackageLists |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/coursePackage/queryExamineCoursePackageLists") |
| | | public Page<Map<String, Object>> queryExamineCoursePackageLists(@RequestBody QueryExamineCoursePackageLists queryExamineCoursePackageLists) { |
| | | Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(queryExamineCoursePackageLists.getLimit(), queryExamineCoursePackageLists.getOffset(), |
| | | queryExamineCoursePackageLists.getSort(), queryExamineCoursePackageLists.getOrder()); |
| | | Page<Map<String, Object>> mapPage = page.setRecords(coursePackageService.queryExamineCoursePackageLists(page, queryExamineCoursePackageLists)); |
| | | return mapPage; |
| | | } |
| | | } |