lsw 11 ヶ月 前
コミット
0e809eed5c

+ 1 - 1
app/pages/serve/index.vue

@@ -26,7 +26,7 @@
 					</view>
 				</view>
 			</view>
-			<view class="cd">
+			<view class="cd" @click="go('/pages/other/webview?src=https://ggfw.nn12333.com:8081/gx/wechat/html/jiuyeView/views/self_employmentApplication.html?applySrc=31')">
 				<view class="out">
 					<view class="int">
 						<view class="icon" style="background-color: #ff9800">&#xe73c;</view>

+ 6 - 4
app/pages/user/resume/application/invite.vue

@@ -10,11 +10,13 @@
 				<view class="distance">{{ item.createTime }}</view>
 			</view>
 			<view class="flex">
-				<view class="f br agree" @click.stop="agree(item, 1)" v-if="item.isAccept == 0">同意</view>
-				<view class="f danger" @click.stop="agree(item, 2)" v-if="item.isAccept == 0">拒绝</view>
-				<view class="f danger" v-if="item.isAccept == 2">已拒绝</view>
-				<view class="f br agree" v-if="item.isAccept == 1">已同意</view>
+				<view class="f br agree" @click.stop="agree(item, 1)" v-if="item.isAccept == 0 && item.isExpire == 0">同意</view>
+				<view class="f danger" @click.stop="agree(item, 2)" v-if="item.isAccept == 0 && item.isExpire == 0">拒绝</view>
+				<view class="f danger" v-if="item.isAccept == 2 && item.isExpire == 0">已拒绝</view>
+				<view class="f br agree" v-if="item.isAccept == 1 && item.isExpire == 0">已同意</view>
+				<view class="f danger" v-if="item.isAccept == 0 && item.isExpire == 1">超时未操作(已过期)</view>
 			</view>
+			<view class="bz" v-if="item.isExpire == 0 && item.isAccept == 0">一个小时内未同意或操作即自动过期</view>
 		</view>
 		<view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
 		<u-empty v-if="!loadMore && list.length == 0"></u-empty>

+ 2 - 1
app/pages/user/resume/application/receive/list.vue

@@ -25,7 +25,8 @@
 			</view>
 			<view class="flex">
 				<view class="f" v-if="item.state == 0">待处理</view>
-				<view class="f" v-if="item.state == 1 && item.isAccept == 0">等待对方同意接单</view>
+				<view class="f" v-if="item.state == 1 && item.isAccept == 0 && item.isExpire == 0">等待对方同意接单</view>
+				<view class="f" v-if="item.state == 1 && item.isAccept == 0 && item.isExpire == 1">对方超时未操作(已过期)</view>
 				<view class="f br" v-if="item.state == 1 && item.isAccept == 1">对方同意接单</view>
 				<view class="f danger" v-if="item.state == 1 && item.isAccept == 2">对方已拒绝</view>
 			</view>

+ 3 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/Position.java

@@ -97,6 +97,9 @@ public class Position extends BaseData {
     @ApiModelProperty(value = "职位审核:0=待审核,1=审核通过,2审核不通过")
     private Integer audit;
 
+    @ApiModelProperty(value = "是否完成:0=否,1=进行中,2=完成")
+    private Integer complete;
+
     @ApiModelProperty(value = "是否推荐:0=否,1=是")
     private Integer recommend;
 

+ 2 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/vo/ReceiveListVo.java

@@ -32,6 +32,8 @@ public class ReceiveListVo {
 
     private Integer isRead;
 
+    private Integer isExpire;
+
     private Integer isContract;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")

+ 32 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/redis/RedisExConfig.java

@@ -0,0 +1,32 @@
+package com.ruoyi.web.work.redis;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.listener.PatternTopic;
+import org.springframework.data.redis.listener.RedisMessageListenerContainer;
+import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
+
+@Configuration
+public class RedisExConfig {
+
+    @Bean
+    public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnectionFactory connectionFactory) {
+        RedisMessageListenerContainer container = new RedisMessageListenerContainer();
+        container.setConnectionFactory(connectionFactory);
+        return container;
+    }
+
+    @Bean
+    public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnectionFactory connectionFactory, MessageListenerAdapter listenerAdapter) {
+        RedisMessageListenerContainer container = new RedisMessageListenerContainer();
+        container.setConnectionFactory(connectionFactory);
+        container.addMessageListener(listenerAdapter, new PatternTopic("__keyevent@*__:expired"));
+        return container;
+    }
+
+    @Bean
+    public MessageListenerAdapter listenerAdapter(RedisKeyExpirationListener listener) {
+        return new MessageListenerAdapter(listener);
+    }
+}

+ 30 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/redis/RedisKeyExpirationListener.java

@@ -0,0 +1,30 @@
+package com.ruoyi.web.work.redis;
+
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.web.work.domain.ResumeDeliver;
+import com.ruoyi.web.work.service.IResumeDeliverService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.connection.Message;
+import org.springframework.data.redis.connection.MessageListener;
+import org.springframework.stereotype.Service;
+
+@Service
+public class RedisKeyExpirationListener implements MessageListener {
+
+    @Autowired
+    private IResumeDeliverService resumeDeliverService;
+
+    @Override
+    public void onMessage(Message message, byte[] pattern) {
+        String expiredKey = message.toString();
+        // 处理过期事件,更新数据库
+        System.out.println("Key expired: " + expiredKey);
+        if (expiredKey.contains("app_deliver")) {
+            ResumeDeliver deliver = resumeDeliverService.getById(StringUtils.getId(expiredKey));
+            if (deliver != null) {
+                deliver.setIsExpire(1);
+                resumeDeliverService.updateById(deliver);
+            }
+        }
+    }
+}

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/impl/PositionServiceImpl.java

@@ -129,7 +129,7 @@ public class PositionServiceImpl extends ServiceImpl<PositionMapper, Position> i
         }
         position.setUserId(AppUtil.getUser().getId());
         position.setState(0);
-        position.setAudit(1);
+        position.setAudit(0);
         position.setRecommend(0);
         if (!save(position)) {
             throw new ServiceException("发布职位失败,请联系平台");

+ 34 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/impl/ResumeDeliverServiceImpl.java

@@ -4,7 +4,9 @@ import cn.hutool.http.HttpUtil;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.constant.CacheConstants;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
@@ -27,6 +29,7 @@ import java.math.BigDecimal;
 import java.text.ParseException;
 import java.util.Date;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 /**
  * @author lsw
@@ -53,6 +56,9 @@ public class ResumeDeliverServiceImpl extends ServiceImpl<ResumeDeliverMapper, R
     private IPayService payService;
 
     @Autowired
+    private RedisCache redisCache;
+
+    @Autowired
     private Environment env;
 
     @Override
@@ -91,6 +97,7 @@ public class ResumeDeliverServiceImpl extends ServiceImpl<ResumeDeliverMapper, R
         return AjaxResult.success();
     }
 
+    @Transactional
     @Override
     public AjaxResult agree(ResumeDeliverDto dto) throws ParseException {
         ResumeDeliver resumeDeliver = getById(dto.getId());
@@ -98,6 +105,21 @@ public class ResumeDeliverServiceImpl extends ServiceImpl<ResumeDeliverMapper, R
             return AjaxResult.error("面试不存在或非法操作");
         }
         resumeDeliver.setIsAccept(dto.getIsAccept());
+        //兼职接单成功,把兼职设置成进行中...
+        if (dto.getIsAccept() == 1 && resumeDeliver.getType() == 1) {
+            String key = CacheConstants.APP_DELIVER + resumeDeliver.getId() + "-" + AppUtil.getUser().getId();
+            if (redisCache.getCacheObject(key) == null) {
+                resumeDeliver.setIsExpire(1);
+                updateById(resumeDeliver);
+                return AjaxResult.error("抱歉你的兼职邀请已经超时无效了");
+            }
+            Position position = new Position();
+            position.setId(resumeDeliver.getPositionId());
+            position.setComplete(1);
+            if (!positionService.updateById(position)) {
+                throw new ServiceException("更新兼职信息失败");
+            }
+        }
         if (!updateById(resumeDeliver)) {
             throw new ServiceException("接受或拒绝面试邀请失败");
         }
@@ -137,7 +159,10 @@ public class ResumeDeliverServiceImpl extends ServiceImpl<ResumeDeliverMapper, R
         if (resumeDeliver == null || !resumeDeliver.getEnterpriseId().equals(AppUtil.getUser().getId()) || resumeDeliver.getType() == 0) {
             return AjaxResult.error("简历不存在或非法操作");
         }
-        List<ResumeDeliver> list = selectList(new ResumeDeliver().setPositionId(resumeDeliver.getPositionId()).setState(1));
+        if(resumeDeliver.getIsExpire()==1){
+            return AjaxResult.error("对方超时未操作(已过期)");
+        }
+        List<ResumeDeliver> list = selectList(new ResumeDeliver().setPositionId(resumeDeliver.getPositionId()).setState(1).setIsExpire(0));
         if (!list.isEmpty() && list.size() > 0) {
             return AjaxResult.error("你已发出兼职邀请,请等待对方答复后或者1小时无回应自动排除");
         }
@@ -155,6 +180,9 @@ public class ResumeDeliverServiceImpl extends ServiceImpl<ResumeDeliverMapper, R
         if (!updateById(resumeDeliver)) {
             throw new ServiceException("发送兼职邀请失败");
         }
+        //用户的接单信息缓存起来60分钟,超时无效。
+        String key = CacheConstants.APP_DELIVER + resumeDeliver.getId() + "-" + resumeDeliver.getUserId();
+        redisCache.setCacheObject(key, resumeDeliver, 1, TimeUnit.MINUTES);
         sendMessage(resumeDeliver);
         return AjaxResult.success();
     }
@@ -313,6 +341,11 @@ public class ResumeDeliverServiceImpl extends ServiceImpl<ResumeDeliverMapper, R
             if (position == null) {
                 throw new ServiceException("兼职不存在");
             }
+            position.setComplete(2);
+            if (!positionService.updateById(position)) {
+                throw new ServiceException("更新兼职信息失败");
+            }
+
             User user = userService.getById(resumeDeliver.getUserId());
             user.setMoney(user.getMoney().add(new BigDecimal(position.getSalary())));
             if (!userService.updateById(user)) {

+ 2 - 0
ruoyi-admin/src/main/resources/application.yml

@@ -79,6 +79,8 @@ spring:
     password:
     # 连接超时时间
     timeout: 60s
+    listener:
+      keyspace-notifications-enabled: true
     lettuce:
       pool:
         # 连接池中的最小空闲连接

+ 1 - 0
ruoyi-admin/src/main/resources/mapper/work/PositionMapper.xml

@@ -48,6 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         WHERE
         state = 0
         AND audit = 1
+        AND complete = 0
         <if test="type != null "> AND type = #{type}</if>
         <if test="enterpriseId != null "> AND user_id = #{enterpriseId}</if>
         <if test="title != null and title != ''"> AND title LIKE concat('%', #{title}, '%')</if>

+ 1 - 1
ruoyi-admin/src/main/resources/mapper/work/UserMapper.xml

@@ -31,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             ( SELECT COUNT( d.id ) FROM tb_resume_deliver d WHERE d.enterprise_id = u.id AND d.is_complete !=2 AND d.type=1 AND d.is_accept=1) AS completeApplication, /*甲方正在进行任务数*/
             ( SELECT COUNT( d.id ) FROM tb_resume_deliver d WHERE d.user_id = u.id AND d.is_complete !=2 AND d.type=1 AND d.is_accept=1) AS completeIng, /*已方正在进行任务数*/
             ( SELECT COUNT( d.id ) FROM tb_resume_deliver d WHERE d.enterprise_id = u.id AND d.is_read = 0 AND d.type=1) AS noReadApplication, /*甲方收到未查看报名数*/
-            ( SELECT COUNT( d.id ) FROM tb_resume_deliver d WHERE d.user_id = u.id AND d.state = 1 AND is_accept = 0 AND type=1) AS partTimeAccept/*兼职邀约未处理*/
+            ( SELECT COUNT( d.id ) FROM tb_resume_deliver d WHERE d.user_id = u.id AND d.state = 1 AND is_accept = 0 AND type=1 AND is_expire=0) AS partTimeAccept/*兼职邀约未处理*/
         FROM
             tb_user u
         WHERE

+ 9 - 0
ruoyi-admin/src/test/java/com/ruoyi/test.java

@@ -0,0 +1,9 @@
+package com.ruoyi;
+
+import com.ruoyi.common.utils.StringUtils;
+
+public class test {
+    public static void main(String[] args) {
+        System.out.println(StringUtils.getId("app_deliver:356-21"));
+    }
+}

+ 2 - 0
ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java

@@ -95,4 +95,6 @@ public class CacheConstants {
      * 平台信息 redis key
      */
     public static final String APP_PLATFORM= "app_platform:";
+
+    public static final String APP_DELIVER= "app_deliver:";
 }

+ 10 - 3
ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java

@@ -612,9 +612,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
         }
     }
 
-    public static Long getId(String fileName) {
-        return Long.parseLong(fileName.substring(fileName.lastIndexOf("/") + 1));
-    }
 
     public static InputStream createTxt(String text) {
         try {
@@ -718,6 +715,16 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
 
         return number;
     }
+    public static Long getId(String input) {
+        Pattern pattern = Pattern.compile("app_deliver:(\\d+)-");
+        Matcher matcher = pattern.matcher(input);
+
+        if (matcher.find()) {
+            return Long.parseLong(matcher.group(1));
+        } else {
+            return null;
+        }
+    }
     public static String truncateString(String input, int maxLength) {
         if (input == null || input.length() <= maxLength) {
             return input;