| | |
| | | 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.TCoursePackage; |
| | | import com.dsh.course.entity.TCoursePackagePayment; |
| | | import com.dsh.course.entity.TCoursePackageType; |
| | | import com.dsh.course.entity.*; |
| | | import com.dsh.course.feignclient.model.ExerciseVideo; |
| | | import com.dsh.course.model.*; |
| | | 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.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.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.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Api |
| | | @CrossOrigin |
| | |
| | | |
| | | @Autowired |
| | | private TCoursePackagePaymentService coursePackagePaymentService; |
| | | |
| | | @Autowired |
| | | private TCoursePackageDiscountService discountService; |
| | | |
| | | /** |
| | | * 上/下架 1为上架 2为下架 3为删除 |
| | |
| | | public String 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; |
| | | } |
| | | |
| | | |
| | | @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){ |
| | | TCoursePackageDiscount byId = discountService.getById(auditDiscount.getId()); |
| | | List<TCoursePackageDiscount> list = discountService.list(new LambdaQueryWrapper<TCoursePackageDiscount>().eq(TCoursePackageDiscount::getCoursePackageId, byId.getCoursePackageId())); |
| | | for (TCoursePackageDiscount tCoursePackageDiscount : list) { |
| | | tCoursePackageDiscount.setAuditStatus(auditDiscount.getType()); |
| | | tCoursePackageDiscount.setAuditRemark(auditDiscount.getText()); |
| | | } |
| | | |
| | | return discountService.updateBatchById(list); |
| | | } |
| | | |
| | | @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; |
| | | } |
| | | } |