begin new project
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.ApkConfigEntity;
|
||||
import com.peanut.modules.common.service.ApkConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController("commonApkConfigController")
|
||||
@RequestMapping("/common/apkConfig")
|
||||
public class ApkConfigController {
|
||||
@Autowired
|
||||
private ApkConfigService apkConfigService;
|
||||
|
||||
|
||||
@RequestMapping("/getApkUrl")
|
||||
public R getApkUrl(@RequestBody Map<String,Integer> map){
|
||||
String url = apkConfigService.getApkUrl(map.get("type"));
|
||||
return R.ok().put("result",url);
|
||||
}
|
||||
|
||||
//获取更新包地址
|
||||
@RequestMapping("/getUpdateUrl")
|
||||
public R getUpdateUrl(@RequestBody Map<String,Object> params){
|
||||
ApkConfigEntity apkConfig = apkConfigService.getOne(new LambdaQueryWrapper<ApkConfigEntity>()
|
||||
.eq(ApkConfigEntity::getType,params.get("type")));
|
||||
String updateUrl = "";
|
||||
String appVer = params.get("version").toString();
|
||||
if (StringUtils.isNotEmpty(apkConfig.getVersion())&&apkConfig.getVersion().contains(appVer)) {
|
||||
updateUrl = apkConfig.getUpdateUrl();
|
||||
}
|
||||
return R.ok().put("updateUrl",updateUrl);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.BaseAreaEntity;
|
||||
import com.peanut.modules.common.service.BaseAreaService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 国家区域管理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonBaseArea")
|
||||
@RequestMapping("common/baseArea")
|
||||
public class BaseAreaController {
|
||||
|
||||
@Autowired
|
||||
private BaseAreaService baseAreaService;
|
||||
|
||||
/**
|
||||
* 添加区域
|
||||
* @param baseArea
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/addBaseArea")
|
||||
public R addBaseArea(@RequestBody BaseAreaEntity baseArea){
|
||||
baseAreaService.save(baseArea);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除区域
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/delBaseArea")
|
||||
public R delBaseArea(@RequestBody Map<String,Object> map){
|
||||
Integer areaId = Integer.valueOf(map.get("areaId").toString());
|
||||
baseAreaService.removeById(areaId);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑区域信息
|
||||
* @param baseArea
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/editBaseArea")
|
||||
public R editBaseArea(@RequestBody BaseAreaEntity baseArea){
|
||||
baseAreaService.updateById(baseArea);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取区域列表
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getBaseAreas")
|
||||
public R getBaseAreas(@RequestBody Map<String,Object> map){
|
||||
Integer limit = Integer.valueOf(map.get("limit").toString());
|
||||
Integer page = Integer.valueOf(map.get("page").toString());
|
||||
|
||||
Page baseAreas = baseAreaService.getBaseAreas(limit, page);
|
||||
return R.ok().put("page",baseAreas);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部国家领域
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getAllBaseArea")
|
||||
public R getAllBaseArea(){
|
||||
List<BaseAreaEntity> list = baseAreaService.list();
|
||||
return R.ok().put("baseAreas",list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.BookBuyConfigEntity;
|
||||
import com.peanut.modules.common.service.BookBuyConfigService;
|
||||
import com.peanut.modules.sys.entity.SysDictDataEntity;
|
||||
import com.peanut.modules.sys.service.SysDictDataService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.time.DateFormatUtils;
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 充值价格表单管理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonBookBuyConfig")
|
||||
@RequestMapping("common/bookBuyConfig")
|
||||
public class BookBuyConfigController {
|
||||
|
||||
@Autowired
|
||||
private BookBuyConfigService service;
|
||||
@Autowired
|
||||
private SysDictDataService sysDictDataService;
|
||||
|
||||
/**
|
||||
* 获取充值价格表单列表
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getBookBuyConfigList")
|
||||
public R getBookBuyConfigList(@RequestBody Map params){
|
||||
LambdaQueryWrapper<BookBuyConfigEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.and(t->t.eq(BookBuyConfigEntity::getEffective,0)
|
||||
.or(q->q.le(BookBuyConfigEntity::getStartTime,new Date()).ge(BookBuyConfigEntity::getEndTime,new Date())));
|
||||
if (params.containsKey("type")&&StringUtils.isNotEmpty(params.get("type").toString())){
|
||||
wrapper.eq(BookBuyConfigEntity::getType,params.get("type"));
|
||||
}
|
||||
if (params.containsKey("qudao")&&StringUtils.isNotEmpty(params.get("qudao").toString())){
|
||||
wrapper.eq(BookBuyConfigEntity::getQudao,params.get("qudao"));
|
||||
}
|
||||
wrapper.orderByAsc(BookBuyConfigEntity::getRealMoney);
|
||||
List<BookBuyConfigEntity> list = service.list(wrapper);
|
||||
return R.ok().put("bookBuyConfigList",list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取充值价格表单列表活动
|
||||
*/
|
||||
@RequestMapping("/getRechargeActivity")
|
||||
public R getRechargeActivity(){
|
||||
List<SysDictDataEntity> res = new ArrayList<>();
|
||||
List<SysDictDataEntity> list = sysDictDataService.list(new LambdaQueryWrapper<SysDictDataEntity>()
|
||||
.eq(SysDictDataEntity::getDictLabel,"rechargeActivity"));
|
||||
for (SysDictDataEntity data:list){
|
||||
String[] str = data.getDictType().split(",");
|
||||
if (DateUtil.parse(str[0]).getTime()<new Date().getTime()&&DateUtil.parse(str[1]).getTime()>new Date().getTime()){
|
||||
res.add(data);
|
||||
}
|
||||
}
|
||||
return R.ok().put("res",res);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.BuyOrder;
|
||||
import com.peanut.modules.common.service.BuyOrderService;
|
||||
import com.peanut.modules.common.to.PrepareOrderDto;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController("commonBuyOrder")
|
||||
@RequestMapping("common/buyOrder")
|
||||
public class BuyOrderController {
|
||||
|
||||
@Autowired
|
||||
private BuyOrderService buyOrderService;
|
||||
|
||||
@RequestMapping("/initPrepareOrder")
|
||||
public R initPrepareOrder(@RequestBody PrepareOrderDto prepareOrderDto){
|
||||
return R.ok().put("data",buyOrderService.initPrepareOrder(prepareOrderDto));
|
||||
}
|
||||
|
||||
//用户订单列表
|
||||
@RequestMapping("/commonBuyOrderList")
|
||||
public R commonBuyOrderList(@RequestBody Map params){
|
||||
IPage<BuyOrder> page = buyOrderService.commonBuyOrderList(params);
|
||||
return R.ok().put("data",page);
|
||||
}
|
||||
|
||||
//用户订单各状态下数量
|
||||
@RequestMapping("/getBuyOrderNumByStatus")
|
||||
public R getBuyOrderNumByStatus(@RequestBody Map params){
|
||||
return R.ok().put("data",buyOrderService.getBuyOrderNumByStatus(params));
|
||||
}
|
||||
|
||||
//订单详情
|
||||
@RequestMapping("/commonOrderDetail")
|
||||
public R commonOrderDetail(@RequestBody Map params){
|
||||
return R.ok().put("data",buyOrderService.commonOrderDetail(params));
|
||||
}
|
||||
|
||||
//获取快递进度详情
|
||||
@RequestMapping("/commonExpressDetail")
|
||||
public R commonExpressDetail(@RequestBody Map params){
|
||||
return R.ok().put("data",buyOrderService.commonExpressDetail(params));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,647 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.*;
|
||||
import com.peanut.modules.medical.service.CourseService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController("commonClass")
|
||||
@RequestMapping("common/class")
|
||||
public class ClassController {
|
||||
|
||||
@Autowired
|
||||
private ClassEntityService classEntityService;
|
||||
@Autowired
|
||||
private ClassModelService classModelService;
|
||||
@Autowired
|
||||
private UserCertificateService userCertificateService;
|
||||
@Autowired
|
||||
private CourseService courseService;
|
||||
@Autowired
|
||||
private ClassExamUserService classExamUserService;
|
||||
@Autowired
|
||||
private SysNoticeService sysNoticeService;
|
||||
@Autowired
|
||||
private ClassTaskService classTaskService;
|
||||
@Autowired
|
||||
private MyUserService userService;
|
||||
|
||||
//班级模型列表
|
||||
@RequestMapping("/getClassModelList")
|
||||
public R getClassModelList(@RequestBody Map<String,Object> params){
|
||||
Page classModelList = classEntityService.getClassModelList(params);
|
||||
return R.ok().put("page",classModelList);
|
||||
}
|
||||
|
||||
//新增班级模型
|
||||
@RequestMapping("/addClassModel")
|
||||
public R addClassModel(@RequestBody ClassModel classModel){
|
||||
String[] courseIds = classModel.getCourseIds().split(",");
|
||||
if(courseIds.length > 0){
|
||||
HashSet<String> set = new HashSet<>();
|
||||
for (String courseId : courseIds) {
|
||||
if (!set.add(courseId)){
|
||||
return R.error("课程不能重复");
|
||||
}
|
||||
}
|
||||
}
|
||||
int score = 0;
|
||||
if (classModel.getIsQuestion()==1){
|
||||
score += classModel.getQuestionScore();
|
||||
}
|
||||
if (classModel.getIsTask()==1){
|
||||
score += classModel.getTaskScore();
|
||||
}
|
||||
if (classModel.getIsMedicalcase()==1){
|
||||
score += classModel.getMedicalcaseScore();
|
||||
}
|
||||
if (classModel.getIsExperience()==1){
|
||||
score += classModel.getExperienceScore();
|
||||
}
|
||||
if (classModel.getIsExam()==1){
|
||||
score += classModel.getExamScore();
|
||||
}
|
||||
if (score==100){
|
||||
return classEntityService.addClassModel(classModel);
|
||||
}else {
|
||||
return R.error("请设置各模块占比总和为100");
|
||||
}
|
||||
}
|
||||
|
||||
//修改班级模型
|
||||
@RequestMapping("/editClassModel")
|
||||
public R editClassModel(@RequestBody ClassModel classModel){
|
||||
String[] courseIds = classModel.getCourseIds().split(",");
|
||||
if(courseIds.length > 0){
|
||||
HashSet<String> set = new HashSet<>();
|
||||
for (String courseId : courseIds) {
|
||||
if (!set.add(courseId)){
|
||||
return R.error("课程不能重复");
|
||||
}
|
||||
}
|
||||
}
|
||||
int score = 0;
|
||||
if (classModel.getIsQuestion()==1){
|
||||
score += classModel.getQuestionScore();
|
||||
}
|
||||
if (classModel.getIsTask()==1){
|
||||
score += classModel.getTaskScore();
|
||||
}
|
||||
if (classModel.getIsMedicalcase()==1){
|
||||
score += classModel.getMedicalcaseScore();
|
||||
}
|
||||
if (classModel.getIsExperience()==1){
|
||||
score += classModel.getExperienceScore();
|
||||
}
|
||||
if (classModel.getIsExam()==1){
|
||||
score += classModel.getExamScore();
|
||||
}
|
||||
if (score==100){
|
||||
return classEntityService.editClassModel(classModel);
|
||||
}else {
|
||||
return R.error("请设置各模块占比总和为100");
|
||||
}
|
||||
}
|
||||
|
||||
//获取模型可选课程
|
||||
@RequestMapping("/getClassModelCourseList")
|
||||
public R getClassModelCourseList(@RequestBody Map<String,Object> params){
|
||||
List<CourseEntity> courseList = classEntityService.getClassModelCourseList(params);
|
||||
return R.ok().put("courseList",courseList);
|
||||
}
|
||||
|
||||
//获取主任下的班级模型
|
||||
@RequestMapping("/getClassModelByUserid")
|
||||
public R getClassModelByUserid(@RequestBody Map<String,Object> params){
|
||||
List<ClassModel> classModelList = classEntityService.getClassModelByUserid(params);
|
||||
return R.ok().put("classModelList",classModelList);
|
||||
}
|
||||
|
||||
//获取主任下的班级
|
||||
@RequestMapping("/getClassByDirectorid")
|
||||
public R getClassByDirectorid(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("classEntityList",classEntityService.getClassByDirectorid(params));
|
||||
}
|
||||
|
||||
//获取班级列表
|
||||
@RequestMapping("/getClassList")
|
||||
public R getClassList(@RequestBody Map<String,Object> params){
|
||||
Page classList = classEntityService.getClassList(params);
|
||||
return R.ok().put("page",classList);
|
||||
}
|
||||
|
||||
//新增班级
|
||||
@RequestMapping("/addClass")
|
||||
public R addClass(@RequestBody ClassEntity classEntity){
|
||||
return classEntityService.addClass(classEntity);
|
||||
}
|
||||
|
||||
//开班
|
||||
@RequestMapping("/openClass")
|
||||
public R openClass(@RequestBody Map<String,Object> params){
|
||||
return classEntityService.openClass(params);
|
||||
}
|
||||
|
||||
//修改班级
|
||||
@RequestMapping("/editClass")
|
||||
public R editClass(@RequestBody Map<String,Object> params){
|
||||
if (classEntityService.editClass(params)){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error("修改出错");
|
||||
}
|
||||
}
|
||||
|
||||
//设置班委
|
||||
@RequestMapping("/setUserRole")
|
||||
@Transactional
|
||||
public R setUserRole(@RequestBody Map<String,Object> params){
|
||||
return classEntityService.setUserRole(params);
|
||||
}
|
||||
|
||||
//获取用户在班级中角色
|
||||
@RequestMapping("/getUserRole")
|
||||
public R getUserRole(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("result",classEntityService.getUserRole(params));
|
||||
}
|
||||
|
||||
//获取用户拥有角色类型
|
||||
@RequestMapping("/getRoleType")
|
||||
public R getRoleType(){
|
||||
return R.ok().put("result",classEntityService.getRoleType());
|
||||
}
|
||||
|
||||
//删除班级
|
||||
@RequestMapping("/delClass")
|
||||
public R delClass(@RequestBody Map<String,Object> params){
|
||||
return classEntityService.delClass(params);
|
||||
}
|
||||
|
||||
//获取班级学员列表
|
||||
@RequestMapping("/getClassUserList")
|
||||
public R getClassUserList(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("result",classEntityService.getClassUserList(params));
|
||||
}
|
||||
|
||||
//添加班级学员
|
||||
@RequestMapping("/addClassUser")
|
||||
public R addClassUser(@RequestBody Map<String,Object> params){
|
||||
return classEntityService.addClassUser(params);
|
||||
}
|
||||
|
||||
//获取班级详情
|
||||
@RequestMapping("/getClassInfo")
|
||||
public R getClassInfo(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("result",classEntityService.getClassInfo(params));
|
||||
}
|
||||
|
||||
//获取班级学员带买课标识
|
||||
@RequestMapping("/getClassUserCourseFlag")
|
||||
public R getClassUserCourseFlag(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("result",classEntityService.getClassUserCourseFlag(params));
|
||||
}
|
||||
|
||||
//同一小班未开班小班
|
||||
@RequestMapping("/getNoOpenClassSameClass")
|
||||
public R getNoOpenClassSameClass(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("result",classEntityService.getNoOpenClassSameClass(params));
|
||||
}
|
||||
|
||||
//查询未加入小班
|
||||
@RequestMapping("/getClassNoUser")
|
||||
public R getClassNoUser(){
|
||||
return R.ok().put("result",classEntityService.getClassNoUser());
|
||||
}
|
||||
|
||||
//查询包含课程的小班(登陆人未加入)
|
||||
@RequestMapping("/getClassByCourseIdNoUser")
|
||||
public R getClassByCourseIdNoUser(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("result",classEntityService.getClassByCourseIdNoUser(params));
|
||||
}
|
||||
|
||||
//查询登陆人已加入小班
|
||||
@RequestMapping("/getClassByUser")
|
||||
public R getClassByUser(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("result",classEntityService.getClassByUser(params));
|
||||
}
|
||||
|
||||
//加入小班前查询用户买课情况
|
||||
@RequestMapping("/getUserCourseBuy")
|
||||
public R getUserCourseBuy(@RequestBody Map<String,Object> params){
|
||||
return classEntityService.getUserCourseBuy(params);
|
||||
}
|
||||
|
||||
//加入小班
|
||||
@RequestMapping("/joinClass")
|
||||
public R joinClass(@RequestBody Map<String,Object> params){
|
||||
return classEntityService.joinClass(params);
|
||||
}
|
||||
|
||||
//退出小班
|
||||
@RequestMapping("/quitClass")
|
||||
public R quitClass(@RequestBody Map<String,Object> params){
|
||||
classEntityService.quitClass(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//我的小班列表
|
||||
@RequestMapping("/MyClassList")
|
||||
public R MyClassList(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("result",classEntityService.MyClassList(params));
|
||||
}
|
||||
|
||||
//新增班级任务医案心得
|
||||
@RequestMapping("/addClassTask")
|
||||
public R addClassTask(@RequestBody ClassTask classTask){
|
||||
if ("2".equals(classTask.getType())){
|
||||
ClassEntity classEntity = classEntityService.getById(classTask.getClassId());
|
||||
if (classEntity.getId()>168){
|
||||
ClassModel classModel = classModelService.getById(classEntity.getModelId());
|
||||
Long taskCount = classTaskService.count(new LambdaQueryWrapper<ClassTask>()
|
||||
.eq(ClassTask::getClassId,classEntity.getId())
|
||||
.eq(ClassTask::getType,"2")
|
||||
.eq(ClassTask::getUserId,ShiroUtils.getUId()));
|
||||
if (taskCount<Math.ceil(classModel.getDays()/7)){
|
||||
}else {
|
||||
return R.error("最多只能提交"+Math.ceil(classModel.getDays()/7)+"条心得");
|
||||
}
|
||||
}
|
||||
}
|
||||
classEntityService.addClassTask(classTask);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//删除任务
|
||||
@RequestMapping("/delClassTask")
|
||||
public R delClassTask(@RequestBody Map<String,Object> params){
|
||||
classEntityService.delClassTask(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//生成班级任务
|
||||
@RequestMapping("/generateClassTask")
|
||||
public R generateClassTask(@RequestBody Map<String,Object> params){
|
||||
classEntityService.generateClassTask(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//获取班级任务列表
|
||||
@RequestMapping("/getClassTaskList")
|
||||
public R getClassTaskList(@RequestBody Map<String,Object> params){
|
||||
Page classTaskList = classEntityService.getClassTaskList(params);
|
||||
return R.ok().put("page",classTaskList);
|
||||
}
|
||||
|
||||
//获取班级任务列表(学员)
|
||||
@RequestMapping("/getClassTaskListStudent")
|
||||
public R getClassTaskListStudent(@RequestBody Map<String,Object> params){
|
||||
Page classTaskList = classEntityService.getClassTaskListStudent(params);
|
||||
return R.ok().put("page",classTaskList);
|
||||
}
|
||||
|
||||
//编辑班级任务医案心得
|
||||
@RequestMapping("/editClassTask")
|
||||
public R editClassTask(@RequestBody ClassTask classTask){
|
||||
classEntityService.editClassTask(classTask);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//获取任务详情
|
||||
@RequestMapping("/getClassTaskInfo")
|
||||
public R getClassTaskInfo(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("result",classEntityService.getClassTaskInfo(params));
|
||||
}
|
||||
|
||||
//获取任务详情学员
|
||||
@RequestMapping("/getClassTaskInfoStudent")
|
||||
public R getClassTaskInfoStudent(@RequestBody Map<String,Object> params){
|
||||
ClassTask classTask = classEntityService.getClassTaskInfoStudent(params);
|
||||
return R.ok().put("classTask",classTask);
|
||||
}
|
||||
|
||||
//新增作业
|
||||
@RequestMapping("/addClassTaskAndQuesReply")
|
||||
public R addClassTaskAndQuesReply(@RequestBody ClassTaskAndQuesReply classTaskAndQuesReply){
|
||||
ClassEntity classEntity = classEntityService.getById(classTaskAndQuesReply.getClassId());
|
||||
if ("3".equals(classEntity.getState())) {
|
||||
return R.error("考试周禁止提交作业");
|
||||
}
|
||||
int res = classEntityService.addClassTaskAndQuesReply(classTaskAndQuesReply);
|
||||
if (res==2){
|
||||
return R.error("已提交");
|
||||
}else if (res==1){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error("提交失败");
|
||||
}
|
||||
}
|
||||
|
||||
//通过任务获取作业列表
|
||||
@RequestMapping("/getReplyListByTaskId")
|
||||
public R getReplyListByTaskId(@RequestBody Map<String,Object> params){
|
||||
Page classTaskAndQuesReplyList = classEntityService.getReplyListByTaskId(params);
|
||||
return R.ok().put("page",classTaskAndQuesReplyList);
|
||||
}
|
||||
|
||||
//通过任务获取作业列表(学员)
|
||||
@RequestMapping("/getReplyListByTaskIdStudent")
|
||||
public R getReplyListByTaskIdStudent(@RequestBody Map<String,Object> params){
|
||||
Page classTaskAndQuesReplyList = classEntityService.getReplyListByTaskIdStudent(params);
|
||||
return R.ok().put("page",classTaskAndQuesReplyList);
|
||||
}
|
||||
|
||||
//心得评分
|
||||
@RequestMapping("/editTaskScore")
|
||||
public R editTaskScore(@RequestBody Map<String,Object> params){
|
||||
return classEntityService.editTaskScore(params);
|
||||
}
|
||||
|
||||
//打分
|
||||
@RequestMapping("/editScore")
|
||||
public R editScore(@RequestBody Map<String,Object> params){
|
||||
return classEntityService.editScore(params);
|
||||
}
|
||||
|
||||
//评分提醒
|
||||
@RequestMapping("/editScoreRemind")
|
||||
public R editScoreRemind(){
|
||||
return classEntityService.editScoreRemind();
|
||||
}
|
||||
|
||||
//编辑作业
|
||||
@RequestMapping("/editClassTaskAndQuesReply")
|
||||
public R editClassTaskAndQuesReply(@RequestBody ClassTaskAndQuesReply classTaskAndQuesReply){
|
||||
classEntityService.editClassTaskAndQuesReply(classTaskAndQuesReply);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//作业详情
|
||||
@RequestMapping("/getClassTaskAndQuesReplyInfo")
|
||||
public R getClassTaskAndQuesReplyInfo(@RequestBody Map<String,Object> params){
|
||||
ClassTaskAndQuesReply classTaskAndQuesReply = classEntityService.getClassTaskAndQuesReplyInfo(params);
|
||||
return R.ok().put("classTaskAndQuesReply", classTaskAndQuesReply);
|
||||
}
|
||||
|
||||
//课后题详情
|
||||
@RequestMapping("/getQuesReplyInfo")
|
||||
public R getQuesReplyInfo(@RequestBody Map<String,Object> params){
|
||||
ClassTaskAndQuesReply classTaskAndQuesReply = classEntityService.getQuesReplyInfo(params);
|
||||
return R.ok().put("classTaskAndQuesReply", classTaskAndQuesReply);
|
||||
}
|
||||
|
||||
//思考题列表
|
||||
@RequestMapping("/getThinkQuestionList")
|
||||
public R getThinkQuestionList(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("thinkQuestionList",classEntityService.getThinkQuestionList(params));
|
||||
}
|
||||
|
||||
//思考题列表(学员)
|
||||
@RequestMapping("/getThinkQuestionListStudent")
|
||||
public R getThinkQuestionListStudent(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("getThinkQuestionListStudent",classEntityService.getThinkQuestionListStudent(params));
|
||||
}
|
||||
|
||||
//学员成绩
|
||||
@RequestMapping("/getUserScore")
|
||||
public R getUserScore(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("result",classEntityService.getUserScore(params));
|
||||
}
|
||||
|
||||
//学员成绩列表
|
||||
@RequestMapping("/userScoreList")
|
||||
public R userScoreList(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("result",classEntityService.userScoreList(params));
|
||||
}
|
||||
|
||||
//导出学员成绩
|
||||
@RequestMapping("/exportUserScore")
|
||||
public void exportUserScore(HttpServletResponse response,@RequestBody Map<String,Object> params){
|
||||
List<Map<String,Object>> userScoreList = classEntityService.userScoreList(params);
|
||||
XSSFWorkbook wb = new XSSFWorkbook();
|
||||
//创建一张表
|
||||
Sheet sheet = wb.createSheet("Student");
|
||||
//创建第一行,起始为0
|
||||
Row titleRow = sheet.createRow(0);
|
||||
titleRow.createCell(0).setCellValue("姓名");
|
||||
titleRow.createCell(1).setCellValue("电话");
|
||||
titleRow.createCell(2).setCellValue("邮箱");
|
||||
titleRow.createCell(3).setCellValue("任务");
|
||||
titleRow.createCell(4).setCellValue("医案");
|
||||
titleRow.createCell(5).setCellValue("心得");
|
||||
titleRow.createCell(6).setCellValue("思考题");
|
||||
titleRow.createCell(7).setCellValue("考试");
|
||||
titleRow.createCell(8).setCellValue("总成绩");
|
||||
//序号,默认为1
|
||||
int cell = 1;
|
||||
//遍历
|
||||
for (Map<String,Object> map : userScoreList) {
|
||||
Row row = sheet.createRow(cell);
|
||||
MyUserEntity user = (MyUserEntity)map.get("user");
|
||||
row.createCell(0).setCellValue(user.getName());
|
||||
row.createCell(1).setCellValue(user.getTel());
|
||||
row.createCell(2).setCellValue(user.getEmail());
|
||||
row.createCell(3).setCellValue(map.containsKey("task0Score")?map.get("task0Score").toString():"0");
|
||||
row.createCell(4).setCellValue(map.containsKey("task1Score")?map.get("task1Score").toString():"0");
|
||||
row.createCell(5).setCellValue(map.containsKey("experienceScore")?map.get("experienceScore").toString():"0");
|
||||
row.createCell(6).setCellValue(map.containsKey("questionScore")?map.get("questionScore").toString():"0");
|
||||
row.createCell(7).setCellValue(map.containsKey("examScore")?map.get("examScore").toString():"0");
|
||||
row.createCell(8).setCellValue(map.get("userScore").toString());
|
||||
//序号自增
|
||||
cell++;
|
||||
}
|
||||
String fileName = "学生成绩.xlsx";
|
||||
OutputStream outputStream =null;
|
||||
try {
|
||||
//文件名编码格式
|
||||
fileName = URLEncoder.encode(fileName,"UTF-8");
|
||||
//设置ContentType请求信息格式
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
//设置标头
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + fileName);
|
||||
outputStream = response.getOutputStream();
|
||||
wb.write(outputStream);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
try {
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//结班
|
||||
@RequestMapping("/closeClass")
|
||||
@Transactional
|
||||
public R closeClass(@RequestBody Map<String,Object> params){
|
||||
//结班限制
|
||||
R r = classEntityService.closeClass(params);
|
||||
//结班后给合格学员发放证书
|
||||
if ("0".equals(r.get("code").toString())){
|
||||
ClassEntity classEntity = classEntityService.getById(params.get("classId").toString());
|
||||
List<Map<String,Object>> userScoreList = classEntityService.userScoreList(params);
|
||||
if (userScoreList.size() > 0){
|
||||
for (int i=0;i<userScoreList.size(); i++) {
|
||||
Map<String, Object> userScoreMap = userScoreList.get(i);
|
||||
MyUserEntity user = (MyUserEntity)userScoreMap.get("user");
|
||||
if (new BigDecimal(userScoreMap.get("userScore").toString()).compareTo(new BigDecimal(60))>=0){
|
||||
//查询小班下得课程信息
|
||||
List<Map<String,Object>> classCourseInfoLlist = classEntityService.classCourseInfoClassId(classEntity.getId(),0);
|
||||
for (Map<String,Object> classCourseInfo:classCourseInfoLlist){
|
||||
UserCertificate userCertificate = new UserCertificate();
|
||||
userCertificate.setTitle(classEntity.getTitle());
|
||||
String type = "B";
|
||||
//卡一下A证率:普通小班A证率为的10%,精英班A证率为20%
|
||||
if (new BigDecimal(userScoreMap.get("userScore").toString()).compareTo(new BigDecimal(70))>=0&&
|
||||
(classEntity.getTitle().contains("精英")?((i+1)<=(Math.round(userScoreList.size()*0.20))):(i+1)<=(Math.round(userScoreList.size()*0.10)))){
|
||||
type = "A";
|
||||
}
|
||||
userCertificate.setType(type);
|
||||
userCertificate.setLabelId(5);
|
||||
userCertificate.setUserId(user.getId());
|
||||
userCertificate.setClassId(classEntity.getId());
|
||||
if (StringUtils.isNotEmpty(classCourseInfo.get("titleAbbr").toString())
|
||||
&&StringUtils.isNotEmpty(classCourseInfo.get("courseETitle").toString())){
|
||||
String certificateNo = classEntityService.getNextCertificateNo(type,classCourseInfo.get("titleAbbr").toString());
|
||||
userCertificate.setCertificateNo(certificateNo);
|
||||
userCertificate.setCourseId((Integer) classCourseInfo.get("courseId"));
|
||||
if (StringUtils.isNotEmpty(user.getPhoto())&&StringUtils.isNotEmpty(user.getName())){
|
||||
String startYear = DateUtil.year(classEntity.getStartTime())+"";
|
||||
String startMonth = DateUtil.month(classEntity.getStartTime())+1+"";
|
||||
String startDay = DateUtil.dayOfMonth(classEntity.getStartTime())+"";
|
||||
String endYear = DateUtil.year(classEntity.getEndTime())+"";
|
||||
String endMonth = DateUtil.month(classEntity.getEndTime())+1+"";
|
||||
String endDay = DateUtil.dayOfMonth(classEntity.getEndTime())+"";
|
||||
double keshiTotal = (double)classCourseInfo.get("keshi");
|
||||
String keshi = (keshiTotal+"").replace(".0","");
|
||||
String courseTitle = classCourseInfo.get("courseTitle").toString();
|
||||
if (courseTitle.contains("【")){
|
||||
courseTitle = courseTitle.substring(0,courseTitle.indexOf("【"));
|
||||
}
|
||||
String[] des = {startYear,startMonth,startDay,endYear,endMonth,endDay,
|
||||
classEntity.getTitle(),courseTitle,keshi};
|
||||
String[] edes = {classCourseInfo.get("courseETitle").toString(),keshi};
|
||||
String url = userCertificateService.generateCertificate(type,certificateNo,user.getPhoto(),user.getName(),
|
||||
des, edes, endYear,endMonth,endDay);
|
||||
userCertificate.setCertificateUrl(url);
|
||||
}
|
||||
userCertificateService.save(userCertificate);
|
||||
}else {
|
||||
R.error("课程未设置英文名或缩写");
|
||||
}
|
||||
SysNotice notice = new SysNotice();
|
||||
notice.setUserId(user.getId());
|
||||
String noticeContent = classCourseInfo.get("courseTitle").toString();
|
||||
if ("A".equals(type)){
|
||||
notice.setContent("您参与的"+classEntity.getTitle()+"小班,已顺利结课,恭喜您," +
|
||||
"获得"+noticeContent+"课程的A证书,在证书管理填写您的相关信息,即可出证啦!");
|
||||
}else {
|
||||
notice.setContent("您参与的"+classEntity.getTitle()+"小班,已顺利结课,恭喜您," +
|
||||
"获得"+noticeContent+"课程的B证书,在证书管理填写您的相关信息,即可出证啦!");
|
||||
}
|
||||
sysNoticeService.save(notice);
|
||||
}
|
||||
}else {
|
||||
SysNotice notice = new SysNotice();
|
||||
notice.setUserId(user.getId());
|
||||
notice.setContent("您参与的"+classEntity.getTitle()+"小班已经结束,很遗憾,您未获得课程证书。期待您下次能考出好的成绩!");
|
||||
sysNoticeService.save(notice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return R.ok();
|
||||
}else {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
//生成证书图片
|
||||
@RequestMapping("/generateCertificateClass")
|
||||
public R generateCertificateClass(@RequestBody Map<String,Object> params) {
|
||||
UserCertificate userCertificate = userCertificateService.getById(params.get("id").toString());
|
||||
MyUserEntity user = userService.getById(userCertificate.getUserId());
|
||||
String photoUrl = user.getPhoto();//证书人照片
|
||||
String realName = user.getName();//真实姓名
|
||||
String type = userCertificate.getType();//证书类型A a证 B b证 ZK自考
|
||||
if ("ZK".equals(type)){
|
||||
CourseEntity courseEntity = courseService.getById(userCertificate.getCourseId());
|
||||
String courseTitle = userCertificate.getTitle();
|
||||
ClassExamUser classExamUser = classExamUserService.getUserHighExam(user.getId(),courseEntity.getId());
|
||||
String endYear = DateUtil.year(classExamUser.getEndTime())+"";
|
||||
String endMonth = DateUtil.month(classExamUser.getEndTime())+1+"";
|
||||
String endDay = DateUtil.dayOfMonth(classExamUser.getEndTime())+"";
|
||||
String[] description= {endYear,endMonth,endDay,courseTitle};
|
||||
String[] edes = {courseEntity.getEtitle()};
|
||||
String certificateNo = userCertificate.getCertificateNo();//证书编号
|
||||
String url = userCertificateService.generateCertificate(type,certificateNo,photoUrl,realName, description, edes, endYear,endMonth,endDay);
|
||||
userCertificate.setCertificateUrl(url);
|
||||
userCertificateService.updateById(userCertificate);
|
||||
}else {
|
||||
ClassEntity classEntity = classEntityService.getById(userCertificate.getClassId());
|
||||
String startYear = DateUtil.year(classEntity.getStartTime())+"";
|
||||
String startMonth = DateUtil.month(classEntity.getStartTime())+1+"";
|
||||
String startDay = DateUtil.dayOfMonth(classEntity.getStartTime())+"";
|
||||
String endYear = DateUtil.year(classEntity.getEndTime())+"";
|
||||
String endMonth = DateUtil.month(classEntity.getEndTime())+1+"";
|
||||
String endDay = DateUtil.dayOfMonth(classEntity.getEndTime())+"";
|
||||
List<Map<String,Object>> list = classEntityService.classCourseInfoClassId(classEntity.getId(),userCertificate.getCourseId());
|
||||
for (Map<String,Object> map:list){
|
||||
double keshiTotal = (double)map.get("keshi");
|
||||
String keshi = (keshiTotal+"").replace(".0","");
|
||||
String courseTitle = map.get("courseTitle").toString();
|
||||
if (courseTitle.contains("【")){
|
||||
courseTitle = courseTitle.substring(0,courseTitle.indexOf("【"));
|
||||
}
|
||||
String[] des = {startYear,startMonth,startDay,endYear,endMonth,endDay,
|
||||
classEntity.getTitle(),courseTitle,keshi};
|
||||
String[] edes = {map.get("courseETitle").toString(),keshi};
|
||||
String certificateNo = userCertificate.getCertificateNo();
|
||||
String url = userCertificateService.generateCertificate(type,certificateNo,photoUrl,realName,des, edes, endYear,endMonth,endDay);
|
||||
userCertificate.setCertificateUrl(url);
|
||||
userCertificateService.updateById(userCertificate);
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//获取小班证书
|
||||
@RequestMapping("/getUserCertificateByClassId")
|
||||
public R getUserCertificateByClassId(@RequestBody Map<String,Object> params) {
|
||||
LambdaQueryWrapper<UserCertificate> wrapper = new LambdaQueryWrapper<>();
|
||||
if (StringUtils.isNotBlank(params.get("classId").toString())){
|
||||
wrapper.eq(UserCertificate::getClassId,params.get("classId"));
|
||||
}
|
||||
wrapper.eq(UserCertificate::getUserId,params.get("userId"));
|
||||
List<UserCertificate> userCertificate = userCertificateService.list(wrapper);
|
||||
return R.ok().put("userCertificate",userCertificate);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,345 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.excel.ExcelUtil;
|
||||
import com.peanut.common.utils.DateUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.*;
|
||||
import com.peanut.modules.master.service.CourseService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
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.multipart.MultipartFile;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController("commonClassExam")
|
||||
@RequestMapping("common/classExam")
|
||||
public class ClassExamController {
|
||||
|
||||
@Autowired
|
||||
private ClassExamService classExamService;
|
||||
|
||||
@Autowired
|
||||
private ClassExamUserService classExamUserService;
|
||||
@Autowired
|
||||
private ClassExamSubjectService classExamSubjectService;
|
||||
@Autowired
|
||||
private ClassExamOptionService classExamOptionService;
|
||||
@Autowired
|
||||
private CourseService courseService;
|
||||
@Autowired
|
||||
private ClassEntityService classEntityService;
|
||||
@Autowired
|
||||
private UserCertificateService userCertificateService;
|
||||
@Autowired
|
||||
private SysNoticeService sysNoticeService;
|
||||
|
||||
//导入考试题
|
||||
@RequestMapping("/importSubject")
|
||||
@Transactional
|
||||
public R importSubject(@RequestParam("file") MultipartFile file, @RequestParam("courseId") int courseId) {
|
||||
int num = 0;
|
||||
try (InputStream fis = file.getInputStream()) {
|
||||
//解析数据
|
||||
ExcelUtil example = new ExcelUtil();
|
||||
example.processOneSheet(fis);
|
||||
LinkedHashMap<String, String> map = example.getRowContents();
|
||||
Iterator<Map.Entry<String, String>> it = map.entrySet().iterator();
|
||||
//处理数据
|
||||
int count = 0;
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<String, String> entry = it.next();
|
||||
String pos = entry.getKey();
|
||||
String rowNo = pos.replaceAll("[a-zA-Z]", "");
|
||||
count = Integer.parseInt(rowNo);
|
||||
// System.out.println(pos + ";" + entry.getValue());
|
||||
}
|
||||
List<ClassExamOption> optionList = new ArrayList<>();
|
||||
//先校验数据
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i=2;i<=count;i++){
|
||||
//类型
|
||||
String type = map.containsKey("A"+i)?map.get("A"+i):"";
|
||||
if (type.contains("单选")||type.contains("多选")){
|
||||
}else {
|
||||
sb.append("第"+i+"行题目类型出错\n");
|
||||
}
|
||||
String option1 = map.containsKey("C"+i)?map.get("C"+i):"";
|
||||
if (StringUtils.isBlank(option1)){
|
||||
sb.append("第"+i+"行无选项1\n");
|
||||
}
|
||||
String option2 = map.containsKey("D"+i)?map.get("D"+i):"";
|
||||
if (StringUtils.isBlank(option2)){
|
||||
sb.append("第"+i+"行无选项2\n");
|
||||
}
|
||||
String option3 = map.containsKey("E"+i)?map.get("E"+i):"";
|
||||
if (StringUtils.isBlank(option3)){
|
||||
sb.append("第"+i+"行无选项3\n");
|
||||
}
|
||||
String option4 = map.containsKey("F"+i)?map.get("F"+i):"";
|
||||
if (StringUtils.isBlank(option4)){
|
||||
sb.append("第"+i+"行无选项4\n");
|
||||
}
|
||||
String answer = map.containsKey("I"+i)?map.get("I"+i):"";
|
||||
if (StringUtils.isBlank(answer)){
|
||||
sb.append("第"+i+"行无答案\n");
|
||||
}
|
||||
//题目
|
||||
String content = map.containsKey("B"+i)?map.get("B"+i):"";
|
||||
if (StringUtils.isBlank(content)) {
|
||||
sb.append("第"+i+"行无题目\n");
|
||||
}
|
||||
}
|
||||
if (sb.length() > 0){
|
||||
throw new Exception(sb.toString());
|
||||
}
|
||||
for (int i=2;i<=count;i++){
|
||||
ClassExamSubject subject = new ClassExamSubject();
|
||||
subject.setCourseId(courseId);
|
||||
if (map.get("A"+i).contains("单选")){
|
||||
subject.setType(0);
|
||||
}else if (map.get("A"+i).contains("多选")){
|
||||
subject.setType(1);
|
||||
}
|
||||
subject.setContent(map.get("B"+i));
|
||||
//所属章节
|
||||
subject.setChapter(map.containsKey("N"+i)?map.get("N"+i):"");
|
||||
//音视频序号
|
||||
subject.setMedia(map.containsKey("O"+i)?map.get("O"+i):"");
|
||||
//音视频时间
|
||||
subject.setMediaTime(map.containsKey("P"+i)?map.get("P"+i):"");
|
||||
//出题人
|
||||
subject.setCreateUser(map.containsKey("Q"+i)?map.get("Q"+i):"");
|
||||
classExamSubjectService.save(subject);
|
||||
num++;
|
||||
//插入选项
|
||||
insertOption(optionList,subject.getId(),map.get("C"+i),map.get("I"+i));
|
||||
insertOption(optionList,subject.getId(),map.get("D"+i),map.get("I"+i));
|
||||
insertOption(optionList,subject.getId(),map.get("E"+i),map.get("I"+i));
|
||||
insertOption(optionList,subject.getId(),map.get("F"+i),map.get("I"+i));
|
||||
insertOption(optionList,subject.getId(),map.containsKey("G"+i)?map.get("G"+i):"",map.get("I"+i));
|
||||
insertOption(optionList,subject.getId(),map.containsKey("H"+i)?map.get("H"+i):"",map.get("I"+i));
|
||||
}
|
||||
classExamOptionService.saveBatch(optionList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return R.error(e.getMessage());
|
||||
}
|
||||
return R.ok("导入成功"+num+"条");
|
||||
}
|
||||
public void insertOption(List<ClassExamOption> optionList,int subjectId,String content,String rightAnswer){
|
||||
if (StringUtils.isNotEmpty(content)){
|
||||
ClassExamOption option = new ClassExamOption();
|
||||
option.setSubjectId(subjectId);
|
||||
if (rightAnswer.contains(content.substring(0,1))){
|
||||
option.setRightWrong(1);
|
||||
}else {
|
||||
option.setRightWrong(0);
|
||||
}
|
||||
char[] c = content.toCharArray();
|
||||
if (c.length>1){
|
||||
if (c[1]=='、'||c[1]==':'||c[1]==';'||c[1]==':'||c[1]==';'||c[1]==' '||c[1]=='.'){
|
||||
content = content.substring(2);
|
||||
}else {
|
||||
content = content.substring(1);
|
||||
}
|
||||
}else {
|
||||
content = "";
|
||||
}
|
||||
if (StringUtils.isNotBlank(content)){
|
||||
option.setContent(content);
|
||||
optionList.add(option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//考试题目列表
|
||||
@RequestMapping("/getClassExamSubjectList")
|
||||
public R getClassExamSubjectList(@RequestBody Map<String,Object> params){
|
||||
Page classExamSubjectList = classExamService.getClassExamSubjectList(params);
|
||||
return R.ok().put("page",classExamSubjectList);
|
||||
}
|
||||
|
||||
//获取服务器时间
|
||||
@RequestMapping("/getServerTime")
|
||||
public R getServerTime(){
|
||||
return R.ok().put("serverTime",new Date().getTime());
|
||||
}
|
||||
|
||||
//生成试卷
|
||||
@RequestMapping("/generateExamPaper")
|
||||
public R generateExamPaper(@RequestBody Map<String,Object> params){
|
||||
return classExamService.generateExamPaper(params);
|
||||
}
|
||||
|
||||
//考试中的试卷
|
||||
@RequestMapping("/examingPaper")
|
||||
public R examingPaper(){
|
||||
return classExamService.examingPaper();
|
||||
}
|
||||
|
||||
//提交选项
|
||||
@RequestMapping("/submitOption")
|
||||
public R submitOption(@RequestBody Map<String,Object> params){
|
||||
classExamService.submitOption(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//提交试卷
|
||||
@RequestMapping("/submitExamPaper")
|
||||
public R submitExamPaper(@RequestBody Map<String,Object> params){
|
||||
ClassExamUser classExamUser = classExamService.submitExamPaper(params);
|
||||
if ("1".equals(classExamUser.getType())){
|
||||
SysNotice notice = new SysNotice();
|
||||
notice.setUserId(classExamUser.getUserId());
|
||||
notice.setContent("考试已完成,请等待结班获取证书获取情况。");
|
||||
sysNoticeService.save(notice);
|
||||
}
|
||||
//自考的人成绩达标,发放证书
|
||||
if ("2".equals(classExamUser.getType())&&classExamUser.getScore()>=60){
|
||||
SysNotice notice = new SysNotice();
|
||||
notice.setUserId(classExamUser.getUserId());
|
||||
notice.setContent("恭喜您,您自考成绩合格,获得课程自考证书,在证书管理填写您的相关信息,即可出证啦!");
|
||||
sysNoticeService.save(notice);
|
||||
UserCertificate userCertificate = new UserCertificate();
|
||||
userCertificate.setType("ZK");
|
||||
userCertificate.setLabelId(8);
|
||||
userCertificate.setUserId(ShiroUtils.getUId());
|
||||
CourseEntity courseEntity = courseService.getById(classExamUser.getRelationId());
|
||||
String courseTitle = courseEntity.getTitle();
|
||||
if (courseTitle.contains("【")){
|
||||
courseTitle = courseEntity.getTitle().substring(0,courseEntity.getTitle().indexOf("【"));
|
||||
}
|
||||
userCertificate.setTitle(courseTitle);
|
||||
String certificateNo = classEntityService.getNextCertificateNo("ZK",courseEntity.getTitleAbbr());//证书编号
|
||||
userCertificate.setCertificateNo(certificateNo);
|
||||
if (StringUtils.isNotEmpty(ShiroUtils.getUser().getPhoto())&&StringUtils.isNotEmpty(ShiroUtils.getUser().getName())){
|
||||
String endYear = DateUtil.year(classExamUser.getEndTime())+"";
|
||||
String endMonth = DateUtil.month(classExamUser.getEndTime())+1+"";
|
||||
String endDay = DateUtil.dayOfMonth(classExamUser.getEndTime())+"";
|
||||
String[] description= {endYear,endMonth,endDay,courseTitle};
|
||||
String[] edes = {courseEntity.getEtitle()};
|
||||
String url = userCertificateService.generateCertificate("ZK",certificateNo,ShiroUtils.getUser().getPhoto(),
|
||||
ShiroUtils.getUser().getName(), description, edes, endYear,endMonth,endDay);
|
||||
userCertificate.setCertificateUrl(url);
|
||||
}
|
||||
userCertificate.setCourseId(courseEntity.getId());
|
||||
userCertificateService.save(userCertificate);
|
||||
}
|
||||
return R.ok().put("examPaper",classExamUser);
|
||||
}
|
||||
|
||||
//试卷列表
|
||||
@RequestMapping("/getExamPaperList")
|
||||
public R getExamPaperList(@RequestBody Map<String,Object> params){
|
||||
Object examPaper = classExamService.getExamPaperList(params);
|
||||
return R.ok().put("examPaper",examPaper);
|
||||
}
|
||||
|
||||
//自考试卷列表
|
||||
@RequestMapping("/getZKExamPaperList")
|
||||
public R getZKExamPaperList(@RequestBody Map<String,Object> params){
|
||||
List<ClassExamUser> ZKExamUserList = classExamUserService.list(new LambdaQueryWrapper<ClassExamUser>()
|
||||
.eq(ClassExamUser::getType,"2")
|
||||
.eq(ClassExamUser::getUserId,ShiroUtils.getUId())
|
||||
.eq(ClassExamUser::getRelationId,params.get("courseId"))
|
||||
.orderByAsc(ClassExamUser::getId));
|
||||
return R.ok().put("ZKExamUserList",ZKExamUserList);
|
||||
}
|
||||
|
||||
//自考试卷列表
|
||||
@RequestMapping("/getNextZKTime")
|
||||
public R getNextZKTime(@RequestBody Map<String,Object> params){
|
||||
List<ClassExamUser> ZKExamUserList = classExamUserService.list(new LambdaQueryWrapper<ClassExamUser>()
|
||||
.eq(ClassExamUser::getType,"2")
|
||||
.eq(ClassExamUser::getUserId,ShiroUtils.getUId())
|
||||
.eq(ClassExamUser::getRelationId,params.get("courseId"))
|
||||
.orderByDesc(ClassExamUser::getId));
|
||||
if (ZKExamUserList.size() == 0){
|
||||
return R.ok().put("nextZKTime",null).put("nextLongTime",null);
|
||||
}else {
|
||||
Date nextTime = DateUtils.addDateDays(ZKExamUserList.get(0).getStartTime(),183);
|
||||
return R.ok().put("nextZKTime",nextTime).put("nextLongTime",nextTime.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
//试卷详情
|
||||
@RequestMapping("/getExamPaperInfo")
|
||||
public R getExamPaperInfo(@RequestBody Map<String,Object> params){
|
||||
return classExamService.getExamPaperInfo(params);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//添加题目
|
||||
@RequestMapping("/addClassExamSubject")
|
||||
public R addClassExamSubject(@RequestBody ClassExamSubject classExamSubject){
|
||||
classExamService.addClassExamSubject(classExamSubject);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//添加选项
|
||||
@RequestMapping("/addClassExamOption")
|
||||
public R addClassExamOption(@RequestBody ClassExamOption classExamOption){
|
||||
classExamService.addClassExamOption(classExamOption);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//题目详情
|
||||
@RequestMapping("/classExamSubjectInfo")
|
||||
public R classExamSubjectInfo(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("classExamSubjectInfo",classExamService.classExamSubjectInfo(params));
|
||||
}
|
||||
|
||||
//修改题目
|
||||
@RequestMapping("/updateClassExamSubject")
|
||||
public R updateClassExamSubject(@RequestBody ClassExamSubject classExamSubject){
|
||||
classExamService.updateClassExamSubject(classExamSubject);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//修改选项
|
||||
@RequestMapping("/updateClassExamOption")
|
||||
public R updateClassExamOption(@RequestBody ClassExamOption classExamOption){
|
||||
classExamService.updateClassExamOption(classExamOption);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//删除题目
|
||||
@RequestMapping("/delClassExamSubject")
|
||||
public R delClassExamSubject(@RequestBody Map<String,Object> params){
|
||||
classExamService.delClassExamSubject(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//删除课程下全部题目
|
||||
@RequestMapping("/delSubjectByCourseId")
|
||||
public R delSubjectByCourseId(@RequestBody Map<String,Object> params){
|
||||
classExamService.delSubjectByCourseId(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//删除选项
|
||||
@RequestMapping("/delClassExamOption")
|
||||
public R delClassExamOption(@RequestBody Map<String,Object> params){
|
||||
classExamService.delClassExamOption(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.service.ShopProductService;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.CouponHistoryService;
|
||||
import com.peanut.modules.common.service.CouponService;
|
||||
import com.peanut.modules.common.service.CouponToProductService;
|
||||
import com.peanut.modules.master.service.CourseService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController("commonCoupon")
|
||||
@RequestMapping("common/coupon")
|
||||
public class CouponController {
|
||||
|
||||
@Autowired
|
||||
private CouponService couponService;
|
||||
@Autowired
|
||||
private CouponHistoryService couponHistoryService;
|
||||
@Autowired
|
||||
private CourseService courseService;
|
||||
@Autowired
|
||||
private CouponToProductService couponToProductService;
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
|
||||
//优惠卷列表
|
||||
@RequestMapping("/getCouponList")
|
||||
public R getCouponList(@RequestBody Map params){
|
||||
Integer limit = Integer.valueOf(params.get("limit").toString());
|
||||
Integer page = Integer.valueOf(params.get("page").toString());
|
||||
LambdaQueryWrapper<CouponEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
if (StringUtils.isNotEmpty(params.get("couponType").toString())){
|
||||
wrapper.eq(CouponEntity::getCouponType,params.get("couponType"));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("couponRange").toString())){
|
||||
wrapper.eq(CouponEntity::getCouponRange,params.get("couponRange"));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("couponName").toString())){
|
||||
wrapper.like(CouponEntity::getCouponName,params.get("couponName"));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("currentState").toString())){
|
||||
wrapper.eq(CouponEntity::getCurrentState,params.get("currentState"));
|
||||
}
|
||||
wrapper.orderByDesc(CouponEntity::getCreateTime);
|
||||
Page<CouponEntity> couponPage = couponService.page(new Page<>(page, limit), wrapper);
|
||||
for (CouponEntity couponEntity : couponPage.getRecords()) {
|
||||
couponService.setRangeList(couponEntity);
|
||||
Long count = couponHistoryService.count(new LambdaQueryWrapper<CouponHistory>()
|
||||
.eq(CouponHistory::getCouponId,couponEntity.getId()));
|
||||
couponEntity.setGrantCount(count.intValue());
|
||||
}
|
||||
return R.ok().put("couponPage",couponPage);
|
||||
}
|
||||
|
||||
//用户优惠卷列表
|
||||
@RequestMapping("/getCouponHistoryList")
|
||||
public R getCouponHistoryList(@RequestBody Map params){
|
||||
Integer limit = Integer.valueOf(params.get("limit").toString());
|
||||
Integer page = Integer.valueOf(params.get("page").toString());
|
||||
MPJLambdaWrapper<CouponHistory> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.leftJoin(CouponEntity.class,CouponEntity::getId,CouponHistory::getCouponId);
|
||||
wrapper.leftJoin(MyUserEntity.class,MyUserEntity::getId,CouponHistory::getUserId);
|
||||
wrapper.selectAll(CouponHistory.class);
|
||||
if (StringUtils.isNotEmpty(params.get("getType").toString())){
|
||||
wrapper.eq(CouponHistory::getGetType,params.get("getType"));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("status").toString())){
|
||||
wrapper.eq(CouponHistory::getStatus,params.get("status"));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("userInfo").toString())) {
|
||||
wrapper.and(t->t.like(MyUserEntity::getName,params.get("userInfo")).or().like(MyUserEntity::getNickname,params.get("userInfo"))
|
||||
.or().like(MyUserEntity::getTel,params.get("userInfo")).or().like(MyUserEntity::getEmail,params.get("userInfo")));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("userId").toString())){
|
||||
wrapper.eq(MyUserEntity::getId,params.get("userId"));
|
||||
}
|
||||
wrapper.orderByAsc(CouponHistory::getStatus);
|
||||
wrapper.orderByDesc(CouponHistory::getCreateTime);
|
||||
Page<CouponHistory> couponList = couponHistoryService.page(new Page<>(page, limit), wrapper);
|
||||
for (CouponHistory ch:couponList.getRecords()){
|
||||
ch.setCouponEntity(couponService.getByIdSetRange(ch.getCouponId()));
|
||||
}
|
||||
return R.ok().put("couponList",couponList);
|
||||
}
|
||||
|
||||
//用户优惠劵详情
|
||||
@RequestMapping("/getCouponHistoryInfo")
|
||||
public R getCouponHistoryInfo(@RequestBody Map<String,Object> params){
|
||||
CouponHistory CouponHistory = couponHistoryService.getById(Integer.parseInt(params.get("id").toString()));
|
||||
CouponEntity couponEntity = couponService.setRangeList(couponService.getByIdSetRange(CouponHistory.getCouponId()));
|
||||
CouponHistory.setCouponEntity(couponEntity);
|
||||
return R.ok().put("couponHistory",CouponHistory);
|
||||
}
|
||||
|
||||
//优惠劵详情
|
||||
@RequestMapping("/getCouponInfo")
|
||||
public R getCouponInfo(@RequestBody Map<String,Object> params){
|
||||
CouponEntity couponEntity = couponService.getByIdSetRange(Integer.parseInt(params.get("id").toString()));
|
||||
couponService.setRangeList(couponEntity);
|
||||
Long count = couponHistoryService.count(new LambdaQueryWrapper<CouponHistory>()
|
||||
.eq(CouponHistory::getCouponId,couponEntity.getId()));
|
||||
couponEntity.setGrantCount(count.intValue());
|
||||
return R.ok().put("couponEntity",couponEntity);
|
||||
}
|
||||
|
||||
//修改优惠劵状态
|
||||
@RequestMapping("/updateCouponState")
|
||||
public R updateCouponState(@RequestBody Map<String,Object> params){
|
||||
CouponEntity coupon = couponService.getById(params.get("id").toString());
|
||||
coupon.setCurrentState((int)params.get("currentState"));
|
||||
couponService.updateById(coupon);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//修改优惠劵
|
||||
@RequestMapping("/updateCoupon")
|
||||
public R updateCoupon(@RequestBody CouponEntity couponEntity){
|
||||
couponService.updateById(couponEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//删除优惠劵
|
||||
@RequestMapping("/delCoupon")
|
||||
@Transactional
|
||||
public R delCoupon(@RequestBody Map<String,Object> params){
|
||||
int couponId = Integer.parseInt(params.get("id").toString());
|
||||
Long count = couponHistoryService.count(new LambdaQueryWrapper<CouponHistory>()
|
||||
.eq(CouponHistory::getCouponId,couponId));
|
||||
if (count>0){
|
||||
return R.error("已有用户拥有优惠券");
|
||||
}
|
||||
CouponEntity c = couponService.getById(couponId);
|
||||
if (c.getCurrentState()==0){
|
||||
return R.error("优惠券发放中,请先结束再删除");
|
||||
}
|
||||
couponService.removeById(couponId);
|
||||
//删除优惠券商品绑定
|
||||
List<CouponToProduct> ctps = couponToProductService.list(new LambdaQueryWrapper<CouponToProduct>()
|
||||
.eq(CouponToProduct::getCouponId,couponId));
|
||||
for (CouponToProduct ctp:ctps){
|
||||
couponToProductService.removeById(ctp.getId());
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//新建优惠劵
|
||||
@RequestMapping("/addCoupon")
|
||||
public R addCoupon(@RequestBody CouponEntity couponEntity){
|
||||
couponService.save(couponEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//发放优惠劵
|
||||
@RequestMapping("/insertCouponHistory")
|
||||
public R insertCouponHistory(@RequestBody Map<String,Object> params){
|
||||
int couponId = (int)params.get("couponId");
|
||||
int userId = (int)params.get("userId");
|
||||
int getType = (int)params.get("getType");
|
||||
String remark = params.get("remark").toString();
|
||||
return couponService.insertCouponHistory(couponId,userId,getType,0,remark);
|
||||
}
|
||||
|
||||
//删除用户优惠卷
|
||||
@RequestMapping("/delCouponHistory")
|
||||
public R delCouponHistory(@RequestBody Map<String,Object> params){
|
||||
couponHistoryService.removeById(params.get("couponHistoryId").toString());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//优惠卷可绑定课程
|
||||
@RequestMapping("/getCourseList")
|
||||
public R getCourseList(@RequestBody Map<String,Object> params){
|
||||
Integer limit = Integer.valueOf(params.get("limit").toString());
|
||||
Integer page = Integer.valueOf(params.get("page").toString());
|
||||
LambdaQueryWrapper<CourseEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.select(CourseEntity::getId,CourseEntity::getTitle);
|
||||
wrapper.like(CourseEntity::getTitle,params.get("title"));
|
||||
wrapper.orderByDesc(CourseEntity::getId);
|
||||
Page<CourseEntity> courses = courseService.page(new Page<>(page, limit), wrapper);
|
||||
return R.ok().put("courses",courses);
|
||||
}
|
||||
|
||||
//付款时优惠卷列表
|
||||
@RequestMapping("/getCouponListPayment")
|
||||
public R getCouponListPayment(@RequestBody Map<String,Object> params){
|
||||
List<CouponHistory> couponHistoryList = couponService.getCouponListPayment(params);
|
||||
return R.ok().put("couponHistoryList",couponHistoryList);
|
||||
}
|
||||
|
||||
//购买商品绑定优惠卷列表
|
||||
@RequestMapping("/couponToProductList")
|
||||
public R couponToShopproductList(@RequestBody Map<String,Object> params){
|
||||
Integer limit = Integer.valueOf(params.get("limit").toString());
|
||||
Integer page = Integer.valueOf(params.get("page").toString());
|
||||
LambdaQueryWrapper<CouponToProduct> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(CouponToProduct::getProductId,params.get("productId"));
|
||||
wrapper.orderByDesc(CouponToProduct::getId);
|
||||
Page<CouponToProduct> couponToShopproductPage = couponToProductService.page(new Page<>(page, limit), wrapper);
|
||||
for (CouponToProduct couponToProduct : couponToShopproductPage.getRecords()) {
|
||||
couponToProduct.setCouponEntity(couponService.getById(couponToProduct.getCouponId()));
|
||||
couponToProduct.setShopProduct(shopProductService.getById(couponToProduct.getShopProduct()));
|
||||
}
|
||||
return R.ok().put("couponToShopproductPage",couponToShopproductPage);
|
||||
}
|
||||
|
||||
//商品绑定优惠卷
|
||||
@RequestMapping("/setCouponToProduct")
|
||||
public R setCouponToProduct(@RequestBody CouponToProduct couponToProduct){
|
||||
CouponToProduct c = couponToProductService.getOne(new LambdaQueryWrapper<CouponToProduct>()
|
||||
.eq(CouponToProduct::getCouponId, couponToProduct.getCouponId())
|
||||
.eq(CouponToProduct::getProductId, couponToProduct.getProductId()));
|
||||
if (c == null){
|
||||
couponToProductService.save(couponToProduct);
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error("已存在");
|
||||
}
|
||||
}
|
||||
|
||||
//解绑商品优惠卷
|
||||
@RequestMapping("/unbindCouponToProduct")
|
||||
public R unbindCouponToProduct(@RequestBody Map<String,Object> params){
|
||||
couponToProductService.removeById(params.get("id").toString());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.CourseGuestbook;
|
||||
import com.peanut.modules.common.entity.CourseGuestbookSupport;
|
||||
import com.peanut.modules.common.service.CourseGuestbookService;
|
||||
import com.peanut.modules.common.service.MyUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController("commonCourseGuestbook")
|
||||
@RequestMapping("common/courseGuestbook")
|
||||
public class CourseGuestbookController {
|
||||
|
||||
@Autowired
|
||||
private CourseGuestbookService service;
|
||||
@Autowired
|
||||
private MyUserService userService;
|
||||
|
||||
@RequestMapping("/getCourseGuestbookList")
|
||||
public R getCourseGuestbookList(@RequestBody Map<String,Object> map){
|
||||
Page courseGuestbookList = service.getCourseGuestbookList(map);
|
||||
return R.ok().put("page",courseGuestbookList);
|
||||
}
|
||||
|
||||
@RequestMapping("/addCourseGuestbook")
|
||||
public R addCourseGuestbook(@RequestBody CourseGuestbook courseGuestbook){
|
||||
service.save(courseGuestbook);
|
||||
CourseGuestbook res = service.getById(courseGuestbook.getId());
|
||||
res.setUser(userService.getById(res.getUserId()));
|
||||
return R.ok().put("courseGuestbook",res);
|
||||
}
|
||||
|
||||
@RequestMapping("/addCourseGuestbookSupport")
|
||||
public R addCourseGuestbookSupport(@RequestBody Map<String,Object> map){
|
||||
service.addCourseGuestbookSupport(map);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/cancelCourseGuestbookSupport")
|
||||
public R cancelCourseGuestbookSupport(@RequestBody Map<String,Object> map){
|
||||
service.cancelCourseGuestbookSupport(map);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,273 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.config.Constants;
|
||||
import com.peanut.config.DelayQueueConfig;
|
||||
import com.peanut.modules.book.service.TransactionDetailsService;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.*;
|
||||
import com.peanut.modules.common.service.JfTransactionDetailsService;
|
||||
import com.peanut.modules.common.service.MyUserService;
|
||||
import com.peanut.modules.master.service.*;
|
||||
import com.peanut.modules.medical.service.CourseService;
|
||||
import com.peanut.modules.pay.weChatPay.dto.WechatPaymentInfo;
|
||||
import com.peanut.modules.pay.weChatPay.service.WxpayService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.amqp.core.MessagePostProcessor;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController("commonCourseRelearn")
|
||||
@RequestMapping("common/courseRelearn")
|
||||
public class CourseRelearnController {
|
||||
|
||||
@Autowired
|
||||
private UserCourseBuyService userCourseBuyService;
|
||||
@Autowired
|
||||
private CourseService courseService;
|
||||
@Autowired
|
||||
private CourseCatalogueService courseCatalogueService;
|
||||
@Autowired
|
||||
private CourseToMedicalService courseToMedicalService;
|
||||
@Autowired
|
||||
private CourseToSociologyService courseToSociologyService;
|
||||
@Autowired
|
||||
private CourseToPsycheService courseToPsycheService;
|
||||
@Autowired
|
||||
private CourseToTaihumedService courseToTaihumedService;
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
@Autowired
|
||||
private BuyOrderService buyOrderService;
|
||||
@Autowired
|
||||
private MyUserService userService;
|
||||
@Autowired
|
||||
private WxpayService wxpayService;
|
||||
@Autowired
|
||||
private TransactionDetailsService transactionDetailsService;
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
@Autowired
|
||||
private JfTransactionDetailsService jfTransactionDetailsService;
|
||||
|
||||
//复读订单列表
|
||||
@RequestMapping("/orderListRelearn")
|
||||
public R orderListRelearn(@RequestBody Map<String,Object> params) {
|
||||
MPJLambdaWrapper<BuyOrder> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.selectAll(BuyOrder.class);
|
||||
wrapper.leftJoin(MyUserEntity.class, MyUserEntity::getId,BuyOrder::getUserId);
|
||||
wrapper.eq(BuyOrder::getOrderType,"relearn");
|
||||
if (StringUtils.isNotEmpty(params.get("orderSn").toString())) {
|
||||
wrapper.eq(BuyOrder::getOrderSn,params.get("orderSn"));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("userInfo").toString())) {
|
||||
wrapper.and(t->t.like(MyUserEntity::getName,params.get("userInfo")).or().like(MyUserEntity::getNickname,params.get("userInfo"))
|
||||
.or().like(MyUserEntity::getTel,params.get("userInfo")).or().like(MyUserEntity::getEmail,params.get("userInfo")));
|
||||
}
|
||||
wrapper.orderByDesc(BuyOrder::getOrderId);
|
||||
Page<BuyOrder> buyOrderPage = buyOrderService.page(new Page<BuyOrder>(
|
||||
Long.parseLong(params.get("page").toString()), Long.parseLong(params.get("limit").toString())), wrapper);
|
||||
for (BuyOrder buyOrder : buyOrderPage.getRecords()){
|
||||
buyOrder.setUser(userService.getById(buyOrder.getUserId()));
|
||||
}
|
||||
return R.ok().put("buyOrderPage",buyOrderPage);
|
||||
}
|
||||
|
||||
//课程目录是否可复读(已购买并过期)
|
||||
@RequestMapping("/courseCatalogueCanRelearn")
|
||||
public R courseCatalogueCanRelearn(@RequestBody Map<String,Object> params){
|
||||
boolean flag = false;
|
||||
boolean displayFlag = false;
|
||||
CourseCatalogueEntity cc = courseCatalogueService.getById(params.get("courseCatalogueId").toString());
|
||||
if (cc != null) {
|
||||
CourseEntity courseEntity = courseService.getById(cc.getCourseId());
|
||||
if (courseEntity != null) {
|
||||
Long mCount = courseToMedicalService.count(new LambdaQueryWrapper<CourseToMedicine>().eq(CourseToMedicine::getCourseId,courseEntity.getId()));
|
||||
Long sCount = courseToSociologyService.count(new LambdaQueryWrapper<CourseToSociologyEntity>().eq(CourseToSociologyEntity::getCourseId,courseEntity.getId()));
|
||||
Long pCount = courseToPsycheService.count(new LambdaQueryWrapper<CourseToPsyche>().eq(CourseToPsyche::getCourseId,courseEntity.getId()));
|
||||
Long tCount = courseToTaihumedService.count(new LambdaQueryWrapper<CourseToTaihumed>().eq(CourseToTaihumed::getCourseId,courseEntity.getId()));
|
||||
if (mCount>0||sCount > 0||pCount > 0||tCount > 0){
|
||||
List<UserCourseBuyEntity> list = userCourseBuyService.list(new MPJLambdaWrapper<UserCourseBuyEntity>()
|
||||
.disableLogicDel()//查询出已删除数据
|
||||
.eq(UserCourseBuyEntity::getUserId, ShiroUtils.getUId())
|
||||
.eq(UserCourseBuyEntity::getCatalogueId,params.get("courseCatalogueId")));
|
||||
if (list.size() > 0) {
|
||||
flag = true;
|
||||
for (UserCourseBuyEntity userCourseBuyEntity : list) {
|
||||
if (userCourseBuyEntity.getDelFlag()==0) {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
displayFlag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return R.ok().put("canRelearn",flag).put("displayFlag",displayFlag);
|
||||
}
|
||||
|
||||
//课程目录复读列表
|
||||
@RequestMapping("/relearnShopProductList")
|
||||
public R relearnShopProductList(@RequestBody Map<String,Object> params) {
|
||||
CourseCatalogueEntity cc = courseCatalogueService.getById(params.get("catalogueId").toString());
|
||||
if (cc != null) {
|
||||
CourseEntity courseEntity = courseService.getById(cc.getCourseId());
|
||||
if (courseEntity != null){
|
||||
Long mCount = courseToMedicalService.count(new LambdaQueryWrapper<CourseToMedicine>().eq(CourseToMedicine::getCourseId,courseEntity.getId()));
|
||||
Long sCount = courseToSociologyService.count(new LambdaQueryWrapper<CourseToSociologyEntity>().eq(CourseToSociologyEntity::getCourseId,courseEntity.getId()));
|
||||
Long pCount = courseToPsycheService.count(new LambdaQueryWrapper<CourseToPsyche>().eq(CourseToPsyche::getCourseId,courseEntity.getId()));
|
||||
Long tCount = courseToTaihumedService.count(new LambdaQueryWrapper<CourseToTaihumed>().eq(CourseToTaihumed::getCourseId,courseEntity.getId()));
|
||||
if (mCount>0||sCount > 0||pCount > 0||tCount > 0){
|
||||
MPJLambdaWrapper<ShopProduct> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.leftJoin(ShopProductCourseEntity.class,ShopProductCourseEntity::getProductId,ShopProduct::getProductId);
|
||||
wrapper.selectAll(ShopProduct.class);
|
||||
wrapper.eq(ShopProductCourseEntity::getCatalogueId,params.get("catalogueId"));
|
||||
wrapper.eq(ShopProductCourseEntity::getDays,365);
|
||||
wrapper.orderByAsc(ShopProduct::getPrice);
|
||||
List<ShopProduct> shopProducts = shopProductService.list(wrapper);
|
||||
if (shopProducts.size()>0) {
|
||||
ShopProduct shopProduct = shopProducts.get(0);
|
||||
ShopProduct sp1 = new ShopProduct();
|
||||
sp1.setProductId(shopProduct.getProductId());
|
||||
sp1.setProductName(shopProduct.getProductName().replace("一年","一月"));
|
||||
sp1.setProductImages(shopProduct.getProductImages());
|
||||
BigDecimal sp1Price = shopProduct.getPrice().divide(new BigDecimal(12),0, RoundingMode.DOWN);
|
||||
sp1.setPrice(sp1Price);
|
||||
|
||||
ShopProduct sp2 = new ShopProduct();
|
||||
sp2.setProductId(shopProduct.getProductId());
|
||||
sp2.setProductName(shopProduct.getProductName().replace("一年","三月"));
|
||||
sp2.setProductImages(shopProduct.getProductImages());
|
||||
BigDecimal sp2Price = shopProduct.getPrice().divide(new BigDecimal(4),0, RoundingMode.DOWN);
|
||||
sp2Price = sp2Price.multiply(new BigDecimal(0.6));
|
||||
sp2Price = sp2Price.setScale(0, RoundingMode.DOWN);
|
||||
sp2.setPrice(sp2Price);
|
||||
|
||||
List<ShopProduct> res = new ArrayList<>();
|
||||
res.add(sp1);
|
||||
res.add(sp2);
|
||||
return R.ok().put("productList",res);
|
||||
}else {
|
||||
return R.error("未找到一年期商品");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return R.ok().put("productList",new ArrayList<>());
|
||||
}
|
||||
|
||||
@RequestMapping("/relearnSave")
|
||||
@Transactional
|
||||
public R relearnSave(@RequestBody BuyOrder buyOrder){
|
||||
int uid = ShiroUtils.getUId();
|
||||
buyOrder.setOrderStatus("0");
|
||||
buyOrder.setOrderType("relearn");
|
||||
String timeId = IdWorker.getTimeId().substring(0, 32);
|
||||
buyOrder.setOrderSn(timeId);
|
||||
buyOrder.setUserId(uid);
|
||||
buyOrderService.save(buyOrder);
|
||||
BigDecimal totalPrice = buyOrder.getRealMoney();
|
||||
//虚拟币支付
|
||||
if (Constants.PAYMENT_METHOD_VIRTUAL.equals(buyOrder.getPaymentMethod())) {
|
||||
buyOrder.setOrderStatus(Constants.ORDER_STATUS_TO_BE_SHIPPED);
|
||||
MyUserEntity user = userService.getById(buyOrder.getUserId());
|
||||
if (usePeanutCoin(user, totalPrice)) {
|
||||
//处理抵扣积分
|
||||
if(buyOrder.getJfDeduction().compareTo(BigDecimal.ZERO)>0){
|
||||
userCoinJf(buyOrder);
|
||||
}
|
||||
buyOrder.setSuccessTime(new Date());
|
||||
// 更新订单状态
|
||||
buyOrderService.updateOrderStatus(user.getId(), buyOrder.getOrderSn(), "2");
|
||||
//记录用户虚拟币消费
|
||||
if(totalPrice.compareTo(BigDecimal.ZERO)>0){
|
||||
transactionDetailsService.recordTransaction(buyOrder, user, totalPrice);
|
||||
}
|
||||
//插入复读记录
|
||||
userCourseBuyService.addUserCourseBuyRelearn(buyOrder,"虚拟币购买:"+buyOrder.getOrderSn());
|
||||
} else {
|
||||
return R.error(500, "余额不足!");
|
||||
}
|
||||
}
|
||||
//微信支付预付款订单
|
||||
if(Constants.PAYMENT_METHOD_WECHAT_PAY.equals(buyOrder.getPaymentMethod())){
|
||||
BuyOrder buyOrderEntity = buyOrderService.getBaseMapper().selectOne(new LambdaQueryWrapper<BuyOrder>()
|
||||
.eq(BuyOrder::getOrderSn, timeId));
|
||||
WechatPaymentInfo paymentInfo = new WechatPaymentInfo();
|
||||
paymentInfo.setOrderSn(buyOrderEntity.getOrderSn());
|
||||
paymentInfo.setBuyOrderId(buyOrder.getOrderId());
|
||||
paymentInfo.setTotalAmount(buyOrderEntity.getRealMoney());
|
||||
if (buyOrder.getCome()==2){
|
||||
paymentInfo.setAppName("wumen");
|
||||
} else if (buyOrder.getCome()==1) {
|
||||
paymentInfo.setAppName("zmzm");
|
||||
} else if (buyOrder.getCome()==3) {
|
||||
paymentInfo.setAppName("xlkj");
|
||||
} else if (buyOrder.getCome()==4) {
|
||||
paymentInfo.setAppName("thyy");
|
||||
}else {
|
||||
paymentInfo.setAppName(buyOrder.getAppName());
|
||||
}
|
||||
wxpayService.prepay(paymentInfo);
|
||||
}
|
||||
rabbitTemplate.convertAndSend(
|
||||
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
|
||||
DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY,
|
||||
buyOrder.getOrderId(),
|
||||
messagePostProcessor()
|
||||
);
|
||||
return R.ok().put("orderSn", timeId).put("money", totalPrice);
|
||||
}
|
||||
|
||||
private boolean usePeanutCoin(MyUserEntity user, BigDecimal totalPrice) {
|
||||
if (user.getPeanutCoin().compareTo(totalPrice) >= 0) {
|
||||
if(totalPrice.compareTo(BigDecimal.ZERO)==0){//纯积分支付,虚拟币不用支付
|
||||
return true;
|
||||
}
|
||||
user.setPeanutCoin(user.getPeanutCoin().subtract(totalPrice));
|
||||
userService.updateById(user);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private MessagePostProcessor messagePostProcessor() {
|
||||
return message -> {
|
||||
//设置有效期30分钟
|
||||
message.getMessageProperties().setExpiration(String.valueOf(30 * 60 * 1000));
|
||||
return message;
|
||||
};
|
||||
}
|
||||
private void userCoinJf(BuyOrder order){
|
||||
MyUserEntity userEntity = userService.getById(order.getUserId());
|
||||
userEntity.setJf(userEntity.getJf().subtract(order.getJfDeduction()));
|
||||
userService.updateById(userEntity);
|
||||
JfTransactionDetails jfTransactionDetails = new JfTransactionDetails();
|
||||
jfTransactionDetails.setUserId(userEntity.getId());
|
||||
jfTransactionDetails.setChangeAmount(order.getJfDeduction().negate());
|
||||
jfTransactionDetails.setActType(1);
|
||||
jfTransactionDetails.setUserBalance(userEntity.getJf());
|
||||
jfTransactionDetails.setRelationId(order.getOrderId());
|
||||
jfTransactionDetails.setRemark("消费积分抵扣:"+order.getJfDeduction().toString()+",订单号:"+order.getOrderSn());
|
||||
jfTransactionDetailsService.save(jfTransactionDetails);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.HttpsUtil;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.ExpressCompany;
|
||||
import com.peanut.modules.common.entity.ExpressOrder;
|
||||
import com.peanut.modules.common.service.ExpressCompanyService;
|
||||
import com.peanut.modules.common.service.ExpressOrderService;
|
||||
import com.peanut.modules.common.to.ExpressPrintDto;
|
||||
import com.peanut.modules.common.vo.ExpressCompanyCommonVo;
|
||||
import com.peanut.modules.common.vo.PrintTemplateVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 快递
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonExpress")
|
||||
@RequestMapping("common/express")
|
||||
public class ExpressController {
|
||||
|
||||
@Autowired
|
||||
private ExpressCompanyService expressCompanyService;
|
||||
@Autowired
|
||||
private ExpressOrderService expressOrderService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取快递公司列表
|
||||
*
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping(path = "/getExpressCompanyList", method = RequestMethod.GET)
|
||||
public R getExpressCompanyList() {
|
||||
List<ExpressCompanyCommonVo> expressCompanyList = expressCompanyService.getExpressCompanyList();
|
||||
return R.ok().put("result",expressCompanyList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取面单列表
|
||||
* @param expressPrintDto
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getExpressPrints")
|
||||
public R getExpressPrints(@RequestBody ExpressPrintDto expressPrintDto) throws IOException {
|
||||
LambdaQueryWrapper<ExpressOrder> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(StringUtils.isNotBlank(expressPrintDto.getExpressOrderSn()),ExpressOrder::getExpressOrderSn,expressPrintDto.getExpressOrderSn());
|
||||
if(expressPrintDto.getDate()!=null&&expressPrintDto.getDate()!=""){
|
||||
String startDate = expressPrintDto.getDate()+" 00:00:00";
|
||||
String endDate = expressPrintDto.getDate()+" 23:59:59";
|
||||
wrapper.between(ExpressOrder::getCreateTime,startDate,endDate);
|
||||
}
|
||||
wrapper.eq(expressPrintDto.getType()!=0,ExpressOrder::getTemplatePrinted,expressPrintDto.getType()==1?1:0);
|
||||
wrapper.orderByDesc(ExpressOrder::getCreateTime);
|
||||
Page<ExpressOrder> expressOrderPage = expressOrderService.getBaseMapper().selectPage(new Page<>(expressPrintDto.getPage(), expressPrintDto.getLimit()), wrapper);
|
||||
for (ExpressOrder e :expressOrderPage.getRecords()){
|
||||
if(e.getPrintTemplate()!=null){
|
||||
String c_string = HttpsUtil.getHttps(e.getPrintTemplate());
|
||||
e.setPrintString(c_string);
|
||||
}
|
||||
}
|
||||
return R.ok().put("page",expressOrderPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取快递面单列表(废弃)
|
||||
*
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping(path = "/getPrintTemplateList", method = RequestMethod.GET)
|
||||
public R getPrintTemplate(@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
@RequestParam(value = "currentPage", defaultValue = "1") Integer currentPage) {
|
||||
Page<ExpressOrder> expressOrderPage = new Page<>(currentPage, pageSize);
|
||||
QueryWrapper<ExpressOrder> expressOrderQueryWrapper = new QueryWrapper<>();
|
||||
|
||||
Long totalDataSize = expressOrderService.count(expressOrderQueryWrapper);
|
||||
int totalPage = totalDataSize.intValue() / pageSize + 1;
|
||||
Page<ExpressOrder> page = expressOrderService.page(expressOrderPage, expressOrderQueryWrapper);
|
||||
List<ExpressOrder> expressOrderList = page.getRecords();
|
||||
List<PrintTemplateVo> data = new ArrayList<>();
|
||||
for (ExpressOrder expressOrder : expressOrderList) {
|
||||
PrintTemplateVo vo = new PrintTemplateVo();
|
||||
QueryWrapper<ExpressCompany> expressCompanyQueryWrapper = new QueryWrapper<>();
|
||||
expressCompanyQueryWrapper.eq("code", expressOrder.getExpressCompanyCode());
|
||||
ExpressCompany expressCompany = expressCompanyService.getOne(expressCompanyQueryWrapper);
|
||||
vo.setExpressCompanyCode(expressCompany.getName());
|
||||
vo.setPrintTemplate(expressOrder.getPrintTemplate());
|
||||
vo.setExpressOrderSn(expressOrder.getExpressOrderSn());
|
||||
vo.setTemplatedPrinted(vo.getTemplatedPrinted());
|
||||
data.add(vo);
|
||||
}
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("data", data);
|
||||
result.put("currentPage", currentPage);
|
||||
result.put("pageSize", pageSize);
|
||||
result.put("totalDataSize", totalDataSize);
|
||||
result.put("totalPage", totalPage);
|
||||
return R.ok().put("result", result);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/printTemplate", method = RequestMethod.POST)
|
||||
public R printTemplate(@RequestBody List<Integer> expressOrderIdList) {
|
||||
UpdateWrapper<ExpressOrder> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.set("template_printed", 1);
|
||||
updateWrapper.in("id", expressOrderIdList);
|
||||
expressOrderService.update(updateWrapper);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.book.service.ShopProductService;
|
||||
import com.peanut.modules.common.dao.ShopProductCourseDao;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.UserVipService;
|
||||
import com.peanut.modules.master.service.CourseCatalogueService;
|
||||
import com.peanut.modules.medical.service.CourseService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
//首页搜索
|
||||
@Slf4j
|
||||
@RestController("commonHomeSearch")
|
||||
@RequestMapping("common/homeSearch")
|
||||
public class HomeSearchController {
|
||||
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
@Autowired
|
||||
private CourseService courseService;
|
||||
@Autowired
|
||||
private CourseCatalogueService courseCatalogueService;
|
||||
@Autowired
|
||||
private ShopProductCourseDao shopProductCourseDao;
|
||||
@Autowired
|
||||
private UserVipService userVipService;
|
||||
|
||||
//首页搜索
|
||||
@RequestMapping("/searchData")
|
||||
public R searchData(@RequestBody Map<String, Object> params) {
|
||||
List<ShopProduct> shopProductList = shopProductService.list(new LambdaQueryWrapper<ShopProduct>()
|
||||
.ne(ShopProduct::getGoodsType,"05")
|
||||
.like(ShopProduct::getProductName, params.get("keyWord").toString()));
|
||||
for (ShopProduct shopProduct : shopProductList) {
|
||||
shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct));
|
||||
if (userVipService.isVip()&&shopProduct.getIsVipPrice()==1){
|
||||
shopProduct.setVipPrice(shopProductService.getVipPrice(shopProduct));
|
||||
}
|
||||
}
|
||||
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.leftJoin(CourseCatalogueEntity.class,CourseCatalogueEntity::getCourseId,CourseEntity::getId);
|
||||
wrapper.select("DISTINCT t.id,t.title,t.image,t.square_image squareImage,t.content");
|
||||
String appName = "course_to_medicine";
|
||||
if ("zmzm".equals(params.get("appName").toString())) {
|
||||
appName = "course_to_sociology";
|
||||
}else if ("xlkj".equals(params.get("appName").toString())) {
|
||||
appName = "course_to_psyche";
|
||||
}
|
||||
wrapper.select("(select level from "+appName+" where course_id = t.id and del_flag = 0 limit 1) level");
|
||||
wrapper.select("(select selective from "+appName+" where course_id = t.id and del_flag = 0 limit 1) selective");
|
||||
//第一版没用上,用来判断用户是否拥有课程
|
||||
wrapper.select("(select count(1) from user_course_buy where user_id = "+ ShiroUtils.getUId() +" and course_id = t.id and del_flag = 0) valid");
|
||||
wrapper.select("(select count(1) from user_course_buy where user_id = "+ ShiroUtils.getUId() +" and course_id = t.id and del_flag = -1) expired");
|
||||
wrapper.like(CourseEntity::getTitle,params.get("keyWord").toString());
|
||||
wrapper.apply("(t.id in (select course_id from "+appName+" where del_flag = 0))");
|
||||
List<Map<String,Object>> courseEntities = courseService.listMaps(wrapper);
|
||||
for (Map<String,Object> map : courseEntities) {
|
||||
List<CourseCatalogueEntity> courseCatalogueEntities = courseCatalogueService.list(new LambdaQueryWrapper<CourseCatalogueEntity>()
|
||||
.eq(CourseCatalogueEntity::getCourseId, map.get("id"))
|
||||
.orderByAsc(CourseCatalogueEntity::getSort));
|
||||
for (CourseCatalogueEntity co : courseCatalogueEntities){
|
||||
MPJLambdaWrapper<ShopProductCourseEntity> shopProductCourseEntityMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
||||
shopProductCourseEntityMPJLambdaWrapper.selectAll(ShopProduct.class);
|
||||
shopProductCourseEntityMPJLambdaWrapper.leftJoin(ShopProduct.class,ShopProduct::getProductId,ShopProductCourseEntity::getProductId);
|
||||
shopProductCourseEntityMPJLambdaWrapper.eq(ShopProductCourseEntity::getCatalogueId,co.getId());
|
||||
List<ShopProduct> shopProducts = shopProductCourseDao.selectJoinList(ShopProduct.class, shopProductCourseEntityMPJLambdaWrapper);
|
||||
co.setProductList(shopProducts);
|
||||
}
|
||||
map.put("courseCatalogueEntityList",courseCatalogueEntities);
|
||||
}
|
||||
return R.ok().put("shopProductList", shopProductList).put("courseEntities", courseEntities);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.JfTransactionDetails;
|
||||
import com.peanut.modules.common.entity.MyUserEntity;
|
||||
import com.peanut.modules.common.entity.TransactionDetailsEntity;
|
||||
import com.peanut.modules.common.service.JfTransactionDetailsService;
|
||||
import com.peanut.modules.common.service.MyUserService;
|
||||
import com.peanut.modules.common.service.TransactionDetailsService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 积分记录
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonJfTransactionDetails")
|
||||
@RequestMapping("common/jfTransactionDetails")
|
||||
public class JfTransactionDetailsController {
|
||||
|
||||
@Autowired
|
||||
private JfTransactionDetailsService jfService;
|
||||
@Autowired
|
||||
private TransactionDetailsService transactionDetailsService;
|
||||
@Autowired
|
||||
private MyUserService userService;
|
||||
|
||||
/**
|
||||
* 获取记录列表
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getJfTransactionDetailsList")
|
||||
public R getTransactionDetailsList(@RequestBody Map params){
|
||||
LambdaQueryWrapper<JfTransactionDetails> wrapper = new LambdaQueryWrapper<>();
|
||||
if (params.containsKey("userId")&& StringUtils.isNotEmpty(params.get("userId").toString())){
|
||||
wrapper.eq(JfTransactionDetails::getUserId,params.get("userId"));
|
||||
}
|
||||
wrapper.orderByDesc(JfTransactionDetails::getCreateTime);
|
||||
List<JfTransactionDetails> list = jfService.list(wrapper);
|
||||
return R.ok().put("transactionDetailsList",list);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/activityDonateJF")
|
||||
@Transactional
|
||||
public R activityDonateJF(){
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String startTime = "2025-11-08 00:00:00";
|
||||
String endTime = "2025-11-13 09:22:00";
|
||||
//查询时间段内所有充值的人
|
||||
List<TransactionDetailsEntity> list = transactionDetailsService.list(new LambdaQueryWrapper<TransactionDetailsEntity>()
|
||||
.between(TransactionDetailsEntity::getCreateTime,startTime,endTime)
|
||||
.gt(TransactionDetailsEntity::getChangeAmount,0)
|
||||
.groupBy(TransactionDetailsEntity::getUserId)
|
||||
.orderByDesc(TransactionDetailsEntity::getCreateTime));
|
||||
for (TransactionDetailsEntity transactionDetail : list) {
|
||||
MyUserEntity user = userService.getById(transactionDetail.getUserId());
|
||||
//时间段内充值总值
|
||||
Map<String,Object> td = transactionDetailsService.getMap(new MPJLambdaWrapper<TransactionDetailsEntity>()
|
||||
.eq(TransactionDetailsEntity::getUserId,transactionDetail.getUserId())
|
||||
.between(TransactionDetailsEntity::getCreateTime,startTime,endTime)
|
||||
.gt(TransactionDetailsEntity::getChangeAmount,0)
|
||||
.selectSum(TransactionDetailsEntity::getChangeAmount));
|
||||
if(new BigDecimal(td.get("changeAmount").toString()).compareTo(new BigDecimal(500))>=0){
|
||||
//时间段内获得的积分
|
||||
Map<String,Object> jftd = jfService.getMap(new MPJLambdaWrapper<JfTransactionDetails>()
|
||||
.eq(JfTransactionDetails::getUserId,transactionDetail.getUserId())
|
||||
.like(JfTransactionDetails::getRemark,"双11")
|
||||
.between(JfTransactionDetails::getCreateTime,startTime,endTime)
|
||||
.gt(TransactionDetailsEntity::getChangeAmount,0)
|
||||
.selectSum(TransactionDetailsEntity::getChangeAmount));
|
||||
BigDecimal jf = BigDecimal.ZERO;
|
||||
BigDecimal changeJf = BigDecimal.ZERO;
|
||||
BigDecimal shouldJf = BigDecimal.ZERO;
|
||||
if (jftd!=null){
|
||||
jf = new BigDecimal(jftd.get("changeAmount").toString());
|
||||
}
|
||||
changeJf = chgf(changeJf,shouldJf,new BigDecimal(td.get("changeAmount").toString()),jf);
|
||||
if (changeJf.compareTo(BigDecimal.ZERO)>0){
|
||||
sb.append((StringUtils.isEmpty(user.getName())?"无名氏":user.getName())+"-"+user.getTel()+"充值"+td.get("changeAmount").toString()+
|
||||
"获得积分"+jf+"补积分"+changeJf+"\n");
|
||||
user.setJf(user.getJf().add(changeJf));
|
||||
userService.updateById(user);
|
||||
addJf(user,changeJf);
|
||||
}else if (changeJf.compareTo(BigDecimal.ZERO)==0){
|
||||
sb.append((StringUtils.isEmpty(user.getName())?"无名氏":user.getName())+"-"+user.getTel()+"充值"+td.get("changeAmount").toString()+
|
||||
"获得积分"+jf+"补积分"+changeJf+"\n");
|
||||
}else if (changeJf.compareTo(BigDecimal.ZERO)<0){
|
||||
sb.append((StringUtils.isEmpty(user.getName())?"无名氏":user.getName())+"-"+user.getTel()+"特殊情况\n");
|
||||
}
|
||||
}else {
|
||||
sb.append((StringUtils.isEmpty(user.getName())?"无名氏":user.getName())+"-"+user.getTel()+"充值"+td.get("changeAmount").toString()+"未达标\n");
|
||||
}
|
||||
}
|
||||
System.out.println(sb.toString());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
public BigDecimal chgf(BigDecimal changeJf,BigDecimal shouldJf,BigDecimal changeAmount,BigDecimal jf){
|
||||
if (new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(5000))>=0||
|
||||
new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(3000))>=0||
|
||||
new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(2000))>=0||
|
||||
new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(1000))>=0||
|
||||
new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(500))>=0){
|
||||
if (new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(5000))>=0){
|
||||
shouldJf = shouldJf.add(new BigDecimal(2500));
|
||||
changeAmount = changeAmount.subtract(new BigDecimal(5000));
|
||||
}else if (new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(3000))>=0){
|
||||
shouldJf = shouldJf.add(new BigDecimal(1300));
|
||||
changeAmount = changeAmount.subtract(new BigDecimal(3000));
|
||||
}else if (new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(2000))>=0){
|
||||
shouldJf = shouldJf.add(new BigDecimal(800));
|
||||
changeAmount = changeAmount.subtract(new BigDecimal(2000));
|
||||
}else if (new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(1000))>=0){
|
||||
shouldJf = shouldJf.add(new BigDecimal(300));
|
||||
changeAmount = changeAmount.subtract(new BigDecimal(1000));
|
||||
}else if (new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(500))>=0){
|
||||
shouldJf = shouldJf.add(new BigDecimal(120));
|
||||
changeAmount = changeAmount.subtract(new BigDecimal(500));
|
||||
}
|
||||
return chgf(changeJf,shouldJf,changeAmount,jf);
|
||||
}
|
||||
changeJf = shouldJf.subtract(jf);
|
||||
return changeJf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void addJf(MyUserEntity user,BigDecimal changeAmount){
|
||||
JfTransactionDetails jfTransactionDetails = new JfTransactionDetails();
|
||||
jfTransactionDetails.setUserId(user.getId());
|
||||
jfTransactionDetails.setActType(0);
|
||||
jfTransactionDetails.setChangeAmount(changeAmount);
|
||||
jfTransactionDetails.setUserBalance(user.getJf());
|
||||
jfTransactionDetails.setRemark("2025年双11活动赠与补送");
|
||||
jfService.save(jfTransactionDetails);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import cn.jiguang.sdk.api.PushApi;
|
||||
import cn.jiguang.sdk.bean.push.PushSendParam;
|
||||
import cn.jiguang.sdk.bean.push.PushSendResult;
|
||||
import cn.jiguang.sdk.bean.push.audience.Audience;
|
||||
import cn.jiguang.sdk.bean.push.message.notification.NotificationMessage;
|
||||
import cn.jiguang.sdk.constants.ApiConstants;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.Arrays;
|
||||
|
||||
@Slf4j
|
||||
@RestController("commonJiGuangPush")
|
||||
@RequestMapping("common/jiGuangPush")
|
||||
public class JiGuangPushController {
|
||||
|
||||
@Autowired
|
||||
private PushApi pushApi;
|
||||
|
||||
//推送测试
|
||||
@RequestMapping("/sendTest")
|
||||
public R sendTest(){
|
||||
PushSendParam param = new PushSendParam();
|
||||
// 通知内容
|
||||
NotificationMessage.Android android = new NotificationMessage.Android();
|
||||
android.setAlert("this is android alert");
|
||||
android.setTitle("this is android title");
|
||||
NotificationMessage notificationMessage = new NotificationMessage();
|
||||
notificationMessage.setAlert("this is alert");
|
||||
notificationMessage.setAndroid(android);
|
||||
param.setNotification(notificationMessage);
|
||||
// 目标人群
|
||||
Audience audience = new Audience();
|
||||
audience.setAliasList(Arrays.asList(ShiroUtils.getUId()+""));
|
||||
param.setAudience(audience);
|
||||
// param.setAudience(ApiConstants.Audience.ALL);
|
||||
// 指定平台
|
||||
// param.setPlatform(Arrays.asList(Platform.android));
|
||||
param.setPlatform(ApiConstants.Platform.ALL);
|
||||
// 发送
|
||||
PushSendResult result = pushApi.send(param);
|
||||
return R.ok().put("result",result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.MainAdEntity;
|
||||
import com.peanut.modules.common.service.MainAdService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController("commonMainAdController")
|
||||
@RequestMapping("common/mainAd")
|
||||
public class MainAdController {
|
||||
|
||||
@Autowired
|
||||
private MainAdService mainAdService;
|
||||
|
||||
@RequestMapping("/getMainAd")
|
||||
public R getMainAd(@RequestBody Map<String,Integer> params){
|
||||
int type = params.get("type");
|
||||
List<MainAdEntity> adDetail = mainAdService.getAd(type);
|
||||
return R.ok().put("list",adDetail);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,352 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.*;
|
||||
import com.vladsch.flexmark.html.HtmlRenderer;
|
||||
import com.vladsch.flexmark.parser.Parser;
|
||||
import com.vladsch.flexmark.util.data.MutableDataSet;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.ai.tool.ToolCallbackProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController("commonMedicalRecords")
|
||||
@RequestMapping("common/medicalRecords")
|
||||
public class MedicalRecordsController {
|
||||
|
||||
private final ChatClient chatClient;
|
||||
@Autowired
|
||||
private MedicalRecordsService medicalRecordsService;
|
||||
@Autowired
|
||||
private DeptLabelService deptLabelService;
|
||||
@Autowired
|
||||
private MedicalRecordsToDeptLabelService medicalRecordsToDeptLabelService;
|
||||
@Autowired
|
||||
private MedicalRecordsCheckUserService medicalRecordsCheckUserService;
|
||||
@Autowired
|
||||
private TaihuTalentService taihuTalentService;
|
||||
@Autowired
|
||||
private TaihuTalentArticleService taihuTalentArticleService;
|
||||
|
||||
//当前用户是否拥有医案模块
|
||||
@RequestMapping("/getMedicalRecordsRoleByUser")
|
||||
public R getMedicalRecordsRoleByUser(){
|
||||
return R.ok().put("roleFlag", taihuTalentService.count(new LambdaQueryWrapper<TaihuTalent>()
|
||||
.eq(TaihuTalent::getUserId,ShiroUtils.getUId())));
|
||||
}
|
||||
|
||||
//获取医案标签列表
|
||||
@RequestMapping("/getMedicalRecordsLabelList")
|
||||
public R getMedicalRecordsLabelList(){
|
||||
return R.ok().put("Medicals", medicalRecordsLabels(0));
|
||||
}
|
||||
private List<DeptLabel> medicalRecordsLabels(int id){
|
||||
List<DeptLabel> deptLabelList = deptLabelService.list(new LambdaQueryWrapper<DeptLabel>()
|
||||
.eq(DeptLabel::getPid, id));
|
||||
for (DeptLabel m : deptLabelList){
|
||||
if(m.getIsLast()!=1){
|
||||
List<DeptLabel> so = this.medicalRecordsLabels(m.getId());
|
||||
m.setChildren(so);
|
||||
}
|
||||
}
|
||||
return deptLabelList;
|
||||
}
|
||||
|
||||
public MedicalRecordsController(ChatClient.Builder chatClientBuilder, ToolCallbackProvider tools) {
|
||||
this.chatClient = chatClientBuilder.defaultToolCallbacks(tools).build();
|
||||
}
|
||||
|
||||
//拆分医案段落
|
||||
@RequestMapping(value = "/medicalRecordsSplit")
|
||||
public R medicalRecordsSplit(@RequestBody Map<String,Object> parmas) {
|
||||
MedicalRecords mr = new MedicalRecords();
|
||||
if (parmas.containsKey("img")&& StringUtils.isNotEmpty(parmas.get("img").toString())) {
|
||||
mr.setImg(parmas.get("img").toString());
|
||||
}
|
||||
if (parmas.containsKey("userId")&& StringUtils.isNotEmpty(parmas.get("userId").toString())) {
|
||||
mr.setUserId(Integer.parseInt(parmas.get("userId").toString()));
|
||||
}else {
|
||||
mr.setUserId(ShiroUtils.getUId());
|
||||
}
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
mr.setOriginalData(parmas.get("message").toString());
|
||||
medicalRecordsService.save(mr);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
Date date = new Date();
|
||||
MutableDataSet options = new MutableDataSet();
|
||||
Parser parser = Parser.builder(options).build();
|
||||
HtmlRenderer renderer = HtmlRenderer.builder(options).build();
|
||||
chatClient.prompt()
|
||||
.user("""
|
||||
整理一下下面的内容,将内容进行结构化,我们要进行记录与归档;
|
||||
不要删减任何内容;
|
||||
个人信息等如果存在要进行脱敏处理,用*代替;
|
||||
如果有标题放到一般信息中,开头必须是1.一般信息,1.一般信息这种要h1样式;
|
||||
如果有刻诊内容,应该放到体格检查中;
|
||||
每个模块之间用end分割;
|
||||
结果必须是markdown格式;
|
||||
按照以下模板整理:
|
||||
1.一般信息
|
||||
...
|
||||
end
|
||||
2.主诉
|
||||
...
|
||||
end
|
||||
3.现病史
|
||||
...
|
||||
end
|
||||
4.既往史
|
||||
...
|
||||
end
|
||||
5.个人史与家族史
|
||||
...
|
||||
end
|
||||
6.体格检查
|
||||
...
|
||||
end
|
||||
7.诊断
|
||||
...
|
||||
end
|
||||
8.治疗和后续诊断
|
||||
...
|
||||
end
|
||||
9.其他
|
||||
...
|
||||
"""+
|
||||
"内容如下:"+parmas.get("message").toString())
|
||||
.stream()
|
||||
.content()
|
||||
.doOnNext(sb::append)
|
||||
.doFinally(data -> {
|
||||
try {
|
||||
System.out.println(sb);
|
||||
String res = sb.toString().replace("```markdown\n","").replace("```","");
|
||||
String[] datas = res.split("end");
|
||||
mr.setInformation(renderer.render(parser.parse(datas[0])));
|
||||
mr.setChiefComplaint(renderer.render(parser.parse(datas[1])));
|
||||
mr.setHistoryOfPresentIllness(renderer.render(parser.parse(datas[2])));
|
||||
mr.setPastHistory(renderer.render(parser.parse(datas[3])));
|
||||
mr.setPersonalAndFamilyHistory(renderer.render(parser.parse(datas[4])));
|
||||
mr.setPhysicaExamination(renderer.render(parser.parse(datas[5])));
|
||||
mr.setDiagnosis(renderer.render(parser.parse(datas[6])));
|
||||
mr.setTreatmentPlan(renderer.render(parser.parse(datas[7])));
|
||||
mr.setOther(renderer.render(parser.parse(datas[8])));
|
||||
mr.setData(uuid+"->");
|
||||
medicalRecordsService.saveOrUpdate(mr);
|
||||
System.out.println(new Date().getTime()-date.getTime());
|
||||
} catch (Exception e) {
|
||||
medicalRecordsService.removeById(mr.getId());
|
||||
}
|
||||
})
|
||||
.doOnError(error -> {
|
||||
medicalRecordsService.removeById(mr.getId());
|
||||
})
|
||||
.subscribe();
|
||||
return R.ok().put("data",mr.getId());
|
||||
}
|
||||
|
||||
//查询正在拆分的医案
|
||||
@RequestMapping(value = "/medicalRecordsQuerySplit")
|
||||
public R medicalRecordsQuerySplit(@RequestBody Map<String,Object> parmas) {
|
||||
MedicalRecords mr = medicalRecordsService.getOne(new MPJLambdaWrapper<MedicalRecords>()
|
||||
.disableLogicDel()
|
||||
.eq(MedicalRecords::getId,parmas.get("id").toString()));
|
||||
MedicalRecordsToDeptLabel toLabel = medicalRecordsToDeptLabelService.getOne(new LambdaQueryWrapper<MedicalRecordsToDeptLabel>()
|
||||
.eq(MedicalRecordsToDeptLabel::getRecordId,mr.getId()));
|
||||
if (toLabel!=null){
|
||||
mr.setLabelId(toLabel.getLabelId());
|
||||
DeptLabel label = deptLabelService.getById(toLabel.getLabelId());
|
||||
if (label!=null){
|
||||
mr.setLabelTitle(label.getTitle());
|
||||
}
|
||||
}
|
||||
return R.ok().put("medicalRecords",mr);
|
||||
}
|
||||
|
||||
//暂存或者保存医案
|
||||
@RequestMapping(value = "/saveMedicalRecords")
|
||||
@Transactional
|
||||
public R saveMedicalRecords(@RequestBody MedicalRecords medicalRecords) {
|
||||
if (medicalRecords.getState()==1){
|
||||
if ("儿科".equals(medicalRecords.getLabelTitle())){
|
||||
if ((!medicalRecords.getPastHistory().contains("接种")&&
|
||||
!medicalRecords.getPastHistory().contains("疫苗"))&&
|
||||
(!medicalRecords.getPersonalAndFamilyHistory().contains("接种")&&
|
||||
!medicalRecords.getPersonalAndFamilyHistory().contains("疫苗"))){
|
||||
return R.error("请补充患者疫苗接种信息");
|
||||
}
|
||||
}
|
||||
if ("妇科".equals(medicalRecords.getLabelTitle())){
|
||||
if ((!medicalRecords.getPastHistory().contains("月经")&&
|
||||
!medicalRecords.getPastHistory().contains("例假")&&
|
||||
!medicalRecords.getPastHistory().contains("婚育"))&&
|
||||
(!medicalRecords.getPersonalAndFamilyHistory().contains("月经")&&
|
||||
!medicalRecords.getPersonalAndFamilyHistory().contains("例假")&&
|
||||
!medicalRecords.getPersonalAndFamilyHistory().contains("婚育"))){
|
||||
return R.error("请补充患者月经婚育信息");
|
||||
}
|
||||
}
|
||||
}
|
||||
medicalRecords.setData(medicalRecords.getInformation()+medicalRecords.getChiefComplaint()+medicalRecords.getHistoryOfPresentIllness()
|
||||
+medicalRecords.getPastHistory()+medicalRecords.getPastHistory()+medicalRecords.getPersonalAndFamilyHistory()
|
||||
+medicalRecords.getPhysicaExamination()+medicalRecords.getDiagnosis()+medicalRecords.getTreatmentPlan());
|
||||
medicalRecordsService.saveOrUpdate(medicalRecords);
|
||||
//绑定标签
|
||||
if (medicalRecords.getLabelId()!=null&&medicalRecords.getLabelId()!=0){
|
||||
MedicalRecordsToDeptLabel toLabel = medicalRecordsToDeptLabelService.getOne(new LambdaQueryWrapper<MedicalRecordsToDeptLabel>()
|
||||
.eq(MedicalRecordsToDeptLabel::getLabelId, medicalRecords.getLabelId())
|
||||
.eq(MedicalRecordsToDeptLabel::getRecordId,medicalRecords.getId()));
|
||||
if (toLabel==null){
|
||||
toLabel = new MedicalRecordsToDeptLabel();
|
||||
}
|
||||
toLabel.setRecordId(medicalRecords.getId());
|
||||
toLabel.setLabelId(medicalRecords.getLabelId());
|
||||
medicalRecordsToDeptLabelService.saveOrUpdate(toLabel);
|
||||
}
|
||||
return R.ok().put("medicalRecords",medicalRecords);
|
||||
}
|
||||
|
||||
//删除医案
|
||||
@RequestMapping(value = "/delMmedicalRecords")
|
||||
public R delMmedicalRecords(@RequestBody Map<String,Object> parmas) {
|
||||
medicalRecordsService.removeById(parmas.get("id").toString());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//医案列表
|
||||
@RequestMapping(value = "/medicalRecordsList")
|
||||
public R medicalRecordsList(@RequestBody Map<String,Object> parmas) {
|
||||
LambdaQueryWrapper<MedicalRecords> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(MedicalRecords::getUserId,ShiroUtils.getUId());
|
||||
if (parmas.get("state").toString().contains(",")){
|
||||
wrapper.and(t->t.eq(MedicalRecords::getState,parmas.get("state").toString().split(",")[0])
|
||||
.or().eq(MedicalRecords::getState,parmas.get("state").toString().split(",")[1]));
|
||||
}else {
|
||||
wrapper.in(MedicalRecords::getState,parmas.get("state"));
|
||||
}
|
||||
List<MedicalRecords> medicalRecordsList = medicalRecordsService.list(wrapper);
|
||||
return R.ok().put("medicalRecordsList",medicalRecordsList);
|
||||
}
|
||||
|
||||
//通过审核医案是否公开
|
||||
@RequestMapping(value = "/setMedicalRecordsShow")
|
||||
public R setMedicalRecordsShow(@RequestBody Map<String,Object> parmas) {
|
||||
MedicalRecords medicalRecords = medicalRecordsService.getById(parmas.get("id").toString());
|
||||
medicalRecords.setShowFlag(1);
|
||||
medicalRecordsService.updateById(medicalRecords);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//通过审核医案同步发布文章
|
||||
@RequestMapping(value = "/addTaihuTalentArticle")
|
||||
@Transactional
|
||||
public R addTaihuTalentArticle(@RequestBody Map<String,Object> parmas) {
|
||||
MedicalRecords medicalRecords = medicalRecordsService.getById(parmas.get("id").toString());
|
||||
TaihuTalentArticle article = new TaihuTalentArticle();
|
||||
article.setUserId(medicalRecords.getUserId());
|
||||
article.setTitle(medicalRecords.getTitle());
|
||||
article.setContent(medicalRecords.getData());
|
||||
article.setImg(medicalRecords.getImg());
|
||||
article.setCome(1);
|
||||
taihuTalentArticleService.save(article);
|
||||
medicalRecords.setArticleFlag(1);
|
||||
medicalRecordsService.updateById(medicalRecords);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//能否审批
|
||||
@RequestMapping("/canCheck")
|
||||
public R canCheck(){
|
||||
boolean flag = false;
|
||||
long c = medicalRecordsCheckUserService.count(new LambdaQueryWrapper<MedicalRecordsCheckUser>()
|
||||
.eq(MedicalRecordsCheckUser::getUserId,ShiroUtils.getUId()));
|
||||
if (c>0){
|
||||
flag = true;
|
||||
}
|
||||
return R.ok().put("flag",flag);
|
||||
}
|
||||
//审批列表
|
||||
@RequestMapping("/getMedicalRecordsCheckList")
|
||||
public R getMedicalRecordsCheckList(@RequestBody Map<String,Object> parmas){
|
||||
MPJLambdaWrapper<MedicalRecords> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.rightJoin(MedicalRecordsToDeptLabel.class, MedicalRecordsToDeptLabel::getRecordId,MedicalRecords::getId);
|
||||
wrapper.rightJoin(MedicalRecordsCheckUser.class,MedicalRecordsCheckUser::getLabelId,MedicalRecordsToDeptLabel::getLabelId);
|
||||
wrapper.selectAll(MedicalRecords.class);
|
||||
wrapper.eq(MedicalRecordsCheckUser::getUserId,ShiroUtils.getUId());
|
||||
wrapper.eq(MedicalRecords::getState,3);
|
||||
if (parmas.containsKey("flag")&&parmas.get("flag")!=null){
|
||||
if ("0".equals(parmas.get("flag").toString())){
|
||||
wrapper.notLike(MedicalRecords::getStateInfo,"\""+ShiroUtils.getUId()+"\"");
|
||||
}else if ("1".equals(parmas.get("flag").toString())){
|
||||
wrapper.like(MedicalRecords::getStateInfo,"\""+ShiroUtils.getUId()+"\"");
|
||||
}
|
||||
}
|
||||
List<MedicalRecords> list = medicalRecordsService.list(wrapper);
|
||||
return R.ok().put("list",list);
|
||||
}
|
||||
//审批医案
|
||||
@RequestMapping("/medicalRecordsCheck")
|
||||
public R medicalRecordsCheck(@RequestBody Map<String,Object> parmas){
|
||||
String stateInfo = "";
|
||||
String state = parmas.get("state").toString();
|
||||
String id = parmas.get("id").toString();
|
||||
MedicalRecords medicalRecords = medicalRecordsService.getById(id);
|
||||
Map<String,Object> userIdAndState = new HashMap<>();
|
||||
if (StringUtils.isNotEmpty(medicalRecords.getStateInfo())){
|
||||
boolean flag = true;//判断是否评价过
|
||||
userIdAndState = JSON.parseObject(medicalRecords.getStateInfo());
|
||||
for (Map.Entry<String,Object> key : userIdAndState.entrySet()) {
|
||||
if (key.equals(ShiroUtils.getUId().toString())){
|
||||
flag = false;
|
||||
key.setValue(state);
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
userIdAndState.put(""+ShiroUtils.getUId(),state);
|
||||
}
|
||||
}else {
|
||||
userIdAndState.put(""+ShiroUtils.getUId(),state);
|
||||
}
|
||||
stateInfo = JSON.toJSONString(userIdAndState);
|
||||
medicalRecords.setStateInfo(stateInfo);
|
||||
LambdaUpdateWrapper<MedicalRecords> wrapper = new LambdaUpdateWrapper<>();
|
||||
wrapper.eq(MedicalRecords::getId,id);
|
||||
wrapper.set(MedicalRecords::getStateInfo,stateInfo);
|
||||
wrapper.set(MedicalRecords::getInfoCount,userIdAndState.size());
|
||||
int same = 0;
|
||||
for (Map.Entry<String,Object> key : userIdAndState.entrySet()) {
|
||||
if (userIdAndState.size()==2&&key.getValue().equals(state)){
|
||||
same++;
|
||||
}
|
||||
}
|
||||
if (same==2){
|
||||
if ("A".equals(state)){
|
||||
wrapper.set(MedicalRecords::getState,6);
|
||||
wrapper.set(MedicalRecords::getTrain,1);
|
||||
}else if ("B".equals(state)){
|
||||
wrapper.set(MedicalRecords::getState,5);
|
||||
}else {
|
||||
wrapper.set(MedicalRecords::getState,4);
|
||||
}
|
||||
}
|
||||
medicalRecordsService.update(wrapper);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,359 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.*;
|
||||
import com.peanut.modules.sys.entity.SysDictDataEntity;
|
||||
import com.peanut.modules.sys.service.SysDictDataService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController("commonMedicaldes")
|
||||
@RequestMapping("common/medicaldes")
|
||||
public class MedicaldesController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private MedicaldesLightService lightService;
|
||||
@Autowired
|
||||
private MedicaldesBookService medicaldesBookService;
|
||||
@Autowired
|
||||
private MedicaldesInheritService inheritService;
|
||||
@Autowired
|
||||
private MedicaldesInheritRelationService relationService;
|
||||
@Autowired
|
||||
private SysDictDataService sysDictDataService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
@Autowired
|
||||
private ProvinceService provinceService;
|
||||
@Autowired
|
||||
private CityService cityService;
|
||||
|
||||
|
||||
/**
|
||||
* 类型列表
|
||||
*/
|
||||
@RequestMapping(path = "/typeList")
|
||||
public R typeList(String label) {
|
||||
LambdaQueryWrapper<SysDictDataEntity> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(SysDictDataEntity::getDictLabel,label);
|
||||
wrapper.orderByAsc(SysDictDataEntity::getSort);
|
||||
return R.ok().put("result",sysDictDataService.list(wrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 书列表
|
||||
*/
|
||||
@RequestMapping(path = "/bookList")
|
||||
public R bookList() {
|
||||
LambdaQueryWrapper<BookEntity> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(BookEntity::getBookType,0);
|
||||
wrapper.orderByDesc(BookEntity::getCreateTime);
|
||||
return R.ok().put("result",bookService.list(wrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 专著出版关系列表
|
||||
*/
|
||||
@RequestMapping(path = "/bookRelationListByType")
|
||||
public R bookRelationListByType(@RequestBody Map map) {
|
||||
MPJLambdaWrapper<MedicaldesBook> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.selectAll(MedicaldesBook.class);
|
||||
wrapper.leftJoin(BookEntity.class,BookEntity::getId,MedicaldesBook::getBookId);
|
||||
wrapper.eq(BookEntity::getBookType,0);
|
||||
if (map.containsKey("dictType")&& StringUtils.isNotEmpty(map.get("dictType").toString())){
|
||||
wrapper.eq(MedicaldesBook::getTypeId,map.get("dictType"));
|
||||
}
|
||||
if (map.containsKey("bookName")&&StringUtils.isNotEmpty(map.get("bookName").toString())){
|
||||
wrapper.like(BookEntity::getName,map.get("bookName"));
|
||||
}
|
||||
wrapper.orderByAsc(MedicaldesBook::getSort);
|
||||
Page<MedicaldesBook> res = medicaldesBookService.page(new Page<MedicaldesBook>(
|
||||
Long.parseLong(map.get("current").toString()), Long.parseLong(map.get("limit").toString())), wrapper);
|
||||
List<MedicaldesBook> list = res.getRecords();
|
||||
if (list.size() > 0) {
|
||||
for (MedicaldesBook b : list) {
|
||||
b.setBook(bookService.getById(b.getBookId()));
|
||||
}
|
||||
res.setRecords(list);
|
||||
}
|
||||
return R.ok().put("result", res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 专著出版列表
|
||||
*/
|
||||
@RequestMapping(path = "/bookListByType")
|
||||
public R bookListByType(String type) {
|
||||
MPJLambdaWrapper<BookEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.selectAll(BookEntity.class);
|
||||
wrapper.leftJoin(MedicaldesBook.class,MedicaldesBook::getBookId,BookEntity::getId);
|
||||
wrapper.eq(MedicaldesBook::getTypeId,type);
|
||||
wrapper.eq(BookEntity::getBookType,0);
|
||||
wrapper.orderByAsc(MedicaldesBook::getSort);
|
||||
List<BookEntity> list = bookService.list(wrapper);
|
||||
return R.ok().put("result", list);
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/saveOrUpdateBookRelation")
|
||||
public R saveOrUpdateBookRelation(@RequestBody MedicaldesBook medicaldesBook) {
|
||||
MPJLambdaWrapper<MedicaldesBook> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.eq(MedicaldesBook::getBookId,medicaldesBook.getBookId());
|
||||
wrapper.eq(MedicaldesBook::getTypeId,medicaldesBook.getTypeId());
|
||||
if (medicaldesBookService.getOne(wrapper)!=null){
|
||||
medicaldesBookService.remove(wrapper);
|
||||
}
|
||||
medicaldesBookService.saveOrUpdate(medicaldesBook);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/delBookRelation")
|
||||
public R delBookRelation(String id) {
|
||||
medicaldesBookService.removeById(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 学术传承列表分页
|
||||
*/
|
||||
@RequestMapping(path = "/inheritListByPage")
|
||||
public R inheritListByPage(@RequestBody Map map) {
|
||||
MPJLambdaWrapper<MedicaldesInherit> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.leftJoin(MedicaldesInheritRelation.class,MedicaldesInheritRelation::getInheritId,MedicaldesInherit::getId);
|
||||
wrapper.leftJoin(City.class,City::getCityId,MedicaldesInherit::getCityId);
|
||||
wrapper.leftJoin(Province.class,Province::getProvId,City::getProvId);
|
||||
wrapper.selectAll(MedicaldesInherit.class);
|
||||
if (map.containsKey("dictType")&&StringUtils.isNotEmpty(map.get("dictType").toString())){
|
||||
wrapper.eq(MedicaldesInheritRelation::getTypeId,map.get("dictType"));
|
||||
}
|
||||
if (map.containsKey("name")&&StringUtils.isNotEmpty(map.get("name").toString())){
|
||||
wrapper.like(MedicaldesInherit::getName,map.get("name"));
|
||||
}
|
||||
wrapper.selectAs(MedicaldesInheritRelation::getTypeId,"type");
|
||||
wrapper.selectAs(MedicaldesInheritRelation::getSort,"sort");
|
||||
wrapper.orderByAsc(MedicaldesInheritRelation::getSort);
|
||||
Page<MedicaldesInherit> page = inheritService.page(new Page<>(
|
||||
Long.parseLong(map.get("current").toString()), Long.parseLong(map.get("limit").toString())),wrapper);
|
||||
return R.ok().put("result", page);
|
||||
}
|
||||
|
||||
//国际医师可能来自国外在省市里加入外国
|
||||
public List<SysDictDataEntity> getCounts() {
|
||||
LambdaQueryWrapper<SysDictDataEntity> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(SysDictDataEntity::getDictLabel,"inheritPro");
|
||||
List<SysDictDataEntity> dataList = sysDictDataService.list(wrapper);
|
||||
return dataList;
|
||||
}
|
||||
|
||||
public List getCityList(String cityName,int countId) {
|
||||
List<City> cityList = new ArrayList<>();
|
||||
City city = new City();
|
||||
city.setProvId((long)countId);
|
||||
city.setCityName(cityName);
|
||||
city.setCityId((long)countId);
|
||||
cityList.add(city);
|
||||
return cityList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 学术传承列表按类型、地区
|
||||
*/
|
||||
@RequestMapping(path = "/inheritListByTypeProvId")
|
||||
public R inheritListByTypeProvId(String type,String provId) {
|
||||
MPJLambdaWrapper<MedicaldesInherit> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.leftJoin(MedicaldesInheritRelation.class,MedicaldesInheritRelation::getInheritId,MedicaldesInherit::getId);
|
||||
wrapper.eq(MedicaldesInheritRelation::getTypeId,type);
|
||||
wrapper.leftJoin(City.class,City::getCityId,MedicaldesInherit::getCityId);
|
||||
wrapper.leftJoin(Province.class,Province::getProvId,City::getProvId);
|
||||
wrapper.selectAll(MedicaldesInherit.class);
|
||||
if ("0".equals(provId)){
|
||||
int[] val = new int[] {0};
|
||||
//未知地址
|
||||
if (getCounts()!=null&&getCounts().size() > 0){
|
||||
for (int i=1;i<=getCounts().size(); i++){
|
||||
val[i] = i;
|
||||
}
|
||||
}
|
||||
wrapper.in(MedicaldesInherit::getCityId,val);
|
||||
}else {
|
||||
wrapper.eq(Province::getProvId,provId);
|
||||
}
|
||||
wrapper.selectAs(MedicaldesInheritRelation::getSort,"sort");
|
||||
wrapper.orderByAsc(MedicaldesInheritRelation::getSort);
|
||||
List<MedicaldesInherit> list = inheritService.list(wrapper);
|
||||
return R.ok().put("result", list);
|
||||
}
|
||||
|
||||
//获取地址
|
||||
@RequestMapping(path = "/getMedicaldesProList")
|
||||
public R getMedicaldesProList() {
|
||||
String s = redisTemplate.opsForValue().get("Province");
|
||||
List<Province> provinceList = new ArrayList<>();
|
||||
if (getCounts() != null&&getCounts().size() > 0){
|
||||
for (int i=0;i<getCounts().size();i++){
|
||||
Province p = new Province();
|
||||
p.setProvName(getCounts().get(i).getDictValue());
|
||||
p.setProvId(Long.valueOf(getCounts().get(i).getDictType()));
|
||||
p.setCityList(getCityList(getCounts().get(i).getDictValue(),Integer.parseInt(getCounts().get(i).getDictType())));
|
||||
provinceList.add(p);
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(s)) {
|
||||
List<Object> redisData = JSONArray.parseArray(s);
|
||||
for (Object object : redisData) {
|
||||
Province ret = JSONObject.parseObject(object.toString(), Province.class);
|
||||
provinceList.add(ret);
|
||||
}
|
||||
return R.ok().put("provinceEntity", provinceList);
|
||||
}else {
|
||||
provinceList.addAll(provinceService.getCity());
|
||||
}
|
||||
return R.ok().put("provinceEntity", provinceList);
|
||||
}
|
||||
|
||||
//获取市列表
|
||||
@RequestMapping(path = "/getCityByPro")
|
||||
public R getCityByPro(@RequestParam("provId") Integer provId) {
|
||||
List<City> prov = new ArrayList<>();
|
||||
List<SysDictDataEntity> list = getCounts();
|
||||
boolean flag = false;
|
||||
if (list != null && list.size() > 0) {
|
||||
for (SysDictDataEntity data:list) {
|
||||
if (provId==Integer.parseInt(data.getDictType())){
|
||||
prov.addAll(getCityList(data.getDictValue(),Integer.parseInt(data.getDictType())));
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!flag) {
|
||||
prov = cityService.getBaseMapper().selectList(new QueryWrapper<City>()
|
||||
.eq("prov_id", provId));
|
||||
}
|
||||
return R.ok().put("prov", prov);
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/getInheritById")
|
||||
public R getInheritById(String id) {
|
||||
MPJLambdaWrapper<MedicaldesInherit> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.eq(MedicaldesInherit::getId,id);
|
||||
wrapper.leftJoin(MedicaldesInheritRelation.class,MedicaldesInheritRelation::getInheritId,MedicaldesInherit::getId);
|
||||
wrapper.leftJoin(City.class,City::getCityId,MedicaldesInherit::getCityId);
|
||||
wrapper.leftJoin(Province.class,Province::getProvId,City::getProvId);
|
||||
wrapper.leftJoin(" (select dict_type,dict_value from sys_dict_data where dict_label = 'inheritPro') dd on dd.dict_type = t.city_id");
|
||||
wrapper.select("t.*,ifnull(t2.city_name,ifnull(dd.dict_value,'其他')) as city_name,ifnull(t3.prov_name,ifnull(dd.dict_value,'其他')) as prov_name,t1.sort as sort");
|
||||
Map<String,Object> inherit = inheritService.getMap(wrapper);
|
||||
return R.ok().put("result",inherit);
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/saveOrUpdateInherit")
|
||||
public R addInherit(@RequestBody MedicaldesInherit inherit) {
|
||||
MedicaldesInheritRelation relation = null;
|
||||
if (inherit.getId()==null) {
|
||||
relation = new MedicaldesInheritRelation();
|
||||
}else {
|
||||
LambdaQueryWrapper<MedicaldesInheritRelation> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(MedicaldesInheritRelation::getInheritId,inherit.getId());
|
||||
relation = relationService.getOne(wrapper);
|
||||
}
|
||||
inheritService.saveOrUpdate(inherit);
|
||||
relation.setTypeId(inherit.getType());
|
||||
relation.setInheritId(inherit.getId());
|
||||
relation.setSort(inherit.getSort());
|
||||
relationService.saveOrUpdate(relation);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/delInherit")
|
||||
public R delInherit(String id) {
|
||||
inheritService.removeById(id);
|
||||
LambdaQueryWrapper<MedicaldesInheritRelation> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(MedicaldesInheritRelation::getInheritId,id);
|
||||
relationService.removeById(relationService.getOne(wrapper));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/getList")
|
||||
public List<Map<String,Object>> getList(String type) {
|
||||
MPJLambdaWrapper<MedicaldesInherit> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.select("count(1) count,ifnull(t3.prov_id,ifnull(dd.dict_type,'0')) AS prov_id,ifnull(t3.prov_name,ifnull(dd.dict_value,'其他')) AS prov_name ");
|
||||
wrapper.leftJoin(MedicaldesInheritRelation.class,MedicaldesInheritRelation::getInheritId,MedicaldesInherit::getId);
|
||||
wrapper.eq(MedicaldesInheritRelation::getTypeId,type);
|
||||
wrapper.leftJoin(City.class,City::getCityId,MedicaldesInherit::getCityId);
|
||||
wrapper.leftJoin(Province.class,Province::getProvId,City::getProvId);
|
||||
wrapper.leftJoin(" (select dict_type,dict_value from sys_dict_data where dict_label = 'inheritPro') dd on dd.dict_type = t.city_id");
|
||||
wrapper.groupBy("prov_name","dict_value");
|
||||
wrapper.orderByAsc("t3.region_code","dict_value");
|
||||
List<Map<String,Object>> list = inheritService.listMaps(wrapper);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 吴门之光列表
|
||||
*/
|
||||
@RequestMapping(path = "/lightListByType")
|
||||
public R lightListByType(String type) {
|
||||
LambdaQueryWrapper<MedicaldesLight> wrapper = new LambdaQueryWrapper();
|
||||
if (StringUtils.isNotEmpty(type)){
|
||||
wrapper.eq(MedicaldesLight::getType,type);
|
||||
}
|
||||
wrapper.orderByAsc(MedicaldesLight::getSort);
|
||||
List<MedicaldesLight> list = lightService.list(wrapper);
|
||||
return R.ok().put("result", list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 吴门之光列表
|
||||
*/
|
||||
@RequestMapping(path = "/lightListByPage")
|
||||
public R lightListByPage(@RequestBody Map map) {
|
||||
LambdaQueryWrapper<MedicaldesLight> wrapper = new LambdaQueryWrapper();
|
||||
if (map.containsKey("type")&&StringUtils.isNotEmpty(map.get("type").toString())){
|
||||
wrapper.eq(MedicaldesLight::getType,map.get("type"));
|
||||
}
|
||||
if (map.containsKey("name")&&StringUtils.isNotEmpty(map.get("name").toString())){
|
||||
wrapper.like(MedicaldesLight::getName,map.get("name"));
|
||||
}
|
||||
wrapper.orderByAsc(MedicaldesLight::getSort);
|
||||
Page<MedicaldesLight> page = lightService.page(new Page<>(
|
||||
Long.parseLong(map.get("current").toString()), Long.parseLong(map.get("limit").toString())),wrapper);
|
||||
return R.ok().put("result", page);
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/getLightById")
|
||||
public R getLightById(String id) {
|
||||
return R.ok().put("result",lightService.getById(id));
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/saveOrUpdateLight")
|
||||
public R addLight(@RequestBody MedicaldesLight light) {
|
||||
lightService.saveOrUpdate(light);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/delLight")
|
||||
public R delLight(String id) {
|
||||
lightService.removeById(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.Message;
|
||||
import com.peanut.modules.common.service.MessageService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 公共消息
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonMessage")
|
||||
@RequestMapping("common/message")
|
||||
public class MessageController {
|
||||
|
||||
@Autowired
|
||||
private MessageService messageService;
|
||||
|
||||
@RequestMapping("/listByPage")
|
||||
public R listByPage(@RequestBody Message message) {
|
||||
LambdaQueryWrapper<Message> wrapper = new LambdaQueryWrapper();
|
||||
if (message.getIsBook()!=null&&message.getIsBook()==1){
|
||||
wrapper.eq(Message::getIsBook,1);
|
||||
}
|
||||
if (message.getIsMedical()!=null&&message.getIsMedical()==1){
|
||||
wrapper.eq(Message::getIsMedical,1);
|
||||
}
|
||||
if (message.getIsSociology()!=null&&message.getIsSociology()==1){
|
||||
wrapper.eq(Message::getIsSociology,1);
|
||||
}
|
||||
if (message.getIsPsyche()!=null&&message.getIsPsyche()==1){
|
||||
wrapper.eq(Message::getIsPsyche,1);
|
||||
}
|
||||
wrapper.orderByDesc(Message::getCreateTime);
|
||||
List<Message> messages = messageService.getBaseMapper().selectList(wrapper);
|
||||
return R.ok().put("messages", messages);
|
||||
}
|
||||
|
||||
@RequestMapping("/getMessageById")
|
||||
public R getMessageById(String id) {
|
||||
return R.ok().put("result", messageService.getById(id));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.config.Constants;
|
||||
import com.peanut.config.DelayQueueConfig;
|
||||
import com.peanut.modules.book.service.BuyOrderService;
|
||||
import com.peanut.modules.common.entity.BuyOrder;
|
||||
import com.peanut.modules.common.entity.MyUserEntity;
|
||||
import com.peanut.modules.common.service.MyUserService;
|
||||
import com.peanut.modules.common.service.OfflineActivityService;
|
||||
import com.peanut.modules.common.service.OfflineActivityToUserService;
|
||||
import com.peanut.modules.pay.weChatPay.dto.WechatPaymentInfo;
|
||||
import com.peanut.modules.pay.weChatPay.service.WxpayService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.MessagePostProcessor;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 线下活动
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonOfflineActivity")
|
||||
@RequestMapping("common/offlineActivity")
|
||||
public class OfflineActivityController {
|
||||
|
||||
@Autowired
|
||||
private OfflineActivityService offlineActivityService;
|
||||
@Autowired
|
||||
private OfflineActivityToUserService toUserService;
|
||||
@Autowired
|
||||
private BuyOrderService buyOrderService;
|
||||
@Autowired
|
||||
private WxpayService wxpayService;
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
|
||||
@RequestMapping("/getOfflineActivityInfo")
|
||||
public R getOfflineActivityInfo(@RequestBody Map<String,Object> params) {
|
||||
return R.ok().put("result", offlineActivityService.getById(params.get("id").toString()));
|
||||
}
|
||||
|
||||
//线下活动报名
|
||||
@RequestMapping("/offlineActivityPaySave")
|
||||
@Transactional
|
||||
public R relearnSave(@RequestBody BuyOrder buyOrder){
|
||||
int uid = ShiroUtils.getUId();
|
||||
buyOrder.setOrderStatus("0");
|
||||
buyOrder.setOrderType("offlineActivity");
|
||||
String timeId = IdWorker.getTimeId().substring(0, 32);
|
||||
buyOrder.setOrderSn(timeId);
|
||||
buyOrder.setUserId(uid);
|
||||
buyOrderService.save(buyOrder);
|
||||
BigDecimal totalPrice = buyOrder.getRealMoney();
|
||||
//微信支付预付款订单
|
||||
if(Constants.PAYMENT_METHOD_WECHAT_PAY.equals(buyOrder.getPaymentMethod())){
|
||||
BuyOrder buyOrderEntity = buyOrderService.getBaseMapper().selectOne(new LambdaQueryWrapper<BuyOrder>()
|
||||
.eq(BuyOrder::getOrderSn, timeId));
|
||||
WechatPaymentInfo paymentInfo = new WechatPaymentInfo();
|
||||
paymentInfo.setOrderSn(buyOrderEntity.getOrderSn());
|
||||
paymentInfo.setBuyOrderId(buyOrder.getOrderId());
|
||||
paymentInfo.setTotalAmount(buyOrderEntity.getRealMoney());
|
||||
if (buyOrder.getCome()==2){
|
||||
paymentInfo.setAppName("wumen");
|
||||
} else if (buyOrder.getCome()==1) {
|
||||
paymentInfo.setAppName("zmzm");
|
||||
} else if (buyOrder.getCome()==3) {
|
||||
paymentInfo.setAppName("xlkj");
|
||||
} else if (buyOrder.getCome()==4) {
|
||||
paymentInfo.setAppName("thyy");
|
||||
}else {
|
||||
paymentInfo.setAppName(buyOrder.getAppName());
|
||||
}
|
||||
wxpayService.prepay(paymentInfo);
|
||||
}
|
||||
rabbitTemplate.convertAndSend(
|
||||
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
|
||||
DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY,
|
||||
buyOrder.getOrderId(),
|
||||
messagePostProcessor()
|
||||
);
|
||||
return R.ok().put("orderSn", timeId).put("money", totalPrice);
|
||||
}
|
||||
|
||||
private MessagePostProcessor messagePostProcessor() {
|
||||
return message -> {
|
||||
//设置有效期30分钟
|
||||
message.getMessageProperties().setExpiration(String.valueOf(30 * 60 * 1000));
|
||||
return message;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.City;
|
||||
import com.peanut.modules.common.entity.County;
|
||||
import com.peanut.modules.common.entity.Province;
|
||||
import com.peanut.modules.common.service.CityService;
|
||||
import com.peanut.modules.common.service.CountyService;
|
||||
import com.peanut.modules.common.service.ProvinceService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 省市区管理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonProvince")
|
||||
@RequestMapping("common/province")
|
||||
public class ProvinceController {
|
||||
|
||||
@Autowired
|
||||
private ProvinceService provinceService;
|
||||
@Autowired
|
||||
private CityService cityService;
|
||||
@Autowired
|
||||
private CountyService countyService;
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
//获取地址
|
||||
@RequestMapping("/getProvince")
|
||||
public R getProvince() {
|
||||
//优化查询速度 目录放入redis中
|
||||
String s = redisTemplate.opsForValue().get("Province");
|
||||
List<Map<String, Object>> listData = new ArrayList<>();
|
||||
if (StringUtils.isNotBlank(s)) {
|
||||
List<Object> redisData = JSONArray.parseArray(s);
|
||||
for (Object object : redisData) {
|
||||
Map<String, Object> ret = (Map<String, Object>) object;//取出list里面的值转为map
|
||||
listData.add(ret);
|
||||
}
|
||||
return R.ok().put("provinceEntity", listData);
|
||||
}
|
||||
List<Province> provinceList = provinceService.getCity();
|
||||
redisTemplate.opsForValue().set("Province", JSON.toJSONString(provinceList));
|
||||
return R.ok().put("provinceEntity", provinceList);
|
||||
}
|
||||
|
||||
//获取省列表
|
||||
@RequestMapping("/getProvinceList")
|
||||
public R getProvinceList() {
|
||||
List<Province> provinceList = provinceService.getBaseMapper().selectList(new QueryWrapper<Province>());
|
||||
return R.ok().put("provinceList", provinceList);
|
||||
}
|
||||
|
||||
//获取市列表
|
||||
@RequestMapping("/getCityList")
|
||||
public R getCityList(@RequestParam("provId") Integer provId) {
|
||||
List<City> prov = cityService.getBaseMapper().selectList(new QueryWrapper<City>()
|
||||
.eq("prov_id", provId));
|
||||
return R.ok().put("prov", prov);
|
||||
}
|
||||
|
||||
//获取区列表
|
||||
@RequestMapping("/getCountyList")
|
||||
public R getCountyList(@RequestParam("cityId") Integer cityId) {
|
||||
List<County> countyList = countyService.getBaseMapper().selectList(new QueryWrapper<County>().eq("city_id", cityId));
|
||||
return R.ok().put("countyList", countyList);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.RagFlowApiUtil;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.common.entity.AiChatContent;
|
||||
import com.peanut.modules.common.service.AiChatContentService;
|
||||
import com.peanut.modules.common.service.AiVipLogService;
|
||||
import com.peanut.modules.common.service.PrecisionMedicineGeneService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController("commonRagFlowApi")
|
||||
@RequestMapping("common/ragFlowApi")
|
||||
public class RagFlowApiController {
|
||||
|
||||
@Autowired
|
||||
private RagFlowApiUtil ragFlowApiUtil;
|
||||
@Autowired
|
||||
private AiChatContentService aiChatContentService;
|
||||
@Autowired
|
||||
private AiVipLogService aiVipLogService;
|
||||
@Autowired
|
||||
private PrecisionMedicineGeneService geneService;
|
||||
|
||||
//聊天助手列表
|
||||
@RequestMapping("/getChatAssistants")
|
||||
public R getChatAssistants() throws Exception{
|
||||
List<Map<String,Object>> list = ragFlowApiUtil.getChatAssistants("");
|
||||
List<Map<String,Object>> res = new ArrayList<>();
|
||||
res.add(new HashMap<>());res.add(new HashMap<>());
|
||||
res.add(new HashMap<>());res.add(new HashMap<>());
|
||||
res.add(new HashMap<>());res.add(new HashMap<>());
|
||||
for (Map<String,Object> map:list) {
|
||||
if (map.get("name").toString().contains("消化")){
|
||||
res.set(0,map);
|
||||
}else if (map.get("name").toString().contains("呼吸")){
|
||||
res.set(1,map);
|
||||
}else if (map.get("name").toString().contains("风湿免疫")){
|
||||
res.set(2,map);
|
||||
}else if (map.get("name").toString().contains("肿瘤")){
|
||||
res.set(3,map);
|
||||
}else if (map.get("name").toString().contains("妇科")){
|
||||
res.set(4,map);
|
||||
}else if (map.get("name").toString().contains("全科")){
|
||||
res.set(5,map);
|
||||
}
|
||||
}
|
||||
return R.ok().put("list",res);
|
||||
}
|
||||
|
||||
//聊天助手下对话列表
|
||||
@RequestMapping("/getChats")
|
||||
public R getChats(@RequestBody Map<String,Object> params) throws Exception{
|
||||
LambdaQueryWrapper<AiChatContent> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(AiChatContent::getUserId, ShiroUtils.getUId());
|
||||
if (StringUtils.isNotEmpty(params.get("chatId").toString())||
|
||||
StringUtils.isNotEmpty(params.get("sessionId").toString())){
|
||||
wrapper.eq(StringUtils.isNotEmpty(params.get("chatId").toString()),
|
||||
AiChatContent::getChatAssistantId,params.get("chatId"));
|
||||
wrapper.eq(StringUtils.isNotEmpty(params.get("sessionId").toString()),
|
||||
AiChatContent::getChatId,params.get("sessionId"));
|
||||
wrapper.orderByAsc(AiChatContent::getCreateTime);
|
||||
}else {
|
||||
wrapper.groupBy(AiChatContent::getChatId);
|
||||
wrapper.orderByDesc(AiChatContent::getCreateTime);
|
||||
}
|
||||
List<AiChatContent> contents = aiChatContentService.list(wrapper);
|
||||
return R.ok().put("list",contents);
|
||||
}
|
||||
|
||||
//创建会话
|
||||
@RequestMapping("/createChat")
|
||||
@Transactional
|
||||
public R createChat(@RequestBody Map<String,Object> params) throws Exception{
|
||||
List<AiChatContent> quankeContentList = aiChatContentService.list(new LambdaQueryWrapper<AiChatContent>()
|
||||
.eq(AiChatContent::getUserId,ShiroUtils.getUId())
|
||||
.like(AiChatContent::getChatAssistantName,"全科")
|
||||
.orderByAsc(AiChatContent::getCreateTime)
|
||||
.groupBy(AiChatContent::getChatId));
|
||||
if (!aiVipLogService.isAiVip()){
|
||||
if (quankeContentList.size()>=3){
|
||||
return R.error("试用机会已用完,开通VIP拥有更多次数");
|
||||
}else {
|
||||
if (!params.get("assistantName").toString().contains("全科")){
|
||||
return R.error("免费次数只能使用全科医生");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if (params.get("assistantName").toString().contains("全科")&&quankeContentList.size()<3){
|
||||
}else {
|
||||
boolean res = aiVipLogService.userCount();
|
||||
if (!res){
|
||||
return R.error("VIP次数已用完");
|
||||
}
|
||||
}
|
||||
}
|
||||
String chatId = ragFlowApiUtil.createChat(params);
|
||||
return R.ok().put("id",chatId);
|
||||
}
|
||||
|
||||
//与助手聊天流式
|
||||
@RequestMapping(value = "/chatToAssistantStream")
|
||||
@Transactional
|
||||
public R chatToAssistantStream(String chatId,String chatName,String sessionId,String sessionName,String question,String patientName,String geneIds){
|
||||
Map<String,Object> geneInfo = null;
|
||||
if (StringUtils.isNotEmpty(geneIds)){
|
||||
geneInfo = geneService.getGeneInfo(geneIds);
|
||||
}
|
||||
ragFlowApiUtil.chatToAssistantStream(chatId,chatName,sessionId,sessionName,question,patientName,geneInfo);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//代理列表
|
||||
@RequestMapping("/getChatAgents")
|
||||
public R getChatAgents() throws Exception{
|
||||
List<Map<String,Object>> list = ragFlowApiUtil.getChatAgents("");
|
||||
return R.ok().put("list",list);
|
||||
}
|
||||
|
||||
//创建代理会话
|
||||
@RequestMapping("/createAgentChat")
|
||||
public R createAgentChat(@RequestBody Map<String,Object> params) throws Exception{
|
||||
String agentId = ragFlowApiUtil.createAgentChat(params);
|
||||
return R.ok().put("id",agentId);
|
||||
}
|
||||
|
||||
//与代理聊天流式
|
||||
@RequestMapping(value = "/chatToAgentStream")
|
||||
@Transactional
|
||||
public R chatToAgentStream(String agentId,String sessionId,String question){
|
||||
ragFlowApiUtil.chatToAgentStream(agentId,sessionId,question);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,337 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.common.entity.SelfEvaluationForm;
|
||||
import com.peanut.modules.common.service.SelfEvaluationFormService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 心身医学自评表
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonSelfEvaluationForm")
|
||||
@RequestMapping("common/selfEvaluationForm")
|
||||
public class SelfEvaluationFormController {
|
||||
|
||||
@Autowired
|
||||
private SelfEvaluationFormService selfEvaluationFormService;
|
||||
|
||||
|
||||
//自测表列表
|
||||
@RequestMapping("/formList")
|
||||
public R formList() {
|
||||
List res = new ArrayList();
|
||||
res.add(yiyu);
|
||||
res.add(jiaolv);
|
||||
// res.add(zibi);
|
||||
res.add(zaokuang);
|
||||
res.add(zilian);
|
||||
return R.ok().put("formList",res);
|
||||
}
|
||||
|
||||
//题目列表
|
||||
@RequestMapping("/formSubjectList")
|
||||
public R formSubjectList(@RequestBody Map<String,Object> params) {
|
||||
List list = null;
|
||||
if ("yiyu".equals(params.get("type").toString())){
|
||||
list = yiyuList;
|
||||
}else if ("jiaolv".equals(params.get("type").toString())){
|
||||
list = jiaolvList;
|
||||
}else if ("zaokuang".equals(params.get("type").toString())){
|
||||
list = zaokuangList;
|
||||
}else if ("zilian".equals(params.get("type").toString())){
|
||||
list = zilianList;
|
||||
}
|
||||
return R.ok().put("list",list);
|
||||
}
|
||||
|
||||
//打分
|
||||
@RequestMapping("/countForm")
|
||||
public R countForm(@RequestBody Map<String,Object> params) {
|
||||
R res = R.error();
|
||||
List<Integer> list = (List) params.get("resList");
|
||||
String country = params.get("country").toString();
|
||||
String city = params.get("city").toString();
|
||||
if ("yiyu".equals(params.get("type").toString())){
|
||||
res = countyiyu(list,country);
|
||||
}else if ("zilian".equals(params.get("type").toString())) {
|
||||
res = countzilian(list);
|
||||
}else if ("jiaolv".equals(params.get("type").toString())) {
|
||||
res = countjiaolv(list);
|
||||
}else if ("zaokuang".equals(params.get("type").toString())) {
|
||||
res = countzaokuang(list);
|
||||
}
|
||||
SelfEvaluationForm f = new SelfEvaluationForm();
|
||||
f.setType(params.get("type").toString());
|
||||
f.setUserId(ShiroUtils.getUId());
|
||||
f.setCountry(country);
|
||||
f.setCity(city);
|
||||
f.setStatus(res.get("status").toString());
|
||||
selfEvaluationFormService.save(f);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
public R countyiyu(List<Integer> list,String country) {
|
||||
int total = 0;
|
||||
for (int i=0;i < list.size(); i++) {
|
||||
//反向题
|
||||
if (i==1||i==4||i==5||i==10||i==11||i==13||i==15||i==16||i==17||i==19){
|
||||
if (list.get(i)==1){
|
||||
total += 4;
|
||||
}else if(list.get(i)==2){
|
||||
total += 3;
|
||||
}else if (list.get(i) == 3) {
|
||||
total += 2;
|
||||
}else {
|
||||
total += 1;
|
||||
}
|
||||
}else {
|
||||
total += list.get(i);
|
||||
}
|
||||
}
|
||||
total = (int)(total*1.25);
|
||||
if ("中国".equals(country)){
|
||||
total = total - 2;
|
||||
}
|
||||
String status ="无抑郁";
|
||||
if (total>=70){
|
||||
status ="重度抑郁";
|
||||
}else if (total >= 60) {
|
||||
status ="中至重度抑郁";
|
||||
}else if (total >= 50) {
|
||||
status ="轻微至轻度抑郁";
|
||||
}
|
||||
return R.ok().put("total",total).put("status",status);
|
||||
}
|
||||
public R countjiaolv(List<Integer> list) {
|
||||
int total = 0;
|
||||
for (int i=0;i < list.size(); i++) {
|
||||
//反向题
|
||||
if (i==1||i==2||i==3||i==4||i==6||i==7||i==8||i==10||i==11||i==12||i==14||i==15||i==16||i==18||i==20){
|
||||
if (list.get(i)==1){
|
||||
total += 1;
|
||||
}else if(list.get(i)==2){
|
||||
total += 2;
|
||||
}else if (list.get(i) == 3) {
|
||||
total += 3;
|
||||
}else {
|
||||
total += 4;
|
||||
}
|
||||
}else {
|
||||
total += list.get(i);
|
||||
}
|
||||
}
|
||||
total = (int)(total*1.25);
|
||||
String status ="正常";
|
||||
if (total>=70){
|
||||
status ="重度焦虑";
|
||||
}else if (total >= 60) {
|
||||
status ="中至重度焦虑";
|
||||
}else if (total >= 50) {
|
||||
status ="轻微至轻度焦虑";
|
||||
}
|
||||
return R.ok().put("total",total).put("status",status);
|
||||
}
|
||||
public R countzaokuang(List<Integer> list) {
|
||||
int total = 0;
|
||||
for (int i=0;i < list.size(); i++) {
|
||||
if (list.get(i)==1){
|
||||
total += 0;
|
||||
}else if(list.get(i)==2){
|
||||
total += 1;
|
||||
}else if (list.get(i) == 3) {
|
||||
total += 2;
|
||||
}else {
|
||||
total += 3;
|
||||
}
|
||||
}
|
||||
String status ="无双相情感障碍 (注意自我保重)";
|
||||
if (total>=19){
|
||||
status ="可能有双相情感账啊 (一定要看心理医生或精神科医生)";
|
||||
}else if (total >= 9) {
|
||||
status ="可能有轻微的双相情感障碍 (建议咨询心理医生或精神科医生)";
|
||||
}
|
||||
return R.ok().put("total",total).put("status",status);
|
||||
}
|
||||
|
||||
public R countzilian(List<Integer> list) {
|
||||
int total = 0;
|
||||
for (int i=0;i < list.size(); i++) {
|
||||
if (1==list.get(i)){
|
||||
total++;
|
||||
}
|
||||
}
|
||||
String status ="正常";
|
||||
if (total>=5){
|
||||
status ="自恋型人格障碍";
|
||||
}
|
||||
return R.ok().put("total",total).put("status",status);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private static final Map<String, Object> yiyu;
|
||||
private static final Map<String, Object> jiaolv;
|
||||
// private static final Map<String, Object> zibi;
|
||||
private static final Map<String, Object> zaokuang;
|
||||
private static final Map<String, Object> zilian;
|
||||
private static final List yiyuList;
|
||||
private static final List jiaolvList;
|
||||
// private static final List zibiList;
|
||||
private static final List zaokuangList;
|
||||
private static final List zilianList;
|
||||
|
||||
static {
|
||||
yiyu = new HashMap<>();
|
||||
yiyu.put("type","yiyu");
|
||||
yiyu.put("title","SDS抑郁自评量表");
|
||||
yiyu.put("des","抑郁自测量表SDS由W.K.Zung编制于1965年,为美国教育卫生福利部推荐的用于精神药理学研究的量表之一。因使用简便,能相当直观地反映病人抑郁的主观感受及其在治疗中的变化,当前已广泛应用于抑郁测试。");
|
||||
yiyu.put("num","20道题目");
|
||||
yiyu.put("tip","请仔细阅读每道题目,把意思弄明白,然后根据最近一周的实际感觉,选择适当的选项。");
|
||||
yiyu.put("cnRes","SDS的评定结果以标准分来定:\n" +
|
||||
"标准分小于52分为无抑郁;\n" +
|
||||
"标准分大于等于52分且小于62分为轻微至轻度抑郁;\n" +
|
||||
"标准分大于等于62分且小于72分为中至重度抑郁;\n" +
|
||||
"标准分大于等于72分为重度抑郁。\n" +
|
||||
"抑郁评定的临界值为T分52,分值越高,抑郁倾向越明显");
|
||||
yiyu.put("worldRes","SDS的评定结果以标准分来定:\n" +
|
||||
"标准分小于50分为无抑郁;\n" +
|
||||
"标准分大于等于50分且小于60分为轻微至轻度抑郁;\n" +
|
||||
"标准分大于等于60分且小于70分为中至重度抑郁;\n" +
|
||||
"标准分大于等于70分为重度抑郁。\n" +
|
||||
"抑郁评定的临界值为T分50,分值越高,抑郁倾向越明显。");
|
||||
yiyu.put("role","SDS评定采用1—4制记分,评分时间为过去一周内。\n" +
|
||||
"正向题,依次评为粗分1、2、3、4分 (1 3 4 7 8 9 10 13 15 19)\n" +
|
||||
"反向题,依次评为粗分4、3、2、1分 (2 5 6 11 12 14 16 17 18 20)\n" +
|
||||
"20项相加得到原始分,原始分分乘以1.25以后取整,得到标准分。");
|
||||
yiyu.put("result", Arrays.asList("没有或很少时间","小部分时间","相当多时间","绝大部分或全部时间"));
|
||||
yiyuList = new ArrayList();
|
||||
yiyuList.add("我觉得闷闷不乐,情绪低沉");
|
||||
yiyuList.add("我觉得一天之中早晨最好");
|
||||
yiyuList.add("我一阵阵哭出来或觉得想哭");
|
||||
yiyuList.add("我晚上睡眠不好");
|
||||
yiyuList.add("我吃得跟平常一样多");
|
||||
yiyuList.add("我与异性密切接触时和以往一样感到愉快");
|
||||
yiyuList.add("我发觉我的体重下降");
|
||||
yiyuList.add("我有便秘的苦恼");
|
||||
yiyuList.add("我心跳比平时快");
|
||||
yiyuList.add("我无缘无故地感到疲乏");
|
||||
yiyuList.add("我的头脑跟平常一样清楚");
|
||||
yiyuList.add("觉得经常做的事情并没有困难");
|
||||
yiyuList.add("我觉得不安而平静不下来");
|
||||
yiyuList.add("我对将来抱有希望");
|
||||
yiyuList.add("我比平常容易生气激动");
|
||||
yiyuList.add("我觉得作出决定是容易的");
|
||||
yiyuList.add("我觉得自己是个有用的人,有人需要我");
|
||||
yiyuList.add("我的生活过得很有意思");
|
||||
yiyuList.add("我认为如果我死了别人会生活得好些");
|
||||
yiyuList.add("我平常感兴趣的事我仍然照样感兴趣");
|
||||
|
||||
jiaolv = new HashMap<>();
|
||||
jiaolv.put("title","SAS焦虑量表");
|
||||
jiaolv.put("type","jiaolv");
|
||||
jiaolv.put("des","焦虑自评量表,由W.K.Zung于1971年编制。从量表结构的形式到具体评定方法,都与抑郁自评量表(SDS)十分相似,用于评定病人焦虑的主观感受及其在治疗中的变化。SAS适用于具有焦虑症状的成年人,它与SDS一样具有广泛的应用性。焦虑是心理咨询门诊中较为常见的一种情绪障碍,因此SAS可作为咨询门诊中了解焦虑症状的自评工具。");
|
||||
jiaolv.put("num","20道题目");
|
||||
jiaolv.put("tip","请仔细阅读每道题目,把意思弄明白,然后根据最近一周的实际感觉,选择适当的选项。");
|
||||
jiaolv.put("cnRes","SAS标准差的分界值为50分,其中50~59分为轻度焦虑,60~69分为中度焦虑,69分以上为重度焦虑。");
|
||||
jiaolv.put("worldRes","SAS标准差的分界值为50分,其中50~59分为轻度焦虑,60~69分为中度焦虑,69分以上为重度焦虑。");
|
||||
jiaolv.put("role","若为正向评分题,依次评为粗分1、2、3、4分;反向评分题(带有*号者),则评为4、3、2、1分。与SDS一样,20个项目得分相加即得粗分(X),经过公式换算,即用粗分乘以1.25以后取整数部分,就得标准分(Y)。");
|
||||
jiaolv.put("result", Arrays.asList("没有或很少时间","小部分时间","相当多时间","绝大部分或全部时间"));
|
||||
jiaolvList = new ArrayList();
|
||||
jiaolvList.add("我觉得比平常容易紧张和着急");
|
||||
jiaolvList.add("我无缘无故地感到害怕");
|
||||
jiaolvList.add("我容易心里烦乱或觉得惊恐");
|
||||
jiaolvList.add("我觉得我可能将要发疯");
|
||||
jiaolvList.add("我觉得一切都很好,也不会发生什么不幸");
|
||||
jiaolvList.add("我手脚发抖打颤");
|
||||
jiaolvList.add("我因为头疼、头颈痛和背痛而苦恼");
|
||||
jiaolvList.add("我感到容易衰弱和疲乏");
|
||||
jiaolvList.add("我觉得心平气和,并且容易安静坐着");
|
||||
jiaolvList.add("我觉得心跳得很快");
|
||||
jiaolvList.add("我因为一阵阵头晕而苦恼");
|
||||
jiaolvList.add("我有晕倒发作或觉得要晕倒似的");
|
||||
jiaolvList.add("我呼气、吸气都感到很容易");
|
||||
jiaolvList.add("我手脚麻木和刺痛");
|
||||
jiaolvList.add("我因为胃痛和消化不良而苦恼");
|
||||
jiaolvList.add("我常常要小便");
|
||||
jiaolvList.add("我的手脚常常是干燥温暖的");
|
||||
jiaolvList.add("我脸红发热");
|
||||
jiaolvList.add("我容易入睡,并且一夜睡得很好");
|
||||
jiaolvList.add("我做恶梦(恶梦)");
|
||||
|
||||
// zibi = new HashMap<>();
|
||||
// zibi.put("title","自闭量表");
|
||||
// zibi.put("type","zibi");
|
||||
// zibi.put("des","你自闭了吗");
|
||||
// zibi.put("num","20道题目");
|
||||
// zibi.put("tip","请仔细阅读每道题目,把意思弄明白,然后根据最近一周的实际感觉,选择适当的选项。");
|
||||
// zibi.put("cnRes","否");
|
||||
// zibi.put("worldRes","否");
|
||||
// zibi.put("role","大于0就自闭");
|
||||
|
||||
zaokuang = new HashMap<>();
|
||||
zaokuang.put("title","双相情感障碍/躁郁症量表");
|
||||
zaokuang.put("type","zaokuang");
|
||||
zaokuang.put("des","BSQ主要用于对双相情感障碍(躁狂抑郁症)进行筛查,量表主要包含12个项目。对于双向情感障碍的筛查,除了通过专门的双向情感障碍量表筛查外,也可以结合躁狂症筛查量表、抑郁症筛查量表一起进行,如果即有躁狂症状又有抑郁症状,则需要考虑双向情感障碍的可能性。");
|
||||
zaokuang.put("num","12道题目");
|
||||
zaokuang.put("tip","请仔细阅读每道题目,把意思弄明白,然后根据最近一周的实际感觉,选择适当的选项。");
|
||||
zaokuang.put("cnRes","0-8 无双相情感障碍 (注意自我保重)\n" +
|
||||
"9-18 可能有轻微的双相情感障碍 (建议咨询心理医生或精神科医生)\n" +
|
||||
"19-36 可能有双相情感账啊 (一定要看心理医生或精神科医生)");
|
||||
zaokuang.put("worldRes","0-8 无双相情感障碍 (注意自我保重)\n" +
|
||||
"9-18 可能有轻微的双相情感障碍 (建议咨询心理医生或精神科医生)\n" +
|
||||
"19-36 可能有双相情感账啊 (一定要看心理医生或精神科医生)");
|
||||
zaokuang.put("role","没有=0,轻度=1,中度数=2,非常严重=3.\n" +
|
||||
"总分0-36分");
|
||||
zaokuang.put("result",Arrays.asList("没有","轻度","中度","非常严重"));
|
||||
zaokuangList = new ArrayList();
|
||||
zaokuangList.add("有时我突然变得非常健谈而且语速非常快。");
|
||||
zaokuangList.add("有时我突然变得特别主动,做一些平时都不做的事情。");
|
||||
zaokuangList.add("有时候我觉得时间过得很快,这种时候我感到有些生气!");
|
||||
zaokuangList.add("我有时候会一方面觉得自己情绪高涨,另一方面又觉得有些沮丧。");
|
||||
zaokuangList.add("别人对我的评价经常提到,有段时间显得过于自卑,有段时间又显得过于自信。");
|
||||
zaokuangList.add("我的工作业绩(学习成绩)不是很稳定,一段时间能做很多事情,也能出成果,另外一段时间却什么都做不出来。");
|
||||
zaokuangList.add("有时候,我会有不明原因的愤怒,甚至想打人。");
|
||||
zaokuangList.add("我在某段时间觉得脑中空空如也,什么都想不出;而在另外一段时间的想法又特别多,很有创意。");
|
||||
zaokuangList.add("我在一些时间喜欢和别人黏在一起玩耍,而在另外一段时间我却只想单独呆着。");
|
||||
zaokuangList.add("我在某段时间觉得特别乐观;另外一段时间我又觉得特别悲观。");
|
||||
zaokuangList.add("我在某段时间感到食欲不振;另外一段时间却情不自禁地暴饮暴食。");
|
||||
zaokuangList.add("我在某段时间觉得特别想哭哭不出来;另外一段时间却特别幽默搞笑。");
|
||||
|
||||
zilian = new HashMap<>();
|
||||
zilian.put("title","自恋型人格障碍量表");
|
||||
zilian.put("type","zilian");
|
||||
zilian.put("des","自恋型人格障碍量表(是否题),测试的主要目的是帮助个体了解自己的自恋程度,以及自恋特质对人际关系、心理健康等方面的影响。通过测试,个体可以更好地认识自己,从而采取适当的措施来调整自己的行为和心态。");
|
||||
zilian.put("num","10道题目");
|
||||
zilian.put("tip","请仔细阅读每道题目,把意思弄明白,然后根据最近一周的实际感觉,选择适当的选项。");
|
||||
zilian.put("cnRes","出现是其中的五项,即可诊断为自恋型人格障碍。");
|
||||
zilian.put("worldRes","出现是其中的五项,即可诊断为自恋型人格障碍。");
|
||||
zilian.put("role","出现是其中的五项,即可诊断为自恋型人格障碍。");
|
||||
zilian.put("result",Arrays.asList("是","否"));
|
||||
zilianList = new ArrayList();
|
||||
zilianList.add("自高自大,对自己的才能夸大其辞,希望受人特别关注。(自高自大)");
|
||||
zilianList.add("坚信他关注的问题是世上独有的,不能被某些特殊的人物了解。(不被理解)");
|
||||
zilianList.add("对权力、金钱、荣誉、美丽或理想爱情有过分幻想。(不切实际)");
|
||||
zilianList.add("缺乏同情心。(不能共情)");
|
||||
zilianList.add("有很强的嫉妒心。");
|
||||
zilianList.add("对批评的反应是愤怒、羞愧或感到耻辱(尽管不一定当即表露出来)(永不认错)");
|
||||
zilianList.add("渴望持久的关注与赞美。(渴望关注)");
|
||||
zilianList.add("喜欢指使他人,要他人为自己服务。(被服务)");
|
||||
zilianList.add("认为自己应享有他人没有的特权。(控制关系)");
|
||||
zilianList.add("亲密关系困难(婚姻关系,亲子关系等)");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.ShopProduct;
|
||||
import com.peanut.modules.common.entity.ShopProductRecord;
|
||||
import com.peanut.modules.common.service.ShopProductRecordService;
|
||||
import com.peanut.modules.master.service.ShopProductService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 商品评价管理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonShopProductRecord")
|
||||
@RequestMapping("common/shopProductRecord")
|
||||
public class ShopProductRecordController {
|
||||
|
||||
@Autowired
|
||||
private ShopProductRecordService recordService;
|
||||
@Autowired
|
||||
private ShopProductService productService;
|
||||
|
||||
@RequestMapping("/listByPage")
|
||||
public R listByPage(@RequestBody Map<String, Object> params) {
|
||||
MPJLambdaWrapper<ShopProductRecord> wrapper = new MPJLambdaWrapper();
|
||||
if (params.containsKey("userId")&&StringUtils.isNotEmpty(params.get("userId").toString())) {
|
||||
wrapper.eq(ShopProductRecord::getUserId,params.get("userId"));
|
||||
}
|
||||
if (params.containsKey("productId")&&StringUtils.isNotEmpty(params.get("productId").toString())) {
|
||||
wrapper.eq(ShopProductRecord::getProductId,params.get("productId"));
|
||||
}
|
||||
if (params.containsKey("state")&&StringUtils.isNotEmpty(params.get("state").toString())) {
|
||||
wrapper.eq(ShopProductRecord::getState,params.get("state"));
|
||||
}
|
||||
wrapper.orderByAsc(ShopProductRecord::getCreateTime);
|
||||
Page<ShopProductRecord> records = recordService.page(new Page<>(
|
||||
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())), wrapper);
|
||||
List<ShopProductRecord> result = records.getRecords();
|
||||
if (result.size() > 0) {
|
||||
for (ShopProductRecord record:result){
|
||||
ShopProduct product = productService.getById(record.getProductId());
|
||||
record.setProduct(product);
|
||||
}
|
||||
}
|
||||
return R.ok().put("result", records);
|
||||
}
|
||||
|
||||
@RequestMapping("/saveRecord")
|
||||
public R saveRecord(@RequestBody ShopProductRecord record) {
|
||||
record.setRecordTime(new Date());
|
||||
record.setState(1);
|
||||
recordService.saveOrUpdate(record);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/reSaveRecord")
|
||||
public R reSaveRecord(@RequestBody ShopProductRecord record) {
|
||||
record.setReRecordTime(new Date());
|
||||
recordService.saveOrUpdate(record);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.SysFeedback;
|
||||
import com.peanut.modules.common.service.SysFeedbackService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 问题反馈
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonSysFeedback")
|
||||
@RequestMapping("common/sysFeedback")
|
||||
public class SysFeedbackController {
|
||||
|
||||
@Autowired
|
||||
private SysFeedbackService sysFeedbackService;
|
||||
|
||||
@RequestMapping("/addSysFeedback")
|
||||
public R addSysFeedback(@RequestBody SysFeedback sysFeedback){
|
||||
if (sysFeedbackService.addSysFeedback(sysFeedback)>0){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error("添加失败");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/getList")
|
||||
public R getList(@RequestBody Map<String,Object> params){
|
||||
List<SysFeedback> res = sysFeedbackService.getList(params);
|
||||
return R.ok().put("res",res);
|
||||
}
|
||||
|
||||
@RequestMapping("/getById")
|
||||
public R getById(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("sysFeedback",sysFeedbackService.getById(params));
|
||||
}
|
||||
|
||||
@RequestMapping("/editStatusById")
|
||||
public R editStatusById(@RequestBody Map<String,Object> params){
|
||||
if (sysFeedbackService.editStatusById(params)>0){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error("修改失败");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/delById")
|
||||
public R delById(@RequestBody Map<String,Object> params){
|
||||
if (sysFeedbackService.delById(params)>0){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error("删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.common.entity.SysNotice;
|
||||
import com.peanut.modules.common.service.SysNoticeService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController("commonSysNotice")
|
||||
@RequestMapping("common/sysNotice")
|
||||
public class SysNoticeController {
|
||||
|
||||
@Autowired
|
||||
private SysNoticeService sysNoticeService;
|
||||
|
||||
//消息通知列表
|
||||
@RequestMapping("/getSysNotices")
|
||||
public R getSysNotices(){
|
||||
LambdaQueryWrapper<SysNotice> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SysNotice::getUserId, ShiroUtils.getUId());
|
||||
wrapper.like(SysNotice::getReadFlag,0);
|
||||
return R.ok().put("list",sysNoticeService.list(wrapper));
|
||||
}
|
||||
|
||||
//查看消息通知
|
||||
@RequestMapping("/readSysNotice")
|
||||
public R readSysNotice(@RequestBody Map<String,Object> params){
|
||||
String[] ids = params.get("id").toString().split(",");
|
||||
for (String id : ids) {
|
||||
SysNotice sysNotice = sysNoticeService.getById(id);
|
||||
sysNotice.setReadFlag(1);
|
||||
sysNotice.setUpdateTime(new Date());
|
||||
sysNoticeService.updateById(sysNotice);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.TaihuWelfareEntity;
|
||||
import com.peanut.modules.common.service.TaihuWelfareService;
|
||||
import com.peanut.modules.common.to.ParamTo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController("commonTaihuWelfare")
|
||||
@RequestMapping("common/taihuWelfare")
|
||||
public class TaihuWelfareController {
|
||||
@Autowired
|
||||
private TaihuWelfareService taihuWelfareService;
|
||||
|
||||
@RequestMapping("/getTaihuWelfareArticleList")
|
||||
public R getTaihuWelfareArticleList(@RequestBody ParamTo param){
|
||||
return taihuWelfareService.getTaihuWelfareArticleList(param);
|
||||
}
|
||||
|
||||
@RequestMapping("/getTaihuWelfareProductList")
|
||||
public R getTaihuWelfareProductList(@RequestBody ParamTo param){
|
||||
return taihuWelfareService.getTaihuWelfareProductList(param);
|
||||
}
|
||||
|
||||
@RequestMapping("/getTaihuWelfareArticleDetail")
|
||||
public R getTaihuWelfareArticleDetail(@RequestBody Map<String,Integer> map){
|
||||
TaihuWelfareEntity byId = taihuWelfareService.getById(map.get("id"));
|
||||
return R.ok().put("result",byId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.peanut.common.utils.HttpContextUtil;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.config.Constants;
|
||||
import com.peanut.config.DelayQueueConfig;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.*;
|
||||
import com.peanut.modules.pay.weChatPay.dto.WechatPaymentInfo;
|
||||
import com.peanut.modules.pay.weChatPay.service.WxpayService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.amqp.core.MessagePostProcessor;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 培训班
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonTrainingClass")
|
||||
@RequestMapping("common/trainingClass")
|
||||
public class TrainingClassController {
|
||||
|
||||
@Autowired
|
||||
private TrainingClassService trainingClassService;
|
||||
@Autowired
|
||||
private TrainingToUserService trainingToUserService;
|
||||
@Autowired
|
||||
private com.peanut.modules.book.service.TransactionDetailsService transactionDetailsService;
|
||||
@Autowired
|
||||
private JfTransactionDetailsService jfTransactionDetailsService;
|
||||
@Autowired
|
||||
private BuyOrderService buyOrderService;
|
||||
@Autowired
|
||||
private WxpayService wxpayService;
|
||||
@Autowired
|
||||
private MyUserService userService;
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
//获取用户当前培训班最低价格
|
||||
@RequestMapping("/getFinalPriceByUser")
|
||||
public R getFinalPriceByUser(@RequestBody Map<String,Object> params) {
|
||||
Map<String,Object> info = trainingClassService.getFinalPriceByUser((int)params.get("classId"),(int)params.get("userId"));
|
||||
return R.ok().put("info",info);
|
||||
}
|
||||
|
||||
//培训班列表
|
||||
@RequestMapping("/trainingClassList")
|
||||
public R trainingClassList(@RequestBody Map<String,Object> params) {
|
||||
//根部不同平台返回不同列表
|
||||
HttpServletRequest request = HttpContextUtil.getHttpServletRequest();
|
||||
String displayApp = "";
|
||||
String appType = request.getHeader("appType")==null?"":request.getHeader("appType");
|
||||
if ("".equals(appType)){
|
||||
displayApp = "0";
|
||||
}else if ("medical".equals(appType)){
|
||||
displayApp = "2";
|
||||
}else if ("sociology".equals(appType)){
|
||||
displayApp = "1";
|
||||
}else if ("psyche".equals(appType)){
|
||||
displayApp = "3";
|
||||
}else if ("taihumed".equals(appType)){
|
||||
displayApp = "4";
|
||||
}
|
||||
List<TrainingClass> trainingClassList = trainingClassService.list(new LambdaQueryWrapper<TrainingClass>()
|
||||
.eq(TrainingClass::getDisplayFlag,0)
|
||||
.eq(StringUtils.isNotEmpty(params.get("year").toString()),TrainingClass::getYear,params.get("year"))
|
||||
.like(!"".equals(displayApp),TrainingClass::getDisplayApp,displayApp)
|
||||
.orderByDesc(TrainingClass::getSingupFlag)
|
||||
.orderByAsc(TrainingClass::getSort));
|
||||
for (TrainingClass trainingClass : trainingClassList) {
|
||||
trainingClass.setFinalFee("0");
|
||||
Map m = trainingClassService.getFinalPriceByUser(trainingClass.getId(),ShiroUtils.getUId());
|
||||
if (m!=null&m.containsKey("identity")){
|
||||
trainingClass.setIdentity(m.get("identity").toString());
|
||||
}
|
||||
if (m!=null&m.containsKey("fee")){
|
||||
trainingClass.setFinalFee(m.get("fee").toString());
|
||||
}
|
||||
Long count = trainingToUserService.count(new LambdaQueryWrapper<TrainingToUser>()
|
||||
.eq(TrainingToUser::getUserId, ShiroUtils.getUId())
|
||||
.eq(TrainingToUser::getTrainingId,trainingClass.getId()));
|
||||
if (count > 0) {
|
||||
trainingClass.setIsJoin(1);
|
||||
}else {
|
||||
trainingClass.setIsJoin(0);
|
||||
}
|
||||
}
|
||||
return R.ok().put("trainingClassList",trainingClassList);
|
||||
}
|
||||
|
||||
//培训班报名
|
||||
@RequestMapping("/trainingClassPaySave")
|
||||
@Transactional
|
||||
public R trainingClassPaySave(@RequestBody BuyOrder buyOrder){
|
||||
Long count = trainingToUserService.count(new LambdaQueryWrapper<TrainingToUser>()
|
||||
.eq(TrainingToUser::getUserId,buyOrder.getUserId())
|
||||
.eq(TrainingToUser::getTrainingId,buyOrder.getTrainingClassId()));
|
||||
if(count>0){
|
||||
return R.error("已报名");
|
||||
}
|
||||
if (!"1".equals(buyOrder.getPaymentMethod())){
|
||||
return R.error("此次会议仅支持微信报名(苹果用户想报名请联系吴门医述客服,客服微信:yilujiankangkefu)");
|
||||
}
|
||||
if (buyOrder.getJfDeduction().compareTo(BigDecimal.ZERO)>0){
|
||||
return R.error("此次会议不支持积分抵扣");
|
||||
}
|
||||
buyOrder.setOrderStatus("0");
|
||||
buyOrder.setOrderType("trainingClass");
|
||||
String timeId = IdWorker.getTimeId().substring(0, 32);
|
||||
buyOrder.setOrderSn(timeId);
|
||||
buyOrder.setUserId(ShiroUtils.getUId());
|
||||
buyOrderService.save(buyOrder);
|
||||
if (StringUtils.isNotEmpty(buyOrder.getUserName())){
|
||||
MyUserEntity user = userService.getById(buyOrder.getUserId());
|
||||
user.setName(buyOrder.getUserName());
|
||||
userService.updateById(user);
|
||||
}
|
||||
BigDecimal totalPrice = buyOrder.getRealMoney();
|
||||
//虚拟币支付
|
||||
if (Constants.PAYMENT_METHOD_VIRTUAL.equals(buyOrder.getPaymentMethod())) {
|
||||
buyOrder.setOrderStatus(Constants.ORDER_STATUS_TO_BE_SHIPPED);
|
||||
MyUserEntity user = userService.getById(buyOrder.getUserId());
|
||||
if (usePeanutCoin(user, totalPrice)) {
|
||||
//处理抵扣积分
|
||||
if(buyOrder.getJfDeduction().compareTo(BigDecimal.ZERO)>0){
|
||||
userCoinJf(buyOrder);
|
||||
}
|
||||
buyOrder.setSuccessTime(new Date());
|
||||
// 更新订单状态
|
||||
buyOrderService.updateOrderStatus(user.getId(), buyOrder.getOrderSn(), "2");
|
||||
//记录用户虚拟币消费
|
||||
if(totalPrice.compareTo(BigDecimal.ZERO)>0){
|
||||
transactionDetailsService.recordTransaction(buyOrder, user, totalPrice);
|
||||
}
|
||||
//插入培训班
|
||||
trainingClassService.addTrainingClassForUser(buyOrder);
|
||||
} else {
|
||||
return R.error(500, "余额不足!");
|
||||
}
|
||||
}
|
||||
//微信支付预付款订单
|
||||
if(Constants.PAYMENT_METHOD_WECHAT_PAY.equals(buyOrder.getPaymentMethod())){
|
||||
BuyOrder buyOrderEntity = buyOrderService.getBaseMapper().selectOne(new LambdaQueryWrapper<BuyOrder>()
|
||||
.eq(BuyOrder::getOrderSn, timeId));
|
||||
WechatPaymentInfo paymentInfo = new WechatPaymentInfo();
|
||||
paymentInfo.setOrderSn(buyOrderEntity.getOrderSn());
|
||||
paymentInfo.setBuyOrderId(buyOrder.getOrderId());
|
||||
paymentInfo.setOrderType(buyOrderEntity.getOrderType());
|
||||
paymentInfo.setTotalAmount(buyOrderEntity.getRealMoney());
|
||||
if (buyOrder.getCome()==2){
|
||||
paymentInfo.setAppName("wumen");
|
||||
} else if (buyOrder.getCome()==1) {
|
||||
paymentInfo.setAppName("zmzm");
|
||||
} else if (buyOrder.getCome()==3) {
|
||||
paymentInfo.setAppName("xlkj");
|
||||
} else if (buyOrder.getCome()==4) {
|
||||
paymentInfo.setAppName("thyy");
|
||||
}else {
|
||||
paymentInfo.setAppName(buyOrder.getAppName());
|
||||
}
|
||||
wxpayService.prepay(paymentInfo);
|
||||
}
|
||||
rabbitTemplate.convertAndSend(
|
||||
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
|
||||
DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY,
|
||||
buyOrder.getOrderId(),
|
||||
messagePostProcessor()
|
||||
);
|
||||
return R.ok().put("orderSn", timeId).put("money", totalPrice);
|
||||
}
|
||||
|
||||
private boolean usePeanutCoin(MyUserEntity user, BigDecimal totalPrice) {
|
||||
if (user.getPeanutCoin().compareTo(totalPrice) >= 0) {
|
||||
if(totalPrice.compareTo(BigDecimal.ZERO)==0){//纯积分支付,虚拟币不用支付
|
||||
return true;
|
||||
}
|
||||
user.setPeanutCoin(user.getPeanutCoin().subtract(totalPrice));
|
||||
userService.updateById(user);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void userCoinJf(BuyOrder order){
|
||||
MyUserEntity userEntity = userService.getById(order.getUserId());
|
||||
userEntity.setJf(userEntity.getJf().subtract(order.getJfDeduction()));
|
||||
userService.updateById(userEntity);
|
||||
JfTransactionDetails jfTransactionDetails = new JfTransactionDetails();
|
||||
jfTransactionDetails.setUserId(userEntity.getId());
|
||||
jfTransactionDetails.setChangeAmount(order.getJfDeduction().negate());
|
||||
jfTransactionDetails.setActType(1);
|
||||
jfTransactionDetails.setUserBalance(userEntity.getJf());
|
||||
jfTransactionDetails.setRelationId(order.getOrderId());
|
||||
jfTransactionDetails.setRemark("消费积分抵扣:"+order.getJfDeduction().toString()+",订单号:"+order.getOrderSn());
|
||||
jfTransactionDetailsService.save(jfTransactionDetails);
|
||||
}
|
||||
|
||||
private MessagePostProcessor messagePostProcessor() {
|
||||
return message -> {
|
||||
//设置有效期30分钟
|
||||
message.getMessageProperties().setExpiration(String.valueOf(30 * 60 * 1000));
|
||||
return message;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.service.BuyOrderProductService;
|
||||
import com.peanut.modules.book.service.ShopProductService;
|
||||
import com.peanut.modules.common.entity.BuyOrder;
|
||||
import com.peanut.modules.common.entity.BuyOrderProduct;
|
||||
import com.peanut.modules.common.entity.ShopProduct;
|
||||
import com.peanut.modules.common.entity.TransactionDetailsEntity;
|
||||
import com.peanut.modules.common.service.BuyOrderService;
|
||||
import com.peanut.modules.common.service.TransactionDetailsService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 付款记录
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonTransactionDetails")
|
||||
@RequestMapping("common/transactionDetails")
|
||||
public class TransactionDetailsController {
|
||||
|
||||
@Autowired
|
||||
private TransactionDetailsService transactionDetailsService;
|
||||
@Autowired
|
||||
private BuyOrderService buyOrderService;
|
||||
@Autowired
|
||||
private BuyOrderProductService buyOrderProductService;
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
|
||||
/**
|
||||
* 获取付款记录列表
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getTransactionDetailsList")
|
||||
public R getTransactionDetailsList(@RequestBody Map params){
|
||||
LambdaQueryWrapper<TransactionDetailsEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
if (params.containsKey("userId")&& StringUtils.isNotEmpty(params.get("userId").toString())){
|
||||
wrapper.eq(TransactionDetailsEntity::getUserId,params.get("userId"));
|
||||
}
|
||||
wrapper.orderByDesc(TransactionDetailsEntity::getCreateTime);
|
||||
List<TransactionDetailsEntity> list = transactionDetailsService.list(wrapper);
|
||||
for (TransactionDetailsEntity detail:list){
|
||||
String productName = "";
|
||||
String orderSn = detail.getPayNo();
|
||||
BuyOrder buyOrder = buyOrderService.getOne(new LambdaQueryWrapper<BuyOrder>()
|
||||
.eq(BuyOrder::getOrderSn,orderSn));
|
||||
if (buyOrder!=null){
|
||||
if ("购买商品".equals(detail.getOrderType())){
|
||||
List<BuyOrderProduct> products = buyOrderProductService.list(new LambdaQueryWrapper<BuyOrderProduct>()
|
||||
.eq(BuyOrderProduct::getOrderId,buyOrder.getOrderId()));
|
||||
for (BuyOrderProduct buyOrderProduct : products) {
|
||||
ShopProduct shopProduct = shopProductService.getById(buyOrderProduct.getProductId());
|
||||
if (shopProduct != null){
|
||||
if (StringUtils.isNotBlank(productName)){
|
||||
productName += ";"+shopProduct.getProductName();
|
||||
}else {
|
||||
productName += shopProduct.getProductName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
detail.setRelationId(buyOrder.getOrderId());
|
||||
}
|
||||
detail.setProductName(productName);
|
||||
}
|
||||
return R.ok().put("transactionDetailsList",list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.UserAddress;
|
||||
import com.peanut.modules.common.service.UserAddressService;
|
||||
import com.peanut.modules.common.vo.UserAddressVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 收货地址管理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonUserAddress")
|
||||
@RequestMapping("common/userAddress")
|
||||
public class UserAddressController {
|
||||
|
||||
@Autowired
|
||||
private UserAddressService userAddressService;
|
||||
|
||||
/**
|
||||
* 获取地址信息
|
||||
*/
|
||||
@RequestMapping("/info/{addressId}")
|
||||
public R info(@PathVariable("addressId") Integer addressId) {
|
||||
UserAddress userAddress = userAddressService.getById(addressId);
|
||||
UserAddressVo vo = new UserAddressVo();
|
||||
BeanUtil.copyProperties(userAddress, vo);
|
||||
vo = userAddressService.getAddressName(vo, userAddress.getRegionCode());
|
||||
return R.ok().put("result", vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody UserAddress userAddress) {
|
||||
if (userAddress.getIsDefault()==1){
|
||||
userAddressService.clearUserDefaultAddress(userAddress.getUserId());
|
||||
}
|
||||
if(userAddress.getRegionCode()==null||userAddress.getRegionCode().equals("")){
|
||||
return R.error("地址异常添加失败!");
|
||||
}
|
||||
String str = userAddress.getConsigneeName()+userAddress.getConsigneePhone()+userAddress.getDetailAddress();
|
||||
if(str.contains("+")||str.contains("&")){
|
||||
return R.error("信息中不能含有“+”、“&”符号!");
|
||||
}
|
||||
userAddressService.save(userAddress);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody UserAddress userAddress) {
|
||||
if (userAddress.getIsDefault()==1){
|
||||
userAddressService.clearUserDefaultAddress(userAddress.getUserId());
|
||||
}
|
||||
String str = userAddress.getConsigneeName()+userAddress.getConsigneePhone()+userAddress.getDetailAddress();
|
||||
if(str.contains("+")||str.contains("&")){
|
||||
return R.error("信息中不能含有“+”、“&”符号!");
|
||||
}
|
||||
userAddressService.updateById(userAddress);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户地址
|
||||
*/
|
||||
@RequestMapping(value = "/delete")
|
||||
public R delete(@RequestParam("id") Integer id) {
|
||||
userAddressService.removeById(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户收货地址列表
|
||||
*/
|
||||
@RequestMapping("/getUserAddress")
|
||||
public R getUserAddress(@RequestParam("userId") Integer userId) {
|
||||
QueryWrapper<UserAddress> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", userId);
|
||||
queryWrapper.orderByDesc("is_default");
|
||||
List<UserAddress> userAddressList = userAddressService.list(queryWrapper);
|
||||
List<UserAddressVo> result = new ArrayList<>();
|
||||
for (UserAddress userAddress : userAddressList) {
|
||||
UserAddressVo vo = new UserAddressVo();
|
||||
BeanUtil.copyProperties(userAddress, vo);
|
||||
vo = userAddressService.getAddressName(vo, userAddress.getRegionCode());
|
||||
result.add(vo);
|
||||
}
|
||||
return R.ok().put("list", result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.common.entity.MyUserEntity;
|
||||
import com.peanut.modules.common.entity.UserCertificate;
|
||||
import com.peanut.modules.common.service.UserCertificateService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户证书
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonUserCertificate")
|
||||
@RequestMapping("common/userCertificate")
|
||||
public class UserCertificateController {
|
||||
|
||||
@Autowired
|
||||
private UserCertificateService userCertificateService;
|
||||
|
||||
//获取证书列表
|
||||
@RequestMapping("/getUserCertificateList")
|
||||
public R getUserCertificateList(@RequestBody Map<String,Object> params) {
|
||||
LambdaQueryWrapper<UserCertificate> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(UserCertificate::getUserId, ShiroUtils.getUId());
|
||||
if (StringUtils.isNotEmpty(params.get("type").toString())){
|
||||
wrapper.eq(UserCertificate::getType, params.get("type"));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("courseId").toString())){
|
||||
wrapper.eq(UserCertificate::getCourseId, params.get("courseId"));
|
||||
}
|
||||
return R.ok().put("certificateList",userCertificateService.list(wrapper));
|
||||
}
|
||||
|
||||
//生成证书(管理员)
|
||||
@RequestMapping("/generateCertificateAdmin")
|
||||
public R generateCertificateAdmin(@RequestBody Map<String,Object> params) {
|
||||
if (StringUtils.isBlank(params.get("type").toString())||StringUtils.isBlank(params.get("certificateNo").toString())||
|
||||
StringUtils.isBlank(params.get("iconUrl").toString())||StringUtils.isBlank(params.get("realName").toString())||
|
||||
StringUtils.isBlank(params.get("description").toString())||StringUtils.isBlank(params.get("edes").toString())||
|
||||
StringUtils.isBlank(params.get("endYear").toString())|| StringUtils.isBlank(params.get("endMonth").toString())||
|
||||
StringUtils.isBlank(params.get("endDay").toString())){
|
||||
return R.error("数据不能为空");
|
||||
}
|
||||
try {
|
||||
ImageIO.read(new URL(params.get("iconUrl").toString()));
|
||||
}catch (Exception e) {
|
||||
return R.error("照片链接错误");
|
||||
}
|
||||
String type = params.get("type").toString();
|
||||
String certificateNo = params.get("certificateNo").toString();
|
||||
String iconUrl = params.get("iconUrl").toString();
|
||||
String realName = params.get("realName").toString();
|
||||
String description = params.get("description").toString();
|
||||
String edescription = params.get("edes").toString();
|
||||
String endYear = params.get("endYear").toString();
|
||||
String endMonth = params.get("endMonth").toString();
|
||||
String endDay = params.get("endDay").toString();
|
||||
String[] des = description.split(",");
|
||||
String[] edes = edescription.split(",");
|
||||
String url = userCertificateService.generateCertificate(type,certificateNo,iconUrl,realName, des, edes, endYear,endMonth,endDay);
|
||||
return R.ok().put("url",url);
|
||||
}
|
||||
|
||||
//证书列表
|
||||
@RequestMapping("/getCertificateList")
|
||||
public R getCertificateList(@RequestBody Map<String,Object> params) {
|
||||
MPJLambdaWrapper<UserCertificate> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.leftJoin(MyUserEntity.class,MyUserEntity::getId,UserCertificate::getUserId);
|
||||
wrapper.selectAll(UserCertificate.class);
|
||||
wrapper.select(MyUserEntity::getName,MyUserEntity::getNickname,MyUserEntity::getTel,MyUserEntity::getEmail);
|
||||
if (StringUtils.isNotBlank(params.get("userWords").toString())){
|
||||
wrapper.and(t->t.like(MyUserEntity::getName,params.get("userWords")).or().like(MyUserEntity::getNickname,params.get("userWords"))
|
||||
.or().like(MyUserEntity::getEmail,params.get("userWords")).or().like(MyUserEntity::getTel,params.get("userWords")));
|
||||
}
|
||||
if (StringUtils.isNotBlank(params.get("title").toString())){
|
||||
wrapper.like(UserCertificate::getTitle,params.get("title"));
|
||||
}
|
||||
if (StringUtils.isNotBlank(params.get("certificateNo").toString())){
|
||||
wrapper.like(UserCertificate::getCertificateNo,params.get("certificateNo"));
|
||||
}
|
||||
wrapper.orderByDesc(UserCertificate::getCreateTime);
|
||||
Page<UserCertificate> page = userCertificateService.page(new Page<>(
|
||||
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
|
||||
return R.ok().put("certificate",page);
|
||||
}
|
||||
|
||||
@RequestMapping("/getCertificateById")
|
||||
public R getCertificateById(@RequestBody Map<String,Object> params) {
|
||||
UserCertificate userCertificate = userCertificateService.getById(params.get("id").toString());
|
||||
return R.ok().put("userCertificate",userCertificate);
|
||||
}
|
||||
|
||||
@RequestMapping("/addCertificate")
|
||||
public R addCertificate(@RequestBody UserCertificate userCertificate) {
|
||||
userCertificateService.save(userCertificate);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/updateCertificate")
|
||||
public R updateCertificate(@RequestBody UserCertificate userCertificate) {
|
||||
userCertificateService.updateById(userCertificate);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/delCertificate")
|
||||
public R delCertificate(@RequestBody Map<String,Object> params) {
|
||||
userCertificateService.removeById(params.get("id").toString());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.common.entity.UserContribution;
|
||||
import com.peanut.modules.master.service.UserContributionService;
|
||||
import com.peanut.modules.sys.entity.SysDictDataEntity;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 湖分
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonUserContribution")
|
||||
@RequestMapping("common/userContribution")
|
||||
public class UserContributionController {
|
||||
|
||||
@Autowired
|
||||
private UserContributionService contributionService;
|
||||
|
||||
//获取我的湖分列表
|
||||
@RequestMapping("/getUserContribution")
|
||||
public R getUserContribution(){
|
||||
Integer userId = ShiroUtils.getUId();
|
||||
//各分类总分
|
||||
MPJLambdaWrapper<UserContribution> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.leftJoin(SysDictDataEntity.class,
|
||||
SysDictDataEntity::getDictType,UserContribution::getType);
|
||||
wrapper.eq(SysDictDataEntity::getDictLabel,"userContributionLabel");
|
||||
wrapper.eq("user_id",userId);
|
||||
wrapper.select("type");
|
||||
wrapper.select("sum(score) as score");
|
||||
wrapper.select(SysDictDataEntity::getDictValue);
|
||||
wrapper.groupBy("type");
|
||||
List contributions = contributionService.listMaps(wrapper);
|
||||
//统计总分
|
||||
MPJLambdaWrapper totalWrapper = new MPJLambdaWrapper();
|
||||
totalWrapper.eq("user_id",userId);
|
||||
totalWrapper.select("sum(score) as score");
|
||||
Map map = contributionService.getMap(totalWrapper);
|
||||
return R.ok().put("list",contributions).put("total",map==null?0:map.get("score"));
|
||||
}
|
||||
|
||||
//分类下湖分明细
|
||||
@RequestMapping("/getUserContributionByType")
|
||||
public R getUserContributionByType(@RequestBody Map<String,Object> params){
|
||||
LambdaQueryWrapper<UserContribution> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(UserContribution::getUserId,ShiroUtils.getUId());
|
||||
wrapper.eq(UserContribution::getType,params.get("type"));
|
||||
wrapper.orderByDesc(UserContribution::getCreateTime);
|
||||
Page<UserContribution> contributions = contributionService.page(new Page<>(
|
||||
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
|
||||
return R.ok().put("list",contributions);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,434 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.*;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.*;
|
||||
import com.peanut.modules.sys.service.SysUserTokenService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
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 java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 用户登陆注册验证码
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonUser")
|
||||
@RequestMapping("common/user")
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private MyUserService userService;
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
@Autowired
|
||||
private SysUserTokenService sysUserTokenService;
|
||||
@Autowired
|
||||
private UserVipService userVipService;
|
||||
@Autowired
|
||||
private UserCourseVideoLogService userCourseVideoLogService;
|
||||
@Autowired
|
||||
private UserCertificateService userCertificateService;
|
||||
@Autowired
|
||||
private UserContributionService userContributionService;
|
||||
@Autowired
|
||||
private UserInviteRegisterService inviteRegisterService;
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
/**
|
||||
* 常规注册 发短信验证码
|
||||
*/
|
||||
@RequestMapping("/sms/sendcode")
|
||||
public R registerSms(@RequestParam("phone") String phone, @RequestParam(required = false) String areaCode) throws Exception {
|
||||
int areacode=0;
|
||||
if(areaCode==null||areaCode.equals("")){
|
||||
areacode=0;
|
||||
}else{
|
||||
areacode = Integer.valueOf(areaCode);
|
||||
}
|
||||
//验证一分钟内是否已经发过
|
||||
String redisCode = redisTemplate.opsForValue().get("RegistCode" + phone);
|
||||
if (!StringUtils.isEmpty(redisCode)) {
|
||||
long l = Long.parseLong(redisCode.split("_")[1]);
|
||||
if (System.currentTimeMillis() - l < 60000) {
|
||||
//60s 内不能再发
|
||||
return R.error(500,"短信验证码频率过高,请稍后再试!");
|
||||
}
|
||||
}
|
||||
//生成随机六位数
|
||||
Random random = new Random();
|
||||
String i = random.nextInt(999999) + "";
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int j = 0; j < 6 - i.length(); j++) {
|
||||
sb.append("0");
|
||||
}
|
||||
i = sb.toString() + i;
|
||||
String code = i + "_"+System.currentTimeMillis();
|
||||
//redis 缓存验证码
|
||||
redisTemplate.opsForValue().set("RegistCode"+phone,code,5, TimeUnit.MINUTES);
|
||||
//发送
|
||||
return userService.sendCodeForRegister(phone,code,areacode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 常规注册 发送邮箱验证码
|
||||
*/
|
||||
@RequestMapping("/getMailCaptcha")
|
||||
public R getMailCaptcha(String email){
|
||||
//验证一分钟内是否已经发过
|
||||
String redisCode = redisTemplate.opsForValue().get("RegistCode" + email);
|
||||
if (!StringUtils.isEmpty(redisCode)) {
|
||||
long l = Long.parseLong(redisCode.split("_")[1]);
|
||||
if (System.currentTimeMillis() - l < 60000) {
|
||||
//60s 内不能再发
|
||||
return R.error(500,"验证码频率过高,请稍后再试!");
|
||||
}
|
||||
}
|
||||
//生成随机六位数
|
||||
Random random = new Random();
|
||||
String code = random.nextInt(999999) + "";
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int j = 0; j < 6 - code.length(); j++) {
|
||||
sb.append("0");
|
||||
}
|
||||
code = sb.toString() + code;
|
||||
String timeCode = code + "_"+System.currentTimeMillis();
|
||||
//redis 缓存验证码
|
||||
redisTemplate.opsForValue().set("RegistCode"+email,timeCode,5, TimeUnit.MINUTES);
|
||||
//发送
|
||||
return MailUtil.sendMail("疯子读书邮箱验证码",code,email);
|
||||
}
|
||||
|
||||
@RequestMapping("/getUserInfo")
|
||||
public R getUserInfo(){
|
||||
int uid = ShiroUtils.getUId();
|
||||
MyUserEntity userEntity = userService.getById(uid);
|
||||
List<UserVip> userVips = userVipService.list(new LambdaQueryWrapper<UserVip>()
|
||||
.eq(UserVip::getUserId, uid)
|
||||
.eq(UserVip::getState,0));
|
||||
userEntity.setUserVips(userVips);
|
||||
Map<String,Object> total = userCourseVideoLogService.getMap(new MPJLambdaWrapper<UserCourseVideoLog>()
|
||||
.eq(UserCourseVideoLog::getUserId,userEntity.getId())
|
||||
.selectSum(UserCourseVideoLog::getDuration));
|
||||
Map<String,Object> today = userCourseVideoLogService.getMap(new MPJLambdaWrapper<UserCourseVideoLog>()
|
||||
.eq(UserCourseVideoLog::getUserId,userEntity.getId())
|
||||
.apply("DATE_FORMAT(create_time,'%Y-%m-%d') = CURRENT_DATE")
|
||||
.selectSum(UserCourseVideoLog::getDuration));
|
||||
BigDecimal totalWatch = new BigDecimal(total==null?"0":total.get("duration").toString()).divide(new BigDecimal(3600),0, RoundingMode.DOWN);
|
||||
BigDecimal todayWatch = new BigDecimal(today==null?"0":today.get("duration").toString()).divide(new BigDecimal(60),0,RoundingMode.DOWN);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
Long zhongyi = userCertificateService.count(new LambdaQueryWrapper<UserCertificate>()
|
||||
.eq(UserCertificate::getUserId,userEntity.getId()).eq(UserCertificate::getLabelId,13));
|
||||
if (zhongyi>0){
|
||||
sb.append("国际中医师");
|
||||
}
|
||||
Long zhenjiu = userCertificateService.count(new LambdaQueryWrapper<UserCertificate>()
|
||||
.eq(UserCertificate::getUserId,userEntity.getId()).eq(UserCertificate::getLabelId,19));
|
||||
if (zhenjiu>0){
|
||||
if (!sb.isEmpty()){
|
||||
sb.append("、");
|
||||
}
|
||||
sb.append("国际针灸师");
|
||||
}
|
||||
Map<String,Object> con = userContributionService.getMap(new MPJLambdaWrapper<UserContribution>()
|
||||
.eq(UserContribution::getUserId,userEntity.getId())
|
||||
.selectSum(UserContribution::getScore));
|
||||
if (con!=null){
|
||||
double score = Double.valueOf(con.get("score").toString());
|
||||
if (score>=15&&!sb.isEmpty()){
|
||||
sb.append("、");
|
||||
}
|
||||
if (score>=500){
|
||||
sb.append("七星湖粉");
|
||||
}else if (score>=300){
|
||||
sb.append("六星湖粉");
|
||||
}else if (score>=150){
|
||||
sb.append("五星湖粉");
|
||||
}else if (score>=135){
|
||||
sb.append("四星半星湖粉");
|
||||
}else if (score>=120){
|
||||
sb.append("四星湖粉");
|
||||
}else if (score>=105){
|
||||
sb.append("三星半湖粉");
|
||||
}else if (score>=90){
|
||||
sb.append("三星湖粉");
|
||||
}else if (score>=75){
|
||||
sb.append("二星半湖粉");
|
||||
}else if (score>=60){
|
||||
sb.append("二星湖粉");
|
||||
}else if (score>=45){
|
||||
sb.append("一星半湖粉");
|
||||
}else if (score>=30){
|
||||
sb.append("一星湖粉");
|
||||
}else if (score>=15){
|
||||
sb.append("半星湖粉");
|
||||
}
|
||||
}
|
||||
return R.ok().put("result",userEntity)
|
||||
.put("totalWatch","累计学习"+totalWatch+"小时")
|
||||
.put("todayWatch","今日学习"+todayWatch+"分钟")
|
||||
.put("des",sb.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定电话号
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/updateUserTel")
|
||||
public R updateUserTel(@RequestBody Map<String,Object> map){
|
||||
String phone = map.get("phone").toString();
|
||||
String code = map.get("code").toString();
|
||||
Integer id = Integer.valueOf(map.get("id").toString());
|
||||
//查询是否存在当前手机号
|
||||
LambdaQueryWrapper<MyUserEntity> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(MyUserEntity::getTel,phone);
|
||||
MyUserEntity userEntity = userService.getOne(wrapper);
|
||||
if (userEntity == null) {
|
||||
String redisCode = redisTemplate.opsForValue().get("RegistCode"+phone);
|
||||
if(StringUtils.isEmpty(redisCode)){
|
||||
return R.error("验证码已过期,请重试");
|
||||
}
|
||||
String lcode = redisCode.split("_")[0];
|
||||
if (!lcode.equals(code)) {
|
||||
return R.error("短信验证码不符!");
|
||||
}
|
||||
MyUserEntity userInfo = userService.getById(id);
|
||||
userInfo.setTel(phone);
|
||||
userService.updateById(userInfo);
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error("手机号已被绑定!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定邮箱
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/updateUserEmail")
|
||||
public R updateUserEmail(@RequestBody Map<String,Object> map){
|
||||
String email = map.get("email").toString();
|
||||
String code = map.get("code").toString();
|
||||
Integer id = Integer.valueOf(map.get("id").toString());
|
||||
//查询是否存在当前邮箱
|
||||
LambdaQueryWrapper<MyUserEntity> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(MyUserEntity::getEmail,email);
|
||||
MyUserEntity userEntity = userService.getOne(wrapper);
|
||||
if (userEntity == null) {
|
||||
String redisCode = redisTemplate.opsForValue().get("RegistCode"+email);
|
||||
if(StringUtils.isEmpty(redisCode)){
|
||||
return R.error("验证码已过期,请重试");
|
||||
}
|
||||
String lcode = redisCode.split("_")[0];
|
||||
if (!lcode.equals(code)) {
|
||||
return R.error("验证码不符!");
|
||||
}
|
||||
MyUserEntity userInfo = userService.getById(id);
|
||||
userInfo.setEmail(email);
|
||||
userService.updateById(userInfo);
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error("邮箱已被绑定!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@RequestMapping("/updateUser")
|
||||
public R updateUser(@RequestBody MyUserEntity userEntity){
|
||||
userService.updateById(userEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码注册或登录
|
||||
*/
|
||||
@RequestMapping("/registerOrLogin")
|
||||
@Transactional
|
||||
public R register(String tel, String code,String inviteCode) {
|
||||
String redisCode = redisTemplate.opsForValue().get("RegistCode" + tel);
|
||||
// System.out.println(redisCode);
|
||||
if (StringUtils.isEmpty(redisCode)){
|
||||
return R.error(500,"验证码已过期,请重试");
|
||||
}
|
||||
String lcode = redisCode.split("_")[0];
|
||||
if (!lcode.equals(code)) {
|
||||
return R.error(500,"验证码不符!");
|
||||
}
|
||||
//校验邀请码
|
||||
MyUserEntity inviteUser = null;
|
||||
if (!StringUtils.isEmpty(inviteCode)) {
|
||||
inviteUser = userService.getOne(new LambdaQueryWrapper<MyUserEntity>()
|
||||
.eq(MyUserEntity::getInviteCode, inviteCode));
|
||||
if (inviteUser == null) {
|
||||
return R.error("邀请码有误");
|
||||
}
|
||||
}
|
||||
//查询是否存在当前用户
|
||||
LambdaQueryWrapper<MyUserEntity> wrapper = new LambdaQueryWrapper();
|
||||
if (tel.contains("@")){
|
||||
wrapper.eq(MyUserEntity::getEmail,tel);
|
||||
}else {
|
||||
wrapper.eq(MyUserEntity::getTel,tel);
|
||||
}
|
||||
MyUserEntity userEntity = userService.getOne(wrapper);
|
||||
if (userEntity == null) {
|
||||
// 用户不存在则创建用户 注册成功
|
||||
MyUserEntity myUserEntity = new MyUserEntity();
|
||||
if (tel.contains("@")){
|
||||
myUserEntity.setEmail(tel);
|
||||
}else {
|
||||
myUserEntity.setTel(tel);
|
||||
}
|
||||
//设置注册来源
|
||||
HttpServletRequest request = HttpContextUtil.getHttpServletRequest();
|
||||
String appType = request.getHeader("appType")==null?"":request.getHeader("appType");
|
||||
int come = 0;
|
||||
if ("medical".equals(appType)){
|
||||
come = 2;
|
||||
}else if ("sociology".equals(appType)){
|
||||
come = 1;
|
||||
}else if ("psyche".equals(appType)){
|
||||
come = 3;
|
||||
}else if ("taihumed".equals(appType)){
|
||||
come = 4;
|
||||
}
|
||||
myUserEntity.setCome(come);
|
||||
myUserEntity.setCreateCity(IPUtils.getCityByIp(IPUtils.getIpAddr(request)));
|
||||
userService.save(myUserEntity);
|
||||
//添加邀请记录
|
||||
if (!StringUtils.isEmpty(inviteCode)){
|
||||
myUserEntity.setInviteCode(inviteCode);
|
||||
userService.updateById(myUserEntity);
|
||||
UserInviteRegister inviteRegister = new UserInviteRegister();
|
||||
inviteRegister.setUserId(inviteUser.getId());
|
||||
inviteRegister.setInvitedUserId(myUserEntity.getId());
|
||||
inviteRegisterService.save(inviteRegister);
|
||||
inviteRegisterService.checkInviteRegisterCount(inviteUser.getId());
|
||||
}
|
||||
R r = sysUserTokenService.createToken(myUserEntity.getId());
|
||||
return R.ok("注册成功").put("userInfo",myUserEntity).put("token",r);
|
||||
}else {
|
||||
R r = sysUserTokenService.createToken(userEntity.getId());
|
||||
return R.ok("登录成功!").put("userInfo",userEntity).put("token",r);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 账号密码登录
|
||||
*/
|
||||
@RequestMapping("/login")
|
||||
public R login(@RequestParam("phone") String phone,
|
||||
@RequestParam("password") String password) {
|
||||
LambdaQueryWrapper<MyUserEntity> wrapper = new LambdaQueryWrapper();
|
||||
if (phone.contains("@")) {
|
||||
wrapper.eq(MyUserEntity::getEmail,phone);
|
||||
}else {
|
||||
wrapper.eq(MyUserEntity::getTel,phone);
|
||||
}
|
||||
//防止多账号报错
|
||||
MyUserEntity userEntity = userService.getOne(wrapper);
|
||||
if (userEntity == null) {
|
||||
return R.error(500,"用户不存在!");
|
||||
}else {
|
||||
if (userEntity.getPassword() == null|| userEntity.getPassword().equals("")) {
|
||||
return R.error(500,"当前未设置密码,请使用验证码登录!");
|
||||
}else {
|
||||
if (MD5Utils.getSaltverifyMD5(password,userEntity.getPassword())){
|
||||
R r = sysUserTokenService.createToken(userEntity.getId());
|
||||
return R.ok("登陆成功!").put("userInfo",userEntity).put("token",r);
|
||||
}else {
|
||||
return R.error(500,"密码不正确,请重试!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置密码带验证
|
||||
*/
|
||||
@RequestMapping("/setPasswordByCode")
|
||||
public R setPassword(@RequestParam("phone") String phone,
|
||||
@RequestParam("password") String password,
|
||||
@RequestParam("code") String code) {
|
||||
String redisCode = redisTemplate.opsForValue().get("RegistCode" + phone);
|
||||
if (StringUtils.isEmpty(redisCode)){
|
||||
return R.error(500,"验证码已过期,请重试");
|
||||
}
|
||||
String lcode = redisCode.split("_")[0];
|
||||
if (!lcode.equals(code)) {
|
||||
return R.error(500,"验证码不符!");
|
||||
}
|
||||
//查询是否存在当前用户
|
||||
LambdaQueryWrapper<MyUserEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
if (phone.contains("@")){
|
||||
wrapper.eq(MyUserEntity::getEmail, phone);
|
||||
}else {
|
||||
wrapper.eq(MyUserEntity::getTel, phone);
|
||||
}
|
||||
MyUserEntity userEntity = userService.getOne(wrapper);
|
||||
if (userEntity == null) {
|
||||
return R.error(500,"当前用户不存在!");
|
||||
}
|
||||
String saltMD5 = MD5Utils.getSaltMD5(password);
|
||||
userEntity.setPassword(saltMD5);
|
||||
userService.updateById(userEntity);
|
||||
return R.ok("成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置密码不验证
|
||||
*/
|
||||
@RequestMapping("/setPasswordById")
|
||||
public R setPassword(@RequestParam("id") String id,@RequestParam("password") String password) {
|
||||
MyUserEntity userEntity = userService.getById(id);
|
||||
if (userEntity == null) {
|
||||
return R.error(500,"当前用户不存在!");
|
||||
}
|
||||
String saltMD5 = MD5Utils.getSaltMD5(password);
|
||||
userEntity.setPassword(saltMD5);
|
||||
userService.updateById(userEntity);
|
||||
return R.ok("成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成迁移验证码
|
||||
*/
|
||||
@RequestMapping("/getMigrationCode")
|
||||
public R getMigrationCode() {
|
||||
//生成随机六位数
|
||||
Random random = new Random();
|
||||
int i = random.nextInt(999999);
|
||||
String code = String.format("%02d", i);
|
||||
MyUserEntity userEntity = userService.getById(ShiroUtils.getUId());
|
||||
userEntity.setMigrationCode(code);
|
||||
userEntity.setRemark("数据已迁移");
|
||||
userService.updateById(userEntity);
|
||||
return R.ok().put("migrationCode",code);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.common.entity.UserCourseVideoLog;
|
||||
import com.peanut.modules.common.service.UserCourseVideoLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 用户观看记录
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonUserCourseVideoLog")
|
||||
@RequestMapping("common/userCourseVideoLog")
|
||||
public class UserCourseVideoLogController {
|
||||
|
||||
@Autowired
|
||||
private UserCourseVideoLogService userCourseVideoLogService;
|
||||
|
||||
//添加记录
|
||||
@RequestMapping("/addUserCourseVideoLog")
|
||||
public R addUserCourseVideoLog(@RequestBody UserCourseVideoLog userCourseVideoLog) {
|
||||
userCourseVideoLog.setUserId(ShiroUtils.getUId());
|
||||
userCourseVideoLogService.save(userCourseVideoLog);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.MyUserService;
|
||||
import com.peanut.modules.common.service.UserInviteCourseService;
|
||||
import com.peanut.modules.common.service.UserInviteRegisterService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户邀请管理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonUserInvite")
|
||||
@RequestMapping("common/userInvite")
|
||||
public class UserInviteController {
|
||||
|
||||
@Autowired
|
||||
private UserInviteRegisterService inviteRegisterService;
|
||||
@Autowired
|
||||
private UserInviteCourseService inviteCourseService;
|
||||
@Autowired
|
||||
private MyUserService myUserService;
|
||||
|
||||
|
||||
//获取邀请注册记录列表
|
||||
@RequestMapping("/getInviteRegisterList")
|
||||
public R getInviteRegisterList(@RequestBody Map<String,Object> params) {
|
||||
MPJLambdaWrapper<UserInviteRegister> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.leftJoin(MyUserEntity.class,MyUserEntity::getId,UserInviteRegister::getUserId);
|
||||
wrapper.leftJoin(MyUserEntity.class,MyUserEntity::getId,UserInviteRegister::getInvitedUserId);
|
||||
wrapper.select("t.create_time");
|
||||
wrapper.select("t1.name,t1.nickname,t1.tel,t1.email");
|
||||
wrapper.select("t2.name invitedName,t2.nickname invitedNickname,t2.tel invitedTel,t2.email invitedEmail");
|
||||
wrapper.orderByDesc(UserInviteRegister::getId);
|
||||
if (StringUtils.isNotBlank(params.get("userInfo").toString())){
|
||||
wrapper.and(t->t.like(MyUserEntity::getName,params.get("userInfo")).or().like(MyUserEntity::getNickname,params.get("userInfo"))
|
||||
.or().like(MyUserEntity::getTel,params.get("userInfo")).or().like(MyUserEntity::getEmail,params.get("userInfo")));
|
||||
}
|
||||
if (StringUtils.isNotBlank(params.get("invitedUserInfo").toString())){
|
||||
wrapper.and(t->t.like(MyUserEntity::getName,params.get("invitedUserInfo")).or().like(MyUserEntity::getNickname,params.get("invitedUserInfo"))
|
||||
.or().like(MyUserEntity::getTel,params.get("invitedUserInfo")).or().like(MyUserEntity::getEmail,params.get("invitedUserInfo")));
|
||||
}
|
||||
Page<Map<String,Object>> page = inviteRegisterService.pageMaps(new Page<>((int)params.get("page"), (int)params.get("limit")), wrapper);
|
||||
return R.ok().put("result", page);
|
||||
}
|
||||
|
||||
//获取邀请购买课程记录列表
|
||||
@RequestMapping("/getInviteCourseList")
|
||||
public R getInviteCourseList(@RequestBody Map<String,Object> params) {
|
||||
MPJLambdaWrapper<UserInviteCourse> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.leftJoin(MyUserEntity.class,MyUserEntity::getId,UserInviteCourse::getUserId);
|
||||
wrapper.leftJoin(MyUserEntity.class,MyUserEntity::getId,UserInviteCourse::getInvitedUserId);
|
||||
wrapper.leftJoin(BuyOrder.class,BuyOrder::getOrderId,UserInviteCourse::getOrderId);
|
||||
wrapper.leftJoin(CourseEntity.class,CourseEntity::getId,UserInviteCourse::getCourseId);
|
||||
wrapper.leftJoin(CourseCatalogueEntity.class,CourseCatalogueEntity::getId,UserInviteCourse::getCatalogueId);
|
||||
wrapper.select("t.create_time");
|
||||
wrapper.select("t1.name,t1.nickname,t1.tel,t1.email");
|
||||
wrapper.select("t2.name invitedName,t2.nickname invitedNickname,t2.tel invitedTel,t2.email invitedEmail");
|
||||
wrapper.select("t3.order_sn,t4.title,t5.title catalogueTitle");
|
||||
wrapper.orderByDesc(UserInviteCourse::getId);
|
||||
if (StringUtils.isNotBlank(params.get("userInfo").toString())){
|
||||
wrapper.and(t->t.like(MyUserEntity::getName,params.get("userInfo")).or().like(MyUserEntity::getNickname,params.get("userInfo"))
|
||||
.or().like(MyUserEntity::getTel,params.get("userInfo")).or().like(MyUserEntity::getEmail,params.get("userInfo")));
|
||||
}
|
||||
if (StringUtils.isNotBlank(params.get("invitedUserInfo").toString())){
|
||||
wrapper.and(t->t.like(MyUserEntity::getName,params.get("invitedUserInfo")).or().like(MyUserEntity::getNickname,params.get("invitedUserInfo"))
|
||||
.or().like(MyUserEntity::getTel,params.get("invitedUserInfo")).or().like(MyUserEntity::getEmail,params.get("invitedUserInfo")));
|
||||
}
|
||||
if (StringUtils.isNotBlank(params.get("courseName").toString())){
|
||||
wrapper.like(CourseEntity::getTitle,params.get("courseName"));
|
||||
}
|
||||
Page<Map<String,Object>> page = inviteCourseService.pageMaps(new Page<>((int)params.get("page"), (int)params.get("limit")), wrapper);
|
||||
return R.ok().put("result", page);
|
||||
}
|
||||
|
||||
//生成邀请码
|
||||
@RequestMapping("/generateInviteCode")
|
||||
public R generateInviteCode() {
|
||||
MyUserEntity userEntity = myUserService.getById(ShiroUtils.getUId());
|
||||
String code = inviteRegisterService.generateInviteCode();
|
||||
userEntity.setInviteCode(code);
|
||||
myUserService.updateById(userEntity);
|
||||
return R.ok();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,522 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.HttpContextUtil;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.config.Constants;
|
||||
import com.peanut.config.DelayQueueConfig;
|
||||
import com.peanut.modules.book.service.TransactionDetailsService;
|
||||
import com.peanut.modules.common.dao.MyUserDao;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.*;
|
||||
import com.peanut.modules.master.service.CourseCatalogueService;
|
||||
import com.peanut.modules.master.service.CourseService;
|
||||
import com.peanut.modules.pay.weChatPay.dto.WechatPaymentInfo;
|
||||
import com.peanut.modules.pay.weChatPay.service.WxpayService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.MessagePostProcessor;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 超V管理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonUserVip")
|
||||
@RequestMapping("common/userVip")
|
||||
public class UserVipController {
|
||||
|
||||
@Autowired
|
||||
private UserVipService userVipService;
|
||||
@Autowired
|
||||
private BuyOrderService buyOrderService;
|
||||
@Autowired
|
||||
private WxpayService wxpayService;
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
@Autowired
|
||||
private MyUserDao myUserDao;
|
||||
@Autowired
|
||||
private VipBuyConfigService vipBuyConfigService;
|
||||
@Autowired
|
||||
private TransactionDetailsService transactionDetailsService;
|
||||
@Autowired
|
||||
private JfTransactionDetailsService jfTransactionDetailsService;
|
||||
@Autowired
|
||||
private CourseCatalogueService courseCatalogueService;
|
||||
|
||||
|
||||
//获取用户类型
|
||||
@RequestMapping("/getUserVipType")
|
||||
public R getUserVipType() {
|
||||
List<Map<String,Object>> resList = new ArrayList();
|
||||
//根部不同平台返回不同列表
|
||||
HttpServletRequest request = HttpContextUtil.getHttpServletRequest();
|
||||
String appType = request.getHeader("appType")==null?"":request.getHeader("appType");
|
||||
if (!"psyche".equals(appType)){
|
||||
List<UserVip> l4 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,4).orderByDesc(UserVip::getEndTime));
|
||||
List<UserVip> l9 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,9).orderByDesc(UserVip::getEndTime));
|
||||
List<UserVip> l5 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,5).orderByDesc(UserVip::getEndTime));
|
||||
List<UserVip> l6 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,6).orderByDesc(UserVip::getEndTime));
|
||||
if (l4.size()>0&&l9.size()>0&&l5.size()>0&&l6.size()>0){
|
||||
Date t4 = l4.get(0).getEndTime();
|
||||
Date t9 = l9.get(0).getEndTime();
|
||||
Date t5 = l5.get(0).getEndTime();
|
||||
Date t6 = l6.get(0).getEndTime();
|
||||
if (t4.getTime()==t9.getTime()&&t9.getTime()==t5.getTime()&&t5.getTime()==t6.getTime()){
|
||||
Map map = new HashMap();
|
||||
map.put("type",1);
|
||||
map.put("endTime",t4);
|
||||
resList.add(map);
|
||||
}else {
|
||||
List<Map<String,Object>> tempList = new ArrayList();
|
||||
Map map4 = new HashMap();
|
||||
map4.put("type",4);
|
||||
map4.put("endTime",t4);
|
||||
tempList.add(map4);
|
||||
Map map9 = new HashMap();
|
||||
map9.put("type",9);
|
||||
map9.put("endTime",t9);
|
||||
tempList.add(map9);
|
||||
Map map5 = new HashMap();
|
||||
map5.put("type",5);
|
||||
map5.put("endTime",t5);
|
||||
tempList.add(map5);
|
||||
Map map6 = new HashMap();
|
||||
map6.put("type",6);
|
||||
map6.put("endTime",t6);
|
||||
tempList.add(map6);
|
||||
tempList = tempList.stream().sorted((map1,map2)->{
|
||||
return Long.compare(((Date)map1.get("endTime")).getTime(),((Date)map2.get("endTime")).getTime());
|
||||
}).collect(Collectors.toList());
|
||||
resList.addAll(tempList);
|
||||
Map map1 = new HashMap();
|
||||
map1.put("type",1);
|
||||
map1.put("endTime",tempList.get(0).get("endTime"));
|
||||
resList.add(map1);
|
||||
}
|
||||
}else {
|
||||
if (l4.size()>0){
|
||||
Map map = new HashMap();
|
||||
map.put("type",4);
|
||||
map.put("endTime",l4.get(0).getEndTime());
|
||||
resList.add(map);
|
||||
}
|
||||
if (l5.size()>0){
|
||||
Map map = new HashMap();
|
||||
map.put("type",5);
|
||||
map.put("endTime",l5.get(0).getEndTime());
|
||||
resList.add(map);
|
||||
}
|
||||
if (l9.size()>0){
|
||||
Map map = new HashMap();
|
||||
map.put("type",9);
|
||||
map.put("endTime",l9.get(0).getEndTime());
|
||||
resList.add(map);
|
||||
}
|
||||
if (l6.size()>0){
|
||||
Map map = new HashMap();
|
||||
map.put("type",6);
|
||||
map.put("endTime",l6.get(0).getEndTime());
|
||||
resList.add(map);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
List<UserVip> l7 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,7).orderByDesc(UserVip::getEndTime));
|
||||
List<UserVip> l8 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,8).orderByDesc(UserVip::getEndTime));
|
||||
if (l7.size()>0&&l8.size()>0){
|
||||
Date t7 = l7.get(0).getEndTime();
|
||||
Date t8 = l8.get(0).getEndTime();
|
||||
if (t7.getTime()==t8.getTime()){
|
||||
Map map = new HashMap();
|
||||
map.put("type",2);
|
||||
map.put("endTime",t7);
|
||||
resList.add(map);
|
||||
}else {
|
||||
List<Map<String,Object>> tempList = new ArrayList();
|
||||
Map map7 = new HashMap();
|
||||
map7.put("type",7);
|
||||
map7.put("endTime",t7);
|
||||
tempList.add(map7);
|
||||
Map map8 = new HashMap();
|
||||
map8.put("type",8);
|
||||
map8.put("endTime",t8);
|
||||
tempList.add(map8);
|
||||
tempList = tempList.stream().sorted((map1,map2)->{
|
||||
return Long.compare(((Date)map1.get("endTime")).getTime(),((Date)map2.get("endTime")).getTime());
|
||||
}).collect(Collectors.toList());
|
||||
resList.addAll(tempList);
|
||||
Map map2 = new HashMap();
|
||||
map2.put("type",2);
|
||||
map2.put("endTime",tempList.get(0).get("endTime"));
|
||||
resList.add(map2);
|
||||
}
|
||||
}else {
|
||||
if (l7.size()>0){
|
||||
Map map = new HashMap();
|
||||
map.put("type",7);
|
||||
map.put("endTime",l7.get(0).getEndTime());
|
||||
resList.add(map);
|
||||
}
|
||||
if (l8.size()>0){
|
||||
Map map = new HashMap();
|
||||
map.put("type",8);
|
||||
map.put("endTime",l8.get(0).getEndTime());
|
||||
resList.add(map);
|
||||
}
|
||||
}
|
||||
resList = resList.stream().sorted((map1,map2)->{
|
||||
return Long.compare(((Date)map1.get("endTime")).getTime(),((Date)map2.get("endTime")).getTime());
|
||||
}).collect(Collectors.toList());
|
||||
return R.ok().put("list", resList);
|
||||
}
|
||||
|
||||
|
||||
//vip商品列表
|
||||
@RequestMapping("/getVipBuyConfigList")
|
||||
public R getVipBuyConfigList() {
|
||||
List<List> ll = new ArrayList<>();
|
||||
//根部不同平台返回不同列表
|
||||
HttpServletRequest request = HttpContextUtil.getHttpServletRequest();
|
||||
String appType = request.getHeader("appType")==null?"":request.getHeader("appType");
|
||||
if ("psyche".equals(appType)){
|
||||
ll.add(Arrays.asList(8,7));
|
||||
ll.add(Arrays.asList(2));
|
||||
}else {
|
||||
ll.add(Arrays.asList(1));
|
||||
ll.add(Arrays.asList(4));
|
||||
ll.add(Arrays.asList(9));
|
||||
ll.add(Arrays.asList(5));
|
||||
ll.add(Arrays.asList(6));
|
||||
ll.add(Arrays.asList(2));
|
||||
ll.add(Arrays.asList(7,8));
|
||||
}
|
||||
List<Map<String,Object>> resList = new ArrayList<>();
|
||||
for (List l : ll) {
|
||||
LambdaQueryWrapper<VipBuyConfigEntity> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.select(VipBuyConfigEntity::getType,VipBuyConfigEntity::getTitle);
|
||||
wrapper.and(r->r.eq(VipBuyConfigEntity::getDateType,0).or(f->f.eq(VipBuyConfigEntity::getDateType,1).lt(VipBuyConfigEntity::getStartTime,new Date()).gt(VipBuyConfigEntity::getEndTime,new Date())));
|
||||
wrapper.in(VipBuyConfigEntity::getType,l);
|
||||
if ("psyche".equals(appType)){
|
||||
wrapper.orderByDesc(VipBuyConfigEntity::getType);
|
||||
}
|
||||
wrapper.groupBy(VipBuyConfigEntity::getType);
|
||||
List<Map<String,Object>> list = vipBuyConfigService.listMaps(wrapper);
|
||||
for (Map<String,Object> map:list){
|
||||
Map originalPriceAndCourseCount = getOriginalPriceAndCourseCount(map.get("type").toString());
|
||||
map.put("originalPrice",originalPriceAndCourseCount.get("originalPrice"));//模块下课程一年原价
|
||||
map.put("courseCount",originalPriceAndCourseCount.get("courseCount"));//模块下课程数量
|
||||
map.put("tip",null);//提示到期
|
||||
map.put("vcbList",null);//vip商品列表
|
||||
map.put("yanqiList",null);//延期商品列表
|
||||
map.put("state",null);//有效状态
|
||||
boolean flag = false;
|
||||
if ("1".equals(map.get("type").toString())){
|
||||
List<UserVip> uv4 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,4).orderByDesc(UserVip::getEndTime));
|
||||
List<UserVip> uv9 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,9).orderByDesc(UserVip::getEndTime));
|
||||
List<UserVip> uv5 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,5).orderByDesc(UserVip::getEndTime));
|
||||
List<UserVip> uv6 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,6).orderByDesc(UserVip::getEndTime));
|
||||
if (uv4.size() > 0 && uv9.size() > 0 && uv5.size() > 0 && uv6.size() > 0){//办理过
|
||||
if (uv4.get(0).getState()==0&&uv9.get(0).getState()==0&&uv5.get(0).getState()==0&&uv6.get(0).getState()==0){
|
||||
long l4 = uv4.get(0).getEndTime().getTime();
|
||||
long l9 = uv9.get(0).getEndTime().getTime();
|
||||
long l5 = uv5.get(0).getEndTime().getTime();
|
||||
long l6 = uv6.get(0).getEndTime().getTime();
|
||||
List<Long> tempList = new ArrayList();
|
||||
tempList.add(l4);
|
||||
tempList.add(l9);
|
||||
tempList.add(l5);
|
||||
tempList.add(l6);
|
||||
tempList = tempList.stream().sorted((long1,long2)->{
|
||||
return Long.compare(long1,long2);
|
||||
}).collect(Collectors.toList());
|
||||
map.put("tip",(tempList.get(0)-new Date().getTime())/60/60/24/1000);
|
||||
map.put("state",0);
|
||||
}else {
|
||||
map.put("state",1);
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
}else if ("2".equals(map.get("type").toString())){
|
||||
List<UserVip> uv7 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,7).orderByDesc(UserVip::getEndTime));
|
||||
List<UserVip> uv8 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,8).orderByDesc(UserVip::getEndTime));
|
||||
if (uv7.size() > 0 && uv8.size() > 0){
|
||||
if (uv7.get(0).getState()==0&&uv8.get(0).getState()==0){
|
||||
if (uv7.get(0).getEndTime().getTime()<uv8.get(0).getEndTime().getTime()){
|
||||
map.put("tip",(uv7.get(0).getEndTime().getTime()-new Date().getTime())/60/60/24/1000);
|
||||
}else {
|
||||
map.put("tip",(uv8.get(0).getEndTime().getTime()-new Date().getTime())/60/60/24/1000);
|
||||
}
|
||||
map.put("state",0);
|
||||
}else {
|
||||
map.put("state",1);
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
}else {
|
||||
List<UserVip> userVips = userVipService.list(new LambdaQueryWrapper<UserVip>()
|
||||
.eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,map.get("type")).orderByDesc(UserVip::getEndTime));
|
||||
if (userVips.size()>0){
|
||||
if (userVips.get(0).getState()==0){
|
||||
map.put("tip",(userVips.get(0).getEndTime().getTime()-new Date().getTime())/60/60/24/1000);
|
||||
map.put("state",0);
|
||||
}else {
|
||||
map.put("state",1);
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if (flag){
|
||||
List<VipBuyConfigEntity> yanqiList = vipBuyConfigService.list(new LambdaQueryWrapper<VipBuyConfigEntity>()
|
||||
.and(r->r.eq(VipBuyConfigEntity::getDateType,0).or(f->f.eq(VipBuyConfigEntity::getDateType,1).lt(VipBuyConfigEntity::getStartTime,new Date()).gt(VipBuyConfigEntity::getEndTime,new Date())))
|
||||
.eq(VipBuyConfigEntity::getType,map.get("type")+"1"));
|
||||
map.put("yanqiList",yanqiList);
|
||||
}else {
|
||||
List<VipBuyConfigEntity> vcbList = vipBuyConfigService.list(new LambdaQueryWrapper<VipBuyConfigEntity>()
|
||||
.and(r->r.eq(VipBuyConfigEntity::getDateType,0).or(f->f.eq(VipBuyConfigEntity::getDateType,1).lt(VipBuyConfigEntity::getStartTime,new Date()).gt(VipBuyConfigEntity::getEndTime,new Date())))
|
||||
.eq(VipBuyConfigEntity::getType,map.get("type")));
|
||||
map.put("vcbList",vcbList);
|
||||
}
|
||||
}
|
||||
list = list.stream().sorted((map1,map2)->{
|
||||
return Long.compare((Long) (map1.get("tip")==null?0l:map1.get("tip")),(Long)(map2.get("tip")==null?0l:map2.get("tip")));
|
||||
}).collect(Collectors.toList());
|
||||
list = list.stream().sorted((map1,map2)->{
|
||||
return Long.compare((Long) (map1.get("vcbList")==null?0l:1l),(Long)(map2.get("vcbList")==null?0l:1l));
|
||||
}).collect(Collectors.toList());
|
||||
resList.addAll(list);
|
||||
}
|
||||
return R.ok().put("res", resList);
|
||||
}
|
||||
|
||||
//vip配置列表
|
||||
@RequestMapping("/vipBuyConfigList")
|
||||
public R vipBuyConfigList() {
|
||||
List<List> ll = new ArrayList<>();
|
||||
ll.add(Arrays.asList(1));
|
||||
ll.add(Arrays.asList(4));
|
||||
ll.add(Arrays.asList(9));
|
||||
ll.add(Arrays.asList(5));
|
||||
ll.add(Arrays.asList(6));
|
||||
ll.add(Arrays.asList(2));
|
||||
ll.add(Arrays.asList(7,8));
|
||||
List<Map<String,Object>> resList = new ArrayList<>();
|
||||
for (List l : ll) {
|
||||
LambdaQueryWrapper<VipBuyConfigEntity> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.select(VipBuyConfigEntity::getType,VipBuyConfigEntity::getTitle);
|
||||
wrapper.and(r->r.eq(VipBuyConfigEntity::getDateType,0).or(f->f.eq(VipBuyConfigEntity::getDateType,1).lt(VipBuyConfigEntity::getStartTime,new Date()).gt(VipBuyConfigEntity::getEndTime,new Date())));
|
||||
wrapper.in(VipBuyConfigEntity::getType,l);
|
||||
wrapper.groupBy(VipBuyConfigEntity::getType);
|
||||
List<Map<String,Object>> list = vipBuyConfigService.listMaps(wrapper);
|
||||
for (Map<String,Object> map:list){
|
||||
Map originalPriceAndCourseCount = getOriginalPriceAndCourseCount(map.get("type").toString());
|
||||
map.put("originalPrice",originalPriceAndCourseCount.get("originalPrice"));//模块下课程一年原价
|
||||
map.put("courseCount",originalPriceAndCourseCount.get("courseCount"));//模块下课程数量
|
||||
map.put("vcbList",null);//vip商品列表
|
||||
map.put("yanqiList",null);//延期商品列表
|
||||
List<VipBuyConfigEntity> yanqiList = vipBuyConfigService.list(new LambdaQueryWrapper<VipBuyConfigEntity>()
|
||||
.and(r->r.eq(VipBuyConfigEntity::getDateType,0).or(f->f.eq(VipBuyConfigEntity::getDateType,1).lt(VipBuyConfigEntity::getStartTime,new Date()).gt(VipBuyConfigEntity::getEndTime,new Date())))
|
||||
.eq(VipBuyConfigEntity::getType,map.get("type")+"1"));
|
||||
map.put("yanqiList",yanqiList);
|
||||
List<VipBuyConfigEntity> vcbList = vipBuyConfigService.list(new LambdaQueryWrapper<VipBuyConfigEntity>()
|
||||
.and(r->r.eq(VipBuyConfigEntity::getDateType,0).or(f->f.eq(VipBuyConfigEntity::getDateType,1).lt(VipBuyConfigEntity::getStartTime,new Date()).gt(VipBuyConfigEntity::getEndTime,new Date())))
|
||||
.eq(VipBuyConfigEntity::getType,map.get("type")));
|
||||
map.put("vcbList",vcbList);
|
||||
}
|
||||
resList.addAll(list);
|
||||
}
|
||||
return R.ok().put("res", resList);
|
||||
}
|
||||
|
||||
//是否是这门课的vip
|
||||
@RequestMapping("/ownCourseCatalogueByVip")
|
||||
public R ownCourseCatalogueByVip(@RequestBody Map<String,Object> params) {
|
||||
UserVip userVip = userVipService.ownCourseCatalogueByVip(Integer.parseInt(params.get("courseId").toString()));
|
||||
return R.ok().put("userVip", userVip);
|
||||
}
|
||||
|
||||
//当前课程属于什么会员
|
||||
@RequestMapping("/getCourseVipModule")
|
||||
public R getCourseVipModule(@RequestBody Map<String,Object> params) {
|
||||
return R.ok().put("list", userVipService.getCourseVipModule(Integer.parseInt(params.get("courseId").toString())));
|
||||
}
|
||||
|
||||
@RequestMapping("/getMyVipHistory")
|
||||
public R getMyVipHistory(String userId) {
|
||||
LambdaQueryWrapper<UserVip> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(UserVip::getUserId,userId);
|
||||
wrapper.orderByAsc(UserVip::getState);
|
||||
wrapper.orderByAsc(UserVip::getEndTime);
|
||||
List<UserVip> userVips = userVipService.list(wrapper);
|
||||
return R.ok().put("result", userVips);
|
||||
}
|
||||
|
||||
@RequestMapping("/placeVipOrder")
|
||||
@Transactional
|
||||
public R placeVipOrder(@RequestBody BuyOrder buyOrder){
|
||||
int uid = ShiroUtils.getUId();
|
||||
buyOrder.setOrderStatus("0");
|
||||
buyOrder.setOrderType("vip");
|
||||
String timeId = IdWorker.getTimeId().substring(0, 32);
|
||||
buyOrder.setOrderSn(timeId);
|
||||
buyOrder.setUserId(uid);
|
||||
buyOrderService.save(buyOrder);
|
||||
BigDecimal totalPrice = buyOrder.getRealMoney();
|
||||
if (Constants.PAYMENT_METHOD_VIRTUAL.equals(buyOrder.getPaymentMethod())) {
|
||||
buyOrder.setOrderStatus(Constants.ORDER_STATUS_TO_BE_SHIPPED);
|
||||
MyUserEntity user = myUserDao.selectById(buyOrder.getUserId());
|
||||
if (usePeanutCoin(user, totalPrice)&&useJfCoin(user,buyOrder.getJfDeduction())) {
|
||||
// 更新订单状态
|
||||
buyOrderService.updateOrderStatus(user.getId(), buyOrder.getOrderSn(), "2");
|
||||
//记录用户虚拟币消费
|
||||
if(totalPrice.compareTo(BigDecimal.ZERO)>0){
|
||||
transactionDetailsService.recordTransaction(buyOrder, user, totalPrice);
|
||||
}
|
||||
//记录用户积分消费情况
|
||||
if(buyOrder.getJfDeduction()!=null&&buyOrder.getJfDeduction().compareTo(BigDecimal.ZERO) > 0){
|
||||
jfTransactionDetailsService.recordJfTransaction(buyOrder, user, buyOrder.getJfDeduction());
|
||||
}
|
||||
//开通用户vip
|
||||
userVipService.openVipForUser(buyOrder);
|
||||
} else {
|
||||
rabbitTemplate.convertAndSend(
|
||||
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
|
||||
DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY,
|
||||
buyOrder.getOrderId(),
|
||||
messagePostProcessor()
|
||||
);
|
||||
return R.error(500, "余额不足!");
|
||||
}
|
||||
}
|
||||
//下单微信支付预付款订单
|
||||
if(Constants.PAYMENT_METHOD_WECHAT_PAY.equals(buyOrder.getPaymentMethod())){
|
||||
BuyOrder buyOrderEntity = buyOrderService.getBaseMapper().selectOne(new LambdaQueryWrapper<BuyOrder>().eq(BuyOrder::getOrderSn, timeId));
|
||||
WechatPaymentInfo paymentInfo = new WechatPaymentInfo();
|
||||
paymentInfo.setOrderSn(buyOrderEntity.getOrderSn());
|
||||
paymentInfo.setBuyOrderId(buyOrderEntity.getOrderId());
|
||||
paymentInfo.setTotalAmount(buyOrderEntity.getRealMoney());
|
||||
// paymentInfo.setAppName(buyOrder.getAppName());
|
||||
if (buyOrder.getCome()==2){
|
||||
paymentInfo.setAppName("wumen");
|
||||
} else if (buyOrder.getCome()==1) {
|
||||
paymentInfo.setAppName("zmzm");
|
||||
} else if (buyOrder.getCome()==3) {
|
||||
paymentInfo.setAppName("xlkj");
|
||||
} else if (buyOrder.getCome()==4) {
|
||||
paymentInfo.setAppName("thyy");
|
||||
}else {
|
||||
paymentInfo.setAppName(buyOrder.getAppName());
|
||||
}
|
||||
wxpayService.prepay(paymentInfo);
|
||||
}
|
||||
rabbitTemplate.convertAndSend(
|
||||
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
|
||||
DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY,
|
||||
buyOrder.getOrderId(),
|
||||
messagePostProcessor()
|
||||
);
|
||||
return R.ok().put("orderSn", timeId).put("money",buyOrder.getRealMoney());
|
||||
}
|
||||
|
||||
private boolean usePeanutCoin(MyUserEntity user, BigDecimal totalPrice) {
|
||||
if (user.getPeanutCoin().compareTo(totalPrice) >= 0) {
|
||||
if(totalPrice.compareTo(BigDecimal.ZERO)==0){//纯积分支付,虚拟币不用支付
|
||||
return true;
|
||||
}
|
||||
user.setPeanutCoin(user.getPeanutCoin().subtract(totalPrice));
|
||||
myUserDao.updateById(user);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean useJfCoin(MyUserEntity user,BigDecimal jf){
|
||||
if(jf==null){
|
||||
return true;
|
||||
}
|
||||
if(user.getJf().compareTo(jf)>=0){
|
||||
user.setJf(user.getJf().subtract(jf));
|
||||
myUserDao.updateById(user);
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private MessagePostProcessor messagePostProcessor() {
|
||||
return message -> {
|
||||
//设置有效期30分钟
|
||||
message.getMessageProperties().setExpiration(String.valueOf(30 * 60 * 1000));
|
||||
return message;
|
||||
};
|
||||
}
|
||||
|
||||
public Map getOriginalPriceAndCourseCount(String type) {
|
||||
Map map = new HashMap();
|
||||
map.put("courseCount",0);
|
||||
map.put("originalPrice",0);
|
||||
if ("4".equals(type)||"9".equals(type)||"5".equals(type)||"6".equals(type)){
|
||||
List list = new ArrayList<>();
|
||||
if ("4".equals(type)){
|
||||
userVipService.bottomLabel(1,list);
|
||||
}else if ("9".equals(type)){
|
||||
userVipService.bottomLabel(74,list);
|
||||
}else if ("5".equals(type)){
|
||||
userVipService.bottomLabel(2,list);
|
||||
}else if ("6".equals(type)){
|
||||
userVipService.bottomLabel(5,list);
|
||||
}
|
||||
if (list.size()>0){
|
||||
MPJLambdaWrapper<CourseCatalogueEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.inSql(CourseCatalogueEntity::getCourseId,
|
||||
"select course_id from course_to_medicine where del_flag = 0 and medical_id in ("+String.join(",",list.toString().replace("[","").replace("]",""))+") group by course_id");
|
||||
wrapper.select("count(1) as courseCount,sum(fee) as originalPrice");
|
||||
map = courseCatalogueService.getMap(wrapper);
|
||||
}
|
||||
}else if ("7".equals(type)){
|
||||
MPJLambdaWrapper<CourseCatalogueEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.inSql(CourseCatalogueEntity::getCourseId,
|
||||
"select course_id from course_to_sociology where del_flag = 0 group by course_id");
|
||||
wrapper.select("count(1) as courseCount,sum(fee) as originalPrice");
|
||||
map = courseCatalogueService.getMap(wrapper);
|
||||
}else if ("8".equals(type)){
|
||||
MPJLambdaWrapper<CourseCatalogueEntity> pWrapper = new MPJLambdaWrapper();
|
||||
pWrapper.inSql(CourseCatalogueEntity::getCourseId,
|
||||
"select course_id from course_to_psyche where del_flag = 0 group by course_id");
|
||||
pWrapper.select("count(1) as courseCount,sum(fee) as originalPrice");
|
||||
map = courseCatalogueService.getMap(pWrapper);
|
||||
}else if ("2".equals(type)){
|
||||
MPJLambdaWrapper<CourseCatalogueEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.inSql(CourseCatalogueEntity::getCourseId,
|
||||
"select course_id from course_to_sociology where del_flag = 0 group by course_id\n" +
|
||||
"union \n" +
|
||||
"select course_id from course_to_psyche where del_flag = 0 group by course_id");
|
||||
wrapper.select("count(1) as courseCount,sum(fee) as originalPrice");
|
||||
map = courseCatalogueService.getMap(wrapper);
|
||||
}else if ("1".equals(type)){
|
||||
MPJLambdaWrapper<CourseCatalogueEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.inSql(CourseCatalogueEntity::getCourseId,
|
||||
"select course_id from course_to_medicine where del_flag = 0 group by course_id\n" +
|
||||
"union \n" +
|
||||
"select course_id from course_to_sociology where del_flag = 0 group by course_id\n" +
|
||||
"union \n" +
|
||||
"select course_id from course_to_psyche where del_flag = 0 group by course_id");
|
||||
wrapper.select("count(1) as courseCount,sum(fee) as originalPrice");
|
||||
map = courseCatalogueService.getMap(wrapper);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.WxPublicAccountArticle;
|
||||
import com.peanut.modules.common.service.WxPublicAccountArticleService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.Connection;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonParser;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController("commonWxPublicAccount")
|
||||
@RequestMapping("common/wxPublicAccount")
|
||||
public class WxPublicAccountController {
|
||||
|
||||
@Autowired
|
||||
private WxPublicAccountArticleService wxPublicAccountArticleService;
|
||||
|
||||
//获取公众号文章列表
|
||||
@RequestMapping("/getWxPublicAccountArticleList")
|
||||
public R getWxPublicAccountArticleList(@RequestBody Map<String,Object> params) {
|
||||
Page<WxPublicAccountArticle> wxPublicAccountArticlePage = wxPublicAccountArticleService.page(new Page<>(
|
||||
Long.parseLong(params.get("page").toString()),Long.parseLong(params.get("limit").toString())),
|
||||
new LambdaQueryWrapper<WxPublicAccountArticle>()
|
||||
.like(WxPublicAccountArticle::getTitle,params.get("title"))
|
||||
.eq(StringUtils.isNotEmpty(params.get("type")==null?"":params.get("type").toString()),WxPublicAccountArticle::getType,params.get("type"))
|
||||
.orderByDesc(WxPublicAccountArticle::getCreateTime));
|
||||
return R.ok().put("page",wxPublicAccountArticlePage);
|
||||
}
|
||||
|
||||
//新增公众号文章
|
||||
@RequestMapping("/addWxPublicAccountArticle")
|
||||
public R addWxPublicAccountArticle(@RequestBody Map<String,Object> params) {
|
||||
try {
|
||||
String token = params.get("token").toString();
|
||||
String cookie = params.get("cookie").toString();
|
||||
int begin = 0;
|
||||
int count = 20;
|
||||
List<JsonObject> items = new ArrayList<>();
|
||||
List<String> deleteAppmsgids = new ArrayList<>();
|
||||
boolean ready = false;
|
||||
while (!ready) {
|
||||
String url = "https://mp.weixin.qq.com/cgi-bin/appmsgpublish?sub=list" + "&begin=" + begin + "&count=" + count + "&token=" + token + "&lang=zh_CN&f=json&ajax=1";
|
||||
Connection.Response response = Jsoup.connect(url)
|
||||
.header("Cookie", cookie)
|
||||
.ignoreContentType(true)
|
||||
.execute();
|
||||
String body = response.body();
|
||||
JsonObject root = JsonParser.parseString(body).getAsJsonObject();
|
||||
JsonObject publishPage = JsonParser.parseString(root.get("publish_page").getAsString()).getAsJsonObject();
|
||||
JsonArray publishList = publishPage.getAsJsonArray("publish_list");
|
||||
if (publishList.size()>0){
|
||||
for (int i = 0; i < publishList.size(); i++) {
|
||||
JsonObject item = publishList.get(i).getAsJsonObject();
|
||||
items.add(item);
|
||||
}
|
||||
}else {
|
||||
ready = true;
|
||||
}
|
||||
begin += count; // 下一页
|
||||
}
|
||||
List<WxPublicAccountArticle> allArticles = new ArrayList<>();
|
||||
for (JsonObject item:items){
|
||||
// publish_info 本身是一个字符串,需要再解析一次
|
||||
JsonObject publishInfo = JsonParser.parseString(item.get("publish_info").getAsString()).getAsJsonObject();
|
||||
JsonArray appmsgInfo = publishInfo.getAsJsonArray("appmsg_info");
|
||||
for (int j = 0; j < appmsgInfo.size(); j++) {
|
||||
JsonObject article = appmsgInfo.get(j).getAsJsonObject();
|
||||
String appmsgid = article.get("appmsgid").getAsString()+"-"+(article.get("itemidx")==null?"":article.get("itemidx").getAsString());
|
||||
boolean del = article.get("is_deleted").getAsBoolean();
|
||||
if (del){
|
||||
deleteAppmsgids.add(appmsgid);
|
||||
continue;
|
||||
}
|
||||
String content_url = article.get("content_url").getAsString();
|
||||
String title = article.get("title").getAsString();
|
||||
String digest = article.get("digest").getAsString();
|
||||
String cover = article.get("cover").getAsString();
|
||||
JsonObject lineInfo = article.getAsJsonObject("line_info");
|
||||
long sendTime = lineInfo.get("send_time").getAsLong();
|
||||
Date d = new Date(sendTime * 1000);
|
||||
WxPublicAccountArticle wxPublicAccountArticle = new WxPublicAccountArticle();
|
||||
wxPublicAccountArticle.setAppmsgid(appmsgid);
|
||||
wxPublicAccountArticle.setUrl(content_url);
|
||||
wxPublicAccountArticle.setTitle(title);
|
||||
if (digest.length()>200){
|
||||
digest = digest.substring(0, 200);
|
||||
}
|
||||
wxPublicAccountArticle.setDescription(digest);
|
||||
wxPublicAccountArticle.setImgurl(cover);
|
||||
wxPublicAccountArticle.setCreateTime(d);
|
||||
allArticles.add(wxPublicAccountArticle);
|
||||
}
|
||||
}
|
||||
List<WxPublicAccountArticle> dels = wxPublicAccountArticleService.list(new LambdaQueryWrapper<WxPublicAccountArticle>()
|
||||
.in(WxPublicAccountArticle::getAppmsgid,deleteAppmsgids));
|
||||
wxPublicAccountArticleService.removeByIds(dels);
|
||||
List<WxPublicAccountArticle> addArticles = new ArrayList<>();
|
||||
for (WxPublicAccountArticle article:allArticles){
|
||||
if (wxPublicAccountArticleService.count(new LambdaQueryWrapper<WxPublicAccountArticle>()
|
||||
.eq(WxPublicAccountArticle::getAppmsgid,article.getAppmsgid()))==0){
|
||||
addArticles.add(article);
|
||||
}
|
||||
}
|
||||
wxPublicAccountArticleService.saveBatch(addArticles);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return R.error(e.toString());
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//修改公众号文章
|
||||
@RequestMapping("/updateWxPublicAccountArticle")
|
||||
public R updateWxPublicAccountArticle(@RequestBody WxPublicAccountArticle wxPublicAccountArticle) {
|
||||
wxPublicAccountArticleService.updateById(wxPublicAccountArticle);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//删除公众号文章
|
||||
@RequestMapping("/delWxPublicAccountArticle")
|
||||
public R delWxPublicAccountArticle(@RequestBody Map<String,Object> params) {
|
||||
wxPublicAccountArticleService.removeById(params.get("id").toString());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user