44323
2023-11-05 9baa55cf4292ad0fe80547f9c840e917775411f4
cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackageController.java
@@ -24,6 +24,7 @@
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.*;
@@ -32,6 +33,7 @@
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * @author zhibing.pu
@@ -61,6 +63,33 @@
    @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
@@ -78,6 +107,46 @@
        }
    }
    @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);
    }
    /**
     * 根据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));
    }
    /**
     * 本周福利列表
     */
@@ -116,11 +185,11 @@
            @ApiImplicitParam(name = "lat",value = "纬度",dataType = "String"),
    })
    public ResultUtil<ExchangeCoursePackageResponse> discountCourseDatas(Integer coursePackageDiscountId,String lon,String lat){
        try {
//        try {
            return ResultUtil.success(tcpdService.getWeekFreeCourseDetails(coursePackageDiscountId,lat,lon));
        }catch (Exception e){
            return ResultUtil.runErr();
        }
//        }catch (Exception e){
//            return ResultUtil.runErr();
//        }
    }
@@ -193,6 +262,7 @@
    @ResponseBody
    @PostMapping("/coursePackage/addCoursePackage")
    public Integer addCoursePackage(@RequestBody TCoursePackage coursePackage){
        coursePackage.setNeedNum(coursePackage.getCodeTime());
        return coursePackageService.addCoursePackage(coursePackage);
    }