|
|
@@ -1,12 +1,9 @@
|
|
|
package io.renren.modules.listener;
|
|
|
|
|
|
-import cn.hutool.core.util.NumberUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.rabbitmq.client.Channel;
|
|
|
import io.renren.common.canstant.QueueConstant;
|
|
|
import io.renren.common.enums.EnterpriseStatusEnum;
|
|
|
-import io.renren.modules.qmgj.dao.MemberInfoDao;
|
|
|
-import io.renren.modules.qmgj.entity.MemberInfoEntity;
|
|
|
import io.renren.modules.qyh.entity.EnterpriseEntity;
|
|
|
import io.renren.modules.qyh.service.EnterpriseService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -16,7 +13,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.IOException;
|
|
|
-import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
|
@Component
|
|
|
@Slf4j
|
|
|
@@ -30,14 +27,22 @@ public class EnterpriseVipListener {
|
|
|
String s = new String(message.getBody());
|
|
|
JSONObject jsonObject = JSONObject.parseObject(s);
|
|
|
Long id = Long.parseLong(jsonObject.get("enterpriseId").toString());
|
|
|
- EnterpriseEntity enterpriseEntity = enterpriseService.getById(id);
|
|
|
+ long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
|
|
try {
|
|
|
- if(!LocalDate.now().equals(enterpriseEntity.getExpiredTime().toLocalDate())) {
|
|
|
+ EnterpriseEntity enterpriseEntity = enterpriseService.getById(id);
|
|
|
+ if (enterpriseEntity == null) {
|
|
|
+ log.info("企业不存在,ID: {}", id);
|
|
|
+ channel.basicAck(deliveryTag, false);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (enterpriseEntity.getExpiredTime().isAfter(LocalDateTime.now())) {
|
|
|
log.info("该企业已成功续费会员");
|
|
|
- channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
+ channel.basicAck(deliveryTag, false);
|
|
|
+ return;
|
|
|
}
|
|
|
enterpriseEntity.setStatus(EnterpriseStatusEnum.EXPIRED.value());
|
|
|
enterpriseService.updateById(enterpriseEntity);
|
|
|
+ channel.basicAck(deliveryTag, false);
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|