微信退款
This commit is contained in:
parent
81bc8da7b9
commit
c10e8da522
|
@ -28,7 +28,7 @@ import java.util.List;
|
||||||
@Validated
|
@Validated
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/scale/reservationOrder")
|
@RequestMapping("/reservation/order")
|
||||||
public class ReservationOrderController extends BaseController {
|
public class ReservationOrderController extends BaseController {
|
||||||
|
|
||||||
private final IReservationOrderService reservationOrderService;
|
private final IReservationOrderService reservationOrderService;
|
||||||
|
@ -36,7 +36,7 @@ public class ReservationOrderController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 查询预约订单列表
|
* 查询预约订单列表
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("scale:reservationOrder:list")
|
@SaCheckPermission("reservation:order:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<ReservationOrderVo> list(ReservationOrderBo bo, PageQuery pageQuery) {
|
public TableDataInfo<ReservationOrderVo> list(ReservationOrderBo bo, PageQuery pageQuery) {
|
||||||
return reservationOrderService.queryPageList(bo, pageQuery);
|
return reservationOrderService.queryPageList(bo, pageQuery);
|
||||||
|
@ -45,7 +45,7 @@ public class ReservationOrderController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 导出预约订单列表
|
* 导出预约订单列表
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("scale:reservationOrder:export")
|
@SaCheckPermission("reservation:order:export")
|
||||||
@Log(title = "预约订单", businessType = BusinessType.EXPORT)
|
@Log(title = "预约订单", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(ReservationOrderBo bo, HttpServletResponse response) {
|
public void export(ReservationOrderBo bo, HttpServletResponse response) {
|
||||||
|
@ -58,7 +58,7 @@ public class ReservationOrderController extends BaseController {
|
||||||
*
|
*
|
||||||
* @param id 主键
|
* @param id 主键
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("scale:reservationOrder:query")
|
@SaCheckPermission("reservation:order:query")
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public R<ReservationOrderVo> getInfo(@NotNull(message = "主键不能为空")
|
public R<ReservationOrderVo> getInfo(@NotNull(message = "主键不能为空")
|
||||||
@PathVariable Long id) {
|
@PathVariable Long id) {
|
||||||
|
|
|
@ -5,7 +5,9 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.dromara.common.core.domain.R;
|
import org.dromara.common.core.domain.R;
|
||||||
|
import org.dromara.common.core.validate.EditGroup;
|
||||||
import org.dromara.common.excel.utils.ExcelUtil;
|
import org.dromara.common.excel.utils.ExcelUtil;
|
||||||
|
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||||
import org.dromara.common.log.annotation.Log;
|
import org.dromara.common.log.annotation.Log;
|
||||||
import org.dromara.common.log.enums.BusinessType;
|
import org.dromara.common.log.enums.BusinessType;
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
|
@ -28,7 +30,7 @@ import java.util.List;
|
||||||
@Validated
|
@Validated
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/scale/reservationRefund")
|
@RequestMapping("/reservation/refund")
|
||||||
public class ReservationRefundController extends BaseController {
|
public class ReservationRefundController extends BaseController {
|
||||||
|
|
||||||
private final IReservationRefundService reservationRefundService;
|
private final IReservationRefundService reservationRefundService;
|
||||||
|
@ -61,8 +63,20 @@ public class ReservationRefundController extends BaseController {
|
||||||
@SaCheckPermission("reservation:refund:query")
|
@SaCheckPermission("reservation:refund:query")
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public R<ReservationRefundVo> getInfo(@NotNull(message = "主键不能为空")
|
public R<ReservationRefundVo> getInfo(@NotNull(message = "主键不能为空")
|
||||||
@PathVariable Long id) {
|
@PathVariable Long id) {
|
||||||
return R.ok(reservationRefundService.queryById(id));
|
return R.ok(reservationRefundService.queryById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同意退款
|
||||||
|
*
|
||||||
|
* @param bo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Log(title = "同意退款", businessType = BusinessType.INSERT)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PostMapping("/agree")
|
||||||
|
public R<Void> refundAgree(@Validated(EditGroup.class) @RequestBody ReservationRefundBo bo) throws Exception {
|
||||||
|
return toAjax(reservationRefundService.agree(bo));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,13 @@ package org.dromara.scale.controller.wx;
|
||||||
import cn.dev33.satoken.annotation.SaIgnore;
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
|
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
|
||||||
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
||||||
|
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
|
||||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||||
import com.github.binarywang.wxpay.service.WxPayService;
|
import com.github.binarywang.wxpay.service.WxPayService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.scale.service.IReservationOrderService;
|
import org.dromara.scale.service.IReservationOrderService;
|
||||||
|
import org.dromara.scale.service.IReservationRefundService;
|
||||||
import org.dromara.scale.service.ISysScaleOrderService;
|
import org.dromara.scale.service.ISysScaleOrderService;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
@ -37,6 +39,8 @@ public class WxPayController {
|
||||||
|
|
||||||
private final IReservationOrderService reservationOrderService;
|
private final IReservationOrderService reservationOrderService;
|
||||||
|
|
||||||
|
private final IReservationRefundService reservationRefundService;
|
||||||
|
|
||||||
@PostMapping("/notify/order/scale")
|
@PostMapping("/notify/order/scale")
|
||||||
public String parseScaleNotifyResult(@RequestBody String xmlData) throws WxPayException {
|
public String parseScaleNotifyResult(@RequestBody String xmlData) throws WxPayException {
|
||||||
log.info("---------量表支付回调-----------------");
|
log.info("---------量表支付回调-----------------");
|
||||||
|
@ -51,4 +55,11 @@ public class WxPayController {
|
||||||
reservationOrderService.processOrder(notifyResult);
|
reservationOrderService.processOrder(notifyResult);
|
||||||
return WxPayNotifyResponse.success("成功");
|
return WxPayNotifyResponse.success("成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/notify/refund/reservation")
|
||||||
|
public String refundReservationNotifyResult(@RequestBody String xmlData) throws WxPayException {
|
||||||
|
final WxPayRefundNotifyResult result = this.payService.parseRefundNotifyResult(xmlData);
|
||||||
|
reservationRefundService.refundOrder(result);
|
||||||
|
return WxPayNotifyResponse.success("成功");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,10 +42,11 @@ public class ReservationRefund extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private String refundDesc;
|
private String refundDesc;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退款状态
|
* 退款状态
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
private String wxRefundId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,13 +23,13 @@ public class ReservationRefundBo extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "不能为空", groups = { EditGroup.class })
|
@NotNull(message = "不能为空", groups = {EditGroup.class})
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单号
|
* 订单号
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "订单号不能为空", groups = { AddGroup.class, EditGroup.class })
|
@NotNull(message = "订单号不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||||
private Long orderId;
|
private Long orderId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,7 +41,7 @@ public class ReservationRefundBo extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* 退款原因
|
* 退款原因
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "退款原因不能为空", groups = { AddGroup.class, EditGroup.class })
|
@NotBlank(message = "退款原因不能为空", groups = {AddGroup.class})
|
||||||
private String refundDesc;
|
private String refundDesc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package org.dromara.scale.domain.vo;
|
package org.dromara.scale.domain.vo;
|
||||||
|
|
||||||
|
import io.github.linpeilie.annotations.AutoMapping;
|
||||||
|
import org.dromara.common.translation.annotation.Translation;
|
||||||
|
import org.dromara.common.translation.constant.TransConstant;
|
||||||
import org.dromara.scale.domain.ReservationRefund;
|
import org.dromara.scale.domain.ReservationRefund;
|
||||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
@ -39,9 +42,14 @@ public class ReservationRefundVo implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 申请人
|
* 申请人
|
||||||
*/
|
*/
|
||||||
|
@Translation(type = TransConstant.USER_ID_TO_NICKNAME)
|
||||||
@ExcelProperty(value = "申请人")
|
@ExcelProperty(value = "申请人")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
|
@Translation(type = TransConstant.USER_ID_TO_NICKNAME)
|
||||||
|
@AutoMapping(target = "userId")
|
||||||
|
private Long userPhone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退款原因
|
* 退款原因
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.dromara.scale.service;
|
package org.dromara.scale.service;
|
||||||
|
|
||||||
|
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
import org.dromara.scale.domain.bo.ReservationRefundBo;
|
import org.dromara.scale.domain.bo.ReservationRefundBo;
|
||||||
|
@ -56,4 +57,8 @@ public interface IReservationRefundService {
|
||||||
*/
|
*/
|
||||||
Boolean updateByBo(ReservationRefundBo bo);
|
Boolean updateByBo(ReservationRefundBo bo);
|
||||||
|
|
||||||
|
Boolean agree(ReservationRefundBo bo) throws Exception ;
|
||||||
|
|
||||||
|
Boolean refundOrder(WxPayRefundNotifyResult notifyResult);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
||||||
import com.github.binarywang.wxpay.service.WxPayService;
|
import com.github.binarywang.wxpay.service.WxPayService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.common.core.utils.MapstructUtils;
|
import org.dromara.common.core.utils.MapstructUtils;
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
@ -34,6 +35,7 @@ import java.util.Map;
|
||||||
* @author cjw
|
* @author cjw
|
||||||
* @date 2024-08-22
|
* @date 2024-08-22
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class ReservationOrderServiceImpl implements IReservationOrderService {
|
public class ReservationOrderServiceImpl implements IReservationOrderService {
|
||||||
|
@ -132,7 +134,19 @@ public class ReservationOrderServiceImpl implements IReservationOrderService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean processOrder(WxPayOrderNotifyResult notifyResult) {
|
public Boolean processOrder(WxPayOrderNotifyResult notifyResult) {
|
||||||
|
String returnCode = notifyResult.getReturnCode();
|
||||||
String orderId = notifyResult.getOutTradeNo();
|
String orderId = notifyResult.getOutTradeNo();
|
||||||
|
if ("FAIL".equals(returnCode)) {
|
||||||
|
log.error("预约订单:{},支付时通信异常。异常原因:{}", orderId, notifyResult.getReturnMsg());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String resultCode = notifyResult.getResultCode();
|
||||||
|
if("FAIL".equals(resultCode)){
|
||||||
|
String errCode = notifyResult.getErrCode();
|
||||||
|
String errCodeDes = notifyResult.getErrCodeDes();
|
||||||
|
log.error("预约订单:{},支付异常。异常代码:{}。异常原因:{}", orderId, errCode,errCodeDes);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
String transactionId = notifyResult.getTransactionId();
|
String transactionId = notifyResult.getTransactionId();
|
||||||
long id = Long.parseLong(orderId);
|
long id = Long.parseLong(orderId);
|
||||||
ReservationOrder reservationOrder = baseMapper.selectById(id);
|
ReservationOrder reservationOrder = baseMapper.selectById(id);
|
||||||
|
|
|
@ -3,7 +3,11 @@ package org.dromara.scale.service.impl;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
|
||||||
|
import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
|
||||||
|
import com.github.binarywang.wxpay.service.WxPayService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.common.core.exception.ServiceException;
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
import org.dromara.common.core.utils.MapstructUtils;
|
import org.dromara.common.core.utils.MapstructUtils;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
|
@ -19,6 +23,8 @@ import org.dromara.scale.mapper.ReservationRefundMapper;
|
||||||
import org.dromara.scale.service.IReservationRefundService;
|
import org.dromara.scale.service.IReservationRefundService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -28,12 +34,14 @@ import java.util.Map;
|
||||||
* @author cjw
|
* @author cjw
|
||||||
* @date 2024-10-15
|
* @date 2024-10-15
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class ReservationRefundServiceImpl implements IReservationRefundService {
|
public class ReservationRefundServiceImpl implements IReservationRefundService {
|
||||||
|
|
||||||
private final ReservationRefundMapper baseMapper;
|
private final ReservationRefundMapper baseMapper;
|
||||||
private final ReservationOrderMapper orderMapper;
|
private final ReservationOrderMapper orderMapper;
|
||||||
|
private final WxPayService wxService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询预约退款
|
* 查询预约退款
|
||||||
|
@ -115,6 +123,56 @@ public class ReservationRefundServiceImpl implements IReservationRefundService {
|
||||||
return baseMapper.updateById(update) > 0;
|
return baseMapper.updateById(update) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean agree(ReservationRefundBo bo) throws Exception {
|
||||||
|
Long orderId = bo.getOrderId();
|
||||||
|
Long refundId = bo.getId();
|
||||||
|
ReservationOrder order = orderMapper.selectById(orderId);
|
||||||
|
BigDecimal orderPrice = order.getOrderPrice();
|
||||||
|
int totalFee = orderPrice.multiply(new BigDecimal(100)).intValue();
|
||||||
|
WxPayRefundRequest request = new WxPayRefundRequest();
|
||||||
|
request.setOutTradeNo(orderId.toString());
|
||||||
|
request.setOutRefundNo(refundId.toString());
|
||||||
|
request.setTotalFee(totalFee);
|
||||||
|
request.setRefundFee(totalFee);
|
||||||
|
request.setNotifyUrl("https://api.ysmental.com/tenant/wx/pay/notify/refund/reservation");
|
||||||
|
this.wxService.refund(request);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean refundOrder(WxPayRefundNotifyResult notifyResult) {
|
||||||
|
String returnCode = notifyResult.getReturnCode();
|
||||||
|
WxPayRefundNotifyResult.ReqInfo reqInfo = notifyResult.getReqInfo();
|
||||||
|
String refundId = reqInfo.getOutRefundNo();
|
||||||
|
if ("FAIL".equals(returnCode)) {
|
||||||
|
log.error("退款单号:{},退款时通信异常。异常原因:{}", refundId, notifyResult.getReturnMsg());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String resultCode = reqInfo.getRefundStatus();
|
||||||
|
if (!"SUCCESS".equals(resultCode)) {
|
||||||
|
log.error("退款单号:{},退款异常。异常代码:{}。", refundId, resultCode);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String orderId = reqInfo.getOutTradeNo();
|
||||||
|
String wxRefundId = reqInfo.getRefundId();
|
||||||
|
|
||||||
|
//更新订单状态
|
||||||
|
Date date = new Date();
|
||||||
|
ReservationOrder order = new ReservationOrder();
|
||||||
|
order.setId(Long.parseLong(orderId));
|
||||||
|
order.setOrderStatus(99);
|
||||||
|
order.setUpdateTime(date);
|
||||||
|
boolean orderFlag = orderMapper.updateById(order) > 0;
|
||||||
|
ReservationRefund refund = new ReservationRefund();
|
||||||
|
refund.setId(Long.parseLong(refundId));
|
||||||
|
refund.setStatus(1);
|
||||||
|
refund.setWxRefundId(wxRefundId);
|
||||||
|
refund.setUpdateTime(date);
|
||||||
|
boolean refundFlag = baseMapper.insert(refund) > 0;
|
||||||
|
return orderFlag && refundFlag;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存前的数据校验
|
* 保存前的数据校验
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
||||||
import com.github.binarywang.wxpay.service.WxPayService;
|
import com.github.binarywang.wxpay.service.WxPayService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.common.core.utils.MapstructUtils;
|
import org.dromara.common.core.utils.MapstructUtils;
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
@ -25,6 +26,7 @@ import org.dromara.scale.service.ISysScaleOrderService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -34,6 +36,7 @@ import java.util.Map;
|
||||||
* @author cjw
|
* @author cjw
|
||||||
* @date 2024-07-30
|
* @date 2024-07-30
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class SysScaleOrderServiceImpl implements ISysScaleOrderService {
|
public class SysScaleOrderServiceImpl implements ISysScaleOrderService {
|
||||||
|
@ -145,12 +148,25 @@ public class SysScaleOrderServiceImpl implements ISysScaleOrderService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean processOrder(WxPayOrderNotifyResult notifyResult) {
|
public Boolean processOrder(WxPayOrderNotifyResult notifyResult) {
|
||||||
|
String returnCode = notifyResult.getReturnCode();
|
||||||
String orderId = notifyResult.getOutTradeNo();
|
String orderId = notifyResult.getOutTradeNo();
|
||||||
|
if ("FAIL".equals(returnCode)) {
|
||||||
|
log.error("量表订单:{},通信异常。异常原因:{}", orderId, notifyResult.getReturnMsg());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String resultCode = notifyResult.getResultCode();
|
||||||
|
if ("FAIL".equals(resultCode)) {
|
||||||
|
String errCode = notifyResult.getErrCode();
|
||||||
|
String errCodeDes = notifyResult.getErrCodeDes();
|
||||||
|
log.error("量表订单:{},支付异常。异常代码:{}。异常原因:{}", orderId, errCode, errCodeDes);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
String transactionId = notifyResult.getTransactionId();
|
String transactionId = notifyResult.getTransactionId();
|
||||||
long id = Long.parseLong(orderId);
|
long id = Long.parseLong(orderId);
|
||||||
SysScaleOrder scaleOrder = baseMapper.selectById(id);
|
SysScaleOrder scaleOrder = baseMapper.selectById(id);
|
||||||
Long userId = scaleOrder.getCreateBy();
|
Long userId = scaleOrder.getCreateBy();
|
||||||
Long recordId = scaleOrder.getRecordId();
|
Long recordId = scaleOrder.getRecordId();
|
||||||
|
Date date = new Date();
|
||||||
//初始量测记录
|
//初始量测记录
|
||||||
SysEvaluationRecord record = new SysEvaluationRecord();
|
SysEvaluationRecord record = new SysEvaluationRecord();
|
||||||
record.setRecordId(recordId);
|
record.setRecordId(recordId);
|
||||||
|
@ -158,12 +174,14 @@ public class SysScaleOrderServiceImpl implements ISysScaleOrderService {
|
||||||
//个人测评订单号就是批次号
|
//个人测评订单号就是批次号
|
||||||
record.setBatchNo(id);
|
record.setBatchNo(id);
|
||||||
record.setUpdateBy(userId);
|
record.setUpdateBy(userId);
|
||||||
|
record.setUpdateTime(date);
|
||||||
boolean recordFlag = recordMapper.updateById(record) > 0;
|
boolean recordFlag = recordMapper.updateById(record) > 0;
|
||||||
//更新订单状态
|
//更新订单状态
|
||||||
SysScaleOrder order = new SysScaleOrder();
|
SysScaleOrder order = new SysScaleOrder();
|
||||||
order.setId(id);
|
order.setId(id);
|
||||||
order.setOrderStatus(1);
|
order.setOrderStatus(1);
|
||||||
order.setUpdateBy(userId);
|
//order.setUpdateBy(userId);
|
||||||
|
order.setUpdateTime(date);
|
||||||
order.setTransactionId(transactionId);
|
order.setTransactionId(transactionId);
|
||||||
boolean orderFlag = baseMapper.updateById(order) > 0;
|
boolean orderFlag = baseMapper.updateById(order) > 0;
|
||||||
return recordFlag && orderFlag;
|
return recordFlag && orderFlag;
|
||||||
|
|
Loading…
Reference in New Issue