|
@@ -1,16 +1,20 @@
|
|
|
package com.fire.admin.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.RandomUtil;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fire.admin.dto.CustomerDto;
|
|
|
import com.fire.admin.mapper.CustomerMapper;
|
|
|
+import com.fire.admin.mapper.FlowAppMapper;
|
|
|
import com.fire.admin.service.CustomerService;
|
|
|
import com.fire.admin.util.SecurityUtil;
|
|
|
import com.fire.admin.vo.CustomerInfoVo;
|
|
|
import com.fire.dto.CustomerInfo;
|
|
|
+import com.fire.dto.FlowAppInfo;
|
|
|
import com.fire.utils.date.DateUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import redis.clients.jedis.JedisCluster;
|
|
|
|
|
@@ -32,6 +36,9 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, CustomerInf
|
|
|
@Resource
|
|
|
private JedisCluster jedisCluster;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private FlowAppMapper flowAppMapper;
|
|
|
+
|
|
|
/**
|
|
|
* @Description: TODO 分页获取客户信息
|
|
|
* @Param: 查询条件,根据客户名称模糊查询
|
|
@@ -54,6 +61,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, CustomerInf
|
|
|
*/
|
|
|
@Override
|
|
|
public void insertCustomer(CustomerDto customerDto) {
|
|
|
+ // TODO 新增客户
|
|
|
CustomerInfo customerInfo = CustomerInfo.builder().partnerId(customerDto.getPartnerId())
|
|
|
.customerName(customerDto.getCustomerName())
|
|
|
.shorterName(customerDto.getShorterName())
|
|
@@ -70,11 +78,25 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, CustomerInf
|
|
|
.partnerCommission(customerDto.getPartnerCommission())
|
|
|
.userId(customerDto.getUserId())
|
|
|
.priceCheck(customerDto.getPriceCheck()).build();
|
|
|
- baseMapper.insert(customerInfo);
|
|
|
-
|
|
|
- log.info("新增客户对象为:【{}】", customerInfo.toString());
|
|
|
+ int count1 = baseMapper.insert(customerInfo);
|
|
|
+ // TODO 新增客户接入
|
|
|
+ FlowAppInfo appInfo = FlowAppInfo.builder().customerId(customerInfo.getCustomerId())
|
|
|
+ .appId(RandomUtil.randomString(8))
|
|
|
+ .appKey(RandomUtil.randomString(32))
|
|
|
+ .startDate(DateUtils.strformatDatetime(LocalDateTime.now()))
|
|
|
+ .status(1)
|
|
|
+ .appName(customerInfo.getCustomerName().concat("话费包接入"))
|
|
|
+ .totalCount(1)
|
|
|
+ .time(7200).build();
|
|
|
+ int count2 = flowAppMapper.insert(appInfo);
|
|
|
+ if (count1 > 0 && count2 > 0) {
|
|
|
+ // TODO 发送消息到 topic 分别发送到 客户的 topic 以及 客户接入的 topic
|
|
|
|
|
|
+ log.info("新增客户对象为:【{}】", customerInfo.toString());
|
|
|
+ log.info("新增客户接入信息为:【{}】", appInfo.toString());
|
|
|
+ }
|
|
|
jedisCluster.hset(CUSTOMER_AMOUNT.key(), CUSTOMER_AMOUNT.key().concat(customerInfo.getCustomerId().toString()), "0");
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|