Browse Source

小程序接口, 增加返回信息

Memory_LG 4 months ago
parent
commit
9f4cff0c88

+ 9 - 1
qmjszx-admin/src/main/java/beilv/web/controller/stadium/StadiumController.java

@@ -2,7 +2,9 @@ package beilv.web.controller.stadium;
 
 import beilv.common.core.controller.BaseController;
 import beilv.common.core.domain.AjaxResult;
+import beilv.common.core.domain.entity.SysDictData;
 import beilv.common.core.page.TableDataInfo;
+import beilv.common.utils.DictUtils;
 import beilv.common.utils.StringUtils;
 import beilv.common.utils.uuid.IdUtils;
 import beilv.competition.domain.Competition;
@@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.*;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 @RestController
 @RequestMapping("/app-api/stadium")
@@ -74,7 +77,12 @@ public class StadiumController extends BaseController {
     @GetMapping("/getStadiumList")
     public AjaxResult getStadiumList(StadiumBO stadiumBO) {
         startPage();
-        return AjaxResult.success(stadiumService.getStadiumList(stadiumBO));
+        Map<String, String> paymentStatus = DictUtils.getDictCacheToMap("payment_status");
+        List<Stadium> stadiumList = stadiumService.getStadiumList(stadiumBO);
+        stadiumList.forEach(stadium -> {
+            stadium.setPaymentStatus(paymentStatus.get(stadium.getPaymentStatus()));
+        });
+        return AjaxResult.success(getDataTable(stadiumList));
     }
 
     /**

+ 1 - 1
qmjszx-business/src/main/java/beilv/competition/mapper/CompetitionMapper.java

@@ -67,7 +67,7 @@ public interface CompetitionMapper {
 
     boolean selectStadumIsOpenById(String id);
 
-    void updateBookARace(@Param("id") Integer id);
+    void updateBookARace(Stadium stadium);
 
     Competition getCompetitionInfo(@Param("orderId") String orderId);
 }

+ 10 - 3
qmjszx-business/src/main/java/beilv/competition/service/impl/CompetitionServiceImpl.java

@@ -6,6 +6,7 @@ import beilv.competition.domain.Competition;
 import beilv.competition.mapper.CompetitionMapper;
 import beilv.competition.service.ICompetitionService;
 import beilv.competition.task.CloseReg;
+import beilv.stadium.domain.Stadium;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -35,14 +36,20 @@ public class CompetitionServiceImpl implements ICompetitionService {
     public void init() {
         // 找到所有报名中的赛事
         Competition competition = new Competition();
-        competition.setCompetitionState("competiton_state_2");
+        competition.setCompetitionState(BAO_MING_ZHONG);
         List<Competition> competitionList = this.selectCompetitionList(competition);
         competitionList.forEach(item -> {
             Date date = new Date(item.getApplyStartTime().getTime() - (long) (item.getApplyBeforeTime() * 60 * 60 * 1000));
             if (new Date().getTime() >= date.getTime()) {
-                item.setCompetitionState("competiton_state_3");
+                item.setCompetitionState(BAO_MING_JIE_SHU);
                 competitionMapper.updateCompetition(item);
-                competitionMapper.updateBookARace(item.getId());
+
+                Stadium stadium = new Stadium();
+                stadium.setCompetitionId(String.valueOf(item.getId()));
+                stadium.setPaymentStatus("payment_status_verification");
+                stadium.setVerificationTime(new Date());
+
+                competitionMapper.updateBookARace(stadium);
             } else {
                 Timer timer = new Timer();
                 timer.schedule(new CloseReg(competitionMapper, item.getId()), date);

+ 8 - 1
qmjszx-business/src/main/java/beilv/competition/task/CloseReg.java

@@ -2,7 +2,9 @@ package beilv.competition.task;
 
 import beilv.competition.domain.Competition;
 import beilv.competition.mapper.CompetitionMapper;
+import beilv.stadium.domain.Stadium;
 
+import java.util.Date;
 import java.util.TimerTask;
 
 public class CloseReg extends TimerTask {
@@ -23,6 +25,11 @@ public class CloseReg extends TimerTask {
         competition.setCompetitionState("competiton_state_3");
         this.competitionMapper.updateCompetition(competition);
 
-        this.competitionMapper.updateBookARace(id);
+        //核验当前赛事下已支付的订单
+        Stadium stadium = new Stadium();
+        stadium.setCompetitionId(String.valueOf(id));
+        stadium.setPaymentStatus("payment_status_verification");
+        stadium.setVerificationTime(new Date());
+        this.competitionMapper.updateBookARace(stadium);
     }
 }

+ 17 - 0
qmjszx-business/src/main/java/beilv/stadium/domain/Stadium.java

@@ -2,6 +2,8 @@ package beilv.stadium.domain;
 
 import lombok.*;
 
+import java.util.Date;
+
 @Getter
 @Setter
 @ToString
@@ -61,4 +63,19 @@ public class Stadium {
      */
     private String refundInstructions;
 
+    /**
+     * 核验时间
+     */
+    private Date verificationTime;
+    /**
+     * 实付金额
+     */
+    private Double amountActuallyPaid;
+
+
+    private String competitionTitle;
+    private String competitionExpense;
+    private String viewingTicket;
+    private String competitionImg;
+
 }

+ 7 - 3
qmjszx-business/src/main/resources/mapper/competition/CompetitionMapper.xml

@@ -176,10 +176,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
           AND competition_id = #{id}
     </select>
 
-    <update id="updateBookARace" parameterType="int">
+    <update id="updateBookARace" parameterType="Stadium">
         update beilv_book_a_race
-        set payment_status = 'payment_status_verification'
-        where competition_id = #{id} and payment_status = 'payment_status_have_paid'
+            set payment_status = #{paymentStatus},
+                verification_time = #{verificationTime}
+        where
+                competition_id = #{competitionId}
+            and
+                payment_status = 'payment_status_have_paid'
     </update>
 
     <select id="getCompetitionInfo" parameterType="string" resultMap="CompetitionResult">

+ 15 - 6
qmjszx-business/src/main/resources/mapper/stadium/StadiumMapper.xml

@@ -18,6 +18,12 @@
         <result property="competitionId" column="competition_id"/>
         <result property="orderType" column="order_type"/>
         <result property="refundInstructions" column="refund_instructions"/>
+        <result property="verificationTime" column="verification_time"/>
+        <result property="amountActuallyPaid" column="amount_actually_paid"/>
+        <result property="competitionTitle" column="competition_title"/>
+        <result property="competitionExpense" column="competition_expense"/>
+        <result property="viewingTicket" column="viewing_ticket"/>
+        <result property="competitionImg" column="competition_img"/>
     </resultMap>
 
 
@@ -59,6 +65,7 @@
             <if test="paymentTime != null">payment_time = #{paymentTime},</if>
             <if test="cancellationTime != null">cancellation_time = #{cancellationTime},</if>
             <if test="refundTime != null">refund_time = #{refundTime},</if>
+            <if test="verificationTime != null">verification_time = #{verificationTime},</if>
             <if test="paymentStatus != null">payment_status = #{paymentStatus},</if>
             <if test="refundInstructions != null">refund_instructions = #{refundInstructions},</if>
         </trim>
@@ -74,18 +81,20 @@
 
     <select id="getStadimList" parameterType="stadiumBO" resultMap="StadiumResult">
         select
-            id, user_id, contact_people, contact_number, registration_time, payment_time,
-            cancellation_time, refund_time, payment_status, order_id, competition_id, order_type, refund_instructions
-        from beilv_book_a_race
+        ar.id, ar.user_id, ar.contact_people, ar.contact_number, ar.registration_time, ar.payment_time,
+        ar.cancellation_time, ar.refund_time, ar.payment_status, ar.order_id, ar.competition_id, ar.order_type, ar.refund_instructions,
+        ar.verification_time, ar.amount_actually_paid ,bc.competition_title, bc.competition_expense, bc.viewing_ticket, bc.competition_img
+        from beilv_book_a_race ar
+        left join beilv_competition bc on ar.competition_id = bc.id
         <where>
             <if test="userId != null and userId != ''">
-                and user_id = #{userId}
+                and ar.user_id = #{userId}
             </if>
             <if test="orderType != null and orderType != ''">
-                and order_type = #{orderType}
+                and ar.order_type = #{orderType}
             </if>
             <if test="paymentStatus != null and paymentStatus != ''">
-                and payment_status = #{paymentStatus}
+                and ar.payment_status = #{paymentStatus}
             </if>
         </where>
     </select>

+ 13 - 0
qmjszx-common/src/main/java/beilv/common/utils/DictUtils.java

@@ -1,6 +1,9 @@
 package beilv.common.utils;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+
 import org.springframework.stereotype.Component;
 import beilv.common.constant.Constants;
 import beilv.common.core.domain.entity.SysDictData;
@@ -45,6 +48,16 @@ public class DictUtils
         return null;
     }
 
+    public static Map<String, String> getDictCacheToMap(String key){
+        List<SysDictData> dictCache = getDictCache(key);
+        Map<String, String> result = new HashMap<>();
+
+        dictCache.forEach(sysdictData->{
+            result.put(sysdictData.getDictValue(), sysdictData.getDictLabel());
+        });
+        return result;
+    }
+
     /**
      * 根据字典类型和字典值获取字典标签
      *