feat:柜子信息
This commit is contained in:
1 parent
29e1cddcf6
commit
44775cd2d9
19 files changed
+509
-215
No files matched your search
@@ -52,9 +52,10 @@ CREATE TABLE hard_door_manager
|
||||
power_status int DEFAULT NULL COMMENT '1:通电;2:断电',
|
||||
net_status int DEFAULT NULL COMMENT '在线状态。1:在线;2:离线',
|
||||
sale_status int DEFAULT NULL COMMENT '售卖状态。1:在售;2:停售',
|
||||
sim_sn varchar(32) NOT NULL COMMENT 'sim 卡号。设备有上报会返回,若一次上报都没有,则返回 null',
|
||||
signal_intensity int DEFAULT NULL COMMENT 'sim 信号强度。大于-95 表示信号强度好;-95 到-105 表示信号强度中等;小于-105 表示信号差;',
|
||||
signal_ratio int DEFAULT NULL COMMENT '信噪比,体现信道传输质量的参数。大于 15 表示质量好;15 到 0 表示质量中等;小于等于 0 表示质量差;',
|
||||
signal_time int DEFAULT NULL COMMENT 'sim 信号值更新时间。yyyy-MM-dd HH:mm:ss',
|
||||
signal_time datetime DEFAULT NULL COMMENT 'sim 信号值更新时间。yyyy-MM-dd HH:mm:ss',
|
||||
cabinet_list text DEFAULT NULL COMMENT '货柜列表JSON',
|
||||
restart_time datetime DEFAULT NULL COMMENT '上次重启时间',
|
||||
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
|
||||
@@ -266,6 +267,7 @@ CREATE TABLE hard_broadcast
|
||||
user_id bigint NOT NULL COMMENT '预定用户',
|
||||
hard_id bigint NOT NULL COMMENT '硬件id',
|
||||
topic varchar(128) NOT NULL COMMENT 'mq主题',
|
||||
biz_type varchar(64) NOT NULL COMMENT '关联业务类型',
|
||||
biz_id varchar(64) NOT NULL COMMENT '关联业务编号',
|
||||
title varchar(64) NOT NULL COMMENT '预定标题',
|
||||
content varchar(128) NOT NULL COMMENT '广播内容',
|
||||
|
||||
@@ -415,6 +415,7 @@ CREATE TABLE wallet_code_use
|
||||
status char(1) DEFAULT '0' NOT NULL COMMENT '是否使用',
|
||||
code varchar(1024) DEFAULT NULL COMMENT '二维码',
|
||||
code_content varchar(1024) DEFAULT NULL COMMENT '二维码内容',
|
||||
short_code varchar(32) DEFAULT '' COMMENT '短码',
|
||||
use_time timestamp NULL COMMENT '使用时间',
|
||||
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
|
||||
create_time datetime DEFAULT NULL COMMENT '创建时间',
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.bsd.pjcloud.hard.api.constant;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 硬件广播类型
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum HardBroadcastEnum {
|
||||
OFFLINE_CANTEEN_RESERVE("1", "线下食堂订餐广播"),
|
||||
;
|
||||
private final String type;
|
||||
private final String description;
|
||||
|
||||
public static HardBroadcastEnum valueOfByType(String type) {
|
||||
if (ObjectUtil.isEmpty(type)) return null;
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
|
||||
}
|
||||
}
|
||||
+88
-79
@@ -3,14 +3,17 @@ package com.bsd.pjcloud.hard.api.entity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.*;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 设备广播
|
||||
*/
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@TenantTable
|
||||
@TableName("hard_broadcast")
|
||||
@@ -19,118 +22,124 @@ import java.time.LocalDateTime;
|
||||
public class HardBroadcastEntity extends Model<HardBroadcastEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description="编号")
|
||||
@Schema(description = "编号")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 预定用户
|
||||
*/
|
||||
@Schema(description="预定用户")
|
||||
/**
|
||||
* 预定用户
|
||||
*/
|
||||
@Schema(description = "预定用户")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 硬件id
|
||||
*/
|
||||
@Schema(description="硬件id")
|
||||
/**
|
||||
* 硬件id
|
||||
*/
|
||||
@Schema(description = "硬件id")
|
||||
private Long hardId;
|
||||
|
||||
/**
|
||||
* mq主题
|
||||
*/
|
||||
@Schema(description="mq主题")
|
||||
/**
|
||||
* mq主题
|
||||
*/
|
||||
@Schema(description = "mq主题")
|
||||
private String topic;
|
||||
|
||||
/**
|
||||
* 关联业务编号
|
||||
*/
|
||||
@Schema(description="关联业务编号")
|
||||
/**
|
||||
* 业务类型
|
||||
*/
|
||||
@Schema(description = "业务类型")
|
||||
private String bizType;
|
||||
|
||||
/**
|
||||
* 关联业务编号
|
||||
*/
|
||||
@Schema(description = "关联业务编号")
|
||||
private String bizId;
|
||||
|
||||
/**
|
||||
* 预定标题
|
||||
*/
|
||||
@Schema(description="预定标题")
|
||||
/**
|
||||
* 预定标题
|
||||
*/
|
||||
@Schema(description = "预定标题")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 广播内容
|
||||
*/
|
||||
@Schema(description="广播内容")
|
||||
/**
|
||||
* 广播内容
|
||||
*/
|
||||
@Schema(description = "广播内容")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 当前广播次数
|
||||
*/
|
||||
@Schema(description="当前广播次数")
|
||||
/**
|
||||
* 当前广播次数
|
||||
*/
|
||||
@Schema(description = "当前广播次数")
|
||||
private Integer broadcastCount;
|
||||
|
||||
/**
|
||||
* 最大广播次数
|
||||
*/
|
||||
@Schema(description="最大广播次数")
|
||||
/**
|
||||
* 最大广播次数
|
||||
*/
|
||||
@Schema(description = "最大广播次数")
|
||||
private Integer broadcastMaxCount;
|
||||
|
||||
/**
|
||||
* 是否广播语音
|
||||
*/
|
||||
@Schema(description="是否广播语音")
|
||||
/**
|
||||
* 是否广播语音
|
||||
*/
|
||||
@Schema(description = "是否广播语音")
|
||||
private String isBroadcast;
|
||||
|
||||
/**
|
||||
* 是否完成
|
||||
*/
|
||||
@Schema(description="是否完成")
|
||||
/**
|
||||
* 是否完成
|
||||
*/
|
||||
@Schema(description = "是否完成")
|
||||
private String isDone;
|
||||
|
||||
/**
|
||||
* 完成时间
|
||||
*/
|
||||
@Schema(description="完成时间")
|
||||
/**
|
||||
* 完成时间
|
||||
*/
|
||||
@Schema(description = "完成时间")
|
||||
private LocalDateTime isDoneTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="创建人")
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建人")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="创建时间")
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description="修改人")
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description = "修改人")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description="修改时间")
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description = "修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除标记
|
||||
*/
|
||||
/**
|
||||
* 删除标记
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="删除标记")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "删除标记")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(description="租户ID")
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(description = "租户ID")
|
||||
private Long tenantId;
|
||||
}
|
||||
+8
-1
@@ -7,6 +7,7 @@ import lombok.*;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 智能柜设置
|
||||
@@ -89,6 +90,12 @@ public class HardDoorManagerEntity extends Model<HardDoorManagerEntity> {
|
||||
@Schema(description = "售卖状态。1:在售;2:停售")
|
||||
private Integer saleStatus;
|
||||
|
||||
/**
|
||||
* sim 卡号。设备有上报会返回,若一次上报都没有,则返回 null。
|
||||
*/
|
||||
@Schema(description = "sim 卡号。设备有上报会返回,若一次上报都没有,则返回 null。")
|
||||
private String simSn;
|
||||
|
||||
/**
|
||||
* sim 信号强度。大于-95 表示信号强度好;-95 到-105 表示信号强度中等;小于-105 表示信号差;
|
||||
*/
|
||||
@@ -105,7 +112,7 @@ public class HardDoorManagerEntity extends Model<HardDoorManagerEntity> {
|
||||
* sim 信号值更新时间。yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
@Schema(description = "sim 信号值更新时间。yyyy-MM-dd HH:mm:ss")
|
||||
private Integer signalTime;
|
||||
private LocalDateTime signalTime;
|
||||
|
||||
/**
|
||||
* 货柜列表JSON
|
||||
|
||||
+10
@@ -5,10 +5,20 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardBroadcastDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardBroadcastEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardBroadcastVo;
|
||||
|
||||
public interface HardBroadcastService extends IService<HardBroadcastEntity> {
|
||||
|
||||
Page<HardBroadcastVo> scopePageJoin(Page page, HardBroadcastDto dto, DataScope dataScope);
|
||||
|
||||
/**
|
||||
* 添加线下食堂预约订单广播
|
||||
*/
|
||||
void addReserveOrderTask(HardOrderEntity orderdetail);
|
||||
|
||||
/**
|
||||
* 完成硬件广播
|
||||
*/
|
||||
void doneBroadcast(HardOrderEntity orderdetail);
|
||||
}
|
||||
+86
-1
@@ -1,20 +1,25 @@
|
||||
package com.bsd.pjcloud.hard.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.admin.api.utils.DataUtil;
|
||||
import com.bsd.pjcloud.admin.api.vo.UserVO;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardBroadcastEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardBroadcastDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.manager.HardManagerDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardBroadcastEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.manager.HardManagerEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
|
||||
import com.bsd.pjcloud.hard.api.utils.HardUtil;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardAuthVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardBroadcastVo;
|
||||
import com.bsd.pjcloud.hard.mapper.HardBroadcastMapper;
|
||||
import com.bsd.pjcloud.hard.mapper.manager.HardManagerMapper;
|
||||
@@ -36,6 +41,8 @@ import java.util.List;
|
||||
@Service
|
||||
public class HardBroadcastServiceImpl extends ServiceImpl<HardBroadcastMapper, HardBroadcastEntity> implements HardBroadcastService {
|
||||
|
||||
static private final String TAG = "硬件广播";
|
||||
|
||||
private final HardManagerMapper hardManagerMapper;
|
||||
|
||||
private final RemoteUserService remoteUserService;
|
||||
@@ -47,6 +54,84 @@ public class HardBroadcastServiceImpl extends ServiceImpl<HardBroadcastMapper, H
|
||||
return pageList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加线下食堂预约订单广播
|
||||
*/
|
||||
@Override
|
||||
public void addReserveOrderTask(HardOrderEntity orderdetail) {
|
||||
if (ObjectUtil.isEmpty(orderdetail)) return;
|
||||
HardTypeEnum hardTypeEnum = HardTypeEnum.valueOfByType(orderdetail.getSysType());
|
||||
if (ObjectUtil.isEmpty(orderdetail)) {
|
||||
log.error("|{}|addReserveOrderTask发送mq消息失败,设备类型错误hardType不存在hardType|{}|", TAG, orderdetail.getSysType());
|
||||
return;
|
||||
}
|
||||
if (ObjectUtil.notEqual(hardTypeEnum, HardTypeEnum.CANTEEN)) return;
|
||||
HardOrderTypeEnum hardOrderType = HardOrderTypeEnum.valueOfByType(orderdetail.getOrderType());
|
||||
if (ObjectUtil.isEmpty(hardOrderType)) {
|
||||
log.error("|{}|addReserveOrderTask发送mq消息失败,订餐类型错误hardType不存在hardType|{}|", TAG, orderdetail.getOrderType());
|
||||
return;
|
||||
}
|
||||
if (ObjectUtil.notEqual(hardOrderType, HardOrderTypeEnum.RESERVE)) return;
|
||||
// 是否重复
|
||||
HardBroadcastEntity broadcastDetail = baseMapper.selectOne(new LambdaQueryWrapper<HardBroadcastEntity>()
|
||||
.eq(HardBroadcastEntity::getBizId, orderdetail.getId())
|
||||
);
|
||||
if (ObjectUtil.isNotEmpty(broadcastDetail)) {
|
||||
log.error("|{}|addReserveOrderTask发送mq消息失败,广播已存在|{}|", TAG, orderdetail.getId());
|
||||
return;
|
||||
}
|
||||
// 查询设备
|
||||
|
||||
HardBroadcastEntity saveObj = HardBroadcastEntity.builder()
|
||||
.userId(orderdetail.getUserId())
|
||||
.hardId(orderdetail.getHardId())
|
||||
.topic("")
|
||||
.bizType(HardBroadcastEnum.OFFLINE_CANTEEN_RESERVE.getType())
|
||||
.bizId(String.valueOf(orderdetail.getId()))
|
||||
.title(HardBroadcastEnum.OFFLINE_CANTEEN_RESERVE.getDescription())
|
||||
.content("")
|
||||
.broadcastCount(0)
|
||||
.broadcastMaxCount(20)
|
||||
.isBroadcast(YesNoEnum.YES.getCode())
|
||||
.isDone(YesNoEnum.NO.getCode())
|
||||
.build();
|
||||
baseMapper.insert(saveObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成硬件广播
|
||||
*/
|
||||
@Override
|
||||
public void doneBroadcast(HardOrderEntity orderdetail) {
|
||||
if (ObjectUtil.isEmpty(orderdetail)) return;
|
||||
HardTypeEnum hardTypeEnum = HardTypeEnum.valueOfByType(orderdetail.getSysType());
|
||||
if (ObjectUtil.isEmpty(orderdetail)) {
|
||||
log.error("|{}|doneBroadcast发送mq消息失败,设备类型错误hardType不存在hardType|{}|", TAG, orderdetail.getSysType());
|
||||
return;
|
||||
}
|
||||
if (ObjectUtil.notEqual(hardTypeEnum, HardTypeEnum.CANTEEN)) return;
|
||||
HardOrderTypeEnum hardOrderType = HardOrderTypeEnum.valueOfByType(orderdetail.getOrderType());
|
||||
if (ObjectUtil.isEmpty(hardOrderType)) {
|
||||
log.error("|{}|doneBroadcast发送mq消息失败,订餐类型错误hardType不存在hardType|{}|", TAG, orderdetail.getOrderType());
|
||||
return;
|
||||
}
|
||||
if (ObjectUtil.notEqual(hardOrderType, HardOrderTypeEnum.RESERVE)) return;
|
||||
HardBroadcastEntity broadcastDetail = baseMapper.selectOne(new LambdaQueryWrapper<HardBroadcastEntity>()
|
||||
.eq(HardBroadcastEntity::getBizId, orderdetail.getId())
|
||||
);
|
||||
if (ObjectUtil.isEmpty(broadcastDetail)) {
|
||||
log.error("|{}|doneBroadcast发送mq消息失败,广播不存在|{}|", TAG, orderdetail.getId());
|
||||
return;
|
||||
}
|
||||
HardBroadcastEntity updateObj = HardBroadcastEntity.builder()
|
||||
.id(broadcastDetail.getId())
|
||||
.isBroadcast(YesNoEnum.NO.getCode())
|
||||
.isDone(YesNoEnum.YES.getCode())
|
||||
.isDoneTime(orderdetail.getCreateTime())
|
||||
.build();
|
||||
baseMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
private void disposeList(List<HardBroadcastVo> list, HardBroadcastDto dto) {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
// 设备
|
||||
|
||||
+45
-13
@@ -1,6 +1,7 @@
|
||||
package com.bsd.pjcloud.hard.service.impl.manager;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
@@ -11,12 +12,10 @@ import com.bsd.pjcloud.hard.api.vo.manager.HardDoorManagerVo;
|
||||
import com.bsd.pjcloud.hard.mapper.manager.HardDoorManagerMapper;
|
||||
import com.bsd.pjcloud.hard.service.HardDoorManagerService;
|
||||
import com.bsd.pjcloud.thirdparty.api.feign.RemoterThirdDoorApiService;
|
||||
import com.bsd.pjcloud.thirdparty.dto.door.DoorBindDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.door.DoorRegisterDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.door.DoorVideoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.door.DoorVolumeDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.door.*;
|
||||
import com.bsd.pjcloud.thirdparty.vo.door.DoorBindVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.door.DoorRegisterVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.door.DoorStatusVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.door.DoorVolumeVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -59,24 +58,18 @@ public class HardDoorManagerServiceImpl extends ServiceImpl<HardDoorManagerMappe
|
||||
saveOrUpdate.setHardId(dto.getHardId());
|
||||
saveOrUpdate.setImei(dto.getImei());
|
||||
saveOrUpdate.setDeviceCode(dto.getDeviceCode());
|
||||
saveOrUpdate.setDoorCount(dto.getDoorCount());
|
||||
baseMapper.insert(saveOrUpdate);
|
||||
dto.setId(saveOrUpdate.getId());
|
||||
} else {
|
||||
HardDoorManagerEntity saveOrUpdate = new HardDoorManagerEntity();
|
||||
saveOrUpdate.setId(hardDoorDetail.getId());
|
||||
saveOrUpdate.setHardId(dto.getHardId());
|
||||
saveOrUpdate.setImei(dto.getImei());
|
||||
saveOrUpdate.setDeviceCode(dto.getDeviceCode());
|
||||
saveOrUpdate.setDoorCount(dto.getDoorCount());
|
||||
baseMapper.updateById(saveOrUpdate);
|
||||
}
|
||||
// 设备绑定
|
||||
DoorBindDto bindDto = new DoorBindDto();
|
||||
bindDto.setImei(dto.getImei());
|
||||
bindDto.setDeviceCode(dto.getDeviceCode());
|
||||
bindDto.setOutDeviceCode(String.valueOf(dto.getHardId()));
|
||||
DoorBindVo bindVo = thirdDoorApiService.bind(bindDto).getData();
|
||||
if (!bindVo.isSuccess()) {
|
||||
throw new RuntimeException(bindVo.getMessage());
|
||||
}
|
||||
// 设备注册
|
||||
DoorRegisterDto registerDto = new DoorRegisterDto();
|
||||
registerDto.setImei(dto.getImei());
|
||||
@@ -85,6 +78,45 @@ public class HardDoorManagerServiceImpl extends ServiceImpl<HardDoorManagerMappe
|
||||
if (!registerVo.isSuccess()) {
|
||||
throw new RuntimeException(registerVo.getMessage());
|
||||
}
|
||||
// 设备绑定
|
||||
DoorBindDto bindDto = new DoorBindDto();
|
||||
bindDto.setImei(dto.getImei());
|
||||
bindDto.setDeviceCode(registerVo.getDeviceCode());
|
||||
bindDto.setOutDeviceCode(String.valueOf(dto.getHardId()));
|
||||
DoorBindVo bindVo = thirdDoorApiService.bind(bindDto).getData();
|
||||
if (!bindVo.isSuccess()) {
|
||||
throw new RuntimeException(bindVo.getMessage());
|
||||
}
|
||||
// 查询设备状态
|
||||
DoorStatusDto statusDto = new DoorStatusDto();
|
||||
statusDto.setDeviceCode(bindVo.getDeviceCode());
|
||||
DoorStatusVo statusVo = thirdDoorApiService.status(statusDto).getData();
|
||||
if (!statusVo.isSuccess()) {
|
||||
throw new RuntimeException(statusVo.getMessage());
|
||||
}
|
||||
// 查询设备详情
|
||||
HardDoorManagerEntity hardDoorManagerDetail = baseMapper.selectById(dto.getId());
|
||||
// 更新设备信息
|
||||
HardDoorManagerEntity updateObj = new HardDoorManagerEntity();
|
||||
updateObj.setId(hardDoorManagerDetail.getId());
|
||||
updateObj.setPowerStatus(statusVo.getPowerStatus());
|
||||
updateObj.setNetStatus(statusVo.getNetStatus());
|
||||
updateObj.setNetStatus(statusVo.getSaleStatus());
|
||||
updateObj.setSaleStatus(statusVo.getSaleStatus());
|
||||
updateObj.setSimSn(statusVo.getSimSn());
|
||||
updateObj.setSignalIntensity(statusVo.getSignalIntensity());
|
||||
updateObj.setSignalRatio(statusVo.getSignalRatio());
|
||||
updateObj.setSignalTime(statusVo.getSignalTime());
|
||||
// 注册的设备信息
|
||||
updateObj.setCabinetNum(registerVo.getCabinetNum());
|
||||
updateObj.setCabinetCameraNum(registerVo.getCabinetCameraNum());
|
||||
updateObj.setCabinetWeightUnitNum(registerVo.getCabinetWeightUnitNum());
|
||||
if (ObjectUtil.isEmpty(statusVo.getCabinetStatusList())) {
|
||||
updateObj.setCabinetList("");
|
||||
} else {
|
||||
updateObj.setCabinetList(JSONUtil.toJsonStr(statusVo.getCabinetStatusList()));
|
||||
}
|
||||
baseMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+17
-5
@@ -38,10 +38,7 @@ import com.bsd.pjcloud.hard.api.vo.order.HardCarVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
|
||||
import com.bsd.pjcloud.hard.mapper.manager.HardManagerMapper;
|
||||
import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper;
|
||||
import com.bsd.pjcloud.hard.service.HardCarService;
|
||||
import com.bsd.pjcloud.hard.service.HardInvoiceService;
|
||||
import com.bsd.pjcloud.hard.service.HardManagerService;
|
||||
import com.bsd.pjcloud.hard.service.HardOrderService;
|
||||
import com.bsd.pjcloud.hard.service.*;
|
||||
import com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketSpuService;
|
||||
import com.bsd.pjcloud.supermarket.dto.SupermarketSpuUpdateStockReqDTO;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
|
||||
@@ -90,6 +87,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
private final HardParentCarServiceImpl hardParentCarServiceImpl;
|
||||
@Lazy
|
||||
private final HardInvoiceService hardInvoiceService;
|
||||
private final HardBroadcastService hardBroadcastService;
|
||||
|
||||
private final RemoteMchService remoteMchService;
|
||||
private final RemoteCodeUseService remoteCodeUseService;
|
||||
@@ -297,7 +295,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
HardParentCarEntity parentCar = hardCarService.getParentCarById(dto.getCarParentId());
|
||||
if (ObjectUtil.isEmpty(parentCar)) throw new RuntimeException("购物车不存在");
|
||||
// 查询商户
|
||||
MchManageVo hardManager = remoteMchService.getById(dto.getMerchantId()).getData();
|
||||
MchManageVo hardManager = remoteMchService.getById(parentCar.getMerchantId()).getData();
|
||||
if (ObjectUtil.isEmpty(hardManager)) throw new RuntimeException("商户不存在");
|
||||
// 查询父购物车
|
||||
List<HardCarEntity> carList = hardCarService.getByParentCarId(dto.getCarParentId());
|
||||
@@ -345,6 +343,8 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
if (isPay) getSelf().fastReduceBalance(orderObj);
|
||||
// 是否需要创建二维码
|
||||
getSelf().generateCode(orderObj);
|
||||
// 发送mq消息
|
||||
getSelf().createOrderAfterSendMqMsg(orderObj.getId());
|
||||
// 扣减库存
|
||||
getSelf().fastenerInventory(orderObj, YesNoEnum.YES);
|
||||
return orderObj.getId();
|
||||
@@ -587,8 +587,20 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
log.info("|{}|发送mq消息成功,超市打印发票order|{}|", TAG, JSON.toJSONString(orderId));
|
||||
}
|
||||
}
|
||||
case CANTEEN -> {
|
||||
HardOrderTypeEnum hardOrderType = HardOrderTypeEnum.valueOfByType(orderdetail.getOrderType());
|
||||
if (ObjectUtil.isEmpty(hardTypeEnum)) {
|
||||
log.error("|{}|发送mq消息失败,订餐类型错误hardType不存在hardType|{}|", TAG, orderdetail.getOrderType());
|
||||
return;
|
||||
}
|
||||
// 发送订餐mq
|
||||
if (ObjectUtil.equals(hardOrderType, HardOrderTypeEnum.RESERVE)) {
|
||||
hardBroadcastService.addReserveOrderTask(orderdetail);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 不返回错误
|
||||
log.info("|{}|发送mq消息成功,意外的错误error|{}|", TAG, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -7,6 +7,7 @@
|
||||
<result property="userId" column="user_id"/>
|
||||
<result property="hardId" column="hard_id"/>
|
||||
<result property="topic" column="topic"/>
|
||||
<result property="bizType" column="biz_type"/>
|
||||
<result property="bizId" column="biz_id"/>
|
||||
<result property="title" column="title"/>
|
||||
<result property="content" column="content"/>
|
||||
@@ -28,6 +29,7 @@
|
||||
a.user_id,
|
||||
a.hard_id,
|
||||
a.topic,
|
||||
a.biz_type,
|
||||
a.biz_id,
|
||||
a.title,
|
||||
a.content,
|
||||
@@ -52,6 +54,9 @@
|
||||
<if test="dto.hardId != null">
|
||||
and a.hard_id = #{dto.hardId}
|
||||
</if>
|
||||
<if test="dto.bizType != null">
|
||||
and a.biz_type = #{dto.bizType}
|
||||
</if>
|
||||
<if test="dto.bizId != null">
|
||||
and a.biz_id = #{dto.bizId}
|
||||
</if>
|
||||
@@ -77,5 +82,4 @@
|
||||
<include refid="whereA"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
+2
@@ -14,6 +14,7 @@
|
||||
<result property="powerStatus" column="power_status"/>
|
||||
<result property="netStatus" column="net_status"/>
|
||||
<result property="saleStatus" column="sale_status"/>
|
||||
<result property="simSn" column="sim_sn"/>
|
||||
<result property="signalIntensity" column="signal_intensity"/>
|
||||
<result property="signalRatio" column="signal_ratio"/>
|
||||
<result property="signalTime" column="signal_time"/>
|
||||
@@ -39,6 +40,7 @@
|
||||
a.power_status,
|
||||
a.net_status,
|
||||
a.sale_status,
|
||||
a.sim_sn,
|
||||
a.signal_intensity,
|
||||
a.signal_ratio,
|
||||
a.signal_time,
|
||||
|
||||
+3
-3
@@ -59,10 +59,10 @@ public class DoorStatusVo extends DoorBaseInnerVo {
|
||||
/**
|
||||
* 货柜列表
|
||||
*/
|
||||
private List<Cabinet> cabinetList;
|
||||
private List<Cabinet> cabinetStatusList;
|
||||
|
||||
@Data
|
||||
public class Cabinet {
|
||||
public static class Cabinet {
|
||||
|
||||
/**
|
||||
* 货柜号(1,2)
|
||||
@@ -72,7 +72,7 @@ public class DoorStatusVo extends DoorBaseInnerVo {
|
||||
/**
|
||||
* 锁在线1:在线;2:离线
|
||||
*/
|
||||
private Integer isLockOnline;
|
||||
private String isLockOnline;
|
||||
|
||||
/**
|
||||
* 锁状态1:锁关;2:锁开
|
||||
|
||||
+1
@@ -78,6 +78,7 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
+1
@@ -13,6 +13,7 @@ public enum WalletCodeBizEnum {
|
||||
FOREIGN("2", "外来人员"),
|
||||
CANTEEN_RESERVE("3", "食堂线上预订"),
|
||||
SUPERMARKET_RESERVE("4", "超市线上预订"),
|
||||
USER_WALLET("5", "用户钱包二维码"),
|
||||
;
|
||||
private final String code;
|
||||
|
||||
|
||||
+68
-61
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
@@ -24,94 +25,100 @@ import java.time.LocalDateTime;
|
||||
public class WalletCodeUseEntity extends Model<WalletCodeUseEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description="编号")
|
||||
@Schema(description = "编号")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@Schema(description="用户id")
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@Schema(description = "用户id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@Schema(description="类型")
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@Schema(description = "类型")
|
||||
private String bizType;
|
||||
|
||||
/**
|
||||
* 类型关联id
|
||||
*/
|
||||
@Schema(description="类型关联id")
|
||||
/**
|
||||
* 类型关联id
|
||||
*/
|
||||
@Schema(description = "类型关联id")
|
||||
private Long bizId;
|
||||
|
||||
/**
|
||||
* 是否使用
|
||||
*/
|
||||
@Schema(description="是否使用")
|
||||
/**
|
||||
* 是否使用
|
||||
*/
|
||||
@Schema(description = "是否使用")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 二维码
|
||||
*/
|
||||
@Schema(description="二维码")
|
||||
/**
|
||||
* 二维码
|
||||
*/
|
||||
@Schema(description = "二维码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 二维码内容
|
||||
*/
|
||||
@Schema(description="二维码内容")
|
||||
/**
|
||||
* 二维码内容
|
||||
*/
|
||||
@Schema(description = "二维码内容")
|
||||
private String codeContent;
|
||||
|
||||
/**
|
||||
* 使用时间
|
||||
*/
|
||||
@Schema(description="使用时间")
|
||||
/**
|
||||
* 短码
|
||||
*/
|
||||
@Schema(description = "短码")
|
||||
private String shortCode;
|
||||
|
||||
/**
|
||||
* 使用时间
|
||||
*/
|
||||
@Schema(description = "使用时间")
|
||||
private LocalDateTime useTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="创建人")
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建人")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="创建时间")
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description="修改人")
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description = "修改人")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description="修改时间")
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description = "修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除标记
|
||||
*/
|
||||
/**
|
||||
* 删除标记
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="删除标记")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "删除标记")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(description="租户ID")
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(description = "租户ID")
|
||||
private Long tenantId;
|
||||
}
|
||||
+24
-1
@@ -7,7 +7,6 @@ import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletCodeBizEnum;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletCodeUseDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletCodeUseEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletCodeUseVo;
|
||||
import com.bsd.pjcloud.wallet.service.WalletCodeUseService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
@@ -33,24 +32,37 @@ public class WalletCodeUseController {
|
||||
private final WalletCodeUseService walletCodeUseService;
|
||||
|
||||
/* ************************************* start 远程调用 start ************************************* */
|
||||
|
||||
/**
|
||||
* 核销二维码
|
||||
*/
|
||||
@Inner
|
||||
@GetMapping("/cancel-code")
|
||||
public R<Boolean> cancelCode(@RequestParam Long id) {
|
||||
return R.ok(walletCodeUseService.cancelCode(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否核销
|
||||
*/
|
||||
@Inner
|
||||
@GetMapping("/is-cancel-code")
|
||||
public R<Boolean> isCancelCode(@RequestParam Long id) {
|
||||
return R.ok(walletCodeUseService.isCancelCode(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成二维码
|
||||
*/
|
||||
@Inner
|
||||
@GetMapping("/generate-code")
|
||||
public R<Boolean> generateCode(@RequestParam Long id, @RequestParam Long userId, @RequestParam WalletCodeBizEnum walletCodeBiz, @RequestParam Integer count) {
|
||||
return R.ok(walletCodeUseService.generate(id, userId, walletCodeBiz, count));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ids查询
|
||||
*/
|
||||
@Inner
|
||||
@GetMapping("/get-by-biz-ids")
|
||||
public R<List<WalletCodeUseEntity>> getByBizIds(@RequestParam List<Long> ids) {
|
||||
@@ -60,6 +72,9 @@ public class WalletCodeUseController {
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*/
|
||||
@Inner
|
||||
@GetMapping("/get-by-biz-id")
|
||||
public R<WalletCodeUseEntity> getByBizId(@RequestParam Long id) {
|
||||
@@ -78,6 +93,14 @@ public class WalletCodeUseController {
|
||||
}
|
||||
/* ************************************* end app end ************************************* */
|
||||
|
||||
/* ************************************* start android start ************************************* */
|
||||
@Operation(summary = "根据短码查询加密信息", description = "根据短码查询加密信息")
|
||||
@GetMapping("/ad/by-short-code")
|
||||
public R adByShortCode(@RequestParam String shortCode) {
|
||||
return R.ok(walletCodeUseService.getByShortCode(shortCode));
|
||||
}
|
||||
/* ************************************* end android end ************************************* */
|
||||
|
||||
@Operation(summary = "二维码列表", description = "二维码列表")
|
||||
@GetMapping("/code-list")
|
||||
public R codeList(@ParameterObject Page page, @ParameterObject WalletCodeUseDto dto) {
|
||||
|
||||
+12
-4
@@ -10,22 +10,30 @@ import jakarta.validation.constraints.NotNull;
|
||||
|
||||
public interface WalletCodeUseService extends IService<WalletCodeUseEntity> {
|
||||
|
||||
/**
|
||||
* 生成二维码
|
||||
*/
|
||||
Boolean generate(@NotNull Long id, @NotNull Long userId, @NotNull WalletCodeBizEnum walletCodeBizEnum, @NotNull Integer count);
|
||||
|
||||
/**
|
||||
* 生成钱包二码
|
||||
*/
|
||||
WalletCodeUseEntity generateWallet(@NotNull Long walletId);
|
||||
|
||||
Page<WalletCodeUseVo> pageJoin(Page page, WalletCodeUseDto dto);
|
||||
|
||||
/**
|
||||
* 核销二维码
|
||||
* @param id useCodeId
|
||||
* @return
|
||||
*/
|
||||
Boolean cancelCode(Long id);
|
||||
|
||||
/**
|
||||
* 二维码是否核销
|
||||
* @param id useCodeId
|
||||
* @return
|
||||
*/
|
||||
Boolean isCancelCode(Long id);
|
||||
|
||||
/**
|
||||
* 根据短码查询加密信息
|
||||
*/
|
||||
String getByShortCode(String shortCode);
|
||||
}
|
||||
+106
-2
@@ -1,32 +1,42 @@
|
||||
package com.bsd.pjcloud.wallet.service.impl;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.admin.api.dto.UserInfo;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysUser;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteFileService;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.admin.api.utils.DataUtil;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
|
||||
import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.common.core.util.QRCodeImageGenerator;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.hard.api.dto.code.QRCodeExtraDto;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletCodeBizEnum;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletCodeUseDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletCodeUseEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletCodeUseVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletCodeUseMapper;
|
||||
import com.bsd.pjcloud.wallet.service.WalletCodeUseService;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.code.QRCodeDto;
|
||||
import com.bsd.pjcloud.hard.api.utils.HardUtil;
|
||||
import com.bsd.pjcloud.wallet.service.WalletManageService;
|
||||
import com.bsd.pjcloud.wallet.service.WalletSettingService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.seata.spring.annotation.GlobalTransactional;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -35,6 +45,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -53,9 +64,16 @@ public class WalletCodeUseServiceImpl extends ServiceImpl<WalletCodeUseMapper, W
|
||||
|
||||
static private final String TAG = "二维码使用管理";
|
||||
|
||||
@Lazy
|
||||
private final WalletManageService walletManageService;
|
||||
private final WalletSettingService walletSettingService;
|
||||
|
||||
private final RemoteUserService userService;
|
||||
private final RemoteFileService remoteFileService;
|
||||
|
||||
/**
|
||||
* 生成二维码
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean generate(Long id, Long userId, WalletCodeBizEnum biz, Integer count) {
|
||||
@@ -78,8 +96,10 @@ public class WalletCodeUseServiceImpl extends ServiceImpl<WalletCodeUseMapper, W
|
||||
R upload = remoteFileService.innerUpload(multipartFile, null, null, null);
|
||||
Map data = (Map) upload.getData();
|
||||
String url = (String) data.get("url");
|
||||
// 生成短码
|
||||
String shortCode = generateShortCode(code.getRight());
|
||||
// 更新
|
||||
WalletCodeUseEntity updateObj = WalletCodeUseEntity.builder().id(item.getId()).code(url).codeContent(code.getRight()).build();
|
||||
WalletCodeUseEntity updateObj = WalletCodeUseEntity.builder().id(item.getId()).code(url).codeContent(code.getRight()).shortCode(shortCode).build();
|
||||
baseMapper.updateById(updateObj);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -90,6 +110,60 @@ public class WalletCodeUseServiceImpl extends ServiceImpl<WalletCodeUseMapper, W
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成钱包二码
|
||||
*/
|
||||
@Override
|
||||
public WalletCodeUseEntity generateWallet(Long walletId) {
|
||||
WalletManageEntity wallet = walletManageService.getWallet(walletId);
|
||||
if (ObjectUtil.isEmpty(wallet)) throw new RuntimeException("已经存在钱包退款");
|
||||
WalletSettingVo setting = walletSettingService.getSetting();
|
||||
// 获取钱包二维码过期时间配置
|
||||
long imgExceedTime = -1;
|
||||
if (ObjectUtil.equals(setting.getRefreshQrCodeEnable(), YesNoEnum.YES.getCode()) && ObjectUtil.isNotEmpty(setting.getRefreshQrCodeFre())) {
|
||||
Integer exceedTime = setting.getRefreshQrCodeFre();
|
||||
LocalDateTime updatedTime = LocalDateTime.now().plusSeconds(exceedTime);
|
||||
imgExceedTime = updatedTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
}
|
||||
// 用户用户信息
|
||||
QRCodeExtraDto extraDto = new QRCodeExtraDto();
|
||||
UserInfo user = userService.getByUserId(wallet.getUserId()).getData();
|
||||
extraDto = BeanUtils.toBean(user, QRCodeExtraDto.class);
|
||||
extraDto.setWalletId(wallet.getId());
|
||||
extraDto.setWalletCardNumber(wallet.getCardNumber());
|
||||
extraDto.setWalletTypeId(wallet.getWalletTypeId());
|
||||
extraDto.setWalletBalance(wallet.getBalance());
|
||||
extraDto.setIsFreeze(wallet.getIsFreeze());
|
||||
QRCodeDto qrCodeDto = new QRCodeDto();
|
||||
qrCodeDto.setUserId(wallet.getUserId());
|
||||
qrCodeDto.setId(wallet.getId());
|
||||
qrCodeDto.setTypeId(wallet.getWalletTypeId());
|
||||
qrCodeDto.setOrderType(HardOrderTypeEnum.BELOW.getType());
|
||||
qrCodeDto.setPayType(HardPayTypeEnum.WALLET_QR_CODE.getType());
|
||||
qrCodeDto.setExceedTime(imgExceedTime);
|
||||
qrCodeDto.setExtra(JSON.toJSONString(extraDto));
|
||||
String encodeJson = Base64.encode(JSON.toJSONString(qrCodeDto));
|
||||
// 删除以前的用户钱包二维码
|
||||
baseMapper.delete(new LambdaQueryWrapper<WalletCodeUseEntity>()
|
||||
.eq(WalletCodeUseEntity::getUserId, wallet.getUserId())
|
||||
.eq(WalletCodeUseEntity::getBizType, WalletCodeBizEnum.USER_WALLET.getCode())
|
||||
.eq(WalletCodeUseEntity::getBizId, wallet.getId())
|
||||
);
|
||||
String shortCode = generateShortCode(encodeJson);
|
||||
WalletCodeUseEntity codeUseEntity = WalletCodeUseEntity.builder()
|
||||
.userId(wallet.getUserId())
|
||||
.bizType(WalletCodeBizEnum.USER_WALLET.getCode())
|
||||
.bizId(wallet.getId())
|
||||
.status(YesNoEnum.NO.getCode())
|
||||
.code("")
|
||||
.codeContent(encodeJson)
|
||||
.shortCode(shortCode)
|
||||
.build();
|
||||
baseMapper.insert(codeUseEntity);
|
||||
return codeUseEntity;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Page<WalletCodeUseVo> pageJoin(Page page, WalletCodeUseDto dto) {
|
||||
Page<WalletCodeUseVo> list = baseMapper.pageJoin(page, dto);
|
||||
@@ -126,4 +200,34 @@ public class WalletCodeUseServiceImpl extends ServiceImpl<WalletCodeUseMapper, W
|
||||
if (ObjectUtil.isEmpty(codeUse)) return null;
|
||||
return ObjectUtil.equals(codeUse.getStatus(), YesNoEnum.YES.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据短码查询加密信息
|
||||
*/
|
||||
@Override
|
||||
public String getByShortCode(String shortCode) {
|
||||
WalletCodeUseEntity detail = baseMapper.selectOne(new LambdaQueryWrapper<WalletCodeUseEntity>()
|
||||
.eq(WalletCodeUseEntity::getShortCode, shortCode)
|
||||
.orderByDesc(WalletCodeUseEntity::getCreateTime)
|
||||
.orderByDesc(WalletCodeUseEntity::getId)
|
||||
.last("limit 1")
|
||||
);
|
||||
return detail.getCodeContent();
|
||||
}
|
||||
|
||||
// 生成短码
|
||||
public String generateShortCode(String codeContent) {
|
||||
while (true) {
|
||||
String shortCode = DigestUtils.md5Hex(codeContent);
|
||||
// 判断code是否存在
|
||||
Long count = baseMapper.selectCount(new LambdaQueryWrapper<WalletCodeUseEntity>().eq(WalletCodeUseEntity::getShortCode, shortCode));
|
||||
if (count == 0) {
|
||||
return shortCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private WalletCodeUseServiceImpl getSelf() {
|
||||
return SpringUtil.getBean(getClass());
|
||||
}
|
||||
}
|
||||
+5
-43
@@ -4,9 +4,7 @@ import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelWriter;
|
||||
@@ -25,29 +23,20 @@ import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.admin.api.utils.DataUtil;
|
||||
import com.bsd.pjcloud.common.core.constant.CacheConstants;
|
||||
import com.bsd.pjcloud.common.core.constant.CommonRoleConstant;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
|
||||
import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.data.resolver.ParamResolver;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.code.QRCodeDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.code.QRCodeExtraDto;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletManageBalanceDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletManageDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletTypeDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletActiveEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.*;
|
||||
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
|
||||
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletManageBalanceVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletManageMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTransactionMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTypeMapper;
|
||||
@@ -65,8 +54,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -86,7 +73,7 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
|
||||
private final WalletTypeMapper walletTypeMapper;
|
||||
|
||||
private final WalletTypeService walletTypeService;
|
||||
private final WalletSettingService walletSettingService;
|
||||
private final WalletCodeUseService walletCodeUseService;
|
||||
@Lazy
|
||||
private final WalletActiveService walletActiveService;
|
||||
@Lazy
|
||||
@@ -207,34 +194,9 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
|
||||
|
||||
@Override
|
||||
public String getQrCode(Long walletId) {
|
||||
WalletManageEntity wallet = this.getWallet(walletId);
|
||||
if (ObjectUtil.isEmpty(wallet)) throw new RuntimeException("已经存在钱包退款");
|
||||
WalletSettingVo setting = walletSettingService.getSetting();
|
||||
// 获取钱包二维码过期时间配置
|
||||
long imgExceedTime = -1;
|
||||
if (ObjectUtil.equals(setting.getRefreshQrCodeEnable(), YesNoEnum.YES.getCode()) && ObjectUtil.isNotEmpty(setting.getRefreshQrCodeFre())) {
|
||||
Integer exceedTime = setting.getRefreshQrCodeFre();
|
||||
LocalDateTime updatedTime = LocalDateTime.now().plusSeconds(exceedTime);
|
||||
imgExceedTime = updatedTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
}
|
||||
// 用户用户信息
|
||||
QRCodeExtraDto extraDto = new QRCodeExtraDto();
|
||||
UserInfo user = userService.getByUserId(wallet.getUserId()).getData();
|
||||
extraDto = BeanUtils.toBean(user, QRCodeExtraDto.class);
|
||||
extraDto.setWalletId(wallet.getId());
|
||||
extraDto.setWalletCardNumber(wallet.getCardNumber());
|
||||
extraDto.setWalletTypeId(wallet.getWalletTypeId());
|
||||
extraDto.setWalletBalance(wallet.getBalance());
|
||||
extraDto.setIsFreeze(wallet.getIsFreeze());
|
||||
QRCodeDto qrCodeDto = new QRCodeDto();
|
||||
qrCodeDto.setUserId(wallet.getUserId());
|
||||
qrCodeDto.setId(wallet.getId());
|
||||
qrCodeDto.setTypeId(wallet.getWalletTypeId());
|
||||
qrCodeDto.setOrderType(HardOrderTypeEnum.BELOW.getType());
|
||||
qrCodeDto.setPayType(HardPayTypeEnum.WALLET_QR_CODE.getType());
|
||||
qrCodeDto.setExceedTime(imgExceedTime);
|
||||
qrCodeDto.setExtra(JSON.toJSONString(extraDto));
|
||||
return Base64.encode(JSON.toJSONString(qrCodeDto));
|
||||
WalletCodeUseEntity walletCodeUse = walletCodeUseService.generateWallet(walletId);
|
||||
if (ObjectUtil.isEmpty(walletCodeUse)) throw new RuntimeException("钱包二维码生成错误");
|
||||
return walletCodeUse.getShortCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user