浏览代码

add 订单状态查询接口

周箭河 5 年之前
父节点
当前提交
2492c37fc0

+ 1 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamRegistrationController.java

@@ -84,7 +84,6 @@ public class ExamRegistrationController extends BaseController {
 
     @ApiOperation(value = "报名")
     @PostMapping(value = "add")
-    @PreAuthorize("@pcs.hasPermissions('examRegistration/add')")
     public HttpResponseResult add(@RequestBody ExamRegistration examRegistration) throws Exception {
         SysUser student = sysUserFeignService.queryUserInfo();
         examRegistration.setStudentId(student.getId());
@@ -111,7 +110,7 @@ public class ExamRegistrationController extends BaseController {
 
     @ApiOperation(value = "获取报名信息")
     @GetMapping(value = "getExamRegistration")
-    @ApiImplicitParams({@ApiImplicitParam(name = "examRegistrationId", value = "报名id", required = true, dataType = "file")})
+    @ApiImplicitParams({@ApiImplicitParam(name = "examRegistrationId", value = "报名id", required = true, dataType = "int")})
     public HttpResponseResult<ExamRegistration> getExamRegistration(Integer examRegistrationId) {
         return succeed(examRegistrationService.getExamRegistration(examRegistrationId));
     }

+ 14 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamRegistrationPaymentDao.java

@@ -3,8 +3,11 @@ package com.keao.edu.user.dao;
 import com.keao.edu.common.dal.BaseDAO;
 import com.keao.edu.user.dto.StudentExamPaymentDto;
 import com.keao.edu.user.entity.ExamRegistrationPayment;
+import com.keao.edu.user.enums.TransStatusEnum;
 import org.apache.ibatis.annotations.Param;
+import org.apache.poi.ss.formula.functions.T;
 
+import java.util.Date;
 import java.util.List;
 
 public interface ExamRegistrationPaymentDao extends BaseDAO<Long, ExamRegistrationPayment> {
@@ -41,4 +44,15 @@ public interface ExamRegistrationPaymentDao extends BaseDAO<Long, ExamRegistrati
      * @return
      */
     StudentExamPaymentDto getOrderInfo(@Param("orderNo") String orderNo);
+
+
+    /**
+     * 获取过期未支付的订单列表
+     * @param orderNoList
+     * @param transStatus
+     * @param beforeTime
+     * @return
+     */
+    List<ExamRegistrationPayment> findOrdersOverTime(@Param("orderNoList") List<String> orderNoList, @Param("transStatus") TransStatusEnum transStatus, @Param("beforeTime") Date beforeTime);
+
 }

+ 23 - 35
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamRegistrationPaymentServiceImpl.java

@@ -147,7 +147,7 @@ public class ExamRegistrationPaymentServiceImpl extends BaseServiceImpl<Long, Ex
                     continue;
                 }
             }
-            //closeOrders(orderNoList); //关闭订单
+            closeOrders(orderNoList); //关闭订单
         }
     }
 
@@ -197,38 +197,26 @@ public class ExamRegistrationPaymentServiceImpl extends BaseServiceImpl<Long, Ex
 //    }
 //
 //
-//    private void closeOrders(List<String> orderNoList) throws Exception {
-//        if (orderNoList.size() == 0) {
-//            return;
-//        }
-//
-//        Calendar beforeTime = Calendar.getInstance();
-//        beforeTime.add(Calendar.MINUTE, -30);// 30分钟之前的时间
-//        Date beforeDate = beforeTime.getTime();
-//
-//        List<StudentPaymentOrder> ordersOverTime = findOrdersOverTime(orderNoList, DealStatusEnum.ING, beforeDate);
-//        for (StudentPaymentOrder order : ordersOverTime) {
-//            try {
-//                order.setStatus(DealStatusEnum.FAILED);
-//                order.setMemo("超时未支付关闭");
-//                if (order.getType().equals(OrderTypeEnum.APPLY)) { //报名订单
-//                    studentRegistrationService.updateApplyOrder(order);
-//                } else if (order.getType().equals(OrderTypeEnum.SMALL_CLASS_TO_BUY)) {
-//                    vipGroupService.orderCallback(order);
-//                } else if (order.getType().equals(OrderTypeEnum.RENEW)) {
-//                    musicGroupService.renewForCallback(order);
-//                } else if (order.getType().equals(OrderTypeEnum.SPORADIC) || order.getType().equals(OrderTypeEnum.LUCK)) {
-//                    sporadicChargeInfoService.renewForCallback(order);
-//                } else if (order.getType().equals(OrderTypeEnum.PRACTICE_GROUP_BUY) || order.getType().equals(OrderTypeEnum.PRACTICE_GROUP_RENEW)) {
-//                    practiceGroupService.orderCallback(order);
-//                } else if (order.getType().equals(OrderTypeEnum.REPAIR)) {
-//                    studentRepairService.orderCallback(order);
-//                }
-//            } catch (Exception e) {
-//                e.printStackTrace();
-//                continue;
-//            }
-//        }
-//
-//    }
+    private void closeOrders(List<String> orderNoList) throws Exception {
+        if (orderNoList.size() == 0) {
+            return;
+        }
+
+        Calendar beforeTime = Calendar.getInstance();
+        beforeTime.add(Calendar.MINUTE, -30);// 30分钟之前的时间
+        Date beforeDate = beforeTime.getTime();
+
+        List<ExamRegistrationPayment> ordersOverTime = examRegistrationPaymentDao.findOrdersOverTime(orderNoList, TransStatusEnum.ING, beforeDate);
+        for (ExamRegistrationPayment order : ordersOverTime) {
+            try {
+                order.setTransStatus(TransStatusEnum.FAILED);
+                order.setMemo("超时未支付关闭");
+
+            } catch (Exception e) {
+                e.printStackTrace();
+                continue;
+            }
+        }
+
+    }
 }

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamRegistrationServiceImpl.java

@@ -94,7 +94,7 @@ public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegis
         examRegistrationDao.insert(examRegistration);
 
         ExamRegistrationPayment examRegistrationPayment = new ExamRegistrationPayment();
-        examRegistrationPayment.setTenantId(examRegistration.getTenantId());
+        examRegistrationPayment.setTenantId(examinationBasic.getTenantId());
         examRegistrationPayment.setExamRegistrationId(examRegistration.getId().longValue());
         examRegistrationPayment.setStudentId(examRegistration.getStudentId());
         examRegistrationPayment.setExaminationBasicId(examRegistration.getExaminationBasicId());

+ 11 - 2
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamRegistrationPaymentMapper.xml

@@ -48,7 +48,7 @@
         -->
         INSERT INTO exam_registration_payment
         (id_,exam_registration_id_,student_id_,examination_basic_id_,order_no_,trans_no_,mer_no_,trans_amount_,trans_status_,trans_successed_time_,create_time_,update_time_,tenant_id_)
-        VALUES(#{id},#{examRegistrationId},#{studentId},#{examinationBasicId},#{orderNo},#{transNo},#{transAmount},#{transStatus},#{merNo},#{transSuccessedTime},NOW(),NOW(),#{tenantId})
+        VALUES(#{id},#{examRegistrationId},#{studentId},#{examinationBasicId},#{orderNo},#{transNo},#{merNo},#{transAmount},#{transStatus},#{transSuccessedTime},NOW(),NOW(),#{tenantId})
     </insert>
 
     <!-- 根据主键查询一条记录 -->
@@ -80,7 +80,7 @@
                 trans_no_ = #{transNo},
             </if>
             <if test="payChannel != null">
-                pay_channel_ = #{pay_channel_},
+                pay_channel_ = #{payChannel},
             </if>
             <if test="merNo != null">
                 mer_no_ = #{merNo},
@@ -141,4 +141,13 @@
         LEFT JOIN exam_registration er ON er.id_ = erp.exam_registration_id_
         WHERE order_no_ = #{orderNo}
     </select>
+    <!-- 获取超时未支付的订单 -->
+    <select id="findOrdersOverTime" resultMap="ExamRegistrationPayment">
+        SELECT * FROM exam_registration_payment WHERE order_no_ IN
+        <foreach collection="orderNoList" item="orderNo" index="index" open="(" close=")" separator=",">
+            #{orderNo}
+        </foreach>
+        AND trans_status_=#{transStatus,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}
+        <![CDATA[ AND create_time_ <= ]]> #{beforeTime}
+    </select>
 </mapper>