creat:生成核销二维码
This commit is contained in:
1 parent
4f4055f9e5
commit
3a4bd07819
29 files changed
+662
-202
No files matched your search
+28
@@ -0,0 +1,28 @@
|
||||
package hardware.constant;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 硬件订单类型
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum HardOrderTypeEnum {
|
||||
BELOW(1, "线下购买"),
|
||||
RESERVE(2, "线上订餐"),
|
||||
FOREIGN_TICKET(3, "外来人员"),
|
||||
STRIDE_DEPT(4, "跨单位"),
|
||||
;
|
||||
private final Integer type;
|
||||
private final String description;
|
||||
|
||||
public static HardOrderTypeEnum valueOfByType(Integer type) {
|
||||
if (ObjectUtil.isEmpty(type)) return null;
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
|
||||
}
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package hardware.constant;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 硬件订单支付方式
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum HardPayTypeEnum {
|
||||
WALLET_DEFAULT(1, "普通钱包支付"),
|
||||
WALLET_QR_CODE(2, "钱包二维码支付"),
|
||||
WALLET_CARD(3, "钱包饭卡支付"),
|
||||
FACE(4, "人脸识别支付"),
|
||||
STRIDE_DEPT_QR_CODE(5, "跨单位二维码支付"),
|
||||
FOREIGN_TICKET_QR_CODE(6, "外来人员二维码支付"),
|
||||
RESERVE_QR_CODE(7, "线上订餐二维码支付"),
|
||||
CASH(8, "现金支付"),
|
||||
;
|
||||
private final Integer type;
|
||||
private final String description;
|
||||
|
||||
public static HardPayTypeEnum valueOfByType(Integer type) {
|
||||
if (ObjectUtil.isEmpty(type)) return null;
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
/*
|
||||
* @author pigx archetype
|
||||
* <p>
|
||||
* 常量和枚举定义
|
||||
*/
|
||||
package hardware.constant;
|
||||
Whitespace-only changes.
@@ -0,0 +1,39 @@
|
||||
package hardware.dto.code;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class QRCodeDto {
|
||||
// 总id
|
||||
private Long id;
|
||||
|
||||
// 子id
|
||||
private Long itemId;
|
||||
|
||||
// 类型id 比如钱包类型
|
||||
private Long typeId;
|
||||
|
||||
// 用户id
|
||||
private Long userId;
|
||||
|
||||
// 订单类型
|
||||
private Integer orderType;
|
||||
|
||||
// 支付类型
|
||||
private Integer payType;
|
||||
|
||||
// 过期时间 -1 代表没有限制
|
||||
private Long exceedTime;
|
||||
|
||||
/**
|
||||
* 额外的用户信息json
|
||||
* @see QRCodeExtraDto
|
||||
*/
|
||||
private String extra;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
/*
|
||||
* @author pigx archetype
|
||||
* <p>
|
||||
* DTO 存放目录
|
||||
*/
|
||||
package hardware.dto;
|
||||
@@ -1,6 +0,0 @@
|
||||
/*
|
||||
* @author pigx archetype
|
||||
* <p>
|
||||
* 实体 存放目录
|
||||
*/
|
||||
package hardware.entity;
|
||||
@@ -0,0 +1,44 @@
|
||||
package hardware.utils;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import hardware.dto.code.QRCodeDto;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
@UtilityClass
|
||||
public class HardUtil {
|
||||
|
||||
public Pair<String, String> generate(QRCodeDto dto) {
|
||||
String fileName = "qrcode";
|
||||
if (ObjectUtil.isEmpty(dto.getId())) {
|
||||
fileName += "_unknown";
|
||||
} else {
|
||||
fileName += "_" + dto.getId().toString();
|
||||
}
|
||||
if (ObjectUtil.isEmpty(dto.getItemId())) {
|
||||
fileName += "_unknown";
|
||||
} else {
|
||||
fileName += "_" + dto.getItemId().toString();
|
||||
}
|
||||
if (ObjectUtil.isEmpty(dto.getUserId())) {
|
||||
fileName += "_unknown";
|
||||
} else {
|
||||
fileName += "_" + dto.getUserId().toString();
|
||||
}
|
||||
if (ObjectUtil.isEmpty(dto.getOrderType())) {
|
||||
fileName += "_unknown";
|
||||
} else {
|
||||
fileName += "_" + dto.getOrderType().toString();
|
||||
}
|
||||
if (ObjectUtil.isEmpty(dto.getPayType())) {
|
||||
fileName += "_unknown";
|
||||
} else {
|
||||
fileName += "_" + dto.getPayType().toString();
|
||||
}
|
||||
String coeContent = Base64.encode(JSONUtil.toJsonStr(dto));
|
||||
return new Pair<>(fileName, coeContent);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user