diff --git a/pom.xml b/pom.xml
index d6e0cee..5cc39e0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,10 +8,6 @@
ruoyi
3.8.3
- ruoyi
- http://www.ruoyi.vip
- 若依管理系统
-
3.8.3
UTF-8
@@ -151,44 +147,40 @@
${kaptcha.version}
-
+
com.ruoyi
- ruoyi-quartz
+ ruoyi-framework
${ruoyi.version}
-
+
com.ruoyi
- ruoyi-generator
+ ruoyi-system
${ruoyi.version}
-
+
com.ruoyi
- ruoyi-framework
+ ruoyi-common
${ruoyi.version}
-
com.ruoyi
- ruoyi-system
+ ruoyi-app-domain
${ruoyi.version}
-
-
com.ruoyi
- ruoyi-common
+ ruoyi-im-client
${ruoyi.version}
-
com.ruoyi
- ruoyi-app-domain
+ ruoyi-im-server
${ruoyi.version}
@@ -199,9 +191,10 @@
ruoyi-admin
ruoyi-framework
ruoyi-system
- ruoyi-quartz
- ruoyi-generator
ruoyi-common
+ ruoyi-im-client
+ ruoyi-im-server
+
pom
diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml
index cd76956..e683ad3 100644
--- a/ruoyi-admin/pom.xml
+++ b/ruoyi-admin/pom.xml
@@ -18,19 +18,11 @@
-
- org.springframework.boot
- spring-boot-devtools
- true
-
-
-
-
-
-
- mysql
- mysql-connector-java
-
+
+
+
+
+
@@ -38,16 +30,7 @@
ruoyi-framework
-
-
- com.ruoyi
- ruoyi-quartz
-
-
-
- com.ruoyi
- ruoyi-generator
-
+
@@ -59,23 +42,13 @@
-
-
- com.github.wechatpay-apiv3
- wechatpay-apache-httpclient
- 0.4.8
-
-
- junit
- junit
- 4.12
-
-
- com.squareup.okhttp3
- okhttp-android-support
- 3.13.1
-
+
+
+
+
+
+
@@ -98,16 +71,16 @@
-
- org.apache.maven.plugins
- maven-war-plugin
- 3.1.0
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ 3.1.0
false
${project.artifactId}
-
-
+
+
${project.artifactId}
-
\ No newline at end of file
+
diff --git a/ruoyi-admin/ruoyi-admin.iml b/ruoyi-admin/ruoyi-admin.iml
new file mode 100644
index 0000000..541cb8b
--- /dev/null
+++ b/ruoyi-admin/ruoyi-admin.iml
@@ -0,0 +1,219 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java
index 32eb6f1..57a0406 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java
@@ -3,12 +3,14 @@ package com.ruoyi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.context.annotation.ComponentScan;
/**
* 启动程序
- *
+ *
* @author ruoyi
*/
+
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class RuoYiApplication
{
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_course/AppointmentAppController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_course/AppointmentAppController.java
deleted file mode 100644
index ce8d18e..0000000
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_course/AppointmentAppController.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package com.ruoyi.web.controller.app_course;
-
-import cn.hutool.core.date.DateUtil;
-import com.ruoyi.RestResponse;
-import com.ruoyi.common.core.controller.BaseController;
-import com.ruoyi.common.utils.SecurityUtils;
-import com.ruoyi.course.domain.Appointment;
-import com.ruoyi.course.domain.AppointmentVo;
-import com.ruoyi.course.mapper.AppointmentMapper;
-import com.ruoyi.course.service.AppointmentServiceImpl;
-import io.swagger.annotations.Api;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- *
- * 课程 前端控制器
- *
- *
- * @author xhj
- * @since 2022-09-22
- */
-@Api(tags = "课程", description = "提供课程相关的API")
-@RestController
-@RequestMapping("/api/appointment")
-public class AppointmentAppController extends BaseController {
-
- @Autowired
- AppointmentServiceImpl appointmentService;
-
- @Autowired
- AppointmentMapper mapper;
-
-
-// @PostMapping("/getAppointmentList")
- public RestResponse getAppointmentList(@RequestBody Map map) {
-// List list = appointmentService.getList(map);
-// return new RestResponse().setData(list);
- return RestResponse.success().setData(appointmentService.findList(map));
- }
-
-// @PostMapping("/updateAppointment")
- public RestResponse updateAppointment(@RequestBody Appointment appointment) {
- String username = SecurityUtils.getUsername();
- appointment.setUpdateUser(username);
-// LocalDateTime now= ;
- appointment.setUpdateTime(DateUtil.parseLocalDateTime(DateUtil.now(),"yyyy-MM-dd HH:mm:ss"));
- appointmentService.updateById(appointment);
- return RestResponse.success();
- }
-
- /**
- * 预约课程
- * @param appointment
- * @return
- */
-// @PostMapping("/yy")
- public RestResponse yy(@RequestBody Appointment appointment) {
- appointment.setCreateTime(DateUtil.parseLocalDateTime(DateUtil.now(),"yyyy-MM-dd HH:mm:ss"));
- appointmentService.save(appointment);
- return RestResponse.success();
- }
-
- //我的预约
- //预约成功
- //预约失败
- @PostMapping("/appointments")
- public RestResponse appointments(HttpServletRequest request) {
- Long userId= Long.parseLong(request.getAttribute("userId").toString());
- Map map=new HashMap();
- map.put("consumerId",userId);
- List list=appointmentService.findList(map);
- List list1=new ArrayList<>();//预约中
- List list2=new ArrayList<>();//预约成功
- List list3=new ArrayList<>();//预约失败
- List list4=new ArrayList<>();//取消预约
- for (AppointmentVo a:list){
- if (a.getFlag()==0){
- list1.add(a);
- continue;
- }
- if (a.getFlag()==1){
- list2.add(a);
- continue;
- }
- if (a.getFlag()==2){
- list3.add(a);
- continue;
- }
- if (a.getFlag()==3){
- list4.add(a);
- }
- }
- map.clear();
- map.put("list1",list1);
- map.put("list2",list2);
- map.put("list3",list3);
- map.put("list4",list4);
- return RestResponse.success().setData(map);
- }
-
-
- //取消预约
- @PostMapping("/cancel")
- public RestResponse cancel(@RequestBody Appointment appointment) {
- appointment.setUpdateTime(DateUtil.parseLocalDateTime(DateUtil.now(),"yyyy-MM-dd HH:mm:ss"));
- int i= mapper.cancel(appointment);
- return RestResponse.success().setMessage(i==0?"修改失败,当前状态无法取消预约!":"成功!");
- }
-
-
-
-
-
-}
-
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_course/ConsumerCourseController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_course/ConsumerCourseController.java
deleted file mode 100644
index 5a3a806..0000000
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_course/ConsumerCourseController.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.ruoyi.web.controller.app_course;
-
-
-import com.ruoyi.RestResponse;
-import com.ruoyi.course.domain.CourseLog;
-import com.ruoyi.course.mapper.ConsumerCourseMapper;
-import com.ruoyi.course.service.ConsumerCourseServiceImpl;
-import com.ruoyi.course.service.CourseServiceImpl;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- *
- * 前端控制器
- *
- *
- * @author xn
- * @since 2022-12-29
- */
-@RestController
-@RequestMapping("/api/consumerCourse")
-public class ConsumerCourseController {
-
- @Resource
- private CourseServiceImpl courseService;
- @Resource
- private ConsumerCourseServiceImpl consumerCourseService;
- @Resource
- private ConsumerCourseMapper mapper;
-
- //我的课程 (视频)
- @PostMapping("/myCourse")
- public RestResponse myCourse(HttpServletRequest request){
- Long userId= Long.parseLong(request.getAttribute("userId").toString());
- List list= mapper.myCourse(userId);
- List list1=new ArrayList<>();
- List list2=new ArrayList<>();
- for (CourseLog l:list){
- if (l.getCourseType().equals("2")){
- list1.add(l);
- }
- if (l.getCourseType().equals("3")){
- list2.add(l);
- }
- }
- Map map=new HashMap();
- map.put("list1",list1);//大咖课
- map.put("list2",list2);//教练培训
- return new RestResponse().setSuccess(true).setData(map);
- }
-
-
-}
-
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_course/CourseAppController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_course/CourseAppController.java
deleted file mode 100644
index e91a28c..0000000
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_course/CourseAppController.java
+++ /dev/null
@@ -1,406 +0,0 @@
-package com.ruoyi.web.controller.app_course;
-
-import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.util.ObjectUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.ruoyi.RestResponse;
-import com.ruoyi.common.core.controller.BaseController;
-import com.ruoyi.common.core.domain.entity.SysDictData;
-import com.ruoyi.common.utils.JpushClientUtil;
-import com.ruoyi.common.utils.SecurityUtils;
-import com.ruoyi.course.domain.*;
-import com.ruoyi.course.service.ConsumerCourseServiceImpl;
-import com.ruoyi.course.service.CourseLogServiceImpl;
-import com.ruoyi.course.service.CourseServiceImpl;
-import com.ruoyi.course.service.HistoryMessageServiceImpl;
-import com.ruoyi.search.domain.MemberUser;
-import com.ruoyi.search.service.MemberUserServicelmpl;
-import com.ruoyi.shop.domain.ShopOrder;
-import com.ruoyi.shop.domain.ShopOrderItem;
-import com.ruoyi.shop.service.impl.ShopOrderItemServiceImpl;
-import com.ruoyi.shop.service.impl.ShopOrderServiceImpl;
-import com.ruoyi.system.domain.SysUserRole;
-import com.ruoyi.system.mapper.SysUserRoleMapper;
-import com.ruoyi.system.service.ISysDictDataService;
-import com.ruoyi.web.util.PayUtil;
-import com.ruoyi.web.util.SnowFlake;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.*;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- *
- * 课程 前端控制器
- *
- *
- * @author xhj
- * @since 2022-09-22
- */
-@RestController
-@RequestMapping("/api/course")
-public class CourseAppController extends BaseController {
-
- @Autowired
- CourseServiceImpl courseService;
- @Autowired
- HistoryMessageServiceImpl historyMessageService;
- @Autowired
- CourseLogServiceImpl courseLogService;
- @Autowired
- ISysDictDataService iSysDictDataService;
- @Autowired
- MemberUserServicelmpl memberUserService;
- @Resource
- private ShopOrderServiceImpl orderService;
- @Resource
- private ShopOrderItemServiceImpl itemService;
- @Resource
- private ConsumerCourseServiceImpl consumerCourseService;
- @Resource
- private SysUserRoleMapper sysUserRoleMapper;
-
-
- /**
- *
- * courseName 名字
- * courseType 课程分类 //1 传入1
- * memberType[] 会籍数组
- * @param map
- * @return 显示得内容 是 courseType1 字典
- */
- @PostMapping("/list")
- public RestResponse list(@RequestBody Map map) {
- map.put("releases",1);
- List list = courseService.getList(map);
- return new RestResponse().setData(list);
- }
-
-
- /**
- * 字典?
- * @param map
- * @return
- */
- @PostMapping("/listByCourseType1")
- public RestResponse listByCourseType1(@RequestBody Map map) {
- SysDictData sysDictData= new SysDictData();
- sysDictData.setDictType("yj_source_pt_type");
- sysDictData.setMerchantId(SecurityUtils.getMerchanId());
- return RestResponse.success().setData(iSysDictDataService.selectDictDataList(sysDictData));
-
- }
-
-
- /**
- * 预约课程
- * @param appointment
- * @return
- */
-// @PostMapping("/yyCourse")
- public RestResponse yyCourse(@RequestBody Appointment appointment) {
- courseService.yyCourse(appointment);
- return RestResponse.success();
- }
-
-
- /**
- * courseId 课程id 会员课的id
- * @param map
- * @return userName 教练姓名 course_names课程名称(进修课提升) memberType 类型(小班课) course_picture 图片
- * memberType 必须传1 courseType1 = 会员/1对1 具体根据courseType 查询
- */
- @PostMapping("/listLog")
- public RestResponse listLog(@RequestBody Map map) {
- //todo
- List list = courseService.getListLog(map);
- return new RestResponse().setData(list);
- }
-
- /**
- * 显示课程表
- *
- * @param map date 当天的日期 courseId 课程分类id
- * @return
- * 2022.11.30改(xn)
- */
- @PostMapping("/listLogDate")
- public RestResponse listLogDate(@RequestBody Map map) {
-// Map map1 = courseService.listLogDate(map);
- map.put("userId",null);
- Map map1 = courseService.listLogDate1(map);
- return new RestResponse().setData(map1);
- }
-
- @PostMapping("/listLogDateForMember")
- public RestResponse listLogDateForMember(@RequestBody Map map,HttpServletRequest request) {
- Long userId= Long.parseLong(request.getAttribute("userId").toString());
- // Map map1 = courseService.listLogDate(map);
- map.put("userId",userId);
- Map map1 = courseService.listLogDate1(map);
- return new RestResponse().setData(map1);
- }
-
-
- @PostMapping("/getTeacherList")
- public RestResponse getTeacherList(@RequestBody Map map) {
-// sysUserService.selectUserList()
-
- List sysUserRoles = sysUserRoleMapper.selectALLByRole(map.get("merchantId").toString());
- if(sysUserRoles.size()==0){
- return RestResponse.failure("没有教练信息");
- }
- return RestResponse.success().setData(sysUserRoles);
- }
-
-
- /**
- *
- * app服务-大咖课/教练培训
- * @param course
- * @return
- * @author xn
- */
-// @PostMapping("/listForService")
- public RestResponse listForService(@RequestBody Course course) {
- course.setReleases(1);
- List list = courseService.listForApp(course);
- return new RestResponse().success().setData(list);
- }
-
- /**
- *
- * app服务-特色课程详情
- * @param course
- * @return
- * @author xn
- */
-// @PostMapping("/getOne")
- public RestResponse getOne(@RequestBody Course course) {
- Course c = courseService.listForApp(course).get(0);
- return new RestResponse().success().setData(c);
- }
-
-
- /**
- * 课程详情(未登录)
- * @param courseLogVo
- * @return
- */
- @PostMapping("/getDetail")
- public RestResponse getDetail(@RequestBody CourseLogVo courseLogVo) {
- CourseLog courseLog =courseLogService.getById(courseLogVo.getId());
- Course course =courseService.getById(courseLog.getCourseId());
- courseLog.generateMemberNum();
- Map map=new HashMap();
- map.put("course",course);
- courseLog.setVideoLong("1");
- map.put("courseLog",courseLog);
- return new RestResponse().success().setData(map);
- }
-
- /**
- * 登录后,查看付费视频课
- * @param courseLogVo
- * @param request
- * @return
- */
- @PostMapping("/watchLongVideo")
- public RestResponse watchLongVideo(@RequestBody CourseLogVo courseLogVo, HttpServletRequest request) {
- Long userId= Long.parseLong(request.getAttribute("userId").toString());
- CourseLog courseLog =courseLogService.getById(courseLogVo.getId());
- Course course =courseService.getById(courseLog.getCourseId());
- Map map=new HashMap();
- map.put("course",course);
- map.put("courseLog",courseLog);
- //判断是否购买过
- Long l= consumerCourseService.count(new QueryWrapper()
- .eq("consumer_id",userId)
- .eq("course_log_id",courseLogVo.getId()));
- if (l<1l){
- courseLog.setVideoLong("1"); //页面
- return new RestResponse().success().setData(map);
- }
- return new RestResponse().success().setData(map);
- }
-
- /**
- * 预约课程1
- * @param appointment
- * @return
- */
- @PostMapping("/yyCourse1")
- @Transactional(rollbackFor = RuntimeException.class)
- public RestResponse yyCourse1(@RequestBody Appointment appointment, HttpServletRequest request) {
- Long userId= Long.parseLong(request.getAttribute("userId").toString());
- //查看校验课程是否符合预约条件
- CourseLog log=courseLogService.getById(appointment.getCourseLogId());
- if ( DateUtil.parse(log.getStartDate()+" "+log.getStartTime(),"yyyy-MM-dd HH:mm").before(DateUtil.date())){
- return new RestResponse().setSuccess(false).setMessage("该课程已过期,请选择其他课程!");
- }
- if (log.getNumber()==log.getAppointmentNum()){
- return new RestResponse().setSuccess(false).setMessage("该课程预约已满,请选择其他课程!");
- }
-
- log.generateMemberNum();
- if (ObjectUtil.isNotEmpty(log.getMemberNum())){
-
- //判断是否为会员
- List memberUsers=memberUserService.list(new QueryWrapper().eq("consumer_id",userId));
- if (ObjectUtil.isEmpty(memberUsers)){
- return new RestResponse().setSuccess(false).setMessage("该课程为会员课,请加入相应会籍后预约!");
- }
-
- int flag=0;
- for (Object memberId:log.getMemberNum()){
- int id=Integer.parseInt(memberId.toString());
- for (MemberUser user:memberUsers){
- //判断会员会籍与课程会籍是否相符
- if (user.getMemberId()==id){
- //如果上课日期在会员有效期之内
- if (DateUtil.parse(log.getStartDate(),"yyyy-MM-dd").before(
- DateUtil.parse(user.getValidityTime(),"yyyy-MM-dd"))){
- flag=1;
- }
- }
- }
- }
- if (flag==0){
- return new RestResponse().setSuccess(false).setMessage("该课程为会员课,您的会籍类型与课程不符,请加入相应会籍后预约!");
- }
- }
- appointment.setPhone(request.getAttribute("phone").toString());
- courseService.yyCourse1(appointment);
-
- //给教练发送消息,提醒确认
- Context context=courseService.getTeacherPhone(appointment.getCourseLogId());
- String notification_title=context.getUserName()+"教练,您有一条课程预约";
- String msg_content="学员:"+request.getAttribute("phone").toString()+"预约您的课程,请登录后台处理!";
-
- try {
- JpushClientUtil.sendMessage(context.getPhonenumber(),notification_title,msg_content);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- //消息记录
- HistoryMessage message=new HistoryMessage();
- message.setPhone(context.getPhonenumber());
- message.setNotificationTitle(notification_title);
- message.setMsgContent(msg_content);
- message.setSendTime(DateUtil.now());
- historyMessageService.save(message);
- return RestResponse.success();
- }
-
- /**
- * 购买课程
- * @param courseLogVo
- * @param request
- * @return
- * @throws Exception
- */
- @PostMapping("/createOrderForCourse")
- @Transactional(rollbackFor = RuntimeException.class)
- public RestResponse createOrderForCourse(@RequestBody CourseLogVo courseLogVo, HttpServletRequest request) throws Exception{
- Long userId= Long.parseLong(request.getAttribute("userId").toString());
- //判断是否购买过
- long count= consumerCourseService.count(new QueryWrapper()
- .eq("consumer_id",userId)
- .eq("course_log_id",courseLogVo.getId()));
- if (count>0l){
- return new RestResponse().setSuccess(false).setMessage("课程已购买过,请到 我的->我的课程 中查看!");
- }
-
-
- //生成订单(支付中)
- ShopOrder order=new ShopOrder();
- order.setOrderSn(SnowFlake.getOrder()+"");//订单号
- order.setBusinessId(courseLogVo.getStroreId());//商户
- order.setIdUser(userId);//客户id
- order.setMobile(request.getAttribute("phone").toString());//收件人电话(客户电话)
- order.setCreateTime(DateUtil.parseLocalDateTime(DateUtil.now(),"yyyy-MM-dd HH:mm:ss"));
- order.setOrderType(3);//订单类型:1.商品 2.会籍 3.课程
- order.setPayType("微信支付");
- order.setTradeAmount(courseLogVo.getCoursePrice());//TradeAmount交易金额 MemberPrice价格
-
- orderService.save(order);
-
- //生成订单详情
- ShopOrderItem item=new ShopOrderItem();
- item.setIdOrder(order.getId());//订单id
- item.setIdSouseLog(courseLogVo.getId());//开课记录id
- item.setTotalPrice(courseLogVo.getCoursePrice());//总价
- item.setThumbnail(courseLogVo.getCoursePicture());//缩略图
- item.setType("3");//1 商品 2 会籍 3 课程
- item.setCourseContext(courseLogVo.getCourseContext());//课程内容
- item.setCourseType(courseLogVo.getCourseType());//2大咖课 3教练培训
- item.setCourseNames(courseLogVo.getCourseNames());
- itemService.save(item);
-
- //单位: 元 转换成 分
- BigDecimal total=courseLogVo.getCoursePrice().multiply(new BigDecimal(100));
- Map map=new HashMap();
-
- //0元
- if (total.equals(BigDecimal.ZERO)){
- //支付成功 给用户添加课程 TODO
-
- map.put("timeStamp","1");
- return new RestResponse().setSuccess(true).setMessage("成功").setData(map);
- }
- map= PayUtil.creatOrder(total.setScale(1, RoundingMode.HALF_UP).intValue(),order.getOrderSn());
- return new RestResponse().setSuccess(true).setMessage("成功").setData(map);
- }
-
-
- //视频以流的方式播放
-// @RequestMapping(value = "/longView", method = {RequestMethod.GET})
- @GetMapping("/longView")
- public void imageView1(HttpServletRequest request, HttpServletResponse httpServletResponse){
- String fileName="/profile/upload/2022/11/10/WeChat_20221110133401_20221110133433A027.mp4";
-
- byte[] bytes = file2byte("../ruoyi/uploadPath"+fileName.substring(8));
-
- httpServletResponse.setContentType("application/octet-stream");
- httpServletResponse.setContentLength(bytes.length);
- try {
- httpServletResponse.getOutputStream().write(bytes);
- } catch (IOException e) {
- System.out.println("IO异常----");
- }
- }
-
- public byte[] file2byte(String filePath) {
- byte[] buffer = null;
- try {
- File file = new File(filePath);
- FileInputStream fis = new FileInputStream(file);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- byte[] b = new byte[1024];
- int n;
- while ((n = fis.read(b)) != -1) {
- bos.write(b, 0, n);
- }
- fis.close();
- bos.close();
- buffer = bos.toByteArray();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return buffer;
- }
-
-}
-
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_course/HistoryMessageController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_course/HistoryMessageController.java
deleted file mode 100644
index 48609ce..0000000
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_course/HistoryMessageController.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.ruoyi.web.controller.app_course;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.ruoyi.RestResponse;
-import com.ruoyi.course.domain.HistoryMessage;
-import com.ruoyi.course.service.HistoryMessageServiceImpl;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.List;
-
-/**
- * 我的消息
- */
-@Api(tags = "我的消息", description = "提供我的消息相关的API")
-@RestController
-@RequestMapping("/api/historyMessage")
-public class HistoryMessageController {
-
-
- @Autowired
- HistoryMessageServiceImpl historyMessageService;
-
- @ApiOperation("我的消息列表")
- @PostMapping("/getMessages")
- public RestResponse getMessages(HttpServletRequest request){
- List list= historyMessageService.list(new QueryWrapper()
- .eq("phone",request.getAttribute("phone").toString())
- .eq("releases",true));
- return new RestResponse().setSuccess(true).setData(list);
- }
-
- @ApiOperation("消息详情")
- @PostMapping("/getOne")
- public RestResponse getOne(@RequestBody HistoryMessage message){
- HistoryMessage historyMessage= historyMessageService.getById(message.getId());
- return new RestResponse().setSuccess(true).setData(historyMessage);
- }
-
- @ApiOperation("删除消息")
- @PostMapping("/remove")
- public RestResponse remove(@RequestBody HistoryMessage message){
- message.setReleases(false);
- historyMessageService.updateById(message);
- return new RestResponse().setSuccess(true);
- }
-
-}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_course/MemberAppController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_course/MemberAppController.java
deleted file mode 100644
index 2ebd086..0000000
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_course/MemberAppController.java
+++ /dev/null
@@ -1,186 +0,0 @@
-package com.ruoyi.web.controller.app_course;
-
-
-import cn.hutool.core.date.DateUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.ruoyi.RestResponse;
-import com.ruoyi.course.domain.Member;
-import com.ruoyi.course.service.ConsumerCourseServiceImpl;
-import com.ruoyi.course.service.MemberServiceImpl;
-import com.ruoyi.search.domain.MemberUser;
-import com.ruoyi.search.service.MemberUserServicelmpl;
-import com.ruoyi.shop.domain.ShopOrder;
-import com.ruoyi.shop.domain.ShopOrderItem;
-import com.ruoyi.shop.service.impl.ShopOrderItemServiceImpl;
-import com.ruoyi.shop.service.impl.ShopOrderServiceImpl;
-import com.ruoyi.web.util.PayUtil;
-import com.ruoyi.web.util.SnowFlake;
-import io.swagger.annotations.Api;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.time.LocalDateTime;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- *
- * 前端控制器
- *
- *
- * @author xhj
- * @since 2022-09-23
- */
-@Api(tags = "会籍", description = "提供会籍相关的API")
-@RestController
-@RequestMapping("/api/member")
-public class
-MemberAppController {
-
- @Autowired
- private MemberServiceImpl memberService;
- @Autowired
- private MemberUserServicelmpl memberUserServicel;
- @Resource
- private ShopOrderServiceImpl orderService;
- @Resource
- private ShopOrderItemServiceImpl itemService;
- @Resource
- private ConsumerCourseServiceImpl consumerCourseService;
-
- /**
- * app服务-本店会籍类型列表
- * @param member
- * @return
- * @author xn
- */
-// @ApiOperation("获取本店会籍列表")
- @PostMapping("/getMembers")
- public RestResponse getMembers(@RequestBody Member member) {
- List list = memberService.list(new QueryWrapper()
- .eq("strore_id",member.getStroreId())
- .eq("releases",1)
- );
- return new RestResponse().setData(list);
- }
-
- /**
- * app服务-会籍详情
- * @param member
- * @return
- * @author xn
- */
-// @ApiOperation("会籍详情")
- @PostMapping("/getOne")
- public RestResponse getOne(@RequestBody Member member) {
- Member m = memberService.getById(member.getMemberId());
- return new RestResponse().setData(m);
- }
-
- /**
- * 数据字典
- * @param member
- * @return
- */
-// @ApiOperation("会籍数据字典")
- @PostMapping(value = "/getList")
- public RestResponse findList1(@RequestBody Member member) {
- List list =memberService.findList(member);
- return new RestResponse().setSuccess(true).setMessage("成功").setData(list);
- }
-
- /**
- * 购买会籍下订单
- * @param memberUser
- * @param request
- * @return
- */
-// @ApiOperation("购买会籍")
- @PostMapping("/createOrderForMember")
- @Transactional(rollbackFor = RuntimeException.class)
- public RestResponse createOrderForMember(@RequestBody MemberUser memberUser, HttpServletRequest request) throws Exception{
- Long userId= Long.parseLong(request.getAttribute("userId").toString());
- //判断是否已经在籍
- LocalDateTime dateTime= DateUtil.parseLocalDateTime(DateUtil.format(DateUtil.tomorrow(),"yyyy-MM-dd 00:00:00"));
- List list=memberUserServicel.list(new QueryWrapper()//DateUtil.now()
- .eq("member_id",memberUser.getMemberId())
- .eq("consumer_id",userId)
- .last(" and (validity_time > now() or come_time ='"+dateTime+"')"));//截止日期为今天之后(未到期) 或 开始日期在明天(今天办的)
- if (list.size()>0){
- if (list.get(0).getComeTime().equals(dateTime)){
- return new RestResponse().setSuccess(false).setMessage("您已成功办理会籍,生效时间为"+DateUtil.tomorrow().toString("yyyy-MM-dd 00:00:00")+"!请勿重复办理!");
- }else {
- return new RestResponse().setSuccess(false).setMessage("会籍存续中,请勿重复办理!");
- }
- }
- //价格/月 * 有效期(月)
- BigDecimal price= memberUser.getMemberPrice().multiply(new BigDecimal(memberUser.getValidity()));
- //生成订单(支付中)
- ShopOrder order=new ShopOrder();
- order.setOrderSn(SnowFlake.getOrder()+"");//订单号
- order.setBusinessId(memberUser.getStroreId());//商户
- order.setIdUser(userId);//客户id
- order.setMobile(request.getAttribute("phone").toString());//收件人电话(客户电话)
- order.setCreateTime(DateUtil.parseLocalDateTime(DateUtil.now(),"yyyy-MM-dd HH:mm:ss"));
- order.setOrderType(2);//订单类型:1.商品 2.会籍 3.课程
- order.setPayType("微信支付");
- order.setTradeAmount(price);//TradeAmount交易金额
-
- orderService.save(order);
-
- //生成订单详情
- ShopOrderItem item=new ShopOrderItem();
- item.setIdOrder(order.getId());//订单id
- item.setIdMember(memberUser.getMemberId());//会员id
- item.setTotalPrice(price);//总价
- item.setThumbnail(memberUser.getMemberPicture());//缩略图
- item.setType("2");//1 商品 2 会籍 3 课程
- item.setMemberType(memberUser.getMemberName());//会籍类型=会籍名称
- item.setMemberValidity(memberUser.getValidity());//会籍有效期(月)
- item.setBrief(memberUser.getMemberContext());//简介=会籍内容
- item.setMemberRecommend(memberUser.getRecommend());//推荐人
- itemService.save(item);
- //单位: 元 转换成 分
- BigDecimal total=price.multiply(new BigDecimal(100));
- Map map=new HashMap();
-
- //0元
- if (total.equals(BigDecimal.ZERO)){
- //支付成功 生成会籍
-
- map.put("timeStamp","1");
- return new RestResponse().setSuccess(true).setMessage("成功").setData(map);
- }
- map= PayUtil.creatOrder(total.setScale(1, RoundingMode.HALF_UP).intValue(),order.getOrderSn());
- return new RestResponse().setSuccess(true).setMessage("成功").setData(map);
- }
-
- /**
- * 我的会籍
- * 存续的
- * @return
- */
-// @ApiOperation("我的会籍")
- @PostMapping("/myMembers")
- public RestResponse myMembers(HttpServletRequest request){
- Long userId= Long.parseLong(request.getAttribute("userId").toString());
- List list=memberUserServicel.list(new QueryWrapper()
- .eq("consumer_id",userId)
- .last("and validity_time > now()"));
- return new RestResponse().setSuccess(true).setData(list);
- }
-
- //课程表与会籍相关联
-
-
-}
-
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/CourceLpController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/CourceLpController.java
deleted file mode 100644
index 811aa22..0000000
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/CourceLpController.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.ruoyi.web.controller.app_shop;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.ruoyi.RestResponse;
-import com.ruoyi.course.domain.CourseLog;
-import com.ruoyi.course.service.CourseLogServiceImpl;
-import com.ruoyi.shop.domain.YjCourseLp;
-import com.ruoyi.shop.service.impl.YjCourceLpMenuServiceImpl;
-import com.ruoyi.shop.service.impl.YjCourceLpServiceImpl;
-import com.ruoyi.shop.service.impl.YjMerchantServiceImpl;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.util.List;
-@Api(tags = "瑜伽流派", description = "提供瑜伽流派相关的API")
-@RestController
-@RequestMapping("/api/courseLp")
-public class CourceLpController {
- @Resource
- private YjCourceLpServiceImpl service;
- @Resource
- private YjMerchantServiceImpl merchantService;
- @Resource
- private YjCourceLpMenuServiceImpl menuService;
- @Resource
- private CourseLogServiceImpl courseLogService;
-
- /**
- * 列表
- * @param lp
- * @return
- */
- @PostMapping("/list")
- @ApiOperation("获取瑜伽流派 列表")
- public RestResponse list(@RequestBody YjCourseLp lp){
- List list=service.list(new QueryWrapper()
- .eq("merchant_id", lp.getMerchantId())
- .eq("enabled",true)
- .orderByDesc("modify_time")
- );
- return new RestResponse().setSuccess(true).setMessage("成功").setData(list);
- }
-
- @ApiOperation("获取当前瑜伽流派下的课程")
- @PostMapping("/courseList")
- public RestResponse courseList(@RequestBody YjCourseLp lp){
-// 课程分类courseType 是否显示releases
- List list=service.list(new QueryWrapper()
- .eq("merchant_id", lp.getMerchantId())
- .eq("enabled",true)
- .orderByDesc("modify_time")
- );
- list.forEach(l->{
- l.setCourseType(lp.getCourseType());
- l.setReleases(true);
- List courseList=courseLogService.list(new QueryWrapper()
- .select("id","course_id","course_names","course_price","course_picture","course_type")
- .eq("course_type",lp.getCourseType())//课程类型 2大咖课 3教练培训
- .eq("releases",true) //上架
- .eq("lp_id",l.getId())//流派
- );
- l.setCourseList(courseList);
- });
- return new RestResponse().setSuccess(true).setMessage("成功").setData(list);
- }
-
-}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/GoodsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/GoodsController.java
deleted file mode 100644
index 317aa8b..0000000
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/GoodsController.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package com.ruoyi.web.controller.app_shop;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.ruoyi.RestResponse;
-import com.ruoyi.shop.domain.ShopGoods;
-import com.ruoyi.shop.domain.ShopGoodsCategory;
-import com.ruoyi.shop.mapper.ShopGoodsMapper;
-import com.ruoyi.shop.service.impl.ShopGoodsCategoryServiceImpl;
-import com.ruoyi.shop.service.impl.ShopGoodsServiceImpl;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-@Api(tags = "商品", description = "提供商品相关的API")
-@RestController
-@RequestMapping("/api/goods")
-public class GoodsController {
- @Resource
- private ShopGoodsServiceImpl service;
-
- @Resource
- private ShopGoodsCategoryServiceImpl categoryService;
-
- @Resource
- private ShopGoodsMapper goodsMapper;
-
-
- @ApiOperation("商品类别")
- @PostMapping("/getGoodsCategory")
- public RestResponse getGoodsCategory(@RequestBody ShopGoodsCategory category){
- List categoryList=categoryService.list(new QueryWrapper()
- .eq("business_id",category.getBusinessId())
- .eq("pid","0")
- .eq("display",true)
- .eq("is_delete",false));
- return new RestResponse().setSuccess(true).setMessage("成功").setData(categoryList);
- }
-
- @ApiOperation("商品列表")
- @PostMapping("/getGoods")
- public RestResponse getGoods(@RequestBody ShopGoodsCategory category){
- List goods=goodsMapper.getByPid(category.getId());
- return new RestResponse().setSuccess(true).setMessage("成功").setData(goods);
- }
-
- @ApiOperation("商品详情")
- @PostMapping("/getOne")
- public RestResponse getOne(@RequestBody ShopGoods goods){
- return new RestResponse().setSuccess(true).setMessage("成功").setData(service.getById(goods.getId()));
- }
-
-}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/IndexController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/IndexController.java
deleted file mode 100644
index e36b965..0000000
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/IndexController.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.ruoyi.web.controller.app_shop;
-
-import cn.hutool.core.util.ObjectUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.ruoyi.RestResponse;
-import com.ruoyi.shop.domain.YjIndex;
-import com.ruoyi.shop.domain.YjMerchant;
-import com.ruoyi.shop.service.impl.YjIndexServiceImpl;
-import com.ruoyi.shop.service.impl.YjMerchantServiceImpl;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.util.List;
-@Api(tags = "首页", description = "提供首页信息相关的API")
-@RestController
-@RequestMapping("/api/index")
-public class IndexController {
-
- @Resource
- private YjIndexServiceImpl indexService;
- @Resource
- private YjMerchantServiceImpl merchantService;
-
-
- //商户list
- @ApiOperation("门店列表")
- @PostMapping("/getMerchant")
- public RestResponse getMerchant(){
- List list=merchantService.list(new QueryWrapper()
- .select("address","enterprise_name","phone","banner","id")
- .eq("status",2));
- return new RestResponse().setSuccess(true).setData(list);
- }
-
- @ApiOperation("首页图标")
- @ApiImplicitParam(name = "merchantId", value = "商户ID", required = true, dataType = "String", dataTypeClass = String.class)
- @PostMapping("/getIndex")
- public RestResponse getIndex(@RequestBody YjIndex yjIndex){
- YjIndex y= indexService.getOne(new QueryWrapper()
- .eq("merchant_id",yjIndex.getMerchantId()));
-
- if (ObjectUtil.isNotEmpty(y)){
- return new RestResponse().setSuccess(true).setData(y);
- }else {
- return new RestResponse().setSuccess(false);
- }
-
-
- }
-}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/LoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/LoginController.java
deleted file mode 100644
index 358c97a..0000000
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/LoginController.java
+++ /dev/null
@@ -1,315 +0,0 @@
-package com.ruoyi.web.controller.app_shop;
-
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.ruoyi.RestResponse;
-import com.ruoyi.common.constant.CacheConstants;
-import com.ruoyi.common.constant.Constants;
-import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.core.domain.entity.SysUser;
-import com.ruoyi.common.core.domain.model.LoginBody;
-import com.ruoyi.common.core.domain.model.LoginUser;
-import com.ruoyi.common.core.redis.RedisCache;
-import com.ruoyi.common.exception.ServiceException;
-import com.ruoyi.common.exception.user.CaptchaException;
-import com.ruoyi.common.exception.user.CaptchaExpireException;
-import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
-import com.ruoyi.common.utils.*;
-import com.ruoyi.common.utils.ip.IpUtils;
-import com.ruoyi.framework.config.JwtUtil1;
-import com.ruoyi.framework.manager.AsyncManager;
-import com.ruoyi.framework.manager.factory.AsyncFactory;
-import com.ruoyi.framework.security.context.AuthenticationContextHolder;
-import com.ruoyi.framework.web.service.TokenService;
-import com.ruoyi.shop.domain.Consumer;
-import com.ruoyi.shop.domain.YjMerchant;
-import com.ruoyi.shop.service.ConsumerService;
-import com.ruoyi.shop.service.impl.YjMerchantServiceImpl;
-import com.ruoyi.system.service.ISysConfigService;
-import com.ruoyi.system.service.ISysUserService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.security.authentication.AuthenticationManager;
-import org.springframework.security.authentication.BadCredentialsException;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.Authentication;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-@Api(tags = "登录与验证")
-@RestController
-@RequestMapping("/api")
-public class LoginController {
-
-
- @Resource
- private ConsumerService service;
- @Autowired
- private ISysUserService userService;
- @Resource
- JwtUtil1 jwtUtil1;
- @Autowired
- private TokenService tokenService;
- @Resource
- RedisTemplate redisTemplate;
-
- @Autowired
- private RedisCache redisCache;
- @Autowired
- private ISysConfigService configService;
- @Resource
- private AuthenticationManager authenticationManager;
-
-
- @ApiOperation("登录")
- @PostMapping("/login")
- public AjaxResult login(@RequestBody LoginBody loginBody){
-
- AjaxResult ajax = AjaxResult.success();
- if (StrUtil.isEmpty(loginBody.getRegisterId())){
- ajax.put(Constants.FAIL, "设备id异常");
- return ajax;
- }
- boolean captchaEnabled = configService.selectCaptchaEnabled();
- // 验证码开关
- if (captchaEnabled)
- {
- validateCaptcha(loginBody.getAccount(),loginBody.getCode(),loginBody.getUuid());
- }
-
- //用户名是否存在
- SysUser user = userService.selectUserByUserName(loginBody.getAccount());
-
- //未注册
- if(ObjectUtil.isEmpty(user) ){
- //注册并登录
- //用户账号 昵称 门店 密码 头像
- // registerId 地址
- // 必填 user_name nick_name merchant_id
- user=new SysUser();
- user.setUserName(loginBody.getAccount());
- user.setNickName("用户"+loginBody.getAccount());
- user.setPassword(SecurityUtils.encryptPassword(loginBody.getPassword()));
- user.setRegisterId(loginBody.getRegisterId());
- user.setVisitStore(getIndex(user).get("id"));
- Long[] ros={107l};//用户角色
- user.setRoleIds(ros);
- userService.insertUser(user);
- String token = validateUser(loginBody.getAccount(),loginBody.getPassword());
- //设置推送别名
- JpushClientUtil.bindAlias(loginBody.getRegisterId(),loginBody.getAccount());
- ajax.put(Constants.TOKEN, token);
- return ajax;
- }
-
- //已注册 直接登录
- String token = validateUser(loginBody.getAccount(),loginBody.getPassword());
- //设置推送别名
- JpushClientUtil.bindAlias(loginBody.getRegisterId(),loginBody.getAccount());
- if (!loginBody.getRegisterId().equals(user.getRegisterId())){
- //判断登录设备是否更换 todo
-// userService.updateUser();
- }
- //返回token
- ajax.put(Constants.TOKEN, token);
- return ajax;
- }
-
- /**
- * 校验验证码
- *
- * @param code 验证码
- * @param uuid 唯一标识
- * @return 结果
- */
- public void validateCaptcha(String username, String code, String uuid)
- {
- String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
- String captcha = redisCache.getCacheObject(verifyKey);
- redisCache.deleteObject(verifyKey);
- if (captcha == null)
- {
- //验证码为空
- AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
- throw new CaptchaExpireException();
- }
- if (!code.equalsIgnoreCase(captcha))
- {
- //验证码不存在
- AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
- throw new CaptchaException();
- }
- }
-
- //用户验证
- public String validateUser(String username,String password){
- // 用户验证
- Authentication authentication = null;
- try
- {
- UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
- AuthenticationContextHolder.setContext(authenticationToken);
- // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
- authentication = authenticationManager.authenticate(authenticationToken);
- }
- catch (Exception e)
- {
- if (e instanceof BadCredentialsException)
- {
- AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
- throw new UserPasswordNotMatchException();
- }
- else
- {
- AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
- throw new ServiceException(e.getMessage());
- }
- }
- finally
- {
- AuthenticationContextHolder.clearContext();
- }
- AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
- LoginUser loginUser = (LoginUser) authentication.getPrincipal();
- if (StrUtil.isEmpty(loginUser.getUser().getMerchantId())){
- throw new RuntimeException("未建商户无法登录");
- }
- recordLoginInfo(loginUser.getUserId());
- // 生成token
- return tokenService.createToken(loginUser);
- }
-
-
- /**
- * 获取用户信息
- *
- * @return 用户信息
- */
- @GetMapping("/getInfo")
- public AjaxResult getInfo()
- {
- SysUser user = SecurityUtils.getLoginUser().getUser();
- // 角色集合
-// Set roles = permissionService.getRolePermission(user);
- // 权限集合
-// Set permissions = permissionService.getMenuPermission(user);
- AjaxResult ajax = AjaxResult.success();
- ajax.put("user", user);
- ajax.put("merchant",getIndex(user));
-// ajax.put("roles", roles);
-// ajax.put("permissions", permissions);
- return ajax;
- }
- /**
- * 记录登录信息
- *
- * @param userId 用户ID
- */
- public void recordLoginInfo(Long userId)
- {
- SysUser sysUser = new SysUser();
- sysUser.setUserId(userId);
- sysUser.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
- sysUser.setLoginDate(DateUtils.getNowDate());
- userService.updateUserProfile(sysUser);
- }
-
-// -----------------------------------------------
- @ApiOperation("获取验证码")
-// @PostMapping ("/getCode")
- public RestResponse getCode(@RequestBody Consumer consumer){
- String captcha=(String) redisTemplate.opsForValue().get(consumer.getConsumerPhonenumber());
- if (StrUtil.isNotEmpty(captcha)){
- return new RestResponse().setSuccess(false).setMessage("请1分钟后重试");
- }
- captcha =gen()+"";
-
- //发送成功 手机号存到redis 对应code 1分钟有效期
- redisTemplate.opsForValue().set(consumer.getConsumerPhonenumber(),
- captcha,
- 1,
- TimeUnit.MINUTES);
- return new RestResponse().setSuccess(true).setMessage("发送成功").setData(captcha);
- }
-
- public int gen() {
- Random r = new Random( System.currentTimeMillis() );
- return ((1 + r.nextInt(2)) * 100000 + r.nextInt(100000));
- }
-
- /**
- * 短信验证码登录方式
- * @param map
- * @return
- */
- public RestResponse login(@RequestBody Map map){
- System.out.println("---------------------registerId"+map.get("registerId"));
- String captcha=(String)redisTemplate.opsForValue().get(map.get("consumerPhonenumber"));
- if(map.get("captcha").equals(captcha)){
- //登录成功
- redisTemplate.delete(map.get("consumerPhonenumber"));
- Map dataMap = new HashMap<>();
- //查找数据库,判断是否为新用户:
- //老用戶
- Consumer consumer=service.getOne(new QueryWrapper()
- .eq("consumer_phonenumber",map.get("consumerPhonenumber")));
- if (ObjectUtil.isNotEmpty(consumer)){
- //老客户
- if (StrUtil.isNotEmpty(map.get("registerId"))){
- consumer.setRegisterId(map.get("registerId"));
- service.updateById(consumer);
- //设置推送别名
- JpushClientUtil.bindAlias(consumer.getRegisterId(),consumer.getConsumerPhonenumber());
- }
- String token = jwtUtil1.generateToken(consumer.getConsumerId().toString(),consumer.getConsumerPhonenumber());
- dataMap.put("jwt",token);
- dataMap.put("userInfo",consumer);
- return new RestResponse().setSuccess(true).setMessage("成功").setData(dataMap);
- }
- //新用戶
- consumer=new Consumer();
- consumer.setConsumerPhonenumber(map.get("consumerPhonenumber"));
- consumer.setConsumerName("用户"+map.get("consumerPhonenumber"));
- consumer.setConsumerNickName("用户"+map.get("consumerPhonenumber"));
- consumer.setRegisterId(map.get("registerId"));
- consumer.setConsumerAvatar("/default.jpeg");
- service.save(consumer);
- //设置推送别名
- JpushClientUtil.bindAlias(consumer.getRegisterId(),consumer.getConsumerPhonenumber());
- String token = jwtUtil1.generateToken(consumer.getConsumerId().toString(),consumer.getConsumerPhonenumber());
- dataMap.put("jwt",token);
- dataMap.put("userInfo",consumer);
-// dataMap.put("index",getIndex(consumer));
-
- return new RestResponse().setSuccess(true).setMessage("成功").setData(dataMap);
- }
-
- return new RestResponse().setSuccess(false).setMessage("失败");
- }
- @Resource
- private YjMerchantServiceImpl merchantService;
-
- public Map getIndex(SysUser c){
- YjMerchant merchant;
- Map m=new HashMap();
- if (StrUtil.isNotEmpty(c.getVisitStore())){
- merchant=merchantService.getById(c.getVisitStore());
- }else {
- merchant= merchantService.list().get(0);
- }
- m.put("address",merchant.getAddress());
- m.put("enterpriseName",merchant.getEnterpriseName());
- m.put("phone",merchant.getPhone());
- m.put("banner",merchant.getBanner());
- m.put("id",merchant.getId());
- return m;
- }
-
-}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/OrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/OrderController.java
deleted file mode 100644
index 954fd8b..0000000
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/OrderController.java
+++ /dev/null
@@ -1,323 +0,0 @@
-package com.ruoyi.web.controller.app_shop;
-
-import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
-import com.ruoyi.RestResponse;
-import com.ruoyi.shop.domain.ShopGoods;
-import com.ruoyi.shop.domain.ShopOrder;
-import com.ruoyi.shop.domain.ShopOrderItem;
-import com.ruoyi.shop.service.impl.ShopCartServiceImpl;
-import com.ruoyi.shop.service.impl.ShopGoodsServiceImpl;
-import com.ruoyi.shop.service.impl.ShopOrderItemServiceImpl;
-import com.ruoyi.shop.service.impl.ShopOrderServiceImpl;
-import com.ruoyi.web.controller.app_shop.dto.ShopOrderDto;
-import com.ruoyi.web.util.PayUtil;
-import com.ruoyi.web.util.SnowFlake;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-@Api(tags = "订单信息", description = "提供订单信息相关的API")
-@RestController
-@RequestMapping("/api/order")
-public class OrderController {
-
- @Resource
- private ShopGoodsServiceImpl goodsService;
- @Resource
- private ShopCartServiceImpl cartService;
- @Resource
- private ShopOrderServiceImpl orderService;
- @Resource
- private ShopOrderItemServiceImpl itemService;
-
-
- /**
- * 提交订单
- * @param orderDto
- * @param request
- * @return
- * ①按商品所属商户生成订单
- * ②生成订单详情
- * ③删除对应购物车
- * ④修改商品库存
- */
- @ApiOperation("提交订单-生成预付单")
- @PostMapping("/createOrder")
- @Transactional(rollbackFor = RuntimeException.class)
- public RestResponse createOrder(@RequestBody ShopOrderDto orderDto, HttpServletRequest request) throws Exception{
- Long userId= Long.parseLong(request.getAttribute("userId").toString());
-
- //商户:商品list
- Map> goodsMap=orderDto.getList().stream().collect(Collectors.groupingBy(ShopGoods::getBusinessId));
- String OrderSn=SnowFlake.getOrder()+"";
- BigDecimal total=new BigDecimal(0);//微信支付金额
-
- for (String key:goodsMap.keySet()){
- //生成订单
- ShopOrder order=new ShopOrder();
- order.setBusinessId(key);//商户
- order.setIdUser(userId);
- order.setConsignee(orderDto.getName());//收件人
- order.setConsigneeAddress(orderDto.getProvince()+" "+
- orderDto.getCity()+" "+
- orderDto.getAddress());//收件地址
- order.setMobile(orderDto.getPhone());//收件人电话
- order.setCreateTime(DateUtil.parseLocalDateTime(DateUtil.now(),"yyyy-MM-dd HH:mm:ss"));
- order.setOrderSn(OrderSn);//订单号
- order.setPayType("微信支付");
- order.setOrderType(1);//订单类型:1.商品 2.会籍 3.课程
- orderService.save(order);
- BigDecimal totalPrice=new BigDecimal(0);//总金额
- BigDecimal tradeAmount=new BigDecimal(0);//交易金额
-
- for (ShopGoods goods:goodsMap.get(key)){
- ShopOrderItem item=new ShopOrderItem();
- item.setGoodsName(goods.getName());//* 商品名称
- item.setIdGoods(goods.getId());//* 商品名称
- item.setThumbnail(goods.getThumbnail());//* 商品缩略图
- item.setBrief(goods.getBrief());//* 商品简介
- item.setAttribute(goods.getAttribute());//* 规格
- item.setCount(goods.getCount());//数量
- item.setPrice(goods.getPrice());//单价
- item.setIdOrder(order.getId());//订单id
- item.setType("1");//1 商品 2 会籍 3 课程
- BigDecimal to=goods.getPrice().multiply(new BigDecimal(goods.getCount()));
- item.setTotalPrice(to);//总金额
- //商品库存更改
- Boolean isEnough= goodsService.update(new UpdateWrapper()
- .setSql("stock=stock-"+goods.getCount())
- .eq("id",goods.getId())
- .ge("stock",goods.getCount()));
- if(!isEnough){
- throw new RuntimeException("商品["+goods.getName()+"]库存不足!");
-// return new RestResponse().setSuccess(false).setMessage("商品["+goods.getName()+"]库存不足!");
- }
- itemService.save(item);
- if (StrUtil.isNotEmpty(goods.getCartId())){
- cartService.removeById(goods.getCartId());
- }
- tradeAmount=tradeAmount.add(to);//实际需要支付的金额
- totalPrice=totalPrice.add(goods.getMarketPrice().multiply(new BigDecimal(goods.getCount())));
- }
- order.setTotalPrice(totalPrice);
- order.setTradeAmount( tradeAmount);//实际需要支付的金额
- orderService.updateById(order);
- //
- total=total.add(order.getTradeAmount());
- }
-
- total=total.multiply(new BigDecimal(100));
- Map map=new HashMap();
- if (total.equals(BigDecimal.ZERO)){
- //0元,直接支付成功 无需调用微信支付
- orderService.paySuccess(OrderSn,DateUtil.now(),"","0");
- map.put("timeStamp","1");
- return new RestResponse().setSuccess(true).setMessage("成功").setData(map);
- }
-
- //调用微信支付 生成预付单
- map= PayUtil.creatOrder(total.setScale(1, RoundingMode.HALF_UP).intValue(),OrderSn);
- return new RestResponse().setSuccess(true).setMessage("成功").setData(map);
-
- }
-
-// public RestResponse createOrder(@RequestBody ShopOrderDto orderDto, HttpServletRequest request){
-// Long userId= Long.parseLong(request.getAttribute("userId").toString());
-//
-//// List goodsIds = orderDto.getList().stream().map(ShopGoods::getId).collect(Collectors.toList());
-//// List goodsList = goodsMapper.selectBatchIds(goodsIds);
-// Map> goodsMap=orderDto.getList().stream().collect(Collectors.groupingBy(ShopGoods::getBusinessId));
-//
-// for (String key:goodsMap.keySet()){
-// //生成订单
-// ShopOrder order=new ShopOrder();
-// order.setBusinessId(key);//商户
-// order.setIdUser(userId);
-// order.setConsignee(orderDto.getName());//收件人
-// order.setConsigneeAddress(orderDto.getProvince()+" "+
-// orderDto.getCity()+" "+
-// orderDto.getAddress());//收件地址
-// order.setMobile(orderDto.getPhone());//收件人电话
-// order.setCreateTime(DateUtil.parseLocalDateTime(DateUtil.now(),"yyyy-MM-dd HH:mm:ss"));
-// order.setOrderSn(SnowFlake.getOrder()+"");
-// orderService.save(order);
-// BigDecimal totalPrice=new BigDecimal(0);//总金额
-// BigDecimal tradeAmount=new BigDecimal(0);//交易金额
-//
-// for (ShopGoods goods:goodsMap.get(key)){
-// ShopOrderItem item=new ShopOrderItem();
-// item.setGoodsName(goods.getName());//* 商品名称
-// item.setIdGoods(goods.getId());//* 商品名称
-// item.setThumbnail(goods.getThumbnail());//* 商品缩略图
-// item.setBrief(goods.getBrief());//* 商品简介
-// item.setAttribute(goods.getAttribute());//* 规格
-// item.setCount(goods.getCount());//数量
-// item.setPrice(goods.getPrice());//单价
-// item.setIdOrder(order.getId());//订单id
-// BigDecimal To=goods.getPrice().multiply(new BigDecimal(goods.getCount()));
-// item.setTotalPrice(To);//总金额
-// //商品库存更改
-// Boolean isEnough= goodsService.update(new UpdateWrapper()
-// .setSql("stock=stock-"+goods.getCount())
-// .eq("id",goods.getId())
-// .ge("stock",goods.getCount()));
-// if(!isEnough){
-// throw new RuntimeException("商品["+goods.getName()+"]库存不足!");
-//// return new RestResponse().setSuccess(false).setMessage("商品["+goods.getName()+"]库存不足!");
-// }
-// itemService.save(item);
-// if (StrUtil.isNotEmpty(goods.getCartId())){
-// cartService.removeById(goods.getCartId());
-// }
-// totalPrice=totalPrice.add(To);
-// tradeAmount=tradeAmount.add(goods.getMarketPrice().multiply(new BigDecimal(goods.getCount())));
-// }
-// order.setTotalPrice(tradeAmount);
-// order.setTradeAmount(totalPrice);//
-// orderService.updateById(order);
-// }
-// return new RestResponse().setSuccess(true).setMessage("成功");
-// }
-
- /**
- * 取消订单(订单状态为“1已下单/待付款”)
- * ①更改订单状态
- * ②加回产品库存
- * @param order
- * @return
- */
-// @PostMapping("/cancelOrder")
- @Transactional(rollbackFor = RuntimeException.class)
- public RestResponse cancelOrder(@RequestBody ShopOrder order){
- //更改订单状态
- //查询对应订单详情
- //根据订单详情数量 更改商品库存
- Boolean isUpdate= orderService.update(new UpdateWrapper()
- .set("status",2)
- .eq("id",order.getId())
- .eq("status",1));
- if (isUpdate){
- List itemList=itemService.list(new QueryWrapper()
- .eq("id_order",order.getId()));
- for (ShopOrderItem item:itemList){
- goodsService.update(new UpdateWrapper()
- .setSql("stock=stock+"+item.getCount())
- .eq("id",item.getIdGoods()));
- }
- return new RestResponse().setSuccess(true).setMessage("订单取消成功");
- }
-
- return new RestResponse().setSuccess(false).setMessage("该订单无法取消");
- }
-
- /**
- * 付款
- * @param order
- * @return
- */
-// @PostMapping("/pay")
- public RestResponse pay(@RequestBody ShopOrder order){
- if(orderService.getById(order.getId()).getPayStatus()==2){
- return new RestResponse().setSuccess(true).setMessage("该订单已支付成功,请勿重复支付!");
- }
- ShopOrder o=orderService.getById(order);
- order.setStatus(3);
- order.setPayStatus(2);
- order.setPayTime(DateUtil.now());
- order.setRealPrice(o.getTradeAmount());
- orderService.updateById(order);
- return new RestResponse().setSuccess(true).setMessage("订单支付成功");
- }
-
- /**
- * 签收
- * @param order
- * @return
- */
- @ApiOperation("确认收货")
- @PostMapping("/received")
- public RestResponse received(@RequestBody ShopOrder order){
- order.setStatus(6);
- orderService.updateById(order);
- return new RestResponse().setSuccess(true).setMessage("成功");
- }
-
- /**
- * 订单列表
- * @param request
- * @return
- */
- @ApiOperation(value = "获取订单列表", notes = "我的订单")
- @PostMapping("/orderList")
- public RestResponse orderList(HttpServletRequest request){
- Long userId= Long.parseLong(request.getAttribute("userId").toString());
- List list=orderService.list(new QueryWrapper()
- .eq("id_user",userId));
- List list1=new ArrayList<>();
- List list2=new ArrayList<>();
- List list3=new ArrayList<>();
- List list4=new ArrayList<>();
- List list6=new ArrayList<>();
- for (ShopOrder order:list){
- order.setItemList(getItemList(order.getId()));
- if (order.getStatus()==1){
- list1.add(order);
- }
- if (order.getStatus()==2){
- list2.add(order);
- }
- if (order.getStatus()==3){
- list3.add(order);
- }
- if (order.getStatus()==4){
- list4.add(order);
- }
- if (order.getStatus()==6){
- list6.add(order);
- }
- }
- Map> map=new HashMap<>();
- map.put("list",list);//全部订单
- map.put("list1",list1);//未付款
- map.put("list2",list2);//2已取消
- map.put("list3",list3);//3已付款/待发货
- map.put("list4",list4);//4已发货/待收货
- map.put("list6",list6);//6已签收
- return new RestResponse().setSuccess(true).setMessage("成功").setData(map);
- }
-
- /**
- * 订单详情
- * @param order
- * @return
- */
- @ApiOperation("订单详情")
- @PostMapping("/getOrder")
- public RestResponse getOrder(@RequestBody ShopOrder order){
- ShopOrder o= orderService.getById(order.getId());
- o.setItemList(getItemList(order.getId()));
- return new RestResponse().setSuccess(true).setMessage("成功").setData(o);
- }
-
- public List getItemList(String orderId){
- return itemService.list(new QueryWrapper().eq("id_order",orderId));
- }
-
-}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/PayController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/PayController.java
deleted file mode 100644
index 840ee88..0000000
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/PayController.java
+++ /dev/null
@@ -1,220 +0,0 @@
-package com.ruoyi.web.controller.app_shop;
-
-import cn.hutool.core.date.DateTime;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.ruoyi.shop.domain.ShopOrder;
-import com.ruoyi.shop.service.impl.ShopOrderServiceImpl;
-import com.ruoyi.web.util.PayConstants;
-import com.ruoyi.web.util.PayUtil;
-import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
-import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner;
-import com.wechat.pay.contrib.apache.httpclient.auth.Verifier;
-import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Credentials;
-import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Validator;
-import com.wechat.pay.contrib.apache.httpclient.cert.CertificatesManager;
-import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.util.EntityUtils;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.security.PrivateKey;
-import java.text.SimpleDateFormat;
-import java.util.*;
-
-@RestController
-@RequestMapping("/api")
-public class PayController {
- @Resource
- private ShopOrderServiceImpl orderService;
-
- /**
- * 付款前
- * @param amount
- * @return
- * @throws Exception
- */
-// @PostMapping("/creat_order")
-// private Map creatOrder(int amount) throws Exception{
-// return PayUtil.creatOrder("三朵兰",amount,"123");
-// }
-
-
- /**
- *
- * @return
- * https://www.test.com/callback
- */
- @PostMapping("/callback")
- public Map callback(HttpServletRequest request) {
-
- System.out.println("Wechatpay-Timestamp:"+ request.getHeader("Wechatpay-Timestamp"));
- System.out.println("Wechatpay-Nonce:"+ request.getHeader("Wechatpay-Nonce"));
- System.out.println("Wechatpay-Signature:"+ request.getHeader("Wechatpay-Signature"));
- System.out.println("Wechatpay-Serial:"+ request.getHeader("Wechatpay-Serial"));
- Map result=new HashMap();
- result.put("code","FAIL");
-
- try {
- StringBuilder signStr=new StringBuilder();
- signStr.append( request.getHeader("Wechatpay-Timestamp")).append("\n");
- signStr.append( request.getHeader("Wechatpay-Nonce")).append("\n");
-
- BufferedReader br=request.getReader();
- String str=null;
- StringBuilder builder=new StringBuilder();
- while ((str=br.readLine())!=null){
- builder.append(str);
- }
- System.out.println(builder);
-
- signStr.append( builder.toString()).append("\n");
- //验证签名
- if (!PayUtil.signVerify(request.getHeader("Wechatpay-Serial"),signStr.toString(),request.getHeader("Wechatpay-Signature"))){
- result.put("message","sign error");
- return result;
- }
- //解密密文
- String ciphertext=PayUtil.decryptOrder(builder.toString());
- System.out.println(ciphertext);
- //验证订单
- ObjectMapper objectMapper = new ObjectMapper();
- JsonNode node=objectMapper.readTree(ciphertext);
- JsonNode amount=node.get("amount");//订单金额信息
- String payer_total=amount.get("payer_total").textValue();//用户支付金额,单位为分
- String payer_currency=amount.get("payer_currency").textValue();//用户支付币种 示例值:CNY
- String trade_state=node.get("trade_state").textValue();//交易状态 SUCCESS
- String out_trade_no=node.get("out_trade_no").textValue();//商户订单号
- String success_time=node.get("success_time").textValue();//支付完成时间
- String transaction_id=node.get("transaction_id").textValue();//支付完成时间
-
- List list = orderService.list(new QueryWrapper().eq("orderSn",out_trade_no));
- //判断交易状态 可能是多次 SUCCESS; 也可能是 多次不同状态 ;
- // 现只处理支付成功与支付失败两种状态
- //判断是否处理过
- if (list.get(0).getPayStatus()==1){
- System.out.println("处理订单:"+out_trade_no+" 交易状态:"+trade_state);
- //支付失败
- if (trade_state.equals("PAYERROR")){
- System.out.println("取消订单+关单");
- orderService.cancelOrder(out_trade_no);
- try {
- PayUtil.closeOrder(out_trade_no);//关单
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- //支付成功
- if (trade_state.equals("SUCCESS")){
- System.out.println("支付成功");
- orderService.paySuccess(out_trade_no
- ,getStringByRFC3339(success_time)
- ,transaction_id
- ,payer_total);
-
- result.put("code","SUCCESS");
-
- }
- }
-
- }catch (IOException e){
- e.printStackTrace();
- }
- return result;
- }
-
-
- public void a(@RequestBody Map map){
- String out_trade_no=map.get("out_trade_no");
- String trade_state=map.get("trade_state");
- String success_time="2022-12-31T10:34:56+08:00";
- String transaction_id="微信支付订单号";
- String payer_total="0.1";
-
- List list = orderService.list(new QueryWrapper().eq("order_sn",out_trade_no));
- //判断交易状态 可能是多次 SUCCESS; 也可能是 多次不同状态 ;
- // 现只处理支付成功与支付失败两种状态
- //判断是否处理过
- if (list.get(0).getPayStatus()==1){
- //支付失败
- if (trade_state.equals("PAYERROR")){
- System.out.println("取消订单+关单");
- orderService.cancelOrder(out_trade_no);
- try {
- PayUtil.closeOrder(out_trade_no);//关单
- System.out.println("code,***");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- //支付成功
- if (trade_state.equals("SUCCESS")){
- System.out.println("支付成功");
- orderService.paySuccess(out_trade_no
- ,getStringByRFC3339(success_time)
- ,transaction_id
- ,payer_total);
-
- System.out.println("code,SUCCESS");
-
- }
- }
- }
-
- //查询订单
- public void queryOrder() throws Exception{
- PrivateKey merchantPrivateKey = PemUtil.loadPrivateKey(PayConstants.PRIVATE_KEY);
- // 获取证书管理器实例
- CertificatesManager certificatesManager = CertificatesManager.getInstance();
- // 向证书管理器增加需要自动更新平台证书的商户信息
- certificatesManager.putMerchant(PayConstants.MCH_ID, new WechatPay2Credentials(PayConstants.MCH_ID,
- new PrivateKeySigner(PayConstants.MCH_SERIAL_NO, merchantPrivateKey)),
- PayConstants.API_V3KEY.getBytes(StandardCharsets.UTF_8));
- // 从证书管理器中获取verifier
- Verifier verifier = certificatesManager.getVerifier(PayConstants.MCH_ID);
- CloseableHttpClient httpClient = WechatPayHttpClientBuilder.create()
- .withMerchant(PayConstants.MCH_ID, PayConstants.MCH_SERIAL_NO, merchantPrivateKey)
- .withValidator(new WechatPay2Validator(certificatesManager.getVerifier(PayConstants.MCH_ID)))
- .build();
-//***********************
- URIBuilder uriBuilder = new URIBuilder("https://api.mch.weixin.qq.com/v3/pay/partner/transactions/id/"+"订单号"+"?mchid="+PayConstants.MCH_ID);
- HttpGet httpGet = new HttpGet(uriBuilder.build());
- httpGet.addHeader("Accept", "application/json");
-
- CloseableHttpResponse response = httpClient.execute(httpGet);
-
- String bodyAsString = EntityUtils.toString(response.getEntity());
- System.out.println(bodyAsString);
- }
-
- /**
- * 支付成功时间格式化
- *
- * 遵循rfc3339标准格式
- * 格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE
- * 示例值:2018-06-08T10:34:56+08:00
- * @param dateStr
- * @return
- */
- public static String getStringByRFC3339(String dateStr){
- DateTime dateTime = new DateTime(dateStr);
- long timeInMillis = dateTime.toCalendar(Locale.getDefault()).getTimeInMillis();
- Date date = new Date(timeInMillis);
-
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String time = format.format(date);
- return time;
- }
-}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/ShopCartController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/ShopCartController.java
deleted file mode 100644
index adf45a8..0000000
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/ShopCartController.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.ruoyi.web.controller.app_shop;
-
-import cn.hutool.core.util.ObjectUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.ruoyi.RestResponse;
-import com.ruoyi.shop.domain.ShopCart;
-import com.ruoyi.shop.domain.ShopGoods;
-import com.ruoyi.shop.mapper.ShopCartMapper;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import java.util.List;
-import java.util.Map;
-@Api(tags = "购物车", description = "提供购物车相关的API")
-@RestController
-@RequestMapping("/api/shopCart")
-public class ShopCartController {
-
- @Resource
- private ShopCartMapper shopCartMapper;
-
- @ApiOperation("加入购物车")
- @PostMapping("/addShopCart")
- public RestResponse addShopCart(@RequestBody ShopCart shopCart, HttpServletRequest request){
- Long userId= Long.parseLong(request.getAttribute("userId").toString());
- ShopCart s=shopCartMapper.selectOne(new QueryWrapper()
- .eq("id_user",userId)
- .eq("id_goods",shopCart.getIdGoods()));
- if (ObjectUtil.isNotEmpty(s)){
- s.setCount(s.getCount()+1);
- shopCartMapper.updateById(s);
- return new RestResponse().setSuccess(true).setMessage("成功");
- }
- shopCart.setIdUser(userId);
- shopCartMapper.insert(shopCart);
- return new RestResponse().setSuccess(true).setMessage("成功");
- }
-
- @ApiOperation("购物车删除商品")
- @PostMapping("/removeShopCart")
- public RestResponse removeShopCart(@RequestBody Map> map){
- List ids=map.get("ids");
- shopCartMapper.deleteBatchIds(ids);
- return new RestResponse().setSuccess(true).setMessage("成功");
- }
-
- @ApiOperation("购物车商品列表")
- @PostMapping("/shopCartList")
- public RestResponse shopCartList(HttpServletRequest request){
- Long userId= Long.parseLong(request.getAttribute("userId").toString());
- List list=shopCartMapper.cartList(userId);
- return new RestResponse().setSuccess(true).setMessage("成功").setData(list);
- }
-
- @ApiOperation("购物车修改商品数量")
- @PostMapping("/changeCount")
- public RestResponse changeCount(@RequestBody ShopCart shopCart){
- shopCartMapper.updateById(shopCart);
- return new RestResponse().setSuccess(true).setMessage("成功");
- }
-
-}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/dto/ShopOrderDto.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/dto/ShopOrderDto.java
deleted file mode 100644
index 98a9217..0000000
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/dto/ShopOrderDto.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.ruoyi.web.controller.app_shop.dto;
-
-import com.ruoyi.shop.domain.ShopGoods;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import java.util.List;
-
-@Data
-public class ShopOrderDto {
-
- /**
- * 省
- */
- @ApiModelProperty("省")
- private String province;
-
- /**
- * 市
- */
- private String city;
-
- /**
- * 详细地址
- */
- private String address;
- /**
- * 电话
- */
- private String phone;
-
- /**
- * 收货人名称
- */
- private String name;
-
- private String message;
- private List list;
-
-}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/AppreciateController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/AppreciateController.java
similarity index 83%
rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/AppreciateController.java
rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/AppreciateController.java
index a142c68..cf2bf80 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/AppreciateController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/AppreciateController.java
@@ -1,10 +1,10 @@
-package com.ruoyi.web.controller.app_shop;
+package com.ruoyi.web.controller.basic;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ruoyi.RestResponse;
-import com.ruoyi.shop.domain.YjAppreciate;
-import com.ruoyi.shop.service.impl.YjAppreciateServiceImpl;
+import com.ruoyi.basic.domain.YjAppreciate;
+import com.ruoyi.basic.service.impl.YjAppreciateServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
@@ -18,7 +18,7 @@ import java.util.List;
/**
* 瑜伽欣赏
*/
-@Api(tags = "瑜伽欣赏", description = "提供瑜伽欣赏相关的API")
+@Api(tags = "034-瑜伽欣赏", description = "提供瑜伽欣赏相关的API")
@RestController
@RequestMapping("/api/appreciate")
public class AppreciateController {
@@ -35,7 +35,8 @@ public class AppreciateController {
@PostMapping("/getList")
public RestResponse getList(@RequestBody YjAppreciate appreciate){
List list= service.list(new QueryWrapper()
- .eq("merchan_id",appreciate.getMerchanId())
+ .select("id,title,image,read_num,start_time")
+ .eq("visit_store",appreciate.getVisitStore())
.eq("status",true)
.orderByDesc("modify_time"));
return new RestResponse().setSuccess(true).setMessage("成功").setData(list);
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_course/ContextAppController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/ContextAppController.java
similarity index 64%
rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_course/ContextAppController.java
rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/ContextAppController.java
index 5db3ef4..030bcf5 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_course/ContextAppController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/ContextAppController.java
@@ -1,9 +1,12 @@
-package com.ruoyi.web.controller.app_course;
+package com.ruoyi.web.controller.basic;
import com.ruoyi.RestResponse;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.course.domain.Context;
-import com.ruoyi.course.service.ContextServicelmpl;
+import com.ruoyi.course.domain.ReqSearchClaTime;
+import com.ruoyi.course.domain.time.RespBusinessClaTimeCalendar;
+import com.ruoyi.course.service.ScClaTimeService;
+import com.ruoyi.course.service.impl.ContextServicelmpl;
import com.ruoyi.system.service.impl.SysUserServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -16,7 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
-@Api(tags = "教练", description = "获取教练信息")
+@Api(tags = "022-教练", description = "获取教练信息")
@RestController
@RequestMapping("/api/context")
public class ContextAppController extends BaseController {
@@ -24,11 +27,12 @@ public class ContextAppController extends BaseController {
ContextServicelmpl contextService;
@Autowired
SysUserServiceImpl userService;
+ @Autowired
+ ScClaTimeService scClaTimeService;
@ApiOperation("教练列表")
@PostMapping(value = "/getList")
public RestResponse findList1(@RequestBody Map params) {
- params.put("releases",true);
List list =contextService.getList(params);
return new RestResponse().setSuccess(true).setMessage("成功").setData(list);
}
@@ -36,7 +40,14 @@ public class ContextAppController extends BaseController {
@ApiOperation("教练详细信息")
@PostMapping("/getOne")
public RestResponse update(@RequestBody Map params) {
- Context c =contextService.getList(params).get(0);
+ Context c =contextService.getOne(params);
+ return RestResponse.success().setData(c);
+ }
+ @ApiOperation("教练课程表")
+ @PostMapping("/searchListForCalendar")
+ public RestResponse update(@RequestBody ReqSearchClaTime reqSearchClaTime) {
+ RespBusinessClaTimeCalendar c =scClaTimeService.searchListForCalendar(reqSearchClaTime);
return RestResponse.success().setData(c);
}
+
}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/HealthyController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/HealthyController.java
similarity index 83%
rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/HealthyController.java
rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/HealthyController.java
index adfb36e..997033f 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/HealthyController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/HealthyController.java
@@ -1,10 +1,10 @@
-package com.ruoyi.web.controller.app_shop;
+package com.ruoyi.web.controller.basic;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ruoyi.RestResponse;
-import com.ruoyi.shop.domain.YjHealthy;
-import com.ruoyi.shop.service.impl.YjHealthyServiceImpl;
+import com.ruoyi.basic.domain.YjHealthy;
+import com.ruoyi.basic.service.impl.YjHealthyServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
@@ -18,7 +18,7 @@ import java.util.List;
/**
* 健康饮食
*/
-@Api(tags = "健康饮食", description = "提供健康饮食相关的API")
+@Api(tags = "036-健康饮食", description = "提供健康饮食相关的API")
@RestController
@RequestMapping("/api/healthy")
public class HealthyController {
@@ -34,7 +34,8 @@ public class HealthyController {
@PostMapping("/getList")
public RestResponse getList(@RequestBody YjHealthy healthy){
List list= service.list(new QueryWrapper()
- .eq("merchan_id",healthy.getMerchanId())
+ .select("id,title,image,read_num,start_time")
+ .eq("visit_store",healthy.getVisitStore())
.eq("status",true)
.orderByDesc("modify_time"));
return new RestResponse().setSuccess(true).setMessage("成功").setData(list);
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/IndexController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/IndexController.java
new file mode 100644
index 0000000..8fe7087
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/IndexController.java
@@ -0,0 +1,77 @@
+package com.ruoyi.web.controller.basic;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.ruoyi.RestResponse;
+import com.ruoyi.basic.service.YjAppUserService;
+import com.ruoyi.common.core.domain.entity.AppUser;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.basic.domain.YjStore;
+import com.ruoyi.basic.service.impl.YjStoreServiceImpl;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Api(tags = "021-首页", description = "提供首页信息相关的API")
+@RestController
+@RequestMapping("/api/index")
+public class IndexController {
+ @Resource
+ private YjStoreServiceImpl storeService;
+ @Autowired
+ private YjAppUserService appUserService;
+
+
+ @ApiOperation("门店列表")
+ @PostMapping("/getStores")
+ public RestResponse getStores(){
+ Long userId = SecurityUtils.getAppLoginUser().getAppUser().getId();
+ AppUser appUser =appUserService.getById(userId);
+ YjStore s=storeService.getOne(new QueryWrapper().select("tenant_id").eq("id",appUser.getVisitStore()));
+ List list= storeService.list(new QueryWrapper()
+ .select("address","" +
+ "store_name","phone","id","parent_id")
+ .eq("status",2)
+ .eq("tenant_id",s.getTenantId())
+ .orderByAsc("tenant_id")
+ );
+
+ list.forEach(l->{
+ if (l.getParentId().equals("0")){
+ l.setStoreName(l.getStoreName()+"(总店)");
+ }
+ });
+ return new RestResponse().setSuccess(true).setData(list);
+ }
+
+ @ApiOperation("切换门店")
+ @PostMapping("/changeStore")
+ public RestResponse changeStore(@RequestBody Map map){
+ String visitStoreId =map.get("visitStoreId");
+ //登录用户的访问门店字段修改
+ AppUser appUser = SecurityUtils.getAppLoginUser().getAppUser();
+ appUserService.update(new UpdateWrapper()
+ .eq("app_user_id",appUser)
+ .set("visit_store",visitStoreId));
+ //返回新切换的门店信息
+ YjStore yjStore= storeService.getById(visitStoreId);
+ Map m=new HashMap();
+ m.put("address",yjStore.getAddress());
+ m.put("storeName",yjStore.getStoreName());
+ m.put("phone",yjStore.getPhone());
+ m.put("banner",yjStore.getBanner());
+ m.put("id",yjStore.getId());
+ return new RestResponse().setSuccess(true).setData(m);
+ }
+
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/InheritController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/InheritController.java
similarity index 83%
rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/InheritController.java
rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/InheritController.java
index 34d425a..62c5b3a 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/InheritController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/InheritController.java
@@ -1,10 +1,10 @@
-package com.ruoyi.web.controller.app_shop;
+package com.ruoyi.web.controller.basic;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ruoyi.RestResponse;
-import com.ruoyi.shop.domain.YjInherit;
-import com.ruoyi.shop.service.impl.YjInheritServiceImpl;
+import com.ruoyi.basic.domain.YjInherit;
+import com.ruoyi.basic.service.impl.YjInheritServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
@@ -18,7 +18,7 @@ import java.util.List;
/**
* 瑜伽传承
*/
-@Api(tags = "瑜伽传承", description = "提供瑜伽传承相关的API")
+@Api(tags = "031-瑜伽传承", description = "提供瑜伽传承相关的API")
@RestController
@RequestMapping("/api/inherit")
public class InheritController {
@@ -35,7 +35,8 @@ public class InheritController {
@PostMapping("/getList")
public RestResponse getList(@RequestBody YjInherit inherit){
List list= inheritService.list(new QueryWrapper()
- .eq("merchan_id",inherit.getMerchanId())
+ .select("id,title,image,read_num,start_time")
+ .eq("visit_store",inherit.getVisitStore())
.eq("status",true)
.orderByDesc("modify_time"));
return new RestResponse().setSuccess(true).setMessage("成功").setData(list);
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/PracticeMomentsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/PracticeMomentsController.java
similarity index 82%
rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/PracticeMomentsController.java
rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/PracticeMomentsController.java
index 42d1ca3..4977b1b 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/PracticeMomentsController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/PracticeMomentsController.java
@@ -1,9 +1,9 @@
-package com.ruoyi.web.controller.app_shop;
+package com.ruoyi.web.controller.basic;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.RestResponse;
-import com.ruoyi.shop.domain.YjPracticeMoments;
-import com.ruoyi.shop.service.impl.YjPracticeMomentsServiceImpl;
+import com.ruoyi.basic.domain.YjPracticeMoments;
+import com.ruoyi.basic.service.impl.YjPracticeMomentsServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
@@ -17,7 +17,7 @@ import java.util.List;
/**
* 练习瞬间
*/
-@Api(tags = "练习瞬间", description = "提供练习瞬间相关的API")
+@Api(tags = "033-练习瞬间", description = "提供练习瞬间相关的API")
@RestController
@RequestMapping("/api/moments")
public class PracticeMomentsController {
@@ -34,7 +34,8 @@ public class PracticeMomentsController {
@PostMapping("/getList")
public RestResponse getList(@RequestBody YjPracticeMoments moments){
List list=momentsService.list(new QueryWrapper()
- .eq("merchan_id",moments.getMerchanId())
+ .select("id,title,image,read_num,start_time")
+ .eq("visit_store",moments.getVisitStore())
.eq("status",true)
.orderByDesc("modify_time"));
return new RestResponse().setSuccess(true).setMessage("成功").setData(list);
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/SenseController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/SenseController.java
similarity index 83%
rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/SenseController.java
rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/SenseController.java
index 594ff24..b8c27d3 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/SenseController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/SenseController.java
@@ -1,10 +1,10 @@
-package com.ruoyi.web.controller.app_shop;
+package com.ruoyi.web.controller.basic;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ruoyi.RestResponse;
-import com.ruoyi.shop.domain.YjSense;
-import com.ruoyi.shop.service.impl.YjSenseServiceImpl;
+import com.ruoyi.basic.domain.YjSense;
+import com.ruoyi.basic.service.impl.YjSenseServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
@@ -18,7 +18,7 @@ import java.util.List;
/**
* 瑜伽常识
*/
-@Api(tags = "瑜伽常识", description = "提供瑜伽常识相关的API")
+@Api(tags = "035-瑜伽常识", description = "提供瑜伽常识相关的API")
@RestController
@RequestMapping("/api/sense")
public class SenseController {
@@ -34,7 +34,8 @@ public class SenseController {
@PostMapping("/getList")
public RestResponse getList(@RequestBody YjSense sense){
List list= service.list(new QueryWrapper()
- .eq("merchan_id",sense.getMerchanId())
+ .select("id,title,image,read_num,start_time")
+ .eq("visit_store",sense.getVisitStore())
.eq("status",true)
.orderByDesc("modify_time"));
return new RestResponse().setSuccess(true).setMessage("成功").setData(list);
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/MerchantController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/StoreController.java
similarity index 61%
rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/MerchantController.java
rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/StoreController.java
index af5b312..f0eae7f 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/MerchantController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/StoreController.java
@@ -1,9 +1,9 @@
-package com.ruoyi.web.controller.app_shop;
+package com.ruoyi.web.controller.basic;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.RestResponse;
-import com.ruoyi.shop.domain.YjMerchant;
-import com.ruoyi.shop.service.impl.YjMerchantServiceImpl;
+import com.ruoyi.basic.domain.YjStore;
+import com.ruoyi.basic.service.impl.YjStoreServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
@@ -12,28 +12,29 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
+import java.util.Map;
/**
* 门店
*/
-@Api(tags = "门店", description = "提供门店相关的API")
+@Api(tags = "032-了解场馆", description = "提供门店相关的API")
@RestController
-@RequestMapping("/api/merchan")
-public class MerchantController {
+@RequestMapping("/api/store")
+public class StoreController {
@Resource
- private YjMerchantServiceImpl merchantService;
+ private YjStoreServiceImpl merchantService;
/**
* 企业简介+门店列表
- * @param merchan
+ * @param map
* @return
*/
@ApiOperation(value = "创始人+企业简介+门店列表")
@PostMapping("/getList")
- public RestResponse getList(@RequestBody YjMerchant merchan){
- YjMerchant m=merchantService.getOne(new QueryWrapper()
+ public RestResponse getList(@RequestBody Map map){
+ YjStore m=merchantService.getOne(new QueryWrapper()
.select("id,enterprise_name,address,phone,founder,profile")
- .eq("id",merchan.getId()));
+ .eq("id",map.get("visitStore")));
return new RestResponse().setSuccess(true).setMessage("成功").setData(m);
}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/WeChatController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/WeChatController.java
new file mode 100644
index 0000000..f353700
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/WeChatController.java
@@ -0,0 +1,46 @@
+package com.ruoyi.web.controller.basic;
+
+import cn.hutool.crypto.SecureUtil;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Arrays;
+
+@RestController
+public class WeChatController {
+ @Value("${wechat.token}")
+ String TOKEN;
+
+
+ /**
+ *
+ * @param signature
+ * @param timestamp
+ * @param nonce
+ * @param echostr
+ * @return
+ */
+ @GetMapping("")
+ public String check(@RequestParam("signature") String signature,
+ @RequestParam("timestamp") String timestamp,
+ @RequestParam("nonce") String nonce,
+ @RequestParam("echostr") String echostr){
+ return this.check1(signature,timestamp,nonce,echostr);
+ }
+
+ public String check1(String signature,String timestamp,String nonce,String echostr) {
+ String[] arr = new String[]{TOKEN,timestamp,nonce};
+ Arrays.sort(arr);
+ StringBuilder content = new StringBuilder();
+ for (String s : arr) {
+ content.append(s);
+ }
+ String temp = SecureUtil.sha1(content.toString());
+ if (temp.equals(signature)){
+ return echostr;
+ }
+ return null;
+ }
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/dto/AppLoginUser.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/dto/AppLoginUser.java
new file mode 100644
index 0000000..0f82022
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/basic/dto/AppLoginUser.java
@@ -0,0 +1,62 @@
+package com.ruoyi.web.controller.basic.dto;
+
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.annotation.Excel.ColumnType;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@ApiModel(value = "AppLoginUser", description = "app登录用户信息")
+@Data
+public class AppLoginUser
+{
+ private static final long serialVersionUID = 1L;
+
+ /** 用户ID */
+ @ApiModelProperty("用户ID")
+ @Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号")
+ private Long userId;
+
+ /** 用户账号 */
+ @ApiModelProperty("用户昵称")
+ @Excel(name = "登录名称")
+ private String userName;
+
+ /** 用户昵称 */
+ @ApiModelProperty("用户名称")
+ @Excel(name = "用户名称")
+ private String nickName;
+
+ /** 用户邮箱 */
+ @ApiModelProperty("用户邮箱")
+ @Excel(name = "用户邮箱")
+ private String email;
+
+ /** 手机号码 */
+ @ApiModelProperty("手机号码")
+ @Excel(name = "手机号码")
+ private String phonenumber;
+
+ /** 用户性别 */
+ @ApiModelProperty("用户性别;0=男,1=女,2=未知")
+ @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
+ private String sex;
+
+ /** 用户头像 */
+ @ApiModelProperty("用户头像")
+ private String avatar;
+
+ /** 角色ID */
+ @ApiModelProperty("角色ID;顾问:103 ;教练:104 ;店长:105 ;普通用户:107;")
+ private Long roleId;
+
+ /** 所属门店id */
+ @ApiModelProperty("所属门店id")
+ private String venId;
+
+ @ApiModelProperty("设备id")
+ private String registerId;
+ @ApiModelProperty("访问/浏览门店id")
+ private String visitStore;
+
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
deleted file mode 100644
index e882775..0000000
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
+++ /dev/null
@@ -1,223 +0,0 @@
-package com.ruoyi.web.controller.common;
-
-import com.ruoyi.common.config.RuoYiConfig;
-import com.ruoyi.common.constant.Constants;
-import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.common.utils.file.FileUploadUtils;
-import com.ruoyi.common.utils.file.FileUtils;
-import com.ruoyi.framework.config.ServerConfig;
-import com.ruoyi.shop.service.impl.YjLinkServiceImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * 通用请求处理
- *
- * @author ruoyi
- */
-@RestController
-@RequestMapping("/common")
-public class CommonController
-{
- private static final Logger log = LoggerFactory.getLogger(CommonController.class);
-
- @Autowired
- private ServerConfig serverConfig;
- @Autowired
- private YjLinkServiceImpl yjLinkService;
-
- private static final String FILE_DELIMETER = ",";
-
- /**
- * 通用下载请求
- *
- * @param fileName 文件名称
- * @param delete 是否删除
- */
- @GetMapping("/download")
- public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
- {
- try
- {
- if (!FileUtils.checkAllowDownload(fileName))
- {
- throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
- }
- String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
- String filePath = RuoYiConfig.getDownloadPath() + fileName;
-
- response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
- FileUtils.setAttachmentResponseHeader(response, realFileName);
- FileUtils.writeBytes(filePath, response.getOutputStream());
- if (delete)
- {
- FileUtils.deleteFile(filePath);
- }
- }
- catch (Exception e)
- {
- log.error("下载文件失败", e);
- }
- }
-
- /**
- * 通用上传请求(单个)
- */
- @PostMapping("/upload")
- public AjaxResult uploadFile(MultipartFile file) throws Exception
- {
- try
- {
- // 上传文件路径
- String filePath = RuoYiConfig.getUploadPath();
- // 上传并返回新文件名称
- String fileName = FileUploadUtils.upload(filePath, file);
-
- yjLinkService.add(fileName,"picture");
-
- String url = serverConfig.getUrl() + fileName;
- AjaxResult ajax = AjaxResult.success();
- ajax.put("url", url);
- ajax.put("fileName", fileName);
- ajax.put("newFileName", FileUtils.getName(fileName));
- ajax.put("originalFilename", file.getOriginalFilename());
- return ajax;
- }
- catch (Exception e)
- {
- return AjaxResult.error(e.getMessage());
- }
- }
- @PostMapping("/uploadVideo")
- public AjaxResult uploadVideo(MultipartFile file) throws Exception
- {
- try
- {
- // 上传文件路径
- String filePath = RuoYiConfig.getUploadPath();
- // 上传并返回新文件名称
- String fileName = FileUploadUtils.upload(filePath, file);
-
- yjLinkService.add(fileName,"video");
-
- String url = serverConfig.getUrl() + fileName;
- AjaxResult ajax = AjaxResult.success();
- ajax.put("url", url);
- ajax.put("fileName", fileName);
- ajax.put("newFileName", FileUtils.getName(fileName));
- ajax.put("originalFilename", file.getOriginalFilename());
- return ajax;
- }
- catch (Exception e)
- {
- return AjaxResult.error(e.getMessage());
- }
- }
- @PostMapping("/uploadSp")
- public AjaxResult uploadFileSp(MultipartFile file) throws Exception
- {
- try
- {
- // 上传文件路径
- String filePath = RuoYiConfig.getUploadPath();
- // 上传并返回新文件名称
- String fileName = FileUploadUtils.upload(filePath, file);
-
- yjLinkService.add(fileName,"video");
-
- String url = serverConfig.getUrl() + fileName;
- AjaxResult ajax = AjaxResult.success();
- ajax.put("url", url);
- ajax.put("fileName", fileName);
- ajax.put("newFileName", FileUtils.getName(fileName));
- ajax.put("originalFilename", file.getOriginalFilename());
- return ajax;
- }
- catch (Exception e)
- {
- return AjaxResult.error(e.getMessage());
- }
- }
-
- /**
- * 通用上传请求(多个)
- */
- @PostMapping("/uploads")
- public AjaxResult uploadFiles(List files) throws Exception
- {
- try
- {
- // 上传文件路径
- String filePath = RuoYiConfig.getUploadPath();
- List urls = new ArrayList();
- List fileNames = new ArrayList();
- List newFileNames = new ArrayList();
- List originalFilenames = new ArrayList();
- for (MultipartFile file : files)
- {
- // 上传并返回新文件名称
- String fileName = FileUploadUtils.upload(filePath, file);
-
- yjLinkService.add(fileName,"picture");
-
- String url = serverConfig.getUrl() + fileName;
- urls.add(url);
- fileNames.add(fileName);
- newFileNames.add(FileUtils.getName(fileName));
- originalFilenames.add(file.getOriginalFilename());
- }
- AjaxResult ajax = AjaxResult.success();
- ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER));
- ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER));
- ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER));
- ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER));
- return ajax;
- }
- catch (Exception e)
- {
- return AjaxResult.error(e.getMessage());
- }
- }
-
- /**
- * 本地资源通用下载
- */
- @GetMapping("/download/resource")
- public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
- throws Exception
- {
- try
- {
- if (!FileUtils.checkAllowDownload(resource))
- {
- throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
- }
- // 本地资源路径
- String localPath = RuoYiConfig.getProfile();
- // 数据库资源地址
- String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
- // 下载名称
- String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
- response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
- FileUtils.setAttachmentResponseHeader(response, downloadName);
- FileUtils.writeBytes(downloadPath, response.getOutputStream());
- }
- catch (Exception e)
- {
- log.error("下载文件失败", e);
- }
- }
-}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/course/CourseController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/course/CourseController.java
new file mode 100644
index 0000000..ad7687e
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/course/CourseController.java
@@ -0,0 +1,32 @@
+package com.ruoyi.web.controller.course;
+
+import com.ruoyi.RestResponse;
+import com.ruoyi.common.core.controller.BaseController;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+@Api(tags = "040-教练", description = "获取商品及课程分类")
+@RestController
+@RequestMapping("/api/course/category")
+public class CourseController extends BaseController {
+// @Autowired
+// ContextServicelmpl contextService;
+// @Autowired
+// SysUserServiceImpl userService;
+
+ @ApiOperation("商品及课程类型列表")
+ @PostMapping(value = "/getList")
+ public RestResponse findList(@RequestBody Map params) {
+// List list =contextService.getList(params);
+ return new RestResponse().setSuccess(true).setMessage("成功");
+ }
+
+
+
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/FileController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/FileController.java
new file mode 100644
index 0000000..8b1b520
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/FileController.java
@@ -0,0 +1,40 @@
+package com.ruoyi.web.controller.im;
+
+import com.ruoyi.im.domain.vo.UploadImageVO;
+import com.ruoyi.im.service.FileService;
+import com.ruoyi.web.controller.im.result.Result;
+import com.ruoyi.web.controller.im.result.ResultUtils;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.logging.log4j.util.Strings;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+@Slf4j
+@RestController
+@Tag(name = "文件上传")
+@RequiredArgsConstructor
+@RequestMapping("/api")
+public class FileController {
+
+ private final FileService fileService;
+
+ @Operation(summary = "上传图片", description = "上传图片,上传后返回原图和缩略图的url")
+ @PostMapping("/image/upload")
+ public Result uploadImage(@RequestParam("file") MultipartFile file,
+ @RequestParam(defaultValue = "true") Boolean isPermanent) {
+ return ResultUtils.success(fileService.uploadImage(file,isPermanent));
+ }
+
+ @Operation(summary = "上传文件", description = "上传文件,上传后返回文件url")
+ @PostMapping("/file/upload")
+ public Result uploadFile(@RequestParam("file") MultipartFile file) {
+ return ResultUtils.success(fileService.uploadFile(file), Strings.EMPTY);
+ }
+
+}
\ No newline at end of file
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/FriendController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/FriendController.java
new file mode 100644
index 0000000..ebcd8e7
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/FriendController.java
@@ -0,0 +1,65 @@
+package com.ruoyi.web.controller.im;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.ruoyi.basic.service.YjAppUserService;
+import com.ruoyi.common.annotation.RepeatSubmit;
+import com.ruoyi.common.core.domain.entity.AppUser;
+import com.ruoyi.im.domain.vo.FriendVO;
+import com.ruoyi.im.domain.vo.UserVO;
+import com.ruoyi.im.service.FriendService;
+import com.ruoyi.web.controller.im.result.Result;
+import com.ruoyi.web.controller.im.result.ResultUtils;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+
+@RestController
+@RequestMapping("/api/friend")
+@RequiredArgsConstructor
+public class FriendController {
+
+ private final FriendService friendService;
+ private final YjAppUserService appUserService;
+ @GetMapping("/list")
+ @Operation(summary = "好友列表", description = "获取好友列表")
+ public Result> findFriends() {
+ return ResultUtils.success(friendService.findFriends());
+ }
+
+ @GetMapping("/find/{phonenumber}")
+ @Operation(summary = "查找用户", description = "根据电话查找用户")
+ public Result findById(@NotNull @PathVariable("phonenumber") String phonenumber) {
+ //权限:课程顾问 店长 教练 查询客户信息
+ //todo
+ AppUser appUser=appUserService.getOne(new QueryWrapper().eq("phoneNumber",phonenumber));
+ ResultUtils.success(appUser);
+ return null;
+ }
+
+ @RepeatSubmit
+ @PostMapping("/add")
+ @Operation(summary = "添加好友", description = "双方建立好友关系")
+ public Result addFriend(@NotNull(message = "好友id不可为空") @RequestParam Long friendId) {
+ friendService.addFriend(friendId);
+ return ResultUtils.success();
+ }
+
+ @GetMapping("/find/{friendId}")
+ @Operation(summary = "查找好友信息", description = "查找好友信息")
+ public Result findFriend(@NotNull(message = "好友id不可为空") @PathVariable Long friendId) {
+ return ResultUtils.success(friendService.findFriend(friendId));
+ }
+
+
+ @DeleteMapping("/delete/{friendId}")
+ @Operation(summary = "删除好友", description = "解除好友关系")
+ public Result delFriend(@NotNull(message = "好友id不可为空") @PathVariable Long friendId) {
+ friendService.delFriend(friendId);
+ return ResultUtils.success();
+ }
+
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/PrivateMessageController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/PrivateMessageController.java
new file mode 100644
index 0000000..7b58497
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/PrivateMessageController.java
@@ -0,0 +1,73 @@
+package com.ruoyi.web.controller.im;
+
+
+import com.ruoyi.im.domain.dto.PrivateMessageDTO;
+import com.ruoyi.im.domain.vo.FriendVO;
+import com.ruoyi.im.domain.vo.PrivateMessageVO;
+import com.ruoyi.im.service.FriendService;
+import com.ruoyi.im.service.PrivateMessageService;
+import com.ruoyi.web.controller.im.result.Result;
+import com.ruoyi.web.controller.im.result.ResultUtils;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import java.io.IOException;
+import java.util.List;
+
+@Tag(name = "私聊消息")
+@RestController
+@RequestMapping("/api/message/private")
+@RequiredArgsConstructor
+public class PrivateMessageController {
+
+ private final PrivateMessageService privateMessageService;
+
+ @PostMapping("/send")
+ @Operation(summary = "发送消息", description = "发送私聊消息")
+ public Result sendMessage(@Valid @RequestBody PrivateMessageDTO vo) {
+ return ResultUtils.success(privateMessageService.sendMessage(vo));
+ }
+
+ /**
+ *
+ * @param minId 最大已读消息的id
+ * @return
+ */
+ @GetMapping("/pullOfflineMessage")
+ @Operation(summary = "拉取离线消息", description = "拉取离线消息,消息将通过webscoket异步推送")
+ public Result pullOfflineMessage(@RequestParam Long minId) {
+ privateMessageService.pullOfflineMessage(minId);
+ return ResultUtils.success();
+ }
+
+ @PutMapping("/readed")
+ @Operation(summary = "消息已读", description = "将会话中接收的消息状态置为已读")
+ public Result readedMessage(@RequestParam Long friendId) {
+ privateMessageService.readedMessage(friendId);
+ return ResultUtils.success();
+ }
+ @GetMapping("/maxReadedId")
+ @Operation(summary = "获取最大已读消息的id", description = "获取某个会话中已读消息的最大id")
+ public Result getMaxReadedId(@RequestParam Long friendId) {
+ return ResultUtils.success(privateMessageService.getMaxReadedId(friendId));
+ }
+
+// @GetMapping("/history")
+ @Operation(summary = "查询聊天记录", description = "查询聊天记录")
+ public Result> recallMessage(
+ @NotNull(message = "好友id不能为空") @RequestParam Long friendId,
+ @NotNull(message = "页码不能为空") @RequestParam Long page,
+ @NotNull(message = "size不能为空") @RequestParam Long size) {
+ return ResultUtils.success(privateMessageService.findHistoryMessage(friendId, page, size));
+ }
+
+}
+
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/SystemController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/SystemController.java
new file mode 100644
index 0000000..c2496df
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/SystemController.java
@@ -0,0 +1,34 @@
+package com.ruoyi.web.controller.im;
+
+
+import com.ruoyi.common.config.WebrtcConfig;
+import com.ruoyi.im.domain.vo.SystemConfigVO;
+import com.ruoyi.web.controller.im.result.ResultUtils;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.web.controller.im.result.Result;
+/**
+ * @author: blue
+ * @date: 2024-06-10
+ * @version: 1.0
+ */
+@Tag(name = "系统相关")
+@RestController
+@RequestMapping("/system")
+@RequiredArgsConstructor
+public class SystemController {
+
+ private final WebrtcConfig webrtcConfig;
+
+ @GetMapping("/config")
+ @Operation(summary = "加载系统配置", description = "加载系统配置")
+ public Result loadConfig() {
+ return ResultUtils.success(new SystemConfigVO(webrtcConfig));
+ }
+
+
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/WebrtcPrivateController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/WebrtcPrivateController.java
new file mode 100644
index 0000000..b09cdfd
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/WebrtcPrivateController.java
@@ -0,0 +1,76 @@
+package com.ruoyi.web.controller.im;
+
+import com.ruoyi.im.service.WebrtcPrivateService;
+import com.ruoyi.web.controller.im.result.ResultUtils;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+import com.ruoyi.web.controller.im.result.Result;
+
+@Tag(name = "单人通话")
+@RestController
+@RequestMapping("/webrtc/private")
+@RequiredArgsConstructor
+public class WebrtcPrivateController {
+
+ private final WebrtcPrivateService webrtcPrivateService;
+
+
+ @Operation(summary = "呼叫视频通话")
+ @PostMapping("/call")
+ public Result call(@RequestParam Long uid, @RequestParam(defaultValue = "video") String mode,
+ @RequestBody String offer) {
+ webrtcPrivateService.call(uid, mode, offer);
+ return ResultUtils.success();
+ }
+
+ @Operation(summary = "接受视频通话")
+ @PostMapping("/accept")
+ public Result accept(@RequestParam Long uid, @RequestBody String answer) {
+ webrtcPrivateService.accept(uid, answer);
+ return ResultUtils.success();
+ }
+
+ @Operation(summary = "拒绝视频通话")
+ @PostMapping("/reject")
+ public Result reject(@RequestParam Long uid) {
+ webrtcPrivateService.reject(uid);
+ return ResultUtils.success();
+ }
+
+ @Operation(summary = "取消呼叫")
+ @PostMapping("/cancel")
+ public Result cancel(@RequestParam Long uid) {
+ webrtcPrivateService.cancel(uid);
+ return ResultUtils.success();
+ }
+
+ @Operation(summary = "呼叫失败")
+ @PostMapping("/failed")
+ public Result failed(@RequestParam Long uid, @RequestParam String reason) {
+ webrtcPrivateService.failed(uid, reason);
+ return ResultUtils.success();
+ }
+
+ @Operation(summary = "挂断")
+ @PostMapping("/handup")
+ public Result handup(@RequestParam Long uid) {
+ webrtcPrivateService.handup(uid);
+ return ResultUtils.success();
+ }
+
+ @PostMapping("/candidate")
+ @Operation(summary = "同步candidate")
+ public Result candidate(@RequestParam Long uid, @RequestBody String candidate) {
+ webrtcPrivateService.candidate(uid, candidate);
+ return ResultUtils.success();
+ }
+
+ @Operation(summary = "心跳")
+ @PostMapping("/heartbeat")
+ public Result heartbeat(@RequestParam Long uid) {
+ webrtcPrivateService.heartbeat(uid);
+ return ResultUtils.success();
+ }
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/result/Result.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/result/Result.java
new file mode 100644
index 0000000..8d3ff74
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/result/Result.java
@@ -0,0 +1,14 @@
+package com.ruoyi.web.controller.im.result;
+
+import lombok.Data;
+
+@Data
+public class Result {
+
+ private int code;
+
+ private String message;
+
+ private T data;
+
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/result/ResultUtils.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/result/ResultUtils.java
new file mode 100644
index 0000000..1ea96d7
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/result/ResultUtils.java
@@ -0,0 +1,64 @@
+package com.ruoyi.web.controller.im.result;
+
+
+import com.ruoyi.common.im.enums.ResultCode;
+
+public final class ResultUtils {
+
+ private ResultUtils() {
+ }
+
+ public static Result success() {
+ Result result = new Result<>();
+ result.setCode(ResultCode.SUCCESS.getCode());
+ result.setMessage(ResultCode.SUCCESS.getMsg());
+ return result;
+ }
+
+ public static Result success(T data) {
+ Result result = new Result<>();
+ result.setCode(ResultCode.SUCCESS.getCode());
+ result.setMessage(ResultCode.SUCCESS.getMsg());
+ result.setData(data);
+ return result;
+ }
+
+ public static Result success(T data, String messsage) {
+ Result result = new Result<>();
+ result.setCode(ResultCode.SUCCESS.getCode());
+ result.setMessage(messsage);
+ result.setData(data);
+ return result;
+ }
+
+ public static Result success(String messsage) {
+ Result result = new Result<>();
+ result.setCode(ResultCode.SUCCESS.getCode());
+ result.setMessage(messsage);
+ return result;
+ }
+
+ public static Result error(Integer code, String messsage) {
+ Result result = new Result<>();
+ result.setCode(code);
+ result.setMessage(messsage);
+ return result;
+ }
+
+
+ public static Result error(ResultCode resultCode, String messsage) {
+ Result result = new Result<>();
+ result.setCode(resultCode.getCode());
+ result.setMessage(messsage);
+ return result;
+ }
+
+ public static Result error(ResultCode resultCode) {
+ Result result = new Result<>();
+ result.setCode(resultCode.getCode());
+ result.setMessage(resultCode.getMsg());
+ return result;
+ }
+
+
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/session/UserSession.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/session/UserSession.java
new file mode 100644
index 0000000..de9cad1
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/session/UserSession.java
@@ -0,0 +1,21 @@
+package com.ruoyi.web.controller.im.session;
+
+
+import com.ruoyi.common.im.model.IMSessionInfo;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class UserSession extends IMSessionInfo {
+
+ /**
+ * 用户名称
+ */
+ private String userName;
+
+ /**
+ * 用户昵称
+ */
+ private String nickName;
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/session/WebrtcGroupSession.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/session/WebrtcGroupSession.java
new file mode 100644
index 0000000..d13dabd
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/session/WebrtcGroupSession.java
@@ -0,0 +1,34 @@
+package com.ruoyi.web.controller.im.session;
+
+
+import com.ruoyi.common.im.model.IMUserInfo;
+import lombok.Data;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @author: Blue
+ * @date: 2024-06-01
+ * @version: 1.0
+ */
+@Data
+public class WebrtcGroupSession {
+
+ /**
+ * 通话发起者
+ */
+ private IMUserInfo host;
+
+ /**
+ * 所有被邀请的用户列表
+ */
+ private List userInfos;
+
+ /**
+ * 已经进入通话的用户列表
+ */
+ private List inChatUsers = new LinkedList<>();
+
+
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/session/WebrtcPrivateSession.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/session/WebrtcPrivateSession.java
new file mode 100644
index 0000000..215de50
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/session/WebrtcPrivateSession.java
@@ -0,0 +1,39 @@
+package com.ruoyi.web.controller.im.session;
+
+import lombok.Data;
+
+/*
+ * webrtc 会话信息
+ * @Author Blue
+ * @Date 2022/10/21
+ */
+@Data
+public class WebrtcPrivateSession {
+ /**
+ * 发起者id
+ */
+ private Long callerId;
+ /**
+ * 发起者终端类型
+ */
+ private Integer callerTerminal;
+
+ /**
+ * 接受者id
+ */
+ private Long acceptorId;
+
+ /**
+ * 接受者终端类型
+ */
+ private Integer acceptorTerminal;
+
+ /**
+ * 通话模式
+ */
+ private String mode;
+ /**
+ * 开始聊天时间戳
+ */
+ private Long chatTimeStamp;
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/session/WebrtcUserInfo.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/session/WebrtcUserInfo.java
new file mode 100644
index 0000000..4fcb20a
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/im/session/WebrtcUserInfo.java
@@ -0,0 +1,28 @@
+package com.ruoyi.web.controller.im.session;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * @author: Blue
+ * @date: 2024-06-02
+ * @version: 1.0
+ */
+@Data
+@Schema(description = "用户信息")
+public class WebrtcUserInfo {
+ @Schema(description = "用户id")
+ private Long id;
+
+ @Schema(description = "用户昵称")
+ private String nickName;
+
+ @Schema(description = "用户头像")
+ private String headImage;
+
+ @Schema(description = "是否开启摄像头")
+ private Boolean isCamera;
+
+ @Schema(description = "是否开启麦克风")
+ private Boolean isMicroPhone;
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/login/AppLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/login/AppLoginController.java
new file mode 100644
index 0000000..36dec11
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/login/AppLoginController.java
@@ -0,0 +1,143 @@
+package com.ruoyi.web.controller.login;
+
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson2.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.ruoyi.basic.domain.dto.StoreDto;
+import com.ruoyi.basic.mapper.YjStoreMapper;
+import com.ruoyi.basic.service.impl.YjAppUserServiceImpl;
+import com.ruoyi.common.constant.CacheConstants;
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.AppUser;
+import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.core.domain.model.AppUserLoginBody;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.framework.web.service.AppLoginService;
+import com.ruoyi.basic.domain.YjStore;
+import com.ruoyi.basic.service.impl.YjStoreServiceImpl;
+import com.ruoyi.mall.util.PayConstants;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+@Api(tags = "01-登录与验证")
+@RestController
+@RequestMapping("/api")
+public class AppLoginController {
+
+ @Autowired
+ private AppLoginService appLoginService;
+
+ @Autowired
+ private YjAppUserServiceImpl appUserService;
+
+ @Autowired
+ private YjStoreMapper storeMapper;
+
+
+ /**
+ * 注册
+ * @param loginBody
+ * @return
+ */
+ @PostMapping("/register")
+ public AjaxResult register(@RequestBody AppUserLoginBody loginBody){
+ AppUser appUser=new AppUser();
+ appUser.setPhoneNumber("15004070930");
+ appUser.setPassword(SecurityUtils.encryptPassword(loginBody.getPassword()));
+ appUser.setStatus(1);
+ appUser.setVisitStore("14b8471ff004e074e928d795053b4233");
+
+ appUserService.save(appUser);
+ //todo 默认visitstore
+ //todo openid
+
+ return null;
+ }
+
+ /**
+ * 账号密码注册 手机号+验证码+密码
+ * @param loginBody
+ * @return
+ */
+ @ApiOperation("登录")
+ @PostMapping("/login")
+ public AjaxResult login(@RequestBody AppUserLoginBody loginBody){
+ AjaxResult ajax = AjaxResult.success();
+ String token=appLoginService.login(loginBody.getPhonenumber(),loginBody.getPassword(),loginBody.getCode(),loginBody.getUuid(),loginBody.getRegisterId(),loginBody.getMiniAppCode());
+ ajax.put(Constants.TOKEN, token);
+ return ajax;
+ }
+
+ /**
+ * 获取用户信息
+ *
+ * @return 用户信息
+ */
+ @ApiOperation(value = "获取用户信息")
+ @GetMapping("/getInfo")
+ public AjaxResult getInfo()
+ {
+ AppUser user = SecurityUtils.getAppLoginUser().getAppUser();
+ AjaxResult ajax = AjaxResult.success();
+
+ ajax.put("appLoginUser", user);
+ ajax.put("visitStore",getIndex(user.getVisitStore()));
+ return ajax;
+ }
+
+
+ @Resource
+ private YjStoreServiceImpl merchantService;
+
+
+ public Map getIndex(String visitStore){
+ YjStore yjStore;
+ Map m=new HashMap();
+ if (StrUtil.isNotEmpty(visitStore)){
+ yjStore=merchantService.getById(visitStore);
+ }else {
+ yjStore= merchantService.list().get(0);
+ }
+ m.put("address",yjStore.getAddress());
+ m.put("storeName",yjStore.getStoreName());
+ m.put("phone",yjStore.getPhone());
+ m.put("banner",yjStore.getBanner());
+ m.put("id",yjStore.getId());
+ return m;
+ }
+
+
+
+ /**
+ * 用户当前经纬度 用来查附近门店
+ * @param address(未使用,获取全部门店)
+ * @return
+ */
+ @GetMapping("/getStoreList")
+ public AjaxResult getStoreList(String address) {
+
+ AjaxResult ajax = AjaxResult.success();
+ List dtoList= storeMapper.getListForLogin();
+ dtoList.forEach(l->{
+ l.setChildList(storeMapper.getChilds(l.getId()));
+ });
+ ajax.put("storeList",dtoList);
+ return ajax;
+ }
+
+
+
+
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/login/CaptchaController.java
similarity index 91%
rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java
rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/login/CaptchaController.java
index 6b03f19..b7acbbc 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/login/CaptchaController.java
@@ -1,6 +1,9 @@
-package com.ruoyi.web.controller.common;
+package com.ruoyi.web.controller.login;
import com.google.code.kaptcha.Producer;
+import com.ruoyi.basic.domain.YjStore;
+import com.ruoyi.basic.domain.dto.StoreDto;
+import com.ruoyi.basic.mapper.YjStoreMapper;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.constant.Constants;
@@ -16,14 +19,15 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
-import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* 验证码操作处理
- *
+ *
* @author ruoyi
*/
@RestController
@@ -37,14 +41,16 @@ public class CaptchaController
@Autowired
private RedisCache redisCache;
-
+
@Autowired
private ISysConfigService configService;
+
+
/**
* 生成验证码
*/
@GetMapping("/captchaImage")
- public AjaxResult getCode(HttpServletResponse response) throws IOException
+ public AjaxResult getCode() throws IOException
{
AjaxResult ajax = AjaxResult.success();
boolean captchaEnabled = configService.selectCaptchaEnabled();
@@ -92,4 +98,6 @@ public class CaptchaController
ajax.put("img", Base64.encode(os.toByteArray()));
return ajax;
}
+
+
}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/ShopAddressController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/MemberAddressController.java
similarity index 56%
rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/ShopAddressController.java
rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/MemberAddressController.java
index 6bb5cee..bc21359 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app_shop/ShopAddressController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/MemberAddressController.java
@@ -1,21 +1,18 @@
-package com.ruoyi.web.controller.app_shop;
+package com.ruoyi.web.controller.mall;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ruoyi.RestResponse;
-import com.ruoyi.shop.domain.ShopAddress;
-import com.ruoyi.shop.mapper.ShopAddressMapper;
-import com.ruoyi.shop.service.ShopAddressService;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.mall.domain.MemberAddress;
+import com.ruoyi.mall.mapper.MemberAddressMapper;
+import com.ruoyi.mall.service.MemberAddressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
@@ -30,17 +27,22 @@ import java.util.List;
@Api(tags = "用户地址", description = "提供用户地址相关的API")
@RestController
@RequestMapping("/api/address")
-public class ShopAddressController {
+public class MemberAddressController {
@Resource
- private ShopAddressMapper mapper;
+ private MemberAddressMapper mapper;
@Resource
- private ShopAddressService service;
+ private MemberAddressService service;
+ @ApiOperation("地址list")
+ @GetMapping("/addressList")
+ public RestResponse getAddressList(){
+ return new RestResponse().setSuccess(true).setData(service.getAddressList());
+ }
@ApiOperation("新增收货地址")
@PostMapping("/add")
- public RestResponse add(@RequestBody ShopAddress address, HttpServletRequest request){
- Long userId= Long.parseLong(request.getAttribute("userId").toString());
+ public RestResponse add(@RequestBody MemberAddress address){
+ Long userId= SecurityUtils.getAppLoginUser().getAppUser().getId();
address.setUserId(userId);
if (address.getIsDefault()){
changeDefault(userId);
@@ -50,13 +52,13 @@ public class ShopAddressController {
}
@ApiOperation("收货地址列表")
- @PostMapping("/list")
- public RestResponse list(HttpServletRequest request){
- Long userId= Long.parseLong(request.getAttribute("userId").toString());
+ @PostMapping("/memberAddressList")
+ public RestResponse list(){
+ Long userId= SecurityUtils.getAppLoginUser().getAppUser().getId();
List columns=new ArrayList<>();
columns.add("add_time");
columns.add("is_default");
- List list=mapper.selectList(new QueryWrapper()
+ List list=mapper.selectList(new QueryWrapper()
.eq("user_id",userId)
.orderByDesc(columns));
return new RestResponse().setSuccess(true).setMessage("成功").setData(list);
@@ -64,8 +66,8 @@ public class ShopAddressController {
@ApiOperation("修改收货地址")
@PostMapping("/edit")
- public RestResponse edit(@RequestBody ShopAddress address, HttpServletRequest request){
- Long userId= Long.parseLong(request.getAttribute("userId").toString());
+ public RestResponse edit(@RequestBody MemberAddress address){
+ Long userId= SecurityUtils.getAppLoginUser().getAppUser().getId();
if (address.getIsDefault()){
changeDefault(userId);
}
@@ -75,13 +77,16 @@ public class ShopAddressController {
@ApiOperation("删除收货地址")
@PostMapping("/del")
- public RestResponse del(@RequestBody ShopAddress address){
+ public RestResponse del(@RequestBody MemberAddress address){
mapper.deleteById(address.getId());
return new RestResponse().setSuccess(true).setMessage("成功");
}
public void changeDefault(Long userId){
- service.update(new UpdateWrapper().set("is_default",false).eq("user_id",userId));
+ service.update(new UpdateWrapper().set("is_default",false).eq("user_id",userId));
}
+
+
+
}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/MemberCartController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/MemberCartController.java
new file mode 100644
index 0000000..c52f79e
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/MemberCartController.java
@@ -0,0 +1,88 @@
+package com.ruoyi.web.controller.mall;
+
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.mall.domain.MemberCart;
+import com.ruoyi.mall.domain.query.MemberCartQuery;
+import com.ruoyi.mall.domain.vo.MemberCartVO;
+import com.ruoyi.mall.service.impl.MemberCartService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/api/cart")
+public class MemberCartController {
+ @Autowired
+ private MemberCartService memberCartService;
+
+ /**
+ * 添加购物车
+ *
+ * @return 购物车商品
+ */
+ @PostMapping("add")
+ public ResponseEntity add(@RequestBody MemberCart memberCart) {
+ return ResponseEntity.ok(memberCartService.insert(memberCart));
+ }
+
+ /**
+ * 购物车列表
+ *
+ * @return 购物车列表
+ */
+ @GetMapping("list")
+ public ResponseEntity> list() {
+ MemberCartQuery query = new MemberCartQuery();
+ query.setMemberId(SecurityUtils.getAppLoginUser().getAppUserId());
+ return ResponseEntity.ok(memberCartService.selectList(query, null));
+ }
+
+ /**
+ * 当前用户的购物车商品数量
+ *
+ * @return
+ */
+ @GetMapping("goodscount")
+ public ResponseEntity goodscount() {
+ return ResponseEntity.ok(memberCartService.mineCartNum());
+ }
+ /**
+ * 当前用户的购物车商品id列表
+ *
+ * @return
+ */
+ @GetMapping("cart-ids")
+ public ResponseEntity> cartIds() {
+ return ResponseEntity.ok(memberCartService.mineCartIds());
+ }
+
+
+
+ /**
+ * 修改购物车
+ *
+ * @return 是否修改
+ */
+ @PostMapping("modify")
+ public ResponseEntity modify(@Valid @RequestBody MemberCart memberCart) {
+ return ResponseEntity.ok(memberCartService.update(memberCart));
+ }
+
+ /**
+ * 删除购物车商品
+ *
+ * @return
+ */
+ @DeleteMapping("remove")
+ public ResponseEntity remove(@RequestBody Map> map) {
+ List ids=map.get("ids");
+ return ResponseEntity.ok(memberCartService.deleteByIds(ids));
+ }
+
+
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/OrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/OrderController.java
new file mode 100644
index 0000000..b7c8a24
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/OrderController.java
@@ -0,0 +1,246 @@
+package com.ruoyi.web.controller.mall;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.redis.RedisService;
+import com.ruoyi.common.enums.AftersaleStatus;
+import com.ruoyi.common.enums.OrderStatus;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.mall.domain.dto.DeliveryReq;
+import com.ruoyi.mall.domain.form.*;
+import com.ruoyi.mall.domain.order.Aftersale;
+import com.ruoyi.mall.domain.order.Order;
+import com.ruoyi.mall.domain.vo.*;
+import com.ruoyi.mall.service.impl.AftersaleService;
+import com.ruoyi.mall.service.impl.OrderService;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.PageImpl;
+import org.springframework.data.domain.Pageable;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+
+@RestController
+@RequestMapping("/api/order")
+@Slf4j
+public class OrderController {
+ @Autowired
+ private RedisService redisService;
+ @Autowired
+ private OrderService service;
+ @Autowired
+ private AftersaleService aftersaleService;
+
+ @ApiOperation("下单")
+ @PostMapping("/add")
+ public ResponseEntity submit(@RequestBody OrderSubmitForm form) {
+ Long memberId = SecurityUtils.getAppLoginUser().getAppUserId();
+ String redisKey = "app_order_add" + memberId;
+ String redisValue = memberId + "_" + System.currentTimeMillis();
+ try{
+ redisService.lock(redisKey, redisValue, 60);
+ return ResponseEntity.ok(service.submit(form));
+ }catch (Exception e){
+ log.info("创建订单方法异常", e);
+ throw new RuntimeException(e.getMessage());
+ }finally {
+ try {
+ redisService.unLock(redisKey, redisValue);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @ApiOperation("下单前校验")
+ @PostMapping("/addOrderCheck")
+ public ResponseEntity addOrderCheck(@RequestBody OrderCreateForm orderCreateForm){
+ return ResponseEntity.ok(service.addOrderCheck(orderCreateForm));
+ }
+
+ @ApiOperation("订单支付")
+ @PostMapping("/orderPay")
+ public ResponseEntity orderPay(@RequestBody OrderPayForm req){
+ log.info("订单支付","提交的数据:"+ JSONObject.toJSONString(req));
+ String redisKey = "app_oms_order_pay_"+req.getPayId();
+ String redisValue = req.getPayId()+"_"+System.currentTimeMillis();
+ try {
+ redisService.lock(redisKey, redisValue, 60);
+
+ req.setMemberId(SecurityUtils.getAppLoginUser().getAppUserId());
+ return ResponseEntity.ok(service.orderPay(req));
+ }catch (Exception e){
+ log.error("支付方法异常", e);
+ throw new RuntimeException(e.getMessage());
+ }finally {
+ try{
+ redisService.unLock(redisKey,redisValue);
+ }catch (Exception e){
+ log.error("",e);
+ }
+ }
+ }
+
+ @ApiOperation("订单列表")
+ @GetMapping("/page")
+ public ResponseEntity> orderPage(Integer status, Pageable pageable){
+ return ResponseEntity.ok(service.orderPage(status, SecurityUtils.getAppLoginUser().getAppUserId(), pageable));
+ }
+
+ @ApiOperation("订单详情")
+ @GetMapping("/orderDetail")
+ public ResponseEntity orderDetail(@RequestParam(required = false) Long orderId){
+ if (orderId == null){
+ throw new RuntimeException("系统繁忙");
+ }
+ return ResponseEntity.ok(service.orderDetail(orderId));
+ }
+
+ @ApiOperation("确认收货")
+ @GetMapping("/orderComplete")
+ public ResponseEntity orderComplete(Long orderId) {
+ log.info("确认收货,订单id:"+orderId);
+ String redisKey = "app_oms_order_complete_"+orderId;
+ String redisValue = orderId+"_"+System.currentTimeMillis();
+ try{
+ redisService.lock(redisKey,redisValue,60);
+ return ResponseEntity.ok(service.orderComplete(orderId));
+ }catch (Exception e){
+ log.error("确认收货异常",e);
+ throw new RuntimeException(e.getMessage());
+ }finally {
+ try{
+ redisService.unLock(redisKey,redisValue);
+ }catch (Exception e){
+ log.error("",e);
+ }
+ }
+ }
+
+ @ApiOperation("订单数量统计")
+ @GetMapping("/countOrder")
+ public ResponseEntity orderNumCount(){
+ Long memberId = SecurityUtils.getAppLoginUser().getAppUserId();
+ return ResponseEntity.ok(service.orderNumCount(memberId));
+ }
+
+ @ApiOperation("取消订单")
+ @PostMapping("/orderCancel")
+ public ResponseEntity orderCancel(@RequestBody CancelOrderForm request){
+ String redisKey = "app_oms_order_cancel_"+ request.getIdList().get(0);
+ String redisValue = request.getIdList().get(0)+"_"+System.currentTimeMillis();
+ try{
+ redisService.lock(redisKey,redisValue,60);
+ return ResponseEntity.ok(service.orderBatchCancel(request, SecurityUtils.getAppLoginUser().getAppUserId()));
+ }catch (Exception e){
+ log.error("订单取消方法异常",e);
+ throw new RuntimeException("订单取消失败");
+ }finally {
+ try {
+ redisService.unLock(redisKey,redisValue);
+ }catch (Exception e){
+ log.error("",e);
+ }
+ }
+ }
+
+
+
+ @ApiOperation("申请售后")
+ @PostMapping("/applyRefund")
+ public ResponseEntity applyRefund(@RequestBody ApplyRefundForm applyRefundForm){
+ String redisKey = "app_oms_order_applyRefund_" + applyRefundForm.getOrderId();
+ String redisValue = applyRefundForm.getOrderId() + "_" + System.currentTimeMillis();
+ try{
+ redisService.lock(redisKey, redisValue, 60);
+ Order order = service.applyRefund(applyRefundForm);
+ // 如果是未发货,系统自动退款
+ if (order.getStatus().equals(OrderStatus.NOT_DELIVERED.getType())) {
+ DealWithAftersaleForm req = new DealWithAftersaleForm();
+ req.setOrderId(applyRefundForm.getOrderId());
+ req.setOptType(1);
+ aftersaleService.dealWith(req, order.getMemberId(), "直接发起退款");
+ }
+ return ResponseEntity.ok(true);
+ }catch (Exception e){
+ log.error("申请售后发生异常",e);
+ throw new RuntimeException(e.getMessage());
+ }finally {
+ try {
+ redisService.unLock(redisKey, redisValue);
+ } catch (Exception e) {
+ log.error("", e);
+ }
+ }
+ }
+
+ @ApiOperation("取消售后")
+ @GetMapping("/cancelRefund")
+ public ResponseEntity cancelRefund(Long orderId){
+ log.info("【取消售后】订单id:" + orderId);
+ String redisKey = "app_oms_order_cancelRefund_" + orderId;
+ String redisValue = orderId + "_" + System.currentTimeMillis();
+ try{
+ redisService.lock(redisKey, redisValue, 60);
+ return ResponseEntity.ok(service.cancelRefund(orderId));
+ }catch (Exception e){
+ log.error("取消售后发生异常",e);
+ throw new RuntimeException(e.getMessage());
+ }finally {
+ try {
+ redisService.unLock(redisKey, redisValue);
+ } catch (Exception e) {
+ log.error("", e);
+ }
+ }
+ }
+
+ @ApiOperation("售后订单详情")
+ @GetMapping("/refundOrderDetail")
+ public ResponseEntity refundOrderDetail(@RequestParam Long orderId){
+ return ResponseEntity.ok(service.refundOrderDetail(orderId));
+ }
+
+ @ApiOperation("用户提交退货单号")
+ @PostMapping("/aftersale/delivery")
+ public AjaxResult delivery(@RequestBody @Valid DeliveryReq req){
+ log.info("用户提交退货单号","提交的数据:"+JSONObject.toJSONString(req));
+ String redisKey = "app_oms_order_delivery_"+req.getOrderId();
+ String redisValue = req.getOrderId()+"_"+System.currentTimeMillis();
+ try {
+ redisService.lock(redisKey, redisValue, 60);
+ Order order = service.selectById(req.getOrderId());
+ Aftersale aftersale = aftersaleService.queryAfterSale(req.getOrderId());
+ if(order == null || aftersale == null){
+ return AjaxResult.error("未查询到订单信息");
+ }
+ //仅退款不需要退货
+ if(aftersale.getType() == 1){
+ return AjaxResult.error("仅退款不需要退货");
+ }
+ if(aftersale.getStatus() != AftersaleStatus.WAIT.getType()){
+ return AjaxResult.error("当前状态不可退货");
+ }
+ //更新退款单
+ aftersale.setRefundWpCode(req.getDeliveryCompanyCode());
+ aftersale.setRefundWaybillCode(req.getDeliverySn());
+ aftersaleService.update(aftersale);
+
+ return AjaxResult.success();
+ }catch (Exception e){
+ log.error("用户提交退货单号异常", e);
+ return AjaxResult.error("提交发货信息失败");
+ }finally {
+ try{
+ redisService.unLock(redisKey,redisValue);
+ }catch (Exception e){
+ log.error("",e);
+ }
+ }
+ }
+
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/PayNotifyController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/PayNotifyController.java
new file mode 100644
index 0000000..11577eb
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/PayNotifyController.java
@@ -0,0 +1,143 @@
+package com.ruoyi.web.controller.mall;
+
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson2.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.ruoyi.mall.domain.dto.PayNotifyMessageDTO;
+import com.ruoyi.mall.service.impl.OrderService;
+import com.ruoyi.web.core.config.WechatPayConfig;
+import com.wechat.pay.java.core.Config;
+import com.wechat.pay.java.core.notification.NotificationConfig;
+import com.wechat.pay.java.core.notification.NotificationParser;
+import com.wechat.pay.java.core.notification.RequestParam;
+import com.wechat.pay.java.service.partnerpayments.jsapi.model.Transaction;
+import com.wechat.pay.java.service.refund.model.RefundNotification;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 订单表Controller
+ *
+ * @author sjm
+ * @date 2023-04-05
+ */
+@Api(description ="微信回调接口列表")
+@RestController
+@RequestMapping("/no-auth/wechat")
+public class PayNotifyController {
+ private static final Logger log = LoggerFactory.getLogger(PayNotifyController.class);
+
+ @Autowired
+ private OrderService OrderService;
+// @Autowired
+// private AftersaleService aftersaleService;
+
+ private final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
+
+ /**
+ * 微信支付回调
+ * @param request
+ * @throws IOException
+ */
+ @PostMapping("/notify")
+ public void weChatPayNotify(HttpServletRequest request) throws Exception {
+ log.info("收到了微信支付回调");
+ // 从请求头中获取信息
+ String timestamp = request.getHeader("Wechatpay-Timestamp");
+ String nonce = request.getHeader("Wechatpay-Nonce");
+ String signature = request.getHeader("Wechatpay-Signature");
+ String singType = request.getHeader("Wechatpay-Signature-Type");
+ String wechatPayCertificateSerialNumber = request.getHeader("Wechatpay-Serial");
+ // 拿到请求体body
+ StringBuilder requestBody = new StringBuilder();
+ String line;
+ BufferedReader reader;
+ reader = request.getReader();
+ while (null != (line = reader.readLine())) {
+ requestBody.append(line);
+ }
+ // 构造 RequestParam
+ RequestParam requestParam = new RequestParam.Builder()
+ .serialNumber(wechatPayCertificateSerialNumber)
+ .nonce(nonce)
+ .signature(signature)
+ .timestamp(timestamp)
+ .body(requestBody.toString())
+ .build();
+// log.info("【requestParam】" + JSONObject.toJSON(requestParam));
+ //初始化了 RSAAutoCertificateConfig
+ Config config = WechatPayConfig.getInstance();
+ // 初始化解析器 NotificationParser
+ NotificationParser parser = new NotificationParser((NotificationConfig) config);
+ // 以支付通知回调为例,验签、解密并转换成 Transaction
+ Transaction transaction = parser.parse(requestParam, Transaction.class);
+// log.info("【transaction】" + JSONObject.toJSON(transaction));
+ PayNotifyMessageDTO message = new PayNotifyMessageDTO();
+ message.setOutTradeNo(Long.valueOf(transaction.getOutTradeNo()));
+ message.setMemberId(Long.valueOf(transaction.getAttach()));
+ message.setTradeStatus(transaction.getTradeState());
+ if (StrUtil.isEmpty(transaction.getSuccessTime())){
+ throw new RuntimeException("微信支付回调失败");
+ }
+ message.setPayTime(formatter.parse(transaction.getSuccessTime().substring(0, transaction.getSuccessTime().indexOf("+"))));
+ message.setTradeNo(transaction.getTransactionId());
+// OrderService.payCallBack(message);
+ }
+
+
+// @ApiOperation(value = "微信退款回调")
+// @PostMapping("/weChatRefundNotify")
+// public void weChatRefundNotify(HttpServletRequest request) throws IOException {
+// log.info("收到了微信支付退款回调");
+// // 从请求头中获取信息
+// String timestamp = request.getHeader("Wechatpay-Timestamp");
+// String nonce = request.getHeader("Wechatpay-Nonce");
+// String signature = request.getHeader("Wechatpay-Signature");
+// String singType = request.getHeader("Wechatpay-Signature-Type");
+// String wechatPayCertificateSerialNumber = request.getHeader("Wechatpay-Serial");
+// // 拿到请求体body
+// StringBuilder requestBody = new StringBuilder();
+// String line;
+// BufferedReader reader;
+// reader = request.getReader();
+// while (null != (line = reader.readLine())) {
+// requestBody.append(line);
+// }
+// // 构造 RequestParam
+// RequestParam requestParam = new RequestParam.Builder()
+// .serialNumber(wechatPayCertificateSerialNumber)
+// .nonce(nonce)
+// .signature(signature)
+// .timestamp(timestamp)
+// .body(requestBody.toString())
+// .build();
+//
+// log.info("【requestParam】" + JSONObject.toJSON(requestParam));
+// //初始化了 RSAAutoCertificateConfig
+// Config config = WechatPayConfig.getInstance();
+// // 初始化解析器 NotificationParser
+// NotificationParser parser = new NotificationParser((NotificationConfig) config);
+//
+// //获取退款回调的信息
+// RefundNotification refundInfo = parser.parse(requestParam, RefundNotification.class);
+// aftersaleService.refundOrderExc(refundInfo);
+// }
+
+
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/ProductController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/ProductController.java
new file mode 100644
index 0000000..0b94721
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mall/ProductController.java
@@ -0,0 +1,86 @@
+package com.ruoyi.web.controller.mall;
+
+
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.ruoyi.RestResponse;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.mall.domain.MemberAddress;
+import com.ruoyi.mall.domain.Product;
+import com.ruoyi.mall.domain.query.ProductQuery;
+import com.ruoyi.mall.domain.vo.AppProductVO;
+import com.ruoyi.mall.domain.vo.ProductDetailVO;
+import com.ruoyi.mall.domain.vo.ProductVO;
+import com.ruoyi.mall.mapper.MemberAddressMapper;
+import com.ruoyi.mall.service.MemberAddressService;
+import com.ruoyi.mall.service.ProductCategoryService;
+import com.ruoyi.mall.service.impl.ProductService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageImpl;
+import org.springframework.data.domain.Pageable;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ * 用户地址 前端控制器
+ *
+ *
+ * @author xn
+ * @since 2022-09-29
+ */
+@Api(tags = "app商品信息")
+@RestController
+@RequestMapping("/api/product")
+public class ProductController {
+
+ @Autowired
+ private ProductCategoryService categoryService;
+ @Autowired
+ private ProductService productService;
+
+ /**
+ * 商品页分类list
+ * @return
+ */
+ @ApiOperation("商品类别")
+ @PostMapping("/categoryList")
+ public RestResponse getAddressList(@RequestBody Map params){
+ return new RestResponse().setSuccess(true).setData(categoryService.getProductCategorys(params));
+ }
+
+ /**
+ * 商品搜索
+ * @param query {categoryId:分类;search:名称;} null:全部商品
+ * @param page
+ * @return
+ */
+ @PostMapping("/list")
+ public ResponseEntity> queryGoodByPage(@RequestBody ProductQuery query, Pageable page) {
+ List pageRes = productService.selectList(query, page);
+ return ResponseEntity.ok(new PageImpl<>(BeanUtil.copyToList(pageRes,AppProductVO.class), page, ((com.github.pagehelper.Page) pageRes).getTotal()));
+ }
+
+ /**
+ * 商品详情
+ * @param id
+ * @return
+ */
+ @GetMapping("/detail/{id}")
+ public ResponseEntity queryDetail(@PathVariable Long id) {
+ ProductDetailVO detail = productService.queryDetail(id);
+ return ResponseEntity.ok(detail);
+ }
+
+
+}
+
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java
deleted file mode 100644
index 69470d0..0000000
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java
+++ /dev/null
@@ -1,120 +0,0 @@
-package com.ruoyi.web.controller.monitor;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.RedisCallback;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.ruoyi.common.constant.CacheConstants;
-import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.system.domain.SysCache;
-
-/**
- * 缓存监控
- *
- * @author ruoyi
- */
-@RestController
-@RequestMapping("/monitor/cache")
-public class CacheController
-{
- @Autowired
- private RedisTemplate redisTemplate;
-
- private final static List caches = new ArrayList();
- {
- caches.add(new SysCache(CacheConstants.LOGIN_TOKEN_KEY, "用户信息"));
- caches.add(new SysCache(CacheConstants.SYS_CONFIG_KEY, "配置信息"));
- caches.add(new SysCache(CacheConstants.SYS_DICT_KEY, "数据字典"));
- caches.add(new SysCache(CacheConstants.CAPTCHA_CODE_KEY, "验证码"));
- caches.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "防重提交"));
- caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理"));
- caches.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "密码错误次数"));
- }
-
- @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
- @GetMapping()
- public AjaxResult getInfo() throws Exception
- {
- Properties info = (Properties) redisTemplate.execute((RedisCallback