| | |
| | | package com.dsh.course.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.course.entity.CoursePackagePaymentConfig; |
| | | import com.dsh.course.entity.TCoursePackage; |
| | | import com.dsh.course.model.vo.response.WeekLimitedResponse; |
| | | import com.dsh.course.entity.TCoursePackagePayment; |
| | | 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.vo.response.Details; |
| | | import com.dsh.course.model.vo.response.ExchangeCoursePackageResponse; |
| | | import com.dsh.course.service.ICoursePackagePaymentConfigService; |
| | | import com.dsh.course.service.TCoursePackageDiscountService; |
| | | import com.dsh.course.service.TCoursePackagePaymentService; |
| | | import com.dsh.course.service.TCoursePackageService; |
| | | import com.dsh.course.util.ResultUtil; |
| | | import com.dsh.course.util.TokenUtil; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | @Autowired |
| | | private TCoursePackageDiscountService tcpdService; |
| | | |
| | | @Resource |
| | | private StoreClient storeClient; |
| | | |
| | | @Resource |
| | | private TCoursePackagePaymentService tcppmenService; |
| | | |
| | | @Resource |
| | | private ICoursePackagePaymentConfigService icppconfigService; |
| | | |
| | | |
| | | @Autowired |
| | | private TokenUtil tokenUtil; |
| | |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/coursePackage/queryCoursePackageById") |
| | | @PostMapping("/base/coursePackage/queryCoursePackageById") |
| | | public TCoursePackage queryCoursePackageById(@RequestBody Integer id){ |
| | | try { |
| | | TCoursePackage coursePackage = coursePackageService.getById(id); |
| | |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/useBenefit/weekLimitedBenefit") |
| | | @ApiOperation(value = "使用福利-本周福利限时折扣列表", tags = {"APP-开始上课"}) |
| | | @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赠送课时)") |
| | | @ApiImplicitParam(name = "discountType",value = "默认显示 限时折扣 (1限时折扣 2赠送课时)",dataType = "int"), |
| | | @ApiImplicitParam(name = "lon",value = "经度",dataType = "String"), |
| | | @ApiImplicitParam(name = "lat",value = "纬度",dataType = "String"), |
| | | }) |
| | | public ResultUtil<WeekLimitedResponse> thisWeeksBenefitList(Integer discountType,String lon,String lat){ |
| | | public ResultUtil<List<Details>> thisWeeksBenefitList(Integer discountType, String lon, String lat){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | if(null == appUserId){ |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 折扣课包详情 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/useBenefit/discountCourseDatas") |
| | | @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<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)); |
| | | 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() + ")"); |
| | | courseVo.setClassStartTime(coursePackage.getClassStartTime() +"-"+ coursePackage.getClassEndTime()); |
| | | 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); |
| | | if (minConfig != null){ |
| | | courseVo.setClassHours(minConfig.getClassHours()); |
| | | courseVo.setOriginalPrice(minConfig.getCashPayment()); |
| | | } |
| | | |
| | | courseVoList.add(courseVo); |
| | | } |
| | | } |
| | | return courseVoList; |
| | | } |
| | | |
| | | /** |
| | | * 根据id获取课包 |
| | | * @param coursePackConfigId |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/coursePackage/queryConfigCoursePackData") |
| | | public CoursePackagePaymentConfig queryConfigCoursePackData(@RequestBody Integer coursePackConfigId){ |
| | | return icppconfigService.getById(coursePackConfigId); |
| | | } |
| | | |
| | | } |