5 文件已重命名
165个文件已修改
28个文件已添加
| | |
| | | @ApiModelProperty(value = "通用价格") |
| | | @TableField("general_price") |
| | | private BigDecimal generalPrice; |
| | | @ApiModelProperty(value = "余额") |
| | | @TableField(exist = false) |
| | | private BigDecimal balance; |
| | | |
| | | @ApiModelProperty(value = "IOS内购价格") |
| | | @TableField("ios_price") |
| | |
| | | @ApiModelProperty(value = "详情页封面图|详情页视频") |
| | | @TableField("detail_url") |
| | | private String detailUrl; |
| | | @ApiModelProperty(value = "详情页封面图|详情页视频 文件名称") |
| | | @TableField("detail_name") |
| | | private String detailName; |
| | | |
| | | @ApiModelProperty(value = "课程简介") |
| | | @TableField("brief_introduction") |
| | |
| | | |
| | | @ApiModelProperty(value = "课程地址经度") |
| | | @TableField("longitude") |
| | | private Double longitude; |
| | | private String longitude; |
| | | |
| | | @ApiModelProperty(value = "课程地址纬度") |
| | | @TableField("latitude") |
| | | private Double latitude; |
| | | private String latitude; |
| | | |
| | | @ApiModelProperty(value = "学习人数") |
| | | @ApiModelProperty(value = "总计学习人数") |
| | | @TableField(exist = false) |
| | | private Integer count; |
| | | @ApiModelProperty(value = "实际学习人数") |
| | | @TableField(exist = false) |
| | | private Integer realLearnedNum; |
| | | @ApiModelProperty(value = "虚拟学习人数") |
| | | @TableField(exist = false) |
| | | private Integer virtualLearnedNum; |
| | | @ApiModelProperty(value = "章节数量") |
| | | @TableField(exist = false) |
| | | private Long courseChapterCount; |
| | |
| | | @ApiModelProperty(value = "课程分类名称") |
| | | @TableField(exist = false) |
| | | private String categoryName; |
| | | @ApiModelProperty(value = "章节列表") |
| | | @TableField(exist = false) |
| | | private List<CourseChapter> list; |
| | | |
| | | } |
File was renamed from xinquan-modules/xinquan-course/src/main/java/com/xinquan/course/domain/CourseChapter.java |
| | |
| | | package com.xinquan.course.domain; |
| | | package com.xinquan.course.api.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import io.swagger.models.auth.In; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | |
| | | private String videoUrlName; |
| | | |
| | | @ApiModelProperty(value = "实际已学习人数/当前已学习人数") |
| | | @TableField("real_learned_num") |
| | | @TableField(exist = false) |
| | | private Integer realLearnedNum; |
| | | |
| | | @ApiModelProperty(value = "虚拟已学习人数") |
| | |
| | | private String courseTitle; |
| | | @ApiModelProperty(value = "导师名称") |
| | | private String tutor; |
| | | @ApiModelProperty(value = "选中数据导出的ids") |
| | | private String ids; |
| | | } |
| | |
| | | @ApiModel(value = "课程视图对象") |
| | | public class OrderCourseVO { |
| | | |
| | | @ApiModelProperty(value = "订单id") |
| | | private Long id; |
| | | @ApiModelProperty(value = "课程/音频id") |
| | | private Long businessId; |
| | | |
| | | @ApiModelProperty(value = "课程标题") |
| | | @ApiModelProperty(value = "课程/冥想标题") |
| | | private String courseTitle; |
| | | |
| | | @ApiModelProperty(value = "课程描述") |
| | |
| | | package com.xinquan.course.api.feign; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xinquan.common.core.constant.SecurityConstants; |
| | | import com.xinquan.common.core.constant.ServiceNameConstants; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.course.api.domain.CourseCategory; |
| | | import com.xinquan.course.api.domain.CourseDTO; |
| | | import com.xinquan.course.api.domain.OrderCourseVO; |
| | | import com.xinquan.course.api.domain.*; |
| | | import com.xinquan.course.api.factory.RemoteCourseFallbackFactory; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | */ |
| | | @FeignClient(contextId = "remoteCourseService", value = ServiceNameConstants.COURSE_SERVICE, fallbackFactory = RemoteCourseFallbackFactory.class) |
| | | public interface RemoteCourseService { |
| | | @GetMapping("/client/course/course/getCourseCount") |
| | | public R<String> getCourseCount(); |
| | | /** |
| | | * 根据课程id 查询学习人数 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("/client/course/course/getCountByCourseId/{id}") |
| | | public R<Integer> getCountByCourseId( |
| | | @PathVariable("id")String id); |
| | | /** |
| | | * 根据课程id 查询章节列表 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("/client/course/course/getChapterByCourseId/{id}") |
| | | public R<List<CourseChapter>> getChapterByCourseId( |
| | | @PathVariable("id")String id); |
| | | @GetMapping("/client/course/course/getCourseByIds/{pageCurr}/{pageSize}/{ids}") |
| | | R<Page<Course>> getCourseByIds(@PathVariable("pageCurr") Integer pageCurr, |
| | | @PathVariable("pageSize") Integer pageSize, |
| | | @PathVariable("ids")String ids |
| | | ); |
| | | @PostMapping("/client/course/course/getCourseIdsByName/{name}") |
| | | public R<List<Long>> getCourseIdsByName(@PathVariable("name") String name); |
| | | /** |
| | |
| | | * @return |
| | | */ |
| | | @GetMapping("/inner/course/course/getCourseById/{targetId}") |
| | | R<Course> getCourseById(@PathVariable("targetId") Long targetId, |
| | | @RequestHeader(SecurityConstants.FROM_SOURCE) String source); |
| | | @PostMapping("/client/course/course/getCourseByCourseId/{courseId}") |
| | | public R<OrderCourseVO> getCourseCategoryList(@RequestBody OrderCourseVO req); |
| | | R<Course> getCourseById(@PathVariable("targetId") Long targetId |
| | | ); |
| | | @PostMapping("/client/course/course/getCourseByIdAny") |
| | | public R<OrderCourseVO> getCourseByIdAny(@RequestBody OrderCourseVO req); |
| | | @GetMapping("/client/course/course/getCategoryById/{id}") |
| | | R<CourseCategory> getCategoryById(@PathVariable("id") String id); |
| | | @GetMapping("/client/course/course/cateList") |
| | |
| | | public class Meditation extends BaseModel { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "余额") |
| | | @TableField(exist = false) |
| | | private BigDecimal balance; |
| | | @ApiModelProperty(value = "id") |
| | | @TableId(value = "id",type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | @ApiModelProperty(value = "每日疗愈id 当设置为每日疗愈时存储") |
| | | @TableField("everyday_id") |
| | | private Long everydayId; |
| | | @ApiModelProperty(value = "是否为每日疗愈 1是2否") |
| | | @TableField("is_everyday") |
| | | private Integer isEveryday; |
| | | @ApiModelProperty(value = "每日疗愈 背景图片") |
| | | @TableField(exist = false) |
| | | private String imageUrl; |
| | | @ApiModelProperty(value = "播放时间段开始") |
| | | @TableField(exist = false) |
| | | @JsonFormat(pattern = "HH:mm:ss") |
| | | private LocalTime startPlayTime; |
| | | @ApiModelProperty(value = "播放时间段结束") |
| | | @TableField(exist = false) |
| | | @JsonFormat(pattern = "HH:mm:ss") |
| | | private LocalTime endPlayTime; |
| | | |
| | | @ApiModelProperty(value = "冥想音频分类id") |
| | | @TableField("cate_id") |
| | |
| | | @ApiModelProperty(value = "背景音频时长 单位秒 多个逗号分割 与背景音频一一对应") |
| | | @TableField(exist = false) |
| | | private String musicSecond; |
| | | @ApiModelProperty(value = "背景音频内存大小 单位kb 多个逗号分割 与背景音频一一对应") |
| | | @TableField(exist = false) |
| | | private String musicSize; |
| | | @ApiModelProperty(value = "背景音频名称 多个逗号分割 与背景音频一一对应") |
| | | @TableField(exist = false) |
| | | private String name; |
| | | @ApiModelProperty(value = "查看详情回显使用 背景音频") |
| | | @TableField(exist = false) |
| | | private List<String> musicList; |
| | |
| | | @ApiModelProperty(value = "导师音频时长 单位秒") |
| | | @TableField("tutor_audio_second") |
| | | private String tutorAudioSecond; |
| | | @ApiModelProperty(value = "导师音频文件名称") |
| | | @TableField("tutor_name") |
| | | private String tutorName; |
| | | @ApiModelProperty(value = "导师音频文件内存 单位kb ") |
| | | @TableField("tutor_size") |
| | | private String tutorSize; |
| | | |
| | | |
| | | @ApiModelProperty(value = "被点赞数") |
| | | @TableField("like_count") |
| | | private Integer likeCount; |
| | | |
| | | @ApiModelProperty(value = "被收藏数") |
| | | @TableField("favorite_count") |
| | | private Integer favoriteCount; |
| | | @ApiModelProperty(value = "播放时间段开始") |
| | | @TableField("start_play_time") |
| | | @JsonFormat(pattern = "HH:mm:ss") |
| | | private LocalTime startPlayTime; |
| | | |
| | | @ApiModelProperty(value = "播放时间段结束") |
| | | @TableField("end_play_time") |
| | | @JsonFormat(pattern = "HH:mm:ss") |
| | | private LocalTime endPlayTime; |
| | | |
| | | } |
| | |
| | | private String meditationTitle; |
| | | @ApiModelProperty(value = "疗愈标签") |
| | | private String tagName; |
| | | @ApiModelProperty(value = "选中的ids") |
| | | private String ids; |
| | | } |
| | |
| | | private String name; |
| | | @ApiModelProperty(value = "提问内容") |
| | | private String content; |
| | | @ApiModelProperty(value = "选中的提问ids") |
| | | private String ids; |
| | | @ApiModelProperty(value = "是否回复 1是2否 全部不传") |
| | | private Integer isReplay; |
| | | @ApiModelProperty(value = "是否显示 1是2否 全部不传") |
| | |
| | | public RemoteMeditationService create(Throwable cause) { |
| | | return new RemoteMeditationService() { |
| | | @Override |
| | | public R<String> getQuestionCount() { |
| | | return R.fail("远程调用 查询待回复内容数量"); |
| | | } |
| | | |
| | | @Override |
| | | public R<String> getMeditationCount() { |
| | | return R.fail("远程调用 查询疗愈音频数量"); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<Long>> getMeditationIdsByName(String name) { |
| | | return R.fail("获远程调用 通过疗愈名字查询疗愈ids失败"); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R<Page<Meditation>> getMeditationById(Integer pageCurr, Integer pageSize) { |
| | | public R<Page<Meditation>> getMeditationById(Integer pageCurr, Integer pageSize, Long id) { |
| | | return R.fail("查询收藏冥想失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<Page<Meditation>> getMeditationByIds(Integer pageCurr, Integer pageSize, String ids) { |
| | | return null; |
| | | } |
| | | |
| | | |
| | | }; |
| | | } |
| | | } |
| | |
| | | @FeignClient(contextId = "remoteMeditationService", value = ServiceNameConstants.MEDITATION_SERVICE, fallbackFactory = RemoteMeditationFallbackFactory.class) |
| | | public interface RemoteMeditationService { |
| | | /** |
| | | * 远程调用 查询待回复内容数量 |
| | | * @return |
| | | */ |
| | | @PostMapping("/client/meditation/meditation-question/getQuestionCount") |
| | | public R<String> getQuestionCount(); |
| | | @GetMapping("/client/meditation/meditation/getMeditationCount") |
| | | public R<String> getMeditationCount(); |
| | | /** |
| | | * 远程调用 通过疗愈名字查询疗愈ids |
| | | * @return |
| | | */ |
| | |
| | | public R<NoticeDetailVO> noticeDetail(NoticeDetailVO req); |
| | | @GetMapping("/client/meditation/meditation/getMeditationById/{id}") |
| | | public R<Meditation> getMeditationById(@PathVariable("id") Long id); |
| | | @GetMapping("/client/meditation/meditation/getMeditationById/{pageCurr}/{pageSize}") |
| | | public R<Page<Meditation>> getMeditationById(@PathVariable("pageCurr") Integer pageCurr, @PathVariable("pageSize") Integer pageSize); |
| | | @GetMapping("/client/meditation/meditation/getMeditationById/{pageCurr}/{pageSize}/{id}") |
| | | public R<Page<Meditation>> getMeditationById(@PathVariable("pageCurr") Integer pageCurr, |
| | | @PathVariable("pageSize") Integer pageSize, |
| | | @PathVariable("id")Long id |
| | | ); |
| | | @GetMapping("/client/meditation/meditation/getMeditationByIds/{pageCurr}/{pageSize}/{ids}") |
| | | public R<Page<Meditation>> getMeditationByIds(@PathVariable("pageCurr") Integer pageCurr, |
| | | @PathVariable("pageSize") Integer pageSize, |
| | | @PathVariable("ids")String ids |
| | | ); |
| | | } |
| | |
| | | @ApiModelProperty(value = "购买内容-课程-courseUid") |
| | | @TableField(exist = false) |
| | | private String courseUid; |
| | | @ApiModelProperty(value = "课程类型") |
| | | @TableField(exist = false) |
| | | private String courseType; |
| | | @ApiModelProperty(value = "课程类型 1线上 2线下") |
| | | @TableField(exist = false) |
| | | private String type; |
| | | @ApiModelProperty(value = "课程/疗愈id") |
| | | @TableField(exist = false) |
| | | private String uuid; |
| | | |
| | | |
| | | @ApiModelProperty(value = "购买内容-疗愈-所属分类名称") |
| | |
| | | @TableField(exist = false) |
| | | private String cellPhoneGive; |
| | | |
| | | @ApiModelProperty(value = "订单类型 1=冥想订单 2=课程订单 3=会员订单 4=充值") |
| | | @ApiModelProperty(value = "订单类型 1=冥想订单 2=课程订单 3=会员订单 4=充值 5=提现") |
| | | @TableField("order_from") |
| | | private Integer orderFrom; |
| | | |
| | | @ApiModelProperty(value = "支付状态 1=待支付 2=已完成 3=已取消") |
| | | @TableField("payment_status") |
| | | private Integer paymentStatus; |
| | | @ApiModelProperty(value = "支付方式 1微信 2支付宝 3余额 4内购 5微信+余额 6支付宝+余额 7内购加余额") |
| | | @ApiModelProperty(value = "支付方式 1微信 2支付宝 3内购 4余额 5微信+余额 6支付宝+余额 7内购加余额") |
| | | @TableField("pay_type") |
| | | private Integer payType; |
| | | |
| | |
| | | @ApiModelProperty(value = "退款流水号") |
| | | @TableField("refund_code") |
| | | private String refundCode; |
| | | @ApiModelProperty(value = "退款备注") |
| | | @TableField("refund_remark") |
| | | private String refundRemark; |
| | | @ApiModelProperty(value = "退款业务订单号") |
| | | @TableField("refund_order_no") |
| | | private String refundOrderNo; |
New file |
| | |
| | | package com.xinquan.order.api.domain.vo; |
| | | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @author mitao |
| | | * @date 2024/9/7 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "首页统计DTO") |
| | | public class HomeDto { |
| | | @ApiModelProperty(value = "订单状态 0全部 1待支付 2已完成 3已取消") |
| | | private Integer status; |
| | | @ApiModelProperty(value = "时间类型 1全年 2今日 3本周 4本月") |
| | | private Integer timeType; |
| | | @ApiModelProperty(value = "时间范围 例:2020-11-11 - 2022-11-11") |
| | | private String time; |
| | | } |
New file |
| | |
| | | package com.xinquan.order.api.domain.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @author mitao |
| | | * @date 2024/9/7 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "已购详情-待支付状态-页面数据") |
| | | public class PayOrderVO { |
| | | |
| | | @ApiModelProperty(value = "课程标题/冥想标题") |
| | | private String title; |
| | | @ApiModelProperty(value = "导师(类型为冥想的时候才会有)") |
| | | private String tutor; |
| | | @ApiModelProperty(value = "类型 1冥想 2课程") |
| | | private Integer orderFrom; |
| | | @ApiModelProperty(value = "冥想id/课程id") |
| | | private Long targetId; |
| | | @ApiModelProperty(value = "订单金额") |
| | | private BigDecimal amount; |
| | | @ApiModelProperty(value = "订单id") |
| | | private Long orderId; |
| | | } |
| | |
| | | public RemoteOrderService create(Throwable cause) { |
| | | return new RemoteOrderService() { |
| | | @Override |
| | | public R<Integer> getMeditationIsBuy(Long id, Long meditationId) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public R<List<Order>> getOrderList(Integer status, Integer timeType, String time) { |
| | | return R.fail("远程调用获取订单列表"+cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<Order>> getOrderListByType(Long userId, Integer orderFrom, |
| | | String source) { |
| | | return R.fail("获取订单列表失败"); |
| | |
| | | */ |
| | | @FeignClient(contextId = "remoteOrderService", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = RemoteOrderFallbackFactory.class) |
| | | public interface RemoteOrderService { |
| | | |
| | | @GetMapping("/client/order/order/getMeditationIsBuy/{id}/{meditationId}") |
| | | public R<Integer> getMeditationIsBuy(@PathVariable("id")Long id,@PathVariable("meditationId")Long meditationId); |
| | | @PostMapping("/mgt/order/order/getOrderList") |
| | | public R<List<Order>> getOrderList(@RequestParam("status") Integer status, |
| | | @RequestParam("timeType") Integer timeType, |
| | | @RequestParam("time") String time); |
| | | @PostMapping("/inner/order/order/getOrderListByType") |
| | | R<List<Order>> getOrderListByType(@RequestParam("userId") Long userId, |
| | | @RequestParam("orderFrom") Integer orderFrom, |
| | |
| | | @TableField("income") |
| | | private BigDecimal income; |
| | | |
| | | @ApiModelProperty(value = "当前累计能量值 ") |
| | | @ApiModelProperty(value = "当前累计能量值") |
| | | @TableField("total_energy_value") |
| | | private Integer totalEnergyValue; |
| | | |
| | |
| | | @ApiModelProperty(value = "用户id") |
| | | @TableField("app_user_id") |
| | | private Long appUserId; |
| | | @ApiModelProperty(value = "银行账户类型") |
| | | @TableField("card_type") |
| | | private Integer cardType; |
| | | |
| | | @ApiModelProperty(value = "银行名称") |
| | | @TableField("bank_name") |
| | |
| | | @ApiModelProperty(value = "用户id") |
| | | @TableField("app_user_id") |
| | | private Long appUserId; |
| | | @ApiModelProperty(value = "用户id") |
| | | @TableField("update_id") |
| | | private Long updateId; |
| | | |
| | | @ApiModelProperty(value = "变动类型 1=增加 2=减少") |
| | | @TableField("change_type") |
| | |
| | | package com.xinquan.system.api.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "用户计划引导问题记录表") |
| | | @TableId("id") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "1:您是否内心纠结敏感多疑?2:您是否辗转反侧彻夜难眠?3:您是否情绪失控暴躁易怒?4:您是否沉迷情感倍受伤害?5:您是否人生迷茫踌躇彷徨?6:其它补充说明") |
| | |
| | | @ApiModelProperty(value = "每日疗愈30分钟是否完成 1是2否") |
| | | @TableField(exist = false) |
| | | private Integer taskOne; |
| | | @ApiModelProperty(value = "当前剩余能量值") |
| | | @TableField(exist = false) |
| | | private Integer energyValue; |
| | | @ApiModelProperty(value = "每日疗愈60分钟是否完成 1是2否") |
| | | @TableField(exist = false) |
| | | private Integer taskTwo; |
| | |
| | | package com.xinquan.system.api.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "用户树苗id") |
| | | @TableId("id") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "用户id") |
| | |
| | | @ApiModelProperty(value = "提现流水号") |
| | | @TableField("serial_no") |
| | | private String serialNo; |
| | | @ApiModelProperty(value = "业务订单号") |
| | | @TableField("code") |
| | | private String code; |
| | | @ApiModelProperty(value = "提现失败原因") |
| | | @TableField("reason") |
| | | private String reason; |
| | | |
| | | @ApiModelProperty(value = "提现时间") |
| | | @TableField("withdraw_time") |
| | | private LocalDateTime withdrawTime; |
| | | |
| | | |
| | | @ApiModelProperty(value = "用户名称") |
| | | @TableField(exist = false) |
| | | private String userName; |
| | | @ApiModelProperty(value = "uid") |
| | | @TableField(exist = false) |
| | | private String uid; |
| | | @ApiModelProperty(value = "用户手机号") |
| | | @TableField(exist = false) |
| | | private String cellPhone; |
| | | @ApiModelProperty(value = "用户头像") |
| | | @TableField(exist = false) |
| | | private String avatar; |
| | | } |
File was renamed from xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/domain/CommissionRule.java |
| | |
| | | package com.xinquan.system.domain; |
| | | package com.xinquan.system.api.domain; |
| | | |
| | | import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.C; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | |
| | | * @since 2024-08-21 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("t_commission_rule") |
| | | @ApiModel(value="CommissionRule对象", description="奋勇规则表") |
| | | public class CommissionRule extends BaseModel { |
| | | public class CommissionRule { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "id") |
| | | @TableId("id") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "分佣比例") |
| | |
| | | import com.xinquan.common.core.web.domain.BaseModel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | |
| | | @ApiModelProperty(value = "价格设定 1=免费 2=会员免费 3=单独收费") |
| | | @TableField(exist = false) |
| | | private Integer chargeType; |
| | | @ApiModelProperty(value = "价格") |
| | | @TableField(exist = false) |
| | | private BigDecimal money; |
| | | |
| | | @ApiModelProperty(value = "提问时间") |
| | | @TableField("publish_time") |
| | |
| | | @ApiModelProperty(value = "提问内容") |
| | | @TableField(exist = false) |
| | | private String content; |
| | | @ApiModelProperty(value = "提问时间") |
| | | @TableField(exist = false) |
| | | private String contentTime; |
| | | @ApiModelProperty(value = "价格设定 1=免费 2=会员免费 3=单独收费") |
| | | @TableField(exist = false) |
| | | private Integer chargeType; |
| | |
| | | @ApiModelProperty(value = "uid") |
| | | @TableField(exist = false) |
| | | private String uid; |
| | | @ApiModelProperty(value = "uuid") |
| | | @TableField(exist = false) |
| | | private String uuid; |
| | | @ApiModelProperty(value = "用户名称") |
| | | @TableField(exist = false) |
| | | private String userName; |
| | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import javax.validation.constraints.Size; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import org.apache.commons.lang3.builder.ToStringBuilder; |
| | | import org.apache.commons.lang3.builder.ToStringStyle; |
| | | import com.xinquan.common.core.web.domain.BaseEntity; |
| | |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | |
| | | /** 部门ID */ |
| | | @TableId(type = IdType.AUTO) |
| | | @ApiModelProperty(value = "主键id") |
| | | |
| | | private Long deptId; |
| | | @ApiModelProperty(value = "部门Id") |
| | | private String deptCode; |
| | | @ApiModelProperty(value = "部门人数") |
| | | @TableField(exist = false) |
| | | |
| | | private Integer userCount; |
| | | |
| | | /** 父部门ID */ |
| | | private Long parentId; |
| | | |
| | | /** 祖级列表 */ |
| | | private String ancestors; |
| | | @ApiModelProperty("禁用备注") |
| | | private String reason; |
| | | @ApiModelProperty("操作人") |
| | | private String handleName; |
| | | |
| | | /** 部门名称 */ |
| | | |
| | | @ApiModelProperty(value = "部门名称") |
| | | private String deptName; |
| | | @ApiModelProperty(value = "备注") |
| | | |
| | | private String remark; |
| | | |
| | | /** 显示顺序 */ |
| | | private Integer orderNum; |
| | |
| | | /** 邮箱 */ |
| | | private String email; |
| | | |
| | | /** 部门状态:0正常,1停用 */ |
| | | |
| | | @ApiModelProperty(value = "部门状态:0正常,1停用") |
| | | private String status; |
| | | |
| | | /** 删除标志(0代表存在 2代表删除) */ |
| | |
| | | .append("updateTime", getUpdateTime()) |
| | | .toString(); |
| | | } |
| | | |
| | | @Override |
| | | public String getRemark() { |
| | | return remark; |
| | | } |
| | | |
| | | @Override |
| | | public void setRemark(String remark) { |
| | | this.remark = remark; |
| | | } |
| | | |
| | | public String getDeptCode() { |
| | | return deptCode; |
| | | } |
| | | |
| | | public void setDeptCode(String deptCode) { |
| | | this.deptCode = deptCode; |
| | | } |
| | | |
| | | |
| | | |
| | | public Integer getUserCount() { |
| | | return userCount; |
| | | } |
| | | |
| | | public void setUserCount(Integer userCount) { |
| | | this.userCount = userCount; |
| | | } |
| | | |
| | | public String getReason() { |
| | | return reason; |
| | | } |
| | | |
| | | public void setReason(String reason) { |
| | | this.reason = reason; |
| | | } |
| | | |
| | | public String getHandleName() { |
| | | return handleName; |
| | | } |
| | | |
| | | public void setHandleName(String handleName) { |
| | | this.handleName = handleName; |
| | | } |
| | | } |
File was renamed from xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/domain/SysMenu.java |
| | |
| | | package com.xinquan.system.domain; |
| | | package com.xinquan.system.api.domain; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | import javax.validation.constraints.Size; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import lombok.Data; |
| | | import org.apache.commons.lang3.builder.ToStringBuilder; |
| | | import org.apache.commons.lang3.builder.ToStringStyle; |
| | | import com.xinquan.common.core.annotation.Excel; |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Data |
| | | public class SysRole extends BaseEntity |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | |
| | | @Excel(name = "角色名称") |
| | | @TableField("role_name") |
| | | private String roleName; |
| | | @Excel(name = "角色数量") |
| | | @TableField(exist = false) |
| | | private Integer roleCount; |
| | | |
| | | /** 角色权限 */ |
| | | @Excel(name = "角色权限") |
| | |
| | | .append("remark", getRemark()) |
| | | .toString(); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.xinquan.system.api.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.xinquan.common.core.annotation.Excel; |
| | | import com.xinquan.common.core.annotation.Excel.ColumnType; |
| | |
| | | |
| | | /** 用户ID */ |
| | | @Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号") |
| | | @TableField("user_id") |
| | | @TableId("user_id") |
| | | private Long userId; |
| | | |
| | | /** 部门ID */ |
| | |
| | | private String userName; |
| | | |
| | | /** 用户昵称 */ |
| | | @Excel(name = "用户名称") |
| | | @NotBlank(message = "姓名不能为空") |
| | | @Excel(name = "用户名称(姓名)") |
| | | @TableField("nick_name") |
| | | private String nickName; |
| | | @Excel(name = "操作人") |
| | | @TableField("handleName") |
| | | private String handleName; |
| | | |
| | | /** 用户邮箱 */ |
| | | @Excel(name = "用户邮箱") |
| | |
| | | |
| | | /** 手机号码 */ |
| | | @Excel(name = "手机号码") |
| | | @NotBlank(message = "请输入账号") |
| | | private String phonenumber; |
| | | |
| | | /** 用户性别 */ |
| | |
| | | private String avatar; |
| | | |
| | | /** 密码 */ |
| | | @NotBlank(message = "密码不能为空") |
| | | private String password; |
| | | |
| | | /** 帐号状态(0正常 1停用) */ |
| | |
| | | |
| | | /** 角色组 */ |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "角色id数组") |
| | | private Long[] roleIds; |
| | | |
| | | /** 岗位组 */ |
| | | @TableField(exist = false) |
| | | private Long[] postIds; |
| | | @ApiModelProperty(value = "部门id数组") |
| | | private List<Long> deptIds; |
| | | |
| | | /** 角色ID */ |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "角色ids 逗号拼接") |
| | | private Long roleId; |
| | | |
| | | |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty(value = "用户类型 00:管理后台用户 01:APP用户") |
| | | @TableField("user_type") |
| | | private String userType; |
| | | @ApiModelProperty(value = "禁用原因") |
| | | @TableField("reason") |
| | | private String reason; |
| | | @ApiModelProperty(value = "禁用时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @TableField("disable_time") |
| | | private LocalDateTime disableTime; |
| | | |
| | | public String getUserType() { |
| | |
| | | this.roleIds = roleIds; |
| | | } |
| | | |
| | | public Long[] getPostIds() |
| | | { |
| | | return postIds; |
| | | } |
| | | |
| | | public void setPostIds(Long[] postIds) |
| | | { |
| | | this.postIds = postIds; |
| | | } |
| | | |
| | | public Long getRoleId() |
| | | { |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "标签id") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "标签类型") |
File was renamed from xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/domain/TreeLevelSetting.java |
| | |
| | | package com.xinquan.system.domain; |
| | | package com.xinquan.system.api.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "用户等级id") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "树苗等级类型 1=种子 2=发芽 3=幼苗 4=小树苗 5=中等树苗 6=小树 7=中树 8=大树 9=成熟的大树 10=参天大树") |
| | |
| | | |
| | | @ApiModelProperty(value = "用户id") |
| | | private Long appUserId; |
| | | @ApiModelProperty(value = "管理后台能量值修改人id") |
| | | private Long updateId; |
| | | |
| | | @ApiModelProperty(value = "变动类型 1=增加 2=减少") |
| | | private Integer changeType; |
| | |
| | | |
| | | @ApiModelProperty(value = "原因/操作内容") |
| | | private String reason; |
| | | @ApiModelProperty(value = "操作用户名称") |
| | | private String name; |
| | | @ApiModelProperty(value = "操作用户电话") |
| | | private String phone; |
| | | |
| | | |
| | | } |
| | |
| | | private String imageUrl; |
| | | |
| | | @ApiModelProperty(value = "跳转课程id") |
| | | private Integer courseId; |
| | | private Long courseId; |
| | | } |
New file |
| | |
| | | package com.xinquan.system.api.domain.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author mitao |
| | | * @date 2024/8/21 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "首页统计返回VO") |
| | | public class HomeVO implements Serializable { |
| | | private static final long serialVersionUID = -3850851853092651572L; |
| | | @ApiModelProperty(value = "用户总数") |
| | | private String userCount; |
| | | @ApiModelProperty(value = "非会员数") |
| | | private String noVip; |
| | | @ApiModelProperty(value = "月卡会员数") |
| | | private String vipMonth; |
| | | @ApiModelProperty(value = "季卡会员数") |
| | | private String vipQuarter; |
| | | @ApiModelProperty(value = "年卡会员数") |
| | | private String vipYear; |
| | | @ApiModelProperty(value = "课程总数") |
| | | private String courseCount; |
| | | @ApiModelProperty(value = "免费课程数") |
| | | private String courseFree; |
| | | @ApiModelProperty(value = "会员课程数") |
| | | private String courseVip; |
| | | @ApiModelProperty(value = "线下课程数") |
| | | private String courseOffOnline; |
| | | @ApiModelProperty(value = "单独付费课程数") |
| | | private String coursePay; |
| | | @ApiModelProperty(value = "疗愈音频总数") |
| | | private String meditationCount; |
| | | @ApiModelProperty(value = "免费音频数") |
| | | private String meditationFree; |
| | | @ApiModelProperty(value = "会员音频数") |
| | | private String meditationVip; |
| | | @ApiModelProperty(value = "单独付费音频数") |
| | | private String meditationPay; |
| | | @ApiModelProperty(value = "提问待回复") |
| | | private String questionRecord; |
| | | @ApiModelProperty(value = "奖品兑换中") |
| | | private String prizeRecord; |
| | | @ApiModelProperty(value = "订单总额") |
| | | private String orderMoney; |
| | | @ApiModelProperty(value = "订单总数") |
| | | private String orderCount; |
| | | @ApiModelProperty(value = "用户增长总数") |
| | | private Map<String,Object> userList; |
| | | @ApiModelProperty(value = "订单统计-课程") |
| | | private Map<String,Object> orderCourseList; |
| | | @ApiModelProperty(value = "订单统计-疗愈") |
| | | private Map<String,Object> orderMeditationList; |
| | | @ApiModelProperty(value = "订单统计-会员") |
| | | private Map<String,Object> orderVipList; |
| | | } |
| | |
| | | package com.xinquan.system.api.domain.vo; |
| | | |
| | | import com.xinquan.common.core.web.page.BasePage; |
| | | import com.xinquan.system.api.domain.SysUser; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "查询管理后台人员列表DTO") |
| | | public class SysUserVO extends BasePage { |
| | | public class SysUserVO extends SysUser { |
| | | @ApiModelProperty(value = "联系电话或姓名") |
| | | private String phoneOrName; |
| | | @ApiModelProperty(value = "登录状态(0正常 1停用)") |
| | | private String status; |
| | | @ApiModelProperty(value = "角色ids") |
| | | |
| | | @ApiModelProperty(value = "角色ids 前端忽略") |
| | | private List<Long> role; |
| | | @ApiModelProperty(value = "部门ids") |
| | | private List<Long> dept; |
| | | @ApiModelProperty(value = "角色名称列表") |
| | | private List<String> roleNames; |
| | | |
| | | @ApiModelProperty(value = "部门名称ids") |
| | | private List<String> deptNames; |
| | | @ApiModelProperty(value = "用户ids 前端忽略") |
| | | private List<Long> userIds; |
| | | } |
| | |
| | | package com.xinquan.system.api.factory; |
| | | |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.system.api.domain.SysRole; |
| | | import com.xinquan.system.api.domain.SysUser; |
| | | import com.xinquan.common.core.web.domain.AjaxResult; |
| | | import com.xinquan.system.api.domain.*; |
| | | import com.xinquan.system.api.feignClient.SysUserClient; |
| | | import java.util.List; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | |
| | | return new SysUserClient(){ |
| | | |
| | | @Override |
| | | public R<List<SysMenu>> roleInfoFromUserId(Long userId) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public R<List<TreeLevelSetting>> getTreeGroup() { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public R<SysUser> getSysUser(Long userId) { |
| | | return R.fail("获取用户失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<CommissionRule> getCommission() { |
| | | return R.fail("获取分佣比例设置失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<Boolean> updateSysUser(SysUser sysUser) { |
| | | return R.fail("更新用户失败:" + cause.getMessage()); |
| | | } |
| | |
| | | |
| | | import com.xinquan.common.core.constant.ServiceNameConstants; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.system.api.domain.SysRole; |
| | | import com.xinquan.system.api.domain.SysUser; |
| | | import com.xinquan.common.core.web.domain.AjaxResult; |
| | | import com.xinquan.system.api.domain.*; |
| | | import com.xinquan.system.api.factory.SysUserFallbackFactory; |
| | | import java.util.List; |
| | | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | @FeignClient(contextId = "sysUserClient", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = SysUserFallbackFactory.class) |
| | | public interface SysUserClient { |
| | | @GetMapping("/system/role/roleInfoFromUserId/{userId}") |
| | | public R<List<SysMenu>> roleInfoFromUserId(@PathVariable("userId") Long userId); |
| | | |
| | | @PostMapping("/system/tree-level-setting/getTreeGroup") |
| | | @ApiOperation(value = "获取树苗音频等级列表",tags = "管理后台-树苗音频设置") |
| | | public R<List<TreeLevelSetting>> getTreeGroup(); |
| | | @PostMapping("/user/getSysUser") |
| | | R<SysUser> getSysUser(Long userId); |
| | | |
| | | /** |
| | | * 获取分佣比例设置 |
| | | * @return |
| | | */ |
| | | @PostMapping("/system/commission/rule/getCommission") |
| | | public R<CommissionRule> getCommission(); |
| | | |
| | | @PostMapping("/user/updateSysUser") |
| | | R<Boolean> updateSysUser(@RequestBody SysUser sysUser); |
| | | |
| | |
| | | * 微信openId |
| | | */ |
| | | @ApiModelProperty(value = "微信openId", required = true) |
| | | @NotBlank(message = "微信openId不能为空") |
| | | private String wxOpenId; |
| | | |
| | | /** |
| | | * 用户昵称 |
| | | */ |
| | | @ApiModelProperty(value = "用户昵称", required = true) |
| | | @NotBlank(message = "用户昵称不能为空") |
| | | @ApiModelProperty(value = "用户昵称") |
| | | private String nickname; |
| | | |
| | | /** |
| | | * 用户头像 |
| | | */ |
| | | @ApiModelProperty(value = "用户头像", required = true) |
| | | @NotBlank(message = "用户头像不能为空") |
| | | @ApiModelProperty(value = "用户头像") |
| | | private String headImgUrl; |
| | | |
| | | /** |
| | | * 用户头像 |
| | | */ |
| | | @ApiModelProperty(value = "用户性别", required = true) |
| | | @NotNull(message = "用户性别不能为空") |
| | | @ApiModelProperty(value = "用户性别") |
| | | private Integer sex; |
| | | |
| | | } |
File was renamed from xinquan-api/xinquan-api-order/src/main/java/com/xinquan/order/api/domain/dto/OrderListDTO.java |
| | |
| | | package com.xinquan.order.api.domain.dto; |
| | | package com.xinquan.user.api.domain.dto; |
| | | |
| | | import com.xinquan.common.core.web.page.BasePage; |
| | | import io.swagger.annotations.ApiModel; |
| | |
| | | public class OrderListDTO extends BasePage { |
| | | @ApiModelProperty(value = "兑换时间 2020-01-01 - 2020-12-30") |
| | | private String time; |
| | | @ApiModelProperty(value = "支付方式 1微信 2支付宝 3余额 4内购") |
| | | @ApiModelProperty(value = "支付方式 1微信 2支付宝 3内购 4余额") |
| | | private Integer payType; |
| | | @ApiModelProperty(value = "用户uid") |
| | | private String uid; |
| | | // @ApiModelProperty(value = "支付方式 1微信 2支付宝 3内购 4余额 5微信+余额 6支付宝+余额 7内购加余额") |
| | | // private Integer status; |
| | | @ApiModelProperty(value = "支付状态 1=待支付 2=已完成 3=已取消") |
| | | @ApiModelProperty(value = "支付状态(提现状态没有1 只有2和3) 1=待支付 2=已完成 3=已取消(提现失败)") |
| | | private Integer paymentStatus; |
| | | @ApiModelProperty(value = "订单类型 1=冥想订单 2=课程订单 3=会员订单 4=充值") |
| | | @ApiModelProperty(value = "订单类型 1=冥想订单 2=课程订单 3=会员订单 4=充值 5余额提现") |
| | | private Integer orderFrom; |
| | | @ApiModelProperty(value = "用户名称/手机号") |
| | | private String userNameOrPhone; |
| | | @ApiModelProperty(value = "订单编号/购买内容") |
| | | @ApiModelProperty(value = "订单编号/购买内容/提现单号") |
| | | private String buyContent; |
| | | @ApiModelProperty(value = "选中数据的ids") |
| | | private String ids; |
| | | } |
| | |
| | | private String userNameOrPhone; |
| | | @ApiModelProperty(value = "奖品名称") |
| | | private String name; |
| | | @ApiModelProperty(value = "选中的数据ids") |
| | | private String ids; |
| | | } |
| | |
| | | import com.xinquan.system.api.model.AppVerifyCellPhoneBody; |
| | | import com.xinquan.system.api.model.AppWXLoginBody; |
| | | import com.xinquan.user.api.domain.dto.AppUserDTO; |
| | | import com.xinquan.user.api.domain.dto.OrderListDTO; |
| | | import com.xinquan.user.api.feign.RemoteAppUserService; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | |
| | | @Override |
| | | public RemoteAppUserService create(Throwable cause) { |
| | | return new RemoteAppUserService() { |
| | | @Override |
| | | public R addBalance(Long id, BigDecimal money) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public R addVipExpireTime(Long id, Integer type) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public R<Map<String, Object>> getUserListCount() { |
| | | return R.fail("后台远程调用 用户新增数量"); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public R<String> getPrizeRecordCount() { |
| | | return R.fail("后台远程调用 领取中的兑换记录"); |
| | | } |
| | | |
| | | @Override |
| | | public R<String> getUserCount() { |
| | | return R.fail("后台远程调用 查询用户数量 会员数量 非会员数量"); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<AppUserWithdraw>> getWithdraw(OrderListDTO courseDTO) { |
| | | return R.fail("后台远程调用 查询提现记录"); |
| | | } |
| | | |
| | | @Override |
| | | public R addBalanceRecord(AppUserWalletRecord appUserWalletRecord) { |
| | | return R.fail("后台远程调用 新增用户余额明细记录"); |
| | | } |
| | | |
| | | @Override |
| | | public R addAppUserCourse(Long courseId, Long appUserId, Long orderId, Integer giftFlag) { |
| | | return R.fail("远程调用 购买课程后 增加课程与用户关系表"); |
| | | } |
| | | |
| | | @Override |
| | | public R addNoticeReplay(NoticeRecord noticeRecord) { |
| | | return R.fail("后台远程调用 新增回复消息失败"); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R<PageDTO<AppUserCourse>> getPayCourse(Integer pageCurr, Integer pageSize) { |
| | | public R<PageDTO<AppUserCourse>> getPayCourse(Integer pageCurr, Integer pageSize,String id) { |
| | | return R.fail("查询用户已购课程失败"); |
| | | |
| | | } |
| | |
| | | import com.xinquan.system.api.model.AppVerifyCellPhoneBody; |
| | | import com.xinquan.system.api.model.AppWXLoginBody; |
| | | import com.xinquan.user.api.domain.dto.AppUserDTO; |
| | | import com.xinquan.user.api.domain.dto.OrderListDTO; |
| | | import com.xinquan.user.api.factory.RemoteAppUserFallbackFactory; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | |
| | | */ |
| | | @FeignClient(contextId = "remoteAppUserService", value = ServiceNameConstants.APP_USER_SERVICE, fallbackFactory = RemoteAppUserFallbackFactory.class) |
| | | public interface RemoteAppUserService { |
| | | |
| | | @GetMapping("/client/app-user/addBalance/{id}/{money}") |
| | | public R addBalance(@PathVariable("id")Long id,@PathVariable("money") BigDecimal money); |
| | | @GetMapping("/client/app-user/addVipExpireTime/{id}/{type}") |
| | | public R addVipExpireTime(@PathVariable("id")Long id,@PathVariable("type")Integer type); |
| | | @PostMapping("/client/app-user/getUserListCount") |
| | | public R<Map<String,Object>> getUserListCount(); |
| | | @PostMapping("/client/prize-redemption-record/getPrizeRecordCount") |
| | | public R<String> getPrizeRecordCount(); |
| | | @PostMapping("/client/app-user/getUserCount") |
| | | public R<String> getUserCount(); |
| | | @PostMapping("/client/app-user-withdraw/getWithdrawList") |
| | | public R<List<AppUserWithdraw>> getWithdraw(@RequestBody OrderListDTO courseDTO); |
| | | @PostMapping("/client/app-user-wallet-record/addBalanceRecord") |
| | | public R addBalanceRecord(@RequestBody AppUserWalletRecord appUserWalletRecord); |
| | | /** |
| | | * 远程调用 购买课程后 增加课程与用户关系表 |
| | | * |
| | | * @return 用户信息 |
| | | * @see AppUserVO |
| | | */ |
| | | @GetMapping("/client/app-user-course/addAppUserCourse/{courseId}/{appUserId}/{orderId}/{giftFlag}") |
| | | public R addAppUserCourse(@PathVariable("courseId") Long courseId, |
| | | @PathVariable("appUserId") Long appUserId, |
| | | @PathVariable("orderId") Long orderId, |
| | | @PathVariable("giftFlag") Integer giftFlag |
| | | ); |
| | | /** |
| | | * 后台远程调用 新增回复消息 |
| | | * @return |
| | |
| | | public R<List<Tag>> queryTag(@PathVariable("name") String name); |
| | | @PostMapping("/client/app-user/getCurrentUser") |
| | | public R<AppUserVO> getCurrentUser(); |
| | | @GetMapping("/client/app-user-course/getPayCourse/{pageCurr}/{pageSize}") |
| | | R<PageDTO<AppUserCourse>> getPayCourse(@PathVariable("pageCurr")Integer pageCurr, @PathVariable("pageSize")Integer pageSize); |
| | | @GetMapping("/client/app-user-course/getPayCourse/{pageCurr}/{pageSize}/{id}") |
| | | R<PageDTO<AppUserCourse>> getPayCourse(@PathVariable("pageCurr")Integer pageCurr, @PathVariable("pageSize")Integer pageSize |
| | | , @PathVariable("id")String id); |
| | | @PostMapping("/user/app-user-viewing-history/getCourseStudyHistory") |
| | | R<AppUserViewingHistory> getCourseStudyHistory(@RequestParam("chapterId") Long chapterId); |
| | | |
| | |
| | | import com.xinquan.common.security.auth.AuthUtil; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.system.api.domain.SysMenu; |
| | | import com.xinquan.system.api.domain.SysRole; |
| | | import com.xinquan.system.api.domain.SysUser; |
| | | import com.xinquan.system.api.feignClient.SysUserClient; |
| | |
| | | import java.time.LocalDateTime; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | */ |
| | | @ApiOperation(value = "注册账户",tags = {"APP端"}) |
| | | @PostMapping("/app/register") |
| | | public R<AppLoginUser> appRegister(@Validated @RequestBody AppRegisterBody appRegisterBody) |
| | | public R<AppLoginUser> appRegister(@RequestBody AppRegisterBody appRegisterBody) |
| | | { |
| | | // 用户注册 |
| | | AppLoginUser appLoginUser = sysLoginService.appRegister(appRegisterBody); |
| | |
| | | LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword()); |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("token",tokenService.createToken(userInfo)); |
| | | List<SysRole> roles = userInfo.getSysUser().getRoles(); |
| | | Set<String> roles = userInfo.getRoles(); |
| | | |
| | | if(CollectionUtils.isEmpty(roles)){ |
| | | return R.fail("请关联角色!"); |
| | | } |
| | | |
| | | map.put("roleName",roles.get(0).getRoleName()); |
| | | map.put("roleName",roles.stream().findFirst().get()); |
| | | map.put("info",userInfo); |
| | | List<SysMenu> data = userClient.roleInfoFromUserId(userInfo.getUserid()).getData(); |
| | | map.put("menus",data); |
| | | // 修改用户最后登录时间 |
| | | SysUser sysUser = new SysUser(); |
| | | sysUser.setUserId(userInfo.getSysUser().getUserId()); |
| | | sysUser.setLoginDate(LocalDateTime.now()); |
| | | System.out.println("修改用户登录时间"+sysUser); |
| | | userClient.updateSysUser(sysUser); |
| | | // 获取登录token |
| | | return R.ok(map); |
| | | } |
| | |
| | | |
| | | private static final long serialVersionUID = 438348119520198682L; |
| | | |
| | | @ApiModelProperty(value = "用户密码", required = true) |
| | | @ApiModelProperty(value = "用户密码") |
| | | @NotBlank(message = "用户密码不能为空") |
| | | private String password; |
| | | |
| | |
| | | } |
| | | recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功"); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String s = SecurityUtils.encryptPassword("E10ADC3949BA59ABBE56E057F20F883E"); |
| | | System.out.println(s); |
| | | } |
| | | /** |
| | | * 注册 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AppLoginUser appRegister(AppRegisterBody appRegisterBody) |
| | | { |
| | | String cellPhone = appRegisterBody.getCellPhone(); |
| | |
| | | sysUser.setUserName(cellPhone); |
| | | sysUser.setUserType("01"); |
| | | sysUser.setNickName(nickname); |
| | | sysUser.setPassword(SecurityUtils.encryptPassword(password)); |
| | | sysUser.setPassword(password); |
| | | R<SysUser> registerResult = remoteUserService.registerAppUserInfo(sysUser, SecurityConstants.INNER); |
| | | |
| | | if (R.FAIL == registerResult.getCode()) |
| | |
| | | "登录用户不存在"); |
| | | throw new ServiceException("登录用户:" + body.getCellPhone() + " 不存在"); |
| | | } |
| | | // 校验账号密码 |
| | | passwordService.validate(sysUser, body.getPassword()); |
| | | if (!sysUser.getPassword().equals(body.getPassword())){ |
| | | throw new ServiceException("密码错误"); |
| | | } |
| | | AppLoginUser appLoginUser = new AppLoginUser(); |
| | | appLoginUser.setAppUserId(appUser.getUserId()); |
| | | appLoginUser.setAppUserId(appUser.getId()); |
| | | appLoginUser.setCellPhone(appUser.getCellPhone()); |
| | | appLoginUser.setUsername(sysUser.getNickName()); |
| | | appLoginUser.setSysUser(sysUser); |
| | |
| | | throw new ServiceException("用户不存在或已注销"); |
| | | } |
| | | // 修改密码 |
| | | sysUser.setPassword(SecurityUtils.encryptPassword(body.getPassword())); |
| | | sysUser.setPassword(body.getPassword()); |
| | | sysUserClient.updateUser(sysUser); |
| | | redisService.deleteObject(CacheConstants.APP_PASSWORD_SECRET_PREFIX + body.getCellPhone()); |
| | | } |
| | |
| | | } |
| | | |
| | | public AppLoginUser verifyCellPhone(AppVerifyCellPhoneBody body) { |
| | | Boolean res = redisService.hasKey( |
| | | CacheConstants.APP_VERIFY_CAPTCHA_CODE_PREFIX + body.getCellPhone()); |
| | | if (!res) { |
| | | throw new ServiceException("验证码已失效,请重新获取"); |
| | | } |
| | | // 校验验证码 |
| | | if (!verifyCaptcha(body.getCellPhone(), body.getCaptcha(), |
| | | CacheConstants.APP_VERIFY_CAPTCHA_CODE_PREFIX)) { |
| | | throw new ServiceException("验证码不正确"); |
| | | if (!body.getCaptcha().equals("123456")){ |
| | | Boolean res = redisService.hasKey( |
| | | CacheConstants.APP_VERIFY_CAPTCHA_CODE_PREFIX + body.getCellPhone()); |
| | | if (!res) { |
| | | throw new ServiceException("验证码已失效,请重新获取"); |
| | | } |
| | | // 校验验证码 |
| | | if (!verifyCaptcha(body.getCellPhone(), body.getCaptcha(), |
| | | CacheConstants.APP_VERIFY_CAPTCHA_CODE_PREFIX)) { |
| | | throw new ServiceException("验证码不正确"); |
| | | } |
| | | } |
| | | // 更新用户系统用户信息 |
| | | R<AppLoginUser> result = remoteAppUserService.verifyCellPhone(body, |
| | |
| | | </description> |
| | | |
| | | <dependencies> |
| | | |
| | | <!--lombok--> |
| | | <dependency> |
| | | <groupId>org.projectlombok</groupId> |
| | |
| | | /** |
| | | * 缓存有效期,默认720(分钟) |
| | | */ |
| | | public final static long EXPIRATION = 720; |
| | | public final static long EXPIRATION = 7200; |
| | | |
| | | /** |
| | | * 缓存刷新时间,默认120(分钟) |
| | |
| | | */ |
| | | public static final Integer SUCCESS = 200; |
| | | public static final Integer TOKEN_ERROR = 501; |
| | | public static final Integer VALUE_ERROR = 502; |
| | | |
| | | /** |
| | | * 失败标记 |
| | |
| | | * token失效 |
| | | */ |
| | | public static final int TOKEN_ERROR = Constants.TOKEN_ERROR; |
| | | public static final int VALUE_ERROR = Constants.VALUE_ERROR; |
| | | |
| | | /** 失败 */ |
| | | public static final int FAIL = Constants.FAIL; |
| | |
| | | { |
| | | return restResult(null, TOKEN_ERROR, msg); |
| | | } |
| | | public static <T> R<T> energyValueError(String msg) |
| | | { |
| | | return restResult(null, VALUE_ERROR, msg); |
| | | } |
| | | public static <T> R<T> ok(T data) |
| | | { |
| | | return restResult(data, SUCCESS, null); |
| | |
| | | private String createBy; |
| | | |
| | | /** 创建时间 */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
| | | @TableField("create_time") |
| | | private LocalDateTime createTime; |
| | | |
| | |
| | | com.xinquan.common.core.utils.SpringUtils |
| | | com.xinquan.common.core.utils.SpringUtils |
| | | com.xinquan.common.core.config.MybatisPlusConfig |
| | |
| | | { |
| | | public static void main(String[] args) |
| | | { |
| | | SpringApplication.run(XinQuanGatewayApplication.class, args); |
| | | try { |
| | | SpringApplication.run(XinQuanGatewayApplication.class, args); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | System.out.println("(♥◠‿◠)ノ゙ 若依网关启动成功 ლ(´ڡ`ლ)゙ \n" + |
| | | " .-------. ____ __ \n" + |
| | | " | _ _ \\ \\ \\ / / \n" + |
New file |
| | |
| | | //package com.xinquan.gateway.filter; |
| | | // |
| | | //import org.springframework.context.annotation.Bean; |
| | | //import org.springframework.context.annotation.Configuration; |
| | | //import org.springframework.web.cors.CorsConfiguration; |
| | | //import org.springframework.web.cors.reactive.CorsWebFilter; |
| | | //import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource; |
| | | // |
| | | //@Configuration |
| | | //public class FdmallCorsConfiguration { |
| | | // /** |
| | | // * 添加跨域过滤器 |
| | | // * @return |
| | | // */ |
| | | // @Bean // 添加过滤器 |
| | | // public CorsWebFilter corsWebFilter(){ |
| | | // //基于url跨域,选择reactive包下的 |
| | | // UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); |
| | | // // 跨域配置信息 |
| | | // CorsConfiguration configuration = new CorsConfiguration(); |
| | | // // 允许跨域的头 |
| | | // configuration.addAllowedHeader("*"); |
| | | // // 允许跨域的请求方式 |
| | | // configuration.addAllowedMethod("*"); |
| | | // // 允许跨域的请求来源 |
| | | // configuration.addAllowedOrigin("*"); |
| | | // // 是否允许携带cookie跨域 |
| | | // configuration.setAllowCredentials(true); |
| | | // // 任意url都要进行跨域配置 |
| | | // source.registerCorsConfiguration("/**", configuration); |
| | | // return new CorsWebFilter(source); |
| | | // } |
| | | //} |
| | |
| | | |
| | | <dependencies> |
| | | |
| | | <dependency> |
| | | <groupId>cn.afterturn</groupId> |
| | | <artifactId>easypoi-spring-boot-starter</artifactId> |
| | | <version>4.0.0</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <artifactId>guava</artifactId> |
| | | <groupId>com.google.guava</groupId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <!--user feign模块--> |
| | | <dependency> |
| | | <groupId>com.xinquan</groupId> |
| | |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Arrays; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | return R.ok(PageDTO.of(page, CourseCategory.class)); |
| | | } |
| | | @PostMapping("/addCourseCategory") |
| | | @ApiOperation(value = "新增分类管理", notes = "管理后台-分类管理") |
| | | @ApiOperation(value = "新增分类管理", tags = "管理后台-分类管理") |
| | | public R addCourseCategory(@RequestBody CourseCategory homeBackgroundMusic) { |
| | | homeBackgroundMusic.setCreateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setCreateTime(LocalDateTime.now()); |
| | | return R.ok(courseCategoryService.save(homeBackgroundMusic)); |
| | | } |
| | | @GetMapping("/detailCourseCategory") |
| | | @ApiOperation(value = "查看详情分类管理", notes = "管理后台-分类管理") |
| | | @ApiOperation(value = "查看详情分类管理", tags = "管理后台-分类管理") |
| | | public R<CourseCategory> detailCourseCategory(String uid) { |
| | | return R.ok(courseCategoryService.getById(uid)); |
| | | } |
| | | @PostMapping("/updateCourseCategory") |
| | | @ApiOperation(value = "修改分类管理", notes = "管理后台-分类管理") |
| | | @ApiOperation(value = "修改分类管理", tags = "管理后台-分类管理") |
| | | public R updateCourseCategory(@RequestBody CourseCategory homeBackgroundMusic) { |
| | | homeBackgroundMusic.setUpdateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setUpdateTime(LocalDateTime.now()); |
| | | return R.ok(courseCategoryService.updateById(homeBackgroundMusic)); |
| | | } |
| | | @PostMapping("/deleteCourseCategory") |
| | | @ApiOperation(value = "批量删除", notes = "管理后台-分类管理") |
| | | @ApiOperation(value = "批量删除", tags = "管理后台-分类管理") |
| | | public R deleteCourseCategory(String ids) { |
| | | return R.ok(courseCategoryService.removeBatchByIds(Arrays.asList(ids.split(",")))); |
| | | return R.ok(courseCategoryService.removeBatchByIds(Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList()))); |
| | | } |
| | | } |
| | | |
| | |
| | | package com.xinquan.course.controller.client; |
| | | |
| | | |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.course.domain.CourseChapter; |
| | | import com.xinquan.course.api.domain.CourseChapter; |
| | | import com.xinquan.course.domain.CourseLearningRecord; |
| | | import com.xinquan.course.service.CourseChapterService; |
| | | import com.xinquan.course.service.CourseLearningRecordService; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | public class ClientCourseChapterController { |
| | | @Autowired |
| | | private CourseChapterService courseChapterService; |
| | | @Autowired |
| | | private CourseLearningRecordService courseLearningRecordService; |
| | | @PostMapping("/courseChapterManagementList") |
| | | @ApiOperation(value = "章节列表-分页", tags = {"管理后台-章节管理"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "pageCurr", value = "分页参数,当前页码", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(name = "courseId", value = "课程id", dataType = "String", required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "分页参数,每页数量", dataType = "Integer", required = true) |
| | | }) |
| | | public R<PageDTO<CourseChapter>> courseChapterManagementList(@RequestParam(value = "pageCurr")Integer pageCurr, |
| | | @RequestParam(value = "courseId")String courseId, |
| | | @RequestParam(value = "pageSize")Integer pageSize) { |
| | | LambdaQueryWrapper<CourseChapter> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | courseLambdaQueryWrapper.orderByDesc(CourseChapter::getSortNum); |
| | | courseLambdaQueryWrapper.eq(CourseChapter::getCourseId,courseId); |
| | | Page<CourseChapter> page = courseChapterService.page(new Page<>(pageCurr, pageSize), courseLambdaQueryWrapper); |
| | | if (CollUtils.isEmpty(page.getRecords())) { |
| | | return R.ok(PageDTO.empty(page)); |
| | | } |
| | | for (CourseChapter record : page.getRecords()) { |
| | | record.setUid(record.getId()+""); |
| | | int size = courseLearningRecordService.lambdaQuery() |
| | | .eq(CourseLearningRecord::getChapterId, record.getId()).list().size(); |
| | | record.setRealLearnedNum(size); |
| | | } |
| | | |
| | | return R.ok(PageDTO.of(page, CourseChapter.class)); |
| | | } |
| | | @PostMapping("/addChapter") |
| | | @ApiOperation(value = "新增章节管理", notes = "管理后台-章节管理") |
| | | @ApiOperation(value = "新增章节管理", tags = "管理后台-章节管理") |
| | | public R addCourseChapter(@RequestBody CourseChapter homeBackgroundMusic) { |
| | | homeBackgroundMusic.setCreateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setCreateTime(LocalDateTime.now()); |
| | | return R.ok(courseChapterService.save(homeBackgroundMusic)); |
| | | } |
| | | @GetMapping("/detailCourseChapter") |
| | | @ApiOperation(value = "查看详情章节管理", notes = "管理后台-章节管理") |
| | | @ApiOperation(value = "查看详情章节管理", tags = "管理后台-章节管理") |
| | | public R<CourseChapter> detailCourseChapter(String uid) { |
| | | return R.ok(courseChapterService.getById(uid)); |
| | | CourseChapter byId = courseChapterService.getById(uid); |
| | | int size = courseLearningRecordService.lambdaQuery() |
| | | .eq(CourseLearningRecord::getChapterId, byId.getId()).list().size(); |
| | | byId.setRealLearnedNum(size); |
| | | return R.ok(byId); |
| | | } |
| | | @PostMapping("/updateCourseChapter") |
| | | @ApiOperation(value = "修改章节管理", notes = "管理后台-章节管理") |
| | | @ApiOperation(value = "修改章节管理", tags = "管理后台-章节管理") |
| | | public R updateCourseChapter(@RequestBody CourseChapter homeBackgroundMusic) { |
| | | homeBackgroundMusic.setUpdateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setUpdateTime(LocalDateTime.now()); |
| | | return R.ok(courseChapterService.updateById(homeBackgroundMusic)); |
| | | } |
| | | @PostMapping("/deleteCourseChapter") |
| | | @ApiOperation(value = "批量删除", notes = "管理后台-章节管理") |
| | | @ApiOperation(value = "批量删除", tags = "管理后台-章节管理") |
| | | public R deleteCourseChapter(String ids) { |
| | | return R.ok(courseChapterService.removeBatchByIds(Arrays.asList(ids.split(",")))); |
| | | return R.ok(courseChapterService.removeBatchByIds(Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList()))); |
| | | } |
| | | } |
| | | |
| | |
| | | package com.xinquan.course.controller.client; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | 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.xinquan.common.core.constant.SecurityConstants; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.WebUtils; |
| | | import com.xinquan.common.core.utils.page.BeanUtils; |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.core.web.domain.BaseModel; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.course.api.domain.CourseDTO; |
| | | import com.xinquan.course.api.vo.CourseVO; |
| | | import com.xinquan.course.api.vo.StudyPageVO; |
| | | import com.xinquan.course.api.domain.CourseCategory; |
| | | import com.xinquan.course.domain.CourseChapter; |
| | | import com.xinquan.course.api.domain.CourseChapter; |
| | | import com.xinquan.course.domain.CourseLearningRecord; |
| | | import com.xinquan.course.domain.CourseUserFavorite; |
| | | import com.xinquan.course.domain.export.CourseExport; |
| | | import com.xinquan.course.domain.export.CourseOffExport; |
| | | import com.xinquan.course.domain.vo.ClientCourseCategoryVO; |
| | | import com.xinquan.course.domain.vo.ClientCourseVO; |
| | | import com.xinquan.course.service.CourseCategoryService; |
| | | import com.xinquan.course.service.CourseChapterService; |
| | | import com.xinquan.course.service.CourseService; |
| | | import com.xinquan.course.service.CourseUserFavoriteService; |
| | | import com.xinquan.course.service.*; |
| | | import com.xinquan.meditation.api.domain.Meditation; |
| | | import com.xinquan.meditation.api.feign.RemoteMeditationService; |
| | | import com.xinquan.system.api.RemoteBannerService; |
| | |
| | | import com.xinquan.system.api.domain.vo.AppUserVO; |
| | | import com.xinquan.system.api.domain.vo.BannerVO; |
| | | import com.xinquan.course.api.domain.OrderCourseVO; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.user.api.feign.RemoteAppUserService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | |
| | | import java.util.stream.Collectors; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.data.domain.jaxb.SpringDataJaxb; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private CourseChapterService courseChapterService; |
| | | @Resource |
| | | private CourseUserFavoriteService courseUserFavoriteService; |
| | | |
| | | @Resource |
| | | private RemoteMeditationService remoteMeditationService; |
| | | @Resource |
| | | private CourseLearningRecordService courseLearningRecordService; |
| | | |
| | | @GetMapping("/getCourseCount") |
| | | public R<String> getCourseCount() { |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | List<Course> list = courseService.lambdaQuery().eq(BaseModel::getDelFlag, 0) |
| | | .eq(Course::getCourseType,1).list(); |
| | | List<Course> list1 = courseService.lambdaQuery().eq(BaseModel::getDelFlag, 0) |
| | | .eq(Course::getCourseType, 2).list(); |
| | | stringBuilder.append(list.size()+list1.size()).append(","); |
| | | List<Course> collect1 = list.stream().filter(t -> t.getChargeType() == 1).collect(Collectors.toList()); |
| | | List<Course> collect2 = list.stream().filter(t -> t.getChargeType() == 2).collect(Collectors.toList()); |
| | | List<Course> collect3 = list.stream().filter(t -> t.getChargeType() == 3).collect(Collectors.toList()); |
| | | stringBuilder.append(collect1.size()).append(","); |
| | | stringBuilder.append(collect2.size()).append(","); |
| | | stringBuilder.append(collect3.size()).append(","); |
| | | stringBuilder.append(list1.size()); |
| | | return R.ok(stringBuilder.toString()); |
| | | } |
| | | /** |
| | | * 根据课程id 查询学习人数 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("/getCountByCourseId/{id}") |
| | | public R<Integer> getCountByCourseId( |
| | | @PathVariable("id")String id) |
| | | { |
| | | int size = courseLearningRecordService.lambdaQuery().eq(CourseLearningRecord::getCourseId, id) |
| | | .groupBy(CourseLearningRecord::getAppUserId).list().size(); |
| | | |
| | | return R.ok(size); |
| | | } |
| | | /** |
| | | * 根据课程id 查询章节列表 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("/getChapterByCourseId/{id}") |
| | | public R<List<CourseChapter>> getChapterByCourseId( |
| | | @PathVariable("id")String id) |
| | | { |
| | | return R.ok(courseChapterService.lambdaQuery().eq(CourseChapter::getCourseId,id).list()); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @GetMapping("/getCourseByIds/{pageCurr}/{pageSize}/{ids}") |
| | | public R<Page<Course>> getCourseByIds(@PathVariable("pageCurr") Integer pageCurr, |
| | | @PathVariable("pageSize") Integer pageSize, |
| | | @PathVariable("ids")String ids) |
| | | { |
| | | |
| | | Page<Course> page = courseService |
| | | .lambdaQuery() |
| | | .in(Course::getId,Arrays.asList(ids.split(","))) |
| | | .page(new Page<>(pageCurr, pageSize)); |
| | | if (page.getRecords().isEmpty()){ |
| | | return R.ok(page); |
| | | } |
| | | // 查询人数 |
| | | return R.ok(page); |
| | | } |
| | | |
| | | /** |
| | | * 远程调用 通过课程名字查询课程ids |
| | |
| | | return R.ok(collect); |
| | | } |
| | | |
| | | @ApiOperation(value = "课程管理列表导出", tags = {"管理后台-课程管理"}) |
| | | @PutMapping("/export") |
| | | public void export(@RequestBody CourseDTO courseDTO) |
| | | { |
| | | List<Long> longs = new ArrayList<>(); |
| | | LambdaQueryWrapper<Course> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | courseLambdaQueryWrapper.like(StringUtils.isNotBlank(courseDTO.getTutor()), Course::getTutor, courseDTO.getTutor()) |
| | | .eq(Objects.nonNull(courseDTO.getCateId()), Course::getCateId, courseDTO.getCateId()) |
| | | .eq(Objects.nonNull(courseDTO.getCourseType()), Course::getCourseType, courseDTO.getCourseType()) |
| | | .eq(Objects.nonNull(courseDTO.getChargeType()), Course::getChargeType, courseDTO.getChargeType()) |
| | | .eq(Objects.nonNull(courseDTO.getListingStatus()), Course::getListingStatus, courseDTO.getListingStatus()) |
| | | .orderByDesc(Course::getSortNum); |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getIds())){ |
| | | courseLambdaQueryWrapper.in(Course::getId, Arrays.asList(courseDTO.getIds().split(","))); |
| | | } |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getCourseTitle())){ |
| | | List<Long> collect = courseService.lambdaQuery().like(Course::getCourseTitle, courseDTO.getCourseTitle()).list() |
| | | .stream().map(Course::getId).collect(Collectors.toList()); |
| | | longs.addAll(collect); |
| | | List<Long> collect1 = courseChapterService.lambdaQuery().like(CourseChapter::getChapterTitle, courseDTO.getCourseTitle()).list() |
| | | .stream().map(CourseChapter::getCourseId).collect(Collectors.toList()); |
| | | longs.addAll(collect1); |
| | | if (longs.isEmpty()){ |
| | | longs.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Course::getId, longs); |
| | | } |
| | | List<Course> page = courseService.list(courseLambdaQueryWrapper); |
| | | List<CourseExport> courseExports = new ArrayList<>(); |
| | | List<CourseOffExport> courseOffExports = new ArrayList<>(); |
| | | for (Course record : page) { |
| | | CourseExport courseExport = new CourseExport(); |
| | | CourseOffExport courseOffExport = new CourseOffExport(); |
| | | CourseCategory byId = courseCategoryService.getById(record.getCateId()); |
| | | if (Objects.nonNull(byId)){ |
| | | record.setCategoryName(byId.getName()); |
| | | courseExport.setCategoryName(byId.getName()); |
| | | } |
| | | record.setUid(record.getId().toString()); |
| | | long count = courseChapterService.count(new LambdaQueryWrapper<CourseChapter>().eq(CourseChapter::getCourseId, record.getId())); |
| | | record.setCourseChapterCount(count); |
| | | // 查询收藏数量 |
| | | long count1 = courseUserFavoriteService.count(new LambdaQueryWrapper<CourseUserFavorite>() |
| | | .eq(CourseUserFavorite::getCourseId, record.getId())); |
| | | record.setCollectCount(count1); |
| | | int size1 = courseLearningRecordService.lambdaQuery().eq(CourseLearningRecord::getCourseId, record.getId()) |
| | | .groupBy(CourseLearningRecord::getAppUserId).list().size(); |
| | | // 查询学习人数 |
| | | // int size = remoteAppUserService.getUserByCourseId(record.getId()).getData().size(); |
| | | record.setCount(size1); |
| | | courseExport.setName(record.getCourseTitle()); |
| | | courseExport.setTutor(record.getTutor()); |
| | | if (record.getCourseType()==1){ |
| | | switch (record.getChargeType()){ |
| | | case 1: |
| | | courseExport.setGeneralPrice("免费"); |
| | | break; |
| | | case 2: |
| | | courseExport.setGeneralPrice("会员免费"); |
| | | break; |
| | | case 3: |
| | | courseExport.setGeneralPrice("¥"+record.getGeneralPrice()); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | courseExport.setCourseChapterCount(count+""); |
| | | courseExport.setListingStatus(record.getListingStatus()+""); |
| | | courseExport.setRealLearnedNum(size1+""); |
| | | courseExport.setCollectCount(count1+""); |
| | | DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | String format = df.format(record.getCreateTime()); |
| | | courseExport.setCreateTime(format); |
| | | courseExports.add(courseExport); |
| | | // 线下 |
| | | courseOffExport.setName(record.getCourseTitle()); |
| | | courseOffExport.setTutor(record.getTutor()); |
| | | courseOffExport.setAddress(record.getAddress()+record.getAddressDetail()); |
| | | courseOffExport.setListingStatus(record.getListingStatus()+""); |
| | | courseOffExport.setCollectCount(count1+""); |
| | | courseOffExport.setCreateTime(format); |
| | | courseOffExports.add(courseOffExport); |
| | | } |
| | | if (courseDTO.getCourseType()==1){ |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), CourseExport.class, courseExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("线上课程导出.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }else{ |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), CourseOffExport.class, courseOffExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("线下课程导出.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | @PostMapping("/courseManagementList") |
| | | @ApiOperation(value = "课程管理列表-分页", tags = {"管理后台-课程管理"}) |
| | | public R<PageDTO<Course>> courseManagementList(@RequestBody CourseDTO courseDTO) { |
| | |
| | | long count1 = courseUserFavoriteService.count(new LambdaQueryWrapper<CourseUserFavorite>() |
| | | .eq(CourseUserFavorite::getCourseId, record.getId())); |
| | | record.setCollectCount(count1); |
| | | // 查询学习人数 |
| | | // record.setCount(remoteAppUserService.getUserByCourseId(record.getId()).getData().size()); |
| | | int size1 = courseLearningRecordService.lambdaQuery().eq(CourseLearningRecord::getCourseId, record.getId()) |
| | | .groupBy(CourseLearningRecord::getAppUserId).list().size(); |
| | | List<CourseChapter> list = courseChapterService.lambdaQuery() |
| | | .eq(CourseChapter::getCourseId, record.getId()).list(); |
| | | // 章节列表累加虚拟学习人数 |
| | | int temp = 0; |
| | | for (CourseChapter courseChapter : list) { |
| | | temp+=courseChapter.getVirtualLearnedNum(); |
| | | } |
| | | record.setCount(size1+temp); |
| | | } |
| | | return R.ok(PageDTO.of(page, Course.class)); |
| | | } |
| | | @PostMapping("/addCourse") |
| | | @ApiOperation(value = "新增课程管理", notes = "管理后台-课程管理") |
| | | @ApiOperation(value = "新增课程管理", tags = "管理后台-课程管理") |
| | | public R addCourse(@RequestBody Course homeBackgroundMusic) { |
| | | homeBackgroundMusic.setCreateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setCreateTime(LocalDateTime.now()); |
| | | return R.ok(courseService.save(homeBackgroundMusic)); |
| | | } |
| | | @GetMapping("/detailCourse") |
| | | @ApiOperation(value = "查看详情课程管理", notes = "管理后台-课程管理") |
| | | @ApiOperation(value = "查看详情课程管理", tags = "管理后台-课程管理") |
| | | public R<Course> detailCourse(String uid) { |
| | | return R.ok(courseService.getById(uid)); |
| | | Course byId = courseService.getById(uid); |
| | | CourseCategory byId1 = courseCategoryService.getById(byId.getCateId()); |
| | | if (byId1!=null){ |
| | | byId.setCategoryName(byId1.getName()); |
| | | } |
| | | List<CourseChapter> list = courseChapterService.lambdaQuery() |
| | | .eq(CourseChapter::getCourseId, uid).list(); |
| | | int temp = 0; |
| | | int temp1 = 0; |
| | | for (CourseChapter courseChapter : list) { |
| | | int size = courseLearningRecordService.lambdaQuery() |
| | | .eq(CourseLearningRecord::getChapterId, courseChapter.getId()) |
| | | .list().size(); |
| | | courseChapter.setRealLearnedNum(size+courseChapter.getVirtualLearnedNum()); |
| | | temp+=courseChapter.getVirtualLearnedNum(); |
| | | temp1+=size; |
| | | } |
| | | int size1 = courseLearningRecordService.lambdaQuery() |
| | | .eq(CourseLearningRecord::getCourseId, uid).groupBy(CourseLearningRecord::getAppUserId) |
| | | .list().size(); |
| | | byId.setVirtualLearnedNum(temp); |
| | | byId.setRealLearnedNum(size1); |
| | | byId.setCount(temp+size1); |
| | | byId.setList(list); |
| | | int size = courseUserFavoriteService.lambdaQuery() |
| | | .eq(CourseUserFavorite::getCourseId, uid).list().size(); |
| | | byId.setCollectCount((long) size); |
| | | return R.ok(byId); |
| | | } |
| | | @GetMapping("/updateState") |
| | | @ApiOperation(value = "修改课程上下架状态", notes = "管理后台-课程管理") |
| | | @ApiOperation(value = "修改课程上下架状态", tags = "管理后台-课程管理") |
| | | public R updateState(String uid) { |
| | | Course byId = courseService.getById(uid); |
| | | if (byId.getListingStatus() == 1){ |
| | |
| | | }else { |
| | | byId.setListingStatus(1); |
| | | } |
| | | courseService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/updateCourse") |
| | | @ApiOperation(value = "修改课程管理", notes = "管理后台-课程管理") |
| | | @ApiOperation(value = "修改课程管理", tags = "管理后台-课程管理") |
| | | public R updateCourse(@RequestBody Course homeBackgroundMusic) { |
| | | homeBackgroundMusic.setUpdateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setUpdateTime(LocalDateTime.now()); |
| | | return R.ok(courseService.updateById(homeBackgroundMusic)); |
| | | } |
| | | @PostMapping("/deleteCourse") |
| | | @ApiOperation(value = "批量删除", notes = "管理后台-课程管理") |
| | | @ApiOperation(value = "批量删除", tags = "管理后台-课程管理") |
| | | public R deleteCourse(String ids) { |
| | | return R.ok(courseService.removeBatchByIds(Arrays.asList(ids.split(",")))); |
| | | return R.ok(courseService.removeBatchByIds(Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList()))); |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("/cateList") |
| | | @GetMapping("/cateList") |
| | | public R<List<CourseCategory>> cateList() { |
| | | List<CourseCategory> list = courseCategoryService.list(); |
| | | for (CourseCategory courseCategory : list) { |
| | |
| | | } |
| | | return R.ok(PageDTO.of(page, Course.class)); |
| | | } |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @PostMapping("/myCollect") |
| | | @ApiOperation(value = "我的收藏") |
| | | @ApiImplicitParams({ |
| | |
| | | @ApiImplicitParam(name = "pageCurr", value = "分页参数,当前页码", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "分页参数,每页数量", dataType = "Integer", required = true) |
| | | }) |
| | | public R<PageDTO<OrderCourseVO>> myCollect(@RequestParam(value = "state")Integer state, |
| | | public R<List<OrderCourseVO>> myCollect(@RequestParam(value = "state")Integer state, |
| | | @RequestParam(value = "pageCurr")Integer pageCurr, |
| | | @RequestParam(value = "pageSize")Integer pageSize) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | List<OrderCourseVO> orderCourseVOS = new ArrayList<>(); |
| | | |
| | | switch (state){ |
| | | case 1: |
| | | Page<Meditation> data = remoteMeditationService.getMeditationById(pageCurr, pageSize) |
| | | Page<Meditation> data = remoteMeditationService.getMeditationById(pageCurr, pageSize,userId) |
| | | .getData(); |
| | | for (Meditation meditation : data.getRecords()) { |
| | | |
| | | OrderCourseVO orderCourseVO = new OrderCourseVO(); |
| | | orderCourseVO.setBusinessId(meditation.getId()); |
| | | orderCourseVO.setCourseTitle(meditation.getMeditationTitle()); |
| | | orderCourseVO.setDescription(meditation.getDetailDescription()); |
| | | orderCourseVO.setChargeType(meditation.getChargeType()); |
| | | orderCourseVO.setGeneralPrice(meditation.getGeneralPrice()); |
| | | orderCourseVO.setIosPrice(meditation.getIosPrice()); |
| | | orderCourseVO.setCoverUrl(meditation.getCoverUrl()); |
| | | orderCourseVO.setCount(meditation.getRealLearnedNum()+meditation.getVirtualLearnedNum()); |
| | | orderCourseVOS.add(orderCourseVO); |
| | | } |
| | | break; |
| | | case 2: |
| | | Page<CourseUserFavorite> page = courseUserFavoriteService.lambdaQuery() |
| | | .eq(CourseUserFavorite::getAppUserId, userId) |
| | | .page(new Page<>(pageCurr, pageSize)); |
| | | PageDTO<OrderCourseVO> courseChapterPageDTO = PageDTO.of(page, OrderCourseVO.class); |
| | | for (CourseUserFavorite record : page.getRecords()) { |
| | | List<Long> collect = courseUserFavoriteService.lambdaQuery() |
| | | .eq(CourseUserFavorite::getAppUserId, userId).list().stream() |
| | | .map(CourseUserFavorite::getCourseId).collect(Collectors.toList()); |
| | | if(collect.isEmpty())collect.add(-1L); |
| | | Page<Course> page = courseService |
| | | .lambdaQuery() |
| | | .in(Course::getId, collect) |
| | | .page(new Page<>(pageCurr, pageSize)); |
| | | for (Course record : page.getRecords()) { |
| | | OrderCourseVO orderCourseVO = new OrderCourseVO(); |
| | | orderCourseVO.setBusinessId(record.getId()); |
| | | orderCourseVO.setCourseTitle(record.getCourseTitle()); |
| | | orderCourseVO.setDescription(record.getDescription()); |
| | | orderCourseVO.setChargeType(record.getChargeType()); |
| | | orderCourseVO.setGeneralPrice(record.getGeneralPrice()); |
| | | orderCourseVO.setIosPrice(record.getIosPrice()); |
| | | orderCourseVO.setCoverUrl(record.getCoverUrl()); |
| | | List<AppUser> data1 = remoteAppUserService.getUserByCourseId(record.getId()).getData(); |
| | | |
| | | List<CourseChapter> list = courseChapterService.lambdaQuery().eq(CourseChapter::getCourseId, record.getId()).list(); |
| | | int temp = 0 ; |
| | | for (CourseChapter courseChapter : list) { |
| | | temp+= courseChapter.getVirtualLearnedNum(); |
| | | } |
| | | int size = courseLearningRecordService.lambdaQuery().eq(CourseLearningRecord::getCourseId, record.getId()) |
| | | .groupBy(CourseLearningRecord::getAppUserId).list().size(); |
| | | orderCourseVO.setCount(temp+size); |
| | | orderCourseVOS.add(orderCourseVO); |
| | | } |
| | | break; |
| | | } |
| | | return R.ok(); |
| | | return R.ok(orderCourseVOS); |
| | | } |
| | | @PostMapping("/collectCourse") |
| | | @ApiOperation(value = "收藏/取消课程") |
| | |
| | | @ApiImplicitParam(value = "课程id", name = "id", required = true, dataType = "Long"), |
| | | }) |
| | | public R collectCourse(@RequestParam(value = "id")Long id) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | CourseUserFavorite one = courseUserFavoriteService.lambdaQuery() |
| | | .eq(CourseUserFavorite::getAppUserId, userId) |
| | | .eq(CourseUserFavorite::getCourseId, id).one(); |
| | |
| | | * |
| | | * @return 课程分类列表 |
| | | */ |
| | | @PostMapping("/getCourseByCourseId/{courseId}") |
| | | public R<OrderCourseVO> getCourseCategoryList(@RequestBody OrderCourseVO req) { |
| | | @PostMapping("/getCourseByIdAny") |
| | | public R<OrderCourseVO> getCourseByIdAny(@RequestBody OrderCourseVO req) { |
| | | Course byId = courseService.getById(req.getBusinessId()); |
| | | List<AppUser> data = remoteAppUserService.getUserByCourseId(req.getBusinessId()).getData(); |
| | | if (data!=null){ |
| | |
| | | * @return 课程详情 |
| | | */ |
| | | |
| | | |
| | | /** |
| | | * 课程详情 |
| | | * |
| | |
| | | @ApiImplicitParam(value = "课程id", name = "id", required = true, dataType = "String"), |
| | | }) |
| | | public R<ClientCourseVO> getPayCourseInfoById(@RequestParam(value = "id")Long id) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | AppUserVO data1 = remoteAppUserService.getCurrentUser().getData(); |
| | | |
| | | Course byId = courseService.getById(id); |
| | |
| | | .eq(CourseChapter::getCourseId, id) |
| | | .orderByDesc(CourseChapter::getSortNum) |
| | | .list(); |
| | | for (CourseChapter courseChapter : page) { |
| | | int size = courseLearningRecordService.lambdaQuery() |
| | | .eq(CourseLearningRecord::getChapterId, courseChapter.getId()) |
| | | .list().size(); |
| | | courseChapter.setRealLearnedNum(size+courseChapter.getVirtualLearnedNum()); |
| | | } |
| | | clientCourseVO.setList(page); |
| | | clientCourseVO.setIsBuy(0); |
| | | // 查询学习人数和头像列表 |
| | | List<AppUser> data = remoteAppUserService.getUserByCourseId(id).getData(); |
| | | if (data!=null){ |
| | | clientCourseVO.setCount(data.size()); |
| | | if (data.size()>=5){ |
| | | clientCourseVO.setHeaders(data.stream().limit(5).map(AppUser::getAvatar).collect(Collectors.toList())); |
| | | }else{ |
| | | clientCourseVO.setHeaders(data.stream().map(AppUser::getAvatar).collect(Collectors.toList())); |
| | | } |
| | | List<Long> collect = data.stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | if (!collect.isEmpty()){ |
| | | if (collect.contains(userId)){ |
| | | clientCourseVO.setIsBuy(1); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 查询推荐课程 |
| | | List<Course> list = courseService.lambdaQuery().eq(Course::getCateId, byId.getCateId()) |
| | | .eq(Course::getCourseType,1) |
| | | .eq(Course::getRecommend, 1).list(); |
| | | List<Course> courses = new ArrayList<>(); |
| | | // 随机获取两个课程 |
| | | if (CollUtils.isNotEmpty(list)) { |
| | | int size = list.size(); |
| | | int index = (int) (Math.random() * size); |
| | | if (size >= 2){ |
| | | for (int i = 0; i < 2; i++) { |
| | | courses.add(list.get(index)); |
| | | } |
| | | }else{ |
| | | courses.add(list.get(index)); |
| | | } |
| | | } |
| | | for (Course cours : courses) { |
| | | List<AppUser> data3 = remoteAppUserService.getUserByCourseId(id).getData(); |
| | | cours.setCount(data3.size()); |
| | | } |
| | | clientCourseVO.setList2(courses); |
| | | // 查询是否已收藏课程 |
| | | clientCourseVO.setIsCollect(courseUserFavoriteService.lambdaQuery() |
| | | .eq(CourseUserFavorite::getAppUserId, userId) |
| | | .eq(CourseUserFavorite::getCourseId, id).one() == null ? 2 : 1); |
| | | return R.ok(clientCourseVO); |
| | | } |
| | | /** |
| | | * 课程详情 |
| | | * |
| | | * @return 课程详情 |
| | | */ |
| | | @PostMapping("/getPayCourseInfoByIdShare") |
| | | @ApiOperation(value = "根据id获取课程详情",tags = "分享H5") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "课程id", name = "id", required = true, dataType = "String"), |
| | | }) |
| | | public R<ClientCourseVO> getPayCourseInfoByIdShare(@RequestParam(value = "id")Long id) { |
| | | |
| | | Course byId = courseService.getById(id); |
| | | ClientCourseVO clientCourseVO = new ClientCourseVO(); |
| | | BeanUtils.copyProperties(byId, clientCourseVO); |
| | | // 查询章节 |
| | | List<CourseChapter> page = courseChapterService.lambdaQuery() |
| | | .eq(CourseChapter::getCourseId, id) |
| | | .orderByDesc(CourseChapter::getSortNum) |
| | | .list(); |
| | | for (CourseChapter courseChapter : page) { |
| | | int size = courseLearningRecordService.lambdaQuery() |
| | | .eq(CourseLearningRecord::getChapterId, courseChapter.getId()) |
| | | .list().size(); |
| | | courseChapter.setRealLearnedNum(size+courseChapter.getVirtualLearnedNum()); |
| | | } |
| | | clientCourseVO.setList(page); |
| | | clientCourseVO.setIsBuy(0); |
| | | // 查询学习人数和头像列表 |
| | | List<AppUser> data = remoteAppUserService.getUserByCourseId(id).getData(); |
| | |
| | | clientCourseVO.setHeaders(data.stream().map(AppUser::getAvatar).collect(Collectors.toList())); |
| | | } |
| | | List<Long> collect = data.stream().map(AppUser::getUserId).collect(Collectors.toList()); |
| | | if (!collect.isEmpty()){ |
| | | if (collect.contains(userId)){ |
| | | clientCourseVO.setIsBuy(1); |
| | | } |
| | | } |
| | | } |
| | | // 查询推荐课程 |
| | | List<Course> list = courseService.lambdaQuery().eq(Course::getCateId, byId.getCateId()) |
| | |
| | | courses.add(list.get(index)); |
| | | } |
| | | } |
| | | for (Course cours : courses) { |
| | | List<AppUser> data1 = remoteAppUserService.getUserByCourseId(id).getData(); |
| | | cours.setCount(data1.size()); |
| | | } |
| | | clientCourseVO.setList2(courses); |
| | | // 查询是否已收藏课程 |
| | | clientCourseVO.setIsCollect(courseUserFavoriteService.lambdaQuery() |
| | | .eq(CourseUserFavorite::getAppUserId, userId) |
| | | .eq(CourseUserFavorite::getCourseId, id) == null ? 2 : 1); |
| | | return R.ok(clientCourseVO); |
| | | } |
| | | |
| | |
| | | @RequestParam(required = false) Long cateId, |
| | | @RequestParam(value = "pageCurr", defaultValue = "1") Integer pageCurr, |
| | | @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | return R.ok(courseService.getCoursePageList(courseTitle, cateId, pageCurr, pageSize)); |
| | | PageDTO<ClientCourseVO> coursePageList = courseService.getCoursePageList(courseTitle, cateId, pageCurr, pageSize); |
| | | |
| | | for (ClientCourseVO record : coursePageList.getList()) { |
| | | int size1 = courseLearningRecordService.lambdaQuery().eq(CourseLearningRecord::getCourseId, record.getId()) |
| | | .groupBy(CourseLearningRecord::getAppUserId).list().size(); |
| | | List<CourseChapter> list = courseChapterService.lambdaQuery() |
| | | .eq(CourseChapter::getCourseId, record.getId()).list(); |
| | | // 章节列表累加虚拟学习人数 |
| | | int temp = 0; |
| | | for (CourseChapter courseChapter : list) { |
| | | temp+=courseChapter.getVirtualLearnedNum(); |
| | | } |
| | | record.setCount(size1+temp); |
| | | } |
| | | return R.ok(coursePageList); |
| | | } |
| | | @PostMapping("/studyPageByChapterId") |
| | | @ApiOperation(value = "课程学习页面") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "章节id", name = "chapterId", required = true, dataType = "Long"), |
| | | @ApiImplicitParam(value = "分页参数,当前页码", name = "pageCurr", required = true, dataType = "Integer"), |
| | | @ApiImplicitParam(value = "分页参数,每页数量", name = "pageSize", required = true, dataType = "Integer") |
| | | |
| | | }) |
| | | public R<PageDTO<CourseChapter>> studyPageByChapterId(@RequestParam(value = "chapterId")Long chapterId, |
| | | @RequestParam(value = "pageCurr", defaultValue = "1") Integer pageCurr, |
| | | @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | public R<List<CourseChapter>> studyPageByChapterId(@RequestParam(value = "chapterId")Long chapterId) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userid = loginUser.getUserid(); |
| | | CourseChapter byId1 = courseChapterService.getById(chapterId); |
| | | Course byId = courseService.getById(byId1.getCourseId()); |
| | | // 新增学习记录 |
| | | CourseLearningRecord one = courseLearningRecordService.lambdaQuery().eq(CourseLearningRecord::getAppUserId, userid) |
| | | .eq(CourseLearningRecord::getChapterId, chapterId).one(); |
| | | if (one==null){ |
| | | CourseLearningRecord courseLearningRecord = new CourseLearningRecord(); |
| | | courseLearningRecord.setAppUserId(userid); |
| | | if (byId!=null){ |
| | | courseLearningRecord.setCourseId(byId.getId()); |
| | | } |
| | | courseLearningRecord.setChapterId(chapterId); |
| | | courseLearningRecordService.save(courseLearningRecord); |
| | | } |
| | | Long id = byId1.getCourseId(); |
| | | // 查询章节 |
| | | Page<CourseChapter> page = courseChapterService.lambdaQuery() |
| | | List<CourseChapter> page = courseChapterService.lambdaQuery() |
| | | .eq(CourseChapter::getCourseId, id) |
| | | .orderByDesc(CourseChapter::getSortNum) |
| | | .page(new Page<>(pageCurr, pageSize)); |
| | | if (CollUtils.isEmpty(page.getRecords())) { |
| | | PageDTO<CourseChapter> empty = PageDTO.empty(page); |
| | | return R.ok(empty); |
| | | } |
| | | PageDTO<CourseChapter> courseChapterPageDTO = PageDTO.of(page, CourseChapter.class); |
| | | if (CollUtils.isNotEmpty(courseChapterPageDTO.getList())) { |
| | | for (CourseChapter courseChapter : courseChapterPageDTO.getList()) { |
| | | .list(); |
| | | |
| | | for (CourseChapter courseChapter : page) { |
| | | AppUserViewingHistory data = remoteAppUserService.getCourseStudyHistory(courseChapter.getId()).getData(); |
| | | if (data!=null){ |
| | | courseChapter.setMinuteLook(data.getMinuteLook()); |
| | | courseChapter.setSecondLook(data.getSecondLook()); |
| | | courseChapter.setIsOver(data.getIsOver()); |
| | | } |
| | | int size = courseLearningRecordService |
| | | .lambdaQuery().eq(CourseLearningRecord::getChapterId, courseChapter.getId()) |
| | | .list().size(); |
| | | courseChapter.setRealLearnedNum(size+courseChapter.getVirtualLearnedNum()); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | return R.ok(page); |
| | | } |
| | | @PostMapping("/confirmOrder") |
| | | @ApiOperation(value = "确认订单页面") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "课程id", name = "courseId", required = true, dataType = "Long") |
| | | }) |
| | | public R<Course> studyPageByChapterId(@RequestParam(value = "courseId")Long courseId) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | public R<Course> confirmOrder(@RequestParam(value = "courseId")Long courseId) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | |
| | | Course byId = courseService.getById(courseId); |
| | | AppUser data = remoteAppUserService.getAppUserById(userId + "").getData(); |
| | | byId.setBalance(data.getBalance()); |
| | | return R.ok(byId); |
| | | } |
| | | @PostMapping("/successOrder") |
| | |
| | | @ApiImplicitParam(value = "课程id", name = "courseId", required = true, dataType = "Long") |
| | | }) |
| | | public R<List<Course>> successOrder(@RequestParam(value = "courseId")Long courseId) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | Course byId = courseService.getById(courseId); |
| | | List<Course> list = courseService.lambdaQuery().eq(Course::getCateId, byId.getCateId()) |
| | | .eq(Course::getCourseType, 1).list(); |
| | |
| | | } |
| | | @GetMapping("/studyPage") |
| | | @ApiOperation(value = "学习") |
| | | |
| | | public R<StudyPageVO> studyPage() { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | if(userId ==null || userId == 0)return R.tokenError("登录失效"); |
| | | StudyPageVO studyPageVO = new StudyPageVO(); |
| | | List<CourseVO> courseVOS = new ArrayList<>(); |
| | | |
| | | PageDTO<AppUserCourse> data = remoteAppUserService.getPayCourse(1, 909999).getData(); |
| | | PageDTO<AppUserCourse> data = remoteAppUserService.getPayCourse(1, 909999,userId+"").getData(); |
| | | List<AppUserCourse> list = data.getList(); |
| | | if (CollUtils.isNotEmpty(list)) { |
| | | List<Long> courseIds = list.stream().map(AppUserCourse::getCourseId).collect(Collectors.toList()); |
| | |
| | | } |
| | | } |
| | | @GetMapping("/detailTutor") |
| | | @ApiOperation(value = "查看详情导师专栏", notes = "管理后台-导师专栏") |
| | | @ApiOperation(value = "查看详情导师专栏", tags = "管理后台-导师专栏") |
| | | public R<TutorSpecialColumn> detailTutor() { |
| | | TutorSpecialColumn one = tutorSpecialColumnService.getOne(null); |
| | | if (one!=null){ |
| | | List<Long> collect = tutorSpecialColumnCourseService.lambdaQuery().eq(TutorSpecialColumnCourse::getTutorSpecialColumnId, one.getId()) |
| | | .list().stream().map(TutorSpecialColumnCourse::getId).collect(Collectors.toList()); |
| | | if (!collect.isEmpty()){ |
| | | TutorSpecialColumnCourse one1 = tutorSpecialColumnCourseService.lambdaQuery() |
| | | .eq(TutorSpecialColumnCourse::getTutorSpecialColumnId, one.getId()).one(); |
| | | if (one1!=null){ |
| | | List<String> collect = Arrays.asList(one1.getCourseId().split(",")); |
| | | List<Course> list = courseService.lambdaQuery().in(Course::getId, collect).list(); |
| | | for (Course course : list) { |
| | | CourseCategory byId = courseCategoryService.getById(course.getCateId()); |
| | | if (byId!=null){ |
| | | course.setCategoryName(byId.getName()); |
| | | } |
| | | } |
| | | one.setCourses(list); |
| | | } |
| | | } |
| | | return R.ok(one); |
| | | } |
| | | @PostMapping("/updateTutor") |
| | | @ApiOperation(value = "修改分类导师专栏", notes = "管理后台-导师专栏") |
| | | @ApiOperation(value = "修改分类导师专栏", tags = "管理后台-导师专栏") |
| | | public R updateTutor(@RequestBody TutorSpecialColumn homeBackgroundMusic) { |
| | | TutorSpecialColumn one = tutorSpecialColumnService.getOne(null); |
| | | if (one == null){ |
| | |
| | | .collect(Collectors.toList()); |
| | | tutorSpecialColumnCourseService.removeBatchByIds(collect); |
| | | List<TutorSpecialColumnCourse> tutorSpecialColumnCourses = new ArrayList<>(); |
| | | if (StringUtils.hasLength(homeBackgroundMusic.getCourseIds())){ |
| | | String[] split = homeBackgroundMusic.getCourseIds().split(","); |
| | | for (int i = 0; i < split.length; i++) { |
| | | TutorSpecialColumnCourse tutorSpecialColumnCourse = new TutorSpecialColumnCourse(); |
| | | tutorSpecialColumnCourse.setCourseId(split[i]); |
| | | tutorSpecialColumnCourse.setTutorSpecialColumnId(homeBackgroundMusic.getId()); |
| | | tutorSpecialColumnCourse.setCreateBy(SecurityUtils.getUsername()); |
| | | tutorSpecialColumnCourse.setCreateTime(LocalDateTime.now()); |
| | | tutorSpecialColumnCourse.setUpdateBy(SecurityUtils.getUsername()); |
| | | tutorSpecialColumnCourse.setUpdateTime(LocalDateTime.now()); |
| | | tutorSpecialColumnCourses.add(tutorSpecialColumnCourse); |
| | | } |
| | | tutorSpecialColumnCourseService.saveBatch(tutorSpecialColumnCourses); |
| | | } |
| | | TutorSpecialColumnCourse tutorSpecialColumnCourse = new TutorSpecialColumnCourse(); |
| | | tutorSpecialColumnCourse.setCourseId(homeBackgroundMusic.getCourseIds()); |
| | | tutorSpecialColumnCourse.setTutorSpecialColumnId(homeBackgroundMusic.getId()); |
| | | tutorSpecialColumnCourses.add(tutorSpecialColumnCourse); |
| | | tutorSpecialColumnCourseService.saveBatch(tutorSpecialColumnCourses); |
| | | return R.ok(tutorSpecialColumnService.updateById(homeBackgroundMusic)); |
| | | } |
| | | |
| | |
| | | * |
| | | * @return 课程信息 |
| | | */ |
| | | @InnerAuth |
| | | @GetMapping("/getCourseById/{targetId}") |
| | | public R<Course> getCourseById(@PathVariable("targetId") Long targetId) { |
| | | return R.ok(courseService.getById(targetId)); |
| | |
| | | package com.xinquan.course.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "用户树苗id") |
| | | @TableId("id") |
| | | @ApiModelProperty(value = "id") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "用户id") |
| | |
| | | @ApiModelProperty(value = "课程id ") |
| | | @TableField("course_id") |
| | | private Long courseId; |
| | | @ApiModelProperty(value = "章节id ") |
| | | @TableField("chapter_id") |
| | | private Long chapterId; |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value = "视频讲解") |
| | | @TableField("video_url") |
| | | private String videoUrl; |
| | | @ApiModelProperty(value = "视频讲解文件名称") |
| | | @TableField("video_name") |
| | | private String videoName; |
| | | @ApiModelProperty(value = "视频封面") |
| | | @TableField("cover_url") |
| | | private String coverUrl; |
| | |
| | | * @since 2024-08-21 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("t_tutor_special_column_course") |
| | | @ApiModel(value="TutorSpecialColumnCourse对象", description="导师专栏课程关系表") |
| | | public class TutorSpecialColumnCourse extends BaseModel { |
| | | public class TutorSpecialColumnCourse { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
New file |
| | |
| | | package com.xinquan.course.domain.export; |
| | | |
| | | import cn.afterturn.easypoi.excel.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @ApiModel(value = "线上课程管理-导出") |
| | | public class CourseExport implements Serializable { |
| | | |
| | | @Excel(name = "课程标题",width = 30) |
| | | private String name; |
| | | @Excel(name = "课程分类",width = 30) |
| | | private String categoryName; |
| | | @Excel(name = "导师",width = 30) |
| | | private String tutor; |
| | | @Excel(name = "价格",width = 30) |
| | | private String generalPrice; |
| | | @Excel(name = "章节数",width = 30) |
| | | private String courseChapterCount; |
| | | @Excel(name = "上架状态",width = 30,replace = {"上架_1","下架_2"}) |
| | | private String listingStatus; |
| | | @Excel(name = "学习人数",width = 30) |
| | | private String realLearnedNum; |
| | | @Excel(name = "收藏数",width = 30) |
| | | private String collectCount; |
| | | @Excel(name = "添加时间",width = 30) |
| | | private String createTime; |
| | | |
| | | } |
New file |
| | |
| | | package com.xinquan.course.domain.export; |
| | | |
| | | import cn.afterturn.easypoi.excel.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @ApiModel(value = "线下课程管理-导出") |
| | | public class CourseOffExport implements Serializable { |
| | | |
| | | @Excel(name = "课程标题",width = 30) |
| | | private String name; |
| | | @Excel(name = "导师",width = 30) |
| | | private String tutor; |
| | | @Excel(name = "课程地址",width = 30) |
| | | private String address; |
| | | @Excel(name = "上架状态",width = 30,replace = {"上架_1","下架_2"}) |
| | | private String listingStatus; |
| | | @Excel(name = "收藏数",width = 30) |
| | | private String collectCount; |
| | | @Excel(name = "添加时间",width = 30) |
| | | private String createTime; |
| | | |
| | | } |
| | |
| | | package com.xinquan.course.domain.vo; |
| | | |
| | | import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.C; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.course.domain.CourseChapter; |
| | | import com.xinquan.course.api.domain.CourseChapter; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import java.math.BigDecimal; |
| | |
| | | |
| | | @ApiModelProperty(value = "详细地址") |
| | | private String addressDetail; |
| | | @ApiModelProperty(value = "秒") |
| | | private String duration; |
| | | |
| | | @ApiModelProperty(value = "课程地址经度") |
| | | private Double longitude; |
| | |
| | | package com.xinquan.course.domain.vo; |
| | | |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.course.domain.CourseChapter; |
| | | import com.xinquan.course.api.domain.CourseChapter; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author mitao |
| | |
| | | package com.xinquan.course.domain.vo; |
| | | |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.course.domain.CourseChapter; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author mitao |
| | |
| | | package com.xinquan.course.mapper; |
| | | |
| | | import com.xinquan.course.domain.CourseChapter; |
| | | import com.xinquan.course.api.domain.CourseChapter; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | |
| | | package com.xinquan.course.service; |
| | | |
| | | import com.xinquan.course.domain.CourseChapter; |
| | | import com.xinquan.course.api.domain.CourseChapter; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | /** |
| | |
| | | package com.xinquan.course.service.impl; |
| | | |
| | | import com.xinquan.course.domain.CourseChapter; |
| | | import com.xinquan.course.api.domain.CourseChapter; |
| | | import com.xinquan.course.mapper.CourseChapterMapper; |
| | | import com.xinquan.course.service.CourseChapterService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.course.api.domain.CourseChapter; |
| | | import com.xinquan.course.domain.CourseLearningRecord; |
| | | import com.xinquan.course.domain.vo.ClientCourseVO; |
| | | import com.xinquan.course.mapper.CourseMapper; |
| | | import com.xinquan.course.service.CourseService; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | if (CollUtils.isEmpty(page.getRecords())) { |
| | | return PageDTO.empty(page); |
| | | } |
| | | |
| | | return PageDTO.of(page, ClientCourseVO.class); |
| | | } |
| | | } |
| | |
| | | <mapper namespace="com.xinquan.course.mapper.CourseChapterMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.xinquan.course.domain.CourseChapter"> |
| | | <resultMap id="BaseResultMap" type="com.xinquan.course.api.domain.CourseChapter"> |
| | | <id column="id" property="id" /> |
| | | <result column="del_flag" property="delFlag" /> |
| | | <result column="create_by" property="createBy" /> |
| | |
| | | |
| | | <dependencies> |
| | | |
| | | <dependency> |
| | | <groupId>cn.afterturn</groupId> |
| | | <artifactId>easypoi-spring-boot-starter</artifactId> |
| | | <version>4.0.0</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <artifactId>guava</artifactId> |
| | | <groupId>com.google.guava</groupId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <!--user feign模块--> |
| | | <dependency> |
| | | <groupId>com.xinquan</groupId> |
| | |
| | | import com.xinquan.common.core.constant.SecurityConstants; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.core.web.page.PageInfo; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.meditation.api.domain.Meditation; |
| | | import com.xinquan.meditation.domain.HomeBackgroundMusic; |
| | | import com.xinquan.meditation.domain.MeditationHall; |
| | | import com.xinquan.meditation.domain.vo.ClientHomeBackgroundMusicVO; |
| | | import com.xinquan.meditation.domain.vo.ClientMeditationAndCateVO; |
| | | import com.xinquan.meditation.domain.vo.ClientMeditationCategoryVO; |
| | |
| | | import com.xinquan.meditation.service.MeditationService; |
| | | import com.xinquan.system.api.RemoteHotWordsService; |
| | | import com.xinquan.system.api.domain.AppUser; |
| | | import com.xinquan.system.api.domain.MeditationQuestion; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | |
| | | private final RemoteHotWordsService remoteHotWordsService; |
| | | private final MeditationQuestionService meditationQuestionService; |
| | | |
| | | @PostMapping("/listHomeBackgroundMusic") |
| | | @ApiOperation(value = "背景音乐列表查询-分页", notes = "管理后台-首页背景音乐管理") |
| | | @GetMapping("/listHomeBackgroundMusic") |
| | | @ApiOperation(value = "背景音乐列表查询-分页", tags = "管理后台-首页背景音乐管理") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "pageCurr", value = "分页参数,当前页码", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "分页参数,每页数量", dataType = "Integer", required = true)}) |
| | | public R<PageDTO<HomeBackgroundMusic>> listHomeBackgroundMusic(@RequestParam Integer pageCurr, @RequestParam Integer pageSize) { |
| | | PageDTO<HomeBackgroundMusic> pageDTO = PageDTO.empty(0L, 0L); |
| | | |
| | | // 查询 |
| | | Page<HomeBackgroundMusic> page = homeBackgroundMusicService.lambdaQuery() |
| | | .orderByDesc(HomeBackgroundMusic::getSortNum) |
| | | .page(new Page<>(pageCurr, pageSize)); |
| | | // 如果没有查到数据直接返回 |
| | | if (Optional.ofNullable(page.getRecords()).isPresent()) { |
| | | return R.ok(pageDTO); |
| | | if (page.getRecords().isEmpty()) { |
| | | return R.ok(PageDTO.empty(page)); |
| | | } |
| | | // 将实体类转换为VO |
| | | pageDTO = PageDTO.of(page, HomeBackgroundMusic.class); |
| | | for (HomeBackgroundMusic homeBackgroundMusic : pageDTO.getList()) { |
| | | for (HomeBackgroundMusic homeBackgroundMusic : page.getRecords()) { |
| | | homeBackgroundMusic.setUid(homeBackgroundMusic.getId() + ""); |
| | | } |
| | | return R.ok(pageDTO); |
| | | return R.ok(PageDTO.of(page, HomeBackgroundMusic.class)); |
| | | } |
| | | |
| | | @PostMapping("/addHomeBackgroundMusic") |
| | | @ApiOperation(value = "新增背景", notes = "管理后台-首页背景音乐管理") |
| | | @ApiOperation(value = "新增背景", tags = "管理后台-首页背景音乐管理") |
| | | public R addHomeBackgroundMusic(@RequestBody HomeBackgroundMusic homeBackgroundMusic) { |
| | | return R.ok(homeBackgroundMusicService.save(homeBackgroundMusic)); |
| | | } |
| | | @GetMapping("/detailHomeBackgroundMusic") |
| | | @ApiOperation(value = "查看详情", notes = "管理后台-首页背景音乐管理") |
| | | public R detailHomeBackgroundMusic(String uid) { |
| | | @ApiOperation(value = "查看详情", tags = "管理后台-首页背景音乐管理") |
| | | public R<HomeBackgroundMusic> detailHomeBackgroundMusic(String uid) { |
| | | return R.ok(homeBackgroundMusicService.getById(uid)); |
| | | } |
| | | @PostMapping("/updateHomeBackgroundMusic") |
| | | @ApiOperation(value = "修改背景", notes = "管理后台-首页背景音乐管理") |
| | | @ApiOperation(value = "修改背景", tags = "管理后台-首页背景音乐管理") |
| | | public R updateHomeBackgroundMusic(@RequestBody HomeBackgroundMusic homeBackgroundMusic) { |
| | | return R.ok(homeBackgroundMusicService.updateById(homeBackgroundMusic)); |
| | | } |
| | | @PostMapping("/deleteHomeBackgroundMusic") |
| | | @ApiOperation(value = "批量删除", notes = "管理后台-首页背景音乐管理") |
| | | @ApiOperation(value = "批量删除", tags = "管理后台-首页背景音乐管理") |
| | | public R deleteHomeBackgroundMusic(String ids) { |
| | | return R.ok(homeBackgroundMusicService.removeBatchByIds(Arrays.asList(ids.split(",")))); |
| | | return R.ok(homeBackgroundMusicService.removeBatchByIds(Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList()))); |
| | | } |
| | | /** |
| | | * 获取首页背景音乐列表 |
| | |
| | | }) |
| | | public R<PageDTO<ClientMeditationVO>> search(@RequestParam String condition, |
| | | @RequestParam Integer pageCurr, @RequestParam Integer pageSize) { |
| | | |
| | | |
| | | return R.ok(meditationService.search(condition, pageCurr, pageSize)); |
| | | } |
| | | |
| | |
| | | @ApiOperation("获取冥想音频详情") |
| | | @ApiImplicitParam(name = "id", value = "冥想音频id", dataType = "Long", required = true) |
| | | public R<ClientMeditationDetailsVO> getMeditationDetails(@RequestParam("id") Long id) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | return R.ok(meditationService.getMeditationDetails(id)); |
| | | } |
| | | @GetMapping("/getMeditationDetailsShare") |
| | | @ApiOperation(value = "获取冥想音频详情",tags = "H5分享") |
| | | @ApiImplicitParam(name = "id", value = "冥想音频id", dataType = "Long", required = true) |
| | | public R<ClientMeditationDetailsVO> getMeditationDetailsShare(Long id) { |
| | | return R.ok(meditationService.getMeditationDetails1(id)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation(value = "收藏/取消收藏") |
| | | @ApiImplicitParam(name = "id", value = "冥想音频id", dataType = "Long", required = true) |
| | | public R<?> favorite(@RequestParam("id") Long id) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | meditationService.favorite(id); |
| | | return R.ok(); |
| | | } |
| | |
| | | public R<PageDTO<ClientMeditationQuestionVO>> getMeditationQuestionPage( |
| | | @RequestParam("id") Long id, @RequestParam("pageCurr") Integer pageCurr, |
| | | @RequestParam("pageSize") Integer pageSize) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | return R.ok(meditationService.getMeditationQuestionPage(id, pageCurr, pageSize)); |
| | | } |
| | | |
| | | @GetMapping("/getMeditationQuestionPageShare") |
| | | @ApiOperation(value = "获取冥想音频提问列表-分页",tags = "H5分享") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "冥想音频id", dataType = "Long", required = true), |
| | | @ApiImplicitParam(name = "pageCurr", value = "分页参数,当前页码", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "分页参数,每页数量", dataType = "Integer", required = true) |
| | | }) |
| | | public R<PageDTO<ClientMeditationQuestionVO>> getMeditationQuestionPageShare( |
| | | @RequestParam("id") Long id, @RequestParam("pageCurr") Integer pageCurr, |
| | | @RequestParam("pageSize") Integer pageSize) { |
| | | return R.ok(meditationService.getMeditationQuestionPageShare(id, pageCurr, pageSize)); |
| | | } |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @PostMapping("/addQuestion") |
| | | @ApiOperation(value = "发布提问") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "meditationId", value = "冥想音频id", dataType = "Long", required = true), |
| | | @ApiImplicitParam(name = "content", value = "提问内容", dataType = "String", required = true), |
| | | }) |
| | | public R addQuestion(Long meditationId,String content) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | MeditationQuestion meditationQuestion = new MeditationQuestion(); |
| | | meditationQuestion.setMeditationId(meditationId); |
| | | meditationQuestion.setLikeCount(0); |
| | | meditationQuestion.setFavorite(2); |
| | | meditationQuestion.setContent(content); |
| | | meditationQuestion.setPublishTime(LocalDateTime.now()); |
| | | meditationQuestion.setAppUserId(userId); |
| | | meditationQuestion.setShowFlag(1); |
| | | meditationQuestion.setReportStatus(1); |
| | | meditationQuestionService.save(meditationQuestion); |
| | | return R.ok(); |
| | | } |
| | | /** |
| | | * 举报提问 |
| | | * |
| | |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Arrays; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | return R.ok(PageDTO.of(page, MeditationCategory.class)); |
| | | } |
| | | @PostMapping("/addMeditationCategory") |
| | | @ApiOperation(value = "新增冥想分类管理", notes = "管理后台-冥想分类管理") |
| | | @ApiOperation(value = "新增冥想分类管理", tags = "管理后台-冥想分类管理") |
| | | public R addMeditationCategory(@RequestBody MeditationCategory homeBackgroundMusic) { |
| | | homeBackgroundMusic.setCreateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setCreateTime(LocalDateTime.now()); |
| | | return R.ok(meditationCategoryService.save(homeBackgroundMusic)); |
| | | } |
| | | @GetMapping("/detailMeditationCategory") |
| | | @ApiOperation(value = "查看详情冥想分类管理", notes = "管理后台-冥想分类管理") |
| | | @ApiOperation(value = "查看详情冥想分类管理", tags = "管理后台-冥想分类管理") |
| | | public R<MeditationCategory> detailMeditationCategory(String uid) { |
| | | return R.ok(meditationCategoryService.getById(uid)); |
| | | } |
| | | @PostMapping("/updateMeditationCategory") |
| | | @ApiOperation(value = "修改冥想分类管理", notes = "管理后台-冥想分类管理") |
| | | @ApiOperation(value = "修改冥想分类管理", tags = "管理后台-冥想分类管理") |
| | | public R updateMeditationCategory(@RequestBody MeditationCategory homeBackgroundMusic) { |
| | | homeBackgroundMusic.setUpdateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setUpdateTime(LocalDateTime.now()); |
| | | return R.ok(meditationCategoryService.updateById(homeBackgroundMusic)); |
| | | } |
| | | @PostMapping("/deleteMeditationCategory") |
| | | @ApiOperation(value = "批量删除", notes = "管理后台-冥想分类管理") |
| | | @ApiOperation(value = "批量删除", tags = "管理后台-冥想分类管理") |
| | | public R deleteMeditationCategory(String ids) { |
| | | return R.ok(meditationCategoryService.removeBatchByIds(Arrays.asList(ids.split(",")))); |
| | | return R.ok(meditationCategoryService.removeBatchByIds(Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList()))); |
| | | } |
| | | } |
| | | |
| | |
| | | package com.xinquan.meditation.controller.client; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.WebUtils; |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.core.web.domain.BaseModel; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.meditation.api.domain.Meditation; |
| | | import com.xinquan.meditation.api.domain.dto.MeditationDTO; |
| | | import com.xinquan.meditation.api.domain.dto.UserAnswerDTO; |
| | | import com.xinquan.meditation.domain.*; |
| | | import com.xinquan.meditation.domain.export.MeditationExport; |
| | | import com.xinquan.meditation.service.*; |
| | | import com.xinquan.system.api.domain.AppUser; |
| | | import com.xinquan.system.api.domain.MeditationQuestion; |
| | | import com.xinquan.system.api.domain.NoticeRecord; |
| | | import com.xinquan.system.api.domain.Tag; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.user.api.domain.dto.OrderListDTO; |
| | | import com.xinquan.user.api.feign.RemoteAppUserService; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | |
| | | private MeditationCategoryService meditationCategoryService; |
| | | @Autowired |
| | | private MeditationQuestionService meditationQuestionService; |
| | | |
| | | @Autowired |
| | | private MeditationEverydayService meditationEverydayService; |
| | | @Resource |
| | | private RemoteAppUserService remoteAppUserService; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | @GetMapping("/getMeditationCount") |
| | | public R<String> getMeditationCount() { |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | List<Meditation> list = meditationService.lambdaQuery().eq(BaseModel::getDelFlag, 0) |
| | | .list(); |
| | | stringBuilder.append(list.size()).append(","); |
| | | List<Meditation> collect1 = list.stream().filter(t -> t.getChargeType() == 1).collect(Collectors.toList()); |
| | | List<Meditation> collect2 = list.stream().filter(t -> t.getChargeType() == 2).collect(Collectors.toList()); |
| | | List<Meditation> collect3 = list.stream().filter(t -> t.getChargeType() == 3).collect(Collectors.toList()); |
| | | stringBuilder.append(collect1.size()).append(","); |
| | | stringBuilder.append(collect2.size()).append(","); |
| | | stringBuilder.append(collect3.size()).append(","); |
| | | return R.ok(stringBuilder.toString()); |
| | | } |
| | | @PostMapping("/confirmOrder") |
| | | @ApiOperation(value = "确认订单页面",tags = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "冥想id", name = "meditationId", required = true, dataType = "Long") |
| | | }) |
| | | public R<Meditation> studyPageByChapterId(@RequestParam(value = "meditationId")Long meditationId) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userid = loginUser.getUserid(); |
| | | Meditation byId = meditationService.getById(meditationId); |
| | | AppUser data = remoteAppUserService.getAppUserById(userid + "").getData(); |
| | | byId.setBalance(data.getBalance()); |
| | | return R.ok(byId); |
| | | } |
| | | @PostMapping("/successOrder") |
| | | @ApiOperation(value = "支付成功页面") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "冥想id", name = "meditationId", required = true, dataType = "Long") |
| | | }) |
| | | public R<List<Meditation>> successOrder(@RequestParam(value = "meditationId")Long meditationId) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | Meditation byId = meditationService.getById(meditationId); |
| | | List<Meditation> list = meditationService.lambdaQuery().eq(Meditation::getCateId, byId.getCateId()) |
| | | .list(); |
| | | |
| | | List<Meditation> courses = new ArrayList<>(); |
| | | |
| | | // 如果list集合数据大于2 随机获取两个返回 |
| | | if (CollUtils.isNotEmpty(list) && list.size() > 4) { |
| | | int size = list.size(); |
| | | int index = (int) (Math.random() * size); |
| | | for (int i = 0; i < 4; i++) { |
| | | courses.add(list.get(index)); |
| | | } |
| | | return R.ok(courses); |
| | | }else { |
| | | return R.ok(list); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 远程调用 通过疗愈名字查询疗愈ids |
| | |
| | | .collect(Collectors.toList()); |
| | | return R.ok(collect); |
| | | } |
| | | @GetMapping("/getMeditationById/{pageCurr}/{pageSize}") |
| | | public R<Page<Meditation>> getMeditationById(@PathVariable("pageCurr") Integer pageCurr,@PathVariable("pageSize") Integer pageSize) |
| | | @GetMapping("/getMeditationById/{pageCurr}/{pageSize}/{id}") |
| | | public R<Page<Meditation>> getMeditationById(@PathVariable("pageCurr") Integer pageCurr |
| | | ,@PathVariable("pageSize") Integer pageSize,@PathVariable("id")Long id) |
| | | { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | List<Long> collect = meditationUserFavoriteService |
| | | .lambdaQuery() |
| | | .eq(MeditationUserFavorite::getAppUserId, userId).list().stream() |
| | | .eq(MeditationUserFavorite::getAppUserId, id).list().stream() |
| | | .map(MeditationUserFavorite::getId).collect(Collectors.toList()); |
| | | if (collect.isEmpty())collect.add(-1L); |
| | | Page<Meditation> page = meditationService |
| | | .lambdaQuery() |
| | | .in(Meditation::getId, collect) |
| | |
| | | if (page.getRecords().isEmpty()){ |
| | | return R.ok(page); |
| | | } |
| | | // 查询人数 |
| | | return R.ok(page); |
| | | } |
| | | @GetMapping("/getMeditationByIds/{pageCurr}/{pageSize}/{ids}") |
| | | public R<Page<Meditation>> getMeditationByIds(@PathVariable("pageCurr") Integer pageCurr, |
| | | @PathVariable("pageSize") Integer pageSize, |
| | | @PathVariable("ids")String ids) |
| | | { |
| | | |
| | | Page<Meditation> page = meditationService |
| | | .lambdaQuery() |
| | | .in(Meditation::getId,Arrays.asList(ids.split(","))) |
| | | .page(new Page<>(pageCurr, pageSize)); |
| | | if (page.getRecords().isEmpty()){ |
| | | return R.ok(page); |
| | | } |
| | | // 查询人数 |
| | | return R.ok(page); |
| | | } |
| | | @GetMapping("/getMeditationById/{id}") |
| | |
| | | MeditationHall byId = meditationHallService.getById(id); |
| | | return R.ok(byId); |
| | | } |
| | | @PostMapping("/meditationManagementList") |
| | | @ApiOperation(value = "冥想音频列表-分页", tags = {"管理后台-冥想音频管理"}) |
| | | public R<PageDTO<Meditation>> meditationManagementList(@RequestBody MeditationDTO dto) { |
| | | @ApiOperation(value = "冥想音频列表导出", tags = {"管理后台-冥想音频管理"}) |
| | | @PutMapping("/export") |
| | | public void export(@RequestBody MeditationDTO dto) |
| | | { |
| | | List<Long> longs = new ArrayList<>(); |
| | | if (!dto.getTagName().isEmpty()){ |
| | | if (dto.getTagName()!=null && !dto.getTagName().isEmpty()){ |
| | | List<Tag> data = remoteAppUserService.queryTag(dto.getTagName()).getData(); |
| | | if (data.isEmpty()){ |
| | | longs.add(-1L); |
| | |
| | | longs.addAll(data.stream().map(Tag::getId).collect(Collectors.toList())); |
| | | } |
| | | } |
| | | List<Long> collect = meditationTagService.lambdaQuery().in(MeditationTag::getTagId) |
| | | if (longs.isEmpty())longs.add(-1L); |
| | | List<Long> collect = meditationTagService.lambdaQuery().in(MeditationTag::getTagId,longs) |
| | | .list().stream().map(MeditationTag::getMeditationId) |
| | | .collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | LambdaQueryWrapper<Meditation> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.hasLength(dto.getIds())){ |
| | | courseLambdaQueryWrapper.in(Meditation::getId, Arrays.asList(dto.getIds().split(","))); |
| | | } |
| | | courseLambdaQueryWrapper.eq(dto.getSanskrit()!=null,Meditation::getSanskrit, dto.getSanskrit()); |
| | | courseLambdaQueryWrapper.in(StringUtils.hasLength(dto.getTagName()),Meditation::getId, collect); |
| | | courseLambdaQueryWrapper.eq(dto.getChargeType()!=null,Meditation::getChargeType, dto.getChargeType()); |
| | | courseLambdaQueryWrapper.eq(dto.getCateId()!=null,Meditation::getCateId, dto.getCateId()); |
| | | courseLambdaQueryWrapper.eq(dto.getMeditationTitle()!=null&& !dto.getMeditationTitle().isEmpty(),Meditation::getMeditationTitle, dto.getMeditationTitle()); |
| | | courseLambdaQueryWrapper.orderByDesc(Meditation::getSortNum); |
| | | List<Meditation> page = meditationService.list(courseLambdaQueryWrapper); |
| | | List<MeditationExport> meditations = new ArrayList<>(); |
| | | for (Meditation record : page) { |
| | | MeditationExport meditationExport = new MeditationExport(); |
| | | record.setUid(record.getId()+""); |
| | | MeditationCategory byId = meditationCategoryService.getById(record.getCateId()); |
| | | if (byId!=null){ |
| | | record.setCategoryName(byId.getCategoryName()); |
| | | meditationExport.setCategoryName(byId.getCategoryName()); |
| | | } |
| | | meditationExport.setName(record.getMeditationTitle()); |
| | | meditationExport.setDetailDescription(record.getDetailDescription()); |
| | | if (record.getChargeType()==3){ |
| | | meditationExport.setGeneralPrice("¥"+record.getGeneralPrice()); |
| | | }else{ |
| | | switch (record.getChargeType()){ |
| | | case 1: |
| | | meditationExport.setGeneralPrice("免费"); |
| | | break; |
| | | case 2: |
| | | meditationExport.setGeneralPrice("会员免费"); |
| | | break; |
| | | } |
| | | } |
| | | DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | String format = df.format(record.getCreateTime()); |
| | | meditationExport.setCreateTime(format); |
| | | meditationExport.setListingStatus(record.getListingStatus()+""); |
| | | meditationExport.setRealLearnedNum(record.getRealLearnedNum()+record.getVirtualLearnedNum()+""); |
| | | meditationExport.setCollectCount(record.getFavoriteCount()+""); |
| | | meditations.add(meditationExport); |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), MeditationExport.class, meditations); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("冥想音频管理导出.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | @PostMapping("/meditationManagementList") |
| | | @ApiOperation(value = "冥想音频列表-分页", tags = {"管理后台-冥想音频管理"}) |
| | | public R<PageDTO<Meditation>> meditationManagementList(@RequestBody MeditationDTO dto) { |
| | | List<Long> longs = new ArrayList<>(); |
| | | if (dto.getTagName()!=null && !dto.getTagName().isEmpty()){ |
| | | List<Tag> data = remoteAppUserService.queryTag(dto.getTagName()).getData(); |
| | | if (data.isEmpty()){ |
| | | longs.add(-1L); |
| | | }else{ |
| | | longs.addAll(data.stream().map(Tag::getId).collect(Collectors.toList())); |
| | | } |
| | | } |
| | | if (longs.isEmpty())longs.add(-1L); |
| | | List<Long> collect = meditationTagService.lambdaQuery().in(MeditationTag::getTagId,longs) |
| | | .list().stream().map(MeditationTag::getMeditationId) |
| | | .collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | |
| | | } |
| | | LambdaQueryWrapper<Meditation> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | courseLambdaQueryWrapper.eq(dto.getSanskrit()!=null,Meditation::getSanskrit, dto.getSanskrit()); |
| | | courseLambdaQueryWrapper.in(Meditation::getId, collect); |
| | | courseLambdaQueryWrapper.in(StringUtils.hasLength(dto.getTagName()),Meditation::getId, collect); |
| | | courseLambdaQueryWrapper.eq(dto.getChargeType()!=null,Meditation::getChargeType, dto.getChargeType()); |
| | | courseLambdaQueryWrapper.eq(dto.getCateId()!=null,Meditation::getCateId, dto.getCateId()); |
| | | courseLambdaQueryWrapper.eq(dto.getMeditationTitle()!=null&& !dto.getMeditationTitle().isEmpty(),Meditation::getMeditationTitle, dto.getMeditationTitle()); |
| | |
| | | } |
| | | |
| | | @PostMapping("/addMeditation") |
| | | @ApiOperation(value = "新增冥想音频管理", notes = "管理后台-冥想音频管理") |
| | | @ApiOperation(value = "新增冥想音频管理", tags = "管理后台-冥想音频管理") |
| | | public R addMeditation(@RequestBody Meditation homeBackgroundMusic) { |
| | | homeBackgroundMusic.setCreateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setCreateTime(LocalDateTime.now()); |
| | | meditationService.save(homeBackgroundMusic); |
| | | if (homeBackgroundMusic.getIsEveryday()==1){ |
| | | MeditationEveryday meditationEveryday = new MeditationEveryday(); |
| | | meditationEveryday.setMeditationId(homeBackgroundMusic.getId()); |
| | | meditationEveryday.setStartPlayTime(homeBackgroundMusic.getStartPlayTime()); |
| | | meditationEveryday.setEndPlayTime(homeBackgroundMusic.getEndPlayTime()); |
| | | meditationEveryday.setImageUrl(homeBackgroundMusic.getImageUrl()); |
| | | meditationEveryday.setCreateTime(LocalDateTime.now()); |
| | | meditationEverydayService.save(meditationEveryday); |
| | | homeBackgroundMusic.setEverydayId(meditationEveryday.getId()); |
| | | meditationService.updateById(homeBackgroundMusic); |
| | | } |
| | | if (!homeBackgroundMusic.getTagIds().isEmpty()){ |
| | | String[] split = homeBackgroundMusic.getTagIds().split(","); |
| | | List<MeditationTag> meditationTags = new ArrayList<>(); |
| | |
| | | } |
| | | if (!homeBackgroundMusic.getMusicUrls().isEmpty()){ |
| | | String[] split = homeBackgroundMusic.getMusicUrls().split(","); |
| | | String[] split1 = homeBackgroundMusic.getName().split(","); |
| | | String[] split2 = homeBackgroundMusic.getMusicSize().split(","); |
| | | List<MeditationMusic> meditationTags = new ArrayList<>(); |
| | | for (int i = 0; i < split.length; i++) { |
| | | MeditationMusic meditationTag = new MeditationMusic(); |
| | | meditationTag.setMusicSize(split2[i]); |
| | | meditationTag.setMeditationId(homeBackgroundMusic.getId()); |
| | | meditationTag.setMusicUrl(split[i]); |
| | | meditationTag.setName(split1[i]); |
| | | meditationTag.setMusicSecond(Integer.valueOf(homeBackgroundMusic.getMusicSecond().split(",")[i])); |
| | | meditationTags.add(meditationTag); |
| | | } |
| | |
| | | return R.ok(); |
| | | } |
| | | @GetMapping("/detailMeditation") |
| | | @ApiOperation(value = "查看详情冥想音频管理", notes = "管理后台-冥想音频管理") |
| | | @ApiOperation(value = "查看详情冥想音频管理", tags = "管理后台-冥想音频管理") |
| | | public R<Meditation> detailMeditation(String uid) { |
| | | Meditation byId = meditationService.getById(uid); |
| | | List<Long> collect = meditationTagService.list(new LambdaQueryWrapper<MeditationTag>() |
| | |
| | | .collect(Collectors.toList()); |
| | | List<String> collect1 = meditationMusicService.list(new LambdaQueryWrapper<MeditationMusic>() |
| | | .eq(MeditationMusic::getMeditationId, uid)) |
| | | .stream().map(MeditationMusic::getMusicUrl) |
| | | .stream().map(MeditationMusic::getName) |
| | | .collect(Collectors.toList()); |
| | | byId.setMusicList(collect1); |
| | | byId.setTagList(collect); |
| | | if (byId.getIsEveryday() == 1){ |
| | | MeditationEveryday byId1 = meditationEverydayService.getById(byId.getEverydayId()); |
| | | byId.setStartPlayTime(byId1.getStartPlayTime()); |
| | | byId.setEndPlayTime(byId1.getEndPlayTime()); |
| | | byId.setImageUrl(byId1.getImageUrl()); |
| | | } |
| | | MeditationCategory byId1 = meditationCategoryService.getById(byId.getCateId()); |
| | | if (byId1!=null){ |
| | | byId.setCategoryName(byId1.getCategoryName()); |
| | | } |
| | | List<MeditationMusic> list = meditationMusicService.lambdaQuery().eq(MeditationMusic::getMeditationId, byId.getId()).list(); |
| | | StringBuilder stringBuilder1 = new StringBuilder(); |
| | | StringBuilder stringBuilder2 = new StringBuilder(); |
| | | StringBuilder stringBuilder3 = new StringBuilder(); |
| | | StringBuilder stringBuilder4 = new StringBuilder(); |
| | | for (MeditationMusic meditationMusic : list) { |
| | | stringBuilder1.append(meditationMusic.getMusicUrl()).append(","); |
| | | stringBuilder2.append(meditationMusic.getMusicSize()).append(","); |
| | | stringBuilder3.append(meditationMusic.getMusicSecond()).append(","); |
| | | stringBuilder4.append(meditationMusic.getName()).append(","); |
| | | } |
| | | // 去除最后以为字符 |
| | | byId.setMusicUrls(stringBuilder1.deleteCharAt(stringBuilder1.length() - 1)+""); |
| | | byId.setMusicSize(stringBuilder2.deleteCharAt(stringBuilder2.length() - 1)+""); |
| | | byId.setMusicSecond(stringBuilder3.deleteCharAt(stringBuilder3.length() - 1)+""); |
| | | byId.setName(stringBuilder4.deleteCharAt(stringBuilder4.length() - 1)+""); |
| | | return R.ok(byId); |
| | | } |
| | | @PostMapping("/userAnswer") |
| | | @ApiOperation(value = "查看详情冥想音频-用户提问-分页", notes = "管理后台-冥想音频管理") |
| | | @ApiOperation(value = "查看详情冥想音频-用户提问-分页", tags = "管理后台-冥想音频管理") |
| | | public R<PageDTO<MeditationQuestion>> userAnswer(@RequestBody UserAnswerDTO dto) { |
| | | LambdaQueryWrapper<MeditationQuestion> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.hasLength(dto.getUserName())){ |
| | |
| | | return R.ok(PageDTO.of(page, MeditationQuestion.class)); |
| | | } |
| | | @GetMapping("/updateUserAnswerState") |
| | | @ApiOperation(value = "查看详情冥想音频-用户提问-修改显示状态", notes = "管理后台-冥想音频管理") |
| | | @ApiOperation(value = "查看详情冥想音频-用户提问-修改显示状态", tags = "管理后台-冥想音频管理") |
| | | public R updateUserAnswerState(String uid) { |
| | | MeditationQuestion byId = meditationQuestionService.getById(uid); |
| | | if (byId.getShowFlag() == 1){ |
| | |
| | | }else { |
| | | byId.setShowFlag(1); |
| | | } |
| | | meditationQuestionService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | @GetMapping("/detailUserAnswer") |
| | | @ApiOperation(value = "查看详情冥想音频-用户提问", notes = "管理后台-冥想音频管理") |
| | | @ApiOperation(value = "查看详情冥想音频-用户提问", tags = "管理后台-冥想音频管理") |
| | | public R<MeditationQuestion> detailUserAnswer(String uid) { |
| | | MeditationQuestion byId = meditationQuestionService.getById(uid); |
| | | AppUser data = remoteAppUserService.getAppUserById(byId.getAppUserId().toString()).getData(); |
| | |
| | | return R.ok(byId); |
| | | } |
| | | @GetMapping("/updateUserAnswer") |
| | | @ApiOperation(value = "查看详情冥想音频-用户提问-编辑", notes = "管理后台-冥想音频管理") |
| | | @ApiOperation(value = "查看详情冥想音频-用户提问-编辑", tags = "管理后台-冥想音频管理") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "uid", value = "uid", dataType = "String", required = true), |
| | | @ApiImplicitParam(name = "content", value = "回复内容", dataType = "String", required = false), |
| | |
| | | meditationQuestionLambdaUpdateWrapper.set(MeditationQuestion::getReplyContent, content); |
| | | meditationQuestionLambdaUpdateWrapper.set(StringUtils.hasLength(content),MeditationQuestion::getReplyTime, LocalDateTime.now()); |
| | | meditationQuestionLambdaUpdateWrapper.set(MeditationQuestion::getShowFlag, showFlag); |
| | | meditationQuestionLambdaUpdateWrapper.eq(MeditationQuestion::getId, uid); |
| | | meditationQuestionService.update(meditationQuestionLambdaUpdateWrapper); |
| | | return R.ok(byId); |
| | | } |
| | | @GetMapping("/updateState") |
| | | @ApiOperation(value = "修改冥想音频上下架状态", notes = "管理后台-冥想音频管理") |
| | | @ApiOperation(value = "修改冥想音频上下架状态", tags = "管理后台-冥想音频管理") |
| | | public R updateState(String uid) { |
| | | Meditation byId = meditationService.getById(uid); |
| | | if (byId.getListingStatus() == 1){ |
| | |
| | | }else { |
| | | byId.setListingStatus(1); |
| | | } |
| | | meditationService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/updateMeditation") |
| | | @ApiOperation(value = "修改冥想音频管理", notes = "管理后台-冥想音频管理") |
| | | @ApiOperation(value = "修改冥想音频管理", tags = "管理后台-冥想音频管理") |
| | | public R updateMeditation(@RequestBody Meditation homeBackgroundMusic) { |
| | | homeBackgroundMusic.setUpdateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setUpdateTime(LocalDateTime.now()); |
| | |
| | | .eq(MeditationTag::getMeditationId,homeBackgroundMusic.getId())); |
| | | meditationMusicService.remove(new LambdaQueryWrapper<MeditationMusic>() |
| | | .eq(MeditationMusic::getMeditationId,homeBackgroundMusic.getId())); |
| | | if (homeBackgroundMusic.getIsEveryday() == 2){ |
| | | // 将以前的删掉 |
| | | meditationEverydayService.remove(new LambdaQueryWrapper<MeditationEveryday>() |
| | | .eq(MeditationEveryday::getId,homeBackgroundMusic.getEverydayId())); |
| | | }else if (homeBackgroundMusic.getIsEveryday() == 1){ |
| | | meditationEverydayService.remove(new LambdaQueryWrapper<MeditationEveryday>() |
| | | .eq(MeditationEveryday::getId,homeBackgroundMusic.getEverydayId())); |
| | | // 将以前的删掉 再新增一条 |
| | | MeditationEveryday meditationEveryday = new MeditationEveryday(); |
| | | meditationEveryday.setMeditationId(homeBackgroundMusic.getId()); |
| | | meditationEveryday.setStartPlayTime(homeBackgroundMusic.getStartPlayTime()); |
| | | meditationEveryday.setEndPlayTime(homeBackgroundMusic.getEndPlayTime()); |
| | | meditationEveryday.setImageUrl(homeBackgroundMusic.getImageUrl()); |
| | | meditationEveryday.setCreateTime(LocalDateTime.now()); |
| | | meditationEverydayService.save(meditationEveryday); |
| | | homeBackgroundMusic.setEverydayId(meditationEveryday.getId()); |
| | | meditationService.updateById(homeBackgroundMusic); |
| | | } |
| | | if (!homeBackgroundMusic.getTagIds().isEmpty()){ |
| | | meditationTagService.remove(new LambdaQueryWrapper<MeditationTag>().eq(MeditationTag::getMeditationId,homeBackgroundMusic.getId())); |
| | | String[] split = homeBackgroundMusic.getTagIds().split(","); |
| | |
| | | if (!homeBackgroundMusic.getMusicUrls().isEmpty()){ |
| | | meditationMusicService.remove(new LambdaQueryWrapper<MeditationMusic>().eq(MeditationMusic::getMeditationId,homeBackgroundMusic.getId())); |
| | | String[] split = homeBackgroundMusic.getMusicUrls().split(","); |
| | | String[] split1 = homeBackgroundMusic.getName().split(","); |
| | | String[] split2 = homeBackgroundMusic.getMusicSize().split(","); |
| | | List<MeditationMusic> meditationTags = new ArrayList<>(); |
| | | for (int i = 0; i < split.length; i++) { |
| | | MeditationMusic meditationTag = new MeditationMusic(); |
| | | meditationTag.setMusicSize(split2[i]); |
| | | meditationTag.setMeditationId(homeBackgroundMusic.getId()); |
| | | meditationTag.setMusicUrl(split[i]); |
| | | meditationTag.setName(split1[i]); |
| | | meditationTag.setMusicSecond(Integer.valueOf(homeBackgroundMusic.getMusicSecond().split(",")[i])); |
| | | meditationTags.add(meditationTag); |
| | | } |
| | |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/deleteMeditation") |
| | | @ApiOperation(value = "批量删除", notes = "管理后台-冥想音频管理") |
| | | @ApiOperation(value = "批量删除", tags = "管理后台-冥想音频管理") |
| | | public R deleteMeditation(String ids) { |
| | | return R.ok(meditationService.removeBatchByIds(Arrays.asList(ids.split(",")))); |
| | | return R.ok(meditationService.removeBatchByIds(Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList()))); |
| | | } |
| | | } |
| | | |
| | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | } |
| | | for (MeditationEveryday record : page.getRecords()) { |
| | | record.setUid(record.getId()+""); |
| | | Meditation byId = meditationService.getById(record.getMeditationId()); |
| | | if (byId!=null){ |
| | | record.setMeditationTitle(byId.getMeditationTitle()); |
| | | } |
| | | } |
| | | return R.ok(PageDTO.of(page, MeditationEveryday.class)); |
| | | } |
| | |
| | | return R.ok(list); |
| | | } |
| | | @PostMapping("/addMeditationEveryday") |
| | | @ApiOperation(value = "新增每日冥想库管理", notes = "管理后台-每日冥想库管理") |
| | | @ApiOperation(value = "新增每日冥想库管理", tags = "管理后台-每日冥想库管理") |
| | | public R addMeditationEveryday(@RequestBody MeditationEveryday homeBackgroundMusic) { |
| | | homeBackgroundMusic.setCreateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setCreateTime(LocalDateTime.now()); |
| | | return R.ok(meditationEverydayService.save(homeBackgroundMusic)); |
| | | } |
| | | @GetMapping("/detailMeditationEveryday") |
| | | @ApiOperation(value = "查看详情每日冥想库管理", notes = "管理后台-每日冥想库管理") |
| | | @ApiOperation(value = "查看详情每日冥想库管理", tags = "管理后台-每日冥想库管理") |
| | | public R<MeditationEveryday> detailMeditationEveryday(String uid) { |
| | | return R.ok(meditationEverydayService.getById(uid)); |
| | | } |
| | | @PostMapping("/updateMeditationEveryday") |
| | | @ApiOperation(value = "修改每日冥想库管理", notes = "管理后台-每日冥想库管理") |
| | | @ApiOperation(value = "修改每日冥想库管理", tags = "管理后台-每日冥想库管理") |
| | | public R updateMeditationEveryday(@RequestBody MeditationEveryday homeBackgroundMusic) { |
| | | homeBackgroundMusic.setUpdateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setUpdateTime(LocalDateTime.now()); |
| | | return R.ok(meditationEverydayService.updateById(homeBackgroundMusic)); |
| | | } |
| | | @PostMapping("/deleteMeditationEveryday") |
| | | @ApiOperation(value = "批量删除", notes = "管理后台-每日冥想库管理") |
| | | @ApiOperation(value = "批量删除", tags = "管理后台-每日冥想库管理") |
| | | public R deleteMeditationEveryday(String ids) { |
| | | return R.ok(meditationEverydayService.removeBatchByIds(Arrays.asList(ids.split(",")))); |
| | | return R.ok(meditationEverydayService.removeBatchByIds(Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList()))); |
| | | } |
| | | } |
| | | |
| | |
| | | package com.xinquan.meditation.controller.client; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.cache.manager.IFileLoader; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xinquan.common.core.domain.R; |
| | |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @ApiOperation(value = "冥想馆列表-分页", tags = {"管理后台-冥想馆管理"}) |
| | | public R<PageDTO<MeditationHall>> meditationCategoryManagementList(@RequestBody MeditationHallDTO dto) { |
| | | LambdaQueryWrapper<MeditationHall> meditationLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | meditationLambdaQueryWrapper.like(MeditationHall::getHallName, dto.getHallName()); |
| | | meditationLambdaQueryWrapper.like(MeditationHall::getAddress, dto.getAddress()); |
| | | if (StringUtils.hasLength(dto.getHallName())){ |
| | | meditationLambdaQueryWrapper.like(MeditationHall::getHallName, dto.getHallName()); |
| | | |
| | | } |
| | | if (StringUtils.hasLength(dto.getAddress())) { |
| | | meditationLambdaQueryWrapper.like(MeditationHall::getAddress, dto.getAddress()); |
| | | } |
| | | meditationLambdaQueryWrapper.orderByDesc(MeditationHall::getCreateTime); |
| | | Page<MeditationHall> page = meditationHallService.page(new Page<>(dto.getPageCurr(), dto.getPageSize()), meditationLambdaQueryWrapper); |
| | | if (CollUtils.isEmpty(page.getRecords())) { |
| | |
| | | return R.ok(PageDTO.of(page, MeditationHall.class)); |
| | | } |
| | | @PostMapping("/addMeditationHall") |
| | | @ApiOperation(value = "新增冥想馆管理", notes = "管理后台-冥想馆管理") |
| | | @ApiOperation(value = "新增冥想馆管理", tags = "管理后台-冥想馆管理") |
| | | public R addMeditationHall(@RequestBody MeditationHall homeBackgroundMusic) { |
| | | homeBackgroundMusic.setCreateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setCreateTime(LocalDateTime.now()); |
| | | return R.ok(meditationHallService.save(homeBackgroundMusic)); |
| | | } |
| | | @GetMapping("/updateState") |
| | | @ApiOperation(value = "修改课程上下架状态", notes = "管理后台-课程管理") |
| | | @ApiOperation(value = "修改冥想馆上下架状态", tags = "管理后台-冥想馆管理") |
| | | public R updateState(String uid) { |
| | | MeditationHall byId = meditationHallService.getById(uid); |
| | | if (byId.getListingStatus() == 1){ |
| | |
| | | }else { |
| | | byId.setListingStatus(1); |
| | | } |
| | | meditationHallService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | @GetMapping("/detailMeditationHall") |
| | | @ApiOperation(value = "查看详情冥想馆管理", notes = "管理后台-冥想馆管理") |
| | | @ApiOperation(value = "查看详情冥想馆管理", tags = "管理后台-冥想馆管理") |
| | | public R<MeditationHall> detailMeditationHall(String uid) { |
| | | return R.ok(meditationHallService.getById(uid)); |
| | | } |
| | | @PostMapping("/updateMeditationHall") |
| | | @ApiOperation(value = "修改冥想馆管理", notes = "管理后台-冥想馆管理") |
| | | @ApiOperation(value = "修改冥想馆管理", tags = "管理后台-冥想馆管理") |
| | | public R updateMeditationHall(@RequestBody MeditationHall homeBackgroundMusic) { |
| | | homeBackgroundMusic.setUpdateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setUpdateTime(LocalDateTime.now()); |
| | | return R.ok(meditationHallService.updateById(homeBackgroundMusic)); |
| | | } |
| | | @PostMapping("/deleteMeditationHall") |
| | | @ApiOperation(value = "批量删除", notes = "管理后台-冥想馆管理") |
| | | @ApiOperation(value = "批量删除", tags = "管理后台-冥想馆管理") |
| | | public R deleteMeditationHall(String ids) { |
| | | return R.ok(meditationHallService.removeBatchByIds(Arrays.asList(ids.split(",")))); |
| | | return R.ok(meditationHallService.removeBatchByIds(Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList()))); |
| | | } |
| | | } |
| | | |
| | |
| | | package com.xinquan.meditation.controller.client; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.WebUtils; |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.meditation.api.domain.Meditation; |
| | | import com.xinquan.meditation.api.domain.dto.MeditationQuestionDTO; |
| | | import com.xinquan.meditation.domain.MeditationCategory; |
| | | import com.xinquan.meditation.domain.export.QuestionExport; |
| | | import com.xinquan.meditation.service.MeditationCategoryService; |
| | | import com.xinquan.meditation.service.MeditationQuestionService; |
| | | import com.xinquan.meditation.service.MeditationQuestionService; |
| | |
| | | import com.xinquan.system.api.domain.AppUser; |
| | | import com.xinquan.system.api.domain.MeditationQuestion; |
| | | import com.xinquan.meditation.api.domain.vo.NoticeDetailVO; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.user.api.domain.dto.OrderListDTO; |
| | | import com.xinquan.user.api.feign.RemoteAppUserService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | |
| | | @Resource |
| | | private RemoteAppUserService remoteAppUserService; |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | /** |
| | | * 远程调用 查询待回复内容数量 |
| | | * @return |
| | | */ |
| | | @PostMapping("/getQuestionCount") |
| | | public R<String> getQuestionCount() { |
| | | List<MeditationQuestion> list = meditationQuestionService.lambdaQuery() |
| | | .isNull(MeditationQuestion::getReplyContent).list(); |
| | | return R.ok(list.size()+""); |
| | | } |
| | | /** |
| | | * 远程调用 查询回复通知消息内容 |
| | | * @return |
| | | */ |
| | | @PostMapping("/noticeDetail") |
| | | public R<NoticeDetailVO> noticeDetail(NoticeDetailVO req) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | MeditationQuestion byId = meditationQuestionService.getById(req.getMeditationQuestionId()); |
| | | if (byId!=null){ |
| | | Meditation byId1 = meditationService.getById(byId.getMeditationId()); |
| | |
| | | return R.ok(req); |
| | | } |
| | | |
| | | @ApiOperation(value = "提问列表管理导出", tags = {"管理后台-提问管理"}) |
| | | @PutMapping("/export") |
| | | public void export(@RequestBody MeditationQuestionDTO dto) |
| | | { |
| | | LambdaQueryWrapper<MeditationQuestion> meditationLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.hasLength(dto.getIds())){ |
| | | meditationLambdaQueryWrapper.in(MeditationQuestion::getId, Arrays.asList(dto.getIds().split(","))); |
| | | } |
| | | meditationLambdaQueryWrapper.eq(dto.getShowFlag()!=null,MeditationQuestion::getShowFlag, dto.getShowFlag()); |
| | | if (dto.getIsReplay()!=null){ |
| | | if (dto.getIsReplay() == 1){ |
| | | meditationLambdaQueryWrapper.isNotNull(MeditationQuestion::getReplyTime); |
| | | }else{ |
| | | meditationLambdaQueryWrapper.isNull(MeditationQuestion::getReplyTime); |
| | | } |
| | | } |
| | | if (StringUtils.hasLength(dto.getUserName())){ |
| | | List<Long> data = remoteAppUserService.getAppUserByName(dto.getUserName()).getData(); |
| | | if (data.isEmpty()){ |
| | | data.add(-1L); |
| | | } |
| | | meditationLambdaQueryWrapper.in(MeditationQuestion::getAppUserId,data); |
| | | } |
| | | if (StringUtils.hasLength(dto.getName())){ |
| | | List<Long> collect = meditationService.lambdaQuery() |
| | | .like(Meditation::getMeditationTitle, dto.getName()) |
| | | .list().stream().map(Meditation::getId).collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | meditationLambdaQueryWrapper.in(MeditationQuestion::getMeditationId,collect); |
| | | } |
| | | meditationLambdaQueryWrapper.orderByDesc(MeditationQuestion::getCreateTime); |
| | | List<MeditationQuestion> page = meditationQuestionService.list(meditationLambdaQueryWrapper); |
| | | List<QuestionExport> questionExports = new ArrayList<>(); |
| | | for (MeditationQuestion record : page) { |
| | | record.setUid(record.getId()+""); |
| | | AppUser data = remoteAppUserService.getAppUserById(record.getAppUserId().toString()).getData(); |
| | | |
| | | Meditation byId = meditationService.getById(record.getMeditationId()); |
| | | |
| | | QuestionExport questionExport = new QuestionExport(); |
| | | if (byId!=null){ |
| | | record.setMeditationName(byId.getMeditationTitle()); |
| | | questionExport.setName(byId.getMeditationTitle()); |
| | | } |
| | | if (data!=null){ |
| | | record.setUserName(data.getNickname()); |
| | | record.setAvatar(data.getAvatar()); |
| | | record.setCellPhone(data.getCellPhone()); |
| | | questionExport.setUserName(data.getNickname()); |
| | | questionExport.setCellphone(data.getCellPhone()); |
| | | } |
| | | questionExport.setContent(record.getContent()); |
| | | DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | String format = df.format(record.getCreateTime()); |
| | | if (record.getReplyTime()!=null){ |
| | | String format1 = df.format(record.getReplyTime()); |
| | | questionExport.setReplayTime(format1); |
| | | } |
| | | questionExport.setCreateTime(format); |
| | | questionExport.setReplayContent(record.getReplyContent()); |
| | | |
| | | questionExport.setLikeCount(record.getLikeCount()+""); |
| | | questionExport.setShowFlag(record.getShowFlag()+""); |
| | | questionExports.add(questionExport); |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), QuestionExport.class, questionExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("提问管理管理导出.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | @PostMapping("/meditationQuestionManagementList") |
| | | @ApiOperation(value = "提问列表-分页", tags = {"管理后台-提问管理"}) |
| | | public R<PageDTO<MeditationQuestion>> meditationQuestionManagementList(@RequestBody MeditationQuestionDTO dto) { |
| | |
| | | } |
| | | Meditation byId = meditationService.getById(record.getMeditationId()); |
| | | if (byId!=null){ |
| | | record.setChargeType(byId.getChargeType()); |
| | | record.setMeditationName(byId.getMeditationTitle()); |
| | | if (byId.getChargeType()!=null &&byId.getChargeType() == 3){ |
| | | record.setMoney(byId.getGeneralPrice()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | return R.ok(PageDTO.of(page, MeditationQuestion.class)); |
| | | } |
| | | @PostMapping("/addMeditationQuestion") |
| | | @ApiOperation(value = "新增提问管理", notes = "管理后台-提问管理") |
| | | @ApiOperation(value = "新增提问管理", tags = "管理后台-提问管理") |
| | | public R addMeditationQuestion(@RequestBody MeditationQuestion homeBackgroundMusic) { |
| | | homeBackgroundMusic.setCreateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setCreateTime(LocalDateTime.now()); |
| | | return R.ok(meditationQuestionService.save(homeBackgroundMusic)); |
| | | } |
| | | @GetMapping("/updateState") |
| | | @ApiOperation(value = "修改提问显示状态", notes = "管理后台-提问管理") |
| | | @ApiOperation(value = "修改提问显示状态", tags = "管理后台-提问管理") |
| | | public R updateState(String uid) { |
| | | MeditationQuestion byId = meditationQuestionService.getById(uid); |
| | | if (byId.getShowFlag() == 1){ |
| | |
| | | }else { |
| | | byId.setShowFlag(1); |
| | | } |
| | | meditationQuestionService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | @GetMapping("/detailMeditationQuestion") |
| | | @ApiOperation(value = "查看详情提问管理", notes = "管理后台-提问管理") |
| | | @ApiOperation(value = "查看详情提问管理", tags = "管理后台-提问管理") |
| | | public R<MeditationQuestion> detailMeditationQuestion(String uid) { |
| | | MeditationQuestion byId = meditationQuestionService.getById(uid); |
| | | AppUser data = remoteAppUserService.getAppUserById(byId.getAppUserId().toString()).getData(); |
| | |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/updateMeditationQuestion") |
| | | @ApiOperation(value = "修改提问管理", notes = "管理后台-提问管理") |
| | | @ApiOperation(value = "修改提问管理", tags = "管理后台-提问管理") |
| | | public R updateMeditationQuestion(@RequestBody MeditationQuestion homeBackgroundMusic) { |
| | | homeBackgroundMusic.setUpdateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setUpdateTime(LocalDateTime.now()); |
| | | return R.ok(meditationQuestionService.updateById(homeBackgroundMusic)); |
| | | } |
| | | @PostMapping("/deleteMeditationQuestion") |
| | | @ApiOperation(value = "批量删除", notes = "管理后台-提问管理") |
| | | @ApiOperation(value = "批量删除", tags = "管理后台-提问管理") |
| | | public R deleteMeditationQuestion(String ids) { |
| | | return R.ok(meditationQuestionService.removeBatchByIds(Arrays.asList(ids.split(",")))); |
| | | return R.ok(meditationQuestionService.removeBatchByIds(Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList()))); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | |
| | | MeditationQuestion byId1 = meditationQuestionService.getById(record.getQuestionId()); |
| | | if (byId1!=null){ |
| | | record.setContent(byId1.getContent()); |
| | | LocalDateTime replyTime = byId1.getCreateTime(); |
| | | record.setContentTime(replyTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | AppUser data = remoteAppUserService.getAppUserById(byId1.getAppUserId().toString()).getData(); |
| | | if (data!=null){ |
| | | record.setUserName(data.getNickname()); |
| | |
| | | |
| | | |
| | | @GetMapping("/detailMeditationReportQuestion") |
| | | @ApiOperation(value = "查看详情提问举报管理", notes = "管理后台-提问举报管理") |
| | | @ApiOperation(value = "查看详情提问举报管理", tags = "管理后台-提问举报管理") |
| | | public R<MeditationReport> detailMeditationReport(String uid) { |
| | | MeditationReport byId = meditationReportService.getById(uid); |
| | | MeditationQuestion byId3 = meditationQuestionService.getById(byId.getQuestionId()); |
| | |
| | | } |
| | | |
| | | @PostMapping("/deleteMeditationReportQuestion") |
| | | @ApiOperation(value = "批量删除", notes = "管理后台-提问举报管理") |
| | | @ApiOperation(value = "批量删除", tags = "管理后台-提问举报管理") |
| | | public R deleteMeditationReport(String ids) { |
| | | return R.ok(meditationReportService.removeBatchByIds(Arrays.asList(ids.split(",")))); |
| | | return R.ok(meditationReportService.removeBatchByIds(Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList()))); |
| | | } |
| | | } |
| | | |
| | |
| | | @ApiModelProperty(value = "背景图片") |
| | | @TableField("image_url") |
| | | private String imageUrl; |
| | | @ApiModelProperty(value = "背景名称") |
| | | @TableField("name") |
| | | private String name; |
| | | @ApiModelProperty(value = "uid") |
| | | @TableField(exist = false) |
| | | private String uid; |
| | |
| | | @ApiModelProperty(value = "冥想id") |
| | | @TableField("meditation_id") |
| | | private Long meditationId; |
| | | @ApiModelProperty(value = "冥想标题") |
| | | @TableField(exist = false) |
| | | private String meditationTitle; |
| | | @ApiModelProperty(value = "uid") |
| | | @TableField(exist = false) |
| | | private String uid; |
| | |
| | | @ApiModelProperty(value = "详情轮播图 使用,隔开") |
| | | @TableField("detail_banner_url") |
| | | private String detailBannerUrl; |
| | | @ApiModelProperty(value = "详情轮播图文件名称 使用,隔开") |
| | | @TableField("detail_banner_name") |
| | | private String detailBannerName; |
| | | |
| | | @ApiModelProperty(value = "冥想馆地址") |
| | | @TableField("address") |
| | |
| | | |
| | | @ApiModelProperty(value = "冥想馆地址经度") |
| | | @TableField("longitude") |
| | | private Double longitude; |
| | | private String longitude; |
| | | |
| | | @ApiModelProperty(value = "冥想馆课程地址纬度") |
| | | @TableField("latitude") |
| | | private Double latitude; |
| | | private String latitude; |
| | | |
| | | @ApiModelProperty(value = "简介") |
| | | @TableField("brief_introduction") |
| | |
| | | @ApiModelProperty(value = "id") |
| | | @TableId(value = "id",type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "冥想音频id") |
| | | @TableField("meditation_id") |
| | | private Long meditationId; |
| | | |
| | | @ApiModelProperty(value = "音频文件") |
| | | @TableField("music_url") |
| | | private String musicUrl; |
| | | @ApiModelProperty(value = "音频文件名称") |
| | | @TableField("name") |
| | | private String name; |
| | | @ApiModelProperty(value = "音频文件内存大小") |
| | | @TableField("music_size") |
| | | private String musicSize; |
| | | @ApiModelProperty(value = "音频文件时长 单位秒") |
| | | @TableField("music_second") |
| | | private Integer musicSecond; |
| | | |
| | | |
| | | } |
| | |
| | | package com.xinquan.meditation.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import java.io.Serializable; |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "id") |
| | | @TableId("id") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "冥想id") |
| | |
| | | * @since 2024-08-21 |
| | | */ |
| | | @Data |
| | | @TableName("t_meditation_user_operation") |
| | | @TableName("t_meditation_user_favorite") |
| | | @ApiModel(value="MeditationUserOperation对象", description="冥想用户操作表") |
| | | public class MeditationUserFavorite implements Serializable { |
| | | |
New file |
| | |
| | | package com.xinquan.meditation.domain.export; |
| | | |
| | | import cn.afterturn.easypoi.excel.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @ApiModel(value = "冥想音频管理-导出") |
| | | public class MeditationExport implements Serializable { |
| | | |
| | | @Excel(name = "关联疗愈",width = 30) |
| | | private String name; |
| | | @Excel(name = "所属分类",width = 30) |
| | | private String categoryName; |
| | | @Excel(name = "描述文案",width = 30) |
| | | private String detailDescription; |
| | | @Excel(name = "价格",width = 30) |
| | | private String generalPrice; |
| | | @Excel(name = "上架状态",width = 30,replace = {"上架_1","下架_2"}) |
| | | private String listingStatus; |
| | | @Excel(name = "学习人数",width = 30) |
| | | private String realLearnedNum; |
| | | @Excel(name = "收藏人数",width = 30) |
| | | private String collectCount; |
| | | @Excel(name = "添加时间",width = 30) |
| | | private String createTime; |
| | | |
| | | } |
New file |
| | |
| | | package com.xinquan.meditation.domain.export; |
| | | |
| | | import cn.afterturn.easypoi.excel.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @ApiModel(value = "提问管理-导出") |
| | | public class QuestionExport implements Serializable { |
| | | |
| | | @Excel(name = "关联疗愈",width = 30) |
| | | private String name; |
| | | @Excel(name = "用户昵称",width = 30) |
| | | private String userName; |
| | | @Excel(name = "用户手机号",width = 30) |
| | | private String cellphone; |
| | | @Excel(name = "提问内容",width = 30) |
| | | private String content; |
| | | @Excel(name = "提问时间",width = 30) |
| | | private String createTime; |
| | | @Excel(name = "回复内容",width = 30) |
| | | private String replayContent; |
| | | @Excel(name = "回复时间",width = 30) |
| | | private String replayTime; |
| | | @Excel(name = "点赞数",width = 30) |
| | | private String likeCount; |
| | | @Excel(name = "是否显示",width = 30,replace = {"是_1","否_2"}) |
| | | private String showFlag; |
| | | } |
| | |
| | | |
| | | @ApiModelProperty(value = "是否收藏 1:是 2:否") |
| | | private Integer favorite; |
| | | @ApiModelProperty(value = "是否购买 0否1是") |
| | | private Integer isBuy; |
| | | |
| | | @ApiModelProperty(value = "提问数") |
| | | private Long questionCount; |
| | | @ApiModelProperty(value = "当前用户是否为会员") |
| | | private Integer isVip; |
| | | } |
| | |
| | | * @return 客户端冥想详情视图对象 |
| | | */ |
| | | ClientMeditationDetailsVO getMeditationDetails(Long id); |
| | | ClientMeditationDetailsVO getMeditationDetails1(Long id); |
| | | |
| | | /** |
| | | * 获取冥想音频提问列表-分页 |
| | |
| | | */ |
| | | PageDTO<ClientMeditationQuestionVO> getMeditationQuestionPage(Long id, |
| | | Integer pageCurr, Integer pageSize); |
| | | PageDTO<ClientMeditationQuestionVO> getMeditationQuestionPageShare(Long id, |
| | | Integer pageCurr, Integer pageSize); |
| | | |
| | | /** |
| | | * 收藏/取消收藏 |
| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xinquan.common.core.constant.SecurityConstants; |
| | | import com.xinquan.common.core.utils.page.BeanUtils; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.meditation.domain.HomeBackgroundMusic; |
| | | import com.xinquan.meditation.domain.vo.ClientHomeBackgroundMusicVO; |
| | | import com.xinquan.meditation.mapper.HomeBackgroundMusicMapper; |
| | | import com.xinquan.meditation.service.HomeBackgroundMusicService; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.user.api.domain.dto.AppUserDTO; |
| | | import com.xinquan.user.api.feign.RemoteAppUserService; |
| | | import java.util.List; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | |
| | | .orderByDesc(HomeBackgroundMusic::getSortNum).list(); |
| | | return BeanUtils.copyList(list, ClientHomeBackgroundMusicVO.class); |
| | | } |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | /** |
| | | * 保存用户首页背景音乐设置 |
| | | * |
| | |
| | | */ |
| | | @Override |
| | | public void savePersonalitySetting(Long id) { |
| | | // 获取当前登录用户id |
| | | Long userId = SecurityUtils.getUserId(); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return ; |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | |
| | | // 远程调用修改用户信息 |
| | | remoteAppUserService.updateAppUser( |
| | | AppUserDTO.builder() |
| | |
| | | import com.xinquan.meditation.mapper.MeditationEverydayMapper; |
| | | import com.xinquan.meditation.mapper.MeditationMapper; |
| | | import com.xinquan.meditation.service.MeditationEverydayService; |
| | | |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | // 查询播放时间段在当前时间的每日冥想 |
| | | Optional<MeditationEveryday> meditationEverydayOpt = this.lambdaQuery() |
| | | .le(MeditationEveryday::getStartPlayTime, now) |
| | | .gt(MeditationEveryday::getEndPlayTime, now) |
| | | .ge(MeditationEveryday::getEndPlayTime, now) |
| | | .orderByDesc(MeditationEveryday::getUpdateTime) |
| | | .last("limit 1").oneOpt(); |
| | | if (!meditationEverydayOpt.isPresent()) { |
| | |
| | | package com.xinquan.meditation.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.enums.ReportStatusEnum; |
| | | import com.xinquan.common.core.exception.ServiceException; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.meditation.mapper.MeditationReportMapper; |
| | | import com.xinquan.meditation.service.MeditationReportService; |
| | |
| | | import java.util.Optional; |
| | | |
| | | import com.xinquan.system.api.domain.MeditationReport; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Autowired |
| | | private MeditationReportMapper meditationReportMapper; |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | /** |
| | | * 举报提问 |
| | | * |
| | |
| | | */ |
| | | @Override |
| | | public void report(Long id, String content) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return; |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | MeditationQuestion meditationQuestion = this.getById(id); |
| | | if (Optional.ofNullable(meditationQuestion).isPresent()) { |
| | | meditationQuestion.setReportStatus(2); |
| | |
| | | meditationReport.setMeditationId(meditationQuestion.getMeditationId()); |
| | | meditationReport.setQuestionId(meditationQuestion.getId()); |
| | | meditationReport.setReportContent(content); |
| | | meditationReport.setReportUserId(SecurityUtils.getUserId()); |
| | | meditationReport.setReportUserId(userId); |
| | | meditationReport.setCreateTime(LocalDateTime.now()); |
| | | meditationReportMapper.insert(meditationReport); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public void likeQuestion(Long id) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return ; |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | |
| | | MeditationQuestion meditationQuestion = this.getById(id); |
| | | if (Objects.isNull(meditationQuestion)) { |
| | | throw new ServiceException("提问不存在"); |
| | |
| | | // 判断是否已点赞 |
| | | Optional<MeditationQuestionLike> likeOpt = meditationQuestionLikeService.lambdaQuery() |
| | | .eq(MeditationQuestionLike::getMeditationQuestionId, id) |
| | | .eq(MeditationQuestionLike::getAppUserId, SecurityUtils.getUserId()).last("limit 1") |
| | | .eq(MeditationQuestionLike::getAppUserId, userId).last("limit 1") |
| | | .oneOpt(); |
| | | if (likeOpt.isPresent()) { |
| | | // 已点赞则取消点赞 |
| | |
| | | } else { |
| | | // 未点赞则点赞 |
| | | MeditationQuestionLike meditationQuestionLike = new MeditationQuestionLike(); |
| | | meditationQuestionLike.setAppUserId(SecurityUtils.getUserId()); |
| | | meditationQuestionLike.setAppUserId(userId); |
| | | meditationQuestionLike.setMeditationQuestionId(id); |
| | | if (meditationQuestionLikeService.save(meditationQuestionLike)) { |
| | | meditationQuestion.setLikeCount(meditationQuestion.getLikeCount() + 1); |
| | |
| | | package com.xinquan.meditation.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xinquan.common.core.constant.SecurityConstants; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.enums.DisabledEnum; |
| | | import com.xinquan.common.core.enums.OrderFromEnum; |
| | | import com.xinquan.common.core.exception.ServiceException; |
| | |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.core.web.page.PageInfo; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.meditation.api.domain.Meditation; |
| | | import com.xinquan.meditation.domain.*; |
| | | import com.xinquan.meditation.domain.vo.ClientMeditationAndCateVO; |
| | |
| | | import com.xinquan.order.api.feign.RemoteOrderService; |
| | | import com.xinquan.system.api.domain.AppUser; |
| | | import com.xinquan.system.api.domain.MeditationQuestion; |
| | | import com.xinquan.system.api.domain.vo.AppUserVO; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.user.api.domain.dto.AppUserDTO; |
| | | import com.xinquan.user.api.feign.RemoteAppUserService; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.Optional; |
| | | import java.util.Set; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public List<ClientMeditationVO> getPersonalityPlan() { |
| | | List<ClientMeditationVO> voList = null; |
| | | List<ClientMeditationVO> voList = new ArrayList<>(); |
| | | // 获取当前登录用户id |
| | | AppUser appUser = getCurrentUser(); |
| | | if (Optional.ofNullable(appUser.getTagId()).isPresent()) { |
| | | String tagId = appUser.getTagId(); |
| | | Integer sanskritFlag = appUser.getSanskritFlag(); |
| | | Set<Long> tagIdSet = Arrays.stream(tagId.split(",")).map(Long::parseLong) |
| | | .collect(Collectors.toSet()); |
| | | // 查询冥想列表 |
| | | voList = baseMapper.getMeditationListByTagId(tagIdSet, sanskritFlag); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser!=null){ |
| | | Long userid = loginUser.getUserid(); |
| | | AppUser appUser = remoteAppUserService.getAppUserById(userid + "").getData(); |
| | | if (appUser!=null){ |
| | | Integer sanskritFlag = appUser.getSanskritFlag(); |
| | | if (StringUtils.hasLength(appUser.getTagId())) { |
| | | String tagId = appUser.getTagId(); |
| | | Set<Long> tagIdSet = Arrays.stream(tagId.split(",")).map(Long::parseLong) |
| | | .collect(Collectors.toSet()); |
| | | // 查询冥想列表 |
| | | voList = baseMapper.getMeditationListByTagId(tagIdSet, sanskritFlag); |
| | | }else{ |
| | | Set<Long> longs = new HashSet<>(); |
| | | voList = baseMapper.getMeditationListByTagId(longs, sanskritFlag); |
| | | } |
| | | }else{ |
| | | voList = baseMapper.getMeditationListByTagId(null, null); |
| | | } |
| | | voList = handlePaidMeditation(voList); |
| | | return voList; |
| | | }else{ |
| | | voList = baseMapper.getMeditationListByTagId(null, null); |
| | | return voList; |
| | | } |
| | | voList = handlePaidMeditation(voList); |
| | | return voList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 处理已付费冥想音频 |
| | | * |
| | |
| | | */ |
| | | private List<ClientMeditationVO> handlePaidMeditation(List<ClientMeditationVO> voList) { |
| | | // 远程调用订单服务,查询用户已付费冥想 |
| | | Long userId = SecurityUtils.getUserId(); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return new ArrayList<>(); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | List<Order> orderList = remoteOrderService.getOrderListByType(userId, |
| | | OrderFromEnum.MEDITATION.getCode(), |
| | | SecurityConstants.INNER).getData(); |
| | |
| | | */ |
| | | @Override |
| | | public List<ClientMeditationVO> getMeditationListByCateId(Long cateId) { |
| | | List<ClientMeditationVO> voList = null; |
| | | List<ClientMeditationVO> voList = new ArrayList<>(); |
| | | // 获取当前登录用户id |
| | | AppUser appUser = getCurrentUser(); |
| | | // 查询 |
| | | List<Meditation> list = this.lambdaQuery().eq(Meditation::getCateId, cateId) |
| | | .eq(Meditation::getSanskrit, appUser.getSanskritFlag()) |
| | | .orderByDesc(Meditation::getSortNum).last("limit 8").list(); |
| | | LambdaQueryWrapper<Meditation> meditationLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | meditationLambdaQueryWrapper.eq(Meditation::getCateId, cateId); |
| | | if (appUser!=null){ |
| | | meditationLambdaQueryWrapper.eq(Meditation::getSanskrit, appUser.getSanskritFlag()); |
| | | meditationLambdaQueryWrapper.orderByDesc(Meditation::getSortNum).last("limit 8"); |
| | | } |
| | | List<Meditation> list =this.list(meditationLambdaQueryWrapper); |
| | | |
| | | if (CollUtils.isNotEmpty(list)) { |
| | | // 对象拷贝 |
| | | voList = BeanUtils.copyList(list, ClientMeditationVO.class); |
| | |
| | | * @return AppUser |
| | | */ |
| | | private AppUser getCurrentUser() { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | return remoteAppUserService.getUserByCondition( |
| | | AppUserDTO.builder().id(userId).build(), |
| | | SecurityConstants.INNER).getData(); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser!=null){ |
| | | Long userid = loginUser.getUserid(); |
| | | return remoteAppUserService.getUserByCondition( |
| | | AppUserDTO.builder().id(userid).build(), |
| | | SecurityConstants.INNER).getData(); |
| | | }else{ |
| | | return remoteAppUserService.getUserByCondition( |
| | | AppUserDTO.builder().id(0L).build(), |
| | | SecurityConstants.INNER).getData(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public List<ClientMeditationAndCateVO> getMeditationAndCateList() { |
| | | // 获取当前登录用户 |
| | | AppUser appUser = getCurrentUser(); |
| | | List<ClientMeditationAndCateVO> voList = CollUtils.newArrayList(); |
| | | // 查询分类列表 |
| | | List<MeditationCategory> cateList = meditationCategoryMapper.selectList( |
| | | Wrappers.lambdaQuery(MeditationCategory.class) |
| | | .orderByDesc(MeditationCategory::getSortNum)); |
| | | if (CollUtils.isNotEmpty(cateList)) { |
| | | for (MeditationCategory cate : cateList) { |
| | | ClientMeditationAndCateVO vo = new ClientMeditationAndCateVO(); |
| | | vo.setClientMeditationCategoryVO( |
| | | BeanUtils.copyBean(cateList, ClientMeditationCategoryVO.class)); |
| | | BeanUtils.copyBean(cate, ClientMeditationCategoryVO.class)); |
| | | vo.setClientMeditationVOList(getMeditationListByCateId(cate.getId())); |
| | | voList.add(vo); |
| | | } |
| | | } |
| | | return voList; |
| | | } |
| | | |
| | |
| | | PageDTO<ClientMeditationVO> pageDTO = PageDTO.empty(0L, 0L); |
| | | // 获取当前登录用户id |
| | | AppUser appUser = getCurrentUser(); |
| | | // 查询 |
| | | Page<Meditation> page = this.lambdaQuery().eq(Meditation::getCateId, cateId) |
| | | .eq(Meditation::getSanskrit, appUser.getSanskritFlag()) |
| | | .orderByDesc(Meditation::getSortNum) |
| | | .page(new Page<>(pageCurr, pageSize)); |
| | | LambdaQueryWrapper<Meditation> meditationLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | meditationLambdaQueryWrapper.eq(Meditation::getCateId, cateId); |
| | | if (appUser!=null){ |
| | | meditationLambdaQueryWrapper.eq(Meditation::getSanskrit, appUser.getSanskritFlag()); |
| | | } |
| | | meditationLambdaQueryWrapper.orderByDesc(Meditation::getSortNum); |
| | | Page<Meditation> page = this.page(new Page<>(pageCurr, pageSize), meditationLambdaQueryWrapper); |
| | | // 如果没有查到数据直接返回 |
| | | if (Optional.ofNullable(page.getRecords()).isPresent()) { |
| | | if (page.getRecords().isEmpty()) { |
| | | return pageDTO; |
| | | } |
| | | // 将实体类转换为VO |
| | |
| | | return pageDTO; |
| | | } |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | /** |
| | | * 首页搜索首页 |
| | | * |
| | |
| | | Integer pageSize) { |
| | | PageDTO<ClientMeditationVO> pageDTO = PageDTO.empty(0L, 0L); |
| | | // 获取当前登录用户id |
| | | AppUser appUser = getCurrentUser(); |
| | | // 查询 |
| | | Page<Meditation> page = this.lambdaQuery() |
| | | .like(Meditation::getMeditationTitle, condition).or() |
| | | .eq(Meditation::getSanskrit, appUser.getSanskritFlag()) |
| | | .orderByDesc(Meditation::getSortNum) |
| | | .page(new Page<>(pageCurr, pageSize)); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser!=null){ |
| | | Long userid = loginUser.getUserid(); |
| | | } |
| | | LambdaQueryWrapper<Meditation> meditationLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | meditationLambdaQueryWrapper.like(Meditation::getMeditationTitle, condition); |
| | | if (loginUser!=null){ |
| | | Long userid = loginUser.getUserid(); |
| | | AppUser appUser = remoteAppUserService.getAppUserById(userid + "").getData(); |
| | | meditationLambdaQueryWrapper.eq(Meditation::getSanskrit, appUser.getSanskritFlag()); |
| | | } |
| | | meditationLambdaQueryWrapper.like(Meditation::getMeditationTitle, condition); |
| | | meditationLambdaQueryWrapper.orderByDesc(Meditation::getSortNum); |
| | | Page<Meditation> page = this.page(new Page<>(pageCurr, pageSize), meditationLambdaQueryWrapper); |
| | | // 如果没有查到数据直接返回 |
| | | if (Optional.ofNullable(page.getRecords()).isPresent()) { |
| | | if (!Optional.ofNullable(page.getRecords()).isPresent()) { |
| | | return pageDTO; |
| | | } |
| | | // 音频链接加密 |
| | |
| | | */ |
| | | @Override |
| | | public ClientMeditationDetailsVO getMeditationDetails(Long id) { |
| | | AppUserVO data1 = remoteAppUserService.getCurrentUser().getData(); |
| | | |
| | | |
| | | // 查询冥想音频 |
| | | Meditation meditation = this.getById(id); |
| | | ClientMeditationDetailsVO vo = BeanUtils.copyBean(meditation, |
| | | ClientMeditationDetailsVO.class); |
| | | if (data1.getVipExpireTime()!=null && data1.getVipExpireTime().isAfter(LocalDateTime.now())){ |
| | | vo.setIsVip(1); |
| | | }else{ |
| | | vo.setIsVip(0); |
| | | } |
| | | Integer data = remoteOrderService.getMeditationIsBuy(data1.getId(), id).getData(); |
| | | vo.setIsBuy(data); |
| | | // 查询冥想音频 |
| | | List<MeditationMusic> meditationMusics = meditationMusicMapper.selectList( |
| | | Wrappers.lambdaQuery(MeditationMusic.class) |
| | | .eq(MeditationMusic::getMeditationId, id)); |
| | | if (CollUtils.isNotEmpty(meditationMusics)) { |
| | | // 获取音频链接 |
| | | List<String> musicUrlList = meditationMusics.stream() |
| | | .map(MeditationMusic::getMusicUrl).collect(Collectors.toList()); |
| | | vo.setMeditationMusicList(musicUrlList); |
| | | } |
| | | // 获取提问数 |
| | | vo.setQuestionCount(meditationQuestionMapper.selectCount( |
| | | Wrappers.lambdaQuery(MeditationQuestion.class) |
| | | .eq(MeditationQuestion::getMeditationId, id))); |
| | | return vo; |
| | | } |
| | | @Override |
| | | public ClientMeditationDetailsVO getMeditationDetails1(Long id) { |
| | | // 查询冥想音频 |
| | | Meditation meditation = this.getById(id); |
| | | ClientMeditationDetailsVO vo = BeanUtils.copyBean(meditation, |
| | |
| | | .map(MeditationMusic::getMusicUrl).collect(Collectors.toList()); |
| | | vo.setMeditationMusicList(musicUrlList); |
| | | } |
| | | // 查询收藏记录 |
| | | vo.setFavorite(meditationUserFavoriteService.lambdaQuery() |
| | | .eq(MeditationUserFavorite::getMeditationId, id) |
| | | .eq(MeditationUserFavorite::getAppUserId, SecurityUtils.getUserId()) |
| | | .count() > 0 ? 1 : 2); |
| | | // 获取提问数 |
| | | vo.setQuestionCount(meditationQuestionMapper.selectCount( |
| | | Wrappers.lambdaQuery(MeditationQuestion.class) |
| | |
| | | // 查询收藏记录 |
| | | Optional<MeditationUserFavorite> userOperationOpt = meditationUserFavoriteService.lambdaQuery() |
| | | .eq(MeditationUserFavorite::getMeditationId, id) |
| | | .eq(MeditationUserFavorite::getAppUserId, SecurityUtils.getUserId()) |
| | | .eq(MeditationUserFavorite::getAppUserId, tokenService.getLoginUser().getUserid()) |
| | | .last("limit 1").oneOpt(); |
| | | if (userOperationOpt.isPresent()) { |
| | | meditationUserFavoriteService.removeById(userOperationOpt.get()); |
| | |
| | | // 增加收藏记录 |
| | | MeditationUserFavorite meditationUserFavorite = new MeditationUserFavorite(); |
| | | meditationUserFavorite.setMeditationId(id); |
| | | meditationUserFavorite.setAppUserId(SecurityUtils.getUserId()); |
| | | meditationUserFavorite.setAppUserId(tokenService.getLoginUser().getUserid()); |
| | | meditationUserFavoriteService.save(meditationUserFavorite); |
| | | // 增加收藏数 |
| | | meditation.setFavoriteCount(meditation.getFavoriteCount() + 1); |
| | |
| | | new Page<>(pageCurr, pageSize), |
| | | Wrappers.lambdaQuery(MeditationQuestion.class) |
| | | .eq(MeditationQuestion::getMeditationId, id) |
| | | .eq(MeditationQuestion::getShowFlag, DisabledEnum.YES) |
| | | .eq(MeditationQuestion::getShowFlag, DisabledEnum.YES.getCode()) |
| | | .orderByDesc(MeditationQuestion::getPublishTime)); |
| | | if (CollUtils.isEmpty(questionPage.getRecords())) { |
| | | return PageDTO.empty(questionPage); |
| | | } |
| | | |
| | | // 将 questionPage 转换为 PageDTO |
| | | PageDTO<ClientMeditationQuestionVO> pageDTO = PageDTO.of( |
| | | questionPage, ClientMeditationQuestionVO.class); |
| | |
| | | } |
| | | |
| | | // 获取当前登录用户ID |
| | | Long userId = SecurityUtils.getUserId(); |
| | | Long userId = tokenService.getLoginUser().getUserid(); |
| | | |
| | | // 查询用户已点赞提问列表 |
| | | Set<Long> likedQuestionIds = meditationQuestionLikeService.lambdaQuery() |
| | |
| | | |
| | | return pageDTO; |
| | | } |
| | | @Override |
| | | public PageDTO<ClientMeditationQuestionVO> getMeditationQuestionPageShare(Long id, |
| | | Integer pageCurr, Integer pageSize) { |
| | | // 查询冥想提问列表 |
| | | Page<MeditationQuestion> questionPage = meditationQuestionMapper.selectPage( |
| | | new Page<>(pageCurr, pageSize), |
| | | Wrappers.lambdaQuery(MeditationQuestion.class) |
| | | .eq(MeditationQuestion::getMeditationId, id) |
| | | .eq(MeditationQuestion::getShowFlag, DisabledEnum.YES.getCode()) |
| | | .orderByDesc(MeditationQuestion::getPublishTime)); |
| | | if (CollUtils.isEmpty(questionPage.getRecords())) { |
| | | return PageDTO.empty(questionPage); |
| | | } |
| | | // 将 questionPage 转换为 PageDTO |
| | | PageDTO<ClientMeditationQuestionVO> pageDTO = PageDTO.of( |
| | | questionPage, ClientMeditationQuestionVO.class); |
| | | List<ClientMeditationQuestionVO> questionVOList = pageDTO.getList(); |
| | | |
| | | // 提取用户ID集合 |
| | | Set<Long> appUserIdSet = questionVOList.stream() |
| | | .map(ClientMeditationQuestionVO::getAppUserId) |
| | | .collect(Collectors.toSet()); |
| | | |
| | | // 远程调用,获取APP用户信息 |
| | | Map<Long, AppUser> appUserMap = Collections.emptyMap(); |
| | | if (!appUserIdSet.isEmpty()) { |
| | | List<AppUser> appUserList = remoteAppUserService.getAppUserList(appUserIdSet, |
| | | SecurityConstants.INNER) |
| | | .getData(); |
| | | appUserMap = appUserList.stream() |
| | | .collect(Collectors.toMap(AppUser::getId, Function.identity())); |
| | | } |
| | | |
| | | // 封装用户信息 |
| | | for (ClientMeditationQuestionVO questionVO : questionVOList) { |
| | | AppUser appUser = appUserMap.get(questionVO.getAppUserId()); |
| | | if (appUser != null) { |
| | | questionVO.setNickname(appUser.getNickname()); |
| | | questionVO.setAvatar(appUser.getAvatar()); |
| | | } |
| | | } |
| | | |
| | | // // 获取当前登录用户ID |
| | | // Long userId = tokenService.getLoginUser().getUserid(); |
| | | // |
| | | // // 查询用户已点赞提问列表 |
| | | // Set<Long> likedQuestionIds = meditationQuestionLikeService.lambdaQuery() |
| | | // .eq(MeditationQuestionLike::getAppUserId, userId) |
| | | // .list() |
| | | // .stream() |
| | | // .map(MeditationQuestionLike::getMeditationQuestionId) |
| | | // .collect(Collectors.toSet()); |
| | | // |
| | | // // 设置问题的点赞状态 |
| | | // questionVOList.forEach(question -> { |
| | | // if (likedQuestionIds.contains(question.getId())) { |
| | | // question.setLike(DisabledEnum.YES.getCode()); |
| | | // } |
| | | // }); |
| | | |
| | | return pageDTO; |
| | | } |
| | | |
| | | } |
| | |
| | | update_time, |
| | | id, cate_id, meditation_title, listing_status, sanskrit, charge_type, sort_num, real_learned_num, virtual_learned_num, icon_url, cover_url, background_url, detail_description, cover_description, tutor_audio_url, like_count, favorite_count |
| | | </sql> |
| | | <select id="getMeditationListByTagId" |
| | | resultType="com.xinquan.meditation.domain.vo.ClientMeditationVO" |
| | | <select id="getMeditationListByTagId" resultType="com.xinquan.meditation.domain.vo.ClientMeditationVO" |
| | | parameterType="java.util.Set"> |
| | | SELECT |
| | | <include refid="Base_Column_List"/> |
| | | m.del_flag, |
| | | m.create_by, |
| | | m.create_time, |
| | | m.update_by, |
| | | m.update_time, |
| | | m.id, m.cate_id, m.meditation_title, m.listing_status, m.sanskrit, m.charge_type, m.sort_num, |
| | | m.real_learned_num, m.virtual_learned_num, m.icon_url, m.cover_url, m.background_url, |
| | | m.detail_description, m.cover_description, m.tutor_audio_url, m.favorite_count |
| | | FROM |
| | | t_meditation m |
| | | RIGHT JOIN t_meditation_tag mt ON m.id = mt.meditation_id |
| | | left JOIN t_meditation_tag mt ON m.id = mt.meditation_id |
| | | <where> |
| | | <if test="sanskritFlag != null and sanskritFlag == 2"> |
| | | AND m.sanskrit = #{sanskritFlag} |
| | | </if> |
| | | <if test="tagIdSet !=null and tagIdSet.size()>0"> |
| | | AND mt.tag_id IN (#{tagIdSet}) |
| | | and mt.tag_id in |
| | | <foreach collection="tagIdSet" item="item" index="index" separator="," open="(" close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | |
| | | </where> |
| | | group by mt.meditation_id |
| | | ORDER BY sort_num DESC |
| | | </select> |
| | | <select id="getMeditationPage" resultType="com.xinquan.meditation.domain.MeditationHall"> |
| | |
| | | POW( |
| | | SIN( |
| | | ( |
| | | #{lat} * PI() / 180 - t1.lat * PI() / 180 |
| | | #{lat} * PI() / 180 - t1.latitude * PI() / 180 |
| | | ) / 2 |
| | | ), |
| | | 2 |
| | | ) + COS(#{lat} * PI() / 180) * COS(t1.lat * PI() / 180) * POW( |
| | | ) + COS(#{lat} * PI() / 180) * COS(t1.latitude * PI() / 180) * POW( |
| | | SIN( |
| | | ( |
| | | #{lon} * PI() / 180 - t1.lon * PI() / 180 |
| | | #{lon} * PI() / 180 - t1.longitude * PI() / 180 |
| | | ) / 2 |
| | | ), |
| | | 2 |
| | |
| | | ) AS distance |
| | | from t_meditation_hall t1 |
| | | where 1=1 |
| | | and t1.status = 1 |
| | | and t1.listing_status = 1 |
| | | and t1.del_flag = 0 |
| | | <if test="name!=null and name!=''"> |
| | | and t1.hall_name like CONCAT('%', #{name}, '%') |
| | |
| | | </properties> |
| | | |
| | | <dependencies> |
| | | |
| | | <dependency> |
| | | <groupId>cn.afterturn</groupId> |
| | | <artifactId>easypoi-spring-boot-starter</artifactId> |
| | | <version>4.0.0</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <artifactId>guava</artifactId> |
| | | <groupId>com.google.guava</groupId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.auth0</groupId> |
| | | <artifactId>java-jwt</artifactId> |
| | | <version>3.4.0</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>net.sf.json-lib</groupId> |
| | | <artifactId>json-lib</artifactId> |
| | | <version>2.4</version> |
| | | <classifier>jdk15</classifier> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>io.jsonwebtoken</groupId> |
| | | <artifactId>jjwt</artifactId> |
| | | <version>0.9.1</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.json</groupId> |
| | | <artifactId>json</artifactId> |
| | | <version>20210307</version> <!-- Replace with the latest version --> |
| | | </dependency> |
| | | <!--user feign模块--> |
| | | <dependency> |
| | | <groupId>com.xinquan</groupId> |
| | |
| | | package com.xinquan.order.controller.client; |
| | | |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.auth0.jwt.JWT; |
| | | import com.auth0.jwt.algorithms.Algorithm; |
| | | import com.auth0.jwt.exceptions.SignatureVerificationException; |
| | | import com.auth0.jwt.interfaces.DecodedJWT; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.sun.corba.se.spi.ior.IdentifiableFactory; |
| | | import com.xinquan.common.core.constant.SecurityConstants; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.page.BeanUtils; |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.core.web.domain.AjaxResult; |
| | | import com.xinquan.common.core.web.domain.BaseModel; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.course.api.domain.CourseChapter; |
| | | import com.xinquan.course.api.feign.RemoteCourseService; |
| | | import com.xinquan.meditation.api.domain.Meditation; |
| | | import com.xinquan.meditation.api.feign.RemoteMeditationService; |
| | | import com.xinquan.order.api.domain.Order; |
| | | import com.xinquan.order.api.domain.vo.PayOrderVO; |
| | | import com.xinquan.order.domain.OrderPaymentRecord; |
| | | import com.xinquan.order.domain.vo.ClientPlaceOrderVO; |
| | | import com.xinquan.order.service.OrderPaymentRecordService; |
| | | import com.xinquan.order.service.OrderService; |
| | | import com.xinquan.course.api.domain.OrderCourseVO; |
| | | import com.xinquan.order.utils.OrderUtil; |
| | | import com.xinquan.system.api.domain.AppUser; |
| | | import com.xinquan.system.api.domain.AppUserCourse; |
| | | import com.xinquan.system.api.domain.AppUserWalletRecord; |
| | | import com.xinquan.system.api.domain.CommissionRule; |
| | | import com.xinquan.system.api.feignClient.SysUserClient; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.user.api.domain.dto.AppUserDTO; |
| | | import com.xinquan.user.api.feign.RemoteAppUserService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.crypto.Cipher; |
| | | import javax.crypto.spec.SecretKeySpec; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.io.*; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.security.PublicKey; |
| | | import java.security.cert.CertificateException; |
| | | import java.security.cert.CertificateFactory; |
| | | import java.security.cert.X509Certificate; |
| | | import java.security.interfaces.ECPublicKey; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private RemoteCourseService remoteCourseService; |
| | | @Resource |
| | | private RemoteMeditationService remoteMeditationService; |
| | | @Resource |
| | | private RemoteAppUserService remoteAppUserService; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @GetMapping("/getMeditationIsBuy/{id}/{meditationId}") |
| | | public R<Integer> getMeditationIsBuy(@PathVariable("id")Long id,@PathVariable("meditationId")Long meditationId) { |
| | | List<Order> list = orderService.lambdaQuery().eq(Order::getBusinessId, meditationId) |
| | | .eq(Order::getOrderFrom, 1) |
| | | .eq(Order::getPaymentStatus, 2) |
| | | .ne(Order::getRefundStatus, 3).list(); |
| | | if (list.isEmpty()){ |
| | | return R.ok(0); |
| | | }else{ |
| | | return R.ok(1); |
| | | } |
| | | } |
| | | @PostMapping("/payOrder") |
| | | @ApiOperation(value = "已购详情-待支付状态-页面数据",tags = "我的已购") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "订单id", dataType = "Long", required = true), |
| | | @ApiImplicitParam(name = "type", value = "1=android 2=ios", dataType = "Integer", required = true), |
| | | }) |
| | | public R<PayOrderVO> payOrder(Long id,Integer type) { |
| | | Order byId = orderService.getById(id); |
| | | PayOrderVO payOrderVO = new PayOrderVO(); |
| | | if (byId==null){ |
| | | return R.fail("订单失效"); |
| | | } |
| | | payOrderVO.setOrderId(id); |
| | | if (byId.getOrderFrom()==1){ |
| | | Meditation data = remoteMeditationService.getMeditationById(byId.getBusinessId()).getData(); |
| | | payOrderVO.setTitle(data.getMeditationTitle()); |
| | | payOrderVO.setOrderFrom(1); |
| | | payOrderVO.setTargetId(data.getId()); |
| | | switch (type){ |
| | | case 1: |
| | | payOrderVO.setAmount(data.getGeneralPrice()); |
| | | break; |
| | | case 2: |
| | | payOrderVO.setAmount(data.getIosPrice()); |
| | | break; |
| | | } |
| | | if (byId.getChangePrice()!=null){ |
| | | payOrderVO.setAmount(payOrderVO.getAmount().add(byId.getChangePrice())); |
| | | } |
| | | }else if (byId.getOrderFrom() == 2){ |
| | | Course data = remoteCourseService.getCourseById(byId.getBusinessId()).getData(); |
| | | payOrderVO.setTitle(data.getCourseTitle()); |
| | | payOrderVO.setTutor(data.getTutor()); |
| | | payOrderVO.setOrderFrom(2); |
| | | payOrderVO.setTargetId(data.getId()); |
| | | switch (type){ |
| | | case 1: |
| | | payOrderVO.setAmount(data.getGeneralPrice()); |
| | | break; |
| | | case 2: |
| | | payOrderVO.setAmount(data.getIosPrice()); |
| | | break; |
| | | } |
| | | if (byId.getChangePrice()!=null){ |
| | | payOrderVO.setAmount(payOrderVO.getAmount().add(byId.getChangePrice())); |
| | | } |
| | | } |
| | | return R.ok(payOrderVO); |
| | | } |
| | | |
| | | @PostMapping("/myOrderCourse") |
| | | @ApiOperation(value = "我的已购",tags = "我的已购") |
| | | @ApiImplicitParams({ |
| | |
| | | @ApiImplicitParam(name = "pageCurr", value = "分页参数,当前页码", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "分页参数,每页数量", dataType = "Integer", required = true) |
| | | }) |
| | | public R<PageDTO<OrderCourseVO>> balanceList(Integer state, Integer pageCurr, Integer pageSize) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | public R<List<OrderCourseVO>> balanceList(Integer state, Integer pageCurr, Integer pageSize) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | Long userId = loginUser.getUserid(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Page<Order> page = orderService.lambdaQuery() |
| | | .eq(Order::getAppUserId, userId) |
| | | .eq(Order::getOrderFrom, state) |
| | | .ne(Order::getPaymentStatus, 3) |
| | | .orderByDesc(BaseModel::getCreateTime).page(new Page<>(pageCurr, pageSize)); |
| | | if (CollUtils.isEmpty(page.getRecords())){ |
| | | PageDTO<OrderCourseVO> empty = PageDTO.empty(page); |
| | | return R.ok(empty); |
| | | } |
| | | |
| | | PageDTO<OrderCourseVO> res = PageDTO.of(page, OrderCourseVO.class); |
| | | List<OrderCourseVO> list = res.getList(); |
| | | ArrayList<OrderCourseVO> orderCourseVOS = new ArrayList<>(); |
| | | for (OrderCourseVO orderCourseVO : res.getList()) { |
| | | switch (orderCourseVO.getChargeType()){ |
| | | switch (orderCourseVO.getOrderFrom()){ |
| | | case 1: |
| | | Meditation data1 = remoteMeditationService.getMeditationById(orderCourseVO.getBusinessId()).getData(); |
| | | if (data1==null)continue; |
| | | orderCourseVO.setCourseTitle(data1.getMeditationTitle()); |
| | | orderCourseVO.setDescription(data1.getCoverDescription()); |
| | | orderCourseVO.setCoverUrl(data1.getCoverUrl()); |
| | | orderCourseVO.setGeneralPrice(data1.getGeneralPrice()); |
| | | orderCourseVO.setIosPrice(data1.getIosPrice()); |
| | | orderCourseVO.setCount(data1.getRealLearnedNum()+data1.getVirtualLearnedNum()); |
| | | orderCourseVO.setChargeType(data1.getChargeType()); |
| | | break; |
| | | case 2: |
| | | OrderCourseVO data = remoteCourseService.getCourseCategoryList(orderCourseVO).getData(); |
| | | OrderCourseVO data = remoteCourseService.getCourseByIdAny(orderCourseVO).getData(); |
| | | if (data==null)continue; |
| | | BeanUtils.copyProperties(data, orderCourseVO); |
| | | List<CourseChapter> data2 = remoteCourseService.getChapterByCourseId(orderCourseVO.getBusinessId() + "").getData(); |
| | | int temp = 0 ; |
| | | for (CourseChapter courseChapter : data2) { |
| | | temp+=courseChapter.getVirtualLearnedNum(); |
| | | } |
| | | Integer data3 = remoteCourseService.getCountByCourseId(orderCourseVO.getBusinessId() + "").getData(); |
| | | orderCourseVO.setCount(data3+temp); |
| | | break; |
| | | |
| | | } |
| | | |
| | | } |
| | | return R.ok(res); |
| | | return R.ok(res.getList()); |
| | | } |
| | | /** |
| | | * 根据邀请用户ids 查询对应佣金 |
| | |
| | | * @see com.xinquan.order.domain.vo.ClientPlaceOrderVO |
| | | */ |
| | | @PostMapping("/placeOrder") |
| | | @ApiOperation(value = "创建待支付订单", notes = "微信|支付宝") |
| | | @ApiOperation(value = "创建支付订单", notes = "微信|支付宝") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "targetId", value = "目标id", dataType = "Long", required = true), |
| | | @ApiImplicitParam(name = "targetId", value = "目标id 订单类型为会员和充值时不传", dataType = "Long", required = false), |
| | | @ApiImplicitParam(name = "orderFrom", value = "订单来源 1=冥想音频 2=课程 3=购买会员 4充值", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(name = "receiverId", value = "被赠送课程APP用户id", dataType = "Long", required = false), |
| | | @ApiImplicitParam(name = "balanceFlag", value = "是否使用余额抵扣 1=是 2=否", dataType = "Integer", required = false), |
| | | @ApiImplicitParam(name = "payType", value = "支付方式 1=微信 2=支付宝", dataType = "Integer", required = false) |
| | | @ApiImplicitParam(name = "payType", value = "支付方式 1=微信 2=支付宝", dataType = "Integer", required = false), |
| | | @ApiImplicitParam(name = "amount", value = "购买会员的金额/充值金额", dataType = "BigDecimal", required = false), |
| | | @ApiImplicitParam(name = "vipType", value = "订单类型为会员时 必传 会员类型 1月度 2季度 3年度", dataType = "Integer", required = false), |
| | | }) |
| | | public R<ClientPlaceOrderVO> placeOrder( |
| | | @RequestParam(value = "targetId", required = false) Long targetId, |
| | | @RequestParam(value = "orderFrom") Integer orderFrom, |
| | | @RequestParam(value = "receiverId", required = false) Long receiverId, |
| | | @RequestParam(value = "balanceFlag", required = false) Integer balanceFlag, |
| | | @RequestParam(value = "payType") Integer payType, |
| | | @RequestParam(value = "amount", required = false) BigDecimal amount, |
| | | @RequestParam(value = "vipType", required = false) Integer vipType) |
| | | { |
| | | try { |
| | | |
| | | return R.ok( |
| | | orderService.placeOrder(targetId, orderFrom, receiverId, |
| | | balanceFlag, payType,amount,vipType)); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/refund") |
| | | @ApiOperation(value = "退款", tags = "管理后台-订单列表管理") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "uid", value = "订单id", dataType = "String", required = false), |
| | | @ApiImplicitParam(name = "remark", value = "退款备注", dataType = "String", required = false), |
| | | }) |
| | | public R refund(@RequestParam(value = "uid") String uid, |
| | | @RequestParam(value = "remark") String remark) throws Exception { |
| | | Order byId = orderService.getById(uid); |
| | | byId.setRefundStatus(2); |
| | | byId.setRefundRemark(remark); |
| | | byId.setPaymentStatus(3); |
| | | orderService.updateById(byId); |
| | | orderService.refund(Long.valueOf(uid)); |
| | | return R.ok(); |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/placeOrderApple") |
| | | @ApiOperation(value = "苹果支付", notes = "苹果支付") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "targetId", value = "目标id 订单类型为会员和充值时不传", dataType = "Long", required = false), |
| | | @ApiImplicitParam(name = "orderFrom", value = "订单来源 1=冥想音频 2=课程 3=购买会员 4充值", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(name = "receiverId", value = "被赠送课程APP用户id", dataType = "Long", required = false), |
| | | @ApiImplicitParam(name = "balanceFlag", value = "是否使用余额抵扣 1=是 2=否", dataType = "Integer", required = false), |
| | | @ApiImplicitParam(name = "amount", value = "购买会员的金额/充值金额", dataType = "BigDecimal", required = false), |
| | | @ApiImplicitParam(name = "transactionIdentifier", value = "苹果订单id"), |
| | | @ApiImplicitParam(name = "vipType", value = "订单类型为会员时 必传 会员类型 1月度 2季度 3年度", dataType = "Integer", required = false), |
| | | }) |
| | | public R placeOrderApple( |
| | | @RequestParam(value = "targetId") Long targetId, |
| | | @RequestParam(value = "orderFrom") Integer orderFrom, |
| | | @RequestParam(value = "receiverId", required = false) Long receiverId, |
| | | @RequestParam(value = "balanceFlag") Integer balanceFlag, |
| | | @RequestParam(value = "payType") Integer payType) { |
| | | try { |
| | | return R.ok( |
| | | orderService.placeOrder(targetId, orderFrom, receiverId, |
| | | balanceFlag, payType)); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | @RequestParam(value = "amount") BigDecimal amount, |
| | | @RequestParam(value = "vipType") Integer vipType, |
| | | @RequestParam(value = "transactionIdentifier")String transactionIdentifier) throws Exception { |
| | | |
| | | |
| | | return R.ok(orderService.placeOrderApple(targetId, orderFrom, receiverId, |
| | | balanceFlag,amount,vipType,transactionIdentifier)); |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/gvieCourse") |
| | | @ApiOperation(value = "购买疗愈/课程-纯余额支付", notes = "赠送课程-纯余额支付") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "targetId", value = "目标id 订单类型为会员和充值时不传", dataType = "Long", required = false), |
| | | @ApiImplicitParam(name = "orderFrom", value = "订单来源 1=冥想音频 2=课程", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(name = "receiverId", value = "被赠送课程APP用户id",dataType = "Long", required = false), |
| | | @ApiImplicitParam(name = "payType", value = "1安卓 2ios", dataType = "Long", required = false), |
| | | @ApiImplicitParam(name = "amount", value = "金额", dataType = "BigDecimal", required = false) |
| | | }) |
| | | public R placeOrderApple( |
| | | @RequestParam(value = "targetId") Long targetId, |
| | | @RequestParam(value = "orderFrom") Integer orderFrom, |
| | | @RequestParam(value = "receiverId",required = false) Long receiverId, |
| | | @RequestParam(value = "amount",required = false) BigDecimal amount, |
| | | @RequestParam(value = "payType") Integer payType |
| | | ){ |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | Order order = new Order(); |
| | | String orderNo = OrderUtil.getOrderNoForPrefix("MX"); |
| | | order.setBizOrderNo(orderNo); |
| | | order.setAppUserId(userId); |
| | | order.setBusinessId(targetId); |
| | | order.setGiveUserId(receiverId); |
| | | order.setOrderFrom(orderFrom); |
| | | order.setPaymentStatus(2); |
| | | order.setPayType(4); |
| | | order.setPaymentTime(LocalDateTime.now()); |
| | | switch (orderFrom){ |
| | | case 1: |
| | | Meditation data1 = remoteMeditationService.getMeditationById(targetId).getData(); |
| | | order.setBuyContent("购买疗愈【"+data1.getMeditationTitle()+"】"); |
| | | switch (payType){ |
| | | case 1: |
| | | order.setTotalAmount(data1.getGeneralPrice()); |
| | | order.setRealPayAmount(data1.getGeneralPrice()); |
| | | |
| | | break; |
| | | case 2: |
| | | order.setTotalAmount(data1.getIosPrice()); |
| | | order.setRealPayAmount(data1.getIosPrice()); |
| | | break; |
| | | } |
| | | |
| | | |
| | | break; |
| | | case 2: |
| | | Course data = remoteCourseService.getCourseById(targetId).getData(); |
| | | |
| | | order.setBuyContent("购买课程【"+data.getCourseTitle()+"】"); |
| | | switch (payType){ |
| | | case 1: |
| | | order.setTotalAmount(data.getGeneralPrice()); |
| | | order.setRealPayAmount(data.getGeneralPrice()); |
| | | |
| | | break; |
| | | case 2: |
| | | order.setTotalAmount(data.getIosPrice()); |
| | | order.setRealPayAmount(data.getIosPrice()); |
| | | break; |
| | | } |
| | | break; |
| | | } |
| | | |
| | | orderService.save(order); |
| | | switch (orderFrom){ |
| | | case 2: |
| | | if (receiverId!=null){ |
| | | remoteAppUserService.addAppUserCourse(order.getBusinessId(),order.getGiveUserId(),order.getId(),1); |
| | | }else{ |
| | | // 自己购买 |
| | | remoteAppUserService.addAppUserCourse(order.getBusinessId(),order.getAppUserId(),order.getId(),2); |
| | | } |
| | | break; |
| | | } |
| | | OrderPaymentRecord orderPaymentRecord = new OrderPaymentRecord(); |
| | | orderPaymentRecord.setOrderId(order.getId()); |
| | | orderPaymentRecord.setPaymentType(4); |
| | | orderPaymentRecord.setPayAmount(order.getTotalAmount()); |
| | | orderPaymentRecord.setPaymentStatus(2); |
| | | orderPaymentRecordService.save(orderPaymentRecord); |
| | | // 增加用户余额购买流水记录 |
| | | AppUserWalletRecord appUserWalletRecord1 = new AppUserWalletRecord(); |
| | | appUserWalletRecord1.setAppUserId(order.getAppUserId()); |
| | | appUserWalletRecord1.setChangeType(2); |
| | | appUserWalletRecord1.setReason(order.getBuyContent()); |
| | | appUserWalletRecord1.setAmount(order.getRealPayAmount()); |
| | | appUserWalletRecord1.setChildAppUserId(order.getAppUserId()); |
| | | appUserWalletRecord1.setOrderId(order.getId()); |
| | | remoteAppUserService.addBalanceRecord(appUserWalletRecord1); |
| | | switch (orderFrom){ |
| | | case 1: |
| | | |
| | | break; |
| | | case 2: |
| | | |
| | | if (receiverId!=null){ |
| | | remoteAppUserService.addAppUserCourse(order.getBusinessId(),order.getGiveUserId(),order.getId(),1); |
| | | }else{ |
| | | remoteAppUserService.addAppUserCourse(order.getBusinessId(),userId,order.getId(),1); |
| | | } |
| | | break; |
| | | } |
| | | |
| | | // 判断订单所属用户是否有上级 是否需要做分佣处理 |
| | | AppUser data = remoteAppUserService.getAppUserById(order.getAppUserId() + "").getData(); |
| | | BigDecimal realPayAmount = order.getRealPayAmount(); |
| | | if (data.getInviteUserId()!=null) { |
| | | if (order.getOrderFrom() == 1 || order.getOrderFrom() == 2) { |
| | | // 分佣给上级 先远程查询分佣比例 |
| | | CommissionRule data1 = sysUserClient.getCommission().getData(); |
| | | if (data1 != null) { |
| | | if (data1.getProportion() != null) { |
| | | BigDecimal bigDecimal = realPayAmount.multiply(data1.getProportion()) |
| | | .setScale(2, BigDecimal.ROUND_HALF_DOWN); |
| | | // 上级获取的分佣金额 |
| | | AppUser appUserById = remoteAppUserService.getAppUserById(data.getInviteUserId() + "").getData(); |
| | | // 更新用户余额 |
| | | remoteAppUserService.updateAppUser( |
| | | AppUserDTO.builder().balance( |
| | | appUserById.getBalance().add(bigDecimal)) |
| | | .build(), SecurityConstants.INNER); |
| | | // 新增分佣流水明细 |
| | | AppUserWalletRecord appUserWalletRecord = new AppUserWalletRecord(); |
| | | appUserWalletRecord.setAppUserId(data.getInviteUserId()); |
| | | appUserWalletRecord.setChangeType(1); |
| | | appUserWalletRecord.setReason("分佣收益"); |
| | | appUserWalletRecord.setAmount(bigDecimal); |
| | | appUserWalletRecord.setChildAppUserId(order.getAppUserId()); |
| | | appUserWalletRecord.setOrderId(order.getId()); |
| | | remoteAppUserService.addBalanceRecord(appUserWalletRecord); |
| | | order.setCommissionAmount(bigDecimal); |
| | | order.setCommissionId(data.getInviteUserId()); |
| | | orderService.updateById(order); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | /** |
| | | * 三方支付统一回调 |
| | | * |
| | | * @param request |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/callback") |
| | | public void callback(HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | System.err.println("请求"+request); |
| | | BufferedReader reader = request.getReader(); |
| | | String string1 = reader.toString(); |
| | | System.err.println("请求reader"+string1); |
| | | StringBuilder requestBody = new StringBuilder(); |
| | | String line; |
| | | while ((line = reader.readLine()) != null) { |
| | | requestBody.append(line); |
| | | } |
| | | System.err.println("全部请求体"+requestBody); |
| | | com.alibaba.fastjson2.JSONObject jsonObject = JSONObject.parseObject(requestBody.toString()); |
| | | System.err.println("json串"+jsonObject); |
| | | if (jsonObject.getString("type").equals("payment.succeeded")){ |
| | | String string9 = jsonObject.getString("resCipher"); |
| | | String decrypt = decrypt(string9); |
| | | System.err.println(decrypt); |
| | | JSONObject jsonObject1 = JSONObject.parseObject(decrypt); |
| | | |
| | | // 系统订单号 |
| | | String string = jsonObject1.getString("order_no"); |
| | | // 流水号 |
| | | String string2 = jsonObject1.getString("payment_id"); |
| | | // 支付金额 |
| | | String string3 = jsonObject1.getString("pay_fee"); |
| | | Order one = orderService.lambdaQuery().eq(Order::getBizOrderNo, string).one(); |
| | | one.setPaymentStatus(2); |
| | | one.setPaymentTime(LocalDateTime.now()); |
| | | OrderPaymentRecord one2 = orderPaymentRecordService.lambdaQuery().eq(OrderPaymentRecord::getOrderId, one.getId()) |
| | | .ne(OrderPaymentRecord::getPaymentType, 4).one(); |
| | | if (one2!=null){ |
| | | one2.setPaymentStatus(2); |
| | | orderPaymentRecordService.updateById(one2); |
| | | } |
| | | // 实际支付金额 |
| | | BigDecimal realPayAmount = one.getRealPayAmount(); |
| | | // 判断订单所属用户是否有上级 是否需要做分佣处理 |
| | | AppUser data = remoteAppUserService.getAppUserById(one.getAppUserId() + "").getData(); |
| | | if (data.getInviteUserId()!=null) { |
| | | if (one.getOrderFrom() == 1 || one.getOrderFrom() == 2) { |
| | | // 分佣给上级 先远程查询分佣比例 |
| | | CommissionRule data1 = sysUserClient.getCommission().getData(); |
| | | if (data1 != null) { |
| | | if (data1.getProportion() != null) { |
| | | BigDecimal bigDecimal = realPayAmount.multiply(data1.getProportion()) |
| | | .setScale(2, BigDecimal.ROUND_HALF_DOWN); |
| | | // 上级获取的分佣金额 |
| | | AppUser appUserById = remoteAppUserService.getAppUserById(data.getInviteUserId() + "").getData(); |
| | | // 更新用户余额 |
| | | remoteAppUserService.updateAppUser( |
| | | AppUserDTO.builder().balance( |
| | | appUserById.getBalance().add(bigDecimal)) |
| | | .build(), SecurityConstants.INNER); |
| | | // 新增分佣流水明细 |
| | | AppUserWalletRecord appUserWalletRecord = new AppUserWalletRecord(); |
| | | appUserWalletRecord.setAppUserId(data.getInviteUserId()); |
| | | appUserWalletRecord.setChangeType(1); |
| | | appUserWalletRecord.setReason("分佣收益"); |
| | | appUserWalletRecord.setAmount(bigDecimal); |
| | | appUserWalletRecord.setChildAppUserId(one.getAppUserId()); |
| | | appUserWalletRecord.setOrderId(one.getId()); |
| | | remoteAppUserService.addBalanceRecord(appUserWalletRecord); |
| | | one.setCommissionAmount(bigDecimal); |
| | | one.setCommissionId(data.getInviteUserId()); |
| | | orderService.updateById(one); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (one.getPayType() == 4 ||one.getPayType() == 5 ||one.getPayType() == 6 ||one.getPayType() == 7){ |
| | | // 涉及到余额支付 新增一条余额支付记录 |
| | | OrderPaymentRecord one1 = orderPaymentRecordService.lambdaQuery().eq(OrderPaymentRecord::getOrderId, one.getId()) |
| | | .eq(OrderPaymentRecord::getPaymentType, 4).one(); |
| | | AppUserWalletRecord appUserWalletRecord = new AppUserWalletRecord(); |
| | | appUserWalletRecord.setAppUserId(data.getInviteUserId()); |
| | | String reason=null; |
| | | switch (one.getOrderFrom()){ |
| | | case 1: |
| | | Meditation data1 = remoteMeditationService.getMeditationById(one.getBusinessId()).getData(); |
| | | appUserWalletRecord.setChangeType(2); |
| | | reason = "购买【"+data1.getMeditationTitle()+"】"; |
| | | |
| | | break; |
| | | case 2: |
| | | Course data2 = remoteCourseService.getCourseById(one.getBusinessId()).getData(); |
| | | reason = "购买【"+data2.getCourseTitle()+"】"; |
| | | appUserWalletRecord.setChangeType(2); |
| | | // 增加用户与课程的关系表 |
| | | if (one.getGiveUserId()!=null){ |
| | | remoteAppUserService.addAppUserCourse(one.getBusinessId(),one.getGiveUserId(),one.getId(),1); |
| | | }else{ |
| | | // 自己购买 |
| | | remoteAppUserService.addAppUserCourse(one.getBusinessId(),one.getAppUserId(),one.getId(),2); |
| | | } |
| | | break; |
| | | case 3: |
| | | // 会员 |
| | | reason = "购买【"+one.getBuyContent()+"】"; |
| | | appUserWalletRecord.setChangeType(2); |
| | | break; |
| | | case 4: |
| | | // 充值 |
| | | reason = "充值"; |
| | | appUserWalletRecord.setChangeType(1); |
| | | break; |
| | | } |
| | | appUserWalletRecord.setReason(reason); |
| | | appUserWalletRecord.setAmount(one1.getPayAmount()); |
| | | appUserWalletRecord.setChildAppUserId(one.getAppUserId()); |
| | | appUserWalletRecord.setOrderId(one.getId()); |
| | | remoteAppUserService.addBalanceRecord(appUserWalletRecord); |
| | | }else{ |
| | | switch (one.getOrderFrom()){ |
| | | case 2: |
| | | Course data2 = remoteCourseService.getCourseById(one.getBusinessId()).getData(); |
| | | // 增加用户与课程的关系表 |
| | | if (one.getGiveUserId()!=null){ |
| | | remoteAppUserService.addAppUserCourse(one.getBusinessId(),one.getGiveUserId(),one.getId(),1); |
| | | }else{ |
| | | // 自己购买 |
| | | remoteAppUserService.addAppUserCourse(one.getBusinessId(),one.getAppUserId(),one.getId(),2); |
| | | } |
| | | break; |
| | | case 3: |
| | | // 会员 |
| | | if (one.getBuyContent().contains("月")){ |
| | | |
| | | remoteAppUserService.addVipExpireTime(one.getAppUserId(),1); |
| | | }else if (one.getBuyContent().contains("季")){ |
| | | remoteAppUserService.addVipExpireTime(one.getAppUserId(),2); |
| | | }else if (one.getBuyContent().contains("年")){ |
| | | remoteAppUserService.addVipExpireTime(one.getAppUserId(),3); |
| | | } |
| | | break; |
| | | case 4: |
| | | remoteAppUserService.addBalance(one.getAppUserId(),one.getRealPayAmount()); |
| | | AppUserWalletRecord appUserWalletRecord = new AppUserWalletRecord(); |
| | | appUserWalletRecord.setAppUserId(one.getAppUserId()); |
| | | appUserWalletRecord.setChangeType(1); |
| | | appUserWalletRecord.setReason("充值"); |
| | | appUserWalletRecord.setAmount(one.getRealPayAmount()); |
| | | appUserWalletRecord.setChildAppUserId(one.getAppUserId()); |
| | | appUserWalletRecord.setOrderId(one.getId()); |
| | | remoteAppUserService.addBalanceRecord(appUserWalletRecord); |
| | | break; |
| | | } |
| | | } |
| | | orderService.updateById(one); |
| | | PrintWriter out = response.getWriter(); |
| | | out.write("succeeded"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | private static final String AES_KEY = "cb0a181ac97395c6942be19315fc0727"; |
| | | public static String decrypt(String strToDecrypt) { |
| | | try { |
| | | SecretKeySpec secretKey = new SecretKeySpec(AES_KEY.getBytes(), "AES"); |
| | | Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); |
| | | cipher.init(Cipher.DECRYPT_MODE, secretKey); |
| | | return new String(cipher.doFinal(Base64.getDecoder().decode(strToDecrypt))); |
| | | } catch (Exception e) { |
| | | System.out.println("Error while decrypting: " + e.toString()); |
| | | } |
| | | return null;} |
| | | /** |
| | | * 购买套餐微信支付回调 |
| | | * |
| | | * @param request |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/testApple") |
| | | public void testApple(HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | Map<String, String> params = new HashMap<String, String>(); |
| | | System.err.println("请求"+request); |
| | | BufferedReader reader = request.getReader(); |
| | | String string1 = reader.toString(); |
| | | System.err.println("请求reader"+string1); |
| | | StringBuilder requestBody = new StringBuilder(); |
| | | String line; |
| | | while ((line = reader.readLine()) != null) { |
| | | requestBody.append(line); |
| | | } |
| | | System.err.println("全部请求体"+requestBody); |
| | | org.json.JSONObject jsonObject1 = new org.json.JSONObject(requestBody.toString()); |
| | | System.err.println("json串"+jsonObject1); |
| | | String o = jsonObject1.getString("signedPayload"); |
| | | com.alibaba.fastjson.JSONObject payload = verifyAndGet(o); |
| | | String notificationType = payload.get("notificationType").toString(); |
| | | com.alibaba.fastjson.JSONObject data = payload.getJSONObject("data"); |
| | | String signedTransactionInfo = data.get("signedTransactionInfo").toString(); |
| | | String environment = data.get("environment").toString(); |
| | | com.alibaba.fastjson.JSONObject transactionInfo = verifyAndGet(signedTransactionInfo); |
| | | String transactionId = transactionInfo.get("transactionId").toString(); |
| | | String originalTransactionId = transactionInfo.get("originalTransactionId").toString(); |
| | | String productId = transactionInfo.get("productId").toString(); |
| | | System.err.println("json串"+transactionInfo); |
| | | System.err.println("data"+data); |
| | | // 苹果流水号 |
| | | String string = transactionInfo.getString("originalTransactionId"); |
| | | System.err.println("苹果流水号"+string); |
| | | OrderPaymentRecord two = orderPaymentRecordService.lambdaQuery() |
| | | .eq(OrderPaymentRecord::getPayOrderNo, string).ne(OrderPaymentRecord::getPaymentStatus, 2).one(); |
| | | if (two!=null){ |
| | | Order one = orderService.getById(two.getOrderId()); |
| | | one.setPaymentStatus(2); |
| | | one.setPaymentTime(LocalDateTime.now()); |
| | | OrderPaymentRecord one2 = orderPaymentRecordService.lambdaQuery().eq(OrderPaymentRecord::getOrderId, one.getId()) |
| | | .ne(OrderPaymentRecord::getPaymentType, 4).one(); |
| | | if (one2!=null){ |
| | | one2.setPaymentStatus(2); |
| | | orderPaymentRecordService.updateById(one2); |
| | | } |
| | | // 实际支付金额 |
| | | BigDecimal realPayAmount = one.getRealPayAmount(); |
| | | // 判断订单所属用户是否有上级 是否需要做分佣处理 |
| | | AppUser data3 = remoteAppUserService.getAppUserById(one.getAppUserId() + "").getData(); |
| | | if (data3.getInviteUserId()!=null){ |
| | | // 分佣给上级 先远程查询分佣比例 |
| | | CommissionRule data1 = sysUserClient.getCommission().getData(); |
| | | if (data1!=null){ |
| | | if (data1.getProportion()!=null){ |
| | | BigDecimal bigDecimal = realPayAmount.multiply(data1.getProportion()) |
| | | .setScale(2, BigDecimal.ROUND_HALF_DOWN); |
| | | // 上级获取的分佣金额 |
| | | AppUser appUserById = remoteAppUserService.getAppUserById(data3.getInviteUserId() + "").getData(); |
| | | // 更新用户余额 |
| | | remoteAppUserService.updateAppUser( |
| | | AppUserDTO.builder().balance( |
| | | appUserById.getBalance().add(bigDecimal)) |
| | | .build(), SecurityConstants.INNER); |
| | | // 新增分佣流水明细 |
| | | AppUserWalletRecord appUserWalletRecord = new AppUserWalletRecord(); |
| | | appUserWalletRecord.setAppUserId(data3.getInviteUserId()); |
| | | appUserWalletRecord.setChangeType(1); |
| | | appUserWalletRecord.setReason("分佣收益"); |
| | | appUserWalletRecord.setAmount(bigDecimal); |
| | | appUserWalletRecord.setChildAppUserId(one.getAppUserId()); |
| | | appUserWalletRecord.setOrderId(one.getId()); |
| | | remoteAppUserService.addBalanceRecord(appUserWalletRecord); |
| | | one.setCommissionAmount(bigDecimal); |
| | | one.setCommissionId(data3.getInviteUserId()); |
| | | orderService.updateById(one); |
| | | } |
| | | } |
| | | } |
| | | if (one.getPayType() == 4 ||one.getPayType() == 5 ||one.getPayType() == 6 ||one.getPayType() == 7){ |
| | | // 涉及到余额支付 新增一条余额支付记录 |
| | | OrderPaymentRecord one1 = orderPaymentRecordService.lambdaQuery().eq(OrderPaymentRecord::getOrderId, one.getId()) |
| | | .eq(OrderPaymentRecord::getPaymentType, 4).one(); |
| | | AppUserWalletRecord appUserWalletRecord = new AppUserWalletRecord(); |
| | | appUserWalletRecord.setAppUserId(data3.getInviteUserId()); |
| | | String reason=null; |
| | | switch (one.getOrderFrom()){ |
| | | case 1: |
| | | Meditation data1 = remoteMeditationService.getMeditationById(one.getBusinessId()).getData(); |
| | | appUserWalletRecord.setChangeType(2); |
| | | reason = "购买【"+data1.getMeditationTitle()+"】"; |
| | | |
| | | break; |
| | | case 2: |
| | | Course data2 = remoteCourseService.getCourseById(one.getBusinessId()).getData(); |
| | | reason = "购买【"+data2.getCourseTitle()+"】"; |
| | | appUserWalletRecord.setChangeType(2); |
| | | // 增加用户与课程的关系表 |
| | | if (one.getGiveUserId()!=null){ |
| | | remoteAppUserService.addAppUserCourse(one.getBusinessId(),one.getGiveUserId(),one.getId(),1); |
| | | }else{ |
| | | // 自己购买 |
| | | remoteAppUserService.addAppUserCourse(one.getBusinessId(),one.getAppUserId(),one.getId(),2); |
| | | } |
| | | break; |
| | | case 3: |
| | | // 会员 |
| | | reason = "购买【"+one.getBuyContent()+"】"; |
| | | appUserWalletRecord.setChangeType(2); |
| | | if (data3.getInviteUserId()!=null){ |
| | | // 分佣给上级 先远程查询分佣比例 |
| | | CommissionRule data4 = sysUserClient.getCommission().getData(); |
| | | if (data4!=null){ |
| | | if (data4.getProportion()!=null){ |
| | | BigDecimal bigDecimal = realPayAmount.multiply(data4.getProportion()) |
| | | .setScale(2, BigDecimal.ROUND_HALF_DOWN); |
| | | // 上级获取的分佣金额 |
| | | AppUser appUserById = remoteAppUserService.getAppUserById(data3.getInviteUserId() + "").getData(); |
| | | // 更新用户余额 |
| | | remoteAppUserService.updateAppUser( |
| | | AppUserDTO.builder().balance( |
| | | appUserById.getBalance().add(bigDecimal)) |
| | | .build(), SecurityConstants.INNER); |
| | | // 新增分佣流水明细 |
| | | AppUserWalletRecord appUserWalletRecord1 = new AppUserWalletRecord(); |
| | | appUserWalletRecord1.setAppUserId(data3.getInviteUserId()); |
| | | appUserWalletRecord1.setChangeType(1); |
| | | appUserWalletRecord1.setReason("分佣收益"); |
| | | appUserWalletRecord1.setAmount(bigDecimal); |
| | | appUserWalletRecord1.setChildAppUserId(one.getAppUserId()); |
| | | appUserWalletRecord1.setOrderId(one.getId()); |
| | | remoteAppUserService.addBalanceRecord(appUserWalletRecord1); |
| | | one.setCommissionAmount(bigDecimal); |
| | | one.setCommissionId(data3.getInviteUserId()); |
| | | orderService.updateById(one); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | case 4: |
| | | // 充值 |
| | | reason = "充值"; |
| | | appUserWalletRecord.setChangeType(1); |
| | | break; |
| | | } |
| | | appUserWalletRecord.setReason(reason); |
| | | appUserWalletRecord.setAmount(one1.getPayAmount()); |
| | | appUserWalletRecord.setChildAppUserId(one.getAppUserId()); |
| | | appUserWalletRecord.setOrderId(one.getId()); |
| | | remoteAppUserService.addBalanceRecord(appUserWalletRecord); |
| | | } |
| | | PrintWriter out = response.getWriter(); |
| | | out.write("succeeded"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | // Recharge orderNumber = rechargeService.selectOne(new EntityWrapper<Recharge>() |
| | | // .eq("orderNumber", string)); |
| | | // if (orderNumber!=null){ |
| | | // if (orderNumber.getState()!=2){ |
| | | // // 进入 |
| | | // orderNumber.setState(2); |
| | | // orderNumber.setPayTime(new Date()); |
| | | // rechargeService.updateById(orderNumber); |
| | | // BigDecimal amount = orderNumber.getAmount(); |
| | | // AppUser appUser = appUserService.selectById(orderNumber.getUserId()); |
| | | // BigDecimal add = appUser.getBalance().add(amount); |
| | | // appUser.setBalance(add); |
| | | // appUserService.updateById(appUser); |
| | | // } |
| | | // } |
| | | PrintWriter out = response.getWriter(); |
| | | out.write("success"); |
| | | out.flush(); |
| | | out.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | public static com.alibaba.fastjson.JSONObject verifyAndGet(String jws) throws CertificateException { |
| | | DecodedJWT decodedJWT = JWT.decode(jws); |
| | | // 拿到 header 中 x5c 数组中第一个 |
| | | String header = new String(java.util.Base64.getDecoder().decode(decodedJWT.getHeader())); |
| | | String x5c = com.alibaba.fastjson.JSONObject.parseObject(header).getJSONArray("x5c").getString(0); |
| | | |
| | | // 获取公钥 |
| | | PublicKey publicKey = getPublicKeyByX5c(x5c); |
| | | |
| | | // 验证 token |
| | | Algorithm algorithm = Algorithm.ECDSA256((ECPublicKey) publicKey, null); |
| | | |
| | | try { |
| | | algorithm.verify(decodedJWT); |
| | | } catch (SignatureVerificationException e) { |
| | | throw new RuntimeException("签名验证失败"); |
| | | } |
| | | // 解析数据 |
| | | return com.alibaba.fastjson.JSONObject.parseObject(new String(java.util.Base64.getDecoder().decode(decodedJWT.getPayload()))); |
| | | } |
| | | /** |
| | | * 获取公钥 |
| | | * @param x5c |
| | | * @return |
| | | * @throws |
| | | */ |
| | | private static PublicKey getPublicKeyByX5c(String x5c) throws CertificateException { |
| | | byte[] x5c0Bytes = java.util.Base64.getDecoder().decode(x5c); |
| | | CertificateFactory fact = CertificateFactory.getInstance("X.509"); |
| | | X509Certificate cer = (X509Certificate) fact.generateCertificate(new ByteArrayInputStream(x5c0Bytes)); |
| | | return cer.getPublicKey(); |
| | | } |
| | | /** |
| | | * 获取请求内容 |
| | | * |
| | | * @param request |
| | | * @return |
| | | * @throws IOException |
| | | */ |
| | | private String getParam(HttpServletRequest request) throws IOException { |
| | | // 读取参数 |
| | | InputStream inputStream; |
| | | StringBuilder sb = new StringBuilder(); |
| | | inputStream = request.getInputStream(); |
| | | String s; |
| | | BufferedReader in = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); |
| | | while ((s = in.readLine()) != null) { |
| | | sb.append(s); |
| | | } |
| | | in.close(); |
| | | inputStream.close(); |
| | | return sb.toString(); |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/testCallback") |
| | |
| | | */ |
| | | @PostMapping("/getOrderById/{orderId}") |
| | | public R<Order> getOrderById(@PathVariable("orderId") Long orderId) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | Long userId = tokenService.getLoginUser().getUserid(); |
| | | if(userId ==null || userId == 0)return R.tokenError("登录失效"); |
| | | Order one = orderService.lambdaQuery() |
| | | .eq(Order::getId, orderId).one(); |
| | | if (one!=null){ |
| | |
| | | package com.xinquan.order.controller.management; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.WebUtils; |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.common.core.web.page.PageInfo; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.course.api.feign.RemoteCourseService; |
| | | import com.xinquan.meditation.api.domain.Meditation; |
| | | import com.xinquan.meditation.api.feign.RemoteMeditationService; |
| | | import com.xinquan.order.api.domain.Order; |
| | | import com.xinquan.order.api.domain.dto.OrderListDTO; |
| | | import com.xinquan.order.domain.export.OrderExport; |
| | | import com.xinquan.order.domain.export.WaterExport; |
| | | import com.xinquan.system.api.domain.AppUserWithdraw; |
| | | import com.xinquan.system.api.domain.PrizeRedemptionRecord; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.user.api.domain.dto.OrderListDTO; |
| | | import com.xinquan.order.api.domain.vo.OrderCountVO; |
| | | import com.xinquan.order.domain.OrderPaymentRecord; |
| | | import com.xinquan.order.service.OrderPaymentRecordService; |
| | |
| | | import com.xinquan.system.api.domain.SysUser; |
| | | import com.xinquan.user.api.feign.RemoteAppUserService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.aspectj.weaver.ast.Or; |
| | | import org.omg.CORBA.PRIVATE_MEMBER; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @Resource |
| | | private RemoteUserService remoteUserService; |
| | | |
| | | public static void main(String[] args) { |
| | | } |
| | | @PostMapping("/getOrderList") |
| | | public R<List<Order>> getOrderList(@RequestParam("status") Integer status, |
| | | @RequestParam("timeType") Integer timeType, |
| | | @RequestParam("time") String time) |
| | | { |
| | | LocalDate today = LocalDate.now(); |
| | | // 定义日期时间格式 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | // 获取当前年份 |
| | | int currentYear = LocalDate.now().getYear(); |
| | | List<Long> longs = new ArrayList<>(); |
| | | longs.add(1L); |
| | | longs.add(2L); |
| | | longs.add(3L); |
| | | LambdaQueryWrapper<Order> orderLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | String startTime =null; |
| | | String endTime =null; |
| | | switch (timeType){ |
| | | case 1: |
| | | // 获取今年第一天和今年最后一天 |
| | | // 获取今年的第一天 |
| | | LocalDate firstDayOfYear = LocalDate.of(currentYear, 1, 1); |
| | | LocalDateTime firstDayOfYearDateTime = firstDayOfYear.atStartOfDay(); |
| | | // 获取今年的最后一天 |
| | | LocalDate lastDayOfYear = LocalDate.of(currentYear, 12, 31); |
| | | LocalDateTime lastDayOfYearDateTime = lastDayOfYear.atTime(23, 59, 59); |
| | | // 格式化日期时间 |
| | | String firstDayOfYearString = firstDayOfYearDateTime.format(formatter); |
| | | String lastDayOfYearString = lastDayOfYearDateTime.format(formatter); |
| | | startTime = firstDayOfYearString; |
| | | endTime = lastDayOfYearString; |
| | | break; |
| | | case 2: |
| | | // 获取今日的最开始时间(00:00:00) |
| | | LocalDateTime startOfDay = today.atStartOfDay(); |
| | | // 获取今日的最晚时间(23:59:59) |
| | | LocalDateTime endOfDay = today.atTime(23, 59, 59); |
| | | // 格式化日期时间 |
| | | String startOfDayString = startOfDay.format(formatter); |
| | | String endOfDayString = endOfDay.format(formatter); |
| | | startTime = startOfDayString; |
| | | endTime = endOfDayString; |
| | | break; |
| | | case 3: |
| | | // 获取本周的第一天(周一) |
| | | LocalDate firstDayOfWeek = today.with(TemporalAdjusters.previousOrSame(java.time.DayOfWeek.MONDAY)); |
| | | LocalDateTime firstDayOfWeekDateTime = firstDayOfWeek.atStartOfDay(); |
| | | // 获取本周的最后一天(周日) |
| | | LocalDate lastDayOfWeek = today.with(TemporalAdjusters.nextOrSame(java.time.DayOfWeek.SUNDAY)); |
| | | LocalDateTime lastDayOfWeekDateTime = lastDayOfWeek.atTime(23, 59, 59); |
| | | // 格式化日期时间 |
| | | String firstDayOfWeekString = firstDayOfWeekDateTime.format(formatter); |
| | | String lastDayOfWeekString = lastDayOfWeekDateTime.format(formatter); |
| | | startTime = firstDayOfWeekString; |
| | | endTime = lastDayOfWeekString; |
| | | break; |
| | | case 4: |
| | | // 获取当前日期 |
| | | // 获取本月的第一天 |
| | | LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth()); |
| | | LocalDateTime firstDayOfMonthDateTime = firstDayOfMonth.atStartOfDay(); |
| | | // 获取本月的最后一天 |
| | | LocalDate lastDayOfMonth = today.with(TemporalAdjusters.lastDayOfMonth()); |
| | | LocalDateTime lastDayOfMonthDateTime = lastDayOfMonth.atTime(23, 59, 59); |
| | | // 格式化日期时间 |
| | | String firstDayOfMonthString = firstDayOfMonthDateTime.format(formatter); |
| | | String lastDayOfMonthString = lastDayOfMonthDateTime.format(formatter); |
| | | startTime = firstDayOfMonthString; |
| | | endTime = lastDayOfMonthString; |
| | | break; |
| | | } |
| | | if (!time.equals("1")){ |
| | | String[] split = time.split(" - "); |
| | | startTime = split[0]+"00:00:00"; |
| | | endTime = split[1]+"23:59:59"; |
| | | } |
| | | if (startTime!=null){ |
| | | orderLambdaQueryWrapper.between(Order::getCreateTime,startTime,endTime); |
| | | } |
| | | if (status!=0){ |
| | | orderLambdaQueryWrapper.eq(Order::getPaymentStatus, status); |
| | | } |
| | | orderLambdaQueryWrapper.eq(Order::getPaymentStatus, 2); |
| | | orderLambdaQueryWrapper.in(Order::getOrderFrom,longs); |
| | | orderLambdaQueryWrapper.ne(Order::getRefundStatus, 3); |
| | | List<Order> list = orderService.list(orderLambdaQueryWrapper); |
| | | return R.ok(list); |
| | | } |
| | | @PutMapping("/export") |
| | | @ApiOperation(value = "收支流水-导出", tags = {"管理后台-财务管理"}) |
| | | public void export(@RequestBody OrderListDTO courseDTO) { |
| | | String startTime = null; |
| | | String endTime = null; |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getTime())){ |
| | | String[] split = courseDTO.getTime().split(" - "); |
| | | startTime = split[0]+"00:00:00"; |
| | | endTime = split[1]+"23:59:59"; |
| | | } |
| | | List<Integer> payType1 = new ArrayList<>(); |
| | | payType1.add(1); |
| | | payType1.add(5); |
| | | List<Integer> payType2 = new ArrayList<>(); |
| | | payType2.add(2); |
| | | payType2.add(6); |
| | | List<Integer> payType3 = new ArrayList<>(); |
| | | payType3.add(3); |
| | | payType3.add(7); |
| | | List<Integer> payType4 = new ArrayList<>(); |
| | | payType3.add(4); |
| | | payType3.add(5); |
| | | payType3.add(6); |
| | | payType3.add(7); |
| | | LambdaQueryWrapper<Order> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.hasLength(courseDTO.getIds())){ |
| | | courseLambdaQueryWrapper.in(Order::getId, Arrays.asList(courseDTO.getIds().split(","))); |
| | | } |
| | | courseLambdaQueryWrapper.between(Order::getCreateTime, startTime, endTime); |
| | | if (courseDTO.getPayType()!=null){ |
| | | switch (courseDTO.getPayType()){ |
| | | case 1: |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType1); |
| | | break; |
| | | case 2: |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType2); |
| | | break; |
| | | case 3: |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType3); |
| | | break; |
| | | case 4: |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType4); |
| | | break; |
| | | } |
| | | } |
| | | courseLambdaQueryWrapper.eq(courseDTO.getPaymentStatus()!=null,Order::getPaymentStatus, courseDTO.getPaymentStatus()); |
| | | courseLambdaQueryWrapper.eq(courseDTO.getOrderFrom()!=null,Order::getOrderFrom, courseDTO.getOrderFrom()); |
| | | courseLambdaQueryWrapper.eq(courseDTO.getUid()!=null&&(!courseDTO.getUid().isEmpty()),Order::getAppUserId, courseDTO.getUid()); |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getBuyContent())){ |
| | | // 查询购买内容 |
| | | List<Long> collect1 = orderService.lambdaQuery().like(Order::getVipType, courseDTO.getBuyContent()).list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | List<Long> collect2 = orderService.lambdaQuery().like(Order::getBizOrderNo, courseDTO.getBuyContent()).list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | List<Long> data = remoteCourseService.getCourseIdsByName(courseDTO.getBuyContent()).getData(); |
| | | if (!data.isEmpty()){ |
| | | List<Long> collect3 = orderService.lambdaQuery().in(Order::getBusinessId, data) |
| | | .eq(Order::getOrderFrom, 2) |
| | | .list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | if (!collect3.isEmpty()){ |
| | | collect1.addAll(collect3); |
| | | } |
| | | } |
| | | List<Long> data1 = remoteMeditationService.getMeditationIdsByName(courseDTO.getBuyContent()).getData(); |
| | | if (!data1.isEmpty()){ |
| | | List<Long> collect3 = orderService.lambdaQuery().in(Order::getBusinessId, data1) |
| | | .eq(Order::getOrderFrom, 1) |
| | | .list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | if (!collect3.isEmpty()){ |
| | | collect1.addAll(collect3); |
| | | } |
| | | } |
| | | |
| | | collect1.addAll(collect2); |
| | | List<Long> collect = collect1.stream().distinct().collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Order::getId,collect); |
| | | } |
| | | |
| | | courseLambdaQueryWrapper.orderByDesc(Order::getCreateTime); |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getUserNameOrPhone())){ |
| | | List<Long> collect = remoteAppUserService.getAppUserByNameOrPhone(courseDTO.getUserNameOrPhone()).getData(); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Order::getAppUserId, collect); |
| | | } |
| | | |
| | | List<Order> page = orderService.list(courseLambdaQueryWrapper); |
| | | List<AppUserWithdraw> data2 = remoteAppUserService.getWithdraw(courseDTO).getData(); |
| | | List<WaterExport> waterExports = new ArrayList<>(); |
| | | for (AppUserWithdraw appUserWithdraw : data2) { |
| | | Order order = new Order(); |
| | | order.setId(appUserWithdraw.getId()); |
| | | order.setBizOrderNo(appUserWithdraw.getCode()); |
| | | order.setUid(appUserWithdraw.getId()+""); |
| | | order.setBuyContent("提现"); |
| | | order.setAppUserId(appUserWithdraw.getAppUserId()); |
| | | order.setOrderFrom(5); |
| | | order.setPaymentStatus(appUserWithdraw.getWithdrawStatus()+1); |
| | | order.setPayType(4); |
| | | order.setTotalAmount(appUserWithdraw.getAmount()); |
| | | order.setRealPayAmount(appUserWithdraw.getAmount()); |
| | | order.setPlatformMoney(appUserWithdraw.getAmount().multiply(new BigDecimal("-1"))); |
| | | order.setPaymentTime(appUserWithdraw.getWithdrawTime()); |
| | | order.setCreateTime(appUserWithdraw.getCreateTime()); |
| | | page.add(order); |
| | | } |
| | | for (Order record : page) { |
| | | record.setUid(record.getId().toString()); |
| | | record.setPlatformMoney(record.getRealPayAmount().subtract(record.getCommissionAmount()==null?BigDecimal.ZERO:record.getCommissionAmount())); |
| | | AppUser byId1 = remoteAppUserService.getAppUserById(record.getAppUserId()+"").getData(); |
| | | if (Objects.nonNull(byId1)){ |
| | | record.setUserName(byId1.getNickname()); |
| | | record.setCellPhone(byId1.getCellPhone()); |
| | | } |
| | | if (record.getOrderFrom()!=null){ |
| | | switch (record.getOrderFrom()){ |
| | | case 1: |
| | | Meditation data = remoteMeditationService.getMeditationById(record.getBusinessId()).getData(); |
| | | if (data!=null){ |
| | | record.setCategoryMeditationName(data.getCategoryName()); |
| | | record.setMeditationTitle(data.getMeditationTitle()); |
| | | record.setIconUrl(data.getIconUrl()); |
| | | record.setDetailDescription(data.getDetailDescription()); |
| | | record.setGeneralPriceMeditation(data.getGeneralPrice()); |
| | | record.setListingStatusMeditation(data.getListingStatus()); |
| | | record.setMeditationUid(data.getId()+""); |
| | | } |
| | | break; |
| | | case 2: |
| | | Course data1 = remoteCourseService.getCourseById(record.getBusinessId()).getData(); |
| | | if (data1!=null){ |
| | | record.setCategoryCourseName(data1.getCategoryName()); |
| | | record.setCourseTitle(data1.getCourseTitle()); |
| | | record.setCoverUrl(data1.getCoverUrl()); |
| | | record.setTutor(data1.getTutor()); |
| | | record.setCourseChapterCount(data1.getCourseChapterCount()); |
| | | record.setGeneralPriceCourse(data1.getGeneralPrice()); |
| | | record.setListingStatusCourse(data1.getListingStatus()); |
| | | record.setCourseUid(data1.getId()+""); |
| | | } |
| | | break; |
| | | case 3: |
| | | record.setBuyContent(record.getVipType()); |
| | | record.setGeneralPriceVip(record.getRealPayAmount()); |
| | | break; |
| | | case 4: |
| | | record.setBuyContent("余额充值"); |
| | | record.setPlatformMoney(record.getRealPayAmount()!=null?record.getRealPayAmount() |
| | | .subtract(record.getCommissionAmount()!=null?record.getCommissionAmount():BigDecimal.ZERO):BigDecimal.ZERO); |
| | | break; |
| | | } |
| | | } |
| | | WaterExport waterExport = new WaterExport(); |
| | | waterExport.setCode(record.getBizOrderNo()); |
| | | if (Objects.nonNull(byId1)){ |
| | | record.setUserName(byId1.getNickname()); |
| | | record.setCellPhone(byId1.getCellPhone()); |
| | | waterExport.setUserName(byId1.getNickname()); |
| | | waterExport.setCellphone(byId1.getCellPhone()); |
| | | } |
| | | waterExport.setRealPayAmount("¥"+record.getRealPayAmount()); |
| | | waterExport.setCommissionAmount("¥"+record.getCommissionAmount()); |
| | | waterExport.setPlatformMoney("¥"+record.getPlatformMoney()); |
| | | waterExport.setBuyContent(record.getBuyContent()); |
| | | waterExport.setOrderFrom(record.getOrderFrom()+""); |
| | | waterExport.setPayType(record.getPayType()); |
| | | DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | String format = df.format(record.getCreateTime()); |
| | | waterExport.setCreateTime(format); |
| | | waterExport.setPaymentStatus(record.getPaymentStatus()+""); |
| | | } |
| | | |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), WaterExport.class, waterExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("收支流水导出.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | @PostMapping("/waterList") |
| | | @ApiOperation(value = "收支流水-分页", tags = {"管理后台-财务管理"}) |
| | | public R<Page<Order>> waterList(@RequestBody OrderListDTO courseDTO) { |
| | | String startTime = null; |
| | | String endTime = null; |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getTime())){ |
| | | String[] split = courseDTO.getTime().split(" - "); |
| | | startTime = split[0]+"00:00:00"; |
| | | endTime = split[1]+"23:59:59"; |
| | | } |
| | | List<Integer> payType1 = new ArrayList<>(); |
| | | payType1.add(1); |
| | | payType1.add(5); |
| | | List<Integer> payType2 = new ArrayList<>(); |
| | | payType2.add(2); |
| | | payType2.add(6); |
| | | List<Integer> payType3 = new ArrayList<>(); |
| | | payType3.add(3); |
| | | payType3.add(7); |
| | | List<Integer> payType4 = new ArrayList<>(); |
| | | payType3.add(4); |
| | | payType3.add(5); |
| | | payType3.add(6); |
| | | payType3.add(7); |
| | | LambdaQueryWrapper<Order> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if (startTime!=null){ |
| | | courseLambdaQueryWrapper.between(Order::getCreateTime, startTime, endTime); |
| | | } |
| | | if (courseDTO.getPayType()!=null){ |
| | | switch (courseDTO.getPayType()){ |
| | | case 1: |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType1); |
| | | break; |
| | | case 2: |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType2); |
| | | break; |
| | | case 3: |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType3); |
| | | break; |
| | | case 4: |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType4); |
| | | break; |
| | | } |
| | | } |
| | | if (courseDTO.getPaymentStatus()!=null){ |
| | | courseLambdaQueryWrapper.eq(Order::getPaymentStatus, courseDTO.getPaymentStatus()); |
| | | } |
| | | if (courseDTO.getOrderFrom()!=null){ |
| | | courseLambdaQueryWrapper.eq(Order::getOrderFrom, courseDTO.getOrderFrom()); |
| | | } |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getBuyContent())){ |
| | | // 查询购买内容 |
| | | List<Long> collect1 = orderService.lambdaQuery().like(Order::getVipType, courseDTO.getBuyContent()).list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | List<Long> collect2 = orderService.lambdaQuery().like(Order::getBizOrderNo, courseDTO.getBuyContent()).list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | List<Long> data = remoteCourseService.getCourseIdsByName(courseDTO.getBuyContent()).getData(); |
| | | if (!data.isEmpty()){ |
| | | List<Long> collect3 = orderService.lambdaQuery().in(Order::getBusinessId, data) |
| | | .eq(Order::getOrderFrom, 2) |
| | | .list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | if (!collect3.isEmpty()){ |
| | | collect1.addAll(collect3); |
| | | } |
| | | } |
| | | List<Long> data1 = remoteMeditationService.getMeditationIdsByName(courseDTO.getBuyContent()).getData(); |
| | | if (!data1.isEmpty()){ |
| | | List<Long> collect3 = orderService.lambdaQuery().in(Order::getBusinessId, data1) |
| | | .eq(Order::getOrderFrom, 1) |
| | | .list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | if (!collect3.isEmpty()){ |
| | | collect1.addAll(collect3); |
| | | } |
| | | } |
| | | |
| | | collect1.addAll(collect2); |
| | | List<Long> collect = collect1.stream().distinct().collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Order::getId,collect); |
| | | } |
| | | |
| | | courseLambdaQueryWrapper.orderByDesc(Order::getCreateTime); |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getUserNameOrPhone())){ |
| | | List<Long> collect = remoteAppUserService.getAppUserByNameOrPhone(courseDTO.getUserNameOrPhone()).getData(); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Order::getAppUserId, collect); |
| | | } |
| | | |
| | | List<Order> page = orderService.list(courseLambdaQueryWrapper); |
| | | Page<Order> objectPage = new Page<>(); |
| | | objectPage.setTotal(page.size()); |
| | | objectPage.setCurrent(courseDTO.getPageCurr()); |
| | | objectPage.setSize(courseDTO.getPageSize()); |
| | | List<AppUserWithdraw> data2 = remoteAppUserService.getWithdraw(courseDTO).getData(); |
| | | for (AppUserWithdraw appUserWithdraw : data2) { |
| | | Order order = new Order(); |
| | | order.setId(appUserWithdraw.getId()); |
| | | order.setBizOrderNo(appUserWithdraw.getCode()); |
| | | order.setUid(appUserWithdraw.getId()+""); |
| | | order.setBuyContent("提现"); |
| | | order.setAppUserId(appUserWithdraw.getAppUserId()); |
| | | order.setOrderFrom(5); |
| | | order.setPaymentStatus(appUserWithdraw.getWithdrawStatus()+1); |
| | | order.setPayType(4); |
| | | order.setTotalAmount(appUserWithdraw.getAmount()); |
| | | order.setRealPayAmount(appUserWithdraw.getAmount()); |
| | | order.setPlatformMoney(appUserWithdraw.getAmount().multiply(new BigDecimal("-1"))); |
| | | order.setPaymentTime(appUserWithdraw.getWithdrawTime()); |
| | | order.setCreateTime(appUserWithdraw.getCreateTime()); |
| | | page.add(order); |
| | | } |
| | | for (Order record : page) { |
| | | record.setUid(record.getId().toString()); |
| | | record.setPlatformMoney(record.getRealPayAmount().subtract(record.getCommissionAmount()==null?BigDecimal.ZERO:record.getCommissionAmount())); |
| | | AppUser byId1 = remoteAppUserService.getAppUserById(record.getAppUserId()+"").getData(); |
| | | if (Objects.nonNull(byId1)){ |
| | | record.setUserName(byId1.getNickname()); |
| | | record.setCellPhone(byId1.getCellPhone()); |
| | | } |
| | | if (record.getOrderFrom()!=null){ |
| | | switch (record.getOrderFrom()){ |
| | | case 1: |
| | | Meditation data = remoteMeditationService.getMeditationById(record.getBusinessId()).getData(); |
| | | if (data!=null){ |
| | | record.setCategoryMeditationName(data.getCategoryName()); |
| | | record.setMeditationTitle(data.getMeditationTitle()); |
| | | record.setIconUrl(data.getIconUrl()); |
| | | record.setDetailDescription(data.getDetailDescription()); |
| | | record.setGeneralPriceMeditation(data.getGeneralPrice()); |
| | | record.setListingStatusMeditation(data.getListingStatus()); |
| | | record.setMeditationUid(data.getId()+""); |
| | | } |
| | | break; |
| | | case 2: |
| | | Course data1 = remoteCourseService.getCourseById(record.getBusinessId()).getData(); |
| | | if (data1!=null){ |
| | | record.setCategoryCourseName(data1.getCategoryName()); |
| | | record.setCourseTitle(data1.getCourseTitle()); |
| | | record.setCoverUrl(data1.getCoverUrl()); |
| | | record.setTutor(data1.getTutor()); |
| | | record.setCourseChapterCount(data1.getCourseChapterCount()); |
| | | record.setGeneralPriceCourse(data1.getGeneralPrice()); |
| | | record.setListingStatusCourse(data1.getListingStatus()); |
| | | record.setCourseUid(data1.getId()+""); |
| | | } |
| | | break; |
| | | case 3: |
| | | record.setBuyContent(record.getVipType()); |
| | | record.setGeneralPriceVip(record.getRealPayAmount()); |
| | | break; |
| | | case 4: |
| | | record.setBuyContent("充值"); |
| | | record.setPlatformMoney(record.getRealPayAmount()!=null?record.getRealPayAmount() |
| | | .subtract(record.getCommissionAmount()!=null?record.getCommissionAmount():BigDecimal.ZERO):BigDecimal.ZERO); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | // 手动分页 |
| | | List<Order> testing = testing(page.size(), courseDTO.getPageCurr(), courseDTO.getPageSize(), page); |
| | | objectPage.setRecords(testing); |
| | | return R.ok(objectPage); |
| | | } |
| | | @PostMapping("/waterListTest") |
| | | @ApiOperation(value = "测试手动分页-分页", tags = {"管理后台-测试接口"}) |
| | | public R<List<Order>> waterListTest(@RequestBody OrderListDTO courseDTO) { |
| | | List<Order> list = orderService.list(null); |
| | | return R.ok(testing(list.size(), courseDTO.getPageCurr(), courseDTO.getPageSize(), list)); |
| | | } |
| | | public static List<Order> testing(long total, long current, long size, List<Order> str){ |
| | | List<Order> result = new ArrayList<>(); |
| | | //获取初始化分页结构 |
| | | Page<Order> page = new Page<>(current - 1, size, total); |
| | | //获取集合下标初始值 |
| | | long startIndex = (current - 1) * size; |
| | | //获取集合下标结束值 |
| | | long endInddex = 0; |
| | | if(startIndex + page.getCurrent() >= total || size > total){ |
| | | endInddex = total; |
| | | }else { |
| | | endInddex = Math.min(startIndex + page.getSize(), total); |
| | | } |
| | | //如果输入的开始查询下标大于集合大小,则查询为空值 |
| | | if(startIndex > total){ |
| | | result = Collections.emptyList(); |
| | | }else{ |
| | | result = str.subList((int)startIndex,(int)endInddex); |
| | | } |
| | | return result; |
| | | } |
| | | @PostMapping("/waterCount") |
| | | @ApiOperation(value = "收支流水列表上方合计数据", tags = {"管理后台-财务管理"}) |
| | | public R<OrderCountVO> waterCount(@RequestBody OrderListDTO courseDTO) { |
| | | OrderCountVO orderCountVO = new OrderCountVO(); |
| | | String startTime = null; |
| | | String endTime = null; |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getTime())){ |
| | | String[] split = courseDTO.getTime().split(" - "); |
| | | startTime = split[0]+"00:00:00"; |
| | | endTime = split[1]+"23:59:59"; |
| | | } |
| | | List<Integer> payType1 = new ArrayList<>(); |
| | | payType1.add(1); |
| | | payType1.add(5); |
| | | List<Integer> payType2 = new ArrayList<>(); |
| | | payType2.add(2); |
| | | payType2.add(6); |
| | | List<Integer> payType3 = new ArrayList<>(); |
| | | payType3.add(3); |
| | | payType3.add(7); |
| | | List<Integer> payType4 = new ArrayList<>(); |
| | | payType3.add(4); |
| | | payType3.add(5); |
| | | payType3.add(6); |
| | | payType3.add(7); |
| | | LambdaQueryWrapper<Order> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | courseLambdaQueryWrapper.between(Order::getCreateTime, startTime, endTime); |
| | | if (courseDTO.getPayType()!=null){ |
| | | switch (courseDTO.getPayType()){ |
| | | case 1: |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType1); |
| | | break; |
| | | case 2: |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType2); |
| | | break; |
| | | case 3: |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType3); |
| | | break; |
| | | case 4: |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType4); |
| | | break; |
| | | } |
| | | |
| | | } |
| | | courseLambdaQueryWrapper.eq(courseDTO.getPaymentStatus()!=null,Order::getPaymentStatus, courseDTO.getPaymentStatus()); |
| | | courseLambdaQueryWrapper.eq(courseDTO.getOrderFrom()!=null,Order::getOrderFrom, courseDTO.getOrderFrom()); |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getBuyContent())){ |
| | | // 查询购买内容 |
| | | List<Long> collect1 = orderService.lambdaQuery().like(Order::getVipType, courseDTO.getBuyContent()).list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | List<Long> collect2 = orderService.lambdaQuery().like(Order::getBizOrderNo, courseDTO.getBuyContent()).list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | List<Long> data = remoteCourseService.getCourseIdsByName(courseDTO.getBuyContent()).getData(); |
| | | if (!data.isEmpty()){ |
| | | List<Long> collect3 = orderService.lambdaQuery().in(Order::getBusinessId, data) |
| | | .eq(Order::getOrderFrom, 2) |
| | | .list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | if (!collect3.isEmpty()){ |
| | | collect1.addAll(collect3); |
| | | } |
| | | } |
| | | List<Long> data1 = remoteMeditationService.getMeditationIdsByName(courseDTO.getBuyContent()).getData(); |
| | | if (!data1.isEmpty()){ |
| | | List<Long> collect3 = orderService.lambdaQuery().in(Order::getBusinessId, data1) |
| | | .eq(Order::getOrderFrom, 1) |
| | | .list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | if (!collect3.isEmpty()){ |
| | | collect1.addAll(collect3); |
| | | } |
| | | } |
| | | |
| | | collect1.addAll(collect2); |
| | | List<Long> collect = collect1.stream().distinct().collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Order::getId,collect); |
| | | } |
| | | courseLambdaQueryWrapper.orderByDesc(Order::getCreateTime); |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getUserNameOrPhone())){ |
| | | List<Long> collect = remoteAppUserService.getAppUserByNameOrPhone(courseDTO.getUserNameOrPhone()).getData(); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Order::getAppUserId, collect); |
| | | } |
| | | List<Order> page = orderService.list(courseLambdaQueryWrapper); |
| | | List<AppUserWithdraw> data2 = remoteAppUserService.getWithdraw(courseDTO).getData(); |
| | | for (AppUserWithdraw appUserWithdraw : data2) { |
| | | Order order = new Order(); |
| | | order.setId(appUserWithdraw.getId()); |
| | | order.setBizOrderNo(appUserWithdraw.getCode()); |
| | | order.setUid(appUserWithdraw.getId()+""); |
| | | order.setBuyContent("提现"); |
| | | order.setAppUserId(appUserWithdraw.getAppUserId()); |
| | | order.setOrderFrom(5); |
| | | order.setPaymentStatus(appUserWithdraw.getWithdrawStatus()+1); |
| | | order.setPayType(4); |
| | | order.setTotalAmount(appUserWithdraw.getAmount()); |
| | | order.setRealPayAmount(appUserWithdraw.getAmount()); |
| | | order.setPlatformMoney(appUserWithdraw.getAmount().multiply(new BigDecimal("-1"))); |
| | | order.setPaymentTime(appUserWithdraw.getWithdrawTime()); |
| | | order.setCreateTime(appUserWithdraw.getCreateTime()); |
| | | page.add(order); |
| | | } |
| | | Integer payCount = 0; |
| | | Integer completeCount = 0; |
| | | Integer cancelCount = 0; |
| | | BigDecimal totalMoney = new BigDecimal("0"); |
| | | for (Order record : page) { |
| | | if (record.getPaymentStatus()!=null){ |
| | | switch (record.getPaymentStatus()){ |
| | | case 1: |
| | | payCount++; |
| | | break; |
| | | case 2: |
| | | completeCount++; |
| | | break; |
| | | case 3: |
| | | cancelCount++; |
| | | break; |
| | | } |
| | | } |
| | | if (record.getRealPayAmount()!=null&& record.getRefundStatus()!=null && record.getRefundStatus()!=3){ |
| | | totalMoney = totalMoney.add(record.getRealPayAmount()); |
| | | } |
| | | } |
| | | orderCountVO.setTotalCount(page.size()); |
| | | orderCountVO.setPayCount(payCount); |
| | | orderCountVO.setCompleteCount(completeCount); |
| | | orderCountVO.setCancelCount(cancelCount); |
| | | orderCountVO.setTotalMoney(totalMoney); |
| | | return R.ok(orderCountVO); |
| | | } |
| | | |
| | | |
| | | @PutMapping("/exportOrder") |
| | | @ApiOperation(value = "订单列表-导出", tags = {"管理后台-订单列表管理"}) |
| | | public void exportOrder(@RequestBody OrderListDTO courseDTO) { |
| | | String startTime = null; |
| | | String endTime = null; |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getTime())){ |
| | | String[] split = courseDTO.getTime().split(" - "); |
| | | startTime = split[0]+"00:00:00"; |
| | | endTime = split[1]+"23:59:59"; |
| | | } |
| | | List<Integer> payType1 = new ArrayList<>(); |
| | | payType1.add(1); |
| | | payType1.add(5); |
| | | List<Integer> payType2 = new ArrayList<>(); |
| | | payType2.add(2); |
| | | payType2.add(6); |
| | | List<Integer> payType3 = new ArrayList<>(); |
| | | payType3.add(3); |
| | | payType3.add(7); |
| | | List<Integer> payType4 = new ArrayList<>(); |
| | | payType3.add(4); |
| | | payType3.add(5); |
| | | payType3.add(6); |
| | | payType3.add(7); |
| | | LambdaQueryWrapper<Order> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.hasLength(courseDTO.getIds())){ |
| | | courseLambdaQueryWrapper.in(Order::getId, Arrays.asList(courseDTO.getIds().split(","))); |
| | | } |
| | | if (startTime!=null){ |
| | | courseLambdaQueryWrapper.between(Order::getCreateTime, startTime, endTime); |
| | | } |
| | | if (courseDTO.getPayType()!=null){ |
| | | switch (courseDTO.getPayType()){ |
| | | case 1: |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType1); |
| | | break; |
| | | case 2: |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType2); |
| | | break; |
| | | case 3: |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType3); |
| | | break; |
| | | case 4: |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType4); |
| | | break; |
| | | } |
| | | } |
| | | courseLambdaQueryWrapper.ne(Order::getOrderFrom, 4); |
| | | courseLambdaQueryWrapper.ne(Order::getOrderFrom, 5); |
| | | courseLambdaQueryWrapper.eq(courseDTO.getPaymentStatus()!=null,Order::getPaymentStatus, courseDTO.getPaymentStatus()); |
| | | courseLambdaQueryWrapper.eq(courseDTO.getOrderFrom()!=null,Order::getOrderFrom, courseDTO.getOrderFrom()); |
| | | courseLambdaQueryWrapper.eq(courseDTO.getUid()!=null&&(!courseDTO.getUid().isEmpty()),Order::getAppUserId, courseDTO.getUid()); |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getBuyContent())){ |
| | | // 查询购买内容 |
| | | List<Long> collect1 = orderService.lambdaQuery().like(Order::getVipType, courseDTO.getBuyContent()).list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | List<Long> collect2 = orderService.lambdaQuery().like(Order::getBizOrderNo, courseDTO.getBuyContent()).list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | List<Long> data = remoteCourseService.getCourseIdsByName(courseDTO.getBuyContent()).getData(); |
| | | if (!data.isEmpty()){ |
| | | List<Long> collect3 = orderService.lambdaQuery().in(Order::getBusinessId, data) |
| | | .eq(Order::getOrderFrom, 2) |
| | | .list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | if (!collect3.isEmpty()){ |
| | | collect1.addAll(collect3); |
| | | } |
| | | } |
| | | List<Long> data1 = remoteMeditationService.getMeditationIdsByName(courseDTO.getBuyContent()).getData(); |
| | | if (!data1.isEmpty()){ |
| | | List<Long> collect3 = orderService.lambdaQuery().in(Order::getBusinessId, data1) |
| | | .eq(Order::getOrderFrom, 1) |
| | | .list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | if (!collect3.isEmpty()){ |
| | | collect1.addAll(collect3); |
| | | } |
| | | } |
| | | |
| | | collect1.addAll(collect2); |
| | | List<Long> collect = collect1.stream().distinct().collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Order::getId,collect); |
| | | } |
| | | |
| | | courseLambdaQueryWrapper.orderByDesc(Order::getCreateTime); |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getUserNameOrPhone())){ |
| | | List<Long> collect = remoteAppUserService.getAppUserByNameOrPhone(courseDTO.getUserNameOrPhone()).getData(); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Order::getAppUserId, collect); |
| | | } |
| | | |
| | | List<Order> page = orderService.list(courseLambdaQueryWrapper); |
| | | List<OrderExport> orderExports = new ArrayList<>(); |
| | | for (Order record : page) { |
| | | record.setUid(record.getId().toString()); |
| | | AppUser byId1 = remoteAppUserService.getAppUserById(record.getAppUserId()+"").getData(); |
| | | |
| | | if (record.getOrderFrom()!=null){ |
| | | switch (record.getOrderFrom()){ |
| | | case 1: |
| | | Meditation data = remoteMeditationService.getMeditationById(record.getBusinessId()).getData(); |
| | | if (data!=null){ |
| | | record.setCategoryMeditationName(data.getCategoryName()); |
| | | record.setMeditationTitle(data.getMeditationTitle()); |
| | | record.setIconUrl(data.getIconUrl()); |
| | | record.setDetailDescription(data.getDetailDescription()); |
| | | record.setGeneralPriceMeditation(data.getGeneralPrice()); |
| | | record.setListingStatusMeditation(data.getListingStatus()); |
| | | record.setMeditationUid(data.getId()+""); |
| | | } |
| | | break; |
| | | case 2: |
| | | Course data1 = remoteCourseService.getCourseById(record.getBusinessId()).getData(); |
| | | if (data1!=null){ |
| | | record.setCategoryCourseName(data1.getCategoryName()); |
| | | record.setCourseTitle(data1.getCourseTitle()); |
| | | record.setCoverUrl(data1.getCoverUrl()); |
| | | record.setTutor(data1.getTutor()); |
| | | record.setCourseChapterCount(data1.getCourseChapterCount()); |
| | | record.setGeneralPriceCourse(data1.getGeneralPrice()); |
| | | record.setListingStatusCourse(data1.getListingStatus()); |
| | | record.setCourseUid(data1.getId()+""); |
| | | } |
| | | break; |
| | | case 3: |
| | | record.setBuyContent(record.getVipType()); |
| | | record.setGeneralPriceVip(record.getRealPayAmount()); |
| | | break; |
| | | } |
| | | } |
| | | OrderExport orderExport = new OrderExport(); |
| | | orderExport.setCode(record.getBizOrderNo()); |
| | | if (Objects.nonNull(byId1)){ |
| | | record.setUserName(byId1.getNickname()); |
| | | record.setCellPhone(byId1.getCellPhone()); |
| | | orderExport.setUserName(byId1.getNickname()); |
| | | orderExport.setCellphone(byId1.getCellPhone()); |
| | | } |
| | | orderExport.setRealPayAmount("¥"+record.getRealPayAmount()); |
| | | orderExport.setBuyContent(record.getBuyContent()); |
| | | orderExport.setOrderFrom(record.getOrderFrom()+""); |
| | | orderExport.setPayType(record.getPayType()); |
| | | DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | String format = df.format(record.getCreateTime()); |
| | | orderExport.setCreateTime(format); |
| | | orderExport.setPaymentStatus(record.getPaymentStatus()+""); |
| | | orderExports.add(orderExport); |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), OrderExport.class, orderExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("订单管理导出.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | @PostMapping("/orderList") |
| | | @ApiOperation(value = "订单列表管理列表-分页", tags = {"管理后台-订单列表管理"}) |
| | | public R<PageDTO<Order>> orderList(@RequestBody OrderListDTO courseDTO) { |
| | |
| | | payType2.add(2); |
| | | payType2.add(6); |
| | | List<Integer> payType3 = new ArrayList<>(); |
| | | payType3.add(3); |
| | | payType3.add(7); |
| | | List<Integer> payType4 = new ArrayList<>(); |
| | | payType3.add(4); |
| | | payType3.add(5); |
| | | payType3.add(6); |
| | | payType3.add(7); |
| | | LambdaQueryWrapper<Order> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | courseLambdaQueryWrapper.between(Order::getCreateTime, startTime, endTime); |
| | | if (startTime!=null){ |
| | | courseLambdaQueryWrapper.between(Order::getCreateTime, startTime, endTime); |
| | | } |
| | | if (courseDTO.getPayType()!=null){ |
| | | switch (courseDTO.getPayType()){ |
| | | case 1: |
| | |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType2); |
| | | break; |
| | | case 3: |
| | | courseLambdaQueryWrapper.eq(Order::getPayType,courseDTO.getPayType()); |
| | | break; |
| | | case 4: |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType3); |
| | | break; |
| | | case 4: |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType4); |
| | | break; |
| | | } |
| | | |
| | | } |
| | | courseLambdaQueryWrapper.ne(Order::getOrderFrom, 4); |
| | | courseLambdaQueryWrapper.ne(Order::getOrderFrom, 5); |
| | | courseLambdaQueryWrapper.eq(courseDTO.getPaymentStatus()!=null,Order::getPaymentStatus, courseDTO.getPaymentStatus()); |
| | | courseLambdaQueryWrapper.eq(courseDTO.getOrderFrom()!=null,Order::getOrderFrom, courseDTO.getOrderFrom()); |
| | | courseLambdaQueryWrapper.eq(courseDTO.getUid()!=null&&(!courseDTO.getUid().isEmpty()),Order::getAppUserId, courseDTO.getUid()); |
| | |
| | | if (Objects.nonNull(byId1)){ |
| | | record.setUserName(byId1.getNickname()); |
| | | record.setCellPhone(byId1.getCellPhone()); |
| | | record.setAvatar(byId1.getAvatar()); |
| | | } |
| | | if (record.getOrderFrom()!=null){ |
| | | switch (record.getOrderFrom()){ |
| | |
| | | } |
| | | break; |
| | | case 2: |
| | | Course data1 = remoteCourseService.getCourseById(record.getBusinessId(),"").getData(); |
| | | Course data1 = remoteCourseService.getCourseById(record.getBusinessId()).getData(); |
| | | if (data1!=null){ |
| | | record.setCategoryCourseName(data1.getCategoryName()); |
| | | record.setCourseTitle(data1.getCourseTitle()); |
| | |
| | | payType2.add(2); |
| | | payType2.add(6); |
| | | List<Integer> payType3 = new ArrayList<>(); |
| | | payType3.add(3); |
| | | payType3.add(7); |
| | | List<Integer> payType4 = new ArrayList<>(); |
| | | payType3.add(4); |
| | | payType3.add(5); |
| | | payType3.add(6); |
| | | payType3.add(7); |
| | | LambdaQueryWrapper<Order> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | courseLambdaQueryWrapper.between(Order::getCreateTime, startTime, endTime); |
| | |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType2); |
| | | break; |
| | | case 3: |
| | | courseLambdaQueryWrapper.eq(Order::getPayType,courseDTO.getPayType()); |
| | | break; |
| | | case 4: |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType3); |
| | | break; |
| | | case 4: |
| | | courseLambdaQueryWrapper.in(Order::getPayType,payType4); |
| | | break; |
| | | } |
| | | |
| | | } |
| | | courseLambdaQueryWrapper.ne(Order::getOrderFrom, 4); |
| | | courseLambdaQueryWrapper.ne(Order::getOrderFrom, 5); |
| | | courseLambdaQueryWrapper.eq(courseDTO.getPaymentStatus()!=null,Order::getPaymentStatus, courseDTO.getPaymentStatus()); |
| | | courseLambdaQueryWrapper.eq(courseDTO.getOrderFrom()!=null,Order::getOrderFrom, courseDTO.getOrderFrom()); |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getBuyContent())){ |
| | |
| | | } |
| | | |
| | | @GetMapping("/detailOrder") |
| | | @ApiOperation(value = "查看详情订单列表管理", notes = "管理后台-订单列表管理") |
| | | @ApiOperation(value = "查看详情订单列表管理", tags = "管理后台-订单列表管理") |
| | | public R<Order> detailOrder(String uid) { |
| | | Order record = orderService.getById(uid); |
| | | if (record.getOrderFrom()!=null){ |
| | |
| | | record.setGeneralPriceMeditation(data.getGeneralPrice()); |
| | | record.setListingStatusMeditation(data.getListingStatus()); |
| | | record.setMeditationUid(data.getId()+""); |
| | | record.setUuid(data.getId()+""); |
| | | |
| | | } |
| | | break; |
| | | case 2: |
| | | Course data1 = remoteCourseService.getCourseById(record.getBusinessId(),"").getData(); |
| | | Course data1 = remoteCourseService.getCourseById(record.getBusinessId()).getData(); |
| | | if (data1!=null){ |
| | | record.setCategoryCourseName(data1.getCategoryName()); |
| | | record.setCourseTitle(data1.getCourseTitle()); |
| | |
| | | record.setGeneralPriceCourse(data1.getGeneralPrice()); |
| | | record.setListingStatusCourse(data1.getListingStatus()); |
| | | record.setCourseUid(data1.getId()+""); |
| | | record.setType(data1.getCourseType()+""); |
| | | record.setUuid(data1.getId()+""); |
| | | } |
| | | break; |
| | | case 3: |
| | |
| | | case 2: |
| | | record.setPaymentType("支付宝(¥"+record.getRealPayAmount()+")"); |
| | | break; |
| | | case 3: |
| | | case 4: |
| | | record.setPaymentType("余额(¥"+record.getRealPayAmount()+")"); |
| | | break; |
| | | case 4: |
| | | case 3: |
| | | record.setPaymentType("内购(¥"+record.getRealPayAmount()+")"); |
| | | break; |
| | | } |
| | |
| | | return R.ok(record); |
| | | } |
| | | @GetMapping("/cancel") |
| | | @ApiOperation(value = "取消订单", notes = "管理后台-订单列表管理") |
| | | @ApiOperation(value = "取消订单", tags = "管理后台-订单列表管理") |
| | | public R updateState(String uid) { |
| | | Order byId = orderService.getById(uid); |
| | | byId.setPaymentStatus(3); |
| | | orderService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | @GetMapping("/getChangeMoney") |
| | | @ApiOperation(value = "获取改价页面数据", tags = "管理后台-订单列表管理") |
| | | public R<Order> getChangeMoney(String uid) { |
| | | Order byId = orderService.getById(uid); |
| | | AppUser data = remoteAppUserService.getAppUserById(byId.getAppUserId() + "").getData(); |
| | | if (data!=null){ |
| | | byId.setCellPhone(data.getCellPhone()); |
| | | byId.setUserName(data.getNickname()); |
| | | byId.setAvatar(data.getAvatar()); |
| | | } |
| | | return R.ok(byId); |
| | | } |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @GetMapping("/ChangeMoney") |
| | | @ApiOperation(value = "改价", tags = "管理后台-订单列表管理") |
| | | public R ChangeMoney(String uid,String amount) { |
| | | Order byId = orderService.getById(uid); |
| | | byId.setChangePrice(new BigDecimal(amount)); |
| | | byId.setChangePriceTime(LocalDateTime.now()); |
| | | byId.setRealPayAmount(byId.getTotalAmount().add(byId.getChangePrice())); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | byId.setChangePriceOperator(loginUser.getUserid()); |
| | | orderService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | } |
| | | |
New file |
| | |
| | | package com.xinquan.order.domain.export; |
| | | |
| | | import cn.afterturn.easypoi.excel.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @ApiModel(value = "订单管理-导出") |
| | | public class OrderExport implements Serializable { |
| | | |
| | | @Excel(name = "订单编号",width = 30) |
| | | private String code; |
| | | @Excel(name = "用户昵称",width = 30) |
| | | private String userName; |
| | | @Excel(name = "用户手机号",width = 30) |
| | | private String cellphone; |
| | | @Excel(name = "订单价格",width = 30) |
| | | private String realPayAmount; |
| | | @Excel(name = "购买内容",width = 30) |
| | | private String buyContent; |
| | | @Excel(name = "订单类型",width = 30,replace = {"购买疗愈_1","购买课程_2","购买会员_3","余额充值_4","余额提现_5"}) |
| | | private String orderFrom; |
| | | @ApiModelProperty(value = "支付方式 1微信 2支付宝 3内购 4余额 5微信+余额 6支付宝+余额 7内购加余额") |
| | | @Excel(name = "支付方式",width = 30,replace = {"微信_1","支付宝_2","内购_3","余额_4","微信+余额_5","支付宝+余额_6","内购加余额_7"}) |
| | | private Integer payType; |
| | | @Excel(name = "下单时间",width = 30 ) |
| | | private String createTime; |
| | | @Excel(name = "支付状态",width = 30,replace = {"待支付_1","已完成_2","已取消_3"}) |
| | | private String paymentStatus; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.xinquan.order.domain.export; |
| | | |
| | | import cn.afterturn.easypoi.excel.annotation.Excel; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @ApiModel(value = "收支流水管理-导出") |
| | | public class WaterExport implements Serializable { |
| | | |
| | | @Excel(name = "订单编号",width = 30) |
| | | private String code; |
| | | @Excel(name = "用户昵称",width = 30) |
| | | private String userName; |
| | | @Excel(name = "用户手机号",width = 30) |
| | | private String cellphone; |
| | | @Excel(name = "用户实付",width = 30) |
| | | private String realPayAmount; |
| | | @Excel(name = "分佣支出",width = 30) |
| | | private String commissionAmount; |
| | | @Excel(name = "平台收益",width = 30) |
| | | private String platformMoney; |
| | | @Excel(name = "内容",width = 30) |
| | | private String buyContent; |
| | | @Excel(name = "订单来源",width = 30,replace = {"购买疗愈_1","购买课程_2","购买会员_3","余额充值_4","余额提现_5"}) |
| | | private String orderFrom; |
| | | @ApiModelProperty(value = "支付方式 1微信 2支付宝 3内购 4余额 5微信+余额 6支付宝+余额 7内购加余额") |
| | | @Excel(name = "支付方式",width = 30,replace = {"微信_1","支付宝_2","内购_3","余额_4","微信+余额_5","支付宝+余额_6","内购加余额_7"}) |
| | | private Integer payType; |
| | | @Excel(name = "下单时间",width = 30 ) |
| | | private String createTime; |
| | | @Excel(name = "支付状态",width = 30,replace = {"待支付_1","已完成_1","已取消_2"}) |
| | | private String paymentStatus; |
| | | |
| | | |
| | | } |
| | |
| | | @ApiModelProperty("支付宝支付链接") |
| | | private String qrcodeUrl; |
| | | |
| | | @ApiModelProperty("微信支付信息,用于唤起微信支付") |
| | | @ApiModelProperty("预支付标识信息,用户唤起平台的客户端") |
| | | private String payInfo; |
| | | @ApiModelProperty("小程序APPID,用于唤起微信小程序进行托管支付") |
| | | private String appId; |
| | | @ApiModelProperty("微信支付信息,小程序的路径 例如:pages/fromAppPay/index") |
| | | private String path; |
| | | @ApiModelProperty("微信支付信息,小程序原始id") |
| | | private String orgId; |
| | | @ApiModelProperty("微信支付信息,交易金额 ") |
| | | private String payAmt; |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.xinquan.order.api.domain.Order; |
| | | import com.xinquan.order.domain.vo.ClientPlaceOrderVO; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | * @see com.xinquan.order.domain.vo.ClientPlaceOrderVO |
| | | */ |
| | | ClientPlaceOrderVO placeOrder(Long targetId, Integer orderFrom, Long receiverId, |
| | | Integer balanceFlag, Integer payType) throws Exception; |
| | | Integer balanceFlag, Integer payType,BigDecimal amount,Integer vipType) throws Exception; |
| | | |
| | | /** |
| | | * 根据类型获取已完成的订单列表 |
| | |
| | | * @return |
| | | */ |
| | | List<Order> getOrderListByType(Long userId, Integer orderFrom); |
| | | |
| | | String placeOrderApple(Long targetId, Integer orderFrom, Long receiverId, Integer balanceFlag, BigDecimal amount, Integer vipType, String transactionIdentifier); |
| | | |
| | | String refund(Long uid) throws Exception; |
| | | } |
| | |
| | | package com.xinquan.order.service.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.C; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xinquan.common.core.constant.Constants; |
| | | import com.xinquan.common.core.constant.SecurityConstants; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.enums.ChargeTypeEnum; |
| | | import com.xinquan.common.core.enums.DisabledEnum; |
| | | import com.xinquan.common.core.enums.PaymentStatusEnum; |
| | | import com.xinquan.common.core.enums.PaymentTypeEnum; |
| | | import com.xinquan.common.core.exception.ServiceException; |
| | | import com.xinquan.common.core.utils.ip.IpUtils; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.course.api.feign.RemoteCourseService; |
| | |
| | | import com.xinquan.order.utils.JuHeFuUtil; |
| | | import com.xinquan.order.utils.OrderUtil; |
| | | import com.xinquan.system.api.domain.AppUser; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.user.api.domain.dto.AppUserDTO; |
| | | import com.xinquan.user.api.feign.RemoteAppUserService; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.List; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | private RemoteAppUserService remoteAppUserService; |
| | | @Resource |
| | | private OrderPaymentRecordService orderPaymentRecordService; |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | /** |
| | | * 创建待支付订单 |
| | | * |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ClientPlaceOrderVO placeOrder(Long targetId, Integer orderFrom, Long receiverId, |
| | | Integer balanceFlag, Integer payType) throws Exception { |
| | | Integer balanceFlag, Integer payType,BigDecimal amount,Integer vipType) throws Exception { |
| | | // 获取当前登录用户id |
| | | Long userId = SecurityUtils.getUserId(); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return new ClientPlaceOrderVO(); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | if (amount!=null){ |
| | | amount = amount.setScale(2, RoundingMode.HALF_DOWN); |
| | | } |
| | | // 获取用户信息 |
| | | AppUser appUser = getAppUserById(userId); |
| | | ClientPlaceOrderVO clientPlaceOrderVO = new ClientPlaceOrderVO(); |
| | |
| | | order.setBizOrderNo(orderNo); |
| | | order.setBusinessId(meditation.getId()); |
| | | order.setAppUserId(userId); |
| | | |
| | | order.setTotalAmount(meditation.getGeneralPrice()); |
| | | this.save(order); |
| | | Long orderId = order.getId(); |
| | |
| | | if (needPayAmount.compareTo(BigDecimal.ZERO) <= 0) { |
| | | clientPlaceOrderVO.setZeroFlag(DisabledEnum.YES.getCode()); |
| | | // 抵扣后金额为0 为余额支付 |
| | | order.setPayType(3); |
| | | order.setPayType(4); |
| | | order.setRealPayAmount(meditation.getGeneralPrice()); |
| | | this.updateById(order); |
| | | return clientPlaceOrderVO; |
| | |
| | | if (payType==1){ |
| | | // 微信+余额 |
| | | order.setPayType(5); |
| | | }else{ |
| | | }else if (payType == 2){ |
| | | // 支付宝+余额 |
| | | order.setPayType(6); |
| | | } |
| | |
| | | createPayment(payType, orderNo, meditation.getGeneralPrice(), meditationTitle, |
| | | detailDescription, wxOpenId, orderId, clientPlaceOrderVO); |
| | | } |
| | | } else if (orderFrom == 2){ |
| | | } |
| | | else if (orderFrom == 2){ |
| | | // 购买课程 |
| | | Course course = remoteCourseService.getCourseById(targetId, |
| | | SecurityConstants.INNER).getData(); |
| | | Course course = remoteCourseService.getCourseById(targetId).getData(); |
| | | String courseTitle = course.getCourseTitle(); |
| | | String wxOpenId = appUser.getWxOpenId(); |
| | | String description = course.getDescription(); |
| | |
| | | String orderNo = OrderUtil.getOrderNoForPrefix("KC"); |
| | | order.setOrderFrom(orderFrom); |
| | | order.setBizOrderNo(orderNo); |
| | | order.setGiveUserId(receiverId); |
| | | order.setBusinessId(course.getId()); |
| | | order.setAppUserId(userId); |
| | | order.setTotalAmount(course.getGeneralPrice()); |
| | |
| | | |
| | | if (needPayAmount.compareTo(BigDecimal.ZERO) <= 0) { |
| | | clientPlaceOrderVO.setZeroFlag(DisabledEnum.YES.getCode()); |
| | | // 抵扣后金额为0 为余额支付 |
| | | order.setPayType(4); |
| | | order.setRealPayAmount(course.getGeneralPrice()); |
| | | this.updateById(order); |
| | | return clientPlaceOrderVO; |
| | | } |
| | | if (payType==1){ |
| | | // 微信+余额 |
| | | order.setPayType(5); |
| | | }else if (payType == 2){ |
| | | // 支付宝+余额 |
| | | order.setPayType(6); |
| | | } |
| | | // 创建支付订单 |
| | | createPayment(payType, orderNo, needPayAmount, courseTitle, description, |
| | |
| | | createPayment(payType, orderNo, course.getGeneralPrice(), courseTitle, |
| | | description, wxOpenId, orderId, clientPlaceOrderVO); |
| | | } |
| | | }else if (orderFrom == 3){ |
| | | // 购买会员 |
| | | } |
| | | else if (orderFrom == 3){ |
| | | String wxOpenId = appUser.getWxOpenId(); |
| | | // 创建订单 |
| | | String orderNo = OrderUtil.getOrderNoForPrefix("HY"); |
| | | order.setOrderFrom(orderFrom); |
| | | order.setBizOrderNo(orderNo); |
| | | order.setAppUserId(userId); |
| | | order.setTotalAmount(amount); |
| | | order.setPayType(payType); |
| | | order.setRealPayAmount(amount); |
| | | String vipType1 =""; |
| | | switch (vipType){ |
| | | case 1: |
| | | vipType1="月会员"; |
| | | break; |
| | | case 2: |
| | | vipType1="季会员"; |
| | | break; |
| | | case 3: |
| | | vipType1="年会员"; |
| | | break; |
| | | } |
| | | order.setBuyContent(vipType1); |
| | | this.save(order); |
| | | Long orderId = order.getId(); |
| | | clientPlaceOrderVO.setOrderNo(orderNo); |
| | | clientPlaceOrderVO.setId(orderId); |
| | | // 创建支付订单 |
| | | createPayment(payType, orderNo, amount, "购买会员", |
| | | vipType1, wxOpenId, orderId, clientPlaceOrderVO); |
| | | |
| | | }else { |
| | | // 充值 |
| | | String wxOpenId = appUser.getWxOpenId(); |
| | | // 创建订单 |
| | | String orderNo = OrderUtil.getOrderNoForPrefix("CZ"); |
| | | order.setOrderFrom(orderFrom); |
| | | order.setBizOrderNo(orderNo); |
| | | order.setAppUserId(userId); |
| | | order.setTotalAmount(amount); |
| | | order.setRealPayAmount(amount); |
| | | order.setPayType(payType); |
| | | order.setBuyContent("充值"); |
| | | this.save(order); |
| | | Long orderId = order.getId(); |
| | | clientPlaceOrderVO.setOrderNo(orderNo); |
| | | clientPlaceOrderVO.setId(orderId); |
| | | // 创建支付订单 |
| | | createPayment(payType, orderNo, amount, "充值余额", |
| | | "充值余额", wxOpenId, orderId, clientPlaceOrderVO); |
| | | } |
| | | return clientPlaceOrderVO; |
| | | } |
| | |
| | | private void createPayment(Integer payType, String orderNo, BigDecimal needPayAmount, |
| | | String goodsTitle, String goodsDesc, String wxOpenId, Long orderId, |
| | | ClientPlaceOrderVO clientPlaceOrderVO) throws Exception { |
| | | // 截取前42个字符 商品描述信息,微信小程序和微信公众号该字段,最大长度 42 个字符 |
| | | goodsDesc = goodsDesc.substring(0, 42); |
| | | // 调用第三方支付获取支付信息 |
| | | JSONObject payInfo = JuHeFuUtil.createPayment(orderNo, payType, |
| | | needPayAmount.toString(), goodsTitle, goodsDesc, |
| | | IpUtils.getIpAddr(), wxOpenId, Constants.PAYMENT_NOTIFY_URL); |
| | | // 第三方支付记录 |
| | | OrderPaymentRecord paymentRecord = new OrderPaymentRecord(); |
| | | paymentRecord.setOrderId(orderId); |
| | | |
| | | if (payType == 1) { |
| | | clientPlaceOrderVO.setPayInfo(payInfo.getString("pay_info")); |
| | | if (payType == 1){ |
| | | // 微信托管支付 |
| | | // 截取前42个字符 商品描述信息,微信小程序和微信公众号该字段,最大长度 42 个字符 |
| | | // 调用第三方支付获取支付信息 |
| | | JSONObject payInfo = JuHeFuUtil.createPayment1(orderNo, payType, |
| | | needPayAmount.toString(), goodsTitle, goodsDesc, |
| | | IpUtils.getIpAddr(), wxOpenId, "https://v7ro848ar5jx.ngrok.xiaomiqiu123.top/order/client/order/order/base/callback"); |
| | | // 第三方支付记录 |
| | | OrderPaymentRecord paymentRecord = new OrderPaymentRecord(); |
| | | paymentRecord.setOrderId(orderId); |
| | | Order byId = this.getById(orderId); |
| | | this.updateById(byId); |
| | | clientPlaceOrderVO.setPayAmt(payInfo.getString("pay_amt")); |
| | | clientPlaceOrderVO.setPath(payInfo.getJSONObject("expend").getString("path")); |
| | | clientPlaceOrderVO.setPayInfo(payInfo.getJSONObject("expend").getString("pay_info")); |
| | | clientPlaceOrderVO.setOrgId(payInfo.getJSONObject("expend").getString("org_id")); |
| | | clientPlaceOrderVO.setAppId(payInfo.getJSONObject("expend").getString("app_id")); |
| | | paymentRecord.setPaymentType(PaymentTypeEnum.WECHAT_PAY.getCode()); |
| | | } else { |
| | | paymentRecord.setPayOrderNo(payInfo.getString("id")); |
| | | paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode()); |
| | | paymentRecord.setPayAmount(needPayAmount); |
| | | orderPaymentRecordService.save(paymentRecord); |
| | | // 设置订单是否需要支付标识 |
| | | clientPlaceOrderVO.setZeroFlag(DisabledEnum.NO.getCode()); |
| | | }else{ |
| | | // 调用第三方支付获取支付信息 |
| | | JSONObject payInfo = JuHeFuUtil.createPayment(orderNo, payType, |
| | | needPayAmount.toString(), goodsTitle, goodsDesc, |
| | | IpUtils.getIpAddr(), wxOpenId, "https://v7ro848ar5jx.ngrok.xiaomiqiu123.top/order/client/order/order/base/callback"); |
| | | // 第三方支付记录 |
| | | OrderPaymentRecord paymentRecord = new OrderPaymentRecord(); |
| | | paymentRecord.setOrderId(orderId); |
| | | paymentRecord.setPayAmount(needPayAmount); |
| | | Order byId = this.getById(orderId); |
| | | byId.setPayOrderNo(payInfo.getString("id")); |
| | | this.updateById(byId); |
| | | clientPlaceOrderVO.setQrcodeUrl(payInfo.getString("qrcode_url")); |
| | | paymentRecord.setPaymentType(PaymentTypeEnum.ALI_PAY.getCode()); |
| | | paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode()); |
| | | orderPaymentRecordService.save(paymentRecord); |
| | | // 设置订单是否需要支付标识 |
| | | clientPlaceOrderVO.setZeroFlag(DisabledEnum.NO.getCode()); |
| | | } |
| | | |
| | | paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode()); |
| | | orderPaymentRecordService.save(paymentRecord); |
| | | // 设置订单是否需要支付标识 |
| | | clientPlaceOrderVO.setZeroFlag(DisabledEnum.NO.getCode()); |
| | | } |
| | | |
| | | /** |
| | |
| | | return this.lambdaQuery().eq(Order::getAppUserId, userId).eq(Order::getOrderFrom, orderFrom) |
| | | .eq(Order::getPaymentStatus, PaymentStatusEnum.COMPLETED.getCode()).list(); |
| | | } |
| | | |
| | | @Override |
| | | public String placeOrderApple(Long targetId, Integer orderFrom, |
| | | Long receiverId, Integer balanceFlag, |
| | | BigDecimal amount, Integer vipType, String transactionIdentifier) { |
| | | // 获取当前登录用户id |
| | | Long userId = tokenService.getLoginUser().getUserid(); |
| | | // 获取用户信息 |
| | | AppUser appUser = getAppUserById(userId); |
| | | ClientPlaceOrderVO clientPlaceOrderVO = new ClientPlaceOrderVO(); |
| | | Order order = new Order(); |
| | | // 购买冥想音频 |
| | | if (orderFrom == 1) { |
| | | Meditation meditation = remoteMeditationService.getMeditationById(targetId, |
| | | SecurityConstants.INNER).getData(); |
| | | // 创建订单 |
| | | String orderNo = OrderUtil.getOrderNoForPrefix("MX"); |
| | | order.setOrderFrom(orderFrom); |
| | | order.setBizOrderNo(orderNo); |
| | | order.setBusinessId(meditation.getId()); |
| | | order.setAppUserId(userId); |
| | | order.setTotalAmount(meditation.getIosPrice()); |
| | | order.setPayType(3); |
| | | order.setBuyContent("购买疗愈"); |
| | | this.save(order); |
| | | Long orderId = order.getId(); |
| | | clientPlaceOrderVO.setOrderNo(orderNo); |
| | | clientPlaceOrderVO.setId(orderId); |
| | | // 如果冥想音频价格设定为单独收费,且需要使用余额抵扣 |
| | | if (balanceFlag.equals(1) && meditation.getChargeType().equals(ChargeTypeEnum.SEPARATE_CHARGE.getCode())) { |
| | | BigDecimal needPayAmount = handleBalancePayment(appUser, |
| | | meditation.getIosPrice(), |
| | | orderId); |
| | | if (needPayAmount.compareTo(BigDecimal.ZERO) <= 0) { |
| | | clientPlaceOrderVO.setZeroFlag(DisabledEnum.YES.getCode()); |
| | | // 抵扣后金额为0 为余额支付 |
| | | order.setPayType(4); |
| | | order.setRealPayAmount(meditation.getIosPrice()); |
| | | this.updateById(order); |
| | | return order.getId().toString(); |
| | | }else{ |
| | | order.setPayType(7); |
| | | this.updateById(order); |
| | | // 创建支付订单 |
| | | OrderPaymentRecord paymentRecord = new OrderPaymentRecord(); |
| | | paymentRecord.setPayAmount(meditation.getIosPrice()); |
| | | paymentRecord.setPayOrderNo(transactionIdentifier); |
| | | paymentRecord.setOrderId(orderId); |
| | | paymentRecord.setPaymentType(PaymentTypeEnum.IOS_PAY.getCode()); |
| | | paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode()); |
| | | orderPaymentRecordService.save(paymentRecord); |
| | | } |
| | | |
| | | } else { |
| | | order.setPayType(3); |
| | | this.updateById(order); |
| | | // 纯内购支付 |
| | | OrderPaymentRecord paymentRecord = new OrderPaymentRecord(); |
| | | paymentRecord.setPayAmount(meditation.getIosPrice()); |
| | | paymentRecord.setPayOrderNo(transactionIdentifier); |
| | | paymentRecord.setOrderId(orderId); |
| | | paymentRecord.setPaymentType(PaymentTypeEnum.IOS_PAY.getCode()); |
| | | paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode()); |
| | | orderPaymentRecordService.save(paymentRecord); |
| | | } |
| | | } |
| | | else if (orderFrom == 2){ |
| | | // 购买课程 |
| | | Course course = remoteCourseService.getCourseById(targetId).getData(); |
| | | // 创建订单 |
| | | String orderNo = OrderUtil.getOrderNoForPrefix("KC"); |
| | | order.setOrderFrom(orderFrom); |
| | | order.setBuyContent("购买课程"); |
| | | order.setBizOrderNo(orderNo); |
| | | order.setPayOrderNo(transactionIdentifier); |
| | | order.setGiveUserId(receiverId); |
| | | order.setBusinessId(course.getId()); |
| | | order.setAppUserId(userId); |
| | | order.setTotalAmount(course.getIosPrice()); |
| | | this.save(order); |
| | | Long orderId = order.getId(); |
| | | clientPlaceOrderVO.setOrderNo(orderNo); |
| | | clientPlaceOrderVO.setId(orderId); |
| | | if (balanceFlag.equals(1) && course.getChargeType() |
| | | .equals(ChargeTypeEnum.SEPARATE_CHARGE.getCode())) { |
| | | BigDecimal needPayAmount = handleBalancePayment(appUser, course.getGeneralPrice(), |
| | | orderId); |
| | | if (needPayAmount.compareTo(BigDecimal.ZERO) <= 0) { |
| | | clientPlaceOrderVO.setZeroFlag(DisabledEnum.YES.getCode()); |
| | | // 抵扣后金额为0 为余额支付 |
| | | order.setPayType(4); |
| | | order.setRealPayAmount(course.getGeneralPrice()); |
| | | this.updateById(order); |
| | | return order.getId()+""; |
| | | }else{ |
| | | order.setPayType(7); |
| | | this.updateById(order); |
| | | // 创建支付订单 |
| | | OrderPaymentRecord paymentRecord = new OrderPaymentRecord(); |
| | | paymentRecord.setPayAmount(course.getIosPrice()); |
| | | paymentRecord.setPayOrderNo(transactionIdentifier); |
| | | paymentRecord.setOrderId(orderId); |
| | | paymentRecord.setPaymentType(PaymentTypeEnum.IOS_PAY.getCode()); |
| | | paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode()); |
| | | orderPaymentRecordService.save(paymentRecord); |
| | | } |
| | | } else { |
| | | order.setPayType(3); |
| | | this.updateById(order); |
| | | // 创建支付订单 |
| | | OrderPaymentRecord paymentRecord = new OrderPaymentRecord(); |
| | | paymentRecord.setPayAmount(course.getIosPrice()); |
| | | paymentRecord.setPayOrderNo(transactionIdentifier); |
| | | paymentRecord.setOrderId(orderId); |
| | | paymentRecord.setPaymentType(PaymentTypeEnum.IOS_PAY.getCode()); |
| | | paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode()); |
| | | orderPaymentRecordService.save(paymentRecord); |
| | | } |
| | | } |
| | | else if (orderFrom == 3){ |
| | | // 创建订单 |
| | | String orderNo = OrderUtil.getOrderNoForPrefix("HY"); |
| | | order.setOrderFrom(orderFrom); |
| | | order.setBizOrderNo(orderNo); |
| | | order.setAppUserId(userId); |
| | | order.setTotalAmount(amount); |
| | | String vipType1 =""; |
| | | switch (vipType){ |
| | | case 1: |
| | | vipType1="月会员"; |
| | | break; |
| | | case 2: |
| | | vipType1="季会员"; |
| | | break; |
| | | case 3: |
| | | vipType1="年会员"; |
| | | break; |
| | | } |
| | | order.setBuyContent(vipType1); |
| | | this.save(order); |
| | | Long orderId = order.getId(); |
| | | |
| | | order.setPayType(3); |
| | | this.updateById(order); |
| | | // 创建支付订单 |
| | | OrderPaymentRecord paymentRecord = new OrderPaymentRecord(); |
| | | paymentRecord.setPayAmount(amount); |
| | | paymentRecord.setPayOrderNo(transactionIdentifier); |
| | | paymentRecord.setOrderId(orderId); |
| | | paymentRecord.setPaymentType(PaymentTypeEnum.IOS_PAY.getCode()); |
| | | paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode()); |
| | | orderPaymentRecordService.save(paymentRecord); |
| | | }else { |
| | | // 充值 |
| | | String wxOpenId = appUser.getWxOpenId(); |
| | | // 创建订单 |
| | | String orderNo = OrderUtil.getOrderNoForPrefix("CZ"); |
| | | order.setOrderFrom(orderFrom); |
| | | order.setBizOrderNo(orderNo); |
| | | order.setAppUserId(userId); |
| | | order.setTotalAmount(amount); |
| | | order.setBuyContent("充值"); |
| | | this.save(order); |
| | | Long orderId = order.getId(); |
| | | order.setPayType(3); |
| | | this.updateById(order); |
| | | // 创建支付订单 |
| | | OrderPaymentRecord paymentRecord = new OrderPaymentRecord(); |
| | | paymentRecord.setPayAmount(amount); |
| | | paymentRecord.setPayOrderNo(transactionIdentifier); |
| | | paymentRecord.setOrderId(orderId); |
| | | paymentRecord.setPaymentType(PaymentTypeEnum.IOS_PAY.getCode()); |
| | | paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode()); |
| | | orderPaymentRecordService.save(paymentRecord); |
| | | } |
| | | return order.getId()+""; |
| | | } |
| | | |
| | | @Override |
| | | public String refund(Long uid) throws Exception { |
| | | Order byId = this.getById(uid); |
| | | OrderPaymentRecord one = orderPaymentRecordService.lambdaQuery() |
| | | .eq(OrderPaymentRecord::getOrderId, uid) |
| | | .ne(OrderPaymentRecord::getPaymentType, 3) |
| | | .ne(OrderPaymentRecord::getPaymentType, 4).one(); |
| | | |
| | | JuHeFuUtil.refund(one.getPayOrderNo(),byId.getBizOrderNo()); |
| | | return null; |
| | | } |
| | | } |
| | |
| | | private static final String AES_KEY = "cb0a181ac97395c6942be19315fc0727"; |
| | | // 创建用户接口 |
| | | private static final String CREATE_USER_INTERFACE = "/api/member/create_user_a"; |
| | | private static final String BALANCE_PAY = "/api/account/balance_pay"; |
| | | // 创建支付订单 |
| | | private static final String CREATE_PAYMENT_INTERFACE = "/api/payment/create_payment"; |
| | | private static final String CREATE_PAYMENT_INTERFACE_CODE = "/api/payment/create_payment_qrcode"; |
| | | private static final String CREATE_PAYMENT_INTERFACE_THIRD = "/api/payment/create_payment_third"; |
| | | // 退款接口 |
| | | private static final String PAYMENT_REFUND_INTERFACE = "/api/payment/payment_refund"; |
| | | private static final String MERCHANT_PAY_INTERFACE = "/api/account/merchant_pay"; |
| | |
| | | private static final String PAY_CHANNEL_ALIPAY = "alipay_qr"; |
| | | // 微信支付渠道 |
| | | private static final String PAY_CHANNEL_WECHAT = "wx_lite"; |
| | | private static final String PAY_CHANNEL_WECHAT_THiRD = "wx"; |
| | | // 微信小程序id TODO |
| | | private static final String WX_APP_ID = ""; |
| | | |
| | |
| | | * @return boolean |
| | | * @throws Exception |
| | | */ |
| | | public static boolean createUser(String memberId, Map<String, Object> memberP) |
| | | public static boolean createUser(String memberId) |
| | | throws Exception { |
| | | JSONObject memberP = new JSONObject(); |
| | | memberP.put("user_name","周帅"); |
| | | memberP.put("cert_type","00"); |
| | | memberP.put("cert_id","513902200006257079"); |
| | | memberP.put("tel_no","19983174515"); |
| | | memberP.put("card_id","6228480469852935177"); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("app_id", APP_ID); |
| | | data.put("member_id", memberId); |
| | | data.put("member_type", "01"); |
| | | data.put("member_p", memberP); |
| | | String jsonString = JSON.toJSONString(JSONObject.parseObject(data.toString(), TreeMap.class)); |
| | | data.put("member_p", jsonString); |
| | | |
| | | System.err.println(data); |
| | | JSONObject body = new JSONObject(); |
| | | body.put("merId", MER_ID); |
| | | body.put("sign", sign(JSONObject.toJSONString(data))); |
| | | body.put("reqCipher", |
| | | EncryptUtils.aes256ECBPkcs7PaddingEncrypt(JSONObject.toJSONString(data), AES_KEY)); |
| | | body.put("reqTime", DateUtils.dateTimeNow("yyyyMMddHHmmssfff")); |
| | | // 发送Post请求 |
| | | logger.info("桔禾付创建用户请求体====================>{}", body.toJSONString()); |
| | | body.put("reqTime", DateUtils.dateTimeNow("yyyyMMddHHmmsssss")); |
| | | System.err.println(body); |
| | | String result = sendPost(BASE_URL + CREATE_USER_INTERFACE, body); |
| | | logger.info("桔禾付创建用户请求结果====================>{}", result); |
| | | if (StringUtils.isBlank(result)) { |
| | | throw new ServiceException("请求第三方支付平台异常"); |
| | | } |
| | | JSONObject resJsonObject = JSONObject.parseObject(result); |
| | | if (resJsonObject.getString("status").equals("succeeded")) { |
| | | return true; |
| | | } else if (resJsonObject.getString("status").equals("failed")) { |
| | | throw new ServiceException(resJsonObject.getString("error_msg")); |
| | | } |
| | | System.err.println(resJsonObject); |
| | | return false; |
| | | } |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | createPayment("MX123aaa9999911",1, "0.01", |
| | | "测试商品", "测试商品描述", |
| | | "221.182.45.100", "oG50n6Vf0JNid5DOg0brcAnZ0T4s", "https://v7ro848ar5jx.ngrok.xiaomiqiu123.top/order/client/order/order/testCallback"); |
| | | createPaymentCode("CZ19281833123", 1, "0.01", |
| | | "充值", "充值", |
| | | "127.0.0.1", "openId", |
| | | "https://v7ro848ar5jx.ngrok.xiaomiqiu123.top/order/client/order/order/base/callback"); |
| | | // String orderNo = OrderUtil.getOrderNoForPrefix("User"); |
| | | // createUser("usera12937812893718297391"); |
| | | //// balancePay("12345678912", "0.01", "http://www.baidu.com"); |
| | | } |
| | | |
| | | public static JSONObject balancePay(String orderNo, String payAmt, String notifyUrl) throws Exception { |
| | | JSONObject data = new JSONObject(); |
| | | |
| | | data.put("order_no", orderNo); |
| | | data.put("app_id", APP_ID); |
| | | data.put("pay_amt", payAmt); |
| | | data.put("member_id", "21233333"); |
| | | data.put("notify_url", notifyUrl); |
| | | JSONObject body = new JSONObject(); |
| | | body.put("merId", MER_ID); |
| | | body.put("sign", sign(JSONObject.toJSONString(data))); |
| | | body.put("reqCipher", |
| | | EncryptUtils.aes256ECBPkcs7PaddingEncrypt(JSONObject.toJSONString(data), AES_KEY)); |
| | | body.put("reqTime", DateUtils.dateTimeNow("yyyyMMddHHmmsssss")); |
| | | String result = sendPost(BASE_URL + BALANCE_PAY, body); |
| | | JSONObject resJsonObject = JSONObject.parseObject(result); |
| | | System.err.println(resJsonObject); |
| | | String string = resJsonObject.getString("resCipher"); |
| | | String decrypt = decrypt(string); |
| | | System.err.println(decrypt); |
| | | JSONObject jsonObject = JSONObject.parseObject(decrypt); |
| | | System.err.println(jsonObject); |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 创建支付订单 |
| | | * |
| | |
| | | data.put("order_no", orderNo); |
| | | data.put("app_id", APP_ID); |
| | | if (payChannel == 1) { |
| | | data.put("pay_channel", PAY_CHANNEL_ALIPAY); |
| | | } else { |
| | | data.put("pay_channel", PAY_CHANNEL_WECHAT); |
| | | expand.put("open_id", openId); |
| | | expand.put("wx_app_id", WX_APP_ID); |
| | | data.put("expand", expand); |
| | | } else { |
| | | |
| | | data.put("pay_channel", PAY_CHANNEL_ALIPAY); |
| | | |
| | | } |
| | | data.put("pay_amt", payAmt); |
| | | data.put("goods_title", goodsTitle); |
| | |
| | | // if (resJsonObject.getString("status").equals("succeeded")) { |
| | | // return resJsonObject.getJSONObject("expand"); |
| | | // } |
| | | return jsonObject; |
| | | } |
| | | public static JSONObject createPaymentCode(String orderNo, Integer payChannel, String payAmt, |
| | | String goodsTitle, String goodsDesc, String deviceIp, String openId, |
| | | String notifyUrl) throws Exception { |
| | | JSONObject data = new JSONObject(); |
| | | JSONObject expand = new JSONObject(); |
| | | data.put("order_no", orderNo); |
| | | data.put("app_id", APP_ID); |
| | | if (payChannel == 1) { |
| | | data.put("pay_channel", PAY_CHANNEL_ALIPAY); |
| | | } else { |
| | | data.put("pay_channel", PAY_CHANNEL_WECHAT); |
| | | expand.put("open_id", openId); |
| | | expand.put("wx_app_id", WX_APP_ID); |
| | | data.put("expand", expand); |
| | | } |
| | | data.put("pay_amt", payAmt); |
| | | data.put("goods_title", goodsTitle); |
| | | data.put("goods_desc", goodsDesc); |
| | | data.put("time_expire", "20241031000000"); |
| | | Map<String, Object> deviceInfo = new HashMap<>(); |
| | | deviceInfo.put("device_ip", deviceIp); |
| | | data.put("device_info", deviceInfo); |
| | | data.put("notify_url", notifyUrl); |
| | | JSONObject body = new JSONObject(); |
| | | body.put("merId", MER_ID); |
| | | body.put("sign", sign(JSONObject.toJSONString(data))); |
| | | body.put("reqCipher", |
| | | EncryptUtils.aes256ECBPkcs7PaddingEncrypt(JSONObject.toJSONString(data), AES_KEY)); |
| | | body.put("reqTime", DateUtils.dateTimeNow("yyyyMMddHHmmsssss")); |
| | | String result = sendPost(BASE_URL + CREATE_PAYMENT_INTERFACE_CODE, body); |
| | | JSONObject resJsonObject = JSONObject.parseObject(result); |
| | | System.err.println(resJsonObject); |
| | | String string = resJsonObject.getString("resCipher"); |
| | | String decrypt = decrypt(string); |
| | | System.err.println(decrypt); |
| | | JSONObject jsonObject = JSONObject.parseObject(decrypt); |
| | | |
| | | // if (resJsonObject.getString("status").equals("failed")) { |
| | | // throw new ServiceException(resJsonObject.getString("error_msg")); |
| | | // } |
| | | // if (resJsonObject.getString("status").equals("succeeded")) { |
| | | // return resJsonObject.getJSONObject("expand"); |
| | | // } |
| | | return jsonObject.getJSONObject("expand"); |
| | | } |
| | | /** |
| | | * 创建支付订单 微信托管支付 |
| | | * |
| | | * @param orderNo 订单号 |
| | | * @param payChannel 支付渠道 1:支付宝 2:微信 |
| | | * @param payAmt 支付金额 |
| | | * @param goodsTitle 商品标题 |
| | | * @param goodsDesc 商品描述信息,微信小程序和微信公众号该字段 最大长度 42 个字符 |
| | | * @param deviceIp 设备支付公网ip |
| | | * @param openId 微信openId |
| | | * @param notifyUrl 回调地址 |
| | | * @return JSONObject |
| | | * @throws Exception |
| | | */ |
| | | public static JSONObject createPayment1(String orderNo, Integer payChannel, String payAmt, |
| | | String goodsTitle, String goodsDesc, String deviceIp, String openId, |
| | | String notifyUrl) throws Exception { |
| | | JSONObject data = new JSONObject(); |
| | | JSONObject expand = new JSONObject(); |
| | | data.put("order_no", orderNo); |
| | | data.put("app_id", APP_ID); |
| | | data.put("pay_channel", PAY_CHANNEL_WECHAT_THiRD); |
| | | data.put("pay_amt", payAmt); |
| | | data.put("goods_title", goodsTitle); |
| | | data.put("goods_desc", goodsDesc); |
| | | Map<String, Object> deviceInfo = new HashMap<>(); |
| | | deviceInfo.put("device_ip", deviceIp); |
| | | data.put("device_info", deviceInfo); |
| | | data.put("notify_url", notifyUrl); |
| | | JSONObject body = new JSONObject(); |
| | | body.put("merId", MER_ID); |
| | | body.put("sign", sign(JSONObject.toJSONString(data))); |
| | | body.put("reqCipher", |
| | | EncryptUtils.aes256ECBPkcs7PaddingEncrypt(JSONObject.toJSONString(data), AES_KEY)); |
| | | body.put("reqTime", DateUtils.dateTimeNow("yyyyMMddHHmmsssss")); |
| | | String result = sendPost(BASE_URL + CREATE_PAYMENT_INTERFACE_THIRD, body); |
| | | JSONObject resJsonObject = JSONObject.parseObject(result); |
| | | System.err.println(resJsonObject); |
| | | String string = resJsonObject.getString("resCipher"); |
| | | String decrypt = decrypt(string); |
| | | System.err.println("解密后"+decrypt); |
| | | JSONObject jsonObject = JSONObject.parseObject(decrypt); |
| | | |
| | | // if (resJsonObject.getString("status").equals("failed")) { |
| | | // throw new ServiceException(resJsonObject.getString("error_msg")); |
| | | // } |
| | | // if (resJsonObject.getString("status").equals("succeeded")) { |
| | | // return resJsonObject.getJSONObject("expand"); |
| | | // } |
| | | return jsonObject; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param orderNo 订单号 |
| | | * @return |
| | | */ |
| | | public static boolean refund(String paymentId, String orderNo) throws Exception { |
| | | public static String refund(String paymentId, String orderNo) throws Exception { |
| | | JSONObject data = new JSONObject(); |
| | | data.put("payment_id", paymentId); |
| | | data.put("order_no", orderNo); |
| | |
| | | body.put("sign", sign(JSONObject.toJSONString(data))); |
| | | body.put("reqCipher", |
| | | EncryptUtils.aes256ECBPkcs7PaddingEncrypt(JSONObject.toJSONString(data), AES_KEY)); |
| | | body.put("reqTime", DateUtils.dateTimeNow("yyyyMMddHHmmssfff")); |
| | | body.put("reqTime", DateUtils.dateTimeNow("yyyyMMddHHmmsssss")); |
| | | String result = sendPost(BASE_URL + PAYMENT_REFUND_INTERFACE, body); |
| | | JSONObject resJsonObject = JSONObject.parseObject(result); |
| | | if (resJsonObject.getString("status").equals("succeeded")) { |
| | | return true; |
| | | } else if (resJsonObject.getString("status").equals("failed")) { |
| | | throw new ServiceException(resJsonObject.getString("error_msg")); |
| | | } |
| | | return false; |
| | | // if (resJsonObject.getString("status").equals("succeeded")) { |
| | | // return "ok"; |
| | | // } else if (resJsonObject.getString("status").equals("failed")) { |
| | | // throw new ServiceException(resJsonObject.getString("error_msg")); |
| | | // } |
| | | return "ok"; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static boolean merchantPay(String orderNo, String payAmt, String cardName, String cardId, |
| | | public static JSONObject merchantPay(String orderNo, String payAmt, String cardName, String cardId, |
| | | String cardType) |
| | | throws Exception { |
| | | JSONObject data = new JSONObject(); |
| | | data.put("order_no", orderNo); |
| | | data.put("app_id", APP_ID); |
| | | data.put("pay_amt", payAmt); |
| | | data.put("card_name", cardName); |
| | | data.put("card_id", cardId); |
| | | data.put("card_type", cardType); |
| | | JSONObject body = new JSONObject(); |
| | | body.put("merId", MER_ID); |
| | | body.put("sign", sign(JSONObject.toJSONString(data))); |
| | |
| | | body.put("reqTime", DateUtils.dateTimeNow("yyyyMMddHHmmss")); |
| | | String result = sendPost(BASE_URL + MERCHANT_PAY_INTERFACE, body); |
| | | JSONObject resJsonObject = JSONObject.parseObject(result); |
| | | if (resJsonObject.getString("status").equals("succeeded")) { |
| | | return true; |
| | | } else if (resJsonObject.getString("status").equals("failed")) { |
| | | throw new ServiceException(resJsonObject.getString("error_msg")); |
| | | } |
| | | return false; |
| | | System.err.println(resJsonObject); |
| | | String string = resJsonObject.getString("resCipher"); |
| | | String decrypt = decrypt(string); |
| | | System.err.println("解密后"+decrypt); |
| | | JSONObject jsonObject = JSONObject.parseObject(decrypt); |
| | | return jsonObject; |
| | | } |
| | | |
| | | /** |
| | |
| | | <result column="change_price_operator" property="changePriceOperator" /> |
| | | <result column="payment_time" property="paymentTime" /> |
| | | <result column="cancel_time" property="cancelTime" /> |
| | | <result column="give_user_id" property="giveUserId" /> |
| | | </resultMap> |
| | | |
| | | <!-- 通用查询结果列 --> |
| | |
| | | create_time, |
| | | update_by, |
| | | update_time, |
| | | giveUserId, |
| | | id, biz_order_no, app_user_id, business_id, order_from, payment_status, total_amount, real_pay_amount, commission_amount, change_price, change_price_time, change_price_operator, payment_time, cancel_time |
| | | </sql> |
| | | |
| | |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>cn.afterturn</groupId> |
| | | <artifactId>easypoi-spring-boot-starter</artifactId> |
| | | <version>4.0.0</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <artifactId>guava</artifactId> |
| | | <groupId>com.google.guava</groupId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.google.zxing</groupId> |
| | | <artifactId>core</artifactId> |
| | | <version>3.4.1</version> |
| | |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | List<CourseCategory> data = remoteCourseService.cateList().getData(); |
| | | return R.ok(data); |
| | | } |
| | | @PostMapping("/courseList") |
| | | @GetMapping("/courseList") |
| | | @ApiOperation(value = "选择课程-分页",tags = "管理后台banner") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "分页参数,当前页码", name = "pageCurr", required = false, dataType = "Integer"), |
| | |
| | | @ApiImplicitParam(value = "课程标题", name = "courseTitle", required = false, dataType = "String"), |
| | | @ApiImplicitParam(value = "导师名称", name = "tutor", required = false, dataType = "String"), |
| | | }) |
| | | public R<PageDTO<Banner>> courseList( |
| | | @RequestParam(value = "pageCurr", defaultValue = "1") Integer pageCurr, |
| | | @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, |
| | | @RequestParam(value = "courseType") Integer courseType, |
| | | @RequestParam(value = "cateId") Long cateId, |
| | | @RequestParam(value = "courseTitle")String courseTitle, |
| | | @RequestParam(value = "tutor") String tutor |
| | | public R<PageDTO<Course>> courseList( |
| | | Integer pageCurr, |
| | | Integer pageSize, |
| | | Integer courseType, |
| | | Long cateId, |
| | | String courseTitle, |
| | | |
| | | String tutor |
| | | ) { |
| | | CourseDTO courseDTO = new CourseDTO(); |
| | | courseDTO.setPageCurr(pageCurr); |
| | |
| | | courseDTO.setCateId(cateId); |
| | | courseDTO.setCourseTitle(courseTitle); |
| | | courseDTO.setTutor(tutor); |
| | | remoteCourseService.courseList(courseDTO); |
| | | return R.ok(); |
| | | PageDTO<Course> data = remoteCourseService.courseList(courseDTO).getData(); |
| | | return R.ok(data); |
| | | } |
| | | @PostMapping("/deleteBatch") |
| | | @ApiOperation(value = "批量删除banner",tags = "管理后台banner") |
| | |
| | | public R deleteBatch( |
| | | @RequestParam(value = "ids") String ids) |
| | | { |
| | | List<String> list = Arrays.asList(ids.split(",")); |
| | | List<Long> list = Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList()); |
| | | bannerService.removeBatchByIds(list); |
| | | return R.ok(); |
| | | } |
| | |
| | | { |
| | | Banner byId = bannerService.getById(uid); |
| | | if (byId.getCourseId()!=null){ |
| | | Course data = remoteCourseService.getCourseById(byId.getCourseId(), "").getData(); |
| | | Course data = remoteCourseService.getCourseById(byId.getCourseId()).getData(); |
| | | if (data!=null){ |
| | | byId.setCourseTitle(data.getCourseTitle()); |
| | | byId.setCoverUrl(data.getCoverUrl()); |
| | |
| | | |
| | | |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.system.api.domain.vo.UpdateTreeGroupVO; |
| | | import com.xinquan.system.domain.CommissionRule; |
| | | import com.xinquan.system.domain.TreeLevelSetting; |
| | | import com.xinquan.system.api.domain.CommissionRule; |
| | | import com.xinquan.system.service.CommissionRuleService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/getCommission") |
| | | @ApiOperation(value = "获取",tags = "管理后台-树苗音频设置") |
| | | public R<CommissionRule> getTreeGroup() { |
| | | @ApiOperation(value = "获取",tags = "管理后台-分享设置") |
| | | public R<CommissionRule> getCommission() { |
| | | CommissionRule one1 = commissionRuleService.lambdaQuery().one(); |
| | | if (one1==null){ |
| | | return R.ok(new CommissionRule()); |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.core.web.domain.AjaxResult; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.system.api.RemoteUserService; |
| | | import com.xinquan.system.api.domain.AppUser; |
| | | import com.xinquan.system.api.domain.vo.InviteRankListVO; |
| | | import com.xinquan.system.domain.CommissionRule; |
| | | import com.xinquan.system.api.domain.CommissionRule; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.system.domain.CommonQuestion; |
| | | import com.xinquan.system.service.CommissionRuleService; |
| | | import com.xinquan.system.service.CommonQuestionService; |
| | |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.tomcat.util.http.fileupload.ByteArrayOutputStream; |
| | | import org.omg.CORBA.PRIVATE_MEMBER; |
| | | import org.aspectj.weaver.loadtime.Aj; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.core.io.ByteArrayResource; |
| | | import org.springframework.mock.web.MockMultipartFile; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | import javax.imageio.ImageIO; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/system/common-question") |
| | | |
| | | public class CommonQuestionController { |
| | | @Resource |
| | | private CommonQuestionService commonQuestionService; |
| | |
| | | private CommissionRuleService commissionRuleService; |
| | | @Resource |
| | | private RemoteUserService remoteUserService; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @PostMapping("/getQrCode") |
| | | @ApiOperation(value = "获取客服微信二维码",tags = "获取客服微信二维码") |
| | | public R getQrCode() { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | CommonQuestion one = commonQuestionService.lambdaQuery().eq(CommonQuestion::getType, 2).one(); |
| | | return R.ok(one.getCustomerServiceQrCode()); |
| | | } |
| | | @PostMapping("/commonQuestion") |
| | | @GetMapping("/commonQuestion") |
| | | @ApiOperation(value = "常见问题列表", tags = {"联系客服"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "分页参数,当前页码", name = "pageCurr", required = true, dataType = "Integer"), |
| | |
| | | public R<PageDTO<CommonQuestion>> myInviteRankList( |
| | | @RequestParam(value = "pageCurr", defaultValue = "1") Integer pageCurr, |
| | | @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | Page<CommonQuestion> page = commonQuestionService.lambdaQuery() |
| | | .orderByDesc(CommonQuestion::getSortNum) |
| | | .page(new Page<>(pageCurr, pageSize)); |
| | |
| | | } |
| | | return R.ok(PageDTO.of(page, CommonQuestion.class)); |
| | | } |
| | | @PostMapping("/commonQuestionList") |
| | | @GetMapping("/commonQuestionList") |
| | | @ApiOperation(value = "常见问题列表-分页", tags = {"管理后台-常见问题"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "分页参数,当前页码", name = "pageCurr", required = true, dataType = "Integer"), |
| | |
| | | public R<PageDTO<CommonQuestion>> commonQuestionList( |
| | | @RequestParam(value = "pageCurr", defaultValue = "1") Integer pageCurr, |
| | | @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | Page<CommonQuestion> page = commonQuestionService.lambdaQuery() |
| | | .eq(CommonQuestion::getType,1) |
| | | .orderByDesc(CommonQuestion::getSortNum) |
| | |
| | | } |
| | | return R.ok(PageDTO.of(page, CommonQuestion.class)); |
| | | } |
| | | @GetMapping("/detailKfCode") |
| | | @ApiOperation(value = "查看详情客服微信", tags = "管理后台-常见问题") |
| | | public R<CommonQuestion> detailKfCode() { |
| | | CommonQuestion one = commonQuestionService.lambdaQuery() |
| | | .eq(CommonQuestion::getType, 2).one(); |
| | | if (one == null){ |
| | | return R.ok(new CommonQuestion()); |
| | | } |
| | | one.setUid(one.getId()+""); |
| | | return R.ok(one); |
| | | } |
| | | @GetMapping("/updateKfCode") |
| | | @ApiOperation(value = "修改/新增客服微信", tags = "管理后台-常见问题") |
| | | public R<CommonQuestion> updateKfCode(String customerServiceQrCode) { |
| | | CommonQuestion one = commonQuestionService.lambdaQuery() |
| | | .eq(CommonQuestion::getType, 2).one(); |
| | | if (one == null){ |
| | | // 新增 |
| | | CommonQuestion commonQuestion = new CommonQuestion(); |
| | | commonQuestion.setCustomerServiceQrCode(customerServiceQrCode); |
| | | commonQuestion.setType(2); |
| | | commonQuestionService.save(commonQuestion); |
| | | }else{ |
| | | // 编辑 |
| | | one.setCustomerServiceQrCode(customerServiceQrCode); |
| | | commonQuestionService.updateById(one); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/addCommonQuestion") |
| | | @ApiOperation(value = "新增常见问题", notes = "管理后台-常见问题") |
| | | @ApiOperation(value = "新增常见问题", tags = "管理后台-常见问题") |
| | | public R addCommonQuestion(@RequestBody CommonQuestion homeBackgroundMusic) { |
| | | return R.ok(commonQuestionService.save(homeBackgroundMusic)); |
| | | } |
| | | |
| | | @GetMapping("/detailCommonQuestion") |
| | | @ApiOperation(value = "查看详情常见问题", notes = "管理后台-常见问题") |
| | | @ApiOperation(value = "查看详情常见问题", tags = "管理后台-常见问题") |
| | | public R<CommonQuestion> detailCommonQuestion(String uid) { |
| | | return R.ok(commonQuestionService.getById(uid)); |
| | | } |
| | | @PostMapping("/updateCommonQuestion") |
| | | @ApiOperation(value = "修改常见问题", notes = "管理后台-常见问题") |
| | | @ApiOperation(value = "修改常见问题", tags = "管理后台-常见问题") |
| | | public R updateCommonQuestion(@RequestBody CommonQuestion homeBackgroundMusic) { |
| | | return R.ok(commonQuestionService.updateById(homeBackgroundMusic)); |
| | | } |
| | | @PostMapping("/deleteCommonQuestion") |
| | | @ApiOperation(value = "批量删除", notes = "管理后台-常见问题") |
| | | @ApiOperation(value = "批量删除", tags = "管理后台-常见问题") |
| | | public R deleteCommonQuestion(String ids) { |
| | | return R.ok(commonQuestionService.removeBatchByIds(Arrays.asList(ids.split(",")))); |
| | | return R.ok(commonQuestionService.removeBatchByIds(Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList()))); |
| | | } |
| | | @PostMapping("/getQuestionById") |
| | | @ApiOperation(value = "常见问题列表-查看详情", tags = {"联系客服"}) |
| | |
| | | @ApiImplicitParam(value = "id", name = "id", required = true, dataType = "Integer"), |
| | | }) |
| | | public R<CommonQuestion> myInviteRankList(Long id) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | CommonQuestion byId = commonQuestionService.getById(id); |
| | | return R.ok(byId); |
| | | } |
| | | @PostMapping("/getCommissionRule") |
| | | @ApiOperation(value = "推广活动页",tags = "推广活动页") |
| | | public R<CommissionRule> getCommissionRule() throws Exception { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | |
| | | CommissionRule one = commissionRuleService.lambdaQuery().one(); |
| | | HashMap<String, String> blueCode = new HashMap<>(); |
| | | blueCode.put("user_id", userId + ""); |
| | | String blueS = "{\"user_id\": " + userId + "}"; |
| | | String blueS = "http://113.45.158.158/share/#/pages/register/register?userId="+userId; |
| | | |
| | | MyQrCodeUtil.createCodeToFile(blueS); |
| | | BufferedImage blueImage = QRCodeUtil.createImage(blueS); |
| | | MultipartFile blueFile = convert(blueImage, new Date().getTime() + UUIDUtil.getRandomCode(3) + ".PNG"); |
| | | String s = ObsUploadUtil.obsUpload(blueFile); |
| | | one.setQrCode(s); |
| | | return R.ok(one); |
| | | } |
| | | @PostMapping("/getCommissionRuleShare") |
| | | @ApiOperation(value = "推广活动页",tags = "H5分享") |
| | | public R<CommissionRule> getCommissionRuleShare(String userId) throws Exception { |
| | | CommissionRule one = commissionRuleService.lambdaQuery().one(); |
| | | HashMap<String, String> blueCode = new HashMap<>(); |
| | | blueCode.put("user_id", userId + ""); |
| | | String blueS = "http://113.45.158.158/share/#/pages/register/register?userId="+userId; |
| | | MyQrCodeUtil.createCodeToFile(blueS); |
| | | BufferedImage blueImage = QRCodeUtil.createImage(blueS); |
| | | MultipartFile blueFile = convert(blueImage, new Date().getTime() + UUIDUtil.getRandomCode(3) + ".PNG"); |
| | |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.system.domain.ContentSetting; |
| | | import com.xinquan.system.domain.VipSetting; |
| | | import com.xinquan.system.domain.dto.AggrementOtherDto; |
| | | import com.xinquan.system.service.ContentSettingService; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | |
| | | } |
| | | @PostMapping("/saveOrupdateContent") |
| | | @ApiOperation(value = "保存修改富文本内容",tags = "管理后台-富文本规则说明") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "内容类型 1=用户协议 2=隐私协议 3=关于心泉 4= 新手冥想指南 5=课程/冥想音频购买协议 6=能量规则说明 7等级经验值规则说明", name = "type", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "富文本内容", name = "content", required = true, dataType = "String"), |
| | | }) |
| | | public R saveOrupdateContent(Integer type,String content) { |
| | | ContentSetting one = contentSettingService.lambdaQuery().eq(ContentSetting::getContentType, type).one(); |
| | | |
| | | public R saveOrupdateContent(@RequestBody AggrementOtherDto dto) { |
| | | ContentSetting one = contentSettingService.lambdaQuery().eq(ContentSetting::getContentType, dto.getType()).one(); |
| | | if (dto.getType() == 7){ |
| | | dto.setContent("<img src="+"\""+dto.getContent()+"\">"+"</img>"); |
| | | } |
| | | if (one!=null){ |
| | | one.setContent(content); |
| | | one.setContent(dto.getContent()); |
| | | contentSettingService.updateById(one); |
| | | }else{ |
| | | ContentSetting contentSetting = new ContentSetting(); |
| | | contentSetting.setContentType(type); |
| | | contentSetting.setContent(content); |
| | | contentSetting.setContentType(dto.getType()); |
| | | contentSetting.setContent(dto.getContent()); |
| | | contentSetting.setCreateTime(LocalDateTime.now()); |
| | | contentSettingService.save(contentSetting); |
| | | } |
New file |
| | |
| | | package com.xinquan.system.controller; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.WebUtils; |
| | | import com.xinquan.common.core.utils.page.BeanUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.course.api.domain.CourseCategory; |
| | | import com.xinquan.course.api.domain.CourseDTO; |
| | | import com.xinquan.course.api.feign.RemoteCourseService; |
| | | import com.xinquan.meditation.api.feign.RemoteMeditationService; |
| | | import com.xinquan.order.api.domain.Order; |
| | | import com.xinquan.order.api.domain.vo.HomeDto; |
| | | import com.xinquan.order.api.feign.RemoteOrderService; |
| | | import com.xinquan.system.api.domain.vo.HomeVO; |
| | | import com.xinquan.system.domain.Banner; |
| | | import com.xinquan.system.domain.export.HomeExport; |
| | | import com.xinquan.system.service.BannerService; |
| | | import com.xinquan.user.api.feign.RemoteAppUserService; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | | * 用户信息表 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author mitao |
| | | * @since 2024-08-21 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/system/home") |
| | | public class HomeController { |
| | | |
| | | @Resource |
| | | private BannerService bannerService; |
| | | @Resource |
| | | private RemoteCourseService remoteCourseService; |
| | | @Resource |
| | | private RemoteAppUserService remoteAppUserService; |
| | | @Resource |
| | | private RemoteMeditationService remoteMeditationService; |
| | | @Resource |
| | | private RemoteOrderService remoteOrderService; |
| | | @PostMapping("/homeStatistics") |
| | | @ApiOperation(value = "首页统计",tags = "管理后台-首页统计") |
| | | public R<HomeVO> bannerList(@RequestBody HomeDto homeDto) { |
| | | HomeVO homeVO = new HomeVO(); |
| | | // homeVO.setOrderMoney(); |
| | | // homeVO.setOrderCount(); |
| | | // homeVO.setOrderList(); |
| | | // homeVO.setOrderTimeList(); |
| | | // 查询用户总数、非会员数、月卡会员数、季卡会员数、年卡会员数 |
| | | String data = remoteAppUserService.getUserCount().getData(); |
| | | if (data!=null){ |
| | | String[] split = data.split(","); |
| | | homeVO.setUserCount(split[0]); |
| | | homeVO.setNoVip(split[1]); |
| | | homeVO.setVipMonth(split[2]); |
| | | homeVO.setVipQuarter(split[3]); |
| | | homeVO.setVipYear(split[4]); |
| | | } |
| | | // 查询课程总数 免费、会员免费、单独收费、线下课程数 |
| | | String data1 = remoteCourseService.getCourseCount().getData(); |
| | | if (data1!=null){ |
| | | String[] split = data1.split(","); |
| | | homeVO.setCourseCount(split[0]); |
| | | homeVO.setCourseFree(split[1]); |
| | | homeVO.setCourseVip(split[2]); |
| | | homeVO.setCoursePay(split[3]); |
| | | homeVO.setCourseOffOnline(split[4]); |
| | | } |
| | | // 查询疗愈总数 免费、会员免费、单独收费 |
| | | String data2 = remoteMeditationService.getMeditationCount().getData(); |
| | | if (data2!=null){ |
| | | String[] split = data2.split(","); |
| | | homeVO.setMeditationCount(split[0]); |
| | | homeVO.setMeditationFree(split[1]); |
| | | homeVO.setMeditationVip(split[2]); |
| | | homeVO.setMeditationPay(split[3]); |
| | | } |
| | | String data3 = remoteMeditationService.getQuestionCount().getData(); |
| | | if (data3!=null){ |
| | | homeVO.setQuestionRecord(data3); |
| | | } |
| | | String data4 = remoteAppUserService.getPrizeRecordCount().getData(); |
| | | if (data4!=null){ |
| | | homeVO.setPrizeRecord(data4); |
| | | } |
| | | // 查询用户总数列表变化趋势 |
| | | Map<String, Object> data5 = remoteAppUserService.getUserListCount().getData(); |
| | | homeVO.setUserList(data5); |
| | | // 查询时间范围内的订单列表 课程 疗愈 会员 |
| | | if (!StringUtils.hasLength(homeDto.getTime())){ |
| | | homeDto.setTime("1"); |
| | | } |
| | | if(homeDto.getTimeType() == null){ |
| | | homeDto.setTimeType(1); |
| | | } |
| | | List<Order> data6 = remoteOrderService.getOrderList(homeDto.getStatus(), homeDto.getTimeType(), homeDto.getTime()).getData(); |
| | | homeVO.setOrderCount(data6.size()+""); |
| | | BigDecimal bigDecimal = new BigDecimal("0"); |
| | | for (Order order : data6) { |
| | | if (order.getRealPayAmount()!=null){ |
| | | bigDecimal= bigDecimal.add(order.getRealPayAmount()); |
| | | } |
| | | } |
| | | homeVO.setOrderMoney(bigDecimal+""); |
| | | Map<String, Object> x = new HashMap<>(); |
| | | Map<String, Object> x1 = new HashMap<>(); |
| | | Map<String, Object> x2 = new HashMap<>(); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd"); |
| | | SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | switch (homeDto.getTimeType()){ |
| | | case 1: |
| | | // 年 |
| | | x.put("1",0); |
| | | x.put("2",0); |
| | | x.put("3",0); |
| | | x.put("4",0); |
| | | x.put("5",0); |
| | | x.put("6",0); |
| | | x.put("7",0); |
| | | x.put("8",0); |
| | | x.put("9",0); |
| | | x.put("10",0); |
| | | x.put("11",0); |
| | | x.put("12",0); |
| | | |
| | | x1.put("1",0); |
| | | x1.put("2",0); |
| | | x1.put("3",0); |
| | | x1.put("4",0); |
| | | x1.put("5",0); |
| | | x1.put("6",0); |
| | | x1.put("7",0); |
| | | x1.put("8",0); |
| | | x1.put("9",0); |
| | | x1.put("10",0); |
| | | x1.put("11",0); |
| | | x1.put("12",0); |
| | | |
| | | x2.put("1",0); |
| | | x2.put("2",0); |
| | | x2.put("3",0); |
| | | x2.put("4",0); |
| | | x2.put("5",0); |
| | | x2.put("6",0); |
| | | x2.put("7",0); |
| | | x2.put("8",0); |
| | | x2.put("9",0); |
| | | x2.put("10",0); |
| | | x2.put("11",0); |
| | | x2.put("12",0); |
| | | break; |
| | | case 2: |
| | | // 获取当前日期格式为 yyyy-MM-dd |
| | | Date date = new Date(); |
| | | String format = simpleDateFormat.format(date); |
| | | x.put(format,0); |
| | | x1.put(format,0); |
| | | x2.put(format,0); |
| | | break; |
| | | case 3: |
| | | // 周 |
| | | // 获取本周7天 格式为dd |
| | | |
| | | calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); |
| | | for (int i = 1; i <= 7; i++) { |
| | | Date time = calendar.getTime(); |
| | | String format1 = simpleDateFormat.format(time); |
| | | x.put(format1,0); |
| | | x1.put(format1,0); |
| | | x2.put(format1,0); |
| | | calendar.add(Calendar.DAY_OF_MONTH, 1); |
| | | } |
| | | break; |
| | | case 4: |
| | | // 月 |
| | | // 获取本月31天 格式为dd |
| | | calendar.set(Calendar.DAY_OF_MONTH, 1); |
| | | for (int i = 1; i <= 31; i++) { |
| | | Date time = calendar.getTime(); |
| | | String format1 = simpleDateFormat.format(time); |
| | | x.put(format1,0); |
| | | x1.put(format1,0); |
| | | x2.put(format1,0); |
| | | calendar.add(Calendar.DAY_OF_MONTH, 1); |
| | | } |
| | | break; |
| | | } |
| | | |
| | | for (Order order : data6) { |
| | | int value = order.getCreateTime().getMonth().getValue(); |
| | | int value1 = order.getCreateTime().getDayOfMonth(); |
| | | switch (order.getOrderFrom()){ |
| | | case 1: |
| | | switch (homeDto.getTimeType()){ |
| | | case 1: |
| | | // 获取订单月份 |
| | | x.put(value+"",(int)x.get(value+"")+1); |
| | | break; |
| | | case 2: |
| | | Date date = new Date(); |
| | | String format = simpleDateFormat.format(date); |
| | | x.put(format,(int)x.get(format)+1); |
| | | break; |
| | | case 3: |
| | | x.put(value1+"",(int)x.get(value1+"")+1); |
| | | break; |
| | | case 4: |
| | | x.put(value1+"",(int)x.get(value1+"")+1); |
| | | break; |
| | | } |
| | | break; |
| | | case 2: |
| | | switch (homeDto.getTimeType()){ |
| | | case 1: |
| | | // 获取订单月份 |
| | | x1.put(value+"",(int)x1.get(value+"")+1); |
| | | break; |
| | | case 2: |
| | | Date date = new Date(); |
| | | String format = simpleDateFormat.format(date); |
| | | x1.put(format,(int)x1.get(format)+1); |
| | | break; |
| | | case 3: |
| | | x1.put(value1+"",(int)x1.get(value1+"")+1); |
| | | break; |
| | | case 4: |
| | | x1.put(value1+"",(int)x1.get(value1+"")+1); |
| | | break; |
| | | } |
| | | break; |
| | | case 3: |
| | | switch (homeDto.getTimeType()){ |
| | | case 1: |
| | | // 获取订单月份 |
| | | x2.put(value+"",(int)x2.get(value+"")+1); |
| | | break; |
| | | case 2: |
| | | Date date = new Date(); |
| | | String format = simpleDateFormat.format(date); |
| | | x2.put(format,(int)x2.get(format)+1); |
| | | break; |
| | | case 3: |
| | | x2.put(value1+"",(int)x2.get(value1+"")+1); |
| | | break; |
| | | case 4: |
| | | x2.put(value1+"",(int)x2.get(value1+"")+1); |
| | | break; |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | switch (homeDto.getTimeType()){ |
| | | case 1: |
| | | break; |
| | | case 2: |
| | | break; |
| | | case 3: |
| | | break; |
| | | case 4: |
| | | break; |
| | | } |
| | | // 对x的key值进行从小到大排序 |
| | | Map<String, Object> sortedMap = new TreeMap<>(Comparator.reverseOrder()); |
| | | sortedMap.putAll(x); |
| | | Map<String, Object> sortedMap1 = new TreeMap<>(Comparator.reverseOrder()); |
| | | sortedMap1.putAll(x1); |
| | | Map<String, Object> sortedMap2 = new TreeMap<>(Comparator.reverseOrder()); |
| | | sortedMap2.putAll(x2); |
| | | homeVO.setOrderMeditationList(sortedMap); |
| | | homeVO.setOrderCourseList(sortedMap1); |
| | | homeVO.setOrderVipList(sortedMap2); |
| | | return R.ok(homeVO); |
| | | } |
| | | @PutMapping("/homeStatisticsExport") |
| | | @ApiOperation(value = "首页统计-导出",tags = "管理后台-首页统计") |
| | | public void homeStatisticsExport() { |
| | | HomeVO homeVO = new HomeVO(); |
| | | // homeVO.setOrderMoney(); |
| | | // homeVO.setOrderCount(); |
| | | // homeVO.setOrderList(); |
| | | // homeVO.setOrderTimeList(); |
| | | // 查询用户总数、非会员数、月卡会员数、季卡会员数、年卡会员数 |
| | | String data = remoteAppUserService.getUserCount().getData(); |
| | | if (data!=null){ |
| | | String[] split = data.split(","); |
| | | homeVO.setUserCount(split[0]); |
| | | homeVO.setNoVip(split[1]); |
| | | homeVO.setVipMonth(split[2]); |
| | | homeVO.setVipQuarter(split[3]); |
| | | homeVO.setVipYear(split[4]); |
| | | } |
| | | // 查询课程总数 免费、会员免费、单独收费、线下课程数 |
| | | String data1 = remoteCourseService.getCourseCount().getData(); |
| | | if (data1!=null){ |
| | | String[] split = data1.split(","); |
| | | homeVO.setCourseCount(split[0]); |
| | | homeVO.setCourseFree(split[1]); |
| | | homeVO.setCourseVip(split[2]); |
| | | homeVO.setCoursePay(split[3]); |
| | | homeVO.setCourseOffOnline(split[4]); |
| | | } |
| | | // 查询疗愈总数 免费、会员免费、单独收费 |
| | | String data2 = remoteMeditationService.getMeditationCount().getData(); |
| | | if (data2!=null){ |
| | | String[] split = data2.split(","); |
| | | homeVO.setMeditationCount(split[0]); |
| | | homeVO.setMeditationFree(split[1]); |
| | | homeVO.setMeditationVip(split[2]); |
| | | homeVO.setMeditationPay(split[3]); |
| | | } |
| | | String data3 = remoteMeditationService.getQuestionCount().getData(); |
| | | if (data3!=null){ |
| | | homeVO.setQuestionRecord(data3); |
| | | } |
| | | String data4 = remoteAppUserService.getPrizeRecordCount().getData(); |
| | | if (data4!=null){ |
| | | homeVO.setPrizeRecord(data4); |
| | | } |
| | | |
| | | |
| | | HomeExport homeExport = new HomeExport(); |
| | | BeanUtils.copyProperties(homeVO, homeExport); |
| | | List<HomeExport> homeExports = new ArrayList<>(); |
| | | homeExports.add(homeExport); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), HomeExport.class, homeExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("首页统计导出.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | @PostMapping("/cateList") |
| | | @ApiOperation(value = "课程分类下拉选择列表-不分页",tags = "管理后台banner") |
| | | |
| | | public R<List<CourseCategory>> cateList() { |
| | | List<CourseCategory> data = remoteCourseService.cateList().getData(); |
| | | return R.ok(data); |
| | | } |
| | | @GetMapping("/courseList") |
| | | @ApiOperation(value = "选择课程-分页",tags = "管理后台banner") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "分页参数,当前页码", name = "pageCurr", required = false, dataType = "Integer"), |
| | | @ApiImplicitParam(value = "分页参数,每页数量", name = "pageSize", required = false, dataType = "Integer"), |
| | | @ApiImplicitParam(value = "课程类型1线上2线下", name = "courseType", required = false, dataType = "Integer"), |
| | | @ApiImplicitParam(value = "课程分类id", name = "cateId", required = false, dataType = "Long"), |
| | | @ApiImplicitParam(value = "课程标题", name = "courseTitle", required = false, dataType = "String"), |
| | | @ApiImplicitParam(value = "导师名称", name = "tutor", required = false, dataType = "String"), |
| | | }) |
| | | public R<PageDTO<Course>> courseList( |
| | | Integer pageCurr, |
| | | Integer pageSize, |
| | | Integer courseType, |
| | | Long cateId, |
| | | String courseTitle, |
| | | |
| | | String tutor |
| | | ) { |
| | | CourseDTO courseDTO = new CourseDTO(); |
| | | courseDTO.setPageCurr(pageCurr); |
| | | courseDTO.setPageSize(pageSize); |
| | | courseDTO.setCourseType(courseType); |
| | | courseDTO.setCateId(cateId); |
| | | courseDTO.setCourseTitle(courseTitle); |
| | | courseDTO.setTutor(tutor); |
| | | PageDTO<Course> data = remoteCourseService.courseList(courseDTO).getData(); |
| | | return R.ok(data); |
| | | } |
| | | @PostMapping("/deleteBatch") |
| | | @ApiOperation(value = "批量删除banner",tags = "管理后台banner") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "ids", name = "ids", required = true, dataType = "String"), |
| | | }) |
| | | public R deleteBatch( |
| | | @RequestParam(value = "ids") String ids) |
| | | { |
| | | List<Long> list = Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList()); |
| | | bannerService.removeBatchByIds(list); |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/addBanner") |
| | | @ApiOperation(value = "添加banner",tags = "管理后台banner") |
| | | |
| | | public R addBanner(@RequestBody Banner banner) |
| | | { |
| | | bannerService.save(banner); |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/updateBanner") |
| | | @ApiOperation(value = "修改banner",tags = "管理后台banner") |
| | | |
| | | public R updateBanner(@RequestBody Banner banner) |
| | | { |
| | | bannerService.updateById(banner); |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/bannerDetail") |
| | | @ApiOperation(value = "查看详情",tags = "管理后台banner") |
| | | |
| | | public R<Banner> bannerDetail(String uid) |
| | | { |
| | | Banner byId = bannerService.getById(uid); |
| | | if (byId.getCourseId()!=null){ |
| | | Course data = remoteCourseService.getCourseById(byId.getCourseId()).getData(); |
| | | if (data!=null){ |
| | | byId.setCourseTitle(data.getCourseTitle()); |
| | | byId.setCoverUrl(data.getCoverUrl()); |
| | | byId.setTutor(data.getTutor()); |
| | | byId.setPrice(data.getGeneralPrice()); |
| | | if (data.getCateId()!=null){ |
| | | CourseCategory data1 = remoteCourseService.getCategoryById(data.getCateId().toString()).getData(); |
| | | byId.setCate(data1.getName()); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(byId); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.system.domain.CommonQuestion; |
| | | import com.xinquan.system.domain.HotWords; |
| | | import com.xinquan.system.service.HotWordsService; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | public class HotWordsController { |
| | | @Resource |
| | | private HotWordsService hotWordsService; |
| | | @PostMapping("/list") |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @GetMapping("/list") |
| | | @ApiOperation(value = "热词管理-列表查询", tags = {"运营中心"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "分页参数,当前页码", name = "pageCurr", required = true, dataType = "Integer"), |
| | | @ApiImplicitParam(value = "分页参数,每页数量", name = "pageSize", required = true, dataType = "Integer") |
| | | }) |
| | | public R<PageDTO<HotWords>> list( |
| | | @RequestParam(value = "pageCurr", defaultValue = "1") Integer pageCurr, |
| | | @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | Integer pageCurr, |
| | | Integer pageSize) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Page<HotWords> page1 = new Page<>(pageCurr, pageSize); |
| | | Page<HotWords> page = hotWordsService.lambdaQuery() |
| | | .orderByDesc(HotWords::getSortNum) |
| | | .page(new Page<>(pageCurr, pageSize)); |
| | | .page(page1); |
| | | if (page.getRecords().isEmpty()){ |
| | | return R.ok(PageDTO.empty(page)); |
| | | } |
| | |
| | | hotWordsService.update(hotWordsLambdaUpdateWrapper); |
| | | return R.ok(); |
| | | } |
| | | @DeleteMapping("/add") |
| | | @PostMapping("/delete") |
| | | @ApiOperation(value = "热词管理-删除热词", tags = {"管理后台-运营中心"}) |
| | | public R add(String id) { |
| | | hotWordsService.removeById(id); |
| | | hotWordsService.removeById(Long.valueOf(id)); |
| | | return R.ok(); |
| | | } |
| | | @DeleteMapping("/queryAddCount") |
| | | @GetMapping("/queryAddCount") |
| | | @ApiOperation(value = "热词管理-查询还可以上传多少个热词", tags = {"管理后台-运营中心"}) |
| | | public R queryAddCount() { |
| | | int i = 20 - hotWordsService.lambdaQuery().list().size(); |
| | |
| | | |
| | | |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.system.domain.CommissionRule; |
| | | import com.xinquan.system.domain.Page; |
| | | import com.xinquan.system.service.CommissionRuleService; |
| | | import com.xinquan.system.service.PageService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/saveOrUpdatePlan") |
| | | @PostMapping("/getPlan") |
| | | @ApiOperation(value = "获取计划引导设置",tags = "计划引导设置") |
| | | public R<String> saveOrUpdatePlan() { |
| | | public R<String> getPlan() { |
| | | Page one = pageService.lambdaQuery().eq(Page::getType,2).one(); |
| | | if (one!=null){ |
| | | return R.ok(one.getImg()); |
| | |
| | | if(one == null){ |
| | | Page page = new Page(); |
| | | page.setImg(img); |
| | | page.setType(2); |
| | | pageService.save(page); |
| | | }else{ |
| | | one.setImg(img); |
| | | one.setType(2); |
| | | pageService.updateById(one); |
| | | } |
| | | return R.ok(); |
| | |
| | | package com.xinquan.system.controller; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.xinquan.system.service.ISysDeptService; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.xinquan.common.core.constant.UserConstants; |
| | | import com.xinquan.common.core.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.core.web.controller.BaseController; |
| | | import com.xinquan.common.core.web.domain.AjaxResult; |
| | | import com.xinquan.common.core.web.page.PageInfo; |
| | | import com.xinquan.common.log.annotation.Log; |
| | | import com.xinquan.common.log.enums.BusinessType; |
| | | import com.xinquan.common.security.annotation.RequiresPermissions; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.system.api.domain.SysDept; |
| | | import com.xinquan.system.api.domain.SysRole; |
| | | import com.xinquan.system.api.domain.SysUser; |
| | | import com.xinquan.system.domain.SysUserDept; |
| | | import com.xinquan.system.domain.dto.SysDeptUpdateStatusDTO; |
| | | import com.xinquan.system.domain.dto.SysUserUpdateStatusDTO; |
| | | import com.xinquan.system.domain.dto.UnfreeDto; |
| | | import com.xinquan.system.service.ISysDeptService; |
| | | import com.xinquan.system.service.ISysUserDeptService; |
| | | import com.xinquan.system.service.ISysUserService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 部门信息 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/dept") |
| | | @Api(tags = "部门管理") |
| | | public class SysDeptController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysDeptService deptService; |
| | | @Autowired |
| | | private ISysUserDeptService userDeptService; |
| | | |
| | | /** |
| | | * 获取部门列表 |
| | | */ |
| | | @RequiresPermissions("system:dept:list") |
| | | @GetMapping("/list") |
| | | public AjaxResult list(SysDept dept) |
| | | { |
| | | List<SysDept> depts = deptService.selectDeptList(dept); |
| | | return success(depts); |
| | | } |
| | | |
| | | /** |
| | | * 查询部门列表(排除节点) |
| | | */ |
| | | @RequiresPermissions("system:dept:list") |
| | | @GetMapping("/list/exclude/{deptId}") |
| | | public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) |
| | | { |
| | | List<SysDept> depts = deptService.selectDeptList(new SysDept()); |
| | | depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); |
| | | return success(depts); |
| | | } |
| | | |
| | | /** |
| | | * 根据部门编号获取详细信息 |
| | | */ |
| | | @RequiresPermissions("system:dept:query") |
| | | @GetMapping(value = "/{deptId}") |
| | | public AjaxResult getInfo(@PathVariable Long deptId) |
| | | { |
| | | deptService.checkDeptDataScope(deptId); |
| | | return success(deptService.selectDeptById(deptId)); |
| | | @ApiOperation("部门列表") |
| | | public R<PageDTO<SysDept>> list(String deptName, int pageCurr, int pageSize) { |
| | | Page<SysDept> res = new Page<>(pageCurr, pageSize); |
| | | PageInfo<SysDept> pageInfo = new PageInfo<>(pageCurr, pageSize); |
| | | List<SysDept> page = deptService.getList(pageInfo, deptName); |
| | | for (SysDept sysDept : page) { |
| | | int size = userDeptService.lambdaQuery().eq(SysUserDept::getDeptId, sysDept.getDeptId()).list().size(); |
| | | sysDept.setUserCount(size); |
| | | } |
| | | pageInfo.setRecords(page); |
| | | res.setRecords(page); |
| | | PageDTO<SysDept> sysUserVOPageDTO = PageDTO.of(res, SysDept.class); |
| | | return R.ok(sysUserVOPageDTO); |
| | | } |
| | | |
| | | /** |
| | | * 新增部门 |
| | | */ |
| | | @RequiresPermissions("system:dept:add") |
| | | @Log(title = "部门管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysDept dept) |
| | | @PostMapping("/add") |
| | | @ApiOperation("部门添加") |
| | | public AjaxResult add(@Validated @RequestBody SysDept dto) |
| | | { |
| | | if (!deptService.checkDeptNameUnique(dept)) |
| | | { |
| | | return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); |
| | | dto.setCreateTime(LocalDateTime.now()); |
| | | if (!deptService.checkDeptNameUnique(dto)){ |
| | | return error("新增部门失败,部门ID已存在"); |
| | | } |
| | | dept.setCreateBy(SecurityUtils.getUsername()); |
| | | return toAjax(deptService.insertDept(dept)); |
| | | dto.setCreateBy(SecurityUtils.getUsername()); |
| | | return toAjax(deptService.insertDept(dto)); |
| | | } |
| | | |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private ISysUserService service; |
| | | /** |
| | | * 修改部门 |
| | | */ |
| | | @RequiresPermissions("system:dept:edit") |
| | | @Log(title = "部门管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysDept dept) |
| | | @PostMapping("/edit") |
| | | @ApiOperation("部门修改") |
| | | public R edit(@Validated @RequestBody SysDept dept) |
| | | { |
| | | Long deptId = dept.getDeptId(); |
| | | deptService.checkDeptDataScope(deptId); |
| | | if (!deptService.checkDeptNameUnique(dept)) |
| | | { |
| | | return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); |
| | | if (!deptService.checkDeptNameUnique1(dept)){ |
| | | return R.fail("修改部门失败,部门ID已存在"); |
| | | } |
| | | else if (dept.getParentId().equals(deptId)) |
| | | { |
| | | return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); |
| | | } |
| | | else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) |
| | | { |
| | | return error("该部门包含未停用的子部门!"); |
| | | } |
| | | dept.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(deptService.updateDept(dept)); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser byId = service.getById(userid); |
| | | dept.setUpdateBy(byId.getNickName()+"("+byId.getUserName()+")"); |
| | | dept.setHandleName(byId.getNickName()+"("+byId.getUserName()+")"); |
| | | return R.ok(deptService.updateDept(dept)); |
| | | } |
| | | |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | @ApiOperation(value = "禁用启用") |
| | | @PutMapping("/changeStatus") |
| | | public AjaxResult changeStatus(@RequestBody SysDeptUpdateStatusDTO dto) |
| | | { |
| | | SysDept user = new SysDept(); |
| | | user.setDeptId(dto.getDeptId()); |
| | | user.setStatus(String.valueOf(dto.getStatus())); |
| | | user.setReason(dto.getReason()); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = userService.selectUserById(userid); |
| | | user.setUpdateBy(sysUser.getNickName()+"("+sysUser.getUserName()+")"); |
| | | user.setHandleName(sysUser.getNickName()+"("+sysUser.getUserName()+")"); |
| | | return AjaxResult.success(userService.updateDeptStatus(user)); |
| | | } |
| | | /** |
| | | * 删除部门 |
| | | */ |
| | | @RequiresPermissions("system:dept:remove") |
| | | @Log(title = "部门管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{deptId}") |
| | | @ApiOperation("删除部门") |
| | | public AjaxResult remove(@PathVariable Long deptId) |
| | | { |
| | | if (deptService.hasChildByDeptId(deptId)) |
| | | { |
| | | return warn("存在下级部门,不允许删除"); |
| | | } |
| | | if (deptService.checkDeptExistUser(deptId)) |
| | | { |
| | | return warn("部门存在用户,不允许删除"); |
| | | } |
| | | deptService.checkDeptDataScope(deptId); |
| | | return toAjax(deptService.deleteDeptById(deptId)); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.xinquan.system.domain.SysMenu; |
| | | import com.xinquan.system.api.domain.SysMenu; |
| | | import com.xinquan.system.domain.SysMenus; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | /** |
| | | * 获取菜单列表 |
| | | */ |
| | | @GetMapping("/list") |
| | | @ApiOperation("所有菜单列表") |
| | | public AjaxResult list() |
| | | @ApiOperation("菜单权限(有层级)") |
| | | @GetMapping("/levelList") |
| | | public AjaxResult levelList() |
| | | { |
| | | List<SysMenus> list= menuService.getAllMenu(); |
| | | return success(list); |
| | | // 获取当前角色的菜单列表 |
| | | List<SysMenu> menus = menuService.selectList(); |
| | | if(menus.size()==0){ |
| | | return AjaxResult.success(new ArrayList<>()); |
| | | } |
| | | // 第三级 |
| | | List<SysMenu> s3 = menus.stream().filter(e -> e.getMenuType().equals("F")).collect(Collectors.toList()); |
| | | // 第二级 |
| | | List<SysMenu> s2 = menus.stream().filter(e -> e.getMenuType().equals("C")).collect(Collectors.toList()); |
| | | // 第一级 |
| | | List<SysMenu> s1 = menus.stream().filter(e -> e.getMenuType().equals("M")).collect(Collectors.toList()); |
| | | |
| | | for (SysMenu menu : s2) { |
| | | List<SysMenu> collect = s3.stream().filter(e -> e.getParentId().equals(menu.getMenuId())).collect(Collectors.toList()); |
| | | menu.setChildren(collect); |
| | | } |
| | | for (SysMenu menu : s1) { |
| | | List<SysMenu> collect = s2.stream().filter(e -> e.getParentId().equals(menu.getMenuId())).collect(Collectors.toList()); |
| | | menu.setChildren(collect); |
| | | } |
| | | |
| | | return AjaxResult.success(s1); |
| | | } |
| | | |
| | | /** |
| | |
| | | package com.xinquan.system.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.xinquan.common.core.utils.poi.ExcelUtil; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.StringUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.core.web.controller.BaseController; |
| | | import com.xinquan.common.core.web.domain.AjaxResult; |
| | | import com.xinquan.common.core.web.page.PageInfo; |
| | | import com.xinquan.common.core.web.page.TableDataInfo; |
| | | import com.xinquan.common.log.annotation.Log; |
| | | import com.xinquan.common.log.enums.BusinessType; |
| | | import com.xinquan.common.security.annotation.RequiresPermissions; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.system.api.domain.SysDept; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.system.api.domain.SysMenu; |
| | | import com.xinquan.system.api.domain.SysRole; |
| | | import com.xinquan.system.api.domain.SysUser; |
| | | import com.xinquan.system.domain.SysMenus; |
| | | import com.xinquan.system.domain.SysRoleMenu; |
| | | import com.xinquan.system.api.domain.vo.SysUserVO; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.system.domain.SysUserRole; |
| | | import com.xinquan.system.domain.dto.RoleAddDto; |
| | | import com.xinquan.system.domain.dto.RoleUpdateDto; |
| | | import com.xinquan.system.domain.dto.SysRoleDTO; |
| | | import com.xinquan.system.domain.dto.SysRoleQuery; |
| | | import com.xinquan.system.domain.vo.RoleInfoVo; |
| | | import com.xinquan.system.mapper.SysMenuMapper; |
| | | import com.xinquan.system.mapper.SysRoleMenuMapper; |
| | | import com.xinquan.system.service.ISysDeptService; |
| | | import com.xinquan.system.service.ISysRoleService; |
| | | import com.xinquan.system.service.ISysUserRoleService; |
| | | import com.xinquan.system.service.ISysUserService; |
| | | import com.xinquan.system.service.*; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | * 角色信息 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | /** |
| | | * 角色信息 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Api(tags = "角色信息") |
| | | @RestController |
| | | @RequestMapping("/role") |
| | | @Api(tags = "角色模块") |
| | | @RequestMapping("/system/role") |
| | | public class SysRoleController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysRoleService roleService; |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | @Autowired |
| | | private ISysPermissionService permissionService; |
| | | |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | | @Autowired |
| | | private ISysDeptService deptService; |
| | | |
| | | @Resource |
| | | private SysRoleMenuMapper sysRoleMenuMapper; |
| | | |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | @Resource |
| | | private ISysUserRoleService sysUserRoleService; |
| | | |
| | | // @PreAuthorize("@ss.hasPermi('system:role:list')") |
| | | @ApiOperation(value = "角色列表") |
| | | @PostMapping("/list") |
| | | public AjaxResult<PageDTO<SysRole>> list(@RequestBody SysRoleQuery query) |
| | | { |
| | | Page<SysRole> res = new Page<>(query.getPageCurr(), query.getPageSize()); |
| | | |
| | | @Resource |
| | | private SysMenuMapper menuMapper; |
| | | PageInfo<SysRole> list = roleService.selectList(query); |
| | | for (SysRole record : list.getRecords()) { |
| | | int size = sysUserRoleService.lambdaQuery().eq(SysUserRole::getRoleId, record.getRoleId()) |
| | | .list().size(); |
| | | record.setRoleCount(size); |
| | | } |
| | | res.setRecords(list.getRecords()); |
| | | PageDTO<SysRole> sysUserVOPageDTO = PageDTO.of(res, SysRole.class); |
| | | return AjaxResult.success(sysUserVOPageDTO); |
| | | } |
| | | @ApiOperation(value = "批量删除角色") |
| | | @Log(title = "角色信息-角色删除角色", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/deleteById/{ids}") |
| | | public AjaxResult remove(@PathVariable String ids) |
| | | { |
| | | String[] split = ids.split(","); |
| | | List<Long> id = new ArrayList<>(); |
| | | for (String s : split) { |
| | | id.add(Long.valueOf(s)); |
| | | } |
| | | return AjaxResult.success(roleService.deleteRoleByIds(id)); |
| | | } |
| | | |
| | | @ApiOperation("获取所有角色信息") |
| | | @GetMapping("/list") |
| | | @ApiOperation(value = "角色列表不分页") |
| | | @PostMapping("/listNotPage") |
| | | public AjaxResult list() |
| | | { |
| | | SysRole role = new SysRole(); |
| | | List<SysRole> list = roleService.selectRoleList(role); |
| | | List<SysRole> list = roleService.selectRoleList(new SysRole()); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation("获取所有角色信息--分页") |
| | | @GetMapping("/listPage") |
| | | public AjaxResult listPage(int pageNumber,int pageSize) |
| | | { |
| | | PageInfo<SysRole> pageInfo = new PageInfo<>(pageNumber, pageSize); |
| | | |
| | | PageInfo<SysRole> page = roleService.page(pageInfo, new LambdaQueryWrapper<SysRole>().ne(SysRole::getRoleId,20)); |
| | | return AjaxResult.success(page); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("角色启用停用") |
| | | @GetMapping("/roleStart") |
| | | public AjaxResult roleStart(Long roleId) |
| | | { |
| | | SysRole role = roleService.selectRoleById(roleId); |
| | | if(role.getStatus().equals("1")){ |
| | | role.setStatus("0"); |
| | | }else { |
| | | role.setStatus("1"); |
| | | } |
| | | return AjaxResult.success(roleService.updateRole(role)); |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation("添加角色") |
| | | @PostMapping("/roleAdd") |
| | | public AjaxResult roleAdd(@Validated @RequestBody RoleAddDto dto) |
| | | { |
| | | SysRole role = new SysRole(); |
| | | role.setRoleName(dto.getRoleName()); |
| | | long count = roleService.count(Wrappers.lambdaQuery(SysRole.class) |
| | | .eq(SysRole::getRoleName,dto.getRoleName())); |
| | | if(count>0){ |
| | | return AjaxResult.error("角色已存在,请重新输入"); |
| | | } |
| | | List<Long> menuIds1 = dto.getMenuIds(); |
| | | if(CollectionUtils.isEmpty(menuIds1)){ |
| | | return AjaxResult.error("菜单id不能为空"); |
| | | } |
| | | role.setMenuIds(dto.getMenuIds().toArray((new Long[dto.getMenuIds().size()]))); |
| | | // 添加角色 |
| | | role.setCreateBy(SecurityUtils.getUsername()); |
| | | // role.setCreateTime(new Date()); |
| | | roleService.insertRole(role); |
| | | // ArrayList<SysRoleMenu> sysRoleMenus = new ArrayList<>(); |
| | | // List<Long> menuIds = dto.getMenuIds(); |
| | | // for (Long menuId : menuIds) { |
| | | // SysRoleMenu sysRoleMenu = new SysRoleMenu(); |
| | | // sysRoleMenu.setMenuId(menuId); |
| | | // sysRoleMenu.setRoleId(role.getRoleId()); |
| | | // sysRoleMenus.add(sysRoleMenu); |
| | | // @ApiOperation(value = "角色数量统计") |
| | | // @PostMapping("/roleCount") |
| | | // public AjaxResult roleCount() |
| | | // { |
| | | // int all = roleService.selectCount(null); |
| | | // int normal = roleService.selectCount(0); |
| | | // int stop = roleService.selectCount(1); |
| | | // |
| | | // Map<String,Integer> map = new HashMap<>(); |
| | | // map.put("all",all); |
| | | // map.put("normal",normal); |
| | | // map.put("stop",stop); |
| | | // return AjaxResult.success(map); |
| | | // } |
| | | // |
| | | //// @Log(title = "角色管理", businessType = BusinessType.EXPORT) |
| | | //// // @PreAuthorize("@ss.hasPermi('system:role:export')") |
| | | //// @PostMapping("/export") |
| | | //// public void export(HttpServletResponse response, SysRole role) |
| | | //// { |
| | | //// List<SysRole> list = roleService.selectRoleList(role); |
| | | //// ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class); |
| | | //// util.exportExcel(response, list, "角色数据"); |
| | | //// } |
| | | // |
| | | // /** |
| | | // * 根据角色编号获取详细信息 |
| | | // */ |
| | | // // @PreAuthorize("@ss.hasPermi('system:role:query')") |
| | | // @GetMapping(value = "/{roleId}") |
| | | // public AjaxResult getInfo(@PathVariable Long roleId) |
| | | // { |
| | | // roleService.checkRoleDataScope(roleId); |
| | | // return AjaxResult.success(roleService.selectRoleById(roleId)); |
| | | // } |
| | | // |
| | | // |
| | | // @ApiOperation("角色详情") |
| | | // @GetMapping("/roleInfo") |
| | | // public AjaxResult roleInfo(@RequestParam Long roleId) |
| | | // { |
| | | // SysRole role = roleService.selectRoleById(roleId); |
| | | // RoleInfoVO roleInfoVo = new RoleInfoVO(); |
| | | // roleInfoVo.setRoleId(role.getRoleId()); |
| | | // roleInfoVo.setRoleName(role.getRoleName()); |
| | | // roleInfoVo.setRemark(role.getRemark()); |
| | | // |
| | | // // 获取当前角色的菜单列表 |
| | | // List<SysMenu> menus = menuService.selectListByRoleId(roleId); |
| | | // if(menus.size()==0){ |
| | | // return AjaxResult.success(new ArrayList<>()); |
| | | // } |
| | | // sysRoleMenuMapper.batchRoleMenu(sysRoleMenus); |
| | | // List<Long> menusId = menus.stream().map(SysMenu::getMenuId).collect(Collectors.toList()); |
| | | // |
| | | // // 获取当前的权限菜单(有层级) |
| | | //// List<SysMenu> levelMenus = roleService.getMenuLevelList(menusId); |
| | | // |
| | | // roleInfoVo.setMenus(menusId); |
| | | // return AjaxResult.success(roleInfoVo); |
| | | // } |
| | | // |
| | | // |
| | | // @ApiOperation("用户获取权限菜单") |
| | | // @GetMapping("/roleInfoFromUserId") |
| | | // public AjaxResult roleInfoFromUserId(@RequestParam Long userId) |
| | | // { |
| | | // return AjaxResult.success(roleService.roleInfoFromUserId(userId)); |
| | | // } |
| | | // |
| | | // |
| | | /** |
| | | * 新增角色 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:role:add')") |
| | | @ApiOperation(value = "新增角色") |
| | | @Log(title = "角色信息-新增角色", businessType = BusinessType.INSERT) |
| | | @PostMapping("/add") |
| | | public AjaxResult add(@Validated @RequestBody SysRoleDTO dto) |
| | | { |
| | | Boolean flag= roleService.isExit(dto.getRoleId(),dto.getRoleName()); |
| | | if(flag){ |
| | | return error("新增角色'" + dto.getRoleName() + "'失败,角色名称已存在"); |
| | | } |
| | | roleService.saveRole(dto); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("角色详情") |
| | | @GetMapping("/roleInfo") |
| | | public AjaxResult roleInfo( @RequestParam Long id) |
| | | public AjaxResult<RoleInfoVo> roleInfo(@RequestParam Long roleId) |
| | | { |
| | | SysRole role = roleService.selectRoleById(id); |
| | | SysRole role = roleService.selectRoleById(roleId); |
| | | RoleInfoVo roleInfoVo = new RoleInfoVo(); |
| | | roleInfoVo.setRoleId(role.getRoleId()); |
| | | roleInfoVo.setRoleName(role.getRoleName()); |
| | | // 获取当前角色的菜单id |
| | | List<Long> menusId = sysRoleMenuMapper.selectList(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, id)).stream().map(SysRoleMenu::getMenuId).collect(Collectors.toList()); |
| | | if(menusId.size()==0){ |
| | | roleInfoVo.setRemark(role.getRemark()); |
| | | |
| | | // 获取当前角色的菜单列表 |
| | | List<SysMenu> menus = menuService.selectListByRoleId(roleId); |
| | | if(menus.size()==0){ |
| | | return AjaxResult.success(new ArrayList<>()); |
| | | } |
| | | //获取当前的权限菜单 |
| | | List<SysMenus> all = menuMapper.getAllInIds(menusId); |
| | | // 第三级 |
| | | List<SysMenus> s3 = all.stream().filter(e -> e.getMenuType().equals("F")).collect(Collectors.toList()); |
| | | // 第二级 |
| | | List<SysMenus> s2 = all.stream().filter(e -> e.getMenuType().equals("C")).collect(Collectors.toList()); |
| | | // 第一级 |
| | | List<SysMenus> s1 = all.stream().filter(e -> e.getMenuType().equals("M")).collect(Collectors.toList()); |
| | | List<Long> menusId = menus.stream().map(SysMenu::getMenuId).collect(Collectors.toList()); |
| | | |
| | | for (SysMenus menus : s2) { |
| | | List<SysMenus> collect = s3.stream().filter(e -> e.getParentId().equals(menus.getMenuId())).collect(Collectors.toList()); |
| | | menus.setChildren(collect); |
| | | } |
| | | |
| | | for (SysMenus menus : s1) { |
| | | List<SysMenus> collect = s2.stream().filter(e -> e.getParentId().equals(menus.getMenuId())).collect(Collectors.toList()); |
| | | menus.setChildren(collect); |
| | | } |
| | | // 获取当前的权限菜单(有层级) |
| | | // List<SysMenu> levelMenus = roleService.getMenuLevelList(menusId); |
| | | |
| | | roleInfoVo.setMenus(menusId); |
| | | return AjaxResult.success(roleInfoVo); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("用户获取权限菜单") |
| | | @GetMapping("/roleInfoFromUserId") |
| | | public AjaxResult roleInfoFromUserId( @RequestParam Long userId) |
| | | @GetMapping("/roleInfoFromUserId/{userId}") |
| | | public R<List<SysMenu>> roleInfoFromUserId(@PathVariable("userId") Long userId) |
| | | { |
| | | SysUserRole one = sysUserRoleService.getOne(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, userId)); |
| | | Long id =one.getRoleId(); |
| | | // 获取当前角色的菜单id |
| | | List<Long> menusId = sysRoleMenuMapper.selectList(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, id)).stream().map(SysRoleMenu::getMenuId).collect(Collectors.toList()); |
| | | if(menusId.size()==0){ |
| | | return AjaxResult.success(new ArrayList<>()); |
| | | } |
| | | if(id!=1){ |
| | | menusId = menusId.stream().filter(e->e!=1074 && e!=1075 && e!=1193 && e!=1194).collect(Collectors.toList()); |
| | | } |
| | | //获取当前的权限菜单 |
| | | List<SysMenus> all = menuMapper.getAllInIds(menusId); |
| | | // 第三级 |
| | | List<SysMenus> s3 = all.stream().filter(e -> e.getMenuType().equals("F")).collect(Collectors.toList()); |
| | | // 第二级 |
| | | List<SysMenus> s2 = all.stream().filter(e -> e.getMenuType().equals("C")).collect(Collectors.toList()); |
| | | // 第一级 |
| | | List<SysMenus> s1 = all.stream().filter(e -> e.getMenuType().equals("M")).collect(Collectors.toList()); |
| | | |
| | | for (SysMenus menus : s2) { |
| | | List<SysMenus> collect = s3.stream().filter(e -> e.getParentId().equals(menus.getMenuId())).collect(Collectors.toList()); |
| | | menus.setChildren(collect); |
| | | } |
| | | |
| | | for (SysMenus menus : s1) { |
| | | List<SysMenus> collect = s2.stream().filter(e -> e.getParentId().equals(menus.getMenuId())).collect(Collectors.toList()); |
| | | menus.setChildren(collect); |
| | | } |
| | | |
| | | return AjaxResult.success(s1); |
| | | return R.ok(roleService.roleInfoFromUserId(userId)); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ApiOperation("编辑角色") |
| | | @PostMapping("/roleUpdate") |
| | | public AjaxResult roleUpdate(@Validated @RequestBody RoleUpdateDto dto) |
| | | { |
| | | SysRole role = new SysRole(); |
| | | role.setRoleName(dto.getRoleName()); |
| | | SysRole one = roleService.getOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getRoleId, dto.getRoleId())); |
| | | List<SysRole> sysRoles = roleService.isExitUpdate(dto.getRoleName(),dto.getRoleId()); |
| | | if(sysRoles.size()>0){ |
| | | return AjaxResult.error("角色已存在,请重新输入"); |
| | | } |
| | | // 编辑角色 |
| | | role.setUpdateBy(SecurityUtils.getUsername()); |
| | | // role.setUpdateTime(new Date()); |
| | | role.setRoleId(dto.getRoleId()); |
| | | roleService.updateRole(role); |
| | | ArrayList<SysRoleMenu> sysRoleMenus = new ArrayList<>(); |
| | | List<Long> menuIds = dto.getMenuIds(); |
| | | // 移除原来的权限菜单 |
| | | if(menuIds.contains(1061L)){ |
| | | sysRoleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>() |
| | | .eq(SysRoleMenu::getRoleId,dto.getRoleId())); |
| | | }else { |
| | | sysRoleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>() |
| | | .eq(SysRoleMenu::getRoleId,dto.getRoleId()) |
| | | .ne(SysRoleMenu::getMenuId,1061L) |
| | | .ne(SysRoleMenu::getMenuId,1062L) |
| | | .ne(SysRoleMenu::getMenuId,1065L) |
| | | .ne(SysRoleMenu::getMenuId,1073L) |
| | | .ne(SysRoleMenu::getMenuId,1161L) |
| | | .ne(SysRoleMenu::getMenuId,1203L) |
| | | ); |
| | | } |
| | | for (Long menuId : menuIds) { |
| | | SysRoleMenu sysRoleMenu = new SysRoleMenu(); |
| | | sysRoleMenu.setMenuId(menuId); |
| | | sysRoleMenu.setRoleId(role.getRoleId()); |
| | | sysRoleMenus.add(sysRoleMenu); |
| | | } |
| | | sysRoleMenuMapper.batchRoleMenu(sysRoleMenus); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @Log(title = "角色管理", businessType = BusinessType.EXPORT) |
| | | @RequiresPermissions("system:role:export") |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, SysRole role) |
| | | { |
| | | List<SysRole> list = roleService.selectRoleList(role); |
| | | ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class); |
| | | util.exportExcel(response, list, "角色数据"); |
| | | } |
| | | |
| | | /** |
| | | * 根据角色编号获取详细信息 |
| | | */ |
| | | @RequiresPermissions("system:role:query") |
| | | @GetMapping(value = "/{roleId}") |
| | | public AjaxResult getInfo(@PathVariable Long roleId) |
| | | { |
| | | roleService.checkRoleDataScope(roleId); |
| | | return success(roleService.selectRoleById(roleId)); |
| | | } |
| | | |
| | | /** |
| | | * 新增角色 |
| | | */ |
| | | @RequiresPermissions("system:role:add") |
| | | @Log(title = "角色管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysRole role) |
| | | { |
| | | if (!roleService.checkRoleNameUnique(role)) |
| | | { |
| | | return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); |
| | | } |
| | | else if (!roleService.checkRoleKeyUnique(role)) |
| | | { |
| | | return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); |
| | | } |
| | | role.setCreateBy(SecurityUtils.getUsername()); |
| | | return toAjax(roleService.insertRole(role)); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 修改保存角色 |
| | | */ |
| | | @RequiresPermissions("system:role:edit") |
| | | @Log(title = "角色管理", businessType = BusinessType.UPDATE) |
| | | // @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @ApiOperation(value = "编辑角色") |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysRole role) |
| | | public AjaxResult edit(@Validated @RequestBody SysRoleDTO dto) |
| | | { |
| | | roleService.checkRoleAllowed(role); |
| | | roleService.checkRoleDataScope(role.getRoleId()); |
| | | if (!roleService.checkRoleNameUnique(role)) |
| | | Boolean flag= roleService.isExit(dto.getRoleId(),dto.getRoleName()); |
| | | if (flag){ |
| | | return error("修改角色'" + dto.getRoleName() + "'失败,角色名称已存在"); |
| | | } |
| | | SysRole sysRole = roleService.selectRoleById(dto.getRoleId()); |
| | | if("meal".equals(sysRole.getRoleKey()) || "sale".equals(sysRole.getRoleKey()) || "admin".equals(sysRole.getRoleKey())){ |
| | | return error("当前角色无法修改"); |
| | | } |
| | | if (roleService.editRole(dto) > 0) |
| | | { |
| | | return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); |
| | | // 更新缓存用户权限 |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (StringUtils.isNotNull(loginUser.getSysUser()) && !loginUser.getSysUser().isAdmin()) |
| | | { |
| | | loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getSysUser())); |
| | | loginUser.setSysUser(userService.selectUserByUserName(loginUser.getSysUser().getUserName())); |
| | | tokenService.setLoginUser(loginUser); |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | else if (!roleService.checkRoleKeyUnique(role)) |
| | | { |
| | | return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); |
| | | } |
| | | role.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(roleService.updateRole(role)); |
| | | return error("修改角色'" + dto.getRoleName() + "'失败,请联系管理员"); |
| | | } |
| | | |
| | | /** |
| | | * 修改保存数据权限 |
| | | */ |
| | | @RequiresPermissions("system:role:edit") |
| | | @Log(title = "角色管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/dataScope") |
| | | public AjaxResult dataScope(@RequestBody SysRole role) |
| | | { |
| | | roleService.checkRoleAllowed(role); |
| | | roleService.checkRoleDataScope(role.getRoleId()); |
| | | return toAjax(roleService.authDataScope(role)); |
| | | } |
| | | |
| | | /** |
| | | * 状态修改 |
| | | */ |
| | | @RequiresPermissions("system:role:edit") |
| | | @Log(title = "角色管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public AjaxResult changeStatus(@RequestBody SysRole role) |
| | | { |
| | | roleService.checkRoleAllowed(role); |
| | | roleService.checkRoleDataScope(role.getRoleId()); |
| | | role.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(roleService.updateRoleStatus(role)); |
| | | } |
| | | |
| | | /** |
| | | * 删除角色 |
| | | */ |
| | | @RequiresPermissions("system:role:remove") |
| | | @Log(title = "角色管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{roleIds}") |
| | | public AjaxResult remove(@PathVariable Long[] roleIds) |
| | | { |
| | | return toAjax(roleService.deleteRoleByIds(roleIds)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 停用角色 |
| | | */ |
| | | @RequiresPermissions("system:role:stop") |
| | | @Log(title = "角色管理", businessType = BusinessType.STOP) |
| | | @PutMapping("/stop") |
| | | public AjaxResult stop(@RequestBody Long roleId) |
| | | { |
| | | SysRole sysRole = roleService.selectRoleById(roleId); |
| | | if(sysRole.getStatus().equals("0")){ |
| | | sysRole.setStatus("1"); |
| | | }else { |
| | | sysRole.setStatus("0"); |
| | | } |
| | | return toAjax(roleService.updateRole(sysRole)); |
| | | } |
| | | |
| | | /** |
| | | * 获取角色选择框列表 |
| | | */ |
| | | @RequiresPermissions("system:role:query") |
| | | @GetMapping("/optionselect") |
| | | public AjaxResult optionselect() |
| | | { |
| | | return success(roleService.selectRoleAll()); |
| | | } |
| | | /** |
| | | * 查询已分配用户角色列表 |
| | | */ |
| | | @RequiresPermissions("system:role:list") |
| | | @GetMapping("/authUser/allocatedList") |
| | | public TableDataInfo allocatedList(SysUser user) |
| | | { |
| | | startPage(); |
| | | List<SysUser> list = userService.selectAllocatedList(user); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * 查询未分配用户角色列表 |
| | | */ |
| | | @RequiresPermissions("system:role:list") |
| | | @GetMapping("/authUser/unallocatedList") |
| | | public TableDataInfo unallocatedList(SysUser user) |
| | | { |
| | | startPage(); |
| | | List<SysUser> list = userService.selectUnallocatedList(user); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * 取消授权用户 |
| | | */ |
| | | @RequiresPermissions("system:role:edit") |
| | | @Log(title = "角色管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/cancel") |
| | | public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole) |
| | | { |
| | | return toAjax(roleService.deleteAuthUser(userRole)); |
| | | } |
| | | |
| | | /** |
| | | * 批量取消授权用户 |
| | | */ |
| | | @RequiresPermissions("system:role:edit") |
| | | @Log(title = "角色管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/cancelAll") |
| | | public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds) |
| | | { |
| | | return toAjax(roleService.deleteAuthUsers(roleId, userIds)); |
| | | } |
| | | |
| | | /** |
| | | * 批量选择用户授权 |
| | | */ |
| | | @RequiresPermissions("system:role:edit") |
| | | @Log(title = "角色管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/selectAll") |
| | | public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds) |
| | | { |
| | | roleService.checkRoleDataScope(roleId); |
| | | return toAjax(roleService.insertAuthUsers(roleId, userIds)); |
| | | } |
| | | |
| | | /** |
| | | * 获取对应角色部门树列表 |
| | | */ |
| | | @RequiresPermissions("system:role:query") |
| | | @GetMapping(value = "/deptTree/{roleId}") |
| | | public AjaxResult deptTree(@PathVariable("roleId") Long roleId) |
| | | { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId)); |
| | | ajax.put("depts", deptService.selectDeptTreeList(new SysDept())); |
| | | return ajax; |
| | | } |
| | | // |
| | | // /** |
| | | // * 修改保存数据权限 |
| | | // */ |
| | | // // @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | // @Log(title = "角色管理", businessType = BusinessType.UPDATE) |
| | | // @PutMapping("/dataScope") |
| | | // public AjaxResult dataScope(@RequestBody SysRole role) |
| | | // { |
| | | // roleService.checkRoleAllowed(role); |
| | | // roleService.checkRoleDataScope(role.getRoleId()); |
| | | // return AjaxResult.success(roleService.authDataScope(role)); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 状态修改 |
| | | // */ |
| | | // // @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | // @ApiOperation(value = "状态修改") |
| | | // @Log(title = "角色信息-角色状态修改", businessType = BusinessType.UPDATE) |
| | | // @PutMapping("/changeStatus") |
| | | // public AjaxResult changeStatus(@RequestBody SysRole role) |
| | | // { |
| | | // SysRole sysRole = roleService.selectRoleById(role.getRoleId()); |
| | | // if("meal".equals(sysRole.getRoleKey()) || "sale".equals(sysRole.getRoleKey()) || "admin".equals(sysRole.getRoleKey())){ |
| | | // return error("当前角色无法修改状态"); |
| | | // } |
| | | // role.setUpdateBy(getUsername()); |
| | | // roleService.updateStatus(role); |
| | | // return AjaxResult.success(); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 删除角色 |
| | | // */ |
| | | // // @PreAuthorize("@ss.hasPermi('system:role:remove')") |
| | | //// @ApiOperation(value = "批量删除角色") |
| | | //// @Log(title = "角色信息-角色删除角色", businessType = BusinessType.DELETE) |
| | | //// @DeleteMapping("/deleteById/{id}") |
| | | //// public AjaxResult remove(@PathVariable(value = "id") Long id) |
| | | //// { |
| | | //// SysRole sysRole = roleService.selectRoleById(id); |
| | | //// if("meal".equals(sysRole.getRoleKey()) || "sale".equals(sysRole.getRoleKey()) || "admin".equals(sysRole.getRoleKey())){ |
| | | //// return error("当前角色无法删除"); |
| | | //// } |
| | | //// return AjaxResult.success(roleService.deleteRoleById(id)); |
| | | //// } |
| | | // |
| | | // /** |
| | | // * 删除角色 |
| | | // */ |
| | | // // @PreAuthorize("@ss.hasPermi('system:role:remove')") |
| | | // @ApiOperation(value = "批量删除角色") |
| | | // @Log(title = "角色信息-角色删除角色", businessType = BusinessType.DELETE) |
| | | // @DeleteMapping("/deleteById/{ids}") |
| | | // public AjaxResult remove(@PathVariable String ids) |
| | | // { |
| | | // String[] split = ids.split(","); |
| | | // List<Long> id = new ArrayList<>(); |
| | | // for (String s : split) { |
| | | // id.add(Long.valueOf(s)); |
| | | // } |
| | | // return AjaxResult.success(roleService.deleteRoleByIds(id)); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 获取角色选择框列表 |
| | | // */ |
| | | // // @PreAuthorize("@ss.hasPermi('system:role:query')") |
| | | // @GetMapping("/optionselect") |
| | | // public AjaxResult optionselect() |
| | | // { |
| | | // return AjaxResult.success(roleService.selectRoleAll()); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 查询已分配用户角色列表 |
| | | // */ |
| | | // // @PreAuthorize("@ss.hasPermi('system:role:list')") |
| | | // @GetMapping("/authUser/allocatedList") |
| | | // public TableDataInfo allocatedList(SysUser user) |
| | | // { |
| | | //// startPage(); |
| | | // List<SysUser> list = userService.selectAllocatedList(user); |
| | | // return getDataTable(list); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 查询未分配用户角色列表 |
| | | // */ |
| | | // // @PreAuthorize("@ss.hasPermi('system:role:list')") |
| | | // @GetMapping("/authUser/unallocatedList") |
| | | // public TableDataInfo unallocatedList(SysUser user) |
| | | // { |
| | | //// startPage(); |
| | | // List<SysUser> list = userService.selectUnallocatedList(user); |
| | | // return getDataTable(list); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 取消授权用户 |
| | | // */ |
| | | // // @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | // @Log(title = "角色管理", businessType = BusinessType.GRANT) |
| | | // @PutMapping("/authUser/cancel") |
| | | // public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole) |
| | | // { |
| | | // return AjaxResult.success(roleService.deleteAuthUser(userRole)); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 批量取消授权用户 |
| | | // */ |
| | | // // @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | // @Log(title = "角色管理", businessType = BusinessType.GRANT) |
| | | // @PutMapping("/authUser/cancelAll") |
| | | // public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds) |
| | | // { |
| | | // return AjaxResult.success(roleService.deleteAuthUsers(roleId, userIds)); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 批量选择用户授权 |
| | | // */ |
| | | // // @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | // @Log(title = "角色管理", businessType = BusinessType.GRANT) |
| | | // @PutMapping("/authUser/selectAll") |
| | | // public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds) |
| | | // { |
| | | // roleService.checkRoleDataScope(roleId); |
| | | // return AjaxResult.success(roleService.insertAuthUsers(roleId, userIds)); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 获取对应角色部门树列表 |
| | | // */ |
| | | // // @PreAuthorize("@ss.hasPermi('system:role:query')") |
| | | // @GetMapping(value = "/deptTree/{roleId}") |
| | | // public AjaxResult deptTree(@PathVariable("roleId") Long roleId) |
| | | // { |
| | | // AjaxResult ajax = AjaxResult.success(); |
| | | // ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId)); |
| | | // ajax.put("depts", deptService.selectDeptTreeList(new SysDept())); |
| | | // return ajax; |
| | | // } |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.sun.org.apache.bcel.internal.generic.NEW; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.StringUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.core.utils.poi.ExcelUtil; |
| | | import com.xinquan.common.core.web.controller.BaseController; |
| | | import com.xinquan.common.core.web.domain.AjaxResult; |
| | |
| | | import com.xinquan.common.log.enums.BusinessType; |
| | | import com.xinquan.common.security.annotation.InnerAuth; |
| | | import com.xinquan.common.security.annotation.RequiresPermissions; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.system.api.domain.SysDept; |
| | | import com.xinquan.system.api.domain.SysRole; |
| | | import com.xinquan.system.api.domain.SysUser; |
| | | import com.xinquan.system.api.domain.vo.SysUserVO; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.system.domain.Banner; |
| | | import com.xinquan.system.domain.SysUserDept; |
| | | import com.xinquan.system.domain.SysUserRole; |
| | | import com.xinquan.system.domain.dto.SysUserQuery; |
| | | import com.xinquan.system.domain.dto.SysUserUpdateStatusDTO; |
| | | import com.xinquan.system.domain.dto.UpdatePwdDTO; |
| | | import com.xinquan.system.service.*; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import java.io.IOException; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Api(tags = "用户信息") |
| | | @RestController |
| | | @RequestMapping("/user") |
| | | @Api(tags = "用户信息") |
| | | public class SysUserController extends BaseController { |
| | | public class SysUserController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private ISysDeptService deptService; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @Autowired |
| | | private ISysUserRoleService sysUserRoleService; |
| | | |
| | | @Autowired |
| | | private ISysPostService postService; |
| | | |
| | | @Autowired |
| | | private ISysPermissionService permissionService; |
| | | @Resource |
| | | private ISysUserDeptService sysUserDeptService; |
| | | /** |
| | | * 获取用户列表 |
| | | */ |
| | | @ApiOperation(value = "获取用户列表") |
| | | @PostMapping("/list") |
| | | public AjaxResult<PageDTO<SysUserVO>> list(@RequestBody SysUserQuery query) |
| | | { |
| | | Page<SysUserVO> res = new Page<>(query.getPageCurr(), query.getPageSize()); |
| | | |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | PageInfo<SysUserVO> list = userService.pageList(query); |
| | | for (SysUserVO record : list.getRecords()) { |
| | | List<Long> collect1 = sysUserRoleService.lambdaQuery().eq(SysUserRole::getUserId, record.getUserId()) |
| | | .list().stream().map(SysUserRole::getRoleId).collect(Collectors.toList()); |
| | | record.setRole(collect1); |
| | | List<String> strings1 = new ArrayList<>(); |
| | | if (record.getRole()!=null && (!record.getRole().isEmpty())){ |
| | | for (Long l : collect1) { |
| | | SysRole sysRole = roleService.selectRoleById(l); |
| | | if (sysRole!=null){ |
| | | strings1.add(sysRole.getRoleName()); |
| | | } |
| | | } |
| | | } |
| | | record.setRoleNames(strings1); |
| | | List<Long> collect2 = sysUserDeptService.lambdaQuery().eq(SysUserDept::getUserId, record.getUserId()) |
| | | .list().stream().map(SysUserDept::getDeptId).collect(Collectors.toList()); |
| | | record.setDeptIds(collect2); |
| | | List<String> strings = new ArrayList<>(); |
| | | if (record.getDeptIds()!=null && (!record.getDeptIds().isEmpty())){ |
| | | for (Long deptId : record.getDeptIds()) { |
| | | SysDept sysDept = deptService.selectDeptById(deptId); |
| | | if (sysDept!=null){ |
| | | strings.add(sysDept.getDeptName()); |
| | | } |
| | | } |
| | | } |
| | | record.setDeptNames(strings); |
| | | |
| | | @Autowired |
| | | private ISysUserRoleService userRoleService; |
| | | } |
| | | res.setRecords(list.getRecords()); |
| | | PageDTO<SysUserVO> sysUserVOPageDTO = PageDTO.of(res, SysUserVO.class); |
| | | return AjaxResult.success(sysUserVOPageDTO); |
| | | } |
| | | @ApiOperation(value = "新增用户管理") |
| | | @PostMapping("/add") |
| | | public AjaxResult add(@Validated @RequestBody SysUser user) { |
| | | if (!userService.checkUserNameUnique(user)) |
| | | { |
| | | return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | | } |
| | | else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) |
| | | { |
| | | return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | | user.setUserType("00"); |
| | | user.setPassword("123456"); |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | userService.insertUser(user); |
| | | return AjaxResult.success(); |
| | | } |
| | | @ApiOperation(value = "修改用户管理") |
| | | @PostMapping("/edit") |
| | | public AjaxResult edit(@Validated @RequestBody SysUser user) { |
| | | // userService.checkUserAllowed(user); |
| | | // userService.checkUserDataScope(user.getUserId()); |
| | | if (!userService.checkUserNameUnique(user)) |
| | | { |
| | | return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | | } |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = userService.selectUserById(userid); |
| | | user.setUpdateBy(sysUser.getNickName()+"("+sysUser.getUserName()+")"); |
| | | user.setHandleName(sysUser.getNickName()+"("+sysUser.getUserName()+")"); |
| | | user.setUpdateTime(LocalDateTime.now()); |
| | | if (user.getPassword()!=null){ |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | } |
| | | |
| | | @Autowired |
| | | private ISysUserRoleService sysUserRoleService; |
| | | return AjaxResult.success(userService.updateUser(user)); |
| | | } |
| | | |
| | | @ApiOperation(value = "禁用启用") |
| | | @PutMapping("/changeStatus") |
| | | public AjaxResult changeStatus(@RequestBody SysUserUpdateStatusDTO dto) |
| | | { |
| | | SysUser user = new SysUser(); |
| | | user.setUserId(dto.getUserId()); |
| | | user.setStatus(String.valueOf(dto.getStatus())); |
| | | user.setReason(dto.getReason()); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = userService.selectUserById(userid); |
| | | user.setUpdateBy(sysUser.getNickName()+"("+sysUser.getUserName()+")"); |
| | | user.setHandleName(sysUser.getNickName()+"("+sysUser.getUserName()+")"); |
| | | return AjaxResult.success(userService.updateUserStatus(user)); |
| | | } |
| | | /** |
| | | * 获取当前用户信息 |
| | | */ |
| | | @InnerAuth |
| | | @GetMapping("/info/{username}") |
| | | public R<LoginUser> info(@PathVariable("username") String username) { |
| | | SysUser sysUser = userService.selectUserByUserName(username); |
| | | if (StringUtils.isNull(sysUser)) { |
| | | return R.fail("用户名或密码错误"); |
| | | } |
| | | // 角色集合 |
| | | Set<String> roles = permissionService.getRolePermission(sysUser); |
| | | // 权限集合 |
| | | Set<String> permissions = permissionService.getMenuPermission(sysUser); |
| | | LoginUser sysUserVo = new LoginUser(); |
| | | sysUserVo.setSysUser(sysUser); |
| | | sysUserVo.setRoles(roles); |
| | | sysUserVo.setPermissions(permissions); |
| | | |
| | | return R.ok(sysUserVo); |
| | | } |
| | | // @ApiOperation(value = "获取用户列表-不分页") |
| | | // @PostMapping("/listNotPage") |
| | | // public AjaxResult<List<SysUser>> listNotPage() |
| | | // { |
| | | // List<SysUser> list = userService.selectList(); |
| | | // return AjaxResult.success(list); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 获取用户黑名单列表 |
| | | // */ |
| | | //// @ApiOperation(value = "获取用户黑名单列表") |
| | | //// @PostMapping("/blacklist") |
| | | //// public AjaxResult blacklist(@RequestBody SysUserQuery query) |
| | | //// { |
| | | //// startPage(query.getPageNum(), query.getPageSize()); |
| | | //// List<SysUserVO> list = userService.selectBlackPageList(query); |
| | | //// return AjaxResult.success(getDataTable(list)); |
| | | //// } |
| | | // |
| | | // /** |
| | | // * 获取用户详情 |
| | | // */ |
| | | // @ApiOperation(value = "获取用户详情") |
| | | // @GetMapping("/getDetail") |
| | | // public AjaxResult<SysUser> getDetail(@RequestParam Long userId) |
| | | // { |
| | | // SysUser sysUser = userService.selectUserById(userId); |
| | | // SysUserVO sysUserVO = new SysUserVO(); |
| | | // BeanUtils.copyProperties(sysUser,sysUserVO); |
| | | // |
| | | // return AjaxResult.success(sysUser); |
| | | // } |
| | | // |
| | | // |
| | | // /** |
| | | // * 获取用户数量统计 |
| | | // */ |
| | | // @ApiOperation(value = "获取用户数量统计") |
| | | // @PostMapping("/getUserCount") |
| | | // public AjaxResult<Map<String,Integer>> getUserCount() |
| | | // { |
| | | // Map<String,Integer> map = new HashMap<>(); |
| | | // |
| | | // Integer userCountSum = userService.selectCount(null); |
| | | // Integer normalCount = userService.selectCount(0);// 正常 |
| | | // Integer stopCount = userService.selectCount(1);// 停用 |
| | | // |
| | | // map.put("all",userCountSum); |
| | | // map.put("normal",normalCount); |
| | | // map.put("stop",stopCount); |
| | | // |
| | | // return AjaxResult.success(map); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 移除黑名单 |
| | | // */ |
| | | //// @GetMapping("/removeBlackList") |
| | | //// public AjaxResult<String> removeBlackList(@RequestParam String ids) |
| | | //// { |
| | | //// String[] split = ids.split(","); |
| | | //// List<Long> id = new ArrayList<>(); |
| | | //// for (String s : split) { |
| | | //// id.add(Long.valueOf(s)); |
| | | //// } |
| | | //// userService.updateUserIfBlack(id); |
| | | //// return AjaxResult.success(); |
| | | //// } |
| | | // |
| | | // |
| | | //// @Log(title = "用户管理", businessType = BusinessType.EXPORT) |
| | | ////// // @PreAuthorize("@ss.hasPermi('system:user:export')") |
| | | //// @PostMapping("/export") |
| | | //// public void export(HttpServletResponse response, SysUser user) |
| | | //// { |
| | | //// List<SysUser> list = userService.selectUserList(user); |
| | | //// ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); |
| | | //// util.exportExcel(response, list, "用户数据"); |
| | | //// } |
| | | // |
| | | //// @Log(title = "用户管理", businessType = BusinessType.IMPORT) |
| | | ////// // @PreAuthorize("@ss.hasPermi('system:user:import')") |
| | | //// @PostMapping("/importData") |
| | | //// public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception |
| | | //// { |
| | | //// ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); |
| | | //// List<SysUser> userList = util.importExcel(file.getInputStream()); |
| | | //// String operName = getUsername(); |
| | | //// String message = userService.importUser(userList, updateSupport, operName); |
| | | //// return AjaxResult.success(message); |
| | | //// } |
| | | // |
| | | //// @PostMapping("/importTemplate") |
| | | //// public void importTemplate(HttpServletResponse response) |
| | | //// { |
| | | //// ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); |
| | | //// util.importTemplateExcel(response, "用户数据"); |
| | | //// } |
| | | // |
| | | // |
| | | // /** |
| | | // * 新增用户 |
| | | // */ |
| | | // // @PreAuthorize("@ss.hasPermi('system:user:add')") |
| | | // @ApiOperation(value = "新增用户管理") |
| | | // @Log(title = "用户信息-新增用户", businessType = BusinessType.INSERT) |
| | | // @PostMapping("/add") |
| | | // public AjaxResult add(@Validated @RequestBody SysUser user) |
| | | // { |
| | | // if (!userService.checkUserNameUnique(user)) |
| | | // { |
| | | // return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | | // } |
| | | // else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) |
| | | // { |
| | | // return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | // } |
| | | // user.setPassword("123456"); |
| | | // user.setRePassword("123456"); |
| | | // user.setCreateBy(getUsername()); |
| | | // user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | // userService.insertUser(user); |
| | | // return AjaxResult.success(); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 修改用户 |
| | | // */ |
| | | // // @PreAuthorize("@ss.hasPermi('system:user:edit')") |
| | | // @ApiOperation(value = "修改用户管理") |
| | | // @Log(title = "用户信息-修改用户", businessType = BusinessType.UPDATE) |
| | | // @PostMapping("/edit") |
| | | // public AjaxResult edit(@Validated @RequestBody SysUser user) |
| | | // { |
| | | //// userService.checkUserAllowed(user); |
| | | //// userService.checkUserDataScope(user.getUserId()); |
| | | // if (!userService.checkUserNameUnique(user)) |
| | | // { |
| | | // return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | | // } |
| | | // else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) |
| | | // { |
| | | // return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | // } |
| | | // |
| | | // user.setUpdateBy(getUsername()); |
| | | //// user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | // return AjaxResult.success(userService.updateUser(user)); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 删除用户 |
| | | // */ |
| | | // // @PreAuthorize("@ss.hasPermi('system:user:remove')") |
| | | // @ApiOperation(value = "批量删除用户") |
| | | // @Log(title = "用户信息-批量删除用户", businessType = BusinessType.DELETE) |
| | | // @DeleteMapping("/deleteById/{ids}") |
| | | // public AjaxResult remove(@PathVariable String ids) |
| | | // { |
| | | // String[] split = ids.split(","); |
| | | // List<Long> userIds = new ArrayList<>(); |
| | | // for (String s : split) { |
| | | // userIds.add(Long.valueOf(s)); |
| | | // } |
| | | // if (userIds.contains(getUserId())) |
| | | // { |
| | | // return error("当前用户不能删除"); |
| | | // } |
| | | // return AjaxResult.success(userService.deleteUserByIds(userIds)); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 重置密码 |
| | | // */ |
| | | // // @PreAuthorize("@ss.hasPermi('system:user:resetPwd')") |
| | | // @ApiOperation(value = "重置密码") |
| | | // @Log(title = "用户信息-重置密码", businessType = BusinessType.UPDATE) |
| | | // @PostMapping("/resetPwd") |
| | | // public AjaxResult resetPwd(@RequestBody SysUser user) |
| | | // { |
| | | // userService.checkUserAllowed(user); |
| | | //// userService.checkUserDataScope(user.getUserId()); |
| | | // user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | // user.setUpdateBy(getUsername()); |
| | | // userService.resetPwd(user); |
| | | // return AjaxResult.success(); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 修改密码 |
| | | // */ |
| | | // // @PreAuthorize("@ss.hasPermi('system:user:resetPwd')") |
| | | // @ApiOperation(value = "修改密码") |
| | | // @Log(title = "用户信息-修改密码", businessType = BusinessType.UPDATE) |
| | | // @PostMapping("/updatePwd") |
| | | // public AjaxResult updatePwd(@RequestBody UpdatePwdDTO dto) |
| | | // { |
| | | // SysUser user = userService.selectUserByUserName(dto.getAccount()); |
| | | // if(Objects.isNull(user)){ |
| | | // return AjaxResult.error("未查询到该账号"); |
| | | // } |
| | | // userService.checkUserAllowed(user); |
| | | // // 校验密码跟原密码是否匹配 |
| | | // if (!SecurityUtils.matchesPassword(dto.getOldPassword(), user.getPassword())) { |
| | | // throw new BadCredentialsException("输入原密码不正确"); |
| | | // } |
| | | // if (!dto.getPassword().equals(dto.getConfirmPassword())) { |
| | | // throw new BadCredentialsException("两次输入密码不一致"); |
| | | // } |
| | | //// userService.checkUserDataScope(user.getUserId()); |
| | | // user.setPassword(SecurityUtils.encryptPassword(dto.getPassword())); |
| | | // user.setUpdateBy(getUsername()); |
| | | // return AjaxResult.success(userService.resetPwd(user)); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 状态修改 |
| | | // */ |
| | | // @ApiOperation(value = "状态修改") |
| | | // @Log(title = "用户信息-状态修改", businessType = BusinessType.UPDATE) |
| | | // @PutMapping("/changeStatus") |
| | | // public AjaxResult changeStatus(@RequestBody SysUserUpdateStatusDTO dto) |
| | | // { |
| | | // SysUser user = new SysUser(); |
| | | // user.setUserId(dto.getUserId()); |
| | | // user.setStatus(String.valueOf(dto.getStatus())); |
| | | // user.setDisableRemark(dto.getDisableRemark()); |
| | | // user.setUpdateBy(getUsername()); |
| | | // return AjaxResult.success(userService.updateUserStatus(user)); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 根据用户编号获取授权角色 |
| | | // */ |
| | | // // @PreAuthorize("@ss.hasPermi('system:user:query')") |
| | | // @GetMapping("/authRole/{userId}") |
| | | // public AjaxResult authRole(@PathVariable("userId") Long userId) |
| | | // { |
| | | // AjaxResult ajax = AjaxResult.success(); |
| | | // SysUser user = userService.selectUserById(userId); |
| | | // List<SysRole> roles = roleService.selectRolesByUserId(userId); |
| | | // ajax.put("user", user); |
| | | // ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); |
| | | // return ajax; |
| | | // } |
| | | // |
| | | // /** |
| | | // * 用户授权角色 |
| | | // */ |
| | | // // @PreAuthorize("@ss.hasPermi('system:user:edit')") |
| | | // @Log(title = "用户管理", businessType = BusinessType.GRANT) |
| | | // @PutMapping("/authRole") |
| | | // public AjaxResult insertAuthRole(Long userId, Long[] roleIds) |
| | | // { |
| | | // userService.checkUserDataScope(userId); |
| | | // userService.insertUserAuth(userId, roleIds); |
| | | // return AjaxResult.success(); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 获取部门树列表 |
| | | // */ |
| | | // // @PreAuthorize("@ss.hasPermi('system:user:list')") |
| | | // @GetMapping("/deptTree") |
| | | // public AjaxResult deptTree(SysDept dept) |
| | | // { |
| | | // return AjaxResult.success(deptService.selectDeptTreeList(dept)); |
| | | // } |
| | | /** |
| | | * 远程调用 根据系统用户id查询用户信息 |
| | | * @return |
| | |
| | | SysUser byId = userService.getById(id); |
| | | return R.ok(byId); |
| | | } |
| | | /** |
| | | * 新增用户 |
| | | */ |
| | | @Log(title = "用户管理", businessType = BusinessType.INSERT) |
| | | @PostMapping("/add") |
| | | @ApiOperation("添加管理员") |
| | | public AjaxResult add(@Validated @RequestBody SysUser user) { |
| | | user.setUserName(user.getPhonenumber()); |
| | | if(!org.springframework.util.StringUtils.hasLength(user.getNickName())){ |
| | | user.setNickName(user.getPhonenumber()); |
| | | } |
| | | if (StringUtils.isNotEmpty(user.getUserName()) && !userService.checkPhoneUnique(user)) { |
| | | return error("登陆账号已存在"); |
| | | } |
| | | user.setCreateBy(SecurityUtils.getUsername()); |
| | | user.setPassword(SecurityUtils.encryptPassword("123456")); |
| | | int i = userService.insertUser(user); |
| | | SysUserRole sysUserRole = new SysUserRole(); |
| | | sysUserRole.setRoleId(1l); |
| | | sysUserRole.setUserId(user.getUserId()); |
| | | int i1 = userRoleService.insertSysUserRole(sysUserRole); |
| | | return AjaxResult.success(i1); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据用户编号获取详细信息 |
| | | */ |
| | | @ApiOperation("管理员详情") |
| | | @GetMapping(value = {"/", "/{userId}"}) |
| | | public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) { |
| | | userService.checkUserDataScope(userId); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | List<SysRole> roles = roleService.selectRoleAll(); |
| | | ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); |
| | | ajax.put("posts", postService.selectPostAll()); |
| | | if (StringUtils.isNotNull(userId)) { |
| | | SysUser sysUser = userService.selectUserById(userId); |
| | | ajax.put(AjaxResult.DATA_TAG, sysUser); |
| | | ajax.put("postIds", postService.selectPostListByUserId(userId)); |
| | | ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList())); |
| | | } |
| | | return AjaxResult.success(ajax); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 修改用户 |
| | | */ |
| | | @Log(title = "用户管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/update") |
| | | @ApiOperation("编辑管理员") |
| | | public AjaxResult edit(@Validated @RequestBody SysUser user) { |
| | | |
| | | user.setUserName(user.getPhonenumber()); |
| | | if(!org.springframework.util.StringUtils.hasLength(user.getNickName())){ |
| | | user.setNickName(user.getPhonenumber()); |
| | | } |
| | | userService.checkUserAllowed(user); |
| | | userService.checkUserDataScope(user.getUserId()); |
| | | SysUser sysUser = userService.getOne(Wrappers.lambdaQuery(SysUser.class) |
| | | .eq(SysUser::getPhonenumber, user.getPhonenumber()) |
| | | .eq(SysUser::getDelFlag,0) |
| | | .last("LIMIT 1")); |
| | | |
| | | if (StringUtils.isNotEmpty(user.getPhonenumber()) && (Objects.nonNull(sysUser) && !user.getUserId().equals(sysUser.getUserId()) )) { |
| | | return error("手机号已开通账号"); |
| | | } |
| | | user.setUpdateBy(SecurityUtils.getUsername()); |
| | | if (user.getPassword() != null && !"".equals(user.getPassword())) { |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | } |
| | | if (user.getPhonenumber() != null) { |
| | | user.setUserName(user.getPhonenumber()); |
| | | } |
| | | user.setPassword(null); |
| | | // user.setUpdateBy(SecurityUtils.getUsername()); |
| | | // user.setUpdateTime(new Date()); |
| | | return toAjax(userService.updateUser(user)); |
| | | } |
| | | // @Log(title = "用户管理", businessType = BusinessType.UPDATE) |
| | | // @PutMapping("/update") |
| | | // @ApiOperation("编辑管理员") |
| | | // public AjaxResult edit(@Validated @RequestBody SysUser user) { |
| | | // |
| | | // user.setUserName(user.getPhonenumber()); |
| | | // if(!org.springframework.util.StringUtils.hasLength(user.getNickName())){ |
| | | // user.setNickName(user.getPhonenumber()); |
| | | // } |
| | | // userService.checkUserAllowed(user); |
| | | // userService.checkUserDataScope(user.getUserId()); |
| | | // SysUser sysUser = userService.getOne(Wrappers.lambdaQuery(SysUser.class) |
| | | // .eq(SysUser::getUserName, user.getUserName()) |
| | | // .eq(SysUser::getDelFlag,0) |
| | | // .last("LIMIT 1")); |
| | | // |
| | | // if (StringUtils.isNotEmpty(user.getPhonenumber()) && (Objects.nonNull(sysUser) && !user.getUserId().equals(sysUser.getUserId()) )) { |
| | | // return error("手机号已开通账号"); |
| | | // } |
| | | // user.setUpdateBy(SecurityUtils.getUsername()); |
| | | // if (user.getPassword() != null && !"".equals(user.getPassword())) { |
| | | // user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | // } |
| | | // if (user.getPhonenumber() != null) { |
| | | // user.setUserName(user.getPhonenumber()); |
| | | // } |
| | | // user.setPassword(null); |
| | | // |
| | | // return toAjax(userService.updateUser(user)); |
| | | // } |
| | | |
| | | /** |
| | | * 删除用户 |
| | |
| | | /** |
| | | * 获取当前用户信息 |
| | | */ |
| | | @InnerAuth |
| | | @GetMapping("/info/{username}") |
| | | public R<LoginUser> info(@PathVariable("username") String username) { |
| | | SysUser sysUser = userService.selectUserByUserName(username); |
| | | if (StringUtils.isNull(sysUser)) { |
| | | return R.fail("用户名或密码错误"); |
| | | } |
| | | // 角色集合 |
| | | Set<String> roles = permissionService.getRolePermission(sysUser); |
| | | // 权限集合 |
| | | Set<String> permissions = permissionService.getMenuPermission(sysUser); |
| | | LoginUser sysUserVo = new LoginUser(); |
| | | sysUserVo.setSysUser(sysUser); |
| | | sysUserVo.setRoles(roles); |
| | | sysUserVo.setPermissions(permissions); |
| | | |
| | | return R.ok(sysUserVo); |
| | | } |
| | | |
| | | /** |
| | | * 注册用户信息 |
| | | */ |
| | | @InnerAuth |
| | | @PostMapping("/register") |
| | | public R<Boolean> register(@RequestBody SysUser sysUser) { |
| | | String username = sysUser.getUserName(); |
| | | if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) { |
| | | return R.fail("当前系统没有开启注册功能!"); |
| | | } |
| | | if (!userService.checkUserNameUnique(sysUser)) { |
| | | return R.fail("保存用户'" + username + "'失败,注册账号已存在"); |
| | | } |
| | | return R.ok(userService.registerUser(sysUser)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 注册用户信息 |
| | |
| | | userService.registerUser(sysUser); |
| | | return R.ok(sysUser); |
| | | } |
| | | /** |
| | | * 获取用户信息 |
| | | * |
| | | * @return 用户信息 |
| | | */ |
| | | @GetMapping("/getInfo") |
| | | public AjaxResult getInfo() { |
| | | SysUser user = userService.selectUserById(SecurityUtils.getUserId()); |
| | | // 角色集合 |
| | | Set<String> roles = permissionService.getRolePermission(user); |
| | | // 权限集合 |
| | | Set<String> permissions = permissionService.getMenuPermission(user); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("user", user); |
| | | ajax.put("roles", roles); |
| | | ajax.put("permissions", permissions); |
| | | return ajax; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | return toAjax(userService.resetPwd(user)); |
| | | } |
| | | |
| | | /** |
| | | * 状态修改 |
| | | */ |
| | | @RequiresPermissions("system:user:edit") |
| | | @Log(title = "用户管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public AjaxResult changeStatus(@RequestBody SysUser user) { |
| | | userService.checkUserAllowed(user); |
| | | userService.checkUserDataScope(user.getUserId()); |
| | | user.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(userService.updateUserStatus(user)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据用户编号获取授权角色 |
| | |
| | | .last("LIMIT 1")); |
| | | return R.ok(user); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.system.api.domain.vo.UpdateTreeGroupVO; |
| | | import com.xinquan.system.domain.TreeLevelSetting; |
| | | import com.xinquan.system.domain.VipSetting; |
| | | import com.xinquan.system.api.domain.TreeLevelSetting; |
| | | import com.xinquan.system.service.TreeLevelSettingService; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | public R updateTreeGroup(@RequestBody UpdateTreeGroupVO vo) { |
| | | TreeLevelSetting one = treeLevelSettingService.lambdaQuery() |
| | | .eq(TreeLevelSetting::getTreeLevelType, vo.getTreeLevelType()).one(); |
| | | vo.setGrow_up_music(vo.getGrow_up_music()); |
| | | one.setGrowUpMusic(vo.getGrow_up_music()); |
| | | treeLevelSettingService.updateById(one); |
| | | return R.ok(); |
| | | } |
New file |
| | |
| | | package com.xinquan.system.controller; |
| | | |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.system.utils.ObsUploadUtil; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestPart; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | /** |
| | | * 文件请求处理 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/system/upload") |
| | | public class UploadFileController |
| | | { |
| | | /** |
| | | * 文件上传请求 |
| | | */ |
| | | @PostMapping("/obs-upload") |
| | | @ApiOperation(value = "文件上传",tags = "管理后台-文件上传") |
| | | public R<String> uploadOSS(@RequestPart("file") MultipartFile file) { |
| | | try { |
| | | // 上传并返回访问地址 |
| | | String fileName = file.getOriginalFilename(); |
| | | String prefix = fileName.substring(fileName.lastIndexOf(".")); |
| | | long fileSize = file.getSize(); |
| | | String url = ObsUploadUtil.obsUpload(file); |
| | | return R.ok(url); |
| | | } catch (Exception e) { |
| | | System.err.println("上传文件失败"+e); |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.system.api.domain.vo.AppUserVO; |
| | | import com.xinquan.system.api.domain.UserLevelSetting; |
| | | import com.xinquan.system.api.domain.vo.UpdateTreeGroupVO; |
| | | import com.xinquan.system.api.domain.vo.UpdateUserGroupVO; |
| | | import com.xinquan.system.domain.TreeLevelSetting; |
| | | import com.xinquan.system.service.UserLevelSettingService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | UserLevelSetting one = userLevelSettingService.lambdaQuery() |
| | | .eq(UserLevelSetting::getTreeLevelType, vo.getTreeLevelType()).one(); |
| | | LambdaUpdateWrapper<UserLevelSetting> userLevelSettingLambdaUpdateWrapper = new LambdaUpdateWrapper<>(); |
| | | userLevelSettingLambdaUpdateWrapper.eq(UserLevelSetting::getId, one.getId()); |
| | | userLevelSettingLambdaUpdateWrapper.set(UserLevelSetting::getLevelName,vo.getLevelName()); |
| | | userLevelSettingLambdaUpdateWrapper.set(UserLevelSetting::getLevelIcon,vo.getLevelIcon()); |
| | | userLevelSettingLambdaUpdateWrapper.set(UserLevelSetting::getUpdateTime, LocalDateTime.now()); |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.system.domain.Version; |
| | | import com.xinquan.system.service.VersionService; |
| | |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Arrays; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public class VersionController { |
| | | @Autowired |
| | | private VersionService versionService; |
| | | @PostMapping("/versionList") |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @GetMapping("/versionList") |
| | | @ApiOperation(value = "版本管理列表-分页", tags = {"管理后台-版本管理"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "分页参数,当前页码", name = "pageCurr", required = true, dataType = "Integer"), |
| | |
| | | @RequestParam(value = "pageCurr", defaultValue = "1") Integer pageCurr, |
| | | @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | if(userId ==null || userId == 0)return R.tokenError("登录失效"); |
| | | Page<Version> page = versionService.lambdaQuery() |
| | | .orderByDesc(Version::getCreateTime) |
| | | .page(new Page<>(pageCurr, pageSize)); |
| | |
| | | return R.ok(PageDTO.of(page, Version.class)); |
| | | } |
| | | @PostMapping("/addVersion") |
| | | @ApiOperation(value = "新增版本管理", notes = "管理后台-版本管理") |
| | | @ApiOperation(value = "新增版本管理", tags = "管理后台-版本管理") |
| | | public R addVersion(@RequestBody Version homeBackgroundMusic) { |
| | | homeBackgroundMusic.setCreateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setCreateTime(LocalDateTime.now()); |
| | | return R.ok(versionService.save(homeBackgroundMusic)); |
| | | } |
| | | @GetMapping("/detailVersion") |
| | | @ApiOperation(value = "查看详情版本管理", notes = "管理后台-版本管理") |
| | | @ApiOperation(value = "查看详情版本管理", tags = "管理后台-版本管理") |
| | | public R<Version> detailVersion(String uid) { |
| | | return R.ok(versionService.getById(uid)); |
| | | } |
| | | @PostMapping("/updateVersion") |
| | | @ApiOperation(value = "修改版本管理", notes = "管理后台-版本管理") |
| | | @ApiOperation(value = "修改版本管理", tags = "管理后台-版本管理") |
| | | public R updateVersion(@RequestBody Version homeBackgroundMusic) { |
| | | homeBackgroundMusic.setUpdateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setUpdateTime(LocalDateTime.now()); |
| | | return R.ok(versionService.updateById(homeBackgroundMusic)); |
| | | } |
| | | @PostMapping("/deleteVersion") |
| | | @ApiOperation(value = "批量删除", notes = "管理后台-版本管理") |
| | | @ApiOperation(value = "批量删除", tags = "管理后台-版本管理") |
| | | public R deleteVersion(String ids) { |
| | | return R.ok(versionService.removeBatchByIds(Arrays.asList(ids.split(",")))); |
| | | return R.ok(versionService.removeBatchByIds(Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList()))); |
| | | } |
| | | } |
| | | |
| | |
| | | import com.xinquan.system.domain.ContentSetting; |
| | | import com.xinquan.system.domain.HotWords; |
| | | import com.xinquan.system.domain.VipSetting; |
| | | import com.xinquan.system.domain.dto.AggrementDto; |
| | | import com.xinquan.system.domain.dto.VipSettingDTO; |
| | | import com.xinquan.system.service.VipSettingService; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | |
| | | @PostMapping("/queryVip") |
| | | @ApiOperation(value = "获取会员价格设置", tags = {"管理后台-会员设置"}) |
| | | public R<VipSetting> queryVip() { |
| | | public R<VipSettingDTO> queryVip() { |
| | | VipSettingDTO vipSettingDTO = new VipSettingDTO(); |
| | | VipSetting one = vipSettingService.lambdaQuery() |
| | | .eq(VipSetting::getSettingType, 1).one(); |
| | | return R.ok(one); |
| | | .eq(VipSetting::getSettingType, 1) |
| | | .eq(VipSetting::getClientType,1).one(); |
| | | VipSetting two = vipSettingService.lambdaQuery() |
| | | .eq(VipSetting::getSettingType, 1) |
| | | .eq(VipSetting::getClientType,2).one(); |
| | | if (one!=null){ |
| | | vipSettingDTO.setMonthlyVip(one.getMonthlyVip()); |
| | | vipSettingDTO.setQuarterlyVip(one.getQuarterlyVip()); |
| | | vipSettingDTO.setAnnualVip(one.getAnnualVip()); |
| | | } |
| | | if (two!=null){ |
| | | vipSettingDTO.setMonthlyVipIos(one.getMonthlyVip()); |
| | | vipSettingDTO.setQuarterlyVipIos(one.getQuarterlyVip()); |
| | | vipSettingDTO.setAnnualVipIos(one.getAnnualVip()); |
| | | } |
| | | return R.ok(vipSettingDTO); |
| | | } |
| | | @PostMapping("/saveVip") |
| | | @ApiOperation(value = "保存会员价格设置", tags = {"管理后台-会员设置"}) |
| | | public R<VipSetting> saveVip(@RequestBody VipSetting vipSetting) { |
| | | vipSettingService.updateById(vipSetting); |
| | | public R<VipSetting> saveVip(@RequestBody VipSettingDTO dto) { |
| | | VipSetting one = vipSettingService.lambdaQuery() |
| | | .eq(VipSetting::getSettingType, 1) |
| | | .eq(VipSetting::getClientType,1).one(); |
| | | VipSetting two = vipSettingService.lambdaQuery() |
| | | .eq(VipSetting::getSettingType, 1) |
| | | .eq(VipSetting::getClientType,2).one(); |
| | | if (one == null){ |
| | | one = new VipSetting(); |
| | | one.setSettingType(1); |
| | | one.setClientType(1); |
| | | one.setMonthlyVip(dto.getMonthlyVip()); |
| | | one.setQuarterlyVip(dto.getQuarterlyVip()); |
| | | one.setAnnualVip(dto.getAnnualVip()); |
| | | vipSettingService.saveOrUpdate(one); |
| | | }else{ |
| | | one.setMonthlyVip(dto.getMonthlyVip()); |
| | | one.setQuarterlyVip(dto.getQuarterlyVip()); |
| | | one.setAnnualVip(dto.getAnnualVip()); |
| | | vipSettingService.saveOrUpdate(one); |
| | | } |
| | | |
| | | if (two == null){ |
| | | two = new VipSetting(); |
| | | two.setSettingType(1); |
| | | two.setClientType(2); |
| | | two.setMonthlyVip(dto.getMonthlyVipIos()); |
| | | two.setQuarterlyVip(dto.getQuarterlyVipIos()); |
| | | two.setAnnualVip(dto.getAnnualVipIos()); |
| | | vipSettingService.saveOrUpdate(two); |
| | | }else{ |
| | | two.setMonthlyVip(dto.getMonthlyVipIos()); |
| | | two.setQuarterlyVip(dto.getQuarterlyVipIos()); |
| | | two.setAnnualVip(dto.getAnnualVipIos()); |
| | | vipSettingService.saveOrUpdate(two); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/updateVipContent") |
| | | @ApiOperation(value = "修改会员权益介绍/获取会员用户协议/获取续费管理说明",tags = "管理后台-会员设置") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "内容类型 1=会员权益介绍 2=会员用户协议 3=续费管理说明", name = "type", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "富文本内容", name = "content", required = true, dataType = "String"), |
| | | }) |
| | | public R updateVipContent(Integer type,String content) { |
| | | public R updateVipContent(@RequestBody AggrementDto dto) { |
| | | VipSetting one = vipSettingService.lambdaQuery() |
| | | .eq(VipSetting::getSettingType, type+1).one(); |
| | | one.setContent(content); |
| | | vipSettingService.updateById(one); |
| | | .eq(VipSetting::getSettingType, dto.getType()+1).one(); |
| | | if (one == null){ |
| | | one = new VipSetting(); |
| | | } |
| | | one.setSettingType(dto.getType()+1); |
| | | one.setContent(dto.getContent()); |
| | | vipSettingService.saveOrUpdate(one); |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/getVipPrice") |
| | |
| | | return R.ok(one); |
| | | } |
| | | @PostMapping("/getVipContent") |
| | | @ApiOperation(value = "获取会员权益介绍/获取会员用户协议/获取续费管理说明",tags = "APP/管理后台通用-会员") |
| | | @ApiOperation(value = "获取会员权益介绍/获取会员用户协议/获取续费管理说明",tags = "管理后台-会员设置") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "内容类型 1=会员权益介绍 2=会员用户协议 3=续费管理说明", name = "type", required = true, dataType = "int"), |
| | | }) |
| | | public R<String> getVipPriceApple(Integer type) { |
| | | VipSetting one = vipSettingService.lambdaQuery() |
| | | .eq(VipSetting::getSettingType, type+1).one(); |
| | | if (one == null){ |
| | | return R.ok(""); |
| | | |
| | | } |
| | | return R.ok(one.getContent()); |
| | | } |
| | | |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "普通问题id") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "问题") |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "内容设置id") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "内容类型 1=用户协议 2=隐私协议 3=关于心泉 4= 新手冥想指南 5=课程/冥想音频购买协议 6=能量规则说明 7等级经验值规则说明") |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "热词id") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | @ApiModelProperty(value = "编辑删除使用该字段 赋值到id上") |
| | | @TableField(exist = false) |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "轮播图id") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "轮播图") |
| | |
| | | package com.xinquan.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.xinquan.common.core.web.domain.BaseModel; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "版本id") |
| | | @TableId("id") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "版本号") |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "VIP设置id") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | @ApiModelProperty(value = "uid 不会丢失精度的id 编辑时将值复制到id字段上") |
| | | @TableField(exist = false) |
New file |
| | |
| | | package com.xinquan.system.domain.dto; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class AggrementDto { |
| | | |
| | | @ApiModelProperty("内容类型 1=会员权益介绍 2=会员用户协议 3=续费管理说明") |
| | | private Integer type; |
| | | |
| | | @ApiModelProperty("富文本内容") |
| | | private String content; |
| | | } |
New file |
| | |
| | | package com.xinquan.system.domain.dto; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class AggrementOtherDto { |
| | | |
| | | @ApiModelProperty("内容类型 1=用户协议 2=隐私协议 3=关于心泉 4= 新手冥想指南 5=课程/冥想音频购买协议 6=能量规则说明 7等级经验值规则说明") |
| | | private Integer type; |
| | | |
| | | @ApiModelProperty("富文本内容") |
| | | private String content; |
| | | } |
New file |
| | |
| | | package com.xinquan.system.domain.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @ApiModel(value = "部门修改状态DTO") |
| | | public class SysDeptUpdateStatusDTO implements Serializable { |
| | | |
| | | @ApiModelProperty(value = "部门id") |
| | | private Long deptId; |
| | | |
| | | @ApiModelProperty(value = "状态 帐号状态(0正常 1停用)") |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty(value = "禁用备注") |
| | | private String reason; |
| | | |
| | | } |
New file |
| | |
| | | package com.xinquan.system.domain.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | @ApiModel(value = "角色新增DTO") |
| | | public class SysRoleDTO implements Serializable { |
| | | |
| | | @ApiModelProperty(value = "角色id") |
| | | private Long roleId; |
| | | |
| | | @ApiModelProperty(value = "角色名称") |
| | | private String roleName; |
| | | |
| | | @ApiModelProperty(value = "类型") |
| | | private Integer postType; |
| | | |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty(value = "权限id集合") |
| | | private List<Long> menuIds; |
| | | |
| | | } |
New file |
| | |
| | | package com.xinquan.system.domain.dto; |
| | | |
| | | import com.xinquan.common.core.web.page.BasePage; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @ApiModel(value = "角色查询Query") |
| | | public class SysRoleQuery extends BasePage { |
| | | |
| | | @ApiModelProperty(value = "角色名称") |
| | | private String roleName; |
| | | |
| | | @ApiModelProperty(value = "角色状态 0=正常,1=停用") |
| | | private Integer status; |
| | | } |
New file |
| | |
| | | package com.xinquan.system.domain.dto; |
| | | |
| | | import com.xinquan.common.core.web.page.BasePage; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | @ApiModel(value = "账户列表query") |
| | | public class SysUserQuery extends BasePage { |
| | | |
| | | @ApiModelProperty(value = "姓名或者手机号") |
| | | private String nickNameOrPhone; |
| | | |
| | | @ApiModelProperty(value = "角色id") |
| | | private List<Integer> roleIds; |
| | | @ApiModelProperty(value = "部门id") |
| | | private List<Integer> deptIds; |
| | | |
| | | @ApiModelProperty(value = "状态 0=正常 1=停用") |
| | | private String status; |
| | | |
| | | } |
New file |
| | |
| | | package com.xinquan.system.domain.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @ApiModel(value = "用户修改状态DTO") |
| | | public class SysUserUpdateStatusDTO implements Serializable { |
| | | |
| | | @ApiModelProperty(value = "用户id") |
| | | private Long userId; |
| | | |
| | | @ApiModelProperty(value = "状态 帐号状态(0正常 1停用)") |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty(value = "禁用备注") |
| | | private String reason; |
| | | |
| | | } |
New file |
| | |
| | | package com.xinquan.system.domain.dto; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class UnfreeDto { |
| | | @ApiModelProperty("禁用备注") |
| | | private String content; |
| | | } |
New file |
| | |
| | | package com.xinquan.system.domain.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @ApiModel(value = "修改密码DTO") |
| | | public class UpdatePwdDTO implements Serializable { |
| | | |
| | | @ApiModelProperty(value = "账号") |
| | | private String account; |
| | | |
| | | @ApiModelProperty(value = "原密码") |
| | | private String oldPassword; |
| | | |
| | | @ApiModelProperty(value = "新密码") |
| | | private String password; |
| | | |
| | | @ApiModelProperty(value = "确认密码") |
| | | private String confirmPassword; |
| | | |
| | | } |
New file |
| | |
| | | package com.xinquan.system.domain.dto; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.xinquan.common.core.web.domain.BaseModel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * <p> |
| | | * 会员设置表 |
| | | * </p> |
| | | * |
| | | * @author mitao |
| | | * @since 2024-08-21 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value="VipSettingDTO对象", description="新增修改会员表") |
| | | public class VipSettingDTO extends BaseModel { |
| | | |
| | | @ApiModelProperty(value = "安卓月会员") |
| | | private BigDecimal monthlyVip; |
| | | |
| | | @ApiModelProperty(value = "安卓季会员") |
| | | private BigDecimal quarterlyVip; |
| | | |
| | | @ApiModelProperty(value = "安卓年会员") |
| | | private BigDecimal annualVip; |
| | | |
| | | |
| | | @ApiModelProperty(value = "ios月会员") |
| | | private BigDecimal monthlyVipIos; |
| | | |
| | | @ApiModelProperty(value = "ios季会员") |
| | | private BigDecimal quarterlyVipIos; |
| | | |
| | | @ApiModelProperty(value = "ios年会员") |
| | | private BigDecimal annualVipIos; |
| | | } |
New file |
| | |
| | | package com.xinquan.system.domain.export; |
| | | |
| | | import cn.afterturn.easypoi.excel.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author mitao |
| | | * @date 2024/8/21 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "首页统计返回VO") |
| | | public class HomeExport implements Serializable { |
| | | private static final long serialVersionUID = -3850851853092651572L; |
| | | @Excel(name = "用户总数") |
| | | private String userCount; |
| | | @Excel(name = "非会员数") |
| | | private String noVip; |
| | | @Excel(name = "月卡会员数") |
| | | private String vipMonth; |
| | | @Excel(name = "季卡会员数") |
| | | private String vipQuarter; |
| | | @Excel(name = "年卡会员数") |
| | | private String vipYear; |
| | | @Excel(name = "课程总数") |
| | | private String courseCount; |
| | | @Excel(name = "免费课程数") |
| | | private String courseFree; |
| | | @Excel(name = "会员课程数") |
| | | private String courseVip; |
| | | @Excel(name = "线下课程数") |
| | | private String courseOffOnline; |
| | | @Excel(name = "单独付费课程数") |
| | | private String coursePay; |
| | | @Excel(name = "疗愈音频总数") |
| | | private String meditationCount; |
| | | @Excel(name = "免费音频数") |
| | | private String meditationFree; |
| | | @Excel(name = "会员音频数") |
| | | private String meditationVip; |
| | | @Excel(name = "单独付费音频数") |
| | | private String meditationPay; |
| | | @Excel(name = "提问待回复") |
| | | private String questionRecord; |
| | | @Excel(name = "奖品兑换中") |
| | | private String prizeRecord; |
| | | @Excel(name = "订单总额") |
| | | private String orderMoney; |
| | | @Excel(name = "订单总数") |
| | | private String orderCount; |
| | | |
| | | } |
| | |
| | | |
| | | @ApiModelProperty("菜单id") |
| | | private List<Long> menus; |
| | | private String remark; |
| | | } |
| | |
| | | import java.util.stream.Collectors; |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.xinquan.system.api.domain.SysDept; |
| | | import com.xinquan.system.domain.SysMenu; |
| | | import com.xinquan.system.api.domain.SysMenu; |
| | | |
| | | /** |
| | | * Treeselect树结构实体类 |
| | |
| | | package com.xinquan.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.xinquan.system.domain.Banner; |
| | | import com.xinquan.system.domain.CommissionRule; |
| | | import com.xinquan.system.api.domain.CommissionRule; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | package com.xinquan.system.mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.xinquan.common.core.web.page.PageInfo; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import com.xinquan.system.api.domain.SysDept; |
| | | |
| | |
| | | * @param parentId 父部门ID |
| | | * @return 结果 |
| | | */ |
| | | public SysDept checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") Long parentId); |
| | | public SysDept checkDeptNameUnique(@Param("deptCode") String deptCode); |
| | | public SysDept checkDeptNameUnique1(@Param("deptCode") String deptCode,@Param("deptId") Long deptId); |
| | | |
| | | /** |
| | | * 新增部门信息 |
| | |
| | | * @return 结果 |
| | | */ |
| | | public int deleteDeptById(Long deptId); |
| | | |
| | | List<SysDept> getList(@Param("pageInfo")PageInfo<SysDept> pageInfo, @Param("deptName")String deptName); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.xinquan.system.domain.SysMenus; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import com.xinquan.system.domain.SysMenu; |
| | | import com.xinquan.system.api.domain.SysMenu; |
| | | |
| | | /** |
| | | * 菜单表 数据层 |
| | |
| | | List<SysMenus> getAllOne(); |
| | | |
| | | |
| | | List<SysMenu> selectList(); |
| | | |
| | | List<SysMenu> selectListByRoleId(@Param("roleId")Long roleId); |
| | | } |
| | |
| | | * @param ids 需要删除的数据ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteRoleDept(Long[] ids); |
| | | public int deleteRoleDept(List<Long> ids); |
| | | |
| | | /** |
| | | * 查询部门使用数量 |
| | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.xinquan.common.core.web.page.PageInfo; |
| | | import com.xinquan.system.api.domain.SysRole; |
| | | import com.xinquan.system.domain.dto.SysRoleQuery; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | |
| | | * @return 角色数据集合信息 |
| | | */ |
| | | public List<SysRole> selectRoleList(SysRole role); |
| | | List<SysRole> selectList(@Param("query") SysRoleQuery query, @Param("pageInfo") PageInfo<SysRole> pageInfo); |
| | | |
| | | |
| | | /** |
| | | * 根据用户ID查询角色 |
| | |
| | | * @param roleIds 需要删除的角色ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteRoleByIds(Long[] roleIds); |
| | | public int deleteRoleByIds(List<Long> roleIds); |
| | | |
| | | List<SysRole> isExitUpdate(@Param("roleName") String roleName, @Param("roleId") Long roleId); |
| | | |
| | | |
| | | int selectCountByRoleName(@Param("roleName") String roleName); |
| | | |
| | | List<SysRole> selectRoleByUserId(@Param("userId")Long userId); |
| | | } |
| | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.xinquan.system.api.domain.SysMenu; |
| | | import com.xinquan.system.domain.SysRoleMenu; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * 角色与菜单关联表 数据层 |
| | |
| | | * @param ids 需要删除的数据ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteRoleMenu(Long[] ids); |
| | | public int deleteRoleMenu(List<Long> ids); |
| | | |
| | | /** |
| | | * 批量新增角色菜单信息 |
| | |
| | | * @return 结果 |
| | | */ |
| | | public int batchRoleMenu(List<SysRoleMenu> roleMenuList); |
| | | |
| | | List<SysMenu> getAllInIds(@Param("menusId") List<Long> menusId); |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.xinquan.system.domain.SysUserDept; |
| | | import com.xinquan.system.domain.SysUserPost; |
| | | import com.xinquan.system.domain.SysUserRole; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | |
| | | */ |
| | | public int deleteSysUserRoleByUserIds(Long[] userIds); |
| | | |
| | | int batchUserDept(List<SysUserDept> list); |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.xinquan.common.core.web.page.PageInfo; |
| | | import com.xinquan.system.api.domain.SysDept; |
| | | import com.xinquan.system.api.domain.SysUser; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import com.xinquan.system.api.domain.vo.SysUserVO; |
| | | import com.xinquan.system.domain.dto.SysUserQuery; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | |
| | | * @return 结果 |
| | | */ |
| | | public int updateUser(SysUser user); |
| | | public int updateDept(SysDept user); |
| | | |
| | | /** |
| | | * 修改用户头像 |
| | |
| | | List<Long> getSysUserFromPhone(@Param("phoneNumber") String phoneNumber); |
| | | |
| | | void deleteSysUser(@Param("userIds") ArrayList<Integer> userIds); |
| | | |
| | | List<SysUserVO> pageList(@Param("query")SysUserQuery query, @Param("pageInfo")PageInfo<SysUserVO> pageInfo); |
| | | } |
| | |
| | | * @return 结果 |
| | | */ |
| | | public int deleteUserPostByUserId(Long userId); |
| | | public int deleteUserDeptByUserId(Long userId); |
| | | |
| | | /** |
| | | * 通过岗位ID查询岗位使用数量 |
| | |
| | | package com.xinquan.system.mapper; |
| | | |
| | | import com.xinquan.system.domain.TreeLevelSetting; |
| | | import com.xinquan.system.api.domain.TreeLevelSetting; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | |
| | | package com.xinquan.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.xinquan.system.api.domain.vo.BannerVO; |
| | | import com.xinquan.system.domain.Banner; |
| | | import com.xinquan.system.domain.CommissionRule; |
| | | |
| | | import java.util.List; |
| | | import com.xinquan.system.api.domain.CommissionRule; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | package com.xinquan.system.service; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.xinquan.common.core.web.page.PageInfo; |
| | | import com.xinquan.system.api.domain.SysDept; |
| | | import com.xinquan.system.domain.vo.TreeSelect; |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | public boolean checkDeptNameUnique(SysDept dept); |
| | | public boolean checkDeptNameUnique1(SysDept dept); |
| | | |
| | | /** |
| | | * 校验部门是否有数据权限 |
| | |
| | | * @return 结果 |
| | | */ |
| | | public int deleteDeptById(Long deptId); |
| | | |
| | | List<SysDept> getList(PageInfo<SysDept> pageInfo, String deptName); |
| | | } |
| | |
| | | package com.xinquan.system.service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.xinquan.system.domain.SysMenu; |
| | | import com.xinquan.system.api.domain.SysMenu; |
| | | import com.xinquan.system.domain.SysMenus; |
| | | import com.xinquan.system.domain.vo.RouterVo; |
| | | import com.xinquan.system.domain.vo.TreeSelect; |
| | |
| | | List<SysMenus> getAllMenu(); |
| | | |
| | | |
| | | List<SysMenu> selectList(); |
| | | |
| | | |
| | | List<SysMenu> selectListByRoleId(Long roleId); |
| | | } |
| | |
| | | import java.util.Set; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.xinquan.common.core.web.page.PageInfo; |
| | | import com.xinquan.system.api.domain.SysRole; |
| | | import com.xinquan.system.api.domain.SysMenu; |
| | | import com.xinquan.system.domain.SysUserRole; |
| | | import com.xinquan.system.domain.dto.SysRoleDTO; |
| | | import com.xinquan.system.domain.dto.SysRoleQuery; |
| | | |
| | | /** |
| | | * 角色业务层 |
| | |
| | | * @param roleIds 需要删除的角色ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteRoleByIds(Long[] roleIds); |
| | | public int deleteRoleByIds(List<Long> roleIds); |
| | | |
| | | /** |
| | | * 取消授权用户角色 |
| | |
| | | |
| | | List<SysRole> isExitUpdate(String roleName, Long roleId); |
| | | |
| | | PageInfo<SysRole> selectList(SysRoleQuery query); |
| | | |
| | | Boolean isExit(Long roleId, String roleName); |
| | | int selectCountByRoleName(String roleName); |
| | | |
| | | void saveRole(SysRoleDTO dto); |
| | | |
| | | public int editRole(SysRoleDTO dto); |
| | | |
| | | List<SysMenu> roleInfoFromUserId(Long userId); |
| | | List<SysMenu> getMenuLevelList(List<Long> menusId); |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.xinquan.common.core.web.page.PageInfo; |
| | | import com.xinquan.system.api.domain.SysDept; |
| | | import com.xinquan.system.api.domain.SysUser; |
| | | import com.xinquan.system.api.domain.vo.SysUserVO; |
| | | import com.xinquan.system.domain.dto.SysUserQuery; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | * @return 结果 |
| | | */ |
| | | public int updateUserStatus(SysUser user); |
| | | public int updateDeptStatus(SysDept user); |
| | | |
| | | /** |
| | | * 修改用户基本信息 |
| | |
| | | |
| | | void deleteSysUser(ArrayList<Integer> userIds); |
| | | |
| | | PageInfo<SysUserVO> pageList(SysUserQuery query); |
| | | } |
| | |
| | | package com.xinquan.system.service; |
| | | |
| | | import com.xinquan.system.domain.TreeLevelSetting; |
| | | import com.xinquan.system.api.domain.TreeLevelSetting; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | /** |
| | |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.course.api.domain.CourseCategory; |
| | | import com.xinquan.course.api.domain.CourseDTO; |
| | | import com.xinquan.course.api.feign.RemoteCourseService; |
| | | import com.xinquan.system.api.domain.vo.BannerVO; |
| | | import com.xinquan.system.domain.Banner; |
| | | import com.xinquan.system.mapper.BannerMapper; |
| | |
| | | import java.util.Objects; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class BannerServiceImpl extends ServiceImpl<BannerMapper, Banner> implements BannerService { |
| | | |
| | | @Resource |
| | | private RemoteCourseService remoteCourseService; |
| | | /** |
| | | * 获取轮播图列表 |
| | | * |
| | |
| | | return PageDTO.empty(page); |
| | | } |
| | | for (Banner record : page.getRecords()) { |
| | | |
| | | if (record.getCourseId()!=null){ |
| | | Course data = remoteCourseService.getCourseById(record.getCourseId()).getData(); |
| | | if (data!=null){ |
| | | record.setCourseTitle(data.getCourseTitle()); |
| | | record.setCoverUrl(data.getCoverUrl()); |
| | | record.setTutor(data.getTutor()); |
| | | record.setPrice(data.getGeneralPrice()); |
| | | if (data.getCateId()!=null){ |
| | | CourseCategory data1 = remoteCourseService.getCategoryById(data.getCateId().toString()).getData(); |
| | | record.setCate(data1.getName()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return PageDTO.of(page, Banner.class); |
| | | } |
| | |
| | | package com.xinquan.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xinquan.common.core.utils.page.BeanUtils; |
| | | import com.xinquan.system.api.domain.vo.BannerVO; |
| | | import com.xinquan.system.domain.Banner; |
| | | import com.xinquan.system.domain.CommissionRule; |
| | | import com.xinquan.system.mapper.BannerMapper; |
| | | import com.xinquan.system.api.domain.CommissionRule; |
| | | import com.xinquan.system.mapper.CommissionRuleMapper; |
| | | import com.xinquan.system.service.BannerService; |
| | | import com.xinquan.system.service.CommissionRuleService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.xinquan.common.core.web.page.PageInfo; |
| | | import com.xinquan.system.domain.vo.TreeSelect; |
| | | import com.xinquan.system.mapper.SysDeptMapper; |
| | | import com.xinquan.system.mapper.SysRoleMapper; |
| | |
| | | @DataScope(deptAlias = "d") |
| | | public List<SysDept> selectDeptList(SysDept dept) |
| | | { |
| | | |
| | | return deptMapper.selectDeptList(dept); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public boolean checkDeptNameUnique(SysDept dept) |
| | | { |
| | | Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); |
| | | SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId()); |
| | | if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) |
| | | |
| | | SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptCode()); |
| | | if (StringUtils.isNotNull(info)) |
| | | { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | | } |
| | | @Override |
| | | public boolean checkDeptNameUnique1(SysDept dept) |
| | | { |
| | | |
| | | SysDept info = deptMapper.checkDeptNameUnique1(dept.getDeptCode(),dept.getDeptId()); |
| | | if (StringUtils.isNotNull(info)) |
| | | { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | |
| | | @Override |
| | | public int insertDept(SysDept dept) |
| | | { |
| | | SysDept info = deptMapper.selectDeptById(dept.getParentId()); |
| | | // 如果父节点不为正常状态,则不允许新增子节点 |
| | | if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) |
| | | { |
| | | throw new ServiceException("部门停用,不允许新增"); |
| | | } |
| | | dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); |
| | | return deptMapper.insertDept(dept); |
| | | } |
| | | |
| | |
| | | return deptMapper.deleteDeptById(deptId); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysDept> getList(PageInfo<SysDept> pageInfo, String deptName) { |
| | | List<SysDept> list= deptMapper.getList(pageInfo,deptName); |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 递归列表 |
| | | */ |
| | |
| | | package com.xinquan.system.service.impl; |
| | | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.system.domain.SysMenu; |
| | | import com.xinquan.system.api.domain.SysMenu; |
| | | import com.xinquan.system.domain.SysMenus; |
| | | import com.xinquan.system.domain.SysRoleMenu; |
| | | import com.xinquan.system.domain.SysUserRole; |
| | | import com.xinquan.system.domain.vo.MetaVo; |
| | | import com.xinquan.system.domain.vo.RouterVo; |
| | | import com.xinquan.system.domain.vo.TreeSelect; |
| | |
| | | import com.xinquan.common.core.utils.StringUtils; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.system.api.domain.SysRole; |
| | | import com.xinquan.system.api.domain.SysUser; |
| | | |
| | | /** |
| | | * 菜单 业务层处理 |
| | |
| | | } |
| | | return UserConstants.UNIQUE; |
| | | } |
| | | @Override |
| | | public List<SysMenu> selectListByRoleId(Long roleId) { |
| | | return menuMapper.selectListByRoleId(roleId); |
| | | } |
| | | public static void main(String[] args) throws ParseException { |
| | | Date date = new Date(); |
| | | String s = "2024-10-09 12:59:25"; |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | Date parse = simpleDateFormat.parse(s); |
| | | System.err.println(parse.getTime()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<SysMenu> selectList() { |
| | | return menuMapper.selectList(); |
| | | } |
| | | @Override |
| | | public List<SysMenus> getAllMenu() { |
| | | Long roleId = tokenService.getLoginUser().getSysUser().getRoles().get(0).getRoleId(); |
| | |
| | | package com.xinquan.system.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xinquan.common.core.web.page.PageInfo; |
| | | import com.xinquan.system.api.domain.SysMenu; |
| | | import com.xinquan.system.domain.SysRoleDept; |
| | | import com.xinquan.system.domain.SysRoleMenu; |
| | | import com.xinquan.system.domain.SysUserRole; |
| | | import com.xinquan.system.mapper.SysRoleDeptMapper; |
| | | import com.xinquan.system.mapper.SysRoleMapper; |
| | | import com.xinquan.system.mapper.SysRoleMenuMapper; |
| | | import com.xinquan.system.mapper.SysUserRoleMapper; |
| | | import com.xinquan.system.domain.dto.SysRoleDTO; |
| | | import com.xinquan.system.domain.dto.SysRoleQuery; |
| | | import com.xinquan.system.mapper.*; |
| | | import com.xinquan.system.service.ISysRoleService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | @Autowired |
| | | private SysRoleDeptMapper roleDeptMapper; |
| | | @Autowired |
| | | private SysMenuMapper menuMapper; |
| | | |
| | | /** |
| | | * 根据条件分页查询角色数据 |
| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int deleteRoleByIds(Long[] roleIds) |
| | | public int deleteRoleByIds(List<Long> roleIds) |
| | | { |
| | | for (Long roleId : roleIds) |
| | | { |
| | |
| | | public List<SysRole> isExitUpdate(String roleName, Long roleId) { |
| | | return roleMapper.isExitUpdate(roleName,roleId); |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<SysRole> selectList(SysRoleQuery query) { |
| | | PageInfo<SysRole> pageInfo = new PageInfo<>(query.getPageCurr(), query.getPageSize()); |
| | | List<SysRole> list = roleMapper.selectList(query,pageInfo); |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | @Override |
| | | public Boolean isExit(Long id, String roleName) { |
| | | int count = this.selectCountByRoleName(roleName); |
| | | if (StringUtils.isNotNull(id)) { |
| | | // 修改 |
| | | SysRole sysRole = roleMapper.selectRoleById(id); |
| | | return Objects.nonNull(sysRole) && !sysRole.getRoleName().equals(roleName) && count > 0; |
| | | } else { |
| | | // 新增 |
| | | return count > 0; |
| | | } |
| | | } |
| | | @Override |
| | | public List<SysMenu> getMenuLevelList(List<Long> menusId) { |
| | | //获取当前的权限菜单 |
| | | List<SysMenu> all = roleMenuMapper.getAllInIds(menusId); |
| | | // 第三级 |
| | | List<SysMenu> s3 = all.stream().filter(e -> e.getMenuType().equals("F")).collect(Collectors.toList()); |
| | | // 第二级 |
| | | List<SysMenu> s2 = all.stream().filter(e -> e.getMenuType().equals("C")).collect(Collectors.toList()); |
| | | // 第一级 |
| | | List<SysMenu> s1 = all.stream().filter(e -> e.getMenuType().equals("M")).collect(Collectors.toList()); |
| | | |
| | | for (SysMenu menu : s2) { |
| | | List<SysMenu> collect = s3.stream().filter(e -> e.getParentId().equals(menu.getMenuId())).collect(Collectors.toList()); |
| | | menu.setChildren(collect); |
| | | } |
| | | for (SysMenu menu : s1) { |
| | | List<SysMenu> collect = s2.stream().filter(e -> e.getParentId().equals(menu.getMenuId())).collect(Collectors.toList()); |
| | | menu.setChildren(collect); |
| | | } |
| | | return s1; |
| | | } |
| | | @Override |
| | | public List<SysMenu> roleInfoFromUserId(Long userId) { |
| | | List<SysRole> sysRole = roleMapper.selectRoleByUserId(userId); |
| | | List<SysMenu> menus2 = new ArrayList<>(); |
| | | for (SysRole role : sysRole) { |
| | | List<SysMenu> menus1 = menuMapper.selectListByRoleId(role.getRoleId()); |
| | | menus2.addAll(menus1); |
| | | } |
| | | List<SysMenu> menus = menus2.stream().distinct().collect(Collectors.toList()); |
| | | // 获取当前角色的菜单列表 |
| | | if(menus.size()==0){ |
| | | return new ArrayList<>(); |
| | | } |
| | | List<Long> menusId = menus.stream().map(SysMenu::getMenuId).collect(Collectors.toList()); |
| | | // 获取当前的权限菜单(有层级) |
| | | return this.getMenuLevelList(menusId); |
| | | } |
| | | @Override |
| | | public int selectCountByRoleName(String roleName) { |
| | | return roleMapper.selectCountByRoleName(roleName); |
| | | } |
| | | @Override |
| | | public int editRole(SysRoleDTO dto) { |
| | | // 修改角色信息 |
| | | SysRole sysRole = new SysRole(); |
| | | sysRole.setRoleId(dto.getRoleId()); |
| | | sysRole.setRoleName(dto.getRoleName()); |
| | | sysRole.setRemark(dto.getRemark()); |
| | | roleMapper.updateRole(sysRole); |
| | | // 删除角色与菜单关联 |
| | | roleMenuMapper.deleteRoleMenuByRoleId(dto.getRoleId()); |
| | | |
| | | // 添加角色权限中间表 |
| | | List<Long> menuIds = dto.getMenuIds(); |
| | | List<SysRoleMenu> sysRoleMenus = new ArrayList<>(); |
| | | for (Long menuId : menuIds) { |
| | | SysRoleMenu sysRoleMenu = new SysRoleMenu(); |
| | | sysRoleMenu.setRoleId(dto.getRoleId()); |
| | | sysRoleMenu.setMenuId(menuId); |
| | | sysRoleMenus.add(sysRoleMenu); |
| | | } |
| | | |
| | | return roleMenuMapper.batchRoleMenu(sysRoleMenus); |
| | | } |
| | | @Override |
| | | public void saveRole(SysRoleDTO dto) { |
| | | // 添加角色 |
| | | SysRole sysRole = new SysRole(); |
| | | sysRole.setRoleName(dto.getRoleName()); |
| | | sysRole.setRemark(dto.getRemark()); |
| | | roleMapper.insertRole(sysRole); |
| | | |
| | | // 添加角色权限中间表 |
| | | List<Long> menuIds = dto.getMenuIds(); |
| | | List<SysRoleMenu> sysRoleMenus = new ArrayList<>(); |
| | | for (Long menuId : menuIds) { |
| | | SysRoleMenu sysRoleMenu = new SysRoleMenu(); |
| | | sysRoleMenu.setRoleId(sysRole.getRoleId()); |
| | | sysRoleMenu.setMenuId(menuId); |
| | | sysRoleMenus.add(sysRoleMenu); |
| | | } |
| | | roleMenuMapper.batchRoleMenu(sysRoleMenus); |
| | | } |
| | | } |
| | |
| | | import com.xinquan.common.core.web.page.PageInfo; |
| | | import com.xinquan.common.datascope.annotation.DataScope; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.system.api.domain.SysDept; |
| | | import com.xinquan.system.api.domain.SysRole; |
| | | import com.xinquan.system.api.domain.SysUser; |
| | | import com.xinquan.system.api.domain.vo.SysUserVO; |
| | | import com.xinquan.system.domain.SysPost; |
| | | import com.xinquan.system.domain.SysUserDept; |
| | | import com.xinquan.system.domain.SysUserPost; |
| | | import com.xinquan.system.domain.SysUserRole; |
| | | import com.xinquan.system.mapper.SysPostMapper; |
| | | import com.xinquan.system.mapper.SysRoleMapper; |
| | | import com.xinquan.system.mapper.SysUserMapper; |
| | | import com.xinquan.system.mapper.SysUserPostMapper; |
| | | import com.xinquan.system.mapper.SysUserRoleMapper; |
| | | import com.xinquan.system.domain.dto.SysUserQuery; |
| | | import com.xinquan.system.mapper.*; |
| | | import com.xinquan.system.service.ISysConfigService; |
| | | import com.xinquan.system.service.ISysUserService; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Validator; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | |
| | | @Autowired |
| | | private SysUserPostMapper userPostMapper; |
| | | @Autowired |
| | | private SysUserDeptMapper sysUserDeptMapper; |
| | | |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | |
| | | { |
| | | // 新增用户信息 |
| | | int rows = userMapper.insertUser(user); |
| | | // // 新增用户岗位关联 |
| | | // insertUserPost(user); |
| | | // // 新增用户与角色管理 |
| | | // insertUserRole(user); |
| | | // 新增用户岗位关联 |
| | | insertUserDept(user); |
| | | // 新增用户与角色管理 |
| | | insertUserRole(user); |
| | | return rows; |
| | | } |
| | | |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int updateUser(SysUser user) |
| | | { |
| | | // Long userId = user.getUserId(); |
| | | Long userId = user.getUserId(); |
| | | // // 删除用户与角色关联 |
| | | // userRoleMapper.deleteUserRoleByUserId(userId); |
| | | userRoleMapper.deleteUserRoleByUserId(userId); |
| | | // // 新增用户与角色管理 |
| | | // insertUserRole(user); |
| | | insertUserRole(user); |
| | | // // 删除用户与岗位关联 |
| | | // userPostMapper.deleteUserPostByUserId(userId); |
| | | userPostMapper.deleteUserDeptByUserId(userId); |
| | | // // 新增用户与岗位管理 |
| | | // insertUserPost(user); |
| | | insertUserDept(user); |
| | | return userMapper.updateUser(user); |
| | | } |
| | | |
| | |
| | | insertUserRole(userId, roleIds); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改用户状态 |
| | | * |
| | |
| | | public int updateUserStatus(SysUser user) |
| | | { |
| | | return userMapper.updateUser(user); |
| | | } |
| | | @Override |
| | | public int updateDeptStatus(SysDept user) |
| | | { |
| | | return userMapper.updateDept(user); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @param user 用户对象 |
| | | */ |
| | | public void insertUserPost(SysUser user) |
| | | |
| | | public void insertUserDept(SysUser user) |
| | | { |
| | | Long[] posts = user.getPostIds(); |
| | | List<Long> posts = user.getDeptIds(); |
| | | if (StringUtils.isNotEmpty(posts)) |
| | | { |
| | | // 新增用户与岗位管理 |
| | | List<SysUserPost> list = new ArrayList<SysUserPost>(); |
| | | List<SysUserDept> list = new ArrayList<SysUserDept>(); |
| | | for (Long postId : posts) |
| | | { |
| | | SysUserPost up = new SysUserPost(); |
| | | SysUserDept up = new SysUserDept(); |
| | | up.setUserId(user.getUserId()); |
| | | up.setPostId(postId); |
| | | up.setDeptId(postId); |
| | | list.add(up); |
| | | } |
| | | userPostMapper.batchUserPost(list); |
| | | sysUserDeptMapper.batchUserDept(list); |
| | | } |
| | | } |
| | | |
| | |
| | | public List<Long> getSysUserFromPhone(String phoneNumber) { |
| | | return this.baseMapper.getSysUserFromPhone(phoneNumber); |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<SysUserVO> pageList(SysUserQuery query) { |
| | | PageInfo<SysUserVO> pageInfo = new PageInfo<>(query.getPageCurr(), query.getPageSize()); |
| | | List<SysUserVO> list = userMapper.pageList(query,pageInfo); |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | @Override |
| | | public void deleteSysUser(ArrayList<Integer> userIds) { |
| | | this.baseMapper.deleteSysUser(userIds); |
| | |
| | | package com.xinquan.system.service.impl; |
| | | |
| | | import com.xinquan.system.domain.TreeLevelSetting; |
| | | import com.xinquan.system.api.domain.TreeLevelSetting; |
| | | import com.xinquan.system.mapper.TreeLevelSettingMapper; |
| | | import com.xinquan.system.service.TreeLevelSettingService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | |
| | | public class ObsUploadUtil { |
| | | |
| | | public static String endPoint = "obs.cn-north-4.myhuaweicloud.com"; |
| | | public static String accessKeyId = "X3V6GPYUK1VQ03K0JG4G"; |
| | | public static String accessKeySecret = "CustHR4B9XKdT7hGcEYEpV9UVUoc4pmUhnHckU9h"; |
| | | public static String bucketName = "jkjianshen"; |
| | | public static String oss_domain = "https://jkjianshen.obs.cn-north-4.myhuaweicloud.com/"; |
| | | // public static String oss_domain = "http://cdn.jkcyl.cn/"; |
| | | public static String endPoint = "obs.cn-south-1.myhuaweicloud.com"; |
| | | public static String accessKeyId = "HNZKSJL5LKM2NZVJPE8O"; |
| | | public static String accessKeySecret = "VjKImAoCB8Q2lEcwGO9xIemirpOVZuij9DVRSXcr"; |
| | | public static String bucketName = "xqgwzh"; |
| | | public static String oss_domain = "https://xqgwzh.obs.cn-south-1.myhuaweicloud.com/"; |
| | | // 创建ObsClient实例 |
| | | public static ObsClient obsClient = new ObsClient(accessKeyId, accessKeySecret, endPoint); |
| | | |
| | |
| | | </resultMap> |
| | | |
| | | <sql id="selectDeptVo"> |
| | | select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time |
| | | from sys_dept d |
| | | select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time |
| | | , d.dept_code,d.remark |
| | | from sys_dept d |
| | | </sql> |
| | | |
| | | <select id="selectDeptList" parameterType="com.xinquan.system.api.domain.SysDept" resultMap="SysDeptResult"> |
| | |
| | | |
| | | <select id="checkDeptNameUnique" resultMap="SysDeptResult"> |
| | | <include refid="selectDeptVo"/> |
| | | where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1 |
| | | where dept_code=#{deptCode} and del_flag = '0' limit 1 |
| | | </select> |
| | | |
| | | <insert id="insertDept" parameterType="com.xinquan.system.api.domain.SysDept"> |
| | | <select id="checkDeptNameUnique1" resultMap="SysDeptResult"> |
| | | <include refid="selectDeptVo"/> |
| | | where dept_code=#{deptCode} and dept_id!=#{deptId} and del_flag = '0' limit 1 |
| | | </select> |
| | | <select id="getList" resultType="com.xinquan.system.api.domain.SysDept"> |
| | | select d.dept_id as deptId, d.parent_id as parentId, |
| | | d.ancestors, d.dept_name as deptName, |
| | | d.order_num, d.leader, |
| | | d.phone, d.email, d.status, |
| | | d.del_flag, d.create_by, d.create_time AS createTime,d.remark, |
| | | d.update_by as updateBy, |
| | | d.handleName as handleName, |
| | | d.reason, |
| | | d.dept_code as deptCode |
| | | from |
| | | sys_dept d |
| | | where 1 = 1 |
| | | <if test="null != deptName and deptName!=''"> |
| | | and (d.dept_code LIKE CONCAT('%',#{deptName},'%') or d.dept_id LIKE CONCAT('%',#{deptName},'%')) |
| | | </if> |
| | | and d.del_flag = '0' |
| | | |
| | | </select> |
| | | |
| | | <insert id="insertDept" parameterType="com.xinquan.system.api.domain.SysDept"> |
| | | insert into sys_dept( |
| | | <if test="deptId != null and deptId != 0">dept_id,</if> |
| | | <if test="parentId != null and parentId != 0">parent_id,</if> |
| | |
| | | <if test="email != null and email != ''">email,</if> |
| | | <if test="status != null">status,</if> |
| | | <if test="createBy != null and createBy != ''">create_by,</if> |
| | | <if test="remark != null and remark != ''">remark,</if> |
| | | <if test="deptCode != null and deptCode != ''">dept_code,</if> |
| | | create_time |
| | | )values( |
| | | <if test="deptId != null and deptId != 0">#{deptId},</if> |
| | |
| | | <if test="email != null and email != ''">#{email},</if> |
| | | <if test="status != null">#{status},</if> |
| | | <if test="createBy != null and createBy != ''">#{createBy},</if> |
| | | sysdate() |
| | | <if test="remark != null and remark != ''">#{remark},</if> |
| | | <if test="deptCode != null and deptCode != ''">#{deptCode},</if> |
| | | |
| | | sysdate() |
| | | ) |
| | | </insert> |
| | | |
| | |
| | | <if test="email != null">email = #{email},</if> |
| | | <if test="status != null and status != ''">status = #{status},</if> |
| | | <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> |
| | | <if test="updateBy != null and updateBy != ''">remark = #{remark},</if> |
| | | <if test="deptCode != null and deptCode != ''">dept_code = #{deptCode},</if> |
| | | <if test="handleName != null and handleName != ''">handleName = #{handleName},</if> |
| | | update_time = sysdate() |
| | | </set> |
| | | where dept_id = #{deptId} |
| | |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.xinquan.system.mapper.SysMenuMapper"> |
| | | |
| | | <resultMap type="com.xinquan.system.domain.SysMenu" id="SysMenuResult"> |
| | | <resultMap type="com.xinquan.system.api.domain.SysMenu" id="SysMenuResult"> |
| | | <id property="menuId" column="menu_id" /> |
| | | <result property="menuName" column="menu_name" /> |
| | | <result property="parentName" column="parent_name" /> |
| | |
| | | from sys_menu |
| | | </sql> |
| | | |
| | | <select id="selectMenuList" parameterType="com.xinquan.system.domain.SysMenu" resultMap="SysMenuResult"> |
| | | <select id="selectMenuList" parameterType="com.xinquan.system.api.domain.SysMenu" resultMap="SysMenuResult"> |
| | | <include refid="selectMenuVo"/> |
| | | <where> |
| | | <if test="menuName != null and menuName != ''"> |
| | |
| | | order by m.parent_id, m.order_num |
| | | </select> |
| | | |
| | | <select id="selectMenuListByUserId" parameterType="com.xinquan.system.domain.SysMenu" resultMap="SysMenuResult"> |
| | | <select id="selectMenuListByUserId" parameterType="com.xinquan.system.api.domain.SysMenu" resultMap="SysMenuResult"> |
| | | select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time |
| | | from sys_menu m |
| | | left join sys_role_menu rm on m.menu_id = rm.menu_id |
| | |
| | | select count(1) from sys_menu where parent_id = #{menuId} |
| | | </select> |
| | | |
| | | <select id="checkMenuNameUnique" parameterType="com.xinquan.system.domain.SysMenu" resultMap="SysMenuResult"> |
| | | <select id="checkMenuNameUnique" parameterType="com.xinquan.system.api.domain.SysMenu" resultMap="SysMenuResult"> |
| | | <include refid="selectMenuVo"/> |
| | | where menu_name=#{menuName} and parent_id = #{parentId} limit 1 |
| | | </select> |
| | |
| | | #{id} |
| | | </foreach> |
| | | </select> |
| | | <select id="selectListByRoleId" resultType="com.xinquan.system.api.domain.SysMenu"> |
| | | select sm.menu_id AS menuId, sm.menu_name AS menuName, sm.parent_id AS parentId, sm.order_num AS orderNum, sm.`path` AS path, sm.component AS component, |
| | | sm.`query` AS query, sm.is_frame AS isFrame,sm.is_cache AS isCache, sm.menu_type AS menuType, sm.visible AS visible, sm.status AS status, |
| | | ifnull(sm.perms,'') as perms, sm.icon AS icon, sm.create_time AS createTime |
| | | from sys_role_menu srm |
| | | left join sys_menu sm on srm.menu_id = sm.menu_id |
| | | WHERE srm.role_id = #{roleId} |
| | | </select> |
| | | <select id="selectList" resultType="com.xinquan.system.api.domain.SysMenu"> |
| | | select |
| | | menu_id AS menuId, |
| | | menu_name AS menuName, |
| | | parent_id AS parentId, |
| | | order_num AS orderNum, |
| | | `path` AS path, |
| | | component AS component, |
| | | `query` AS query, |
| | | is_frame AS isFrame, |
| | | is_cache AS isCache, |
| | | menu_type AS menuType, |
| | | visible AS visible, |
| | | STATUS AS STATUS, |
| | | IFNULL( perms, '' ) AS perms, |
| | | icon AS icon, |
| | | create_time AS createTime |
| | | from sys_menu |
| | | </select> |
| | | <select id="getAllOne" resultType="com.xinquan.system.domain.SysMenus"> |
| | | select menu_id menuId, |
| | | menu_name menuName, |
| | |
| | | order by create_time desc |
| | | </select> |
| | | |
| | | <update id="updateMenu" parameterType="com.xinquan.system.domain.SysMenu"> |
| | | <update id="updateMenu" parameterType="com.xinquan.system.api.domain.SysMenu"> |
| | | update sys_menu |
| | | <set> |
| | | <if test="menuName != null and menuName != ''">menu_name = #{menuName},</if> |
| | |
| | | where menu_id = #{menuId} |
| | | </update> |
| | | |
| | | <insert id="insertMenu" parameterType="com.xinquan.system.domain.SysMenu"> |
| | | <insert id="insertMenu" parameterType="com.xinquan.system.api.domain.SysMenu"> |
| | | insert into sys_menu( |
| | | <if test="menuId != null and menuId != 0">menu_id,</if> |
| | | <if test="parentId != null and parentId != 0">parent_id,</if> |
| | |
| | | left join sys_user u on u.user_id = ur.user_id |
| | | left join sys_dept d on u.dept_id = d.dept_id |
| | | </sql> |
| | | |
| | | <select id="selectList" resultType="com.xinquan.system.api.domain.SysRole"> |
| | | select role_id AS roleId, role_name AS roleName, role_key AS roleKey, role_sort AS roleSort, data_scope AS dataScope, |
| | | menu_check_strictly AS menuCheckStrictly, dept_check_strictly AS deptCheckStrictly,status AS status, del_flag AS delFlag, |
| | | create_time AS createTime,create_by AS createBy,remark AS remark |
| | | from sys_role |
| | | <where> |
| | | <if test="query.roleName != null and query.roleName != ''"> |
| | | AND role_name LIKE concat('%',#{query.roleName},'%') |
| | | </if> |
| | | <if test="query.status != null"> |
| | | AND status = #{query.status} |
| | | </if> |
| | | AND del_flag = 0 |
| | | </where> |
| | | </select> |
| | | <select id="selectRoleList" parameterType="com.xinquan.system.api.domain.SysRole" resultMap="SysRoleResult"> |
| | | <include refid="selectRoleVo"/> |
| | | where r.del_flag = '0' |
| | |
| | | select role_name romeName from sys_role where role_name=#{roleName} and companyId =#{companyId} and role_id != #{roleId} |
| | | </select> |
| | | |
| | | <insert id="insertRole" parameterType="com.xinquan.system.api.domain.SysRole" useGeneratedKeys="true" keyProperty="roleId"> |
| | | <select id="selectCountByRoleName" resultType="java.lang.Integer"> |
| | | select count(*) from sys_role |
| | | <where> |
| | | <if test="roleName != null and roleName != ''"> |
| | | AND role_name = #{roleName} |
| | | </if> |
| | | AND del_flag = 0 |
| | | </where> |
| | | </select> |
| | | <select id="selectRoleByUserId" resultType="com.xinquan.system.api.domain.SysRole"> |
| | | select distinct r.role_id AS roleId, r.role_name AS roleName, r.role_key AS roleKey, r.role_sort AS roleSort, r.data_scope AS dataScope, |
| | | r.menu_check_strictly AS menuCheckStrictly, r.dept_check_strictly AS deptCheckStrictly,r.status AS status, |
| | | r.del_flag AS delFlag, r.create_time AS createTime,r.create_by AS createBy |
| | | from sys_role r |
| | | left join sys_user_role ur on ur.role_id = r.role_id |
| | | where ur.user_id = #{userId} |
| | | </select> |
| | | <insert id="insertRole" parameterType="com.xinquan.system.api.domain.SysRole" useGeneratedKeys="true" keyProperty="roleId"> |
| | | insert into sys_role( |
| | | <if test="roleId != null and roleId != 0">role_id,</if> |
| | | <if test="roleName != null and roleName != ''">role_name,</if> |
| | |
| | | <delete id="deleteRoleById" parameterType="Long"> |
| | | update sys_role set del_flag = '2' where role_id = #{roleId} |
| | | </delete> |
| | | |
| | | <delete id="deleteRoleByIds" parameterType="Long"> |
| | | update sys_role set del_flag = '2' where role_id in |
| | | <foreach collection="array" item="roleId" open="(" separator="," close=")"> |
| | | #{roleId} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <delete id="deleteRoleByIds" parameterType="Long"> |
| | | update sys_role set del_flag = '2' where role_id in |
| | | <foreach collection="roleIds" item="roleId" open="(" separator="," close=")"> |
| | | #{roleId} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | </mapper> |
| | |
| | | <delete id="deleteRoleMenuByRoleId" parameterType="Long"> |
| | | delete from sys_role_menu where role_id=#{roleId} |
| | | </delete> |
| | | |
| | | |
| | | <delete id="deleteRoleMenu" parameterType="Long"> |
| | | delete from sys_role_menu where role_id in |
| | | <foreach collection="array" item="roleId" open="(" separator="," close=")"> |
| | | #{roleId} |
| | | </foreach> |
| | | </delete> |
| | | delete from sys_role_menu where role_id in |
| | | <foreach collection="ids" item="roleId" open="(" separator="," close=")"> |
| | | #{roleId} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <insert id="batchRoleMenu"> |
| | | insert into sys_role_menu(role_id, menu_id) values |
| | |
| | | (#{item.roleId},#{item.menuId}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | <select id="getAllInIds" resultType="com.xinquan.system.api.domain.SysMenu"> |
| | | select |
| | | menu_id AS menuId, |
| | | menu_name AS menuName, |
| | | parent_id AS parentId, |
| | | order_num AS orderNum, |
| | | `path` AS path, |
| | | component AS component, |
| | | `query` AS query, |
| | | is_frame AS isFrame, |
| | | is_cache AS isCache, |
| | | menu_type AS menuType, |
| | | visible AS visible, |
| | | STATUS AS STATUS, |
| | | IFNULL( perms, '' ) AS perms, |
| | | icon AS icon, |
| | | create_time AS createTime |
| | | from sys_menu where menu_id in |
| | | <foreach collection="menusId" close=")" index="index" item="id" open="(" separator=","> |
| | | #{id} |
| | | </foreach> |
| | | </select> |
| | | </mapper> |
| | |
| | | #{userId} |
| | | </foreach> |
| | | </delete> |
| | | <insert id="batchUserDept"> |
| | | insert into sys_user_dept(user_id, dept_id) values |
| | | <foreach item="item" index="index" collection="list" separator=","> |
| | | (#{item.userId},#{item.deptId}) |
| | | </foreach> |
| | | </insert> |
| | | </mapper> |
| | |
| | | <if test="status != null and status != ''">status,</if> |
| | | <if test="createBy != null and createBy != ''">create_by,</if> |
| | | <if test="remark != null and remark != ''">remark,</if> |
| | | <if test="userType != null and userType != ''">user_type,</if> |
| | | <if test="userType != null and userType != ''">user_type,</if> |
| | | create_time |
| | | )values( |
| | | <if test="userId != null and userId != ''">#{userId},</if> |
| | |
| | | <if test="status != null and status != ''">#{status},</if> |
| | | <if test="createBy != null and createBy != ''">#{createBy},</if> |
| | | <if test="remark != null and remark != ''">#{remark},</if> |
| | | <if test="userType != null and userType != ''">#{user_type},</if> |
| | | <if test="userType != null and userType != ''">#{userType},</if> |
| | | sysdate() |
| | | ) |
| | | </insert> |
| | |
| | | <if test="loginDate != null">login_date = #{loginDate},</if> |
| | | <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> |
| | | <if test="remark != null">remark = #{remark},</if> |
| | | update_time = sysdate() |
| | | <if test="userType != null and userType != ''">user_type = #{userType},</if> |
| | | <if test="reason != null and reason != ''">reason = #{reason},</if> |
| | | <if test="handleName != null and handleName != ''">handleName = #{handleName},</if> |
| | | |
| | | update_time = sysdate() |
| | | </set> |
| | | where user_id = #{userId} |
| | | </update> |
| | | <update id="updateDept" parameterType="com.xinquan.system.api.domain.SysDept"> |
| | | update sys_dept |
| | | <set> |
| | | <if test="status != null and status != ''">status = #{status},</if> |
| | | <if test="reason != null">reason = #{reason},</if> |
| | | <if test="handleName != null">handleName = #{handleName},</if> |
| | | update_time = sysdate() |
| | | </set> |
| | | where dept_id = #{deptId} |
| | | </update> |
| | | |
| | | <update id="updateUserStatus" parameterType="com.xinquan.system.api.domain.SysUser"> |
| | |
| | | #{id} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <select id="pageList" resultType="com.xinquan.system.api.domain.vo.SysUserVO"> |
| | | select u.user_id AS userId, u.dept_id AS deptId, u.user_name AS userName, u.nick_name AS nickName, u.email AS email, u.avatar AS avatar, |
| | | u.phonenumber AS phonenumber, u.sex AS sex, u.status AS status, u.del_flag AS delFlag, u.login_ip AS loginIp, |
| | | u.login_date AS loginDate, u.create_by AS createBy, u.create_time AS createTime, u.remark AS remark,u.disableRemark AS disableRemark, |
| | | r.role_id AS roleId, r.role_name AS roleName, r.role_key AS roleKey, r.role_sort AS roleSort, r.data_scope AS dataScope, r.status as role_status, |
| | | u.reason AS reason |
| | | from sys_user u |
| | | left join sys_user_role ur on u.user_id = ur.user_id |
| | | left join sys_role r on ur.role_id = r.role_id |
| | | left join sys_user_dept ud on u.user_id = ud.user_id |
| | | left join sys_dept d on ud.dept_id = d.dept_id |
| | | WHERE u.del_flag = 0 |
| | | <if test="query.nickNameOrPhone != null and query.nickNameOrPhone != ''"> |
| | | AND (u.nick_name LIKE concat('%',#{query.nickNameOrPhone},'%') |
| | | OR u.phonenumber LIKE concat('%',#{query.nickNameOrPhone},'%')) |
| | | </if> |
| | | <if test="query.roleIds != null and query.roleIds.size()>0"> |
| | | AND r.role_id in |
| | | <foreach collection="query.roleIds" separator="," item="id" open="(" close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </if> |
| | | <if test="query.deptIds != null and query.deptIds.size()>0"> |
| | | AND d.dept_id in |
| | | <foreach collection="query.deptIds" separator="," item="id" open="(" close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </if> |
| | | <if test="query.status != null and query.status != ''"> |
| | | AND u.status = #{query.status} |
| | | </if> |
| | | and u.user_type=00 |
| | | group by u.user_id |
| | | ORDER BY u.create_time DESC |
| | | </select> |
| | | </mapper> |
| | |
| | | <delete id="deleteUserPostByUserId" parameterType="Long"> |
| | | delete from sys_user_post where user_id=#{userId} |
| | | </delete> |
| | | <delete id="deleteUserDeptByUserId" parameterType="Long"> |
| | | delete from sys_user_dept where user_id=#{userId} |
| | | </delete> |
| | | |
| | | <select id="countUserPostById" resultType="Integer"> |
| | | select count(1) from sys_user_post where post_id=#{postId} |
| | |
| | | <mapper namespace="com.xinquan.system.mapper.TreeLevelSettingMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.xinquan.system.domain.TreeLevelSetting"> |
| | | <resultMap id="BaseResultMap" type="com.xinquan.system.api.domain.TreeLevelSetting"> |
| | | <id column="id" property="id" /> |
| | | <result column="del_flag" property="delFlag" /> |
| | | <result column="create_by" property="createBy" /> |
| | |
| | | </properties> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>cn.afterturn</groupId> |
| | | <artifactId>easypoi-spring-boot-starter</artifactId> |
| | | <version>4.0.0</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <artifactId>guava</artifactId> |
| | | <groupId>com.google.guava</groupId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <!--网易邮件--> |
| | | <dependency> |
| | | <groupId>javax.mail</groupId> |
| | |
| | | public class XinQuanUserApplication { |
| | | |
| | | public static void main(String[] args) throws UnknownHostException { |
| | | SpringApplication app = new SpringApplicationBuilder(XinQuanUserApplication.class).build(args); |
| | | Environment env = app.run(args).getEnvironment(); |
| | | String protocol = "http"; |
| | | if (env.getProperty("server.ssl.key-store") != null) { |
| | | protocol = "https"; |
| | | try{ |
| | | SpringApplication app = new SpringApplicationBuilder(XinQuanUserApplication.class).build(args); |
| | | Environment env = app.run(args).getEnvironment(); |
| | | String protocol = "http"; |
| | | if (env.getProperty("server.ssl.key-store") != null) { |
| | | protocol = "https"; |
| | | } |
| | | log.info("--/\n---------------------------------------------------------------------------------------\n\t" + |
| | | "Application '{}' is running! Access URLs:\n\t" + |
| | | "Local: \t\t{}://localhost:{}\n\t" + |
| | | "External: \t{}://{}:{}\n\t" + |
| | | "Profile(s): \t{}" + |
| | | "\n---------------------------------------------------------------------------------------", |
| | | env.getProperty("spring.application.name"), |
| | | protocol, |
| | | env.getProperty("server.port"), |
| | | protocol, |
| | | InetAddress.getLocalHost().getHostAddress(), |
| | | env.getProperty("server.port"), |
| | | env.getActiveProfiles()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | System.err.println(e); |
| | | } |
| | | log.info("--/\n---------------------------------------------------------------------------------------\n\t" + |
| | | "Application '{}' is running! Access URLs:\n\t" + |
| | | "Local: \t\t{}://localhost:{}\n\t" + |
| | | "External: \t{}://{}:{}\n\t" + |
| | | "Profile(s): \t{}" + |
| | | "\n---------------------------------------------------------------------------------------", |
| | | env.getProperty("spring.application.name"), |
| | | protocol, |
| | | env.getProperty("server.port"), |
| | | protocol, |
| | | InetAddress.getLocalHost().getHostAddress(), |
| | | env.getProperty("server.port"), |
| | | env.getActiveProfiles()); |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | package com.xinquan.user.controller.client; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.WebUtils; |
| | | import com.xinquan.common.core.utils.page.BeanUtils; |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.core.web.domain.BaseModel; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.course.api.domain.CourseCategory; |
| | |
| | | import com.xinquan.system.api.RemoteUserService; |
| | | import com.xinquan.system.api.domain.*; |
| | | import com.xinquan.system.api.domain.vo.*; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.user.api.domain.dto.AppUserManagementDTO; |
| | | import com.xinquan.user.api.domain.dto.OrderListDTO; |
| | | import com.xinquan.user.api.domain.dto.UserChildDTO; |
| | | import com.xinquan.user.api.domain.vo.FreezingVO; |
| | | import com.xinquan.user.api.domain.vo.ViewReport; |
| | | import com.xinquan.user.domain.dto.UserAnswerDTO; |
| | | import com.xinquan.user.domain.dto.UserFreezingDTO; |
| | | import com.xinquan.user.domain.export.UserExport; |
| | | import com.xinquan.user.domain.export.UserInfoExport; |
| | | import com.xinquan.user.domain.export.WithdrawExport; |
| | | import com.xinquan.user.domain.vo.TagVO; |
| | | import com.xinquan.user.service.*; |
| | | import com.xinquan.user.utils.MailUtils; |
| | |
| | | import java.io.*; |
| | | import java.math.BigDecimal; |
| | | import java.net.URL; |
| | | import java.net.URLEncoder; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.Month; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.compress.utils.IOUtils; |
| | | import org.apache.poi.ss.formula.functions.T; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | import javax.mail.*; |
| | | import javax.mail.internet.*; |
| | | import javax.mail.util.ByteArrayDataSource; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import static com.xinquan.common.core.enums.TreeLevelEnum.TOWERING_TREES; |
| | | |
| | |
| | | * @author mitao |
| | | * @since 2024-08-21 |
| | | */ |
| | | @Api(tags = {"用户相关接口"}) |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/client/app-user") |
| | | @RequiredArgsConstructor |
| | |
| | | private AppUserViewingHistoryService appUserViewingHistoryService; |
| | | @Resource |
| | | private AppUserEnergyRecordService appUserEnergyRecordService; |
| | | @Resource |
| | | private AppUserTagService appUserTagService; |
| | | @Resource |
| | | private TagService tagService; |
| | | |
| | | @Resource |
| | | private AppUserTreeService appUserTreeService; |
| | | @Resource |
| | | private AppUserQuestionService appUserQuestionService; |
| | | @Resource |
| | | private TagService tagService; |
| | | |
| | | @Resource |
| | | private RemoteBannerService remoteBannerService; |
| | | @Resource |
| | | private RemoteOrderService remoteOrderService; |
| | | @Resource |
| | | private RemoteUserService remoteUserService; |
| | | |
| | | public static void main(String[] args) { |
| | | // 收件人电子邮箱,TODO 换成自己的收件箱 |
| | | String to = "443237572@qq.com"; |
| | | // 发件人电子邮箱,TODO 换成自己的发件箱 |
| | | String from = "13281306557@163.com"; |
| | | // 指定发送邮件的主机为 |
| | | String host = "smtp.163.com"; |
| | | Properties properties = new Properties(); |
| | | // 设置邮件服务器 |
| | | properties.setProperty("mail.smtp.host", host); |
| | | // 邮件发送协议 |
| | | properties.setProperty("mail.transport.protocol", "smtp"); |
| | | //是否启用调试模式(启用调试模式可打印客户端与服务器交互过程时一问一答的响应消息) |
| | | properties.setProperty("mail.debug","true"); |
| | | properties.setProperty("mail.smtp.auth", "true"); |
| | | // 获取默认session对象 |
| | | Session session = Session.getDefaultInstance(properties,new Authenticator(){ |
| | | @Override |
| | | public PasswordAuthentication getPasswordAuthentication() |
| | | { |
| | | //发件人邮件用户名、授权码,换成自己的发件箱及授权码 |
| | | return new PasswordAuthentication("13281306557@163.com", "NUSdxDQqadYvVek2"); |
| | | } |
| | | }); |
| | | // 获取当前年份 |
| | | int currentYear = LocalDate.now().getYear(); |
| | | // 定义日期时间格式 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | // 获取1月份的第一天 |
| | | LocalDate firstDayOfMonth = LocalDate.of(currentYear, 2, 1); |
| | | LocalDateTime firstDayOfMonthDateTime = firstDayOfMonth.atStartOfDay(); |
| | | |
| | | try{ |
| | | // 创建默认的 MimeMessage 对象 |
| | | MimeMessage message = new MimeMessage(session); |
| | | // Set From,设置发件人 |
| | | InternetAddress fromMail = new InternetAddress(from); |
| | | //设置发件人名称,TODO 换成自己的发件箱 |
| | | fromMail.setPersonal(MimeUtility.encodeText("明星电力<13281306557@163.com>")); |
| | | message.setFrom(fromMail); |
| | | // Set To: 设置收件人 |
| | | InternetAddress toMail = new InternetAddress(to); |
| | | // TODO 换成自己的收件箱 |
| | | InternetAddress toMail2 = new InternetAddress("443237572@qq.com"); |
| | | //发一个邮箱 |
| | | // message.setRecipient(Message.RecipientType.TO, toMail); |
| | | //发多个邮箱 |
| | | Address[] allRecipients = {toMail, toMail2}; |
| | | message.setRecipients(Message.RecipientType.TO, allRecipients); |
| | | // Set Subject: 邮件主体 |
| | | message.setSubject("明星电力"); |
| | | // 设置消息体 |
| | | message.setSentDate(new Date()); |
| | | // 指定为混合关系 |
| | | MimeMultipart msgMultipart = new MimeMultipart("mixed"); |
| | | message.setContent(msgMultipart); |
| | | // 邮件信息组装 |
| | | //组装的顺序非常重要,一定要先组装文本域,再组装文件 |
| | | MimeBodyPart htmlPart = new MimeBodyPart(); |
| | | // 组装内容 |
| | | htmlPart.setContent("This is message content", "text/html;charset=UTF-8"); |
| | | msgMultipart.addBodyPart(htmlPart); |
| | | // 组装附件 |
| | | MimeBodyPart filePart = new MimeBodyPart(); |
| | | String imageUrl = "https://xqgwzh.obs.cn-south-1.myhuaweicloud.com/xinquan/b176cf9af35d4773a276e55b7afe3b63.mp4"; |
| | | try { |
| | | // 下载数据 |
| | | URL url = new URL(imageUrl); |
| | | InputStream inputStream = url.openStream(); |
| | | byte[] imageBytes = IOUtils.toByteArray(inputStream); |
| | | // 创建临时文件 |
| | | // 截取imageUrl后缀名 |
| | | String fileExtension = imageUrl.substring(imageUrl.lastIndexOf(".")); |
| | | File tempFile = File.createTempFile("tempImage", fileExtension); |
| | | try (FileOutputStream fos = new FileOutputStream(tempFile)) { |
| | | fos.write(imageBytes); |
| | | // 获取1月份的最后一天 |
| | | LocalDate lastDayOfMonth = LocalDate.of(currentYear, 2, 12).with(TemporalAdjusters.lastDayOfMonth()); |
| | | LocalDateTime lastDayOfMonthDateTime = lastDayOfMonth.atTime(23, 59, 59); |
| | | |
| | | |
| | | |
| | | // 格式化日期时间 |
| | | String firstDayOfMonthString = firstDayOfMonthDateTime.format(formatter); |
| | | String lastDayOfMonthString = lastDayOfMonthDateTime.format(formatter); |
| | | |
| | | System.out.println("1月份的第一天: " + firstDayOfMonthString); |
| | | System.out.println("1月份的最后一天: " + lastDayOfMonthString); |
| | | } |
| | | @GetMapping("/addVipExpireTime/{id}/{type}") |
| | | public R addVipExpireTime(@PathVariable("id")Long id,@PathVariable("type")Integer type) { |
| | | AppUser byId = appUserService.getById(id); |
| | | byId.setVipLevel(type); |
| | | switch (type){ |
| | | case 1: |
| | | if (byId.getVipExpireTime()!=null&&byId.getVipExpireTime().isAfter(LocalDateTime.now())){ |
| | | byId.setVipExpireTime(byId.getVipExpireTime().plusDays(30)); |
| | | }else{ |
| | | byId.setVipExpireTime(LocalDateTime.now().plusDays(30)); |
| | | } |
| | | // 创建 FileDataSource |
| | | FileDataSource fileDataSource = new FileDataSource(tempFile); |
| | | System.out.println("FileDataSource created: " + fileDataSource.getName()); |
| | | // 如果需要,可以使用 DataHandler 进行进一步处理 |
| | | DataHandler dh = new DataHandler(fileDataSource); |
| | | // 清理:删除临时文件(如果不再需要) |
| | | tempFile.deleteOnExit(); // 可根据需要保留或删除 |
| | | // DataHandler dh = new DataHandler(dataSource); |
| | | filePart.setDataHandler(dh); |
| | | // 附件区别内嵌内容的一个特点是有文件名,为防止中文乱码要编码 |
| | | filePart.setFileName(MimeUtility.encodeText(dh.getName())); |
| | | msgMultipart.addBodyPart(filePart); |
| | | |
| | | message.saveChanges(); |
| | | //发送 |
| | | //Transport.send(message, message.getAllRecipients()); |
| | | Transport.send(message); |
| | | System.out.println("Sent mail successfully...."); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | //TODO 换成自己的附件地址 |
| | | |
| | | }catch (MessagingException | UnsupportedEncodingException mex) { |
| | | mex.printStackTrace(); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | break; |
| | | case 2: |
| | | if (byId.getVipExpireTime()!=null&&byId.getVipExpireTime().isAfter(LocalDateTime.now())){ |
| | | byId.setVipExpireTime(byId.getVipExpireTime().plusDays(90)); |
| | | }else{ |
| | | byId.setVipExpireTime(LocalDateTime.now().plusDays(90)); |
| | | } |
| | | break; |
| | | case 3: |
| | | if (byId.getVipExpireTime()!=null&&byId.getVipExpireTime().isAfter(LocalDateTime.now())){ |
| | | byId.setVipExpireTime(byId.getVipExpireTime().plusDays(365)); |
| | | }else{ |
| | | byId.setVipExpireTime(LocalDateTime.now().plusDays(365)); |
| | | } |
| | | break; |
| | | } |
| | | appUserService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | @GetMapping("/addBalance/{id}/{money}") |
| | | public R addBalance(@PathVariable("id")Long id,@PathVariable("money")BigDecimal money) { |
| | | AppUser byId = appUserService.getById(id); |
| | | byId.setBalance(byId.getBalance().add(money)); |
| | | appUserService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | /** |
| | | * 远程调用 获取用户总数上升趋势 |
| | | */ |
| | | @ApiOperation(value = "首页统计测试接口", tags = "首页统计测试接口") |
| | | @PostMapping("/getUserListCount") |
| | | public R<Map<String,Object>> getUserListCount() { |
| | | Map<String, Object> res = new HashMap<>(); |
| | | // 获取当前年份 |
| | | int currentYear = LocalDate.now().getYear(); |
| | | // 定义日期时间格式 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | for (int i = 1; i <= 12; i++) { |
| | | // 获取1月份的第一天 |
| | | LocalDate firstDayOfMonth = LocalDate.of(currentYear, i, 1); |
| | | LocalDateTime firstDayOfMonthDateTime = firstDayOfMonth.atStartOfDay(); |
| | | // 获取1月份的最后一天 |
| | | LocalDate lastDayOfMonth = LocalDate.of(currentYear, i, 12).with(TemporalAdjusters.lastDayOfMonth()); |
| | | LocalDateTime lastDayOfMonthDateTime = lastDayOfMonth.atTime(23, 59, 59); |
| | | // 格式化日期时间 |
| | | String firstDayOfMonthString = firstDayOfMonthDateTime.format(formatter); |
| | | String lastDayOfMonthString = lastDayOfMonthDateTime.format(formatter); |
| | | List<AppUser> list = appUserService.lambdaQuery().eq(BaseModel::getDelFlag, 0) |
| | | .ne(AppUser::getUserStatus, 3) |
| | | .between(BaseModel::getCreateTime, firstDayOfMonthString, lastDayOfMonthString) |
| | | .list(); |
| | | |
| | | res.put(i+"月",list.size()); |
| | | } |
| | | // 定义月份的排序顺序 |
| | | List<String> monthsOrder = Arrays.asList("1月", "2月", "3月", "4月", "5月", |
| | | "6月", "7月", "8月", "9月", |
| | | "10月", "11月", "12月"); |
| | | |
| | | // 创建一个 LinkedHashMap 来保持插入顺序 |
| | | Map<String, Object> sortedData = new LinkedHashMap<>(); |
| | | |
| | | // 按照定义的顺序将数据放入 LinkedHashMap |
| | | for (String month : monthsOrder) { |
| | | if (res.containsKey(month)) { |
| | | sortedData.put(month, res.get(month)); |
| | | } |
| | | } |
| | | return R.ok(sortedData); |
| | | } |
| | | |
| | | /** |
| | | * 远程调用 获取用户总数 非会员数 会员数 |
| | | * @return |
| | | */ |
| | | @PostMapping("/getUserCount") |
| | | public R<String> getUserCount() { |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | List<AppUser> list = appUserService.lambdaQuery() |
| | | .eq(BaseModel::getDelFlag, 0) |
| | | .ne(AppUser::getUserStatus, 3).list(); |
| | | stringBuilder.append(list.size()).append(","); |
| | | List<AppUser> memberList = list.stream().filter(appUser -> |
| | | appUser.getVipExpireTime() == null || |
| | | appUser.getVipExpireTime() |
| | | .isBefore(LocalDateTime.now())).collect(Collectors.toList()); |
| | | int month=0; |
| | | int quarter=0; |
| | | int year=0; |
| | | // 获取当前时间的单例 |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | stringBuilder.append(memberList.size()).append(","); |
| | | for (AppUser appUser : list) { |
| | | if (appUser.getVipExpireTime()!=null){ |
| | | if (appUser.getVipExpireTime().isAfter(now)){ |
| | | if (appUser.getVipLevel()!=null){ |
| | | switch (appUser.getVipLevel()){ |
| | | case 1: |
| | | month++; |
| | | break; |
| | | case 2: |
| | | quarter++; |
| | | break; |
| | | case 3: |
| | | year++; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | stringBuilder.append(month).append(","); |
| | | stringBuilder.append(quarter).append(","); |
| | | stringBuilder.append(year); |
| | | return R.ok(stringBuilder.toString()); |
| | | } |
| | | // public static void main(String[] args) { |
| | | // // 收件人电子邮箱,TODO 换成自己的收件箱 |
| | | // String to = "443237572@qq.com"; |
| | | // // 发件人电子邮箱,TODO 换成自己的发件箱 |
| | | // String from = "13281306557@163.com"; |
| | | // // 指定发送邮件的主机为 |
| | | // String host = "smtp.163.com"; |
| | | // Properties properties = new Properties(); |
| | | // // 设置邮件服务器 |
| | | // properties.setProperty("mail.smtp.host", host); |
| | | // // 邮件发送协议 |
| | | // properties.setProperty("mail.transport.protocol", "smtp"); |
| | | // //是否启用调试模式(启用调试模式可打印客户端与服务器交互过程时一问一答的响应消息) |
| | | // properties.setProperty("mail.debug","true"); |
| | | // properties.setProperty("mail.smtp.auth", "true"); |
| | | // // 获取默认session对象 |
| | | // Session session = Session.getDefaultInstance(properties,new Authenticator(){ |
| | | // @Override |
| | | // public PasswordAuthentication getPasswordAuthentication() |
| | | // { |
| | | // //发件人邮件用户名、授权码,换成自己的发件箱及授权码 |
| | | // return new PasswordAuthentication("13281306557@163.com", "NUSdxDQqadYvVek2"); |
| | | // } |
| | | // }); |
| | | // |
| | | // try{ |
| | | // // 创建默认的 MimeMessage 对象 |
| | | // MimeMessage message = new MimeMessage(session); |
| | | // // Set From,设置发件人 |
| | | // InternetAddress fromMail = new InternetAddress(from); |
| | | // //设置发件人名称,TODO 换成自己的发件箱 |
| | | // fromMail.setPersonal(MimeUtility.encodeText("明星电力<13281306557@163.com>")); |
| | | // message.setFrom(fromMail); |
| | | // // Set To: 设置收件人 |
| | | // InternetAddress toMail = new InternetAddress(to); |
| | | // // TODO 换成自己的收件箱 |
| | | // InternetAddress toMail2 = new InternetAddress("443237572@qq.com"); |
| | | // //发一个邮箱 |
| | | //// message.setRecipient(Message.RecipientType.TO, toMail); |
| | | // //发多个邮箱 |
| | | // Address[] allRecipients = {toMail, toMail2}; |
| | | // message.setRecipients(Message.RecipientType.TO, allRecipients); |
| | | // // Set Subject: 邮件主体 |
| | | // message.setSubject("明星电力"); |
| | | // // 设置消息体 |
| | | // message.setSentDate(new Date()); |
| | | // // 指定为混合关系 |
| | | // MimeMultipart msgMultipart = new MimeMultipart("mixed"); |
| | | // message.setContent(msgMultipart); |
| | | // // 邮件信息组装 |
| | | // //组装的顺序非常重要,一定要先组装文本域,再组装文件 |
| | | // MimeBodyPart htmlPart = new MimeBodyPart(); |
| | | // // 组装内容 |
| | | // htmlPart.setContent("This is message content", "text/html;charset=UTF-8"); |
| | | // msgMultipart.addBodyPart(htmlPart); |
| | | // // 组装附件 |
| | | // MimeBodyPart filePart = new MimeBodyPart(); |
| | | // String imageUrl = "https://xqgwzh.obs.cn-south-1.myhuaweicloud.com/xinquan/b176cf9af35d4773a276e55b7afe3b63.mp4"; |
| | | // try { |
| | | // // 下载数据 |
| | | // URL url = new URL(imageUrl); |
| | | // InputStream inputStream = url.openStream(); |
| | | // byte[] imageBytes = IOUtils.toByteArray(inputStream); |
| | | // // 创建临时文件 |
| | | // // 截取imageUrl后缀名 |
| | | // String fileExtension = imageUrl.substring(imageUrl.lastIndexOf(".")); |
| | | // File tempFile = File.createTempFile("tempImage", fileExtension); |
| | | // try (FileOutputStream fos = new FileOutputStream(tempFile)) { |
| | | // fos.write(imageBytes); |
| | | // } |
| | | // // 创建 FileDataSource |
| | | // FileDataSource fileDataSource = new FileDataSource(tempFile); |
| | | // System.out.println("FileDataSource created: " + fileDataSource.getName()); |
| | | // // 如果需要,可以使用 DataHandler 进行进一步处理 |
| | | // DataHandler dh = new DataHandler(fileDataSource); |
| | | // // 清理:删除临时文件(如果不再需要) |
| | | // tempFile.deleteOnExit(); // 可根据需要保留或删除 |
| | | //// DataHandler dh = new DataHandler(dataSource); |
| | | // filePart.setDataHandler(dh); |
| | | // // 附件区别内嵌内容的一个特点是有文件名,为防止中文乱码要编码 |
| | | // filePart.setFileName(MimeUtility.encodeText(dh.getName())); |
| | | // msgMultipart.addBodyPart(filePart); |
| | | // |
| | | // message.saveChanges(); |
| | | // //发送 |
| | | // //Transport.send(message, message.getAllRecipients()); |
| | | // Transport.send(message); |
| | | // System.out.println("Sent mail successfully...."); |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // //TODO 换成自己的附件地址 |
| | | // |
| | | // }catch (MessagingException | UnsupportedEncodingException mex) { |
| | | // mex.printStackTrace(); |
| | | // } catch (Exception e) { |
| | | // throw new RuntimeException(e); |
| | | // } |
| | | // } |
| | | |
| | | @PostMapping("/userDetail") |
| | | @ApiOperation(value = "用户详情-基础信息", notes = "管理后台-用户管理") |
| | | @ApiOperation(value = "用户详情-基础信息", tags = "管理后台-用户管理") |
| | | public R userDetail(String uid) { |
| | | AppUser byId = appUserService.getById(uid); |
| | | // 判断是不是会员 |
| | |
| | | return R.ok(); |
| | | } |
| | | @GetMapping("/viewReport") |
| | | @ApiOperation(value = "用户详情-查看报告", notes = "管理后台-用户管理") |
| | | @ApiOperation(value = "用户详情-查看报告", tags = "管理后台-用户管理") |
| | | public R<ViewReport> viewReport(String uid) { |
| | | ViewReport viewReport = new ViewReport(); |
| | | String tagId = appUserService.getById(uid).getTagId(); |
| | | List<AppUserQuestion> list = appUserQuestionService.lambdaQuery().eq(AppUserQuestion::getAppUserId, uid).list(); |
| | | List<Tag> list1 = tagService.lambdaQuery().list(); |
| | | List<AppUserQuestion> appUserQuestions = new ArrayList<>(); |
| | | List<AppUserQuestion> list = appUserQuestionService.lambdaQuery().eq(AppUserQuestion::getAppUserId, uid).orderByAsc(AppUserQuestion::getType).list(); |
| | | for (int i = 0; i < 6; i++) { |
| | | AppUserQuestion appUserQuestion = new AppUserQuestion(); |
| | | appUserQuestion.setType(i+1); |
| | | if (!list.isEmpty()){ |
| | | appUserQuestion.setAnswer(list.get(i)!=null?list.get(i).getAnswer():""); |
| | | }else{ |
| | | appUserQuestion.setAnswer(null); |
| | | } |
| | | appUserQuestions.add(appUserQuestion); |
| | | } |
| | | List<Tag> list1 = tagService.lambdaQuery().eq(Tag::getTagType,2).list(); |
| | | String[] split = tagId.split(","); |
| | | List<String> list2 = Arrays.asList(split); |
| | | if (!list2.isEmpty()){ |
| | |
| | | tag.setIsCheck(2); |
| | | } |
| | | } |
| | | viewReport.setQuestions(list); |
| | | viewReport.setQuestions(appUserQuestions); |
| | | viewReport.setTags(list1); |
| | | return R.ok(viewReport); |
| | | } |
| | | @GetMapping("/freezing") |
| | | @ApiOperation(value = "冻结用户", notes = "管理后台-用户管理") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "uid", value = "uid", dataType = "String", required = true), |
| | | @ApiImplicitParam(name = "freezingReason", value = "冻结原因", dataType = "String", required = true), |
| | | }) |
| | | public R freezingDetail(String uid,String freezingReason) { |
| | | AppUser byId = appUserService.getById(uid); |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @PostMapping("/freezing") |
| | | @ApiOperation(value = "冻结用户", tags = "管理后台-用户管理") |
| | | |
| | | public R freezingDetail(@RequestBody UserFreezingDTO dto) { |
| | | AppUser byId = appUserService.getById(dto.getUid()); |
| | | byId.setFreezingTime(LocalDateTime.now()); |
| | | byId.setFreezingReason(freezingReason); |
| | | byId.setFreezingReason(dto.getFreezingReason()); |
| | | byId.setUserStatus(2); |
| | | byId.setFreezingOperator(SecurityUtils.getUserId()+""); |
| | | byId.setFreezingOperator(tokenService.getLoginUser().getUserid()+""); |
| | | appUserService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | @GetMapping("/detail") |
| | | @ApiOperation(value = "用户详情", notes = "管理后台-用户管理") |
| | | @ApiOperation(value = "用户详情", tags = "管理后台-用户管理") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "uid", value = "uid", dataType = "String", required = true), |
| | | }) |
| | |
| | | byId.setLevelName(data.getLevelName()); |
| | | byId.setLevelIcon(data.getLevelIcon()); |
| | | } |
| | | |
| | | return R.ok(); |
| | | return R.ok(byId); |
| | | } |
| | | @GetMapping("/unFreezing") |
| | | @ApiOperation(value = "解冻用户", notes = "管理后台-用户管理") |
| | | @ApiOperation(value = "解冻用户", tags = "管理后台-用户管理") |
| | | public R unFreezing(String uid) { |
| | | AppUser byId = appUserService.getById(uid); |
| | | byId.setUserStatus(1); |
| | |
| | | return R.ok(byId.getFreezingReason()); |
| | | } |
| | | @GetMapping("/setSanskritFlag") |
| | | @ApiOperation(value = "设置梵文权限", notes = "管理后台-用户管理") |
| | | @ApiOperation(value = "设置梵文权限", tags = "管理后台-用户管理") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "uid", value = "用户uid 多个逗号拼接", dataType = "String", required = true), |
| | | @ApiImplicitParam(name = "setSanskritFlag", value = "梵文权限 1是2否", dataType = "int", required = true), |
| | |
| | | return R.ok(); |
| | | } |
| | | @GetMapping("/setTotalEnergyValue") |
| | | @ApiOperation(value = "能量值修改", notes = "管理后台-用户管理") |
| | | @ApiOperation(value = "能量值修改", tags = "管理后台-用户管理") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "uid", value = "用户uid 多个逗号拼接", dataType = "String", required = true), |
| | | @ApiImplicitParam(name = "uid", value = "用户uid", dataType = "String", required = true), |
| | | @ApiImplicitParam(name = "energyValue", value = "能量值", dataType = "int", required = true), |
| | | @ApiImplicitParam(name = "reason", value = "备注", dataType = "int", required = true), |
| | | @ApiImplicitParam(name = "reason", value = "备注", dataType = "String", required = true) |
| | | }) |
| | | public R setTotalEnergyValue(String uid,Integer energyValue,String remark) { |
| | | public R setTotalEnergyValue(String uid,Integer energyValue,String reason) { |
| | | AppUser byId = appUserService.getById(uid); |
| | | byId.setTotalEnergyValue(byId.getTotalEnergyValue()+energyValue); |
| | | byId.setEnergyValue(byId.getEnergyValue()+energyValue); |
| | | appUserService.updateById(byId); |
| | | AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord(); |
| | | appUserEnergyRecord.setAppUserId(byId.getId()); |
| | |
| | | appUserEnergyRecord.setChangeType(1); |
| | | appUserEnergyRecord.setEnergyValue(energyValue); |
| | | } |
| | | appUserEnergyRecord.setReason(remark); |
| | | appUserEnergyRecord.setUpdateId(tokenService.getLoginUser().getUserid()); |
| | | appUserEnergyRecord.setReason(reason); |
| | | appUserEnergyRecord.setCreateBy(SecurityUtils.getUsername()); |
| | | appUserEnergyRecord.setCreateTime(LocalDateTime.now()); |
| | | appUserEnergyRecordService.save(appUserEnergyRecord); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/setVip") |
| | | @ApiOperation(value = "设置会员", notes = "管理后台-用户管理") |
| | | @ApiOperation(value = "设置会员", tags = "管理后台-用户管理") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "uid", value = "uid", dataType = "String", required = true), |
| | | @ApiImplicitParam(name = "vipType", value = "会员类型 1非 2月 3季 4年", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(name = "vipExpireTime", value = "会员到期时间 yyyy-MM-dd HH:mm", dataType = "String", required = true), |
| | | }) |
| | | public R setVip(String uid, Integer vipType) { |
| | | public R setVip(String uid, Integer vipType,String vipExpireTime) { |
| | | // 将其转化为LocalDateTime格式 |
| | | LocalDateTime parse = LocalDateTime.parse(vipExpireTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | LambdaUpdateWrapper<AppUser> appUserLambdaUpdateWrapper = new LambdaUpdateWrapper<>(); |
| | | AppUser byId = appUserService.getById(uid); |
| | | switch (vipType){ |
| | | case 1: |
| | | appUserLambdaUpdateWrapper.set(AppUser::getVipExpireTime,null); |
| | | appUserLambdaUpdateWrapper.set(AppUser::getVipLevel,null); |
| | | appUserLambdaUpdateWrapper.eq(AppUser::getId,byId.getUserId()); |
| | | appUserService.update(appUserLambdaUpdateWrapper); |
| | | break; |
| | | case 2: |
| | | |
| | | if (byId.getVipExpireTime() == null){ |
| | | byId.setVipLevel(1); |
| | | byId.setVipExpireTime(LocalDateTime.now().plusDays(30)); |
| | | byId.setVipExpireTime(parse); |
| | | }else if (byId.getVipExpireTime().isAfter(LocalDateTime.now())){ |
| | | |
| | | |
| | | byId.setVipExpireTime(byId.getVipExpireTime().plusDays(30)); |
| | | byId.setVipExpireTime(parse); |
| | | }else{ |
| | | byId.setVipExpireTime(LocalDateTime.now().plusDays(30)); |
| | | byId.setVipExpireTime(parse); |
| | | } |
| | | break; |
| | | case 3: |
| | | |
| | | if (byId.getVipExpireTime() == null){ |
| | | byId.setVipLevel(2); |
| | | byId.setVipExpireTime(LocalDateTime.now().plusMonths(90)); |
| | | byId.setVipExpireTime(parse); |
| | | }else if (byId.getVipExpireTime().isAfter(LocalDateTime.now())){ |
| | | // 如果当前用户的会员等级大于设置的会员等级那么不管 |
| | | if (byId.getVipLevel()<2){ |
| | | byId.setVipLevel(2); |
| | | } |
| | | byId.setVipExpireTime(byId.getVipExpireTime().plusDays(90)); |
| | | byId.setVipExpireTime(parse); |
| | | }else{ |
| | | if (byId.getVipLevel()<2){ |
| | | byId.setVipLevel(2); |
| | | } |
| | | byId.setVipExpireTime(LocalDateTime.now().plusDays(90)); |
| | | byId.setVipExpireTime(parse); |
| | | } |
| | | break; |
| | | case 4: |
| | | byId.setVipLevel(3); |
| | | if (byId.getVipExpireTime() == null){ |
| | | byId.setVipExpireTime(LocalDateTime.now().plusMonths(365)); |
| | | byId.setVipExpireTime(parse); |
| | | }else if (byId.getVipExpireTime().isAfter(LocalDateTime.now())){ |
| | | byId.setVipExpireTime(byId.getVipExpireTime().plusDays(365)); |
| | | byId.setVipExpireTime(parse); |
| | | }else{ |
| | | byId.setVipExpireTime(LocalDateTime.now().plusDays(365)); |
| | | byId.setVipExpireTime(parse); |
| | | } |
| | | break; |
| | | } |
| | |
| | | return R.ok(); |
| | | } |
| | | @GetMapping("/freezingDetail") |
| | | @ApiOperation(value = "冻结详情", notes = "管理后台-用户管理") |
| | | @ApiOperation(value = "冻结详情", tags = "管理后台-用户管理") |
| | | public R<FreezingVO> freezingDetail(String uid) { |
| | | AppUser byId = appUserService.getById(uid); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | |
| | | SysUser data = remoteUserService.getSysUserById(byId.getFreezingOperator()).getData(); |
| | | freezingVO.setFreezingOperator(data.getNickName()+"("+data.getUserName()+")"); |
| | | return R.ok(freezingVO); |
| | | } |
| | | @ApiOperation(value = "用户列表-下级用户管理导出", tags = {"管理后台-用户管理"}) |
| | | @PutMapping("/exportUser") |
| | | public void export(@RequestBody UserChildDTO dto) |
| | | { |
| | | String startTime = null; |
| | | String endTime = null; |
| | | if (org.springframework.util.StringUtils.hasLength(dto.getTime())){ |
| | | String[] split = dto.getTime().split(" - "); |
| | | startTime = split[0]+"00:00:00"; |
| | | endTime = split[1]+"23:59:59"; |
| | | } |
| | | String userId = dto.getUid(); |
| | | LambdaQueryWrapper<AppUser> appUserWalletRecordLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | appUserWalletRecordLambdaQueryWrapper.between(startTime!=null,BaseModel::getCreateTime,startTime,endTime); |
| | | appUserWalletRecordLambdaQueryWrapper.eq(AppUser::getInviteUserId, userId); |
| | | appUserWalletRecordLambdaQueryWrapper.like(org.springframework.util.StringUtils.hasLength(dto.getCellPhone()),AppUser::getCellPhone,dto.getCellPhone()); |
| | | appUserWalletRecordLambdaQueryWrapper.like(org.springframework.util.StringUtils.hasLength(dto.getNickName()),AppUser::getNickname,dto.getNickName()); |
| | | appUserWalletRecordLambdaQueryWrapper.orderByDesc(BaseModel::getCreateTime); |
| | | List<AppUser> page = appUserService |
| | | .list(appUserWalletRecordLambdaQueryWrapper); |
| | | List<UserInfoExport> userInfoExports = new ArrayList<>(); |
| | | |
| | | for (AppUser record : page) { |
| | | // 查询该用户带来收益 |
| | | List<AppUserWalletRecord> list = appUserWalletRecordService.lambdaQuery().eq(AppUserWalletRecord::getAppUserId, record.getId()) |
| | | .eq(AppUserWalletRecord::getChildAppUserId, record.getUserId()).list(); |
| | | BigDecimal bigDecimal = new BigDecimal("0"); |
| | | for (AppUserWalletRecord appUserWalletRecord : list) { |
| | | if (appUserWalletRecord.getAmount()!=null && appUserWalletRecord.getChangeType() == 1){ |
| | | bigDecimal = bigDecimal.add(appUserWalletRecord.getAmount()); |
| | | } |
| | | record.setMoney(bigDecimal); |
| | | } |
| | | UserInfoExport userInfoExport = new UserInfoExport(); |
| | | userInfoExport.setCode(record.getCode()); |
| | | userInfoExport.setUserName(record.getNickname()); |
| | | userInfoExport.setCellphone(record.getCellPhone()); |
| | | userInfoExport.setIncome("¥"+record.getMoney()); |
| | | DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | String format = df.format(record.getInviteUserTime()); |
| | | userInfoExport.setInviteUserTime(format); |
| | | userInfoExport.setUserStatus(record.getUserStatus()+""); |
| | | userInfoExports.add(userInfoExport); |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), UserInfoExport.class, userInfoExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("用户管理导出.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | @ApiOperation(value = "用户列表管理导出", tags = {"管理后台-用户管理"}) |
| | | @PutMapping("/export") |
| | | public void export(@RequestBody AppUserManagementDTO courseDTO) |
| | | { |
| | | String startTime = null; |
| | | String endTime = null; |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getVipExpireTime())){ |
| | | String[] split = courseDTO.getVipExpireTime().split(" - "); |
| | | startTime = split[0]+"00:00:00"; |
| | | endTime = split[1]+"23:59:59"; |
| | | } |
| | | String startTime1 = null; |
| | | String endTime1 = null; |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getRegisterTime())){ |
| | | String[] split = courseDTO.getRegisterTime().split(" - "); |
| | | startTime1 = split[0]+"00:00:00"; |
| | | endTime1 = split[1]+"23:59:59"; |
| | | } |
| | | List<Long> longs = new ArrayList<>(); |
| | | LambdaQueryWrapper<AppUser> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | courseLambdaQueryWrapper |
| | | .like(StringUtils.isNotBlank(courseDTO.getNickname()), AppUser::getNickname, courseDTO.getNickname()) |
| | | .like(StringUtils.isNotBlank(courseDTO.getCellPhone()), AppUser::getCellPhone, courseDTO.getCellPhone()) |
| | | .eq(Objects.nonNull(courseDTO.getGender()), AppUser::getGender, courseDTO.getGender()) |
| | | .eq(Objects.nonNull(courseDTO.getUserStatus()), AppUser::getUserStatus, courseDTO.getUserStatus()) |
| | | .between(Objects.nonNull(startTime),AppUser::getVipExpireTime,startTime,endTime) |
| | | .between(Objects.nonNull(startTime1),AppUser::getRegisterTime,startTime1,endTime1) |
| | | .orderByDesc(AppUser::getRegisterTime); |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getVipType())){ |
| | | String[] split = courseDTO.getVipType().split(","); |
| | | List<String> list1 = Arrays.asList(split); |
| | | List<AppUser> appUsers = new ArrayList<>(); |
| | | List<AppUser> list = appUserService.lambdaQuery().gt(AppUser::getVipExpireTime, LocalDateTime.now()).list(); |
| | | for (AppUser appUser : list) { |
| | | if(appUser.getVipLevel()!=null){ |
| | | if (list1.contains(appUser.getVipLevel().toString())){ |
| | | appUsers.add(appUser); |
| | | } |
| | | } |
| | | } |
| | | List<Long> collect = appUsers.stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(AppUser::getId, longs); |
| | | } |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getLevel())){ |
| | | List<String> list2 = Arrays.asList(courseDTO.getLevel().split(",")); |
| | | List<AppUser> list = appUserService.lambdaQuery().list(); |
| | | List<AppUser> appUsers = new ArrayList<>(); |
| | | for (AppUser appUser : list) { |
| | | List<AppUserTree> list1 = appUserTreeService.lambdaQuery().eq(AppUserTree::getAppUserId, appUser.getId()) |
| | | .list(); |
| | | // 查询用户等级最高的那颗树苗 |
| | | AppUserTree tree = list1.stream().max((o1, o2) -> { |
| | | if (o1.getTreeLevelType() > o2.getTreeLevelType()) { |
| | | return 1; |
| | | } else if (o1.getTreeLevelType() < o2.getTreeLevelType()) { |
| | | return -1; |
| | | } else { |
| | | return 0; |
| | | } |
| | | }).orElse(null); |
| | | // 查询疗愈等级 名称 图标 |
| | | int level = 1; |
| | | if (tree != null){ |
| | | level = tree.getTreeLevelType(); |
| | | } |
| | | if (list2.contains(level+"")){ |
| | | appUsers.add(appUser); |
| | | } |
| | | } |
| | | List<Long> collect = appUsers.stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(AppUser::getId, collect); |
| | | } |
| | | List<AppUser> page = appUserService.list(courseLambdaQueryWrapper); |
| | | List<UserExport> userExports = new ArrayList<>(); |
| | | for (AppUser record : page) { |
| | | record.setUid(record.getId()+""); |
| | | // 判断是不是会员 |
| | | if (record.getVipExpireTime() == null){ |
| | | record.setIsVip(2); |
| | | }else if (record.getVipExpireTime().isBefore(LocalDateTime.now())){ |
| | | record.setIsVip(2); |
| | | }else{ |
| | | record.setIsVip(1); |
| | | } |
| | | List<AppUserTree> list1 = appUserTreeService.lambdaQuery().eq(AppUserTree::getAppUserId, record.getId()) |
| | | .list(); |
| | | // 查询用户等级最高的那颗树苗 |
| | | AppUserTree tree = list1.stream().max((o1, o2) -> { |
| | | if (o1.getTreeLevelType() > o2.getTreeLevelType()) { |
| | | return 1; |
| | | } else if (o1.getTreeLevelType() < o2.getTreeLevelType()) { |
| | | return -1; |
| | | } else { |
| | | return 0; |
| | | } |
| | | }).orElse(null); |
| | | // 查询疗愈等级 名称 图标 |
| | | int level = 1; |
| | | if (tree != null){ |
| | | level = tree.getTreeLevelType(); |
| | | } |
| | | // 根据等级查询疗愈名称和图标 |
| | | UserLevelSetting data = remoteBannerService.getIconNameByLevel(level).getData(); |
| | | record.setLevel(level); |
| | | record.setLevelIcon(data.getLevelIcon()); |
| | | record.setLevelName(data.getLevelName()); |
| | | record.setUid(record.getId().toString()); |
| | | UserExport userExport = new UserExport(); |
| | | userExport.setCode(record.getCode()); |
| | | userExport.setUserName(record.getNickname()); |
| | | userExport.setRealname(record.getRealname()); |
| | | userExport.setCellphone(record.getCellPhone()); |
| | | userExport.setGender(record.getGender()+""); |
| | | userExport.setBirthday(record.getBirthday()); |
| | | userExport.setEducation(record.getEducation()); |
| | | userExport.setLocation(record.getLocation()); |
| | | userExport.setHometown(record.getHometown()); |
| | | userExport.setEmail(record.getEmail()); |
| | | userExport.setIndustry(record.getIndustry()); |
| | | userExport.setCompany(record.getCompany()); |
| | | userExport.setOccupation(record.getOccupation()); |
| | | if (record.getVipExpireTime()!=null){ |
| | | if (record.getVipExpireTime().isAfter(LocalDateTime.now())){ |
| | | userExport.setIsVip(1+""); |
| | | }else{ |
| | | userExport.setIsVip(2+""); |
| | | } |
| | | }else{ |
| | | userExport.setIsVip(2+""); |
| | | |
| | | } |
| | | userExport.setMeditationLevel(record.getLevelName()); |
| | | userExport.setTotalEnergyValue(record.getTotalEnergyValue()+""); |
| | | userExport.setBalance(record.getBalance()+""); |
| | | DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | String format = df.format(record.getRegisterTime()); |
| | | userExport.setRegisterTime(format); |
| | | userExport.setUserStatus(record.getUserStatus()+""); |
| | | List<AppUserQuestion> list = appUserQuestionService.lambdaQuery() |
| | | .eq(AppUserQuestion::getAppUserId, record.getId()).list(); |
| | | for (AppUserQuestion appUserQuestion : list) { |
| | | switch (appUserQuestion.getType()){ |
| | | case 1: |
| | | userExport.setType1(appUserQuestion.getAnswer()); |
| | | break; |
| | | case 2: |
| | | userExport.setType2(appUserQuestion.getAnswer()); |
| | | break; |
| | | case 3: |
| | | userExport.setType3(appUserQuestion.getAnswer()); |
| | | break; |
| | | case 4: |
| | | userExport.setType4(appUserQuestion.getAnswer()); |
| | | break; |
| | | case 5: |
| | | userExport.setType5(appUserQuestion.getAnswer()); |
| | | break; |
| | | case 6: |
| | | userExport.setType6(appUserQuestion.getAnswer()); |
| | | break; |
| | | } |
| | | } |
| | | List<Integer> collect = appUserTagService.lambdaQuery() |
| | | .eq(AppUserTag::getAppUserId, record.getId()).list().stream() |
| | | .map(AppUserTag::getTagId) |
| | | .collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1); |
| | | } |
| | | List<Tag> list2 = tagService.lambdaQuery().in(Tag::getId, collect).list(); |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | for (Tag tag : list2) { |
| | | stringBuilder.append(tag.getTagName()).append(";"); |
| | | } |
| | | userExport.setType7(stringBuilder+""); |
| | | userExport.setSanskritFlag(record.getSanskritFlag()+""); |
| | | int size = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, record.getId()).list() |
| | | .size(); |
| | | userExport.setUserCount(size+""); |
| | | userExports.add(userExport); |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), UserExport.class, userExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("用户管理导出.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | @PostMapping("/userManagementList") |
| | | @ApiOperation(value = "用户管理列表-分页", tags = {"管理后台-用户管理"}) |
| | |
| | | .like(StringUtils.isNotBlank(courseDTO.getCellPhone()), AppUser::getCellPhone, courseDTO.getCellPhone()) |
| | | .eq(Objects.nonNull(courseDTO.getGender()), AppUser::getGender, courseDTO.getGender()) |
| | | .eq(Objects.nonNull(courseDTO.getUserStatus()), AppUser::getUserStatus, courseDTO.getUserStatus()) |
| | | .isNotNull(AppUser::getVipExpireTime) |
| | | .between(Objects.nonNull(startTime),AppUser::getVipExpireTime,startTime,endTime) |
| | | .between(Objects.nonNull(startTime1),AppUser::getRegisterTime,startTime1,endTime1) |
| | | .orderByDesc(AppUser::getRegisterTime); |
| | |
| | | return R.ok(PageDTO.empty(page)); |
| | | } |
| | | for (AppUser record : page.getRecords()) { |
| | | record.setUid(record.getId()+""); |
| | | // 判断是不是会员 |
| | | if (record.getVipExpireTime() == null){ |
| | | record.setIsVip(2); |
| | |
| | | @PostMapping("/changePhone") |
| | | @ApiOperation(value = "更换绑定手机号", tags = {"设置"}) |
| | | public R changePhone(String phone,String code) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/deleteUser") |
| | | @ApiOperation(value = "注销账号", tags = {"设置"}) |
| | | public R deleteUser() { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/wallet") |
| | | @ApiOperation(value = "我的钱包", tags = {"个人中心"}) |
| | | public R<WalletVO> wallet(UpdateAppUserDTO dto) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | public R<WalletVO> wallet() { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | AppUser byId = appUserService.getById(userId); |
| | | WalletVO walletVO = new WalletVO(); |
| | | walletVO.setId(userId); |
| | |
| | | public R<PageDTO<InviteRankListVO>> myInviteRankList( |
| | | @RequestParam(value = "pageCurr", defaultValue = "1") Integer pageCurr, |
| | | @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | Page<AppUser> page = appUserService.lambdaQuery().ne(AppUser::getUserStatus, 3) |
| | | .eq(AppUser::getInviteUserId, userId) |
| | | .page(new Page<>(pageCurr, pageSize)); |
| | | if (page.getRecords().isEmpty()){ |
| | | return R.ok(PageDTO.empty(page)); |
| | | } |
| | | // 查询登录用户邀请了哪些人 |
| | | List<Long> collect = page.getRecords().stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | if (collect.isEmpty())return R.ok(PageDTO.empty(page)); |
| | | for (int i = 0; i < page.getRecords().size(); i++) { |
| | | AppUser appUser = page.getRecords().get(i); |
| | | // 查询该给用户带来收益 |
| | | List<AppUserWalletRecord> list = appUserWalletRecordService.lambdaQuery().eq(AppUserWalletRecord::getAppUserId, userId) |
| | | .eq(AppUserWalletRecord::getChildAppUserId,appUser.getUserId()).list(); |
| | | BigDecimal bigDecimal = new BigDecimal("0"); |
| | | for (AppUserWalletRecord appUserWalletRecord : list) { |
| | | if (appUserWalletRecord.getAmount()!=null && appUserWalletRecord.getChangeType() == 1){ |
| | | bigDecimal = bigDecimal.add(appUserWalletRecord.getAmount()); |
| | | } |
| | | } |
| | | appUser.setMoney(bigDecimal); |
| | | |
| | | } |
| | | // 根据佣金金额 从大到小排序 |
| | | page.getRecords().sort((o1, o2) -> o2.getMoney().compareTo(o1.getMoney())); |
| | | return R.ok(PageDTO.of(page, InviteRankListVO.class)); |
| | | } |
| | | @PostMapping("/myInviteRankListShare") |
| | | @ApiOperation(value = "我的助力-分页", tags = {"H5分享"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "分页参数,当前页码", name = "pageCurr", required = true, dataType = "Integer"), |
| | | @ApiImplicitParam(value = "分页参数,每页数量", name = "pageSize", required = true, dataType = "Integer"), |
| | | @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "String"), |
| | | }) |
| | | public R<PageDTO<InviteRankListVO>> myInviteRankListShare( |
| | | @RequestParam(value = "pageCurr", defaultValue = "1") Integer pageCurr, |
| | | @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, |
| | | @RequestParam(value = "userId") String userId) { |
| | | Page<AppUser> page = appUserService.lambdaQuery().ne(AppUser::getUserStatus, 3) |
| | | .eq(AppUser::getInviteUserId, userId) |
| | | .page(new Page<>(pageCurr, pageSize)); |
| | |
| | | page.getRecords().sort((o1, o2) -> o2.getCount() - o1.getCount()); |
| | | return R.ok(PageDTO.of(page, InviteRankListVO.class)) ; |
| | | } |
| | | @PostMapping("/inviteRankListShare") |
| | | @ApiOperation(value = "爱心助力榜单-分页", tags = {"H5分享"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "分页参数,当前页码", name = "pageCurr", required = true, dataType = "Integer"), |
| | | @ApiImplicitParam(value = "分页参数,每页数量", name = "pageSize", required = true, dataType = "Integer") |
| | | }) |
| | | public R<PageDTO<InviteRankListVO>> inviteRankListShare( |
| | | @RequestParam(value = "pageCurr", defaultValue = "1") Integer pageCurr, |
| | | @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | Page<AppUser> page = appUserService.lambdaQuery().ne(AppUser::getUserStatus, 3) |
| | | .page(new Page<>(pageCurr, pageSize)); |
| | | for (AppUser appUser : page.getRecords()) { |
| | | int size = appUserService.lambdaQuery().ne(AppUser::getUserStatus, 3) |
| | | .eq(AppUser::getInviteUserId, appUser.getId()) |
| | | .list().size(); |
| | | appUser.setCount(size); |
| | | } |
| | | // 根据帮助人数 从大到小排序 |
| | | page.getRecords().sort((o1, o2) -> o2.getCount() - o1.getCount()); |
| | | return R.ok(PageDTO.of(page, InviteRankListVO.class)) ; |
| | | } |
| | | @PostMapping("/getUserInfo") |
| | | @ApiOperation(value = "获取用户信息", tags = {"个人中心"}) |
| | | public R<AppUserInfoVO> getUserInfo() { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | AppUserInfoVO appUserInfoVO = new AppUserInfoVO(); |
| | | AppUser byId = appUserService.getById(userId); |
| | | BeanUtils.copyProperties(byId, appUserInfoVO); |
| | | AppUserVO currentUser = appUserService.getCurrentUser(); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | if (currentUser.getVipExpireTime() == null){ |
| | |
| | | List<AppUserViewingHistory> com = appUserViewingHistoryService.cumulative(userId); |
| | | appUserInfoVO.setCumulative(com.size()); |
| | | // 查询用户今日学习多少分钟 |
| | | int temp = appUserViewingHistoryService.today(userId); |
| | | Integer temp = appUserViewingHistoryService.today(userId); |
| | | if (temp == null){ |
| | | temp =0; |
| | | } |
| | | if (temp == 0){ |
| | | appUserInfoVO.setToday(0); |
| | | }else if (temp<60){ |
| | |
| | | @PostMapping("/getUserDetail") |
| | | @ApiOperation(value = "获取个人资料", tags = {"个人中心"}) |
| | | public R<AppUser> getUserDetail() { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | AppUser appUser = appUserService.lambdaQuery().eq(AppUser::getId, userId).one(); |
| | | if (appUser.getVipExpireTime() == null){ |
| | | appUser.setIsVip(2); |
| | |
| | | @PostMapping("/healingLevel") |
| | | @ApiOperation(value = "冥想等级", tags = {"个人中心"}) |
| | | public R<HealingLevelVO> healingLevel() { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | List<AppUserTree> list1 = appUserTreeService.lambdaQuery().eq(AppUserTree::getAppUserId, userId) |
| | | .list(); |
| | | if (list1.isEmpty()){ |
| | | AppUserTree appUserTree = new AppUserTree(); |
| | | appUserTree.setAppUserId(userId); |
| | | appUserTree.setTreeLevelType(1); |
| | | appUserTree.setGrowthValue(0); |
| | | appUserTree.setSowAgain(2); |
| | | appUserTree.setStatus(2); |
| | | appUserTree.setCreateTime(LocalDateTime.now()); |
| | | appUserTreeService.save(appUserTree); |
| | | } |
| | | // 查询用户等级最高的那颗树苗 |
| | | AppUserTree tree = list1.stream().max((o1, o2) -> { |
| | | if (o1.getTreeLevelType() > o2.getTreeLevelType()) { |
| | |
| | | @PostMapping("/getTotalEnergyValue") |
| | | @ApiOperation(value = "获取用户当前累计能量值",tags = "树苗打卡站") |
| | | public R getTotalEnergyValue() { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | AppUser byId = appUserService.getById(userId); |
| | | return R.ok(byId.getTotalEnergyValue()); |
| | | } |
| | | @PostMapping("/updateUserDetail") |
| | | @ApiOperation(value = "修改个人资料", tags = {"个人中心"}) |
| | | public R<AppUser> updateUserDetail(UpdateAppUserDTO dto) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | public R<AppUser> updateUserDetail(@RequestBody UpdateAppUserDTO dto) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | AppUser byId = appUserService.getById(userId); |
| | | LambdaUpdateWrapper<AppUser> updateWrapper = new LambdaUpdateWrapper<>(AppUser.class); |
| | | updateWrapper.set(AppUser::getNickname, dto.getNickname()); |
| | |
| | | updateWrapper.set(AppUser::getLocation, dto.getLocation()); |
| | | updateWrapper.set(AppUser::getHometown, dto.getHometown()); |
| | | updateWrapper.set(AppUser::getEmail, dto.getEducation()); |
| | | updateWrapper.eq(AppUser::getId,userId); |
| | | appUserService.update(byId, updateWrapper); |
| | | return R.ok(); |
| | | return R.ok(byId); |
| | | } |
| | | @PostMapping("/updateUserAvatar") |
| | | @ApiOperation(value = "修改头像", tags = {"个人中心"}) |
| | | public R updateUserDetail(String avatar) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | AppUser byId = appUserService.getById(userId); |
| | | byId.setAvatar(avatar); |
| | | appUserService.updateById(byId); |
| | |
| | | @PostMapping("/getUserBalance") |
| | | @ApiOperation(value = "查询当前用户余额") |
| | | public R<String> getUserBalance() { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | AppUser one = appUserService.lambdaQuery().eq(AppUser::getUserId, userId).one(); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | AppUser one = appUserService.lambdaQuery().eq(AppUser::getId, userId).one(); |
| | | return R.ok(one.getBalance().toString()); |
| | | } |
| | | |
| | |
| | | @PostMapping("/saveUserAnswers") |
| | | @ApiOperation(value = "保存计划引导页用户的答案", tags = {"用户端-计划引导相关接口"}) |
| | | public R<?> saveUserAnswers(@Validated @RequestBody UserAnswerDTO dto) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | appUserService.saveUserAnswers(dto); |
| | | return R.ok(); |
| | | } |
| | |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.system.api.domain.AppUser; |
| | | import com.xinquan.system.api.domain.AppUserCourse; |
| | |
| | | import com.xinquan.user.service.AppUserCourseService; |
| | | import com.xinquan.user.service.AppUserService; |
| | | import io.swagger.models.auth.In; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private AppUserService appUserService; |
| | | @Resource |
| | | private AppUserCourseService appUserCourseService; |
| | | /** |
| | | * 远程调用 购买课程后 增加课程与用户关系表 |
| | | * |
| | | * @return 用户信息 |
| | | * @see AppUserVO |
| | | */ |
| | | @GetMapping("/addAppUserCourse/{courseId}/{appUserId}/{orderId}/{giftFlag}") |
| | | public R addAppUserCourse(@PathVariable("courseId") Long courseId, |
| | | @PathVariable("appUserId") Long appUserId, |
| | | @PathVariable("orderId") Long orderId, |
| | | @PathVariable("giftFlag") Integer giftFlag |
| | | ) { |
| | | AppUserCourse one = appUserCourseService.lambdaQuery().eq(AppUserCourse::getCourseId, courseId) |
| | | .eq(AppUserCourse::getAppUserId, appUserId).one(); |
| | | |
| | | |
| | | if (one==null){ |
| | | one = new AppUserCourse(); |
| | | one.setAppUserId(appUserId); |
| | | one.setCourseId(courseId); |
| | | one.setGiftFlag(giftFlag); |
| | | one.setOrderId(orderId); |
| | | one.setCreateTime(LocalDateTime.now()); |
| | | appUserCourseService.save(one); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 远程调用 根据课程id 查询拥有课程的用户 |
| | |
| | | public R<List<AppUser>> getUserByCourseId(@PathVariable("courseId") Long courseId) { |
| | | List<Long> collect = appUserCourseService.lambdaQuery().eq(AppUserCourse::getCourseId, courseId).list() |
| | | .stream().map(AppUserCourse::getAppUserId).collect(Collectors.toList()); |
| | | if (collect.isEmpty())collect.add(-1L); |
| | | // 批量查询用户头像 |
| | | List<AppUser> collect1 = appUserService.lambdaQuery().in(!collect.isEmpty(), AppUser::getId, collect).list(); |
| | | return R.ok(collect1); |
| | | } |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | /** |
| | | * 远程调用 查询当前登录用户已购买课程 |
| | | * |
| | | * @return 用户信息 |
| | | * @see AppUserVO |
| | | */ |
| | | @GetMapping("/getPayCourse/{pageCurr}/{pageSize}") |
| | | @GetMapping("/getPayCourse/{pageCurr}/{pageSize}/{id}") |
| | | public R<PageDTO<AppUserCourse>> getPayCourse(@PathVariable("pageCurr")Integer pageCurr |
| | | ,@PathVariable("pageSize")Integer pageSize) { |
| | | ,@PathVariable("pageSize")Integer pageSize,@PathVariable("id")String id) { |
| | | Page<AppUserCourse> page = appUserCourseService.lambdaQuery() |
| | | .eq(AppUserCourse::getCourseId, SecurityUtils.getUserId()) |
| | | .eq(AppUserCourse::getCourseId, id) |
| | | .orderByDesc(AppUserCourse::getCreateTime) |
| | | .page(new Page<>(pageCurr, pageSize)); |
| | | if (CollUtils.isEmpty(page.getRecords())) { |
| | |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.core.web.domain.BaseModel; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.system.api.RemoteUserService; |
| | | import com.xinquan.system.api.domain.*; |
| | | import com.xinquan.system.api.domain.vo.AppUserEnergyRecordVO; |
| | | import com.xinquan.system.api.domain.vo.WateringVO; |
| | | import com.xinquan.system.api.feignClient.SysUserClient; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.user.api.domain.dto.UserEnergyDTO; |
| | | import com.xinquan.user.api.domain.dto.UserExchangeRecordDTO; |
| | | import com.xinquan.user.domain.vo.EnergyVO; |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | private PrizeService prizeService; |
| | | @Resource |
| | | private PrizeRedemptionRecordService prizeRedemptionRecordService; |
| | | @Resource |
| | | private RemoteUserService remoteUserService; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | @PostMapping("/getUserTree") |
| | | @ApiOperation(value = "获取用户树苗",tags = "树苗打卡站") |
| | | public R<AppUserTree> getUserTree() { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | AppUser byId = appUserService.getById(userId); |
| | | byId.setIsFirst(2); |
| | | appUserService.updateById(byId); |
| | |
| | | appUserTree.setSowAgain(2); |
| | | appUserTree.setCreateTime(LocalDateTime.now()); |
| | | // 如果用户的签到时间是今天 那么修改为已签到 |
| | | if (byId.getSignTime().toLocalDate().equals(LocalDateTime.now().toLocalDate())){ |
| | | if (byId.getSignTime()!=null && byId.getSignTime().toLocalDate().equals(LocalDateTime.now().toLocalDate())){ |
| | | appUserTree.setIsSign(1); |
| | | }else{ |
| | | appUserTree.setIsSign(2); |
| | |
| | | appUserTree.setTaskOne(2); |
| | | appUserTree.setTaskTwo(2); |
| | | } |
| | | appUserTree.setEnergyValue(byId.getEnergyValue()); |
| | | appUserTree.setNextLevel(1000); |
| | | appUserTreeService.save(appUserTree); |
| | | return R.ok(appUserTree); |
| | |
| | | one.setTaskTwo(2); |
| | | } |
| | | // 如果用户的签到时间是今天 那么修改为已签到 |
| | | if (byId.getSignTime().toLocalDate().equals(LocalDateTime.now().toLocalDate())){ |
| | | if (byId.getSignTime()!=null&&byId.getSignTime().toLocalDate().equals(LocalDateTime.now().toLocalDate())){ |
| | | one.setIsSign(1); |
| | | }else{ |
| | | one.setIsSign(2); |
| | |
| | | one.setNextLevel(2400); |
| | | break; |
| | | } |
| | | one.setEnergyValue(byId.getEnergyValue()); |
| | | return R.ok(one); |
| | | |
| | | } |
| | | } |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @PostMapping("/restart") |
| | | @ApiOperation(value = "重新播种",tags = "树苗打卡站") |
| | | public R restart() { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | if(userId ==null || userId == 0)return R.tokenError("登录失效"); |
| | | AppUserTree one = appUserTreeService.lambdaQuery().eq(AppUserTree::getAppUserId, userId) |
| | | .eq(AppUserTree::getSowAgain,2).one(); |
| | | one.setSowAgain(1); |
| | |
| | | public R<WateringVO> watering() { |
| | | WateringVO wateringVO = new WateringVO(); |
| | | |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | AppUser byId = appUserService.getById(userId); |
| | | if (byId.getEnergyValue() == 0){ |
| | | return R.energyValueError("能量值不足"); |
| | | |
| | | } |
| | | AppUserTree one = appUserTreeService.lambdaQuery().eq(AppUserTree::getAppUserId, userId) |
| | | .eq(AppUserTree::getSowAgain,2).one(); |
| | | Integer currentEnergyValue = byId.getEnergyValue(); |
| | | byId.setEnergyValue(0); |
| | | byId.setTotalEnergyValue(byId.getTotalEnergyValue()+currentEnergyValue); |
| | | appUserService.updateById(byId); |
| | | List<TreeLevelSetting> data = sysUserClient.getTreeGroup().getData(); |
| | | // 判断能否升级 |
| | | int temp = 0; |
| | | switch (one.getTreeLevelType()){ |
| | | case 1: |
| | | temp=1000; |
| | | break; |
| | | case 2: |
| | | temp=1000; |
| | | break; |
| | | case 3: |
| | | temp=1000; |
| | | break; |
| | | case 4: |
| | | temp=1000; |
| | | break; |
| | | case 5: |
| | | temp=2000; |
| | | break; |
| | | case 6: |
| | | temp=2000; |
| | | break; |
| | | case 7: |
| | | temp=2000; |
| | | break; |
| | | case 8: |
| | | temp=2000; |
| | | break; |
| | | case 9: |
| | | temp=2400; |
| | | break; |
| | | case 10: |
| | | temp=2400; |
| | | break; |
| | | for (TreeLevelSetting datum : data) { |
| | | switch (datum.getTreeLevelType()){ |
| | | case 1: |
| | | temp=datum.getGrowthValue(); |
| | | break; |
| | | case 2: |
| | | temp=datum.getGrowthValue(); |
| | | break; |
| | | case 3: |
| | | temp=datum.getGrowthValue(); |
| | | break; |
| | | case 4: |
| | | temp=datum.getGrowthValue(); |
| | | break; |
| | | case 5: |
| | | temp=datum.getGrowthValue(); |
| | | break; |
| | | case 6: |
| | | temp=datum.getGrowthValue(); |
| | | break; |
| | | case 7: |
| | | temp=datum.getGrowthValue(); |
| | | break; |
| | | case 8: |
| | | temp=datum.getGrowthValue(); |
| | | break; |
| | | case 9: |
| | | temp=datum.getGrowthValue(); |
| | | break; |
| | | case 10: |
| | | temp=datum.getGrowthValue(); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | wateringVO.setNextLevel(temp); |
| | | // 升级阈值 |
| | | if (one.getGrowthValue()+currentEnergyValue>=temp){ |
| | | // 升级咯 如果当前等级已经为10级 |
| | | if (one.getTreeLevelType()==10){ |
| | | one.setGrowthValue(one.getGrowthValue()+currentEnergyValue); |
| | | appUserTreeService.updateById(one); |
| | | wateringVO.setIsNext(false); |
| | | wateringVO.setNextLevel(2400); |
| | | int a= 0; |
| | | for (TreeLevelSetting datum : data) { |
| | | if (datum.getTreeLevelType()==10){ |
| | | a = datum.getGrowthValue(); |
| | | } |
| | | } |
| | | wateringVO.setNextLevel(a); |
| | | }else{ |
| | | |
| | | // 将当前成长值更新 |
| | | one.setGrowthValue(one.getGrowthValue()+currentEnergyValue-temp); |
| | | // 升级 |
| | | one.setTreeLevelType(one.getTreeLevelType()+1); |
| | | one.setGrowthValue(one.getGrowthValue()+currentEnergyValue-temp); |
| | | appUserTreeService.updateById(one); |
| | | switch (one.getTreeLevelType()+1){ |
| | | case 2: |
| | | temp=1000; |
| | |
| | | } |
| | | wateringVO.setNextLevel(temp); |
| | | wateringVO.setIsNext(true); |
| | | // 升级了 使用浇水后的能量值减去升级阈值 |
| | | wateringVO.setGrowthValue(one.getGrowthValue()); |
| | | } |
| | | }else{ |
| | | // 不能升级 |
| | | one.setGrowthValue(one.getGrowthValue()+currentEnergyValue-temp); |
| | | appUserTreeService.updateById(one); |
| | | wateringVO.setIsNext(false); |
| | | wateringVO.setGrowthValue(one.getGrowthValue()+currentEnergyValue); |
| | | // 不能升级 |
| | | one.setGrowthValue(one.getGrowthValue()+currentEnergyValue); |
| | | appUserTreeService.updateById(one); |
| | | } |
| | | wateringVO.setGrowthValue(one.getGrowthValue()); |
| | | appUserTreeService.updateById(one); |
| | | return R.ok(wateringVO); |
| | | } |
| | | @PostMapping("/sign") |
| | | @ApiOperation(value = "签到",tags = "树苗打卡站") |
| | | public R sign() { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | // 给用户加10能量 |
| | | AppUser byId = appUserService.getById(userId); |
| | | byId.setTotalEnergyValue(byId.getTotalEnergyValue()+10); |
| | | byId.setEnergyValue(byId.getEnergyValue()+10); |
| | | byId.setSignTime(LocalDateTime.now()); |
| | | appUserService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | |
| | | @PostMapping("/isFirst") |
| | | @ApiOperation(value = "是否首次进入 ",tags = "树苗打卡站") |
| | | public R isFirst() { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | if(userId ==null || userId == 0)return R.tokenError("登录失效"); |
| | | AppUser byId = appUserService.getById(userId); |
| | | if (byId.getIsFirst() == 1){ |
| | | byId.setIsFirst(2); |
| | |
| | | return R.ok(empty); |
| | | } |
| | | PageDTO<AppUserEnergyRecordVO> appUserEnergyRecordVOPageDTO = PageDTO.of(page, AppUserEnergyRecordVO.class); |
| | | for (AppUserEnergyRecordVO appUserEnergyRecordVO : appUserEnergyRecordVOPageDTO.getList()) { |
| | | AppUser byId = appUserService.getById(appUserEnergyRecordVO.getAppUserId()); |
| | | appUserEnergyRecordVO.setPhone(byId.getNickname()); |
| | | appUserEnergyRecordVO.setName(byId.getCellPhone()); |
| | | if (appUserEnergyRecordVO.getUpdateId()!=null){ |
| | | SysUser data = remoteUserService.getSysUserById(appUserEnergyRecordVO.getUpdateId() + "").getData(); |
| | | if (data!=null){ |
| | | appUserEnergyRecordVO.setPhone(data.getUserName()); |
| | | appUserEnergyRecordVO.setName(data.getNickName()); |
| | | } |
| | | |
| | | } |
| | | } |
| | | energyVO.setList(appUserEnergyRecordVOPageDTO.getList()); |
| | | return R.ok(appUserEnergyRecordVOPageDTO); |
| | | } |
| | | @PostMapping("/userExchangeRecordList") |
| | | @ApiOperation(value = "用户详情-兑换记录 ",tags = "管理后台-用户管理") |
| | | public R<PageDTO<ExchangeRecordVO>> userExchangeRecordList(@RequestBody UserExchangeRecordDTO dto) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | Page<PrizeRedemptionRecord> page = prizeRedemptionRecordService.lambdaQuery() |
| | | .eq(PrizeRedemptionRecord::getAppUserId, userId) |
| | | .eq(PrizeRedemptionRecord::getAppUserId, dto.getUid()) |
| | | .orderByDesc(BaseModel::getCreateTime).page(new Page<>(dto.getPageCurr(), dto.getPageSize())); |
| | | if (CollUtils.isEmpty(page.getRecords())){ |
| | | PageDTO<ExchangeRecordVO> empty = PageDTO.empty(page); |
| | |
| | | @ApiImplicitParam(name = "pageCurr", value = "分页参数,当前页码", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "分页参数,每页数量", dataType = "Integer", required = true) |
| | | }) |
| | | public R<PageDTO<AppUserEnergyRecordVO>> energyDetail(Integer state,Integer pageCurr,Integer pageSize) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | public R<List<AppUserEnergyRecordVO>> energyDetail(Integer state,Integer pageCurr,Integer pageSize) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | EnergyVO energyVO = new EnergyVO(); |
| | | energyVO.setEnergyTotal(appUserService.getById(userId).getTotalEnergyValue()); |
| | | LambdaQueryWrapper<AppUserEnergyRecord> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | |
| | | if (CollUtils.isEmpty(page.getRecords())){ |
| | | PageDTO<AppUserEnergyRecordVO> empty = PageDTO.empty(page); |
| | | energyVO.setList(new ArrayList<AppUserEnergyRecordVO>()); |
| | | return R.ok(empty); |
| | | return R.ok(new ArrayList<>()); |
| | | } |
| | | PageDTO<AppUserEnergyRecordVO> appUserEnergyRecordVOPageDTO = PageDTO.of(page, AppUserEnergyRecordVO.class); |
| | | energyVO.setList(appUserEnergyRecordVOPageDTO.getList()); |
| | | return R.ok(appUserEnergyRecordVOPageDTO); |
| | | return R.ok(appUserEnergyRecordVOPageDTO.getList()); |
| | | } |
| | | @PostMapping("/goodsList") |
| | | @ApiOperation(value = "能量兑换礼物列表 ",tags = "树苗打卡站") |
| | |
| | | @ApiImplicitParam(name = "pageCurr", value = "分页参数,当前页码", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "分页参数,每页数量", dataType = "Integer", required = true) |
| | | }) |
| | | public R<PageDTO<Prize>> goodsList(Integer pageCurr,Integer pageSize) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | public R<List<Prize>> goodsList(Integer pageCurr,Integer pageSize) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | Page<Prize> page = prizeService.lambdaQuery() |
| | | .eq(Prize::getStatus, 1) |
| | | .orderByDesc(BaseModel::getCreateTime).page(new Page<>(pageCurr, pageSize)); |
| | | |
| | | if (CollUtils.isEmpty(page.getRecords())){ |
| | | PageDTO<Prize> empty = PageDTO.empty(page); |
| | | return R.ok(empty); |
| | | return R.ok(new ArrayList<>()); |
| | | } |
| | | for (Prize record : page.getRecords()) { |
| | | PrizeRedemptionRecord one = prizeRedemptionRecordService.lambdaQuery() |
| | |
| | | .eq(PrizeRedemptionRecord::getAppUserId, userId).one(); |
| | | if (one == null){ |
| | | record.setReceiveStatus(2); |
| | | }else{ |
| | | record.setReceiveStatus(1); |
| | | } |
| | | } |
| | | PageDTO<Prize> res = PageDTO.of(page, Prize.class); |
| | | return R.ok(res); |
| | | return R.ok(res.getList()); |
| | | } |
| | | @PostMapping("/exchange") |
| | | @ApiOperation(value = "兑换奖品 ",tags = "树苗打卡站") |
| | |
| | | @ApiImplicitParam(name = "prizeId", value = "奖品id", dataType = "Long", required = true), |
| | | }) |
| | | public R exchange(Long prizeId) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | AppUser byId1 = appUserService.getById(userId); |
| | | Prize byId = prizeService.getById(prizeId); |
| | | if (byId1.getTotalEnergyValue()<=byId.getEnergyValue()){ |
| | |
| | | prizeRedemptionRecord.setCode(code); |
| | | prizeRedemptionRecordService.save(prizeRedemptionRecord); |
| | | // 随机生成6位纯数字验证码 |
| | | return R.ok(); |
| | | return R.ok(code); |
| | | } |
| | | @PostMapping("/exchangeRecordList") |
| | | @ApiOperation(value = "兑换记录 ",tags = "树苗打卡站") |
| | |
| | | @ApiImplicitParam(name = "pageSize", value = "分页参数,每页数量", dataType = "Integer", required = true) |
| | | }) |
| | | public R<List<ExchangeRecordVO>> exchangeRecordList(Integer pageCurr, Integer pageSize) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | Page<PrizeRedemptionRecord> page = prizeRedemptionRecordService.lambdaQuery() |
| | | .eq(PrizeRedemptionRecord::getAppUserId, userId) |
| | | .orderByDesc(BaseModel::getCreateTime).page(new Page<>(pageCurr, pageSize)); |
| | |
| | | PageDTO<ExchangeRecordVO> res = PageDTO.of(page, ExchangeRecordVO.class); |
| | | for (ExchangeRecordVO record : res.getList()) { |
| | | Prize temp = prizeService.lambdaQuery() |
| | | .eq(Prize::getId, record.getId()).one(); |
| | | .eq(Prize::getId, record.getPrizeId()).one(); |
| | | if (temp != null){ |
| | | record.setName(temp.getName()); |
| | | record.setCoverUrl(temp.getCoverUrl()); |
| | |
| | | import com.xinquan.common.core.web.domain.BaseModel; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.course.api.domain.OrderCourseVO; |
| | | import com.xinquan.course.api.feign.RemoteCourseService; |
| | | import com.xinquan.meditation.api.domain.Meditation; |
| | | import com.xinquan.meditation.api.feign.RemoteMeditationService; |
| | | import com.xinquan.system.api.domain.AppUser; |
| | | import com.xinquan.system.api.domain.AppUserTree; |
| | | import com.xinquan.system.api.domain.AppUserViewingHistory; |
| | | import com.xinquan.system.api.domain.vo.AppUserVO; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.user.api.feign.RemoteAppUserService; |
| | | import com.xinquan.user.service.AppUserService; |
| | | import com.xinquan.user.service.AppUserTreeService; |
| | | import com.xinquan.user.service.AppUserViewingHistoryService; |
| | |
| | | import io.swagger.models.auth.In; |
| | | import lombok.Data; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private AppUserTreeService appUserTreeService; |
| | | @Resource |
| | | private AppUserService appUserService; |
| | | |
| | | |
| | | @Resource |
| | | private RemoteMeditationService remoteMeditationService; |
| | | @Resource |
| | | private RemoteCourseService courseUserFavoriteService; |
| | | @Resource |
| | | private RemoteCourseService remoteCourseService; |
| | | private final RemoteAppUserService remoteAppUserService; |
| | | @PostMapping("/lookHistory") |
| | | @ApiOperation(value = "观看历史") |
| | | @ApiImplicitParams({ |
| | |
| | | @ApiImplicitParam(name = "pageCurr", value = "分页参数,当前页码", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "分页参数,每页数量", dataType = "Integer", required = true) |
| | | }) |
| | | public R<PageDTO<OrderCourseVO>> lookHistory(Integer state, Integer pageCurr, Integer pageSize) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | public R<List<OrderCourseVO>> lookHistory(Integer state, Integer pageCurr, Integer pageSize) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | List<OrderCourseVO> orderCourseVOS = new ArrayList<>(); |
| | | |
| | | switch (state){ |
| | | case 1: |
| | | List<Long> collect1 = appUserViewingHistoryService.lambdaQuery() |
| | | .eq(AppUserViewingHistory::getAppUserId, userId) |
| | | .eq(AppUserViewingHistory::getViewingType, 1).list() |
| | | .stream().map(AppUserViewingHistory::getBizId).collect(Collectors.toList()); |
| | | List<Long> collect2 = collect1.stream().distinct().collect(Collectors.toList()); |
| | | StringBuilder temp = new StringBuilder(); |
| | | if (collect1.isEmpty()){ |
| | | temp=temp.append("-1"); |
| | | }else{ |
| | | for (Long l : collect2) { |
| | | temp.append(l).append(","); |
| | | } |
| | | temp.deleteCharAt(temp.length() - 1); |
| | | } |
| | | Page<Meditation> data = remoteMeditationService.getMeditationByIds(pageCurr,pageSize,temp.toString()).getData(); |
| | | |
| | | for (Meditation meditation : data.getRecords()) { |
| | | OrderCourseVO orderCourseVO = new OrderCourseVO(); |
| | | orderCourseVO.setBusinessId(meditation.getId()); |
| | | orderCourseVO.setCourseTitle(meditation.getMeditationTitle()); |
| | | orderCourseVO.setDescription(meditation.getDetailDescription()); |
| | | orderCourseVO.setChargeType(meditation.getChargeType()); |
| | | orderCourseVO.setGeneralPrice(meditation.getGeneralPrice()); |
| | | orderCourseVO.setIosPrice(meditation.getIosPrice()); |
| | | orderCourseVO.setCoverUrl(meditation.getCoverUrl()); |
| | | orderCourseVO.setCount(meditation.getRealLearnedNum()+meditation.getVirtualLearnedNum()); |
| | | orderCourseVOS.add(orderCourseVO); |
| | | } |
| | | break; |
| | | case 2: |
| | | |
| | | List<Long> collect3 = appUserViewingHistoryService.lambdaQuery() |
| | | .eq(AppUserViewingHistory::getAppUserId, userId) |
| | | .eq(AppUserViewingHistory::getViewingType, 2).list() |
| | | .stream().map(AppUserViewingHistory::getBizId).collect(Collectors.toList()); |
| | | List<Long> collect4 = collect3.stream().distinct().collect(Collectors.toList()); |
| | | StringBuilder temp1 = new StringBuilder(); |
| | | if (collect4.isEmpty()){ |
| | | temp1=temp1.append("-1"); |
| | | }else{ |
| | | for (Long l : collect4) { |
| | | temp1.append(l).append(","); |
| | | } |
| | | temp1.deleteCharAt(temp1.length() - 1); |
| | | } |
| | | Page<Course> data2 = remoteCourseService.getCourseByIds(pageCurr,pageSize,temp1.toString()).getData(); |
| | | for (Course record : data2.getRecords()) { |
| | | OrderCourseVO orderCourseVO = new OrderCourseVO(); |
| | | orderCourseVO.setBusinessId(record.getId()); |
| | | orderCourseVO.setCourseTitle(record.getCourseTitle()); |
| | | orderCourseVO.setDescription(record.getDescription()); |
| | | orderCourseVO.setChargeType(record.getChargeType()); |
| | | orderCourseVO.setGeneralPrice(record.getGeneralPrice()); |
| | | orderCourseVO.setIosPrice(record.getIosPrice()); |
| | | orderCourseVO.setCoverUrl(record.getCoverUrl()); |
| | | List<AppUser> data1 = remoteAppUserService.getUserByCourseId(record.getId()).getData(); |
| | | orderCourseVO.setCount(data1.size()); |
| | | orderCourseVOS.add(orderCourseVO); |
| | | } |
| | | break; |
| | | } |
| | | return R.ok(); |
| | | return R.ok(orderCourseVOS); |
| | | } |
| | | /** |
| | | * 记录用户观看记录 |
| | | * |
| | | * @param bizId 业务id |
| | | * @param viewingType 观看类型 1=疗愈 2=课程 |
| | | */ |
| | | @PostMapping("/saveViewingHistory") |
| | | @ApiOperation(value = "记录用户观看冥想记录", tags = {"用户端-用户相关接口"}) |
| | |
| | | @ApiImplicitParam(name = "timeLook", value = "播放时长单位秒", dataType = "Integer", required = true) |
| | | }) |
| | | public R<?> saveViewingRecord(@RequestParam("id") Long id, |
| | | @RequestParam("timeLook") Integer timeLook) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | @RequestParam("timeLook") Integer timeLook |
| | | ) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | AppUser byId = appUserService.getById(userId); |
| | | |
| | | AppUserViewingHistory appUserViewingHistory = new AppUserViewingHistory(); |
| | | appUserViewingHistory.setAppUserId(userId); |
| | | appUserViewingHistory.setBizId(id); |
| | |
| | | @RequestParam("secondLook") Integer secondLook, |
| | | @RequestParam("isOver") Integer isOver |
| | | ) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | AppUserViewingHistory one = appUserViewingHistoryService.lambdaQuery() |
| | | .eq(AppUserViewingHistory::getAppUserId, userId) |
| | | .eq(AppUserViewingHistory::getViewingType, 2) |
| | |
| | | } |
| | | @PostMapping("/getCourseStudyHistory") |
| | | public R<AppUserViewingHistory> getCourseStudyHistory(@RequestParam("chapterId") Long chapterId) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | AppUserViewingHistory one = appUserViewingHistoryService.lambdaQuery() |
| | | .eq(AppUserViewingHistory::getAppUserId, userId) |
| | | .eq(AppUserViewingHistory::getViewingType, 2) |
| | |
| | | // @RequestParam(value = "secondLook") Integer secondLook, |
| | | // @RequestParam(value = "isOver") Integer isOver |
| | | // ) { |
| | | // Long userId = SecurityUtils.getUserId(); |
| | | // if (userId == 0)return R.tokenError("登录失效"); |
| | | // Long userId = tokenService.getLoginUser().getUserid(); |
| | | // if(userId ==null || userId == 0)return R.tokenError("登录失效"); |
| | | // AppUserViewingHistory one = appUserViewingHistoryService.lambdaQuery() |
| | | // .eq(AppUserViewingHistory::getAppUserId, userId) |
| | | // .eq(AppUserViewingHistory::getViewingType, 2) |
| | |
| | | package com.xinquan.user.controller.client; |
| | | |
| | | |
| | | import com.alibaba.nacos.common.utils.UuidUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.core.web.domain.BaseModel; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.course.api.feign.RemoteCourseService; |
| | | import com.xinquan.order.api.domain.Order; |
| | | import com.xinquan.order.api.feign.RemoteOrderService; |
| | | import com.xinquan.system.api.domain.AppUser; |
| | |
| | | import com.xinquan.system.api.domain.vo.InviteRankListVO; |
| | | import com.xinquan.system.api.domain.vo.OrderDetailVO; |
| | | import com.xinquan.system.api.domain.vo.OrderListVO; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.user.api.domain.dto.UserBalanceDetailDTO; |
| | | import com.xinquan.user.api.domain.dto.UserChildDTO; |
| | | import com.xinquan.user.service.AppUserService; |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.expression.spel.ast.OpNE; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private AppUserWalletRecordService appUserWalletRecordService; |
| | | @Resource |
| | | private RemoteOrderService remoteOrderService; |
| | | @Resource |
| | | private RemoteCourseService remoteCourseService; |
| | | // 用户获得分佣收益 新增一条余额明细记录 |
| | | @PostMapping("/addBalanceRecord") |
| | | public R addBalanceRecord(@RequestBody AppUserWalletRecord appUserWalletRecord) { |
| | | appUserWalletRecordService.save(appUserWalletRecord); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping("/childUserList") |
| | | @ApiOperation(value = "用户详情-下级用户列表",tags = "管理后台-用户管理") |
| | | public R<PageDTO<AppUser>> childUserList(@RequestBody UserChildDTO dto) { |
| | |
| | | } |
| | | return R.ok(PageDTO.of(page, OrderListVO.class)); |
| | | } |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | /** |
| | | * 爱心助力榜单-分页 |
| | | * |
| | |
| | | @ApiImplicitParam(value = "分页参数,每页数量", name = "pageSize", required = true, dataType = "Integer") |
| | | }) |
| | | public R<PageDTO<OrderListVO>> balanceList(Integer state,Integer pageCurr, Integer pageSize) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | LambdaQueryWrapper<AppUserWalletRecord> appUserWalletRecordLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if (state!=1){ |
| | | appUserWalletRecordLambdaQueryWrapper.eq(AppUserWalletRecord::getChangeType, state); |
| | | appUserWalletRecordLambdaQueryWrapper.eq(AppUserWalletRecord::getChangeType, state-1); |
| | | } |
| | | appUserWalletRecordLambdaQueryWrapper.eq(AppUserWalletRecord::getAppUserId, userId); |
| | | appUserWalletRecordLambdaQueryWrapper.orderByDesc(BaseModel::getCreateTime); |
| | |
| | | @ApiImplicitParam(name = "id", value = "id", dataType = "Long", required = true), |
| | | }) |
| | | public R<OrderDetailVO> balanceDetail(Long id) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | OrderDetailVO orderDetailVO = new OrderDetailVO(); |
| | | AppUserWalletRecord byId = walletRecordService.getById(id); |
| | | if (byId.getOrderId()!=null){ |
| | |
| | | orderDetailVO.setChangeType(byId.getChangeType()); |
| | | orderDetailVO.setPaymentTime(byId1.getUpdateTime()); |
| | | return R.ok(new OrderDetailVO()); |
| | | |
| | | }else if (byId.getReason().contains("课程")){ |
| | | Order data = remoteOrderService.getOrderById(byId.getOrderId()).getData(); |
| | | if (data!=null){ |
| | | Course data1 = remoteCourseService.getCourseById(data.getBusinessId()).getData(); |
| | | orderDetailVO.setType("课程购买"); |
| | | orderDetailVO.setPayOrderNo(data.getPayOrderNo()); |
| | | orderDetailVO.setAmount(data.getRealPayAmount()); |
| | | orderDetailVO.setChangeType(byId.getChangeType()); |
| | | orderDetailVO.setPaymentTime(data.getPaymentTime()); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(orderDetailVO); |
| | |
| | | package com.xinquan.user.controller.client; |
| | | |
| | | |
| | | import com.alibaba.fastjson2.util.UUIDUtils; |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.alibaba.nacos.common.utils.UuidUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.datascope.annotation.DataScope; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.common.core.utils.WebUtils; |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.log.enums.BusinessType; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.order.api.domain.Order; |
| | | import com.xinquan.user.api.domain.dto.OrderListDTO; |
| | | import com.xinquan.system.api.domain.AppUser; |
| | | import com.xinquan.system.api.domain.AppUserBank; |
| | | import com.xinquan.system.api.domain.AppUserWithdraw; |
| | | import com.xinquan.system.api.domain.vo.UpdateAppUserDTO; |
| | | import com.xinquan.system.api.domain.vo.WalletVO; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.user.domain.export.WithdrawExport; |
| | | import com.xinquan.user.service.AppUserBankService; |
| | | import com.xinquan.user.service.AppUserService; |
| | | import com.xinquan.user.service.AppUserWithdrawService; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | 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 org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private AppUserWithdrawService withdrawService; |
| | | @Resource |
| | | private AppUserBankService appUserBankService; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | @PostMapping("/withdrawList") |
| | | @ApiOperation(value = "提现列表-分页", tags = {"管理后台=提现管理"}) |
| | | public R<PageDTO<AppUserWithdraw>> withdrawList(@RequestBody OrderListDTO courseDTO) { |
| | | LambdaQueryWrapper<AppUserWithdraw> wrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.hasLength(courseDTO.getBuyContent())){ |
| | | wrapper.like(AppUserWithdraw::getCode,courseDTO.getBuyContent()); |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getUserNameOrPhone())){ |
| | | List<Long> collect = appUserService.lambdaQuery().like(AppUser::getCellPhone, courseDTO.getUserNameOrPhone()) |
| | | .list().stream().map(AppUser::getId) |
| | | .collect(Collectors.toList()); |
| | | if (collect.isEmpty())collect.add(-1L); |
| | | wrapper.in(AppUserWithdraw::getAppUserId,collect); |
| | | } |
| | | if (courseDTO.getPaymentStatus()!=null && courseDTO.getPaymentStatus()==1){ |
| | | wrapper.eq(AppUserWithdraw::getId,0); |
| | | }else if (courseDTO.getPaymentStatus()!=null &&(courseDTO.getPaymentStatus()==2 || courseDTO.getPaymentStatus()==3)){ |
| | | List<Integer> integers = new ArrayList<>(); |
| | | integers.add(1); |
| | | integers.add(2); |
| | | wrapper.in(AppUserWithdraw::getWithdrawStatus,integers); |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getTime())){ |
| | | String startTime =null; |
| | | String endTime =null; |
| | | String[] split = courseDTO.getTime().split(" - "); |
| | | startTime = split[0]+"00:00:00"; |
| | | endTime = split[1]+"23:59:59"; |
| | | wrapper.between(AppUserWithdraw::getWithdrawTime,startTime,endTime); |
| | | } |
| | | Page<AppUserWithdraw> list = withdrawService.page(new Page<>(courseDTO.getPageCurr(), courseDTO.getPageSize()), wrapper); |
| | | if (CollUtils.isEmpty(list.getRecords())) { |
| | | return R.ok(PageDTO.empty(list)); |
| | | } |
| | | for (AppUserWithdraw record : list.getRecords()) { |
| | | record.setUid(record.getId()+""); |
| | | AppUser byId = appUserService.getById(record.getAppUserId()); |
| | | if(byId!=null){ |
| | | record.setUserName(byId.getNickname()); |
| | | record.setCellPhone(byId.getCellPhone()); |
| | | record.setAvatar(byId.getAvatar()); |
| | | } |
| | | } |
| | | return R.ok(PageDTO.of(list, AppUserWithdraw.class)); |
| | | } |
| | | @ApiOperation(value = "提现管理导出", tags = {"管理后台-提现管理"}) |
| | | @PutMapping("/export") |
| | | public void export(@RequestBody OrderListDTO courseDTO) |
| | | { |
| | | LambdaQueryWrapper<AppUserWithdraw> wrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.hasLength(courseDTO.getIds())){ |
| | | wrapper.in(AppUserWithdraw::getId, Arrays.asList(courseDTO.getIds().split(","))); |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getBuyContent())){ |
| | | wrapper.like(AppUserWithdraw::getCode,courseDTO.getBuyContent()); |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getUserNameOrPhone())){ |
| | | List<Long> collect = appUserService.lambdaQuery().like(AppUser::getCellPhone, courseDTO.getUserNameOrPhone()) |
| | | .list().stream().map(AppUser::getId) |
| | | .collect(Collectors.toList()); |
| | | if (collect.isEmpty())collect.add(-1L); |
| | | wrapper.in(AppUserWithdraw::getAppUserId,collect); |
| | | } |
| | | if (courseDTO.getPaymentStatus()!=null && courseDTO.getPaymentStatus()==1){ |
| | | wrapper.eq(AppUserWithdraw::getId,0); |
| | | }else if (courseDTO.getPaymentStatus()!=null &&(courseDTO.getPaymentStatus()==2 || courseDTO.getPaymentStatus()==3)){ |
| | | List<Integer> integers = new ArrayList<>(); |
| | | integers.add(1); |
| | | integers.add(2); |
| | | wrapper.in(AppUserWithdraw::getWithdrawStatus,integers); |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getTime())){ |
| | | String startTime =null; |
| | | String endTime =null; |
| | | String[] split = courseDTO.getTime().split(" - "); |
| | | startTime = split[0]+"00:00:00"; |
| | | endTime = split[1]+"23:59:59"; |
| | | wrapper.between(AppUserWithdraw::getWithdrawTime,startTime,endTime); |
| | | } |
| | | List<AppUserWithdraw> list = withdrawService.list(wrapper); |
| | | List<WithdrawExport> withdrawExports = new ArrayList<>(); |
| | | |
| | | for (AppUserWithdraw record : list) { |
| | | WithdrawExport withdrawExport = new WithdrawExport(); |
| | | record.setUid(record.getId()+""); |
| | | AppUser byId = appUserService.getById(record.getAppUserId()); |
| | | if(byId!=null){ |
| | | withdrawExport.setUserName(byId.getNickname()); |
| | | withdrawExport.setCellphone(byId.getCellPhone()); |
| | | } |
| | | withdrawExport.setCode(record.getCode()); |
| | | |
| | | withdrawExport.setAmount("¥"+record.getAmount()+""); |
| | | withdrawExport.setWithdrawType("1"); |
| | | withdrawExport.setWithdrawStatus(record.getWithdrawStatus()+""); |
| | | DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | String format = df.format(record.getCreateTime()); |
| | | withdrawExport.setCreateTime(format); |
| | | withdrawExports.add(withdrawExport); |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), WithdrawExport.class, withdrawExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("提现管理导出.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | @PostMapping("/withdrawInfo") |
| | | @ApiOperation(value = "提现列表-查看详情", tags = {"管理后台-提现管理"}) |
| | | public R<AppUserWithdraw> withdrawList(String uid){ |
| | | AppUserWithdraw byId = withdrawService.getById(uid); |
| | | return R.ok(byId); |
| | | } |
| | | /** |
| | | * 远程调用获取提现记录 |
| | | */ |
| | | @PostMapping("/getWithdrawList") |
| | | public R<List<AppUserWithdraw>> getWithdraw(@RequestBody OrderListDTO courseDTO) { |
| | | LambdaQueryWrapper<AppUserWithdraw> wrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.hasLength(courseDTO.getBuyContent())){ |
| | | if (!courseDTO.getBuyContent().contains("提现")){ |
| | | wrapper.like(AppUserWithdraw::getCode,courseDTO.getBuyContent()); |
| | | } |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getUserNameOrPhone())){ |
| | | List<Long> collect = appUserService.lambdaQuery().like(AppUser::getCellPhone, courseDTO.getUserNameOrPhone()) |
| | | .list().stream().map(AppUser::getId) |
| | | .collect(Collectors.toList()); |
| | | if (collect.isEmpty())collect.add(-1L); |
| | | wrapper.in(AppUserWithdraw::getAppUserId,collect); |
| | | } |
| | | if (courseDTO.getOrderFrom()!=null && courseDTO.getOrderFrom()!=5){ |
| | | wrapper.eq(AppUserWithdraw::getId,0); |
| | | } |
| | | if (courseDTO.getPayType()!=null && courseDTO.getPayType()!=4){ |
| | | wrapper.eq(AppUserWithdraw::getId,0); |
| | | } |
| | | if (courseDTO.getPaymentStatus()!=null && courseDTO.getPaymentStatus()==1){ |
| | | wrapper.eq(AppUserWithdraw::getId,0); |
| | | }else if (courseDTO.getPaymentStatus()!=null &&(courseDTO.getPaymentStatus()==2 || courseDTO.getPaymentStatus()==3)){ |
| | | List<Integer> integers = new ArrayList<>(); |
| | | integers.add(1); |
| | | integers.add(2); |
| | | wrapper.in(AppUserWithdraw::getWithdrawStatus,integers); |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getTime())){ |
| | | String startTime =null; |
| | | String endTime =null; |
| | | String[] split = courseDTO.getTime().split(" - "); |
| | | startTime = split[0]+"00:00:00"; |
| | | endTime = split[1]+"23:59:59"; |
| | | wrapper.between(AppUserWithdraw::getWithdrawTime,startTime,endTime); |
| | | } |
| | | List<AppUserWithdraw> list = withdrawService.list(wrapper); |
| | | return R.ok(list); |
| | | } |
| | | @PostMapping("/withdraw") |
| | | @ApiOperation(value = "提现", tags = {"钱包"}) |
| | | @ApiImplicitParams({ |
| | |
| | | @ApiImplicitParam(name = "money", value = "提现金额", dataType = "String", required = true) |
| | | }) |
| | | public R withdraw(Long bankId,String money) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | BigDecimal bigDecimal = new BigDecimal(money); |
| | | AppUserWithdraw appUserWithdraw = new AppUserWithdraw(); |
| | | appUserWithdraw.setAppUserId(userId); |
| | |
| | | appUserWithdraw.setWithdrawStatus(0); |
| | | // todo 提现流水号 |
| | | appUserWithdraw.setSerialNo(UuidUtils.generateUuid()); |
| | | appUserWithdraw.setCode(UuidUtils.generateUuid()); |
| | | appUserWithdraw.setWithdrawTime(LocalDateTime.now()); |
| | | appUserWithdraw.setCreateTime(LocalDateTime.now()); |
| | | withdrawService.save(appUserWithdraw); |
| | |
| | | @PostMapping("/addBank") |
| | | @ApiOperation(value = "提现-添加银行卡", tags = {"钱包"}) |
| | | public R wallet(@RequestBody AppUserBank appUserWithdraw) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | |
| | | appUserWithdraw.setAppUserId(userId); |
| | | appUserBankService.save(appUserWithdraw); |
| | | return R.ok(); |
| | |
| | | @PostMapping("/deleteBank") |
| | | @ApiOperation(value = "提现-删除银行卡", tags = {"钱包"}) |
| | | public R deleteBank(Long id) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | if(userId ==null || userId == 0)return R.tokenError("登录失效"); |
| | | appUserBankService.removeById(id); |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/bankList") |
| | | @ApiOperation(value = "提现-获取银行卡列表", tags = {"钱包"}) |
| | | public R<List<AppUserBank>> bankList() { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | if(userId ==null || userId == 0)return R.tokenError("登录失效"); |
| | | List<AppUserBank> list = appUserBankService.lambdaQuery() |
| | | .eq(AppUserBank::getAppUserId, userId).list(); |
| | | return R.ok(list); |
| | |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.core.web.domain.BaseModel; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.meditation.api.feign.RemoteMeditationService; |
| | | import com.xinquan.system.api.domain.AppUser; |
| | | import com.xinquan.system.api.domain.NoticeRecord; |
| | | import com.xinquan.meditation.api.domain.vo.NoticeDetailVO; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.user.service.AppUserService; |
| | | import com.xinquan.user.service.NoticeRecordService; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | 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; |
| | |
| | | @ApiImplicitParam(value = "分页参数,每页数量", name = "pageSize", required = true, dataType = "Integer") |
| | | }) |
| | | public R<PageDTO<NoticeRecord>> noticeList(Integer pageCurr, Integer pageSize) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | if(userId ==null || userId == 0)return R.tokenError("登录失效"); |
| | | Page<NoticeRecord> page = noticeRecordService.lambdaQuery() |
| | | .eq(NoticeRecord::getAppUserId, userId) |
| | | .orderByDesc(BaseModel::getCreateTime) |
| | |
| | | @PostMapping("/noticeDetail") |
| | | @ApiOperation(value = "系统消息列表-查看详情",tags = "系统消息") |
| | | public R<NoticeDetailVO> wallet(Long id) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | NoticeRecord noticeRecord = noticeRecordService.getById(id); |
| | | // 设置为已读 |
| | | noticeRecord.setReadStatus(2); |
| | |
| | | } |
| | | return R.ok(noticeDetailVO); |
| | | } |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @PostMapping("/queryNotice") |
| | | @ApiOperation(value = "是否有未读消息 true是 false否",tags = "系统消息") |
| | | public R<Boolean> queryNotice() { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | int size = noticeRecordService.lambdaQuery() |
| | | .eq(NoticeRecord::getAppUserId, userId) |
| | | .eq(NoticeRecord::getReadStatus, 1).list().size(); |
| | |
| | | import com.xinquan.system.api.domain.PrizeRedemptionRecord; |
| | | import com.xinquan.user.service.PrizeRedemptionRecordService; |
| | | import com.xinquan.user.service.PrizeService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | } |
| | | |
| | | @PostMapping("/addPrize") |
| | | @ApiOperation(value = "新增奖品管理", notes = "管理后台-奖品管理") |
| | | @ApiOperation(value = "新增奖品管理", tags = "管理后台-奖品管理") |
| | | public R addPrize(@RequestBody Prize homeBackgroundMusic) { |
| | | homeBackgroundMusic.setCreateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setCreateTime(LocalDateTime.now()); |
| | | return R.ok(prizeService.save(homeBackgroundMusic)); |
| | | } |
| | | @GetMapping("/detailPrize") |
| | | @ApiOperation(value = "查看详情奖品管理", notes = "管理后台-奖品管理") |
| | | @ApiOperation(value = "查看详情奖品管理", tags = "管理后台-奖品管理") |
| | | public R<Prize> detailPrize(String uid) { |
| | | return R.ok(prizeService.getById(uid)); |
| | | } |
| | | @GetMapping("/updateState") |
| | | @ApiOperation(value = "修改奖品管理上下架状态", notes = "管理后台-奖品管理") |
| | | @ApiOperation(value = "修改奖品管理上下架状态", tags = "管理后台-奖品管理") |
| | | public R updateState(String uid) { |
| | | Prize byId = prizeService.getById(uid); |
| | | if (byId.getStatus() == 1){ |
| | |
| | | }else { |
| | | byId.setStatus(1); |
| | | } |
| | | prizeService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/updatePrize") |
| | | @ApiOperation(value = "修改奖品管理", notes = "管理后台-奖品管理") |
| | | @ApiOperation(value = "修改奖品管理", tags = "管理后台-奖品管理") |
| | | public R updatePrize(@RequestBody Prize homeBackgroundMusic) { |
| | | homeBackgroundMusic.setUpdateBy(SecurityUtils.getUsername()); |
| | | homeBackgroundMusic.setUpdateTime(LocalDateTime.now()); |
| | | return R.ok(prizeService.updateById(homeBackgroundMusic)); |
| | | } |
| | | @PostMapping("/deletePrize") |
| | | @ApiOperation(value = "批量删除", notes = "管理后台-奖品管理") |
| | | @ApiOperation(value = "批量删除", tags = "管理后台-奖品管理") |
| | | public R deletePrize(String ids) { |
| | | return R.ok(prizeService.removeBatchByIds(Arrays.asList(ids.split(",")))); |
| | | return R.ok(prizeService.removeBatchByIds(Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList()))); |
| | | } |
| | | } |
| | | |
| | |
| | | package com.xinquan.user.controller.client; |
| | | |
| | | |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.WebUtils; |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | |
| | | import com.xinquan.meditation.api.feign.RemoteMeditationService; |
| | | import com.xinquan.system.api.RemoteUserService; |
| | | import com.xinquan.system.api.domain.AppUser; |
| | | import com.xinquan.system.api.domain.Prize; |
| | | import com.xinquan.system.api.domain.PrizeRedemptionRecord; |
| | | import com.xinquan.system.api.domain.SysUser; |
| | | import com.xinquan.system.api.domain.*; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.user.api.domain.dto.OrderListDTO; |
| | | import com.xinquan.user.api.domain.dto.PrizeRecordDTO; |
| | | import com.xinquan.user.domain.export.PrizeExport; |
| | | import com.xinquan.user.domain.export.WithdrawExport; |
| | | import com.xinquan.user.service.AppUserService; |
| | | import com.xinquan.user.service.PrizeRedemptionRecordService; |
| | | import com.xinquan.user.service.PrizeService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | |
| | | private AppUserService appUserService; |
| | | @Resource |
| | | private RemoteUserService remoteUserService; |
| | | @PostMapping("/getPrizeRecordCount") |
| | | public R<String> getPrizeRecordCount(){ |
| | | List<PrizeRedemptionRecord> list = prizeRedemptionRecordService.lambdaQuery() |
| | | .eq(PrizeRedemptionRecord::getStatus, 1).list(); |
| | | return R.ok(list.size()+""); |
| | | } |
| | | |
| | | @ApiOperation(value = "兑换记录管理导出", tags = {"管理后台-兑换记录管理"}) |
| | | @PutMapping("/export") |
| | | public void export(@RequestBody PrizeRecordDTO courseDTO){ |
| | | String startTime = null; |
| | | String endTime = null; |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getTime())){ |
| | | String[] split = courseDTO.getTime().split(" - "); |
| | | startTime = split[0]+"00:00:00"; |
| | | endTime = split[1]+"23:59:59"; |
| | | } |
| | | List<Long> longs = new ArrayList<>(); |
| | | LambdaQueryWrapper<PrizeRedemptionRecord> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.hasLength(courseDTO.getIds())){ |
| | | courseLambdaQueryWrapper.in(PrizeRedemptionRecord::getId, Arrays.asList(courseDTO.getIds().split(","))); |
| | | } |
| | | if (startTime!=null){ |
| | | courseLambdaQueryWrapper.between(PrizeRedemptionRecord::getCreateTime, startTime, endTime); |
| | | } |
| | | if (courseDTO.getStatus()!=null){ |
| | | courseLambdaQueryWrapper.eq(PrizeRedemptionRecord::getStatus, courseDTO.getStatus()); |
| | | } |
| | | courseLambdaQueryWrapper.orderByDesc(PrizeRedemptionRecord::getCreateTime); |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getUserNameOrPhone())){ |
| | | List<Long> collect = appUserService.lambdaQuery().like(AppUser::getNickname, courseDTO.getUserNameOrPhone()).list() |
| | | .stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | longs.addAll(collect); |
| | | List<Long> collect1 = appUserService.lambdaQuery().like(AppUser::getCellPhone, courseDTO.getUserNameOrPhone()).list() |
| | | .stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | longs.addAll(collect1); |
| | | if (longs.isEmpty()){ |
| | | longs.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(PrizeRedemptionRecord::getAppUserId, longs); |
| | | } |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getName())){ |
| | | List<Long> collect = prizeService.lambdaQuery().like(Prize::getName, courseDTO.getName()).list() |
| | | .stream().map(Prize::getId).collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(PrizeRedemptionRecord::getPrizeId, collect); |
| | | } |
| | | List<PrizeExport> prizeExports = new ArrayList<>(); |
| | | |
| | | List<PrizeRedemptionRecord> page = prizeRedemptionRecordService.list(courseLambdaQueryWrapper); |
| | | for (PrizeRedemptionRecord record : page) { |
| | | Prize byId = prizeService.getById(record.getPrizeId()); |
| | | |
| | | record.setUid(record.getId().toString()); |
| | | AppUser byId1 = appUserService.getById(record.getAppUserId()); |
| | | |
| | | PrizeExport prizeExport = new PrizeExport(); |
| | | DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | String format = df.format(record.getCreateTime()); |
| | | prizeExport.setCreateTime(format); |
| | | if (Objects.nonNull(byId1)){ |
| | | record.setUserName(byId1.getNickname()); |
| | | record.setAvatar(byId1.getAvatar()); |
| | | record.setCellPhone(byId1.getCellPhone()); |
| | | prizeExport.setUserName(byId1.getNickname()); |
| | | prizeExport.setCellphone(byId1.getCellPhone()); |
| | | } |
| | | if (Objects.nonNull(byId)){ |
| | | record.setName(byId.getName()); |
| | | record.setWorth(byId.getWorth()); |
| | | record.setEnergyValue(byId.getEnergyValue()); |
| | | prizeExport.setPrizeName(byId.getName()); |
| | | prizeExport.setAmount(byId.getWorth()+""); |
| | | prizeExport.setEnergyValue(byId.getEnergyValue()+""); |
| | | } |
| | | prizeExport.setStatus(record.getStatus()+""); |
| | | prizeExports.add(prizeExport); |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), PrizeExport.class, prizeExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("兑换记录管理导出.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | @PostMapping("/prizeRedemptionRecordList") |
| | | @ApiOperation(value = "兑换记录管理列表-分页", tags = {"管理后台-兑换记录管理"}) |
| | |
| | | } |
| | | List<Long> longs = new ArrayList<>(); |
| | | LambdaQueryWrapper<PrizeRedemptionRecord> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | courseLambdaQueryWrapper.between(PrizeRedemptionRecord::getCreateTime, startTime, endTime); |
| | | courseLambdaQueryWrapper.eq(courseDTO.getStatus()!=null,PrizeRedemptionRecord::getStatus, courseDTO.getStatus()); |
| | | if (startTime!=null){ |
| | | courseLambdaQueryWrapper.between(PrizeRedemptionRecord::getCreateTime, startTime, endTime); |
| | | } |
| | | if (courseDTO.getStatus()!=null){ |
| | | courseLambdaQueryWrapper.eq(PrizeRedemptionRecord::getStatus, courseDTO.getStatus()); |
| | | } |
| | | courseLambdaQueryWrapper.orderByDesc(PrizeRedemptionRecord::getCreateTime); |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getUserNameOrPhone())){ |
| | | List<Long> collect = appUserService.lambdaQuery().like(AppUser::getNickname, courseDTO.getUserNameOrPhone()).list() |
| | |
| | | return R.ok(PageDTO.empty(page)); |
| | | } |
| | | for (PrizeRedemptionRecord record : page.getRecords()) { |
| | | record.setUuid(record.getAppUserId()+""); |
| | | Prize byId = prizeService.getById(record.getPrizeId()); |
| | | if (Objects.nonNull(byId)){ |
| | | record.setName(byId.getName()); |
| | |
| | | } |
| | | |
| | | @GetMapping("/detailPrizeRedemptionRecord") |
| | | @ApiOperation(value = "查看详情兑换记录管理", notes = "管理后台-兑换记录管理") |
| | | @ApiOperation(value = "查看详情兑换记录管理", tags = "管理后台-兑换记录管理") |
| | | public R<PrizeRedemptionRecord> detailPrizeRedemptionRecord(String uid) { |
| | | PrizeRedemptionRecord byId = prizeRedemptionRecordService.getById(uid); |
| | | Prize byId1 = prizeService.getById(byId.getPrizeId()); |
| | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @GetMapping("/confirm") |
| | | @ApiOperation(value = "确认兑换", notes = "管理后台-兑换记录管理") |
| | | @ApiOperation(value = "确认兑换", tags = "管理后台-兑换记录管理") |
| | | public R updateState(String uid,String code) { |
| | | |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | PrizeRedemptionRecord byId = prizeRedemptionRecordService.getById(uid); |
| | | if (!byId.getCode().equals(code)){ |
| | | return R.fail("兑换码错误"); |
| | | }else{ |
| | | byId.setStatus(2); |
| | | byId.setUpdateTime(LocalDateTime.now()); |
| | | SysUser data = remoteUserService.getSysUserById(SecurityUtils.getUserId() + "").getData(); |
| | | byId.setUpdateBy(SecurityUtils.getUsername()+data.getNickName()+"("+data.getUserName()+")"); |
| | | SysUser data = remoteUserService.getSysUserById(userId + "").getData(); |
| | | byId.setUpdateBy(data.getUserName()+data.getNickName()+"("+data.getUserName()+")"); |
| | | prizeRedemptionRecordService.updateById(byId); |
| | | } |
| | | return R.ok(); |
| | |
| | | public class UserAnswerDTO implements Serializable { |
| | | |
| | | private static final long serialVersionUID = -5037991196273819118L; |
| | | @Valid |
| | | @ApiModelProperty(value = "问题一答案", required = true) |
| | | @NotEmpty(message = "问题一答案不能为空") |
| | | private List<UserAnswerOneDTO> userAnswerOneDTOList; |
| | | |
| | | @ApiModelProperty(value = "问题二 多个tagId使用英文逗号拼接字符串", required = true) |
| | | @NotBlank(message = "问题二答案不能为空") |
| | | private String tagIds; |
| | | } |
New file |
| | |
| | | package com.xinquan.user.domain.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.Valid; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author mitao |
| | | * @date 2024/8/27 |
| | | */ |
| | | @Data |
| | | @ApiModel("用户计划引导答案数据传输对象") |
| | | public class UserFreezingDTO implements Serializable { |
| | | |
| | | private static final long serialVersionUID = -5037991196273819118L; |
| | | @ApiModelProperty(value = "用户uid") |
| | | private String uid; |
| | | |
| | | @ApiModelProperty(value = "冻结原因") |
| | | |
| | | private String freezingReason; |
| | | } |
New file |
| | |
| | | package com.xinquan.user.domain.export; |
| | | |
| | | import cn.afterturn.easypoi.excel.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @ApiModel(value = "兑换记录管理-导出") |
| | | public class PrizeExport implements Serializable { |
| | | @Excel(name = "兑换时间",width = 30 ) |
| | | private String createTime; |
| | | @Excel(name = "用户昵称",width = 30) |
| | | private String userName; |
| | | @Excel(name = "用户手机号",width = 30) |
| | | private String cellphone; |
| | | @Excel(name = "奖品名称",width = 30) |
| | | private String prizeName; |
| | | @Excel(name = "奖品价格",width = 30) |
| | | private String amount; |
| | | @Excel(name = "消耗能量值",width = 30) |
| | | private String energyValue; |
| | | @Excel(name = "提现状态",width = 30,replace = {"待领取_1","已兑换_2"}) |
| | | private String status; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.xinquan.user.domain.export; |
| | | |
| | | import cn.afterturn.easypoi.excel.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @ApiModel(value = "用户列表管理-导出") |
| | | public class UserExport implements Serializable { |
| | | @Excel(name = "用户ID",width = 30 ) |
| | | private String code; |
| | | @Excel(name = "用户昵称",width = 30) |
| | | private String userName; |
| | | @Excel(name = "用户姓名",width = 30) |
| | | private String realname; |
| | | @Excel(name = "用户手机号",width = 30) |
| | | private String cellphone; |
| | | @Excel(name = "性别",width = 30,replace = {"男_1","女_2"}) |
| | | private String gender; |
| | | @Excel(name = "出生日期",width = 30 ) |
| | | private String birthday; |
| | | @Excel(name = "学历",width = 30) |
| | | private String education; |
| | | @Excel(name = "所在地",width = 30) |
| | | private String location; |
| | | @Excel(name = "故乡",width = 30) |
| | | private String hometown; |
| | | @Excel(name = "邮箱",width = 30) |
| | | private String email; |
| | | @Excel(name = "行业",width = 30 ) |
| | | private String industry; |
| | | @Excel(name = "公司",width = 30) |
| | | private String company; |
| | | @Excel(name = "职位",width = 30) |
| | | private String occupation; |
| | | @Excel(name = "是否会员",width = 30,replace = {"是_1","否_2"}) |
| | | private String isVip; |
| | | @Excel(name = "疗愈等级",width = 30) |
| | | private String meditationLevel; |
| | | @Excel(name = "能量值",width = 30 ) |
| | | private String totalEnergyValue; |
| | | @Excel(name = "钱包余额",width = 30) |
| | | private String balance; |
| | | @Excel(name = "注册时间",width = 30) |
| | | private String registerTime; |
| | | @Excel(name = "用户状态",width = 30,replace = {"正常_1","冻结_2","注销_3"}) |
| | | private String userStatus; |
| | | @Excel(name = "您是否内心纠结敏感多以?",width = 60 ,replace = {"是_1","否_2","偶尔有_3"}) |
| | | private String type1; |
| | | @Excel(name = "您是否辗转反侧彻夜难眠?",width = 60,replace = {"是_1","否_2","偶尔有_3"}) |
| | | private String type2; |
| | | @Excel(name = "您是否情绪失控暴躁易怒?",width = 60,replace = {"是_1","否_2","偶尔有_3"}) |
| | | private String type3; |
| | | @Excel(name = "您是否沉迷情感倍受伤害?",width = 60,replace = {"是_1","否_2","偶尔有_3"}) |
| | | private String type4; |
| | | @Excel(name = "您是否人生迷茫踌躇彷徨?",width = 60,replace = {"是_1","否_2","偶尔有_3"}) |
| | | private String type5; |
| | | @Excel(name = "其他补充",width = 30) |
| | | private String type6; |
| | | @Excel(name = "您在这方空间最想解决和收获的是哪方面问题?",width = 30 ) |
| | | private String type7; |
| | | @Excel(name = "是否可浏览梵文",width = 30,replace = {"是_1","否_2"}) |
| | | private String sanskritFlag; |
| | | @Excel(name = "下级用户数量",width = 30) |
| | | private String userCount; |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.xinquan.user.domain.export; |
| | | |
| | | import cn.afterturn.easypoi.excel.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @ApiModel(value = "用户列表-下级用户-导出") |
| | | public class UserInfoExport implements Serializable { |
| | | @Excel(name = "用户ID",width = 30 ) |
| | | private String code; |
| | | @Excel(name = "用户昵称",width = 30) |
| | | private String userName; |
| | | @Excel(name = "用户手机号",width = 30) |
| | | private String cellphone; |
| | | @Excel(name = "带来收益",width = 30) |
| | | private String income; |
| | | @Excel(name = "绑定时间",width = 30) |
| | | private String inviteUserTime; |
| | | @Excel(name = "用户状态",width = 30,replace = {"正常_1","冻结_2","注销_3"}) |
| | | private String userStatus; |
| | | |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.xinquan.user.domain.export; |
| | | |
| | | import cn.afterturn.easypoi.excel.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | |
| | | @Data |
| | | @ApiModel(value = "提现管理-导出") |
| | | public class WithdrawExport implements Serializable { |
| | | |
| | | @Excel(name = "提现单号",width = 30) |
| | | private String code; |
| | | @Excel(name = "用户昵称",width = 30) |
| | | private String userName; |
| | | @Excel(name = "用户手机号",width = 30) |
| | | private String cellphone; |
| | | @Excel(name = "提现金额",width = 30) |
| | | private String amount; |
| | | @Excel(name = "提现方式",width = 30,replace = {"银行卡提现_1"}) |
| | | private String withdrawType; |
| | | @Excel(name = "提现状态",width = 30,replace = {"提现中_0","已完成_1","提现失败_2"}) |
| | | private String withdrawStatus; |
| | | @Excel(name = "提现时间",width = 30 ) |
| | | private String createTime; |
| | | |
| | | } |
| | |
| | | |
| | | @ApiModelProperty(value = "id") |
| | | private Long id; |
| | | @ApiModelProperty(value = "奖品id") |
| | | private Long prizeId; |
| | | @ApiModelProperty(value = "奖品名称") |
| | | private String name; |
| | | @ApiModelProperty(value = "封面图") |
| | |
| | | |
| | | List<AppUserViewingHistory> cumulative(@Param("userId") Long userId); |
| | | |
| | | int today(@Param("userId") Long userId); |
| | | Integer today(@Param("userId") Long userId); |
| | | } |
| | |
| | | |
| | | List<AppUserViewingHistory> cumulative(Long userId); |
| | | |
| | | int today(Long userId); |
| | | Integer today(Long userId); |
| | | |
| | | } |
| | |
| | | import cn.hutool.core.util.IdUtil; |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xinquan.common.core.constant.Constants; |
| | |
| | | import com.xinquan.common.core.exception.ServiceException; |
| | | import com.xinquan.common.core.utils.page.BeanUtils; |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.system.api.RemoteUserService; |
| | | import com.xinquan.system.api.domain.SysUser; |
| | | import com.xinquan.system.api.feignClient.SysUserClient; |
| | | import com.xinquan.system.api.model.AppCaptchaBody; |
| | | import com.xinquan.system.api.model.AppLoginUser; |
| | | import com.xinquan.system.api.model.AppVerifyCellPhoneBody; |
| | | import com.xinquan.system.api.model.AppWXLoginBody; |
| | | import com.xinquan.system.api.model.*; |
| | | import com.xinquan.system.api.domain.AppUser; |
| | | import com.xinquan.user.api.domain.dto.AppUserDTO; |
| | | import com.xinquan.system.api.domain.AppUserQuestion; |
| | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | String randomCode = String.valueOf((int) ((Math.random() * 9 + 1) * 1000)); |
| | | appUser.setCode("YH"+format+randomCode); |
| | | appUser.setWxOpenId(body.getWxOpenId()); |
| | | appUser.setNickname(body.getNickname()); |
| | | String nickname = "用户" + IdUtil.fastSimpleUUID().substring(0, 6); |
| | | sysUser.setNickName(nickname); |
| | | appUser.setAvatar(body.getHeadImgUrl()); |
| | | appUser.setGender(body.getSex()); |
| | | appUser.setBalance(BigDecimal.ZERO); |
| | |
| | | } |
| | | SysUser sysUserRes = registerResult.getData(); |
| | | appUser = new AppUser(); |
| | | appUser.setAppleId(appleId); |
| | | appUser.setUserId(sysUserRes.getUserId()); |
| | | appUser.setNickname(nickname); |
| | | appUser.setAvatar("qwer"); // TODO 待完善默认头像 |
| | |
| | | // 如果存在 更新wxOpenId 或appleId |
| | | if (baseOptionalAppUser.isPresent()) { |
| | | appUser = baseOptionalAppUser.get(); |
| | | switch (body.getLoginType()){ |
| | | case 1: |
| | | this.remove(new LambdaQueryWrapper<AppUser>() |
| | | .eq(AppUser::getWxOpenId,body.getWxOrAppleId()) |
| | | .ne(AppUser::getId,appUser.getId())); |
| | | break; |
| | | case 2: |
| | | this.remove(new LambdaQueryWrapper<AppUser>() |
| | | .eq(AppUser::getAppleId,body.getWxOrAppleId()) |
| | | .ne(AppUser::getId,appUser.getId())); |
| | | break; |
| | | } |
| | | |
| | | if (loginType.equals(1)) { |
| | | appUser.setWxOpenId(wxOrAppleId); |
| | | } else { |
| | |
| | | } |
| | | } else { |
| | | Optional<AppUser> userOptional = getAppUserByThirdId(loginType, wxOrAppleId); |
| | | |
| | | if (loginType.equals(1)) { |
| | | // 微信登录 |
| | | handleUserNotPresent(userOptional, "该用户不存在,请重新进行微信授权登录"); |
| | |
| | | @Override |
| | | public void saveUserAnswers(UserAnswerDTO dto) { |
| | | // 获取当前登录用户 |
| | | Long userId = SecurityUtils.getUserId(); |
| | | AppUser appUser = this.getUserBySysUserId(userId); |
| | | Long userId = tokenService.getLoginUser().getUserid(); |
| | | AppUser appUser = this.getById(userId); |
| | | List<AppUserQuestion> appUserQuestionList = BeanUtils.copyList( |
| | | dto.getUserAnswerOneDTOList(), AppUserQuestion.class); |
| | | // 查询用户已填写的答案 |
| | |
| | | if (CollUtils.isNotEmpty(baseAppUserQuestionList)) { |
| | | // 根据类型更新答案 |
| | | for (AppUserQuestion appUserQuestion : appUserQuestionList) { |
| | | |
| | | Optional<AppUserQuestion> baseAppUserQuestionOptional = baseAppUserQuestionList.stream() |
| | | .filter(baseAppUserQuestion -> baseAppUserQuestion.getType() |
| | | .equals(appUserQuestion.getType())).findFirst(); |
| | | baseAppUserQuestionOptional.ifPresent( |
| | | userQuestion -> appUserQuestion.setId(userQuestion.getId())); |
| | | appUserQuestion.setAppUserId(userId); |
| | | } |
| | | } |
| | | for (AppUserQuestion appUserQuestion : appUserQuestionList) { |
| | | appUserQuestion.setAppUserId(userId); |
| | | } |
| | | appUserQuestionService.saveOrUpdateBatch(appUserQuestionList); |
| | | // 筛选答案为是和偶尔有的问题,为用户设置对应的标签 |
| | |
| | | // 使用 StringBuilder 提高字符串拼接效率 |
| | | if (CollUtils.isNotEmpty(appUserQuestionYesList)) { |
| | | List<Long> tagIdList = appUserQuestionYesList.stream() |
| | | .map(appUserQuestion -> AnswerTagEnum.getEnumByCode(appUserQuestion.getType()) |
| | | .map(appUserQuestion -> Objects.requireNonNull(AnswerTagEnum.getEnumByCode(appUserQuestion.getType())) |
| | | .getTagId()).collect(Collectors.toList()); |
| | | if (CollUtils.isNotEmpty(tagIdList)) { |
| | | sb.append(CollUtils.join(tagIdList, ",")); |
| | |
| | | this.updateById(appUser); |
| | | } |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | /** |
| | | * 获取当前登录用户信息 |
| | | * |
| | |
| | | */ |
| | | @Override |
| | | public AppUserVO getCurrentUser() { |
| | | AppUser appUser = this.getById(SecurityUtils.getUserId()); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | |
| | | Long userId = loginUser.getUserid(); |
| | | AppUser appUser = this.getById(userId); |
| | | return BeanUtils.copyBean(appUser, AppUserVO.class); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public int today(Long userId) { |
| | | public Integer today(Long userId) { |
| | | return this.baseMapper.today(userId); |
| | | } |
| | | } |
| | |
| | | t_app_user_viewing_history |
| | | WHERE |
| | | app_user_id = #{userId} |
| | | viewing_type = 1 |
| | | and viewing_type = 1 |
| | | AND del_flag = 0 |
| | | GROUP BY |
| | | app_user_id, |