双屏消费机-用户信息查询、mq推送
This commit is contained in:
parent
53584586d5
commit
8602e68f37
|
|
@ -185,7 +185,7 @@ public class AccInfoServiceImpl implements IAccInfoService {
|
||||||
Long userId = users.get(i).getUserId();
|
Long userId = users.get(i).getUserId();
|
||||||
accWalletInfoService.deleteAccWalletInfoByUserId(userId);
|
accWalletInfoService.deleteAccWalletInfoByUserId(userId);
|
||||||
MqUtil.sendDataChange(userId, LeMqConstant.DataChangeType.REMOVE, LeMqConstant.Topic.DATA_CHANGE_CUSTOMER);
|
MqUtil.sendDataChange(userId, LeMqConstant.DataChangeType.REMOVE, LeMqConstant.Topic.DATA_CHANGE_CUSTOMER);
|
||||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePersonPhoto(Math.toIntExact(userId));
|
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(Math.toIntExact(userId),"del");
|
||||||
MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
||||||
count += accInfoMapper.deleteAccInfoByUserId(userId);
|
count += accInfoMapper.deleteAccInfoByUserId(userId);
|
||||||
}
|
}
|
||||||
|
|
@ -213,7 +213,7 @@ public class AccInfoServiceImpl implements IAccInfoService {
|
||||||
}
|
}
|
||||||
|
|
||||||
MqUtil.sendDataChange(sysUser.getUserId(), LeMqConstant.DataChangeType.ADD, LeMqConstant.Topic.DATA_CHANGE_CUSTOMER);
|
MqUtil.sendDataChange(sysUser.getUserId(), LeMqConstant.DataChangeType.ADD, LeMqConstant.Topic.DATA_CHANGE_CUSTOMER);
|
||||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePersonPhoto(Math.toIntExact(sysUser.getUserId()));
|
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(Math.toIntExact(sysUser.getUserId()),"update");
|
||||||
MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
||||||
return this.accWalletInfoService.batchInsertAccWalletInfo(accWalletInfos);
|
return this.accWalletInfoService.batchInsertAccWalletInfo(accWalletInfos);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.bonus.canteen.core.android.controller;
|
||||||
|
|
||||||
|
import com.bonus.canteen.core.android.dto.AppDTO;
|
||||||
|
import com.bonus.canteen.core.android.service.UserService;
|
||||||
|
import com.bonus.common.core.exception.ServiceException;
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@Api(tags = "android-双屏消费机-用户信息")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/android/user")
|
||||||
|
public class UserController {
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
|
@ApiOperation("获取人员信息")
|
||||||
|
@RequestMapping("/getUserInfo")
|
||||||
|
public AjaxResult getUserInfo(@RequestBody AppDTO dto) {
|
||||||
|
try {
|
||||||
|
return userService.getUserInfo(dto);
|
||||||
|
}catch (ServiceException e){
|
||||||
|
return AjaxResult.error("获取人员信息失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -11,4 +11,6 @@ public class AppDTO {
|
||||||
private String deviceSn;
|
private String deviceSn;
|
||||||
|
|
||||||
private String time;
|
private String time;
|
||||||
|
|
||||||
|
private String type;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.bonus.canteen.core.android.mapper;
|
||||||
|
|
||||||
|
import com.bonus.canteen.core.android.dto.AppDTO;
|
||||||
|
import com.bonus.canteen.core.android.vo.UserInfoVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface UserMapper {
|
||||||
|
/**
|
||||||
|
* 获取人员信息
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<UserInfoVo> getUserInfo(AppDTO dto);
|
||||||
|
/**
|
||||||
|
* 获取人员钱包余额
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<UserInfoVo> getMoneyList();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.bonus.canteen.core.android.service;
|
||||||
|
|
||||||
|
import com.bonus.canteen.core.android.dto.AppDTO;
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
|
||||||
|
public interface UserService {
|
||||||
|
/**
|
||||||
|
* 获取人员信息
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult getUserInfo(AppDTO dto);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.bonus.canteen.core.android.service.impl;
|
||||||
|
|
||||||
|
import com.bonus.canteen.core.android.dto.AppDTO;
|
||||||
|
import com.bonus.canteen.core.android.mapper.UserMapper;
|
||||||
|
import com.bonus.canteen.core.android.service.UserService;
|
||||||
|
import com.bonus.canteen.core.android.vo.UserInfoVo;
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
@Service
|
||||||
|
public class UserServiceImpl implements UserService {
|
||||||
|
@Autowired
|
||||||
|
private UserMapper mapper;
|
||||||
|
/**
|
||||||
|
* 获取人员信息
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AjaxResult getUserInfo(AppDTO dto) {
|
||||||
|
List<UserInfoVo> list = mapper.getUserInfo(dto);
|
||||||
|
List<UserInfoVo> moneyList = mapper.getMoneyList();
|
||||||
|
if (!list.isEmpty()){
|
||||||
|
list.forEach(userInfoVo -> {
|
||||||
|
UserInfoVo money = moneyList.stream().filter(moneyVo -> moneyVo.getUserId().equals(userInfoVo.getUserId())).findFirst().orElse(null);
|
||||||
|
if (money != null){
|
||||||
|
userInfoVo.setPersonalWalletBalance(money.getPersonalWalletBalance());
|
||||||
|
userInfoVo.setSubsidiesBalance(money.getSubsidiesBalance());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
System.out.println(list);
|
||||||
|
}else {
|
||||||
|
return AjaxResult.success(new ArrayList<UserInfoVo>());
|
||||||
|
}
|
||||||
|
return AjaxResult.success(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.bonus.canteen.core.android.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ToString
|
||||||
|
public class UserInfoVo {
|
||||||
|
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
private String accId;
|
||||||
|
/**
|
||||||
|
* 卡号
|
||||||
|
*/
|
||||||
|
private String cardNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 序列号 物理卡号
|
||||||
|
*/
|
||||||
|
private String serialNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 个人钱包余额
|
||||||
|
*/
|
||||||
|
private BigDecimal personalWalletBalance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补贴余额
|
||||||
|
*/
|
||||||
|
private BigDecimal subsidiesBalance;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -20,6 +20,16 @@ public class DeviceMqPersonalUpdateMessageDTO {
|
||||||
private Integer updateValidityPhoto;
|
private Integer updateValidityPhoto;
|
||||||
@ApiModelProperty("当前时间")
|
@ApiModelProperty("当前时间")
|
||||||
private String currentTime;
|
private String currentTime;
|
||||||
|
@ApiModelProperty("类型")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
public void setCurrentTime(String currentTime) {
|
public void setCurrentTime(String currentTime) {
|
||||||
this.currentTime = currentTime;
|
this.currentTime = currentTime;
|
||||||
|
|
@ -54,15 +64,17 @@ public class DeviceMqPersonalUpdateMessageDTO {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DeviceMqPersonalUpdateMessageDTO setUpdatePerson(final Integer updatePerson) {
|
public DeviceMqPersonalUpdateMessageDTO setUpdatePerson(final Integer updatePerson, final String type) {
|
||||||
this.currentTime = DateUtils.getTime();
|
this.currentTime = DateUtils.getTime();
|
||||||
this.updatePerson = updatePerson;
|
this.updatePerson = updatePerson;
|
||||||
|
this.type = type;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeviceMqPersonalUpdateMessageDTO setUpdatePersonPhoto(final Integer updatePersonPhoto) {
|
public DeviceMqPersonalUpdateMessageDTO setUpdatePersonPhoto(final Integer updatePersonPhoto) {
|
||||||
this.currentTime = DateUtils.getTime();
|
this.currentTime = DateUtils.getTime();
|
||||||
this.updatePersonPhoto = updatePersonPhoto;
|
this.updatePersonPhoto = updatePersonPhoto;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,6 +106,7 @@ public class DeviceMqPersonalUpdateMessageDTO {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DeviceMqPersonalUpdateMessageDTO{" +
|
return "DeviceMqPersonalUpdateMessageDTO{" +
|
||||||
"updatePerson=" + updatePerson +
|
"updatePerson=" + updatePerson +
|
||||||
|
", type=" + type +
|
||||||
", updatePersonPhoto=" + updatePersonPhoto +
|
", updatePersonPhoto=" + updatePersonPhoto +
|
||||||
", updateCardStatus=" + updateCardStatus +
|
", updateCardStatus=" + updateCardStatus +
|
||||||
", isAccBalChange=" + isAccBalChange +
|
", isAccBalChange=" + isAccBalChange +
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ public class UserFaceServiceImpl implements IUserFaceService {
|
||||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePersonPhoto(1);
|
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePersonPhoto(1);
|
||||||
System.out.println(bean.toString());
|
System.out.println(bean.toString());
|
||||||
//发送mq
|
//发送mq
|
||||||
// MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.bonus.canteen.core.android.mapper.UserMapper">
|
||||||
|
<select id="getUserInfo" resultType="com.bonus.canteen.core.android.vo.UserInfoVo">
|
||||||
|
select
|
||||||
|
su.user_id as userId,
|
||||||
|
su.nick_name as userName,
|
||||||
|
ac.acc_id as accId,
|
||||||
|
ac.card_num as cardNum,
|
||||||
|
ac.serial_num as serialNum
|
||||||
|
from sys_user su
|
||||||
|
left join acc_card ac on ac.user_id = su.user_id
|
||||||
|
<where>
|
||||||
|
<if test="type == 'user'">
|
||||||
|
<if test="time != null and time != ''">
|
||||||
|
AND su.update_time >= #{time} - INTERVAL 5 SECOND;
|
||||||
|
</if>
|
||||||
|
</if>
|
||||||
|
<if test="type == 'card'">
|
||||||
|
<if test="time != null and time != ''">
|
||||||
|
AND ac.update_time >= #{time} - INTERVAL 5 SECOND;
|
||||||
|
</if>
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
<select id="getMoneyList" resultType="com.bonus.canteen.core.android.vo.UserInfoVo">
|
||||||
|
SELECT
|
||||||
|
sum(r.personalWalletBalance) as personalWalletBalance,
|
||||||
|
sum(r.subsidiesBalance) as subsidiesBalance,
|
||||||
|
r.user_id as userId
|
||||||
|
from( select
|
||||||
|
user_id,
|
||||||
|
IF(wallet_id = 1,wallet_bal,0) as personalWalletBalance,
|
||||||
|
IF(wallet_id = 2,wallet_bal,0) as subsidiesBalance,
|
||||||
|
wallet_bal
|
||||||
|
from acc_wallet_info)r
|
||||||
|
GROUP BY r.user_id
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue