cloud-server-account/src/main/java/com/dsh/account/controller/ClassDetailsController.java
@@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.dsh.account.entity.TStudent; import com.dsh.account.feignclient.competition.model.PurchaseRecordVo; import com.dsh.account.model.vo.classDetails.AppointmentRecordVo; import com.dsh.account.model.vo.classDetails.ClasspaymentRequest; import com.dsh.account.model.vo.classDetails.classInsVo.*; import com.dsh.account.model.vo.commentDetail.StuCommentsVo; import com.dsh.account.model.vo.exploreDetail.LonLatRequest; import com.dsh.account.model.vo.medalDetail.GongVo; import com.dsh.account.model.vo.medalDetail.StuMedalVo; import com.dsh.account.model.vo.sourceDetail.CouponStuAvailableVo; @@ -64,17 +66,15 @@ @PostMapping("/api/startCource/queryStudentData") @ApiOperation(value = "上课首页", tags = {"APP-开始上课"}) @ApiImplicitParams({ @ApiImplicitParam(value = "经度值", name = "longitude", required = true, dataType = "String"), @ApiImplicitParam(value = "纬度值", name = "latitude", required = true, dataType = "String"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil<ClassInfoVo> queryCouponRecord(String longitude, String latitude){ public ResultUtil<ClassInfoVo> queryCouponRecord(LonLatRequest lonLatRequest){ try { Integer userIdFormRedis = tokenUtil.getUserIdFormRedis(); if(null == userIdFormRedis){ return ResultUtil.tokenErr(); } return ResultUtil.success(tappuService.queryUserOfStus(userIdFormRedis,longitude,latitude)); return ResultUtil.success(tappuService.queryUserOfStus(userIdFormRedis,lonLatRequest.getLongitude(),lonLatRequest.getLatitude())); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); @@ -86,7 +86,7 @@ @PostMapping("/api/startCource/queryPhysical") @ApiOperation(value = "获取学员测试报告", tags = {"APP-开始上课"}) @ApiImplicitParams({ @ApiImplicitParam(value = "学员id", name = "id", required = true, dataType = "int"), @ApiImplicitParam(value = "学员id", name = "stuID", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil<StuPhysicalVo> getStuPhysicalInfo(Integer stuID){ @@ -117,8 +117,7 @@ if(null == userIdFormRedis){ return ResultUtil.tokenErr(); } istuService.addStuOfAppUser(stu,userIdFormRedis); return ResultUtil.success(); return istuService.addStuOfAppUser(stu,userIdFormRedis); }catch (Exception e){ return ResultUtil.runErr(ResultUtil.ERROR); } @@ -244,7 +243,9 @@ @PostMapping("/api/startCource/renewal") @ApiOperation(value = "课时详情-续课课包详情", tags = {"APP-开始上课"}) @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(value = "课包id", name = "lessonId", required = true, dataType = "int"), @ApiImplicitParam(value = "学员id", name = "stuId", required = true, dataType = "int"), }) public ResultUtil<CourseDetailsOfContinuationResp> renewalOfCourses(Integer lessonId, Integer stuId){ try { @@ -317,7 +318,7 @@ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(value = "学员id", name = "stuId", required = true, dataType = "int"), }) public ResultUtil<List<StuCommentsVo>> queryStuComment(@RequestParam("stuId") Integer stuId){ public ResultUtil<List<StuCommentsVo>> queryStuComment( Integer stuId){ try { return ResultUtil.success(evalstuService.queryStuCommentsList(stuId)); }catch (Exception e){ @@ -336,7 +337,7 @@ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(value = "学员id", name = "stuId", required = true, dataType = "int"), }) public ResultUtil<List<StuMedalVo>> queryStuMedal(@RequestParam("stuId") Integer stuId){ public ResultUtil<List<StuMedalVo>> queryStuMedal( Integer stuId){ try { Integer appUserId = tokenUtil.getUserIdFormRedis(); if(null == appUserId){ @@ -359,7 +360,7 @@ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(value = "学员id", name = "stuId", required = true, dataType = "int"), }) public ResultUtil<List<GongVo>> queryStuGoog(@RequestParam("stuId") Integer stuId){ public ResultUtil<List<GongVo>> queryStuGoog(Integer stuId){ try { Integer appUserId = tokenUtil.getUserIdFormRedis(); if(null == appUserId){ @@ -371,6 +372,50 @@ } } /** * 上课预约记录 */ @ResponseBody @PostMapping("/api/startCource/stuAppointList") @ApiOperation(value = "上课预约记录", tags = {"APP-开始上课"}) @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(value = "学员id", name = "stuId", required = true, dataType = "int"), }) public ResultUtil<AppointmentRecordVo> cgeClassAppointmentRecordList(Integer stuId){ try { Integer appUserId = tokenUtil.getUserIdFormRedis(); if(null == appUserId){ return ResultUtil.tokenErr(); } return ResultUtil.success(istuService.getAppointmentRecords(stuId,appUserId)); }catch (Exception e){ return ResultUtil.runErr(); } } /** * 取消预约 */ @ResponseBody @PostMapping("/api/startCource/cancelCourse") @ApiOperation(value = "上课预约-取消预约", tags = {"APP-开始上课"}) @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(value = "上课记录id", name = "courseStuRecordId", required = true, dataType = "int"), }) public ResultUtil cancelReservation(Integer courseStuRecordId){ try { Integer appUserId = tokenUtil.getUserIdFormRedis(); if(null == appUserId){ return ResultUtil.tokenErr(); } return istuService.cancelReservationOfCourse(courseStuRecordId); }catch (Exception e){ return ResultUtil.runErr(); } } } cloud-server-account/src/main/java/com/dsh/account/controller/ExploreWPController.java
@@ -82,6 +82,9 @@ @ResponseBody @PostMapping("/base/exploreWP/exceptionDetail") @ApiOperation(value = "联系客服-常见问题详情", tags = {"APP-探索玩湃"}) @ApiImplicitParams({ @ApiImplicitParam(value = "问题记录id", name = "quesId", required = true, dataType = "int"), }) public ResultUtil<QuestionIns> queryQuestionData(Integer quesId){ try { return ResultUtil.success(tsService.queryQuestionDataInfo(quesId)); cloud-server-account/src/main/java/com/dsh/account/controller/UseBenefitsController.java
@@ -277,11 +277,31 @@ /** * 商品详情 */ @ResponseBody @PostMapping("/api/useBenefit/goodsDetails") @ApiOperation(value = "积分商城-商品详情", tags = {"APP-使用福利"}) @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(value = "商品id", name = "goodId", required = true, dataType = "int"), @ApiImplicitParam(value = "商品类型 1实物 2课包 3门票 4优惠券", name = "goodsType", required = true, dataType = "int"), }) public ResultUtil<ProductDetailsVo> productDetails(Integer goodId, Integer goodsType){ try { return ResultUtil.success(tauService.productDetails(goodId,goodsType)); }catch (Exception e){ return ResultUtil.runErr(); } } /** * 积分明细 */ @ResponseBody @PostMapping("/api/useBenefit/integralDetails") @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(value = "年月", name = "yearMonth", required = true, dataType = "string"), @@ -300,6 +320,48 @@ } /** * 兑换记录 */ @ResponseBody @PostMapping("/api/useBenefit/exchangeRecords") @ApiOperation(value = "积分商城-兑换记录", tags = {"APP-使用福利"}) @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(value = "使用状态 (1已使用 2未使用)", name = "useType", required = true, dataType = "string"), @ApiImplicitParam(value = "商品类型 1实物 2课包 3门票 4优惠券", name = "goodType", required = true, dataType = "int"), }) public ResultUtil<List<ExchangeDetailsResponse>> exchangeRecordsDetails(Integer useType, Integer goodType){ try { Integer userIdFormRedis = tokenUtil.getUserIdFormRedis(); if(null == userIdFormRedis){ return ResultUtil.tokenErr(); } return ResultUtil.success(uicService.queryExchangeGoodsdetails(userIdFormRedis,useType,goodType)); }catch (Exception e){ return ResultUtil.runErr(); } } /** * 兑换记录详情 */ @ResponseBody @PostMapping("/api/useBenefit/redemptionDetails") @ApiOperation(value = "积分商城-兑换记录详情", tags = {"APP-使用福利"}) @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(value = "记录id", name = "detailsId", required = true, dataType = "string"), }) public ResultUtil<PointDetailsVo> redemptionDetails(Integer detailsId){ try { return ResultUtil.success(uicService.queryRedemptionDetails(detailsId)); }catch (Exception e){ return ResultUtil.runErr(); } } } cloud-server-account/src/main/java/com/dsh/account/feignclient/activity/MerChandiseClient.java
@@ -4,6 +4,10 @@ import com.dsh.account.feignclient.activity.model.CommodityRequest; import com.dsh.account.feignclient.activity.model.IntegralCommodity; import com.dsh.account.feignclient.activity.model.PointsMerchandise; import com.dsh.account.feignclient.activity.model.ProductDetailRequest; import com.dsh.account.model.vo.userBenefitDetail.ExchangeDetailsResponse; import com.dsh.account.model.vo.userBenefitDetail.PointDetailsVo; import com.dsh.account.model.vo.userBenefitDetail.ProductDetailsVo; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -23,4 +27,13 @@ @PostMapping("/base/pointMerchars/getRedeemedNums") public int getRedeemedQuantity(@RequestBody Integer goodId); @PostMapping("/base/pointMerchars/getGoodDetails") ProductDetailsVo getGoodDetailsWithId(@RequestBody ProductDetailRequest detailRequest); @PostMapping("/base/pointMerchars/getDetailsOfExchange") List<ExchangeDetailsResponse> getIntegralExchangeDetails(@RequestBody Integer appUserId); @PostMapping("/base/pointMerchars/getSpecificsOfGoods") public PointDetailsVo getSpecificsOfGoods(@RequestBody Integer speMercharsId); } cloud-server-account/src/main/java/com/dsh/account/feignclient/activity/model/PointsMerchandise.java
@@ -39,7 +39,7 @@ /** * 所属积分 */ private BigDecimal integral; private Integer integral; /** * 商品封面 */ cloud-server-account/src/main/java/com/dsh/account/feignclient/activity/model/ProductDetailRequest.java
New file @@ -0,0 +1,13 @@ package com.dsh.account.feignclient.activity.model; import lombok.Data; @Data public class ProductDetailRequest { Integer goodId; Integer goodsType; } cloud-server-account/src/main/java/com/dsh/account/feignclient/course/CoursePaymentClient.java
@@ -44,7 +44,7 @@ public boolean delPaymentCoursePackage(@RequestBody Integer payId); @PostMapping("/base/coursePack/updatePaymentCoursePackage") void updatePaymentCoursePackage(TCoursePackagePayment coursePackagePayment); void updatePaymentCoursePackage(@RequestBody TCoursePackagePayment coursePackagePayment); @PostMapping("/base/coursePack/savePaymentCoursePackage") public boolean savePaymentCoursePackage(@RequestBody TCoursePackagePayment packagePayment); @@ -52,4 +52,7 @@ @PostMapping("/base/coursePack/allAmountPayRecordOfUser") public List<TCoursePackagePayment> getAmountPayRecord(@RequestBody Integer appUserId); @PostMapping("/base/coursePack/obtainStudentClassDetails") List<RecordAppoint> obtainStudentClassDetailsData(@RequestBody Integer stuId); } cloud-server-account/src/main/java/com/dsh/account/feignclient/course/CourseRecordClient.java
@@ -11,4 +11,8 @@ @PostMapping("/base/courseRecord/queryDeduClassHours") public Integer getDeductionClassHour(@RequestBody GetStudentCourse course); @PostMapping("/base/courseRecord/cancelCourseData") Integer cancelCourseRecordClass(@RequestBody Integer courseRecordId); } cloud-server-account/src/main/java/com/dsh/account/feignclient/course/model/RecordAppoint.java
New file @@ -0,0 +1,30 @@ package com.dsh.account.feignclient.course.model; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data public class RecordAppoint { @ApiModelProperty(value = "课包id") private Integer coursePackageId; @ApiModelProperty(value = "上课记录id") private Long courseStuRecordId; @ApiModelProperty(value = "课包名称") private String coursePackageName; @ApiModelProperty(value = "课时数") private Integer courseHours; @ApiModelProperty(value = "上课时间范围(例如:2021.03.01 8:00-11:00)") private String timeFrame; @ApiModelProperty(value = "门店名称+地址") private String storeNameAddr; @ApiModelProperty(value = "课状态(1待上课 2已开始 3已完成 4已取消)") private Integer status; } cloud-server-account/src/main/java/com/dsh/account/model/vo/classDetails/AppointmentRecordVo.java
New file @@ -0,0 +1,22 @@ package com.dsh.account.model.vo.classDetails; import com.dsh.account.feignclient.course.model.RecordAppoint; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.List; @Data public class AppointmentRecordVo { @ApiModelProperty(value = "学员id") private Integer stuId; @ApiModelProperty(value = "当前学员姓名") private String stuName; @ApiModelProperty(value = "记录列表") private List<RecordAppoint> appointList; } cloud-server-account/src/main/java/com/dsh/account/model/vo/userBenefitDetail/ExchangeDetailsResponse.java
New file @@ -0,0 +1,31 @@ package com.dsh.account.model.vo.userBenefitDetail; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data public class ExchangeDetailsResponse { @ApiModelProperty(value = "记录id") private Long detailsId; @ApiModelProperty(value = "商品名称") private String goodName; @ApiModelProperty(value = "支付类型(积分 / 积分+现金)") private String requiredType; @ApiModelProperty(value = "有效期开始时间") private String startTime; @ApiModelProperty(value = "有效期结束时间") private String endTime; @ApiModelProperty(value = "使用状态 (1已使用 2未使用)") private Integer useStatus; @ApiModelProperty(value = "商品类型 1实物 2课包 3门票 4优惠券") private Integer goodType; } cloud-server-account/src/main/java/com/dsh/account/model/vo/userBenefitDetail/PointDetailsVo.java
New file @@ -0,0 +1,45 @@ package com.dsh.account.model.vo.userBenefitDetail; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.List; @Data public class PointDetailsVo { @ApiModelProperty(value = "记录id") private Integer detailsId; @ApiModelProperty(value = "图片集") private List<String> pics; @ApiModelProperty(value = "商品名称") private String goodName; @ApiModelProperty(value = "适用状态(1已使用 2未使用)") private Integer useType; @ApiModelProperty(value = "有效期开始时间") private String startTime; @ApiModelProperty(value = "有效期结束时间") private String endTime; @ApiModelProperty(value = "下单时间") private String orderTime; @ApiModelProperty(value = "核销时间") private String writeOffTime; @ApiModelProperty(value = "核销门店") private String writeOffName; @ApiModelProperty(value = "适用范围(指定门店可用)") private String belongs; @ApiModelProperty(value = "兑换说明") private String contents; } cloud-server-account/src/main/java/com/dsh/account/model/vo/userBenefitDetail/ProductDetailsVo.java
New file @@ -0,0 +1,58 @@ package com.dsh.account.model.vo.userBenefitDetail; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; import java.util.List; @Data public class ProductDetailsVo { @ApiModelProperty(value = "商品id") private Integer goodId; @ApiModelProperty(value = "图片列表") private List<String> pics; @ApiModelProperty(value = "商品名称") private String goodName; @ApiModelProperty(value = "适用人群") private Integer belongsScope; @ApiModelProperty(value = "已兑换数量") private Integer redeemedNum; @ApiModelProperty(value = "剩余数量") private Integer residueNum; @ApiModelProperty(value = "每人限额") private Integer perLimit; @ApiModelProperty(value = "所需类型(积分/积分+现金)") private String requiredType; @ApiModelProperty(value = "价值") private BigDecimal cost; @ApiModelProperty(value = "课时数") private Integer courseHours; @ApiModelProperty(value = "适用范围") private String belongs; @ApiModelProperty(value = "有效期开始时间") private String startTime; @ApiModelProperty(value = "有效期结束时间") private String endTime; @ApiModelProperty(value = "兑换说明") private String contents; @ApiModelProperty(value = "商品类型 1实物 2课包 3门票 4优惠券") private Integer goodType; } cloud-server-account/src/main/java/com/dsh/account/service/TAppUserService.java
@@ -124,4 +124,6 @@ ResultUtil uploadAppUserHeadImg(Integer appUserId, MultipartFile file, HttpServletRequest request); ProductDetailsVo productDetails(Integer goodId, Integer goodsType ); } cloud-server-account/src/main/java/com/dsh/account/service/TStudentService.java
@@ -4,6 +4,7 @@ import com.dsh.account.entity.TStudent; import com.dsh.account.feignclient.competition.model.PurchaseRecordVo; import com.dsh.account.feignclient.other.model.SysNotice; import com.dsh.account.model.vo.classDetails.AppointmentRecordVo; import com.dsh.account.model.vo.classDetails.ClasspaymentRequest; import com.dsh.account.model.vo.classDetails.classInsVo.ClassDetailsInsVo; import com.dsh.account.model.vo.classDetails.classInsVo.StuDetailsReq; @@ -29,7 +30,7 @@ */ public interface TStudentService extends IService<TStudent> { void addStuOfAppUser(StuDetailsReq stu,Integer appUserId); ResultUtil addStuOfAppUser(StuDetailsReq stu,Integer appUserId) throws Exception; ClassDetailsInsVo querySessionDetailsDt(Integer userIdFormRedis, Integer lessonId, Integer stuId); @@ -75,4 +76,14 @@ ResultUtil insertVipPaymentCallback(String outTradeNo, String transactionId); /** * 查询学院的上课记录 * @param stuId * @param appUserId * @return */ AppointmentRecordVo getAppointmentRecords(Integer stuId, Integer appUserId); ResultUtil cancelReservationOfCourse( Integer courseStuRecordId); } cloud-server-account/src/main/java/com/dsh/account/service/UserIntegralChangesService.java
@@ -3,7 +3,11 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.dsh.account.entity.UserIntegralChanges; import com.dsh.account.model.SaveUserIntegralChangesVo; import com.dsh.account.model.vo.userBenefitDetail.ExchangeDetailsResponse; import com.dsh.account.model.vo.userBenefitDetail.IntegralDetailsResponse; import com.dsh.account.model.vo.userBenefitDetail.PointDetailsVo; import java.util.List; /** * <p> @@ -24,4 +28,10 @@ * @throws Exception */ void saveUserIntegralChanges(SaveUserIntegralChangesVo vo) throws Exception; List<ExchangeDetailsResponse> queryExchangeGoodsdetails(Integer userIdFormRedis, Integer useType, Integer goodType); PointDetailsVo queryRedemptionDetails(Integer detailsId); } cloud-server-account/src/main/java/com/dsh/account/service/impl/TAppUserServiceImpl.java
@@ -12,6 +12,7 @@ import com.dsh.account.feignclient.activity.UserConponClient; import com.dsh.account.feignclient.activity.model.CommodityRequest; import com.dsh.account.feignclient.activity.model.PointsMerchandise; import com.dsh.account.feignclient.activity.model.ProductDetailRequest; import com.dsh.account.feignclient.competition.DeductionCompetitionsClient; import com.dsh.account.feignclient.competition.model.PaymentCompetition; import com.dsh.account.feignclient.course.CoursePackageClient; @@ -739,4 +740,12 @@ return ResultUtil.success(); } @Override public ProductDetailsVo productDetails(Integer goodId, Integer goodsType ) { ProductDetailRequest detailsVo = new ProductDetailRequest(); detailsVo.setGoodsType(goodsType); detailsVo.setGoodId(goodId); return mcClient.getGoodDetailsWithId(detailsVo); } } cloud-server-account/src/main/java/com/dsh/account/service/impl/TStudentServiceImpl.java
@@ -25,6 +25,7 @@ import com.dsh.account.mapper.CoachMapper; import com.dsh.account.mapper.TAppUserMapper; import com.dsh.account.mapper.TStudentMapper; import com.dsh.account.model.vo.classDetails.AppointmentRecordVo; import com.dsh.account.model.vo.classDetails.ClasspaymentRequest; import com.dsh.account.model.vo.classDetails.classInsVo.ClassDetailsInsVo; import com.dsh.account.model.vo.classDetails.classInsVo.StuDetailsReq; @@ -106,8 +107,14 @@ @Override public void addStuOfAppUser(StuDetailsReq stu,Integer appUserId) { public ResultUtil addStuOfAppUser(StuDetailsReq stu,Integer appUserId) throws Exception { TStudent student = new TStudent(); if(ToolUtil.isNotEmpty(stu.getName()) && ToolUtil.isNotEmpty(stu.getIdCard())){ Boolean aBoolean = JuHeUtil.idcardAuthentication(stu.getIdCard(), stu.getName()); if(!aBoolean){ return ResultUtil.error("身份证和姓名不匹配"); } } student.setAppUserId(appUserId); student.setName(stu.getName()); student.setHeadImg(stu.getHeadImg()); @@ -136,6 +143,7 @@ saveParticipant.setPhone(student.getPhone()); saveParticipant.setIdcard(student.getIdCard()); participantClient.saveParticipant(saveParticipant); return ResultUtil.success(); } @Override @@ -555,4 +563,36 @@ return ResultUtil.success(); } @Override public AppointmentRecordVo getAppointmentRecords(Integer stuId, Integer appUserId) { AppointmentRecordVo recordVo = new AppointmentRecordVo(); TStudent tStudent = this.baseMapper.selectOne(new QueryWrapper<TStudent>() .eq("id",stuId ) .eq("appUserId",appUserId)); if (ToolUtil.isNotEmpty(tStudent)){ recordVo.setStuId(tStudent.getId()); recordVo.setStuName(tStudent.getName()); recordVo.setAppointList(couPayClient.obtainStudentClassDetailsData(stuId)); } return recordVo; } @Override public ResultUtil cancelReservationOfCourse(Integer courseStuRecordId) { Integer integer = crClient.cancelCourseRecordClass(courseStuRecordId); switch (integer){ case 1: ResultUtil.success(); break; case 2: ResultUtil.error("开课前三小时不能取消!"); break; default: ResultUtil.runErr(); break; } return null; } } cloud-server-account/src/main/java/com/dsh/account/service/impl/UserIntegralChangesServiceImpl.java
@@ -4,12 +4,16 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.dsh.account.entity.TAppUser; import com.dsh.account.entity.UserIntegralChanges; import com.dsh.account.feignclient.activity.MerChandiseClient; import com.dsh.account.mapper.TAppUserMapper; import com.dsh.account.mapper.UserIntegralChangesMapper; import com.dsh.account.model.SaveUserIntegralChangesVo; import com.dsh.account.model.vo.userBenefitDetail.ExchangeDetailsResponse; import com.dsh.account.model.vo.userBenefitDetail.IntegralDetailsResponse; import com.dsh.account.model.vo.userBenefitDetail.PointDetailsVo; import com.dsh.account.service.UserIntegralChangesService; import com.dsh.account.util.DateTimeHelper; import com.dsh.account.util.ToolUtil; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -34,7 +38,10 @@ @Resource private TAppUserMapper tauMapper; @Resource private MerChandiseClient mcClient; @Override public IntegralDetailsResponse queryUserPointsDetails(String yearMonth, Integer recordId, Integer userIdFormRedis) { IntegralDetailsResponse vo = new IntegralDetailsResponse(); @@ -116,4 +123,25 @@ userIntegralChanges.setInsertTime(new Date()); this.save(userIntegralChanges); } @Override public List<ExchangeDetailsResponse> queryExchangeGoodsdetails(Integer userIdFormRedis, Integer useType, Integer goodType) { List<ExchangeDetailsResponse> integralExchangeDetails = mcClient.getIntegralExchangeDetails(userIdFormRedis); if (ToolUtil.isNotEmpty(useType)){ integralExchangeDetails = integralExchangeDetails.stream() .filter(response -> Objects.equals(response.getUseStatus(), useType)) .collect(Collectors.toList()); } if (ToolUtil.isNotEmpty(goodType)){ integralExchangeDetails = integralExchangeDetails.stream() .filter(response -> Objects.equals(response.getGoodType(), goodType)) .collect(Collectors.toList()); } return integralExchangeDetails; } @Override public PointDetailsVo queryRedemptionDetails(Integer detailsId) { return mcClient.getSpecificsOfGoods(detailsId); } } cloud-server-account/src/main/java/com/dsh/account/util/DateTimeHelper.java
@@ -1484,6 +1484,23 @@ } /** * 获取当前日期是星期几<br> * Obtain the day of the week for the current date. * @param dt * @return 当前日期是星期几 */ public static int getWeekNumOfDate(Date dt) { Integer[] weekDays = {7, 1, 2, 3, 4, 5, 6}; // 将周一的数值设为2,依次递增表示周二到周日 Calendar cal = Calendar.getInstance(); cal.setTime(dt); int w = cal.get(Calendar.DAY_OF_WEEK) - 1; if (w < 0) { w = 6; // 如果为负数,将其设为6,表示周日 } return weekDays[w]; } /** * 获取今天时间 2017-11-20 00:00:00 */ public static Date todayDate() { cloud-server-account/src/main/java/com/dsh/account/util/JuHeUtil.java
New file @@ -0,0 +1,44 @@ package com.dsh.account.util; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.dsh.account.util.httpClinet.HttpClientUtil; import com.dsh.account.util.httpClinet.HttpResult; import java.util.HashMap; import java.util.Map; /** * @author zhibing.pu * @date 2023/7/11 12:05 */ public class JuHeUtil { /** * 校验实名认证 * @param idcard * @param name * @return * @throws Exception */ public static Boolean idcardAuthentication(String idcard, String name) throws Exception{ Map<String, Object> params = new HashMap<>(); params.put("idcard", idcard); params.put("realname", name); params.put("key", "29fec4bbe3108e4fbf52704e5a906fe0"); HttpResult httpResult = HttpClientUtil.pushHttpRequset("POST", "http://op.juhe.cn/idcard/query", params, null, "form"); if(httpResult.getCode() != 200){ return false; } JSONObject jsonObject = JSON.parseObject(httpResult.getData()); Integer error_code = jsonObject.getInteger("error_code"); if(0 == error_code){ JSONObject result = jsonObject.getJSONObject("result"); Integer res = result.getInteger("res"); return res == 1 ? true : false; } return false; } } cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java
@@ -2,19 +2,26 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.dsh.activity.entity.PointsMerchandise; import com.dsh.activity.entity.UserPointsMerchandise; import com.dsh.activity.feignclient.model.IntegralCommodity; import com.dsh.activity.entity.*; import com.dsh.activity.feignclient.course.CoursePackageClient; import com.dsh.activity.feignclient.course.CoursePackageConfigClient; import com.dsh.activity.feignclient.course.model.CoursePackage; import com.dsh.activity.feignclient.course.model.CoursePackagePaymentConfig; import com.dsh.activity.feignclient.model.*; import com.dsh.activity.feignclient.other.StoreClient; import com.dsh.activity.feignclient.other.model.StoreDetailOfCourse; import com.dsh.activity.model.request.CommodityRequest; import com.dsh.activity.service.PointsMerchandiseService; import com.dsh.activity.service.UserPointsMerchandiseService; import com.dsh.activity.service.*; import com.dsh.activity.util.GDMapGeocodingUtil; import com.dsh.activity.util.StrUtils; import com.dsh.activity.util.ToolUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.text.SimpleDateFormat; import java.util.*; @RestController @@ -31,6 +38,26 @@ @Autowired private UserPointsMerchandiseService upmseService; @Autowired private ICouponService iCouponService; @Autowired private CoursePackageClient cpClient; @Autowired private StoreClient stoClient; @Autowired private CoursePackageConfigClient cpcfigClient; @Autowired private PointsMerchandiseStoreService pmdstoService; @Autowired private UserCouponService uconService; @Autowired private CouponStoreService cstoreService; @PostMapping("/base/pointMerchars/convertGoods") @@ -85,4 +112,286 @@ .eq("pointsMerchandiseId",goodId)); } @PostMapping("/base/pointMerchars/getGoodDetails") public ProductDetailsVo getGoodDetailsWithId(@RequestBody ProductDetailRequest detailRequest){ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); ProductDetailsVo detailsVo = new ProductDetailsVo(); PointsMerchandise merchandise = pmdsService.getById(detailRequest.getGoodId()); switch (detailRequest.getGoodsType()){ case 2: // 课包 CoursePackage coursePackage = cpClient.queryCoursePackageById(detailRequest.getGoodId()); detailsVo.setGoodId(coursePackage.getId()); List<String> list1 = Arrays.asList(StrUtils.splitStr2StrArr(coursePackage.getDetailDrawing(), ",")); list1.add(coursePackage.getCoverDrawing()); detailsVo.setPics(list1); Collections.sort(detailsVo.getPics(), (s1, s2) -> { if (s1.equals(coursePackage.getCoverDrawing())) { return -1; // s1排在前面 } else if (s2.equals(coursePackage.getCoverDrawing())) { return 1; // s2排在前面 } else { return 0; // 保持原顺序 } }); detailsVo.setGoodName(coursePackage.getName()); detailsVo.setBelongsScope(merchandise.getUserPopulation()); int coursePackageNums = upmseService.count(new QueryWrapper<UserPointsMerchandise>() .eq("pointsMerchandiseId",merchandise.getId() )); detailsVo.setRedeemedNum(coursePackageNums); detailsVo.setResidueNum(merchandise.getQuantityIssued() - coursePackageNums); detailsVo.setPerLimit(merchandise.getPickUpQuantity()); if (merchandise.getRedemptionMethod() == 1){ detailsVo.setRequiredType(merchandise.getIntegral() + "积分"); }else { detailsVo.setRequiredType(merchandise.getIntegral() + "积分+¥"+merchandise.getCash()); } detailsVo.setCost(merchandise.getPrice()); if (merchandise.getUseScope() == 1){ detailsVo.setBelongs("全国通用"); }else if (merchandise.getUseScope() == 2){ detailsVo.setBelongs(merchandise.getProvince()+"|"+merchandise.getCity() + "用户可用"); }else { List<PointsMerchandiseStore> list = pmdstoService.list(new QueryWrapper<PointsMerchandiseStore>() .eq("pointsMerchandiseId",merchandise.getId() )); PointsMerchandiseStore pointsMerchandiseStore = list.get(0); StoreDetailOfCourse courseOfStore = stoClient.getCourseOfStore(pointsMerchandiseStore.getStoreId()); detailsVo.setBelongs(courseOfStore.getStoreName()+"可用"); } List<CoursePackagePaymentConfig> courseConfigList = cpcfigClient.getCourseConfigList(coursePackage.getId()); int redul = 0; for (CoursePackagePaymentConfig coursePackagePaymentConfig : courseConfigList) { redul = redul + coursePackagePaymentConfig.getClassHours(); } detailsVo.setCourseHours(redul); detailsVo.setStartTime(format.format(merchandise.getStartTime())); detailsVo.setEndTime(format.format(merchandise.getEndTime())); detailsVo.setContents(merchandise.getRedemptionInstructions()); detailsVo.setGoodType(merchandise.getType()); break; case 1: case 3: detailsVo.setGoodId(merchandise.getId()); List<String> list2 = Arrays.asList(StrUtils.splitStr2StrArr(merchandise.getProductImages(), ",")); list2.add(merchandise.getCover()); detailsVo.setPics(list2); Collections.sort(detailsVo.getPics(), (s1, s2) -> { if (s1.equals(merchandise.getCover())) { return -1; // s1排在前面 } else if (s2.equals(merchandise.getCover())) { return 1; // s2排在前面 } else { return 0; // 保持原顺序 } }); detailsVo.setPics(list2); detailsVo.setGoodName(merchandise.getName()); detailsVo.setBelongsScope(merchandise.getUserPopulation()); int count = upmseService.count(new QueryWrapper<UserPointsMerchandise>() .eq("pointsMerchandiseId",merchandise.getId() )); detailsVo.setRedeemedNum(count); detailsVo.setResidueNum(merchandise.getQuantityIssued()-count); detailsVo.setPerLimit(merchandise.getPickUpQuantity()); if (merchandise.getRedemptionMethod() == 1){ detailsVo.setRequiredType(merchandise.getIntegral() + "积分"); }else { detailsVo.setRequiredType(merchandise.getIntegral() + "积分+¥"+merchandise.getCash()); } detailsVo.setCost(merchandise.getPrice()); if (merchandise.getUseScope() == 1){ detailsVo.setBelongs("全国通用"); }else if (merchandise.getUseScope() == 2){ detailsVo.setBelongs(merchandise.getProvince()+"|"+merchandise.getCity() + "用户可用"); }else { List<PointsMerchandiseStore> list = pmdstoService.list(new QueryWrapper<PointsMerchandiseStore>() .eq("pointsMerchandiseId",merchandise.getId() )); PointsMerchandiseStore pointsMerchandiseStore = list.get(0); StoreDetailOfCourse courseOfStore = stoClient.getCourseOfStore(pointsMerchandiseStore.getStoreId()); detailsVo.setBelongs(courseOfStore.getStoreName()+"可用"); } detailsVo.setStartTime(format.format(merchandise.getStartTime())); detailsVo.setEndTime(format.format(merchandise.getEndTime())); detailsVo.setContents(merchandise.getRedemptionInstructions()); detailsVo.setGoodType(merchandise.getType()); break; case 4: // 优惠券 Coupon coupon = iCouponService.getById(detailRequest.getGoodId()); detailsVo.setGoodId(coupon.getId()); List<String> list3 = Arrays.asList(StrUtils.splitStr2StrArr(coupon.getProductImages(), ",")); list3.add(coupon.getCover()); detailsVo.setPics(list3); Collections.sort(detailsVo.getPics(), (s1, s2) -> { if (s1.equals(coupon.getCover())) { return -1; // s1排在前面 } else if (s2.equals(coupon.getCover())) { return 1; // s2排在前面 } else { return 0; // 保持原顺序 } }); detailsVo.setGoodName(coupon.getName()); detailsVo.setBelongsScope(coupon.getUserPopulation()); int couponNums = uconService.count(new QueryWrapper<UserCoupon>() .eq("couponId",coupon.getId() )); detailsVo.setRedeemedNum(couponNums); detailsVo.setResidueNum(coupon.getQuantityIssued()-couponNums); detailsVo.setPerLimit(coupon.getPickUpQuantity()); if (merchandise.getRedemptionMethod() == 1){ detailsVo.setRequiredType(merchandise.getIntegral() + "积分"); }else { detailsVo.setRequiredType(merchandise.getIntegral() + "积分+¥"+merchandise.getCash()); } if (coupon.getUseScope() == 1){ detailsVo.setBelongs("全国通用"); }else if (coupon.getUseScope() == 2){ detailsVo.setBelongs(coupon.getProvince()+"|"+coupon.getCity() + "用户可用"); }else { List<CouponStore> list = cstoreService.list(new QueryWrapper<CouponStore>() .eq("couponId",coupon.getId() )); StoreDetailOfCourse courseOfStore = stoClient.getCourseOfStore(list.get(0).getStoreId()); detailsVo.setBelongs(courseOfStore.getStoreName()+"可用"); } detailsVo.setStartTime(format.format(merchandise.getStartTime())); detailsVo.setEndTime(format.format(merchandise.getEndTime())); detailsVo.setContents(coupon.getIllustrate()); detailsVo.setGoodType(4); break; default: break; } return detailsVo; } @PostMapping("/base/pointMerchars/getDetailsOfExchange") public List<ExchangeDetailsResponse> getIntegralExchangeDetails(@RequestBody Integer appUserId){ List<ExchangeDetailsResponse> responses = new ArrayList<>(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); List<UserPointsMerchandise> pointsMerchandises = upmseService.list(new QueryWrapper<UserPointsMerchandise>() .eq("userId",appUserId )); if (pointsMerchandises.size() > 0 ){ for (UserPointsMerchandise pointsMerchandise : pointsMerchandises) { PointsMerchandise merchandise = pmdsService.getById(pointsMerchandise.getPointsMerchandiseId()); ExchangeDetailsResponse detailsResponse = new ExchangeDetailsResponse(); detailsResponse.setDetailsId(pointsMerchandise.getId()); detailsResponse.setGoodName(merchandise.getName()); if (merchandise.getRedemptionMethod() == 1){ detailsResponse.setRequiredType(merchandise.getIntegral()+"积分"); }else { detailsResponse.setRequiredType(merchandise.getIntegral()+"积分 ¥"+merchandise.getCash()); } detailsResponse.setStartTime(simpleDateFormat.format(merchandise.getStartTime())); detailsResponse.setEndTime(simpleDateFormat.format(merchandise.getEndTime())); detailsResponse.setUseStatus(pointsMerchandise.getStatus()); detailsResponse.setGoodType(merchandise.getType()); responses.add(detailsResponse); } } return responses; } @PostMapping("/base/pointMerchars/getSpecificsOfGoods") public PointDetailsVo getSpecificsOfGoods(@RequestBody Integer speMercharsId){ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); PointDetailsVo detailsVo = new PointDetailsVo(); UserPointsMerchandise byId = upmseService.getById(speMercharsId); if (ToolUtil.isNotEmpty(byId)){ PointsMerchandise pmdsServiceById = pmdsService.getById(byId.getPointsMerchandiseId()); detailsVo.setDetailsId(byId.getId()); switch (pmdsServiceById.getType()){ case 1: case 3: List<String> list2 = Arrays.asList(StrUtils.splitStr2StrArr(pmdsServiceById.getProductImages(), ",")); list2.add(pmdsServiceById.getCover()); detailsVo.setPics(list2); Collections.sort(detailsVo.getPics(), (s1, s2) -> { if (s1.equals(pmdsServiceById.getCover())) { return -1; // s1排在前面 } else if (s2.equals(pmdsServiceById.getCover())) { return 1; // s2排在前面 } else { return 0; // 保持原顺序 } }); break; case 2: CoursePackage coursePackage = cpClient.queryCoursePackageById(pmdsServiceById.getCoursePackageId()); List<String> list1 = Arrays.asList(StrUtils.splitStr2StrArr(coursePackage.getDetailDrawing(), ",")); list1.add(coursePackage.getCoverDrawing()); detailsVo.setPics(list1); Collections.sort(detailsVo.getPics(), (s1, s2) -> { if (s1.equals(coursePackage.getCoverDrawing())) { return -1; // s1排在前面 } else if (s2.equals(coursePackage.getCoverDrawing())) { return 1; // s2排在前面 } else { return 0; // 保持原顺序 } }); break; case 4: Coupon coupon = iCouponService.getById(pmdsServiceById.getId()); List<String> list3 = Arrays.asList(StrUtils.splitStr2StrArr(coupon.getProductImages(), ",")); list3.add(coupon.getCover()); detailsVo.setPics(list3); Collections.sort(detailsVo.getPics(), (s1, s2) -> { if (s1.equals(coupon.getCover())) { return -1; // s1排在前面 } else if (s2.equals(coupon.getCover())) { return 1; // s2排在前面 } else { return 0; // 保持原顺序 } }); break; default: break; } detailsVo.setGoodName(pmdsServiceById.getName()); detailsVo.setStartTime(simpleDateFormat.format(pmdsServiceById.getStartTime())); detailsVo.setEndTime(simpleDateFormat.format(pmdsServiceById.getEndTime())); detailsVo.setOrderTime(simpleDateFormat.format(byId.getInsertTime())); if (byId.getStatus() == 1){ detailsVo.setUseType(2); }else { detailsVo.setUseType(1); detailsVo.setWriteOffTime(simpleDateFormat.format(byId.getVerificationTime())); StoreDetailOfCourse courseOfStore = stoClient.getCourseOfStore(byId.getVerifiStoreId()); detailsVo.setWriteOffName(courseOfStore.getStoreName()); } switch (pmdsServiceById.getUseScope()){ case 1: detailsVo.setBelongs("全国通用"); break; case 2: detailsVo.setBelongs(pmdsServiceById.getProvince()+pmdsServiceById.getCity()); break; case 3: PointsMerchandiseStore one = pmdstoService.getOne(new QueryWrapper<PointsMerchandiseStore>() .eq("pointsMerchandiseId",pmdsServiceById.getId() )); StoreDetailOfCourse courseOfStore = stoClient.getCourseOfStore(one.getStoreId()); detailsVo.setBelongs(courseOfStore.getStoreName()+" "+courseOfStore.getStoreAddr()); break; default: break; } detailsVo.setContents(pmdsServiceById.getRedemptionInstructions()); } return detailsVo; } } cloud-server-activity/src/main/java/com/dsh/activity/entity/PointsMerchandise.java
@@ -35,7 +35,7 @@ @TableId(value = "id", type = IdType.AUTO) private Integer id; /** * 类型(1=实体商品,2=课包商品,3=门票商品) * 类型(1=实体商品,2=课包商品,3=门票商品 4=优惠券) */ @TableField("type") private Integer type; @@ -68,7 +68,7 @@ * 所属积分 */ @TableField("integral") private BigDecimal integral; private Integer integral; /** * 商品封面 */ cloud-server-activity/src/main/java/com/dsh/activity/entity/PointsMerchandiseStore.java
New file @@ -0,0 +1,49 @@ package com.dsh.activity.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import java.io.Serializable; /** * <p> * 积分商品使用门店关系数据 * </p> * * @author jqs * @since 2023-07-12 */ @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) @TableName("t_points_merchandise_store") public class PointsMerchandiseStore extends Model<PointsMerchandiseStore> { private static final long serialVersionUID = 1L; /** * 主键 */ @TableId(value = "id", type = IdType.AUTO) private Integer id; /** * 积分商品id */ private Integer pointsMerchandiseId; /** * 门店id */ private Integer storeId; @Override protected Serializable pkVal() { return this.id; } } cloud-server-activity/src/main/java/com/dsh/activity/entity/UserPointsMerchandise.java
@@ -44,21 +44,26 @@ @TableField("userId") private Integer userId; /** * 状态(1=待核销,2=已核销) */ @TableField("status") private Integer status; /** * 核销人员id */ @TableField("verificationUserId") private Integer verificationUserId; /** * 核销门店id */ @TableField("verifiStoreId") private Integer verifiStoreId; /** * 核销时间 */ @TableField("verificationTime") private Date verificationTime; /** * 状态(1=待核销,2=已核销) */ @TableField("status") private Integer status; /** * 领取时间 */ @TableField("insertTime") cloud-server-activity/src/main/java/com/dsh/activity/feignclient/MerChandiseClient.java
@@ -2,7 +2,7 @@ import com.dsh.activity.entity.PointsMerchandise; import com.dsh.activity.feignclient.model.IntegralCommodity; import com.dsh.activity.feignclient.model.*; import com.dsh.activity.model.request.CommodityRequest; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; @@ -22,4 +22,16 @@ @PostMapping("/base/pointMerchars/getRedeemedNums") public int getRedeemedQuantity(@RequestBody Integer goodId); @PostMapping("/base/pointMerchars/getGoodDetails") ProductDetailsVo getGoodDetailsWithId(@RequestBody ProductDetailRequest detailRequest); @PostMapping("/base/pointMerchars/getDetailsOfExchange") List<ExchangeDetailsResponse> getIntegralExchangeDetails(@RequestBody Integer appUserId); @PostMapping("/base/pointMerchars/getSpecificsOfGoods") public PointDetailsVo getSpecificsOfGoods(@RequestBody Integer speMercharsId); } cloud-server-activity/src/main/java/com/dsh/activity/feignclient/course/CoursePackageConfigClient.java
New file @@ -0,0 +1,18 @@ package com.dsh.activity.feignclient.course; import com.dsh.activity.feignclient.course.model.CoursePackagePaymentConfig; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import java.util.List; @FeignClient(value = "mb-cloud-course") public interface CoursePackageConfigClient { @PostMapping("/base/coursePack/getCoursePackageConfig") List<CoursePackagePaymentConfig> getCourseConfigList(@RequestBody Integer coursePackageId); } cloud-server-activity/src/main/java/com/dsh/activity/feignclient/course/model/CoursePackagePaymentConfig.java
New file @@ -0,0 +1,31 @@ package com.dsh.activity.feignclient.course.model; import lombok.Data; /** * @author zhibing.pu * @date 2023/6/29 10:42 */ @Data public class CoursePackagePaymentConfig { /** * 主键 */ private Integer id; /** * 课包id */ private Integer coursePackageId; /** * 课时数 */ private Integer classHours; /** * 现金支付价格 */ private Double cashPayment; /** * 玩湃币价格 */ private Integer playPaiCoin; } cloud-server-activity/src/main/java/com/dsh/activity/feignclient/model/ExchangeDetailsResponse.java
New file @@ -0,0 +1,31 @@ package com.dsh.activity.feignclient.model; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data public class ExchangeDetailsResponse { @ApiModelProperty(value = "记录id") private Long detailsId; @ApiModelProperty(value = "商品名称") private String goodName; @ApiModelProperty(value = "支付类型(积分 / 积分+现金)") private String requiredType; @ApiModelProperty(value = "有效期开始时间") private String startTime; @ApiModelProperty(value = "有效期结束时间") private String endTime; @ApiModelProperty(value = "使用状态 (1已使用 2未使用)") private Integer useStatus; @ApiModelProperty(value = "商品类型 1实物 2课包 3门票 4优惠券") private Integer goodType; } cloud-server-activity/src/main/java/com/dsh/activity/feignclient/model/PointDetailsVo.java
New file @@ -0,0 +1,45 @@ package com.dsh.activity.feignclient.model; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.List; @Data public class PointDetailsVo { @ApiModelProperty(value = "记录id") private Long detailsId; @ApiModelProperty(value = "图片集") private List<String> pics; @ApiModelProperty(value = "商品名称") private String goodName; @ApiModelProperty(value = "适用状态(1已使用 2未使用)") private Integer useType; @ApiModelProperty(value = "有效期开始时间") private String startTime; @ApiModelProperty(value = "有效期结束时间") private String endTime; @ApiModelProperty(value = "下单时间") private String orderTime; @ApiModelProperty(value = "核销时间") private String writeOffTime; @ApiModelProperty(value = "核销门店") private String writeOffName; @ApiModelProperty(value = "适用范围(指定门店可用)") private String belongs; @ApiModelProperty(value = "兑换说明") private String contents; } cloud-server-activity/src/main/java/com/dsh/activity/feignclient/model/ProductDetailRequest.java
New file @@ -0,0 +1,13 @@ package com.dsh.activity.feignclient.model; import lombok.Data; @Data public class ProductDetailRequest { Integer goodId; Integer goodsType; } cloud-server-activity/src/main/java/com/dsh/activity/feignclient/model/ProductDetailsVo.java
New file @@ -0,0 +1,58 @@ package com.dsh.activity.feignclient.model; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; import java.util.List; @Data public class ProductDetailsVo { @ApiModelProperty(value = "商品id") private Integer goodId; @ApiModelProperty(value = "图片列表") private List<String> pics; @ApiModelProperty(value = "商品名称") private String goodName; @ApiModelProperty(value = "适用人群") private Integer belongsScope; @ApiModelProperty(value = "已兑换数量") private Integer redeemedNum; @ApiModelProperty(value = "剩余数量") private Integer residueNum; @ApiModelProperty(value = "每人限额") private Integer perLimit; @ApiModelProperty(value = "所需类型(积分/积分+现金)") private String requiredType; @ApiModelProperty(value = "价值") private BigDecimal cost; @ApiModelProperty(value = "课时数") private Integer courseHours; @ApiModelProperty(value = "适用范围") private String belongs; @ApiModelProperty(value = "有效期开始时间") private String startTime; @ApiModelProperty(value = "有效期结束时间") private String endTime; @ApiModelProperty(value = "兑换说明") private String contents; @ApiModelProperty(value = "商品类型 1实物 2课包 3门票 4优惠券") private Integer goodType; } cloud-server-activity/src/main/java/com/dsh/activity/mapper/PointsMerchandiseStoreMapper.java
New file @@ -0,0 +1,16 @@ package com.dsh.activity.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.dsh.activity.entity.PointsMerchandiseStore; /** * <p> * 积分商品使用门店关系数据 Mapper 接口 * </p> * * @author jqs * @since 2023-07-12 */ public interface PointsMerchandiseStoreMapper extends BaseMapper<PointsMerchandiseStore> { } cloud-server-activity/src/main/java/com/dsh/activity/service/PointsMerchandiseStoreService.java
New file @@ -0,0 +1,16 @@ package com.dsh.activity.service; import com.baomidou.mybatisplus.extension.service.IService; import com.dsh.activity.entity.PointsMerchandiseStore; /** * <p> * 积分商品使用门店关系数据 服务类 * </p> * * @author jqs * @since 2023-07-12 */ public interface PointsMerchandiseStoreService extends IService<PointsMerchandiseStore> { } cloud-server-activity/src/main/java/com/dsh/activity/service/impl/PointsMerchandiseStoreServiceImpl.java
New file @@ -0,0 +1,20 @@ package com.dsh.activity.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.dsh.activity.entity.PointsMerchandiseStore; import com.dsh.activity.mapper.PointsMerchandiseStoreMapper; import com.dsh.activity.service.PointsMerchandiseStoreService; import org.springframework.stereotype.Service; /** * <p> * 积分商品使用门店关系数据 服务实现类 * </p> * * @author jqs * @since 2023-07-12 */ @Service public class PointsMerchandiseStoreServiceImpl extends ServiceImpl<PointsMerchandiseStoreMapper, PointsMerchandiseStore> implements PointsMerchandiseStoreService { } cloud-server-activity/src/main/resources/mapper/PointsMerchandiseStoreMapper.xml
New file @@ -0,0 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.dsh.activity.mapper.PointsMerchandiseStoreMapper"> </mapper> cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackageController.java
@@ -1,6 +1,7 @@ package com.dsh.course.controller; import com.dsh.course.entity.TCoursePackage; import com.dsh.course.model.vo.response.ExchangeCoursePackageResponse; import com.dsh.course.model.vo.response.WeekLimitedResponse; import com.dsh.course.service.TCoursePackageDiscountService; import com.dsh.course.service.TCoursePackageService; @@ -72,4 +73,50 @@ } } /** * 折扣课包详情 */ @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("/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(); } } } cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java
@@ -53,14 +53,6 @@ @Autowired private TCoursePackageDiscountService tcpdService; @Autowired private PostCourseVideoService pcvService; @Autowired private CoursePackageStudentService cpsService; @Autowired private CancelledClassesService cacService; @Autowired private ICoursePackagePaymentConfigService icppcService; @@ -689,4 +681,23 @@ return packagePaymentService.save(packagePayment); } @PostMapping("/base/coursePack/obtainStudentClassDetails") public List<RecordAppoint> obtainStudentClassDetailsData(@RequestBody Integer stuId){ try { Integer appUserId = tokenUtil.getUserIdFormRedis(); return packagePaymentService.obtainStuClassDetails(stuId,appUserId); }catch (Exception e){ e.printStackTrace(); throw new RuntimeException(); } } @PostMapping("/base/coursePack/getCoursePackageConfig") public List<CoursePackagePaymentConfig> getCourseConfigList(@RequestBody Integer coursePackageId){ return icppcService.list(new QueryWrapper<CoursePackagePaymentConfig>() .eq("coursePackageId",coursePackageId)); } } cloud-server-course/src/main/java/com/dsh/course/controller/CourseRecordController.java
@@ -9,10 +9,17 @@ import com.dsh.course.service.CancelledClassesService; import com.dsh.course.service.CoursePackageStudentService; import com.dsh.course.service.TCoursePackageService; import com.dsh.course.util.ToolUtil; import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.temporal.ChronoUnit; import java.util.Date; import java.util.List; @Api @@ -57,4 +64,35 @@ return sult; } @PostMapping("/base/courseRecord/cancelCourseData") public Integer cancelCourseRecordClass(@RequestBody Integer courseRecordId){ int sult = 0; CoursePackageStudent packageStudent = cosService.getById(courseRecordId); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd"); SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm"); String tis = simpleDateFormat.format(new Date()); if (ToolUtil.isNotEmpty(packageStudent)){ TCoursePackage coursePackage = tcpService.getById(packageStudent.getCoursePackageId()); String startTime = tis +" " + coursePackage.getClassStartTime(); Date parse = null; try { parse = format.parse(startTime); } catch (ParseException e) { throw new RuntimeException(e); } LocalDateTime localDateTime = parse.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); // 计算时间间隔 long hours = ChronoUnit.HOURS.between(LocalDateTime.now(), localDateTime); // 判断是否在前三小时内 if (hours <= 3 && hours >= 0){ sult = 1; }else { sult = 2; } } return sult; } } cloud-server-course/src/main/java/com/dsh/course/feignclient/CoursePackageConfigClient.java
New file @@ -0,0 +1,18 @@ package com.dsh.course.feignclient; import com.dsh.course.entity.CoursePackagePaymentConfig; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import java.util.List; @FeignClient(value = "mb-cloud-course") public interface CoursePackageConfigClient { @PostMapping("/base/coursePack/getCoursePackageConfig") List<CoursePackagePaymentConfig> getCourseConfigList(@RequestBody Integer coursePackageId); } cloud-server-course/src/main/java/com/dsh/course/feignclient/CoursePaymentClient.java
@@ -58,4 +58,7 @@ @PostMapping("/base/coursePack/allAmountPayRecordOfUser") public List<TCoursePackagePayment> getAmountPayRecord(@RequestBody Integer appUserId); @PostMapping("/base/coursePack/obtainStudentClassDetails") List<RecordAppoint> obtainStudentClassDetailsData(@RequestBody Integer stuId); } cloud-server-course/src/main/java/com/dsh/course/feignclient/CourseRecordClient.java
@@ -11,4 +11,7 @@ @PostMapping("/base/courseRecord/queryDeduClassHours") public Integer getDeductionClassHour(@RequestBody GetStudentCourse course); @PostMapping("/base/courseRecord/cancelCourseData") Integer cancelCourseRecordClass(@RequestBody Integer courseRecordId); } cloud-server-course/src/main/java/com/dsh/course/feignclient/model/RecordAppoint.java
New file @@ -0,0 +1,30 @@ package com.dsh.course.feignclient.model; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data public class RecordAppoint { @ApiModelProperty(value = "课包id") private Integer coursePackageId; @ApiModelProperty(value = "上课记录id") private Long courseStuRecordId; @ApiModelProperty(value = "课包名称") private String coursePackageName; @ApiModelProperty(value = "课时数") private Integer courseHours; @ApiModelProperty(value = "上课时间范围(例如:2021.03.01 8:00-11:00)") private String timeFrame; @ApiModelProperty(value = "门店名称+地址") private String storeNameAddr; @ApiModelProperty(value = "课状态(1待上课 2已开始 3已完成 4已取消)") private Integer status; } cloud-server-course/src/main/java/com/dsh/course/model/vo/response/ExchangeCoursePackageResponse.java
New file @@ -0,0 +1,49 @@ package com.dsh.course.model.vo.response; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data public class ExchangeCoursePackageResponse { @ApiModelProperty(value = "限时折扣配置id/赠送课时配置id") private Integer coursePackageDiscountId; @ApiModelProperty(value = "课包封面图") private String coverDrawing; @ApiModelProperty(value = "课包介绍图") private String introduceDrawing; @ApiModelProperty(value = "课包名称") private String coursePackageName; @ApiModelProperty(value = "门店名称+地址") private String storeNameAddr; @ApiModelProperty(value = "门店距离 单位km") private double distance; @ApiModelProperty(value = "课时数") private Integer classHours; @ApiModelProperty(value = "赠送课时数") private Integer freeClassHours; @ApiModelProperty(value = "上课周数") private String weekTime; @ApiModelProperty(value = "上课时间") private String time; @ApiModelProperty(value = "原价") private Double costPrice; @ApiModelProperty(value = "折扣价/会员价") private Double discountPrice; @ApiModelProperty(value = "玩湃币") private Integer wanpaiGold; } cloud-server-course/src/main/java/com/dsh/course/model/vo/response/WeekLimitedResponse.java
@@ -19,6 +19,9 @@ @Data public static class Details{ @ApiModelProperty(value = "限时折扣配置id/赠送课时配置id") private Integer coursePackageDiscountId; @ApiModelProperty(value = "封面图") private String image; @@ -28,7 +31,7 @@ @ApiModelProperty(value = "课包课时数") private Integer courseHours; @ApiModelProperty(value = "赠送课时数(赠送课时取改字段)") @ApiModelProperty(value = "赠送课时数(赠送课时 取该字段)") private Integer donateHours; @ApiModelProperty(value = "今日/明日/周x") @@ -38,12 +41,12 @@ private Date date; @ApiModelProperty(value = "原价") private Integer originalPrice; private Double originalPrice; @ApiModelProperty(value = "折后价") private Integer discountPrice; private Double discountPrice; @ApiModelProperty(value = "状态") @ApiModelProperty(value = "状态(1=查看详情 2=暂未开始)") private Integer status; @ApiModelProperty(value = "门店距离") cloud-server-course/src/main/java/com/dsh/course/service/TCoursePackageDiscountService.java
@@ -2,7 +2,9 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.dsh.course.entity.TCoursePackageDiscount; import com.dsh.course.model.vo.response.ExchangeCoursePackageResponse; import com.dsh.course.model.vo.response.WeekLimitedResponse; import com.dsh.course.util.ResultUtil; /** @@ -17,4 +19,8 @@ WeekLimitedResponse getWeeksBenefitCourse(Integer appUserId,Integer discountType,String lon,String lat); ExchangeCoursePackageResponse getWeekFreeCourseDetails(Integer coursePackageDiscountId,String lat,String lon); ResultUtil paymentDiscountCoursePack(Integer coursePackageDiscountId, Integer appuserId); } cloud-server-course/src/main/java/com/dsh/course/service/TCoursePackagePaymentService.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.dsh.course.entity.TCoursePackagePayment; import com.dsh.course.feignclient.model.RecordAppoint; import com.dsh.course.model.vo.RegisterCourseVo; import com.dsh.course.model.vo.request.ClasspaymentRequest; import com.dsh.course.model.vo.request.CourseOfAfterRequest; @@ -77,4 +78,12 @@ ResultUtil ContinuationOrpaymentCourse(Integer userIdFormRedis, ClasspaymentRequest request); /** * 查询学员的课包上课记录 * @param stuId * @param appUserId * @return */ List<RecordAppoint> obtainStuClassDetails(Integer stuId, Integer appUserId); } cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackageDiscountServiceImpl.java
@@ -1,23 +1,35 @@ package com.dsh.course.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.dsh.course.entity.CoursePackagePaymentConfig; import com.dsh.course.entity.TCoursePackage; import com.dsh.course.entity.TCoursePackageDiscount; import com.dsh.course.entity.TCoursePackagePayment; import com.dsh.course.feignclient.other.StoreClient; import com.dsh.course.feignclient.other.model.GetDistanceVo; import com.dsh.course.feignclient.other.model.Store; import com.dsh.course.mapper.CoursePackagePaymentConfigMapper; import com.dsh.course.mapper.TCoursePackageDiscountMapper; import com.dsh.course.mapper.TCoursePackageMapper; import com.dsh.course.mapper.TCoursePackagePaymentMapper; import com.dsh.course.model.vo.response.ExchangeCoursePackageResponse; import com.dsh.course.model.vo.response.WeekLimitedResponse; import com.dsh.course.service.TCoursePackageDiscountService; import com.dsh.course.util.DateTimeHelper; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.dsh.course.util.LocalDateTimeUtils; import com.dsh.course.util.ResultUtil; import com.dsh.course.util.StrUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; @@ -36,74 +48,361 @@ @Resource private TCoursePackageMapper tcpMapper; @Resource private TCoursePackagePaymentMapper tcppMapper; @Resource private CoursePackagePaymentConfigMapper cppcMapper; @Resource private StoreClient sreClient; @Override public WeekLimitedResponse getWeeksBenefitCourse(Integer appUserId,Integer discountType,String lon,String lat) { Date start = DateTimeHelper.getTodayTime(); Date lastTime = DateTimeHelper.getWeekOfLastDay(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); WeekLimitedResponse response= new WeekLimitedResponse(); public WeekLimitedResponse getWeeksBenefitCourse(Integer appUserId, Integer discountType, String lon, String lat) { Date localTime = DateTimeHelper.getWXTime(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WeekLimitedResponse response = new WeekLimitedResponse(); List<WeekLimitedResponse.Details> list = new ArrayList<>(); QueryWrapper<TCoursePackageDiscount> tCoursePackageDiscountQueryWrapper = new QueryWrapper<>(); tCoursePackageDiscountQueryWrapper.eq("auditStatus",2 ); tCoursePackageDiscountQueryWrapper.eq("auditStatus", 2); List<TCoursePackageDiscount> tCoursePackageDiscounts = new ArrayList<>(); if (null == discountType || discountType == 1){ tCoursePackageDiscountQueryWrapper.eq("type",3); int weekStr = LocalDateTimeUtils.getWeekStr(); if (null == discountType || discountType == 1) { tCoursePackageDiscountQueryWrapper.eq("type", 3); response.setDiscountType(1); tCoursePackageDiscounts = this.baseMapper.selectList(tCoursePackageDiscountQueryWrapper); if (tCoursePackageDiscounts.size() > 0){ if (tCoursePackageDiscounts.size() > 0) { for (TCoursePackageDiscount tCoursePackageDiscount : tCoursePackageDiscounts) { WeekLimitedResponse.Details ls = new WeekLimitedResponse.Details(); TCoursePackage coursePackage = tcpMapper.selectById(tCoursePackageDiscount.getCoursePackageId()); // 判断预约人数是否已满 Integer maxSubscribeNumber = coursePackage.getMaxSubscribeNumber(); Integer integer = tcppMapper.selectCount(new QueryWrapper<TCoursePackagePayment>() .eq("appUserId",appUserId ) .eq("status",1)); if (integer >= maxSubscribeNumber){ continue; } /** * [{ * "startDate": "2023-01-01 00:00:00", * "endDate": "2023-12-31 23:59:59", * "startTime": "02:00:00", * "endTime": "23:00:00", * "weeks": [1, 2, 7], * "cashPayment": 100 * }] */ try { ObjectMapper objectMapper = new ObjectMapper(); JsonNode rootNode = null; rootNode = objectMapper.readTree(tCoursePackageDiscount.getContent()); String courseHours = rootNode.get("courseHours").asText(); String lifespanEnd = rootNode.get("lifespanEnd").asText(); Date endTime = simpleDateFormat.parse(lifespanEnd); if (endTime.compareTo(lastTime) < 0){ continue; JSONArray jsonArray = JSON.parseArray(tCoursePackageDiscount.getContent()); JSONObject jsonObject = jsonArray.getJSONObject(0); Date parse1 = null; Date parse2 = null; String startDate = jsonObject.getString("startDate"); String endDate = jsonObject.getString("endDate"); try { parse1 = simpleDateFormat.parse(startDate); parse2 = simpleDateFormat.parse(endDate); } catch (ParseException e) { throw new RuntimeException(e); } TCoursePackage coursePackage = tcpMapper.selectById(tCoursePackageDiscount.getCoursePackageId()); GetDistanceVo distanceVo = new GetDistanceVo(); distanceVo.setLatitude(lat); distanceVo.setLongitude(lon); distanceVo.setStoreId(coursePackage.getStoreId()); ls.setStoreDistance(sreClient.calculateDistance(distanceVo)); // TODO: 2023/7/10 限时折扣查询 list.add(ls); List<Integer> weeks = jsonObject.getJSONArray("weeks").toJavaList(Integer.class); Double cashPayment = jsonObject.getDouble("cashPayment"); Date tomorrowDate = null; if (weekStr != 7) { Calendar calendar = Calendar.getInstance(); calendar.setTime(localTime); calendar.add(Calendar.DAY_OF_WEEK, 1); tomorrowDate = calendar.getTime(); } boolean isWithinRange = false; if (weeks.contains(weekStr)) { isWithinRange = true; } if (isWithinRange) { // 判断当前日期是否在开始时间和结束时间范围内 if (isDateWithinRange(localTime, parse1, parse2)) { WeekLimitedResponse.Details resde = new WeekLimitedResponse.Details(); resde.setCoursePackageDiscountId(tCoursePackageDiscount.getId()); resde.setImage(coursePackage.getCoverDrawing()); resde.setCoursePackageName(coursePackage.getName()); CoursePackagePaymentConfig paymentConfig = cppcMapper.selectById(tCoursePackageDiscount.getCoursePackagePaymentConfigId()); resde.setCourseHours(paymentConfig.getClassHours()); resde.setDataTime("今日"); resde.setDate(localTime); resde.setOriginalPrice(paymentConfig.getCashPayment()); resde.setDiscountPrice(cashPayment); resde.setStatus(1); GetDistanceVo distanceVo = new GetDistanceVo(); distanceVo.setLatitude(lat); distanceVo.setLongitude(lon); distanceVo.setStoreId(coursePackage.getStoreId()); resde.setStoreDistance(sreClient.calculateDistance(distanceVo)); list.add(resde); } } Calendar tempCalendar = Calendar.getInstance(); tempCalendar.setTime(localTime); tempCalendar.add(Calendar.DAY_OF_WEEK, 1); while (tempCalendar.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) { Date tempDate = tempCalendar.getTime(); int weekNumOfDate = DateTimeHelper.getWeekNumOfDate(tempDate); if (isDateWithinRange(tempDate, parse1, parse2) && weeks.contains(weekNumOfDate)) { WeekLimitedResponse.Details resde = new WeekLimitedResponse.Details(); resde.setCoursePackageDiscountId(tCoursePackageDiscount.getId()); resde.setImage(coursePackage.getCoverDrawing()); resde.setCoursePackageName(coursePackage.getName()); CoursePackagePaymentConfig paymentConfig = cppcMapper.selectById(tCoursePackageDiscount.getCoursePackagePaymentConfigId()); resde.setCourseHours(paymentConfig.getClassHours()); String weekOfDate = ""; if (weekStr != 7 && tempDate.equals(tomorrowDate)) { weekOfDate = "明日"; } else { weekOfDate = DateTimeHelper.getWeekOfDate(tempDate); } resde.setDataTime(weekOfDate); resde.setDate(tempDate); resde.setOriginalPrice(paymentConfig.getCashPayment()); resde.setDiscountPrice(cashPayment); resde.setStatus(2); GetDistanceVo distanceVo = new GetDistanceVo(); distanceVo.setLatitude(lat); distanceVo.setLongitude(lon); distanceVo.setStoreId(coursePackage.getStoreId()); resde.setStoreDistance(sreClient.calculateDistance(distanceVo)); list.add(resde); } tempCalendar.add(Calendar.DAY_OF_WEEK, 1); } } catch (Exception e) { e.printStackTrace(); } } } }else { tCoursePackageDiscountQueryWrapper.eq("type",4); response.setDiscountType(2); tCoursePackageDiscounts = this.baseMapper.selectList(tCoursePackageDiscountQueryWrapper); if (tCoursePackageDiscounts.size() > 0){ for (TCoursePackageDiscount tCoursePackageDiscount : tCoursePackageDiscounts) { try { ObjectMapper objectMapper = new ObjectMapper(); JsonNode rootNode = null; rootNode = objectMapper.readTree(tCoursePackageDiscount.getContent()); String courseHours = rootNode.get("courseHours").asText(); String lifespanStart = rootNode.get("lifespanStart").asText(); String lifespanEnd = rootNode.get("lifespanEnd").asText(); String classHours = rootNode.get("classHours").asText(); } catch (Exception e) { e.printStackTrace(); } else { tCoursePackageDiscountQueryWrapper.eq("type", 4); response.setDiscountType(2); tCoursePackageDiscounts = this.baseMapper.selectList(tCoursePackageDiscountQueryWrapper); if (tCoursePackageDiscounts.size() > 0) { for (TCoursePackageDiscount tCoursePackageDiscount : tCoursePackageDiscounts) { TCoursePackage coursePackage = tcpMapper.selectById(tCoursePackageDiscount.getCoursePackageId()); // 判断预约人数是否已满 Integer maxSubscribeNumber = coursePackage.getMaxSubscribeNumber(); Integer integer = tcppMapper.selectCount(new QueryWrapper<TCoursePackagePayment>() .eq("appUserId",appUserId ) .eq("status",1)); if (integer >= maxSubscribeNumber){ continue; } // [{ // "startDate": "2023-01-01 00:00:00", // "endDate": "2023-12-31 23:59:59", // "startTime": "02:00:00", // "endTime": "23:00:00", // "weeks": [1, 2, 7], // "hour": 10 // }] try { JSONArray jsonArray = JSON.parseArray(tCoursePackageDiscount.getContent()); JSONObject jsonObject = jsonArray.getJSONObject(0); Date parse1 = null; Date parse2 = null; String startDate = jsonObject.getString("startDate"); String endDate = jsonObject.getString("endDate"); try { parse1 = simpleDateFormat.parse(startDate); parse2 = simpleDateFormat.parse(endDate); } catch (ParseException e) { throw new RuntimeException(e); } List<Integer> weeks = jsonObject.getJSONArray("weeks").toJavaList(Integer.class); Integer cashPayment = jsonObject.getInteger("hour"); Date tomorrowDate = null; if (weekStr != 7) { Calendar calendar = Calendar.getInstance(); calendar.setTime(localTime); calendar.add(Calendar.DAY_OF_WEEK, 1); tomorrowDate = calendar.getTime(); } boolean isWithinRange = false; if (weeks.contains(weekStr)) { isWithinRange = true; } if (isWithinRange) { // 判断当前日期是否在开始时间和结束时间范围内 if (isDateWithinRange(localTime, parse1, parse2)) { WeekLimitedResponse.Details resde = new WeekLimitedResponse.Details(); resde.setCoursePackageDiscountId(tCoursePackageDiscount.getId()); resde.setImage(coursePackage.getCoverDrawing()); resde.setCoursePackageName(coursePackage.getName()); CoursePackagePaymentConfig paymentConfig = cppcMapper.selectById(tCoursePackageDiscount.getCoursePackagePaymentConfigId()); resde.setCourseHours(paymentConfig.getClassHours()); resde.setDonateHours(cashPayment); resde.setDataTime("今日"); resde.setDate(localTime); resde.setOriginalPrice(paymentConfig.getCashPayment()); resde.setStatus(1); GetDistanceVo distanceVo = new GetDistanceVo(); distanceVo.setLatitude(lat); distanceVo.setLongitude(lon); distanceVo.setStoreId(coursePackage.getStoreId()); resde.setStoreDistance(sreClient.calculateDistance(distanceVo)); list.add(resde); } } Calendar tempCalendar = Calendar.getInstance(); tempCalendar.setTime(localTime); tempCalendar.add(Calendar.DAY_OF_WEEK, 1); while (tempCalendar.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) { Date tempDate = tempCalendar.getTime(); int weekNumOfDate = DateTimeHelper.getWeekNumOfDate(tempDate); if (isDateWithinRange(tempDate, parse1, parse2) && weeks.contains(weekNumOfDate)) { WeekLimitedResponse.Details resde = new WeekLimitedResponse.Details(); resde.setCoursePackageDiscountId(tCoursePackageDiscount.getId()); resde.setImage(coursePackage.getCoverDrawing()); resde.setCoursePackageName(coursePackage.getName()); CoursePackagePaymentConfig paymentConfig = cppcMapper.selectById(tCoursePackageDiscount.getCoursePackagePaymentConfigId()); resde.setCourseHours(paymentConfig.getClassHours()); resde.setDonateHours(cashPayment); String weekOfDate = ""; if (weekStr != 7 && tempDate.equals(tomorrowDate)) { weekOfDate = "明日"; } else { weekOfDate = DateTimeHelper.getWeekOfDate(tempDate); } resde.setDataTime(weekOfDate); resde.setDate(tempDate); resde.setOriginalPrice(paymentConfig.getCashPayment()); resde.setStatus(2); GetDistanceVo distanceVo = new GetDistanceVo(); distanceVo.setLatitude(lat); distanceVo.setLongitude(lon); distanceVo.setStoreId(coursePackage.getStoreId()); resde.setStoreDistance(sreClient.calculateDistance(distanceVo)); list.add(resde); } tempCalendar.add(Calendar.DAY_OF_WEEK, 1); } } catch (Exception e) { e.printStackTrace(); } } } } } return response; } @Override public ExchangeCoursePackageResponse getWeekFreeCourseDetails(Integer coursePackageDiscountId,String lat,String lon) { ExchangeCoursePackageResponse packageResponse = new ExchangeCoursePackageResponse(); TCoursePackageDiscount coursePackageDiscount = this.baseMapper.selectById(coursePackageDiscountId); packageResponse.setCoursePackageDiscountId(coursePackageDiscount.getId()); Integer coursePackageId = coursePackageDiscount.getCoursePackageId(); TCoursePackage coursePackage = tcpMapper.selectById(coursePackageId); packageResponse.setCoverDrawing(coursePackage.getCoverDrawing()); packageResponse.setIntroduceDrawing(coursePackage.getIntroduceDrawing()); packageResponse.setCoursePackageName(coursePackage.getName()); Store store = sreClient.queryStoreById(coursePackage.getStoreId()); packageResponse.setStoreNameAddr(store.getName() +"(" +store.getAddress()+")"); GetDistanceVo distanceVo = new GetDistanceVo(); distanceVo.setLatitude(lat); distanceVo.setLongitude(lon); distanceVo.setStoreId(coursePackage.getStoreId()); long l = sreClient.calculateDistance(distanceVo); packageResponse.setDistance(l); JSONArray jsonArray = JSON.parseArray(coursePackageDiscount.getContent()); JSONObject jsonObject = jsonArray.getJSONObject(0); CoursePackagePaymentConfig paymentConfig = cppcMapper.selectById(coursePackageDiscount.getCoursePackagePaymentConfigId()); if (coursePackageDiscount.getType() == 3){ Double cashPayment = jsonObject.getDouble("cashPayment"); packageResponse.setClassHours(paymentConfig.getClassHours()); packageResponse.setCostPrice(paymentConfig.getCashPayment()); packageResponse.setDiscountPrice(cashPayment); }else { packageResponse.setClassHours(paymentConfig.getClassHours()); Integer cashPayment = jsonObject.getInteger("hour"); packageResponse.setFreeClassHours(cashPayment); packageResponse.setCostPrice(paymentConfig.getCashPayment()); TCoursePackageDiscount coursePackageDiscount1 = this.baseMapper.selectOne(new QueryWrapper<TCoursePackageDiscount>() .eq("type", 1) .eq("coursePackageId",coursePackage.getId())); String content = coursePackageDiscount1.getContent(); JSONObject jsonObject1 = JSON.parseObject(content); Double vipPrice = jsonObject1.getDouble("num1"); packageResponse.setDiscountPrice(vipPrice); packageResponse.setWanpaiGold(paymentConfig.getPlayPaiCoin()); } List<Integer> weeks = StrUtils.dealStrToList(coursePackage.getClassWeeks()); if (weeks.size() > 0){ StringBuilder courWeeks = new StringBuilder("每"); for (Integer integer : weeks) { switch (integer){ case 1: courWeeks.append("周一、"); break; case 2: courWeeks.append("周二、"); break; case 3: courWeeks.append("周三、"); break; case 4: courWeeks.append("周四、"); break; case 5: courWeeks.append("周五、"); break; case 6: courWeeks.append("周六、"); break; case 7: courWeeks.append("周末、"); break; default: break; } } if (courWeeks.length() > 0 && courWeeks.charAt(courWeeks.length() - 1) == ','){ courWeeks.deleteCharAt(courWeeks.length() - 1); } packageResponse.setWeekTime(courWeeks.toString()); } packageResponse.setTime(coursePackage.getClassStartTime()+"-"+coursePackage.getClassEndTime()); return packageResponse; } @Override public ResultUtil paymentDiscountCoursePack(Integer coursePackageDiscountId, Integer appuserId) { // TODO: 2023/7/13 折扣课包支付 return null; } private static boolean isDateWithinRange(Date date, Date startTime, Date endTime) { return date.after(startTime) && date.before(endTime); } } cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackagePaymentServiceImpl.java
@@ -9,6 +9,7 @@ import com.dsh.course.feignclient.activity.CouponClient; import com.dsh.course.feignclient.activity.model.BenefitsVideos; import com.dsh.course.feignclient.activity.model.Coupon; import com.dsh.course.feignclient.model.RecordAppoint; import com.dsh.course.feignclient.other.StoreClient; import com.dsh.course.feignclient.other.model.Store; import com.dsh.course.mapper.*; @@ -22,10 +23,7 @@ import com.dsh.course.model.vo.response.CourseDetailsResponse; import com.dsh.course.model.vo.response.CourseOfVideoResponse; import com.dsh.course.service.TCoursePackagePaymentService; import com.dsh.course.util.PayMoneyUtil; import com.dsh.course.util.ResultUtil; import com.dsh.course.util.StrUtils; import com.dsh.course.util.UUIDUtil; import com.dsh.course.util.*; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; @@ -33,6 +31,7 @@ import javax.annotation.Resource; import java.math.BigDecimal; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; import java.util.regex.Matcher; @@ -401,4 +400,80 @@ } @Override public List<RecordAppoint> obtainStuClassDetails(Integer stuId, Integer appUserId) { List<RecordAppoint> recordVoList = new ArrayList<>(); List<TCoursePackagePayment> tCoursePackagePayments = this.baseMapper.selectList(new QueryWrapper<TCoursePackagePayment>() .eq("studentId",stuId ) .eq("appUserId",appUserId ) .eq("payStatus",2 ) .eq("status",1 ) .orderByDesc("insertTime")); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd"); SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm"); if (tCoursePackagePayments.size() > 0 ){ for (TCoursePackagePayment tCoursePackagePayment : tCoursePackagePayments) { RecordAppoint recordVo = new RecordAppoint(); recordVo.setCoursePackageId(tCoursePackagePayment.getCoursePackageId()); TCoursePackage coursePackage = tcpmapper.selectById(tCoursePackagePayment.getCoursePackageId()); recordVo.setCoursePackageName(coursePackage.getName()); recordVo.setCourseHours(tCoursePackagePayment.getClassHours()); Date date = DateUtil.getDate(); String classStartTime = coursePackage.getClassStartTime(); String classEndTime = coursePackage.getClassEndTime(); recordVo.setTimeFrame(simpleDateFormat.format(date)+" "+classStartTime+"-"+classEndTime); Store store = stoClient.queryStoreById(coursePackage.getStoreId()); recordVo.setStoreNameAddr(store.getName()+store.getAddress()); CoursePackageStudent coursePackageStudent = cpsMapper.selectOne(new QueryWrapper<CoursePackageStudent>() .eq("coursePackageId",tCoursePackagePayment.getCoursePackageId() ) .eq("studentId",stuId) .eq("appUserId",appUserId) .eq("reservationStatus",1)); if (ToolUtil.isNotEmpty(coursePackageStudent) && coursePackageStudent.getReservationStatus() == 1){ recordVo.setCourseStuRecordId(coursePackageStudent.getId()); String classWeeks = coursePackage.getClassWeeks(); String[] split = classWeeks.split(";"); List<Integer> integerList = Arrays.stream(split) .map(Integer::parseInt) .collect(Collectors.toList()); int dayOfWeek = DateTimeHelper.getDayOfWeek(new Date()); if (integerList.contains(dayOfWeek)){ String dat = simpleDateFormat.format(date) +" "+ classStartTime; Date start = null; try { start = format.parse(dat); } catch (ParseException e) { throw new RuntimeException(e); } if (start.after(new Date())){ recordVo.setStatus(1); }else { CancelledClasses cancelledClasses = cacMapper.selectOne(new QueryWrapper<CancelledClasses>() .eq("coursePackageId",tCoursePackagePayment.getCoursePackageId() )); if (ToolUtil.isNotEmpty(cancelledClasses)){ recordVo.setStatus(3); }else { recordVo.setStatus(2); } } }else { recordVo.setStatus(1); } }else { recordVo.setStatus(4); } recordVoList.add(recordVo); } } return recordVoList; } } cloud-server-course/src/main/java/com/dsh/course/util/DateTimeHelper.java
@@ -1438,6 +1438,24 @@ return weekDays[w]; } /** * 获取当前日期是星期几<br> * Obtain the day of the week for the current date. * @param dt * @return 当前日期是星期几 */ public static int getWeekNumOfDate(Date dt) { Integer[] weekDays = {7, 1, 2, 3, 4, 5, 6}; // 将周一的数值设为2,依次递增表示周二到周日 Calendar cal = Calendar.getInstance(); cal.setTime(dt); int w = cal.get(Calendar.DAY_OF_WEEK) - 1; if (w < 0) { w = 6; // 如果为负数,将其设为6,表示周日 } return weekDays[w]; } /** * 获取今天时间 2017-11-20 00:00:00 */ cloud-server-course/src/main/java/com/dsh/course/util/LocalDateTimeUtils.java
@@ -5,6 +5,8 @@ import java.time.Duration; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.Calendar; import java.util.Date; /** * LocalDateTimeUtils @@ -89,5 +91,26 @@ return dayOfWeek.getValue(); } /** * 根据输入本周的周几,获取当天的时间 * @param dayOfWeekInput 周几 * @return */ public static Date getDateOfWeekNum(int dayOfWeekInput){ // 获取当前日期 Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); // 设置为本周的第一天(星期一) calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); // 根据输入的星期几数值,计算出相应的偏移量 int dayOfWeekIndex = (dayOfWeekInput + 6) % 7; calendar.add(Calendar.DAY_OF_WEEK, dayOfWeekIndex); // 获取计算后的日期 return calendar.getTime(); } }