|
@@ -20,17 +20,25 @@ import com.fire.dto.FlowAppInfo;
|
|
|
import com.fire.dto.enums.Status;
|
|
|
import com.fire.utils.date.DateUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.messaging.support.MessageBuilder;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import redis.clients.jedis.JedisCluster;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import static com.fire.common.constants.RocketTags.CONSUMER_PRODUCT_TAG;
|
|
|
+import static com.fire.common.constants.RocketTags.MAKE_TAG;
|
|
|
+import static com.fire.common.constants.RocketTopic.ORDER_TOPIC;
|
|
|
+import static com.fire.common.constants.RocketTopic.UPDATE_TOPIC;
|
|
|
import static com.fire.dto.enums.RedisKey.CUSTOMER_AMOUNT;
|
|
|
import static com.fire.dto.enums.RedisKey.GLOBAL_ID_INCR;
|
|
|
+import static com.fire.dto.enums.RocketQueue.ORDER_QUEUE;
|
|
|
|
|
|
/**
|
|
|
* @author: liuliu
|
|
@@ -51,6 +59,10 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, CustomerInf
|
|
|
@Autowired
|
|
|
private BankCardService bankCardService;
|
|
|
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private RocketMQTemplate rocketMQTemplate;
|
|
|
+
|
|
|
/**
|
|
|
* @Description: TODO 分页获取客户信息
|
|
|
* @Param: 查询条件,根据客户名称模糊查询
|
|
@@ -117,6 +129,8 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, CustomerInf
|
|
|
if (count1 > 0 && count2 > 0) {
|
|
|
// TODO 发送消息到 topic 分别发送到 客户的 topic 以及 客户接入的 topic
|
|
|
|
|
|
+ rocketMQTemplate.send(UPDATE_TOPIC + ":" + CONSUMER_PRODUCT_TAG, MessageBuilder.withPayload(CONSUMER_PRODUCT_TAG).build());
|
|
|
+
|
|
|
log.info("新增客户对象为:【{}】", customerInfo.toString());
|
|
|
log.info("新增客户接入信息为:【{}】", appInfo.toString());
|
|
|
|
|
@@ -158,7 +172,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, CustomerInf
|
|
|
.address(customerDto.getAddress())
|
|
|
.status(customerDto.getStatus())
|
|
|
.balance(customerDto.getBalance())
|
|
|
- .creditAmount(customerDto.getCreditAmount())
|
|
|
+ .creditAmount(customerDto.getCreditAmount().longValue())
|
|
|
.currentAmount(customerDto.getCurrentAmount())
|
|
|
.isFirstLogin(customerDto.getIsFirstLogin())
|
|
|
.isDeleted(customerDto.getIsDeleted())
|
|
@@ -179,6 +193,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, CustomerInf
|
|
|
|
|
|
if (count > 0) {
|
|
|
log.info("------------------------- 客户修改成功,发送消息到相应的topic --------------------------------");
|
|
|
+ rocketMQTemplate.send(UPDATE_TOPIC + ":" + CONSUMER_PRODUCT_TAG, MessageBuilder.withPayload(CONSUMER_PRODUCT_TAG).build());
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -235,7 +250,8 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, CustomerInf
|
|
|
.isDeleted(1).build();
|
|
|
int count = baseMapper.updateById(info);
|
|
|
if (count > 0) {
|
|
|
- log.info("客户编号为:【{}】 执行了删除操作", customerId);
|
|
|
+ log.info("客户编号为:【{}】 执行了删除操作 , 并发送消息到 topic", customerId);
|
|
|
+ rocketMQTemplate.send(UPDATE_TOPIC + ":" + CONSUMER_PRODUCT_TAG, MessageBuilder.withPayload(CONSUMER_PRODUCT_TAG).build());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -252,8 +268,29 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, CustomerInf
|
|
|
.status(status).build();
|
|
|
int count = baseMapper.updateById(info);
|
|
|
if (count > 0) {
|
|
|
- log.info("客户编号为:【{}】 修改了有效性", customerId);
|
|
|
+ log.info("客户编号为:【{}】 修改了有效性,并发送消息到 topic", customerId);
|
|
|
+ rocketMQTemplate.send(UPDATE_TOPIC + ":" + CONSUMER_PRODUCT_TAG, MessageBuilder.withPayload(CONSUMER_PRODUCT_TAG).build());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Description: TODO 客户授信
|
|
|
+ * @Param: [customerId, creditAmount]
|
|
|
+ * @return: java.lang.Long
|
|
|
+ * @Author: liuliu
|
|
|
+ * @Date: 2021/6/11 11:06
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void creditCustomer(Long customerId, BigDecimal creditAmount) {
|
|
|
+ long amount = creditAmount.multiply(new BigDecimal(10000)).longValue();
|
|
|
+ CustomerInfo customerInfo = CustomerInfo.builder().customerId(customerId).creditAmount(amount).build();
|
|
|
+ int count = baseMapper.updateById(customerInfo);
|
|
|
+ if (count > 0) {
|
|
|
+ log.info("客户编号为:【{}】 加款,加款金额为:【{}】,并发送消息到topic", customerId, creditAmount);
|
|
|
+ // TODO 发送topic
|
|
|
+ rocketMQTemplate.send(UPDATE_TOPIC + ":" + CONSUMER_PRODUCT_TAG, MessageBuilder.withPayload(CONSUMER_PRODUCT_TAG).build());
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|