Browse Source

1.7.5认证通版本查询视频功能优化

JiangChongBo 2 years ago
parent
commit
540d643c36

+ 12 - 1
src/main/java/com/caimei/controller/wechat/WxAuthApi.java

@@ -413,10 +413,21 @@ public class WxAuthApi {
 //        }
         //用户是否已经发过视频
         String userName=jsonObject.getString("userName");
+        Integer authUserId=jsonObject.getInteger("authUserId");
         Boolean flaguserName=authService.getuserName(userName);
         ChallengeRoundVo challengeActivityVo=new ChallengeRoundVo();
+        ResponseJson<ChallengeActivityVo> activitty = authService.getActivitty(authUserId);
+        ChallengeActivityVo challe = activitty.getData();
+        if(challe!=null){
+            challengeActivityVo.setActivityState(challe.getActivityState());
+        }
+        String releaseTime = authService.getReleaseTime(userName);
         if(!flaguserName){
-            challengeActivityVo.setReleaseStatus(1);
+            if(challe.getStartTime().compareTo(releaseTime)<0&&challe.getEndTime().compareTo(releaseTime)>0){
+                challengeActivityVo.setReleaseStatus(1);
+            }else{
+                challengeActivityVo.setReleaseStatus(0);
+            }
             return  ResponseJson.success(challengeActivityVo);
 //            return ResponseJson.error("-1","抱歉,活动规定每个用户只能发布一个视频,您已发布过视频,请勿再次发布!");
         }else{

+ 4 - 0
src/main/java/com/caimei/mapper/cmMapper/AuthMapper.java

@@ -165,4 +165,8 @@ public interface AuthMapper {
     void deleteVideoById(Integer videoID);
 
     ChallengeRoundVo getChallengeRoundInfo(Integer videoID);
+
+    void upStatusById(Integer id);
+
+    String getReleaseTime(@Param("userName")String userName );
 }

+ 4 - 0
src/main/java/com/caimei/model/vo/ChallengeRoundVo.java

@@ -69,4 +69,8 @@ public class ChallengeRoundVo {
          * 发布状态(0机构已经没有发布视频,1机构已经发布过视频)
          */
         private Integer releaseStatus;
+        /**
+         * 0: 活动未开始 1:活动进行中 2:活动已结束
+         */
+        private Integer activityState;
 }

+ 8 - 1
src/main/java/com/caimei/service/auth/AuthService.java

@@ -259,8 +259,15 @@ public interface AuthService {
     String getAuthUserName(Integer authId);
 
     /**
-     * 保存抖音口令
+     * 获取发布时间
+     * @param userName
+     * @return
      */
+    String getReleaseTime(String userName);
+
+        /**
+         * 保存抖音口令
+         */
    void savaDyCommand(Integer authId,String content);
 
     /**

+ 31 - 6
src/main/java/com/caimei/service/auth/impl/AuthServiceImpl.java

@@ -1385,7 +1385,17 @@ public class AuthServiceImpl implements AuthService {
      */
     @Override
     public ResponseJson<ChallengeActivityVo> getActivityTime(Integer authUserId){
-         return ResponseJson.success(authMapper.getActivityTime(authUserId));
+        Date date=new Date();
+        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String releaseTime = sf.format(date).replace("T", "");
+        ChallengeActivityVo activityTime = authMapper.getActivityTime(authUserId);
+        //如果当前时间大于结束时间则活动状态置为未开启状态
+        if(activityTime.getEndTime().compareTo(releaseTime)<0){
+            activityTime.setStatus(0);
+            authMapper.upStatusById(activityTime.getId());
+            //
+        }
+        return ResponseJson.success(activityTime);
     }
 
     /**
@@ -1414,12 +1424,17 @@ public class AuthServiceImpl implements AuthService {
         SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         String releaseTime = sf.format(date).replace("T", "");
         if(activityTime!=null){
-            if(activityTime.getStartTime().compareTo(releaseTime)>0&&activityTime.getStatus()==0){
-                activityTime.setActivityState(0);
-            }else if(activityTime.getStartTime().compareTo(releaseTime)<0&&activityTime.getEndTime().compareTo(releaseTime)>0&&activityTime.getStatus()==1){
-                activityTime.setActivityState(1);
-            }else {
+            //当按钮关闭时,状态皆为已结束,开始时根据时间判断
+            if(activityTime.getStatus()==0){
                 activityTime.setActivityState(2);
+            }else{
+                if(activityTime.getStartTime().compareTo(releaseTime)>0){
+                    activityTime.setActivityState(0);
+                }else if(activityTime.getStartTime().compareTo(releaseTime)<0&&activityTime.getEndTime().compareTo(releaseTime)>0){
+                    activityTime.setActivityState(1);
+                }else {
+                    activityTime.setActivityState(2);
+                }
             }
         }
         return ResponseJson.success(activityTime);
@@ -1474,6 +1489,16 @@ public class AuthServiceImpl implements AuthService {
 
         authMapper.deleteVideoById(videoID);
     }
+
+    /**
+     * 根据手机号获取发布时间
+     * @param userName
+     * @return
+     */
+    @Override
+    public String getReleaseTime(String userName){
+       return  authMapper.getReleaseTime(userName);
+    }
     @Override
     public ResponseJson downLoadChoseZip(String fileId,HttpServletResponse response){
         if (fileId.contains(",")) {

+ 12 - 2
src/main/resources/mapper/AuthMapper.xml

@@ -664,7 +664,7 @@
                where cr.authUserId=#{authUserId}
         <if test="clubUserName != null and clubUserName != ''">
             and (cr.userName like concat('%', #{clubUserName})
-            or  cba.authParty=#{clubUserName})
+            or  cba.authParty like concat('%', #{clubUserName},'%') )
         </if>
        and  cr.releaseTime &gt;#{startTime} and  cr.releaseTime&lt;#{endTime}
     </select>
@@ -679,7 +679,7 @@
             and cr.userName like concat('%', #{mobile})
         </if>
         <if test="authParty != null and authParty != ''">
-            or  cba.authParty=#{authParty})
+            and  cba.authParty like concat('%', #{authParty},'%')
         </if>
         <if test="status != null">
             and cr.status = #{status}
@@ -758,4 +758,14 @@
         from cm_challenge_round cr
         where cr.id=#{videoID}
     </select>
+    <update id="upStatusById">
+        update cm_challenge_activity set
+            status = 0
+        where id=#{id}
+    </update>
+    <select id="getReleaseTime" resultType="java.lang.String">
+        select releaseTime
+        from cm_challenge_round cr
+        where cr.userName=#{userName}
+    </select>
 </mapper>