提交 debf974c authored 作者: liuhaiquan's avatar liuhaiquan

货主充值增加自动冻结逻辑触发

上级 41b83ba2
......@@ -59,4 +59,10 @@ public class RabbitKeyConstants {
public static final String ORDER_CANCEL_ROUTE_KEY ="clx-order.order.cancel.route.key";
// 预付运费和保证金 自动冻结 触发消息队列
public static final String FREEZE_TRIGGER_EXCHANGE = "clx-order.freeze.trigger.exchange";
public static final String FREEZE_TRIGGER_QUEUE = "clx-order.freeze.trigger.queue";
public static final String FREEZE_TRIGGER_ROUTING_KEY = "clx-order.freeze.trigger.routing.key";
}
......@@ -20,7 +20,7 @@ public class OwnerInfoServiceImpl implements OwnerInfoService {
@Override
public OwnerInfoFeignVO getOwnerInfo(Long userNo) {
return Optional.ofNullable(ownerInfoFeign.getOwnerInfo(userNo))
.filter(Result::succeed).map(item->item.getData()).orElseThrow(ResultCodeEnum.FAIL);
.filter(Result::succeed).map(Result::getData).orElseThrow(ResultCodeEnum.FAIL,"未查询到对应的货主信息");
}
}
......@@ -3,12 +3,17 @@ package com.clx.performance.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.clx.order.param.mq.FreezeTriggerMqParam;
import com.clx.performance.common.MqWrapper;
import com.clx.performance.component.IdGenerateSnowFlake;
import com.clx.performance.constant.RabbitKeyConstants;
import com.clx.performance.dao.*;
import com.clx.performance.enums.IdTypeEnum;
import com.clx.performance.enums.OwnerAccountEnum;
import com.clx.performance.enums.PerformanceResultEnum;
import com.clx.performance.extranal.user.OwnerInfoService;
import com.clx.performance.model.*;
import com.clx.performance.param.open.OpenOwnerBindCardParam;
import com.clx.performance.param.open.OpenOwnerCaseOutParam;
......@@ -26,10 +31,10 @@ import com.clx.performance.utils.excel.ExcelUtil;
import com.clx.performance.vo.pc.OwnerAccountAllVO;
import com.clx.performance.vo.pc.OwnerAccountRunningWaterRecordVO;
import com.clx.performance.vo.pc.OwnerAccountVO;
import com.clx.user.enums.driver.DriverTruckEnum;
import com.clx.user.enums.owner.FreezeSettingEnum;
import com.clx.user.feign.OwnerInfoFeign;
import com.clx.user.param.pc.owner.UpdateOwnerBindCardFeignParam;
import com.clx.user.vo.pc.driver.truck.DriverTruckVo;
import com.clx.user.vo.feign.OwnerInfoFeignVO;
import com.clx.user.vo.pc.owner.OwnerBindCardVO;
import com.msl.common.base.Optional;
import com.msl.common.exception.ServiceSystemException;
......@@ -40,12 +45,17 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageBuilder;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Slf4j
@Service
......@@ -70,6 +80,10 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
private final OwnerAccountStruct ownerAccountStruct;
private final RabbitTemplate rabbitTemplate;
private final OwnerInfoService ownerInfoService;
@Override
public IPage<OwnerAccountVO> pageList(PageOwnerAccountListParam param) {
return ownerAccountDao.pageList(param);
......@@ -319,8 +333,17 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
break;
}
}
OwnerInfoFeignVO ownerInfo = ownerInfoService.getOwnerInfo(loginUserInfo.getUserNo());
//充值成功并且当前货主是冻结方式是自动冻结,则触发自动冻结的mq监听
if(Objects.equals(ownerInfo.getFreezeSetting(), FreezeSettingEnum.AUTO.getCode())){
log.info("货主编码:{},货主姓名:{},充值成功金额:{},发送自动冻结的mq消息",loginUserInfo.getUserNo(),loginUserInfo.getUserName(),topUpBalance);
FreezeTriggerMqParam mq = new FreezeTriggerMqParam();
mq.setUserNo(loginUserInfo.getUserNo());
Message message = MessageBuilder.withBody(JSON.toJSONString(new MqWrapper<>(mq)).getBytes()).build();
//设置延时5秒处理,防止事务未提交
message.getMessageProperties().setExpiration("5000");
rabbitTemplate.send(RabbitKeyConstants.FREEZE_TRIGGER_EXCHANGE, RabbitKeyConstants.FREEZE_TRIGGER_ROUTING_KEY,message);
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论