puzhibing
2023-07-27 614b0106f079e67bb674a37ede2bd0fe3df2a430
cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java
@@ -6,6 +6,8 @@
import com.dsh.course.feignclient.account.AppUserClient;
import com.dsh.course.feignclient.account.model.AppUser;
import com.dsh.course.feignclient.model.*;
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.dto.DiscountJsonDto;
import com.dsh.course.model.vo.CourseDetailRequest;
@@ -35,7 +37,10 @@
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Api
@@ -82,6 +87,9 @@
    @Resource
    private AppUserClient auClitn;
    @Resource
    private StoreClient sreClient;
    private final SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm");
    /**
@@ -90,10 +98,16 @@
     * @return  课包列表
     */
    @PostMapping("/base/coursePack/queryPayment")
    public List<StuCourseResp> getStuCoursePackagePayment(@RequestParam("stuId") Integer stuId,@RequestParam("appUserId") Integer appUserId){
    public List<StuCourseResp> getStuCoursePackagePayment(@RequestBody Integer stuId){
        Integer userIdFormRedis = null;
        try {
            userIdFormRedis = tokenUtil.getUserIdFormRedis();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        List<StuCourseResp> resps = new ArrayList<>();
        List<TCoursePackagePayment> byUserId = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>()
                .eq("appUserId",appUserId)
                .eq("appUserId",userIdFormRedis)
                .eq("studentId",stuId));
        if (byUserId.size() > 0 ){
@@ -105,6 +119,8 @@
                resp.setTotalCourseNums(tCoursePackagePayment.getTotalClassHours());
                resp.setResidueNums(tCoursePackagePayment.getLaveClassHours());
                resp.setDeductionNums(tCoursePackagePayment.getTotalClassHours()-tCoursePackagePayment.getLaveClassHours());
                String afterDayDate = DateUtil.getAfterDayDate2(tCoursePackage.getInsertTime(),tCoursePackage.getValidDays() + "");
                resp.setPeriodOfValidity(afterDayDate);
                resps.add(resp);
            }
        }
@@ -131,20 +147,24 @@
            if (list.size() >  0){
                for (TCoursePackagePayment tCoursePackagePayment : list) {
                    TCoursePackage tCoursePackage = tcpService.getById(tCoursePackagePayment.getCoursePackageId());
                    CoursePackagePaymentConfig paymentConfig = icppcService.getOne(new QueryWrapper<CoursePackagePaymentConfig>()
                            .eq("coursePackageId",tCoursePackage.getId() )
                            .eq("classHours",tCoursePackagePayment.getClassHours()));
//                    获取课程有效结束时间,判断 查询的日期parse 是否在有效期范围内
                    Date expirationDate = DateTimeHelper.getExpirationDate(tCoursePackagePayment.getInsertTime(),tCoursePackage.getValidDays());
                    String classWeeks = tCoursePackage.getClassWeeks();
                    if (expirationDate.after(parse) && StrUtils.dealStrToList(classWeeks).contains(DateTimeHelper.getDayOfWeek(parse))){
                        CourseOfStoreVo storeVo = new CourseOfStoreVo();
                        storeVo.setCourseId(tCoursePackage.getId());
                        // TODO: 2023/7/20 查询课包对应门店信息
//                        storeVo.setCourseName();
//                        storeVo.setClassStartTime();
//                        storeVo.setClassEndTime();
//                        storeVo.setStoreId();
//                        storeVo.setStoreName();
//                        storeVo.setLat();
//                        storeVo.setLon();
                        storeVo.setCourseName(tCoursePackage.getName());
                        storeVo.setClassStartTime(tCoursePackage.getClassStartTime());
                        storeVo.setClassEndTime(tCoursePackage.getClassEndTime());
                        storeVo.setStoreId(tCoursePackage.getStoreId());
                        Store store = sreClient.queryStoreById(tCoursePackage.getStoreId());
                        storeVo.setStoreAddress(store.getAddress());
                        storeVo.setLat(store.getLat());
                        storeVo.setLon(store.getLon());
                        storeVo.setCoursePrice(ToolUtil.isEmpty(paymentConfig.getCashPayment()) ? (double) paymentConfig.getPlayPaiCoin():paymentConfig.getCashPayment());
                        course.add(storeVo);
                    }
                }