Kaynağa Gözat

feat(order): 添加退款类型字段并优化退款流程

- 在 AppOrder 实体中新增 refundType 字段,用于区分整单或部分退款
- 更新售后状态描述,简化为存在退款的状态表示
-优化退款订单查询逻辑,支持按组织机构筛选数据- 完善包场信息保存逻辑,增加退款相关字段设置
- 调整定时任务服务,在订单完成时同步更新券使用状态-修复订单状态更新逻辑,确保所有子订单完成后才变更主订单状态- 增强退款页面表单和视图对象,支持时间格式化及价格显示
- 微信支付回调处理中补充退款类型和售后状态的更新操作
wzq 1 hafta önce
ebeveyn
işleme
6a2bca9d21

+ 6 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/WeChatPayService.java

@@ -474,6 +474,9 @@ public class WeChatPayService {
             case "SUCCESS":
                 log.info("订单:{},退款成功!原因:{}", appOrder.getOrderCode(), reason);
                 //修改订单状态
+                appOrder.setAfterSaleStatus(CommonConstant.NUMBER_1);
+                appOrder.setRefundType(CommonConstant.NUMBER_2);
+                appOrderMapper.updateById(appOrder);
                 for (AppOrderProInfo appOrderProInfo : appOrderProInfoList) {
                     appOrderProInfo.setOrderStatus(CommonConstant.ORDER_STATUS_6);
                     appOrderProInfo.setAfterSaleStatus(CommonConstant.NUMBER_2);
@@ -486,6 +489,9 @@ public class WeChatPayService {
             case "PROCESSING":
                 log.info("退款处理中");
                 //修改订单状态
+                appOrder.setAfterSaleStatus(CommonConstant.NUMBER_1);
+                appOrder.setRefundType(CommonConstant.NUMBER_2);
+                appOrderMapper.updateById(appOrder);
                 for (AppOrderProInfo appOrderProInfo : appOrderProInfoList) {
                     appOrderProInfo.setOrderStatus(CommonConstant.ORDER_STATUS_5);
                     appOrderProInfo.setAfterSaleStatus(CommonConstant.NUMBER_1);

+ 13 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/quartz/job/OrTeachingJobService.java

@@ -14,6 +14,7 @@ import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.app.service.IAppIsinService;
 import org.jeecg.modules.quartz.utils.HolidayUtil;
 import org.jeecg.modules.system.app.dto.TeachingDayDTO;
 import org.jeecg.modules.system.app.entity.*;
@@ -59,6 +60,8 @@ public class OrTeachingJobService {
 
     private final IAppOrderService appOrderService;
 
+    private final IAppIsinService appIsinService;
+
     @Resource
     private AppDeviceMapper appDeviceMapper;
 
@@ -282,7 +285,16 @@ public class OrTeachingJobService {
                         if (appOrderProInfo.getOrderStatus() == 1){
                             appOrderProInfo.setOrderStatus(CommonConstant.ORDER_STATUS_2);
                             appOrderProInfoService.updateById(appOrderProInfo);
-                            appOrderService.update(Wrappers.lambdaUpdate(AppOrder.class).set(AppOrder::getOrderStatus, CommonConstant.ORDER_STATUS_2).eq(AppOrder::getId, appOrderProInfo.getOrderId()));
+                            //修改券使用记录状态
+                            appIsinService.update(Wrappers.lambdaUpdate(AppIsin.class).eq(AppIsin::getOrderProInfoId, appOrderProInfo.getId()).set(AppIsin::getIsinStatus, CommonConstant.ISIN_STATUS_1));
+                            //修改订单状态
+                            String orderId = appOrderProInfo.getOrderId();
+                            List<AppOrderProInfo> proInfos = appOrderProInfoService.list(Wrappers.lambdaQuery(AppOrderProInfo.class).eq(AppOrderProInfo::getOrderId, orderId));
+                            if(proInfos.size() == proInfos.stream().filter(ap -> ap.getOrderStatus() > 1).count()){
+                                AppOrder appOrder = appOrderService.getById(orderId);
+                                appOrder.setOrderStatus(CommonConstant.ORDER_STATUS_2);
+                                appOrderService.updateById(appOrder);
+                            }
                         }
                     }
                 }

+ 8 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/controller/AppOrderController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.system.app.controller;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -8,11 +9,13 @@ import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.poi.ss.formula.functions.T;
+import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.pay.config.WeChatProfitSharingService;
 import org.jeecg.modules.system.app.dto.ExportConditionDTO;
 import org.jeecg.modules.system.app.entity.AppOrder;
@@ -292,6 +295,11 @@ public class AppOrderController extends JeecgController<AppOrder, IAppOrderServi
     @Operation(summary="退款管理-分页列表查询")
     @PostMapping(value = "/refundOrderPageList")
     public Result<IPage<RefundOrderPageVO>> refundOrderPageList(@RequestBody RefundOrderPageForm refundOrderPageForm) {
+        LoginUser user = (LoginUser)SecurityUtils.getSubject().getPrincipal();
+        String orgCode = user.getOrgCode();
+        if (!ObjectUtil.equals("A01",orgCode)){
+            refundOrderPageForm.setOrderCode(orgCode);
+        }
         IPage<RefundOrderPageVO> page = appOrderService.refundOrderPageList(refundOrderPageForm);
         return Result.OK(page);
     }

+ 4 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/entity/AppOrder.java

@@ -103,9 +103,12 @@ public class AppOrder implements Serializable {
     @Schema(description = "订单状态 0-待付款 1-待使用 2-已使用 3-已到期 4-已取消 5-退款中 6-已退款")
     private Integer orderStatus;
 
-    @Schema(description = "售后状态 0-暂无售后 1-退款中 2-已退款 3-失败/异常")
+    @Schema(description = "售后状态 0-暂无售后 1-存在退款")
     private Integer afterSaleStatus;
 
+    @Schema(description = "退款类型 0-无 1-整单退款 2-部分退款")
+    private Integer refundType;
+
     @Schema(description = "支付状态 0-待支付 1-支付成功 2-退款中 3-已退款")
     private Integer payStatus;
 

+ 5 - 2
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/form/RefundOrderPageForm.java

@@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
 import lombok.experimental.Accessors;
 import org.jeecg.modules.app.dto.PageDTO;
+import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serial;
 import java.io.Serializable;
@@ -25,12 +26,14 @@ public class RefundOrderPageForm extends PageDTO implements Serializable {
     @Schema(description = "订单编号")
     private String orderCode;
 
-//    @Schema(description = "商户退款单号")
-//    private String outRefundNo;
+    @Schema(description = "orgCode",hidden = true)
+    private String orgCode;
 
     @Schema(description = "开始时间")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date startTime;
 
     @Schema(description = "结束时间")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date endTime;
 }

+ 7 - 3
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/AppOrderMapper.xml

@@ -210,13 +210,17 @@
             o.order_code,
             o.order_status,
             o.after_sale_status,
-            o.create_time
+            o.create_time,
+            o.price
         FROM
             nm_order o
         <where>
-            o.del_flag = 0 AND o.order_status = 1 AND o.after_sale_status > 0
+            o.del_flag = 0 AND o.after_sale_status > 0
+            <if test="refundOrderPageForm.orgCode != null and refundOrderPageForm.orgCode !=''">
+                and o.org_code = #{refundOrderPageForm.orgCode}
+            </if>
             <if test="refundOrderPageForm.orderCode != null and refundOrderPageForm.orderCode !=''">
-                and o.order_code LIKE CONCAT('%',#{appOrderPageForm.orderCode},'%')
+                and o.order_code LIKE CONCAT('%',#{refundOrderPageForm.orderCode},'%')
             </if>
             <if test="refundOrderPageForm.startTime != null">
                 and DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> #{refundOrderPageForm.startTime}

+ 13 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppSitePlaceServiceImpl.java

@@ -472,6 +472,9 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
                 appSitePlace.setTenantId(site.getTenantId());
                 appSitePlace.setCategoryId(category.getId());
                 appSitePlace.setType(SitePlaceTypeEnum.PACKAGE.getCode());
+                appSitePlace.setRefundType(placeCuDTO.getRefundType());
+                appSitePlace.setEarlyRefundTime(placeCuDTO.getEarlyRefundTime());
+                appSitePlace.setReminder(placeCuDTO.getReminder());
                 int insert = baseMapper.insert(appSitePlace);
                 if (insert < 1) throw new JeecgBootException("包场保存失败", SC_INTERNAL_SERVER_ERROR_500);
 
@@ -1052,7 +1055,14 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
 
         //修改所有的sitePlace的退款,预定限制,温馨提示
         for (AppSitePlace existingPlace : existingPlaces) {
-            if (!ObjectUtil.equals(existingPlace.getEarlyRefundTime(), placeCuDTO.getEarlyRefundTime()) || !ObjectUtil.equals(existingPlace.getBuyLimit(), placeCuDTO.getBuyLimit()) || !ObjectUtil.equals(existingPlace.getReminder(), placeCuDTO.getReminder())) {
+            if (!ObjectUtil.equals(existingPlace.getEarlyRefundTime(), placeCuDTO.getEarlyRefundTime()) ||
+                    !ObjectUtil.equals(existingPlace.getBuyLimit(), placeCuDTO.getBuyLimit()) ||
+                    !ObjectUtil.equals(existingPlace.getReminder(), placeCuDTO.getReminder()) ||
+                    !ObjectUtil.equals(existingPlace.getRefundType(), placeCuDTO.getRefundType())
+            ) {
+                if (!ObjectUtil.equals(existingPlace.getRefundType(), placeCuDTO.getRefundType())) {
+                    existingPlace.setRefundType(placeCuDTO.getRefundType());
+                }
                 if (!ObjectUtil.equals(existingPlace.getEarlyRefundTime(), placeCuDTO.getEarlyRefundTime())) {
                     existingPlace.setEarlyRefundTime(placeCuDTO.getEarlyRefundTime());
                 }
@@ -1126,6 +1136,7 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
             appSitePlace.setOrgCode(site.getOrgCode());
             appSitePlace.setTenantId(site.getTenantId());
             appSitePlace.setCategoryId(category.getId());
+            appSitePlace.setRefundType(appSitePlaceCuDTO.getRefundType());
             appSitePlace.setEarlyRefundTime(appSitePlaceCuDTO.getEarlyRefundTime());
             appSitePlace.setBuyLimit(appSitePlaceCuDTO.getBuyLimit());
             appSitePlace.setReminder(appSitePlaceCuDTO.getReminder());
@@ -1244,6 +1255,7 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
                     .setName(category.getName() + (sitePlaces.size() + i))
                     .setType(SitePlaceTypeEnum.PACKAGE.getCode())
                     .setOrgCode(site.getOrgCode())
+                    .setRefundType(appSitePlaceCuDTO.getRefundType())
                     .setEarlyRefundTime(appSitePlaceCuDTO.getEarlyRefundTime())
                     .setBuyLimit(appSitePlaceCuDTO.getBuyLimit())
                     .setReminder(appSitePlaceCuDTO.getReminder())

+ 9 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/vo/RefundOrderPageVO.java

@@ -1,11 +1,13 @@
 package org.jeecg.modules.system.app.vo;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
 import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serial;
 import java.io.Serializable;
@@ -32,5 +34,12 @@ public class RefundOrderPageVO implements Serializable {
     @Schema(description = "订单状态 0-待付款 1-待使用 2-已使用 3-已到期 4-已取消 5-退款中 6已退款")
     private Integer orderStatus;
 
+    @Schema(description = "创建时间")
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    @Schema(description = "实际支付金额")
+    private BigDecimal price;
+
     private List<RefundOrderProInfo> refundOrderProInfoList;
 }