|
@@ -1,16 +1,29 @@
|
|
package com.usky.dxtop.service.impl;
|
|
package com.usky.dxtop.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.usky.dxtop.common.core.page.CommonPage;
|
|
import com.usky.dxtop.common.core.page.CommonPage;
|
|
|
|
+import com.usky.dxtop.common.exception.CustomException;
|
|
|
|
+import com.usky.dxtop.common.utils.StringUtils;
|
|
import com.usky.dxtop.mapper.StaffMapper;
|
|
import com.usky.dxtop.mapper.StaffMapper;
|
|
|
|
+import com.usky.dxtop.model.MsgLog;
|
|
import com.usky.dxtop.model.Staff;
|
|
import com.usky.dxtop.model.Staff;
|
|
|
|
+import com.usky.dxtop.service.MsgLogService;
|
|
import com.usky.dxtop.service.StaffService;
|
|
import com.usky.dxtop.service.StaffService;
|
|
|
|
+import com.usky.dxtop.service.config.rabbitmq.cartget.CartGetConsumeConfig;
|
|
import com.usky.dxtop.service.vo.StaffRequest;
|
|
import com.usky.dxtop.service.vo.StaffRequest;
|
|
|
|
+import org.springframework.amqp.rabbit.connection.CorrelationData;
|
|
|
|
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 服务实现类
|
|
* 服务实现类
|
|
@@ -22,8 +35,13 @@ import org.springframework.stereotype.Service;
|
|
@Service
|
|
@Service
|
|
public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements StaffService {
|
|
public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements StaffService {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ @Qualifier(CartGetConsumeConfig.TEMPLATE)
|
|
|
|
+ private RabbitTemplate rabbitTemplate;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private MsgLogService msgLogService;
|
|
|
|
|
|
- //TODO 需要世贸提供数据后从写mapper
|
|
|
|
@Override
|
|
@Override
|
|
public CommonPage<Staff> page(StaffRequest staffRequest) {
|
|
public CommonPage<Staff> page(StaffRequest staffRequest) {
|
|
IPage<Staff> page = new Page<>(staffRequest.getCurrent(), staffRequest.getSize());
|
|
IPage<Staff> page = new Page<>(staffRequest.getCurrent(), staffRequest.getSize());
|
|
@@ -34,4 +52,30 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
|
staffRequest.getCard());
|
|
staffRequest.getCard());
|
|
return new CommonPage<>(page.getRecords(),page.getTotal(),page.getCurrent(),page.getSize());
|
|
return new CommonPage<>(page.getRecords(),page.getTotal(),page.getCurrent(),page.getSize());
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String getBalance(String card) {
|
|
|
|
+ MsgLog msgLog = new MsgLog();
|
|
|
|
+ msgLog.setBusinessId(0L);
|
|
|
|
+ msgLog.setExchange(CartGetConsumeConfig.NAME);
|
|
|
|
+ msgLog.setRoutingKey(CartGetConsumeConfig.NAME);
|
|
|
|
+ msgLog.setRemark("获取卡余额");
|
|
|
|
+ msgLogService.save(msgLog);
|
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
|
+ map.put("seq",msgLog.getId());
|
|
|
|
+ map.put("card",card);
|
|
|
|
+ msgLog.setMsg(JSON.toJSONString(map));
|
|
|
|
+ msgLogService.updateById(msgLog);
|
|
|
|
+ CorrelationData correlationData = new CorrelationData(msgLog.getId().toString());
|
|
|
|
+ rabbitTemplate.convertAndSend(msgLog.getExchange(), msgLog.getRoutingKey(), msgLog.getMsg(),correlationData);
|
|
|
|
+ return msgLog.getId().toString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Staff one(String id, String phone, String card) {
|
|
|
|
+ if (StringUtils.isBlank(id) && StringUtils.isBlank(phone) && StringUtils.isBlank(card)){
|
|
|
|
+ throw new CustomException("手机号,用户编号,卡号至少输入一个");
|
|
|
|
+ }
|
|
|
|
+ return baseMapper.one(id,phone,card);
|
|
|
|
+ }
|
|
}
|
|
}
|