新增预约订单退款,新增我的预约

This commit is contained in:
cjw 2024-10-15 15:03:37 +08:00
parent 40b8645d39
commit 5f5218181f
20 changed files with 508 additions and 11 deletions

View File

@ -107,7 +107,7 @@ public class CounselorController extends BaseController {
}
/**
* 查询心理咨询师列表
* 查询心理咨询师预约列表
*/
@SaCheckPermission("counselor:reservation:list")
@GetMapping("/reservation/list")

View File

@ -0,0 +1,68 @@
package org.dromara.scale.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.dromara.scale.domain.bo.ReservationRefundBo;
import org.dromara.scale.domain.vo.ReservationRefundVo;
import org.dromara.scale.service.IReservationRefundService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 预约退款
*
* @author cjw
* @date 2024-10-15
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/scale/reservationRefund")
public class ReservationRefundController extends BaseController {
private final IReservationRefundService reservationRefundService;
/**
* 查询预约退款列表
*/
@SaCheckPermission("reservation:refund:list")
@GetMapping("/list")
public TableDataInfo<ReservationRefundVo> list(ReservationRefundBo bo, PageQuery pageQuery) {
return reservationRefundService.queryPageList(bo, pageQuery);
}
/**
* 导出预约退款列表
*/
@SaCheckPermission("reservation:refund:export")
@Log(title = "预约退款", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(ReservationRefundBo bo, HttpServletResponse response) {
List<ReservationRefundVo> list = reservationRefundService.queryList(bo);
ExcelUtil.exportExcel(list, "预约退款", ReservationRefundVo.class, response);
}
/**
* 获取预约退款详细信息
*
* @param id 主键
*/
@SaCheckPermission("reservation:refund:query")
@GetMapping("/{id}")
public R<ReservationRefundVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(reservationRefundService.queryById(id));
}
}

View File

@ -76,6 +76,7 @@ public class WxMyController extends BaseController {
*/
@GetMapping("/intervene/pageList")
public TableDataInfo<ReservationOrderVo> list(ReservationOrderBo bo, PageQuery pageQuery) {
bo.setOrderStatus(2);
return myService.queryReservationPageList(bo, pageQuery);
}
@ -95,6 +96,14 @@ public class WxMyController extends BaseController {
return myService.queryPersonalEvaluationRecordPageList(pageQuery);
}
/**
* 查询我的咨询
*/
@GetMapping("/reservation/pageList")
public TableDataInfo<ReservationOrderVo> reservationList(ReservationOrderBo bo,PageQuery pageQuery) {
return myService.queryReservationPageList(bo, pageQuery);
}
/**
* 获取档案静态列表
*/

View File

@ -14,10 +14,12 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.web.core.BaseController;
import org.dromara.scale.domain.bo.ReservationOrderBo;
import org.dromara.scale.domain.bo.ReservationRefundBo;
import org.dromara.scale.domain.bo.SysScaleOrderBo;
import org.dromara.scale.domain.vo.ReservationOrderVo;
import org.dromara.scale.domain.vo.SysScaleOrderVo;
import org.dromara.scale.service.IReservationOrderService;
import org.dromara.scale.service.IReservationRefundService;
import org.dromara.scale.service.ISysScaleOrderService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -36,6 +38,7 @@ public class WxOrderController extends BaseController {
private final ISysScaleOrderService scaleOrderService;
private final IReservationOrderService reservationOrderService;
private final IReservationRefundService reservationRefundService;
/**
* 查询量表订单列表
@ -114,4 +117,19 @@ public class WxOrderController extends BaseController {
@PathVariable Long id) {
return R.ok(reservationOrderService.queryById(id));
}
/**
* 退款申请
*
* @param bo
* @return
*/
@Log(title = "退款申请", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping("/reservation/refund")
public R<Void> addRefund(@RequestBody ReservationRefundBo bo) throws Exception {
return toAjax(reservationRefundService.insertByBo(bo));
}
}

View File

@ -41,16 +41,14 @@ public class WxPayController {
public String parseScaleNotifyResult(@RequestBody String xmlData) throws WxPayException {
log.info("---------量表支付回调-----------------");
final WxPayOrderNotifyResult notifyResult = this.payService.parseOrderNotifyResult(xmlData);
String outTradeNo = notifyResult.getOutTradeNo();
scaleOrderService.processOrder(outTradeNo);
scaleOrderService.processOrder(notifyResult);
return WxPayNotifyResponse.success("成功");
}
@PostMapping("/notify/order/reservation")
public String parseReservationNotifyResult(@RequestBody String xmlData) throws WxPayException {
final WxPayOrderNotifyResult notifyResult = this.payService.parseOrderNotifyResult(xmlData);
String outTradeNo = notifyResult.getOutTradeNo();
reservationOrderService.processOrder(outTradeNo);
reservationOrderService.processOrder(notifyResult);
return WxPayNotifyResponse.success("成功");
}
}

View File

@ -23,7 +23,7 @@ public class ReservationOrder extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
*
*
*/
@TableId(value = "id")
private Long id;
@ -38,6 +38,8 @@ public class ReservationOrder extends BaseEntity {
*/
private Long counselorId;
private String transactionId;
/**
* 订单价格
*/

View File

@ -0,0 +1,51 @@
package org.dromara.scale.domain;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
/**
* 预约退款对象 m_reservation_refund
*
* @author cjw
* @date 2024-10-15
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("m_reservation_refund")
public class ReservationRefund extends BaseEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(value = "id")
private Long id;
/**
* 订单号
*/
private Long orderId;
/**
* 申请人
*/
private Long userId;
/**
* 退款原因
*/
private String refundDesc;
/**
* 退款状态
*/
private Integer status;
}

View File

@ -35,6 +35,8 @@ public class SysScaleOrder extends TenantEntity {
private Long recordId;
private String transactionId;
/**
* 订单价格
*/

View File

@ -0,0 +1,54 @@
package org.dromara.scale.domain.bo;
import org.dromara.scale.domain.ReservationRefund;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
/**
* 预约退款业务对象 m_reservation_refund
*
* @author cjw
* @date 2024-10-15
*/
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = ReservationRefund.class, reverseConvertGenerate = false)
public class ReservationRefundBo extends BaseEntity {
/**
*
*/
@NotNull(message = "不能为空", groups = { EditGroup.class })
private Long id;
/**
* 订单号
*/
@NotNull(message = "订单号不能为空", groups = { AddGroup.class, EditGroup.class })
private Long orderId;
/**
* 申请人
*/
@NotNull(message = "申请人不能为空", groups = { AddGroup.class, EditGroup.class })
private Long userId;
/**
* 退款原因
*/
@NotBlank(message = "退款原因不能为空", groups = { AddGroup.class, EditGroup.class })
private String refundDesc;
/**
* 退款状态
*/
@NotNull(message = "退款状态不能为空", groups = { AddGroup.class, EditGroup.class })
private Integer status;
}

View File

@ -45,6 +45,8 @@ public class ReservationOrderVo implements Serializable {
@AutoMapping(target = "counselorId")
private Long counselorName;
private String transactionId;
/**
* 订单价格
*/

View File

@ -0,0 +1,58 @@
package org.dromara.scale.domain.vo;
import org.dromara.scale.domain.ReservationRefund;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
/**
* 预约退款视图对象 m_reservation_refund
*
* @author cjw
* @date 2024-10-15
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = ReservationRefund.class)
public class ReservationRefundVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
*
*/
@ExcelProperty(value = "")
private Long id;
/**
* 订单号
*/
@ExcelProperty(value = "订单号")
private Long orderId;
/**
* 申请人
*/
@ExcelProperty(value = "申请人")
private Long userId;
/**
* 退款原因
*/
@ExcelProperty(value = "退款原因")
private String refundDesc;
/**
* 退款状态
*/
@ExcelProperty(value = "退款状态")
private Integer status;
}

View File

@ -0,0 +1,17 @@
package org.dromara.scale.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.dromara.scale.domain.ReservationRefund;
import org.dromara.scale.domain.vo.ReservationRefundVo;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
/**
* 预约退款Mapper接口
*
* @author cjw
* @date 2024-10-15
*/
@Mapper
public interface ReservationRefundMapper extends BaseMapperPlus<ReservationRefund, ReservationRefundVo> {
}

View File

@ -1,5 +1,6 @@
package org.dromara.scale.service;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
@ -49,6 +50,7 @@ public interface IReservationOrderService {
*/
WxPayMpOrderResult insertByBo(ReservationOrderBo bo) throws Exception;
Boolean processOrder(String orderId);
Boolean processOrder(WxPayOrderNotifyResult notifyResult);
}

View File

@ -0,0 +1,59 @@
package org.dromara.scale.service;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.scale.domain.bo.ReservationRefundBo;
import org.dromara.scale.domain.vo.ReservationRefundVo;
import java.util.List;
/**
* 预约退款Service接口
*
* @author cjw
* @date 2024-10-15
*/
public interface IReservationRefundService {
/**
* 查询预约退款
*
* @param id 主键
* @return 预约退款
*/
ReservationRefundVo queryById(Long id);
/**
* 分页查询预约退款列表
*
* @param bo 查询条件
* @param pageQuery 分页参数
* @return 预约退款分页列表
*/
TableDataInfo<ReservationRefundVo> queryPageList(ReservationRefundBo bo, PageQuery pageQuery);
/**
* 查询符合条件的预约退款列表
*
* @param bo 查询条件
* @return 预约退款列表
*/
List<ReservationRefundVo> queryList(ReservationRefundBo bo);
/**
* 新增预约退款
*
* @param bo 预约退款
* @return 是否新增成功
*/
Boolean insertByBo(ReservationRefundBo bo);
/**
* 修改预约退款
*
* @param bo 预约退款
* @return 是否修改成功
*/
Boolean updateByBo(ReservationRefundBo bo);
}

View File

@ -1,5 +1,6 @@
package org.dromara.scale.service;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
@ -50,7 +51,7 @@ public interface ISysScaleOrderService {
WxPayMpOrderResult insertByBo(SysScaleOrderBo bo) throws Exception;
Boolean processOrder(String orderId);
Boolean processOrder(WxPayOrderNotifyResult notifyResult);

View File

@ -123,7 +123,9 @@ public class MyServiceImpl implements IMyService {
public TableDataInfo<ReservationOrderVo> queryReservationPageList(ReservationOrderBo bo, PageQuery pageQuery) {
Long userId = LoginHelper.getUserId();
IPage<ReservationOrderVo> page = reservationOrderMapper.selectVoPage(pageQuery.build(),
new LambdaQueryWrapper<ReservationOrder>().eq(ReservationOrder::getCreateBy, userId));
new LambdaQueryWrapper<ReservationOrder>()
.eq(ReservationOrder::getCreateBy, userId)
.eq(bo.getOrderStatus() != null, ReservationOrder::getOrderStatus, bo.getOrderStatus()));
return TableDataInfo.build(page);
}

View File

@ -3,6 +3,7 @@ package org.dromara.scale.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
import com.github.binarywang.wxpay.service.WxPayService;
@ -130,7 +131,9 @@ public class ReservationOrderServiceImpl implements IReservationOrderService {
}
@Override
public Boolean processOrder(String orderId) {
public Boolean processOrder(WxPayOrderNotifyResult notifyResult) {
String orderId = notifyResult.getOutTradeNo();
String transactionId = notifyResult.getTransactionId();
long id = Long.parseLong(orderId);
ReservationOrder reservationOrder = baseMapper.selectById(id);
Long timeId = reservationOrder.getTimeId();
@ -145,8 +148,10 @@ public class ReservationOrderServiceImpl implements IReservationOrderService {
ReservationOrder order = new ReservationOrder();
order.setId(id);
order.setOrderStatus(1);
order.setTransactionId(transactionId);
order.setUpdateBy(userId);
boolean orderFlag = baseMapper.updateById(order) > 0;
return timeFlag && orderFlag;
}
}

View File

@ -0,0 +1,138 @@
package org.dromara.scale.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.scale.domain.ReservationOrder;
import org.dromara.scale.domain.ReservationRefund;
import org.dromara.scale.domain.bo.ReservationRefundBo;
import org.dromara.scale.domain.vo.ReservationRefundVo;
import org.dromara.scale.mapper.ReservationOrderMapper;
import org.dromara.scale.mapper.ReservationRefundMapper;
import org.dromara.scale.service.IReservationRefundService;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* 预约退款Service业务层处理
*
* @author cjw
* @date 2024-10-15
*/
@RequiredArgsConstructor
@Service
public class ReservationRefundServiceImpl implements IReservationRefundService {
private final ReservationRefundMapper baseMapper;
private final ReservationOrderMapper orderMapper;
/**
* 查询预约退款
*
* @param id 主键
* @return 预约退款
*/
@Override
public ReservationRefundVo queryById(Long id){
return baseMapper.selectVoById(id);
}
/**
* 分页查询预约退款列表
*
* @param bo 查询条件
* @param pageQuery 分页参数
* @return 预约退款分页列表
*/
@Override
public TableDataInfo<ReservationRefundVo> queryPageList(ReservationRefundBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<ReservationRefund> lqw = buildQueryWrapper(bo);
Page<ReservationRefundVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
* 查询符合条件的预约退款列表
*
* @param bo 查询条件
* @return 预约退款列表
*/
@Override
public List<ReservationRefundVo> queryList(ReservationRefundBo bo) {
LambdaQueryWrapper<ReservationRefund> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<ReservationRefund> buildQueryWrapper(ReservationRefundBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<ReservationRefund> lqw = Wrappers.lambdaQuery();
lqw.eq(bo.getOrderId() != null, ReservationRefund::getOrderId, bo.getOrderId());
lqw.eq(bo.getUserId() != null, ReservationRefund::getUserId, bo.getUserId());
lqw.eq(StringUtils.isNotBlank(bo.getRefundDesc()), ReservationRefund::getRefundDesc, bo.getRefundDesc());
lqw.eq(bo.getStatus() != null, ReservationRefund::getStatus, bo.getStatus());
return lqw;
}
/**
* 新增预约退款
*
* @param bo 预约退款
* @return 是否新增成功
*/
@Override
public Boolean insertByBo(ReservationRefundBo bo) {
Long userId = LoginHelper.getUserId();
ReservationRefund add = MapstructUtils.convert(bo, ReservationRefund.class);
add.setUserId(userId);
validEntityBeforeSave(add);
add.setStatus(0);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setId(add.getId());
}
return flag;
}
/**
* 修改预约退款
*
* @param bo 预约退款
* @return 是否修改成功
*/
@Override
public Boolean updateByBo(ReservationRefundBo bo) {
ReservationRefund update = MapstructUtils.convert(bo, ReservationRefund.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(ReservationRefund entity){
Long orderId = entity.getOrderId();
Long userId = entity.getUserId();
ReservationOrder order = orderMapper.selectById(orderId);
if(order == null){
throw new ServiceException("查无订单,请确认后重试");
}
Long createBy = order.getCreateBy();
if(!createBy.equals(userId)){
throw new ServiceException("订单数据异常,请确认后重试");
}
Integer orderStatus = order.getOrderStatus();
if (orderStatus != 1) {
throw new ServiceException("订单数据异常,请确认后重试");
}
}
}

View File

@ -3,6 +3,7 @@ package org.dromara.scale.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
import com.github.binarywang.wxpay.service.WxPayService;
@ -143,7 +144,9 @@ public class SysScaleOrderServiceImpl implements ISysScaleOrderService {
}
@Override
public Boolean processOrder(String orderId) {
public Boolean processOrder(WxPayOrderNotifyResult notifyResult) {
String orderId = notifyResult.getOutTradeNo();
String transactionId = notifyResult.getTransactionId();
long id = Long.parseLong(orderId);
SysScaleOrder scaleOrder = baseMapper.selectById(id);
Long userId = scaleOrder.getCreateBy();
@ -161,6 +164,7 @@ public class SysScaleOrderServiceImpl implements ISysScaleOrderService {
order.setId(id);
order.setOrderStatus(1);
order.setUpdateBy(userId);
order.setTransactionId(transactionId);
boolean orderFlag = baseMapper.updateById(order) > 0;
return recordFlag && orderFlag;
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dromara.scale.mapper.ReservationRefundMapper">
</mapper>