diff --git a/bonus-common-biz/src/main/java/com/bonus/utils/Arith.java b/bonus-common-biz/src/main/java/com/bonus/utils/Arith.java new file mode 100644 index 00000000..718e032a --- /dev/null +++ b/bonus-common-biz/src/main/java/com/bonus/utils/Arith.java @@ -0,0 +1,52 @@ +package com.bonus.utils; + +import java.math.BigDecimal; + +public class Arith { + private static final int DEF_DIV_SCALE = 10; + + private Arith() { + } + + public static double add(double v1, double v2) { + BigDecimal b1 = new BigDecimal(Double.toString(v1)); + BigDecimal b2 = new BigDecimal(Double.toString(v2)); + return b1.add(b2).doubleValue(); + } + + public static double sub(double v1, double v2) { + BigDecimal b1 = new BigDecimal(Double.toString(v1)); + BigDecimal b2 = new BigDecimal(Double.toString(v2)); + return b1.subtract(b2).doubleValue(); + } + + public static double mul(double v1, double v2) { + BigDecimal b1 = new BigDecimal(Double.toString(v1)); + BigDecimal b2 = new BigDecimal(Double.toString(v2)); + return b1.multiply(b2).doubleValue(); + } + + public static double div(double v1, double v2) { + return div(v1, v2, 10); + } + + public static double div(double v1, double v2, int scale) { + if (scale < 0) { + throw new IllegalArgumentException("The scale must be a positive integer or zero"); + } else { + BigDecimal b1 = new BigDecimal(Double.toString(v1)); + BigDecimal b2 = new BigDecimal(Double.toString(v2)); + return b1.divide(b2, scale, 4).doubleValue(); + } + } + + public static double round(double v, int scale) { + if (scale < 0) { + throw new IllegalArgumentException("The scale must be a positive integer or zero"); + } else { + BigDecimal b = new BigDecimal(Double.toString(v)); + BigDecimal one = new BigDecimal("1"); + return b.divide(one, scale, 4).doubleValue(); + } + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/enums/DeliveryTypeEnum.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/enums/DeliveryTypeEnum.java index ed348a81..e0db5490 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/enums/DeliveryTypeEnum.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/enums/DeliveryTypeEnum.java @@ -1,12 +1,13 @@ package com.bonus.core.common.enums; +import com.bonus.core.common.converter.LeExcelFieldConvertor; +import com.bonus.core.common.converter.LeExcelFieldEnum; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -//public enum DeliveryTypeEnum implements LeExcelFieldEnum { -public enum DeliveryTypeEnum { +public enum DeliveryTypeEnum implements LeExcelFieldEnum { SELF_TAKE(1, "自取堂食"), MERCHANT(2, "商家配送"), DINING_CABINET(3, "取餐柜配送"), @@ -80,17 +81,22 @@ public enum DeliveryTypeEnum { return getTypeEnum(key) != NONE; } + + @Override public Integer getKey() { return this.key; } + + @Override public String getDesc() { return this.desc; } -// public static class ExcelConvertor extends LeExcelFieldConvertor { -// public ExcelConvertor() { -// super(DeliveryTypeEnum.class); -// } -// } + public static class ExcelConvertor extends LeExcelFieldConvertor { + public ExcelConvertor() { + super(DeliveryTypeEnum.class); + } + } + } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/JacksonUtil.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/JacksonUtil.java new file mode 100644 index 00000000..b885c0f6 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/JacksonUtil.java @@ -0,0 +1,503 @@ +package com.bonus.core.common.utils; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.text.CharSequenceUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.stream.Collectors; + +public class JacksonUtil { + private static final ObjectMapper objectMapper; + private static final ObjectMapper objectMapperIgnoreNull; + private static final Logger logger; + + public static ObjectMapper getInstance() { + return objectMapper; + } + + public static ObjectMapper getInstanceIgnoreNull() { + return objectMapperIgnoreNull; + } + + public static ObjectNode objectNode() { + return getInstance().createObjectNode(); + } + + public static ArrayNode arrayNode() { + return getInstance().createArrayNode(); + } + + public static boolean isNull(JsonNode jsonNode) { + return jsonNode == null || jsonNode.isNull() || jsonNode.isMissingNode(); + } + + public static boolean isNullOrEmpty(JsonNode jsonNode) { + return jsonNode == null || jsonNode.isNull() || jsonNode.isMissingNode() || jsonNode.isEmpty(); + } + + public static String writeValueAsString(Object obj) { + try { + return getInstance().writeValueAsString(obj); + } catch (IOException var2) { + logger.error(var2.getMessage(), var2); + return null; + } + } + + public static Optional writeValueAsStringOptional(Object obj) { + return Optional.ofNullable(writeValueAsString(obj)); + } + + public static String writeValueAsStringIgnoreNull(Object obj) { + try { + return getInstanceIgnoreNull().writeValueAsString(obj); + } catch (IOException var2) { + logger.error(var2.getMessage(), var2); + return null; + } + } + + public static Optional writeValueAsStringIgnoreNullOptional(Object obj) { + return Optional.ofNullable(writeValueAsStringIgnoreNull(obj)); + } + + public static T readValue(String jsonStr, TypeReference valueTypeRef) { + try { + return getInstance().readValue(jsonStr, valueTypeRef); + } catch (JsonParseException var3) { + logger.error(var3.getMessage(), var3); + } catch (JsonMappingException var4) { + logger.error(var4.getMessage(), var4); + } catch (IOException var5) { + logger.error(var5.getMessage(), var5); + } + + return null; + } + + public static Optional readValueOptional(String jsonStr, TypeReference valueTypeRef) { + return Optional.ofNullable(readValue(jsonStr, valueTypeRef)); + } + + public static T readValue(String jsonStr, Class clazz) { + try { + return getInstance().readValue(jsonStr, clazz); + } catch (JsonParseException var3) { + logger.error(var3.getMessage(), var3); + } catch (JsonMappingException var4) { + logger.error(var4.getMessage(), var4); + } catch (Exception var5) { + logger.error(var5.getMessage(), var5); + } + + return null; + } + + public static Optional readValueOptional(String jsonStr, Class clazz) { + return Optional.ofNullable(readValue(jsonStr, clazz)); + } + + public static T readValueOrEmpty(String jsonStr, Class clazz) throws InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException { + try { + T t = readValue(jsonStr, clazz); + return t != null ? t : clazz.getDeclaredConstructor().newInstance(); + } catch (Throwable var3) { + throw var3; + } + } + + public static T readValue(String jsonStr, Class parametrized, Class... parameterClasses) { + try { + JavaType javaType = getInstance().getTypeFactory().constructParametricType(parametrized, parameterClasses); + return getInstance().readValue(jsonStr, javaType); + } catch (JsonParseException var4) { + logger.error(var4.getMessage(), var4); + } catch (JsonMappingException var5) { + logger.error(var5.getMessage(), var5); + } catch (IOException var6) { + logger.error(var6.getMessage(), var6); + } + + return null; + } + + public static List readList(String jsonStr, Class... parameterClasses) { + List list = (List)readValue(jsonStr, List.class, parameterClasses); + return (List)(list != null ? list : CollUtil.newArrayList(new Object[0])); + } + + public static JsonNode readTree(String jsonStr) { + try { + return getInstance().readTree(jsonStr); + } catch (IOException var2) { + logger.error(var2.getMessage(), var2); + return null; + } + } + + public static JsonNode readTreeOrMissing(String jsonStr) { + JsonNode jsonNode = readTree(jsonStr); + return jsonNode != null ? jsonNode : getInstance().missingNode(); + } + + public static T treeToValue(JsonNode node, Class clz) { + try { + return getInstance().treeToValue(node, clz); + } catch (IOException var3) { + logger.error(var3.getMessage(), var3); + return null; + } + } + + public static Optional treeToValueOptional(JsonNode node, Class clz) { + return Optional.ofNullable(treeToValue(node, clz)); + } + + public static T treeToValueOrEmpty(JsonNode node, Class clz) throws InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException { + try { + T t = treeToValue(node, clz); + return t != null ? t : clz.getDeclaredConstructor().newInstance(); + } catch (Throwable var3) { + throw var3; + } + } + + public static T treeToValue(JsonNode node, TypeReference typeR) { + try { + JavaType javaType = getInstance().getTypeFactory().constructType(typeR); + return getInstance().treeToValue(node, javaType); + } catch (IOException var3) { + logger.error(var3.getMessage(), var3); + return null; + } + } + + public static T treeToValue(JsonNode node, Class parametrized, Class... parameterClasses) { + try { + JavaType javaType = getInstance().getTypeFactory().constructParametricType(parametrized, parameterClasses); + return getInstance().treeToValue(node, javaType); + } catch (IOException var4) { + logger.error(var4.getMessage(), var4); + return null; + } + } + + public static Optional treeToValueOptional(JsonNode node, Class parametrized, Class... parameterClasses) { + return Optional.ofNullable(treeToValue(node, parametrized, parameterClasses)); + } + + public static List treeToList(JsonNode node, Class... parameterClasses) { + List list = (List)treeToValue(node, List.class, parameterClasses); + return (List)(list != null ? list : CollUtil.newArrayList(new Object[0])); + } + + public static JsonNode valueToTree(Object obj) { + return getInstance().valueToTree(obj); + } + + public static JsonNode valueToTreeIgnoreNull(Object obj) { + return getInstanceIgnoreNull().valueToTree(obj); + } + + public static int getIntValue(JsonNode jsonNode, String key, int defaultValue) { + if (jsonNode != null && !jsonNode.isNull() && !jsonNode.isMissingNode()) { + JsonNode node = jsonNode.get(key); + return node != null && !node.isNull() && !node.isMissingNode() ? node.asInt(defaultValue) : defaultValue; + } else { + return defaultValue; + } + } + + public static Integer getInt(JsonNode jsonNode, String key) { + if (jsonNode != null && !jsonNode.isNull() && !jsonNode.isMissingNode()) { + JsonNode node = jsonNode.get(key); + return node != null && !node.isNull() && !node.isMissingNode() ? node.asInt() : null; + } else { + return null; + } + } + + public static long getLongValue(JsonNode jsonNode, String key, long defaultValue) { + if (jsonNode != null && !jsonNode.isNull() && !jsonNode.isMissingNode()) { + JsonNode node = jsonNode.get(key); + return node != null && !node.isNull() && !node.isMissingNode() ? node.asLong(defaultValue) : defaultValue; + } else { + return defaultValue; + } + } + + public static Long getLong(JsonNode jsonNode, String key) { + if (jsonNode != null && !jsonNode.isNull() && !jsonNode.isMissingNode()) { + JsonNode node = jsonNode.get(key); + return node != null && !node.isNull() && !node.isMissingNode() ? node.asLong() : null; + } else { + return null; + } + } + + public static double getDoubleValue(JsonNode jsonNode, String key, double defaultValue) { + if (jsonNode != null && !jsonNode.isNull() && !jsonNode.isMissingNode()) { + JsonNode node = jsonNode.get(key); + return node != null && !node.isNull() && !node.isMissingNode() ? node.asDouble(defaultValue) : defaultValue; + } else { + return defaultValue; + } + } + + public static Double getDouble(JsonNode jsonNode, String key) { + if (jsonNode != null && !jsonNode.isNull() && !jsonNode.isMissingNode()) { + JsonNode node = jsonNode.get(key); + return node != null && !node.isNull() && !node.isMissingNode() ? node.asDouble() : null; + } else { + return null; + } + } + + public static String getStringValue(JsonNode jsonNode, String key, String defaultValue) { + return jsonNode.path(key).asText(defaultValue); + } + + public static String getString(JsonNode jsonNode, String key) { + return getStringValue(jsonNode, key, (String)null); + } + + public static JsonNode getByPath(JsonNode node, String expression) { + if (StringUtils.isEmpty(expression)) { + return node; + } else { + JsonNode result = node; + String[] var3 = StringUtils.split(expression, "."); + int var4 = var3.length; + + for(int var5 = 0; var5 < var4; ++var5) { + String path = var3[var5]; + if (StrUtil.contains(path, "[") && StrUtil.contains(path, "]")) { + String aryPath = StrUtil.subBefore(path, "[", false); + int idxPath = NumberUtil.parseInt(StrUtil.subBetween(path, "[", "]")); + if (idxPath < 0) { + idxPath += result.path(aryPath).size(); + } + + result = result.path(aryPath).path(idxPath); + } else { + result = result.path(path); + } + } + + return result; + } + } + + public static T getValueByPath(String jsonStr, String expression, T defaultValue) { + JsonNode jsonNode = readTreeOrMissing(jsonStr); + return getValueByPath(jsonNode, expression, defaultValue); + } + + public static T getValueByPath(JsonNode jsonNode, String expression, T defaultValue) { + if (jsonNode == null) { + return defaultValue; + } else { + JsonNode nodeByPath = getByPath(jsonNode, expression); + T value = treeToValue(nodeByPath, new TypeReference() { + }); + return value != null ? value : defaultValue; + } + } + + public static void putByPath(JsonNode node, String expression, Object value) { + if (node.isObject()) { + JsonNode currentNode = node; + Iterator iterator = Arrays.stream(StringUtils.split(expression, ".")).iterator(); + + while(true) { + while(iterator.hasNext()) { + String path = (String)iterator.next(); + if (StrUtil.contains(path, "[") && StrUtil.contains(path, "]")) { + String aryPath = StrUtil.subBefore(path, "[", false); + int idxPath = NumberUtil.parseInt(StrUtil.subBetween(path, "[", "]")); + if (idxPath < 0) { + idxPath += currentNode.path(aryPath).size(); + } + + if (!currentNode.path(aryPath).isArray()) { + ((ObjectNode)currentNode).putArray(aryPath); + } + + currentNode = currentNode.path(aryPath); + if (idxPath >= currentNode.size()) { + ((ArrayNode)currentNode).add(objectNode()); + idxPath = currentNode.size() - 1; + } + + if (!iterator.hasNext()) { + if (value instanceof String) { + ((ArrayNode)currentNode).set(idxPath, (String)value); + } else if (value instanceof JsonNode) { + ((ArrayNode)currentNode).set(idxPath, (JsonNode)value); + } else { + ((ArrayNode)currentNode).set(idxPath, valueToTree(value)); + } + } else { + JsonNode nodeByPath = currentNode.path(idxPath); + if (nodeByPath.isObject()) { + currentNode = nodeByPath; + } else { + ((ObjectNode)currentNode).putObject(path); + currentNode = currentNode.path(path); + } + } + } else if (!iterator.hasNext()) { + if (value instanceof String) { + ((ObjectNode)currentNode).put(path, (String)value); + } else if (value instanceof JsonNode) { + ((ObjectNode)currentNode).set(path, (JsonNode)value); + } else { + ((ObjectNode)currentNode).set(path, valueToTree(value)); + } + } else { + JsonNode nodeByPath = currentNode.path(path); + if (nodeByPath.isObject()) { + currentNode = nodeByPath; + } else { + ((ObjectNode)currentNode).putObject(path); + currentNode = currentNode.path(path); + } + } + } + + return; + } + } + } + + public static ArrayNode treeToList(JsonNode param, String childrenColumn, String idColumn, String parentIdColumn, String parentIdValue, String sortColumn) { + if (param != null && !param.isMissingNode()) { + ArrayNode result = doTreeToList(param.deepCopy(), childrenColumn, idColumn, parentIdColumn, parentIdValue); + if (CharSequenceUtil.isNotBlank(sortColumn)) { + ArrayList jsonNodes = CollUtil.newArrayList(result.elements()); + jsonNodes.sort((o1, o2) -> { + String column1 = o1.path(sortColumn).asText(); + String column2 = o2.path(sortColumn).asText(); + return NumberUtil.isNumber(column1) && NumberUtil.isNumber(column2) ? NumberUtil.toBigDecimal(column1).compareTo(NumberUtil.toBigDecimal(column2)) : CharSequenceUtil.compare(column1, column2, true); + }); + result.removeAll(); + result.addAll(jsonNodes); + } + + return result; + } else { + return arrayNode(); + } + } + + public static ArrayNode listToTree(JsonNode param, String childrenColumn, String idColumn, String parentIdColumn, String rootParentIdValue) { + if (param != null && !param.isMissingNode() && !param.isEmpty() && param.isArray()) { + ArrayNode nodeList = (ArrayNode)param.deepCopy(); + Map nodeMap = (Map)CollUtil.newArrayList(nodeList.elements()).stream().collect(Collectors.toMap((nodex) -> { + return nodex.path(idColumn).asText(); + }, (nodex) -> { + return nodex; + })); + Iterator elements = nodeList.iterator(); + + JsonNode node; + while(elements.hasNext()) { + node = (JsonNode)elements.next(); + JsonNode paramNode = (JsonNode)nodeMap.get(node.path(parentIdColumn).asText()); + if (paramNode != null) { + if (paramNode.get(childrenColumn) == null) { + ((ObjectNode)paramNode).putArray(childrenColumn); + } + + ((ArrayNode)paramNode.get(childrenColumn)).add(node); + } + } + + elements = nodeList.elements(); + + while(elements.hasNext()) { + node = (JsonNode)elements.next(); + if (CharSequenceUtil.isBlank(rootParentIdValue)) { + if (!node.path(parentIdColumn).isMissingNode() && !node.path(parentIdColumn).isNull()) { + elements.remove(); + } + } else if (!rootParentIdValue.equals(node.path(parentIdColumn).asText())) { + elements.remove(); + } + } + + return nodeList; + } else { + return arrayNode(); + } + } + + private static ArrayNode doTreeToList(JsonNode param, String childrenColumn, String idColumn, String parentIdColumn, String parentIdValue) { + ArrayNode result = arrayNode(); + if (param.isArray()) { + Iterator var6 = param.iterator(); + + while(var6.hasNext()) { + JsonNode node = (JsonNode)var6.next(); + result.addAll(doTreeToList(node, childrenColumn, idColumn, parentIdColumn, parentIdValue)); + } + } else if (param.isObject()) { + ObjectNode node = (ObjectNode)param; + String nodeId = node.path(idColumn).asText(); + JsonNode children = node.get(childrenColumn); + if (children != null && !children.isMissingNode()) { + result.addAll(doTreeToList(children, childrenColumn, idColumn, parentIdColumn, nodeId)); + } + + if (node.path(parentIdColumn).isMissingNode()) { + node.put(parentIdColumn, parentIdValue); + } + + node.remove(childrenColumn); + result.add(node); + } + + return result; + } + + static { + objectMapper = (new ObjectMapper()).configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).registerModule((new SimpleModule()).addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))).addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))).addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss"))).addSerializer(Long.class, new JsonSerializer() { + @Override + public void serialize(Long value, JsonGenerator gen, SerializerProvider serializers) throws IOException { + gen.writeString(String.valueOf(value)); + } + }).addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))).addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))).addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern("HH:mm:ss")))); + objectMapperIgnoreNull = (new ObjectMapper()).configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).setSerializationInclusion(Include.NON_NULL).registerModule((new SimpleModule()).addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))).addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))).addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss"))).addSerializer(Long.class, new JsonSerializer() { + @Override + public void serialize(Long value, JsonGenerator gen, SerializerProvider serializers) throws IOException { + gen.writeString(String.valueOf(value)); + } + }).addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))).addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))).addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern("HH:mm:ss")))); + logger = LoggerFactory.getLogger(JacksonUtil.class); + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/JavaxValidateUtils.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/JavaxValidateUtils.java new file mode 100644 index 00000000..b4b809f1 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/JavaxValidateUtils.java @@ -0,0 +1,64 @@ +package com.bonus.core.common.utils; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.bonus.common.core.exception.ServiceException; +import com.bonus.constant.RetCodeEnum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.validation.ConstraintViolation; +import javax.validation.Validator; +import java.util.Set; +import java.util.function.Function; + +public class JavaxValidateUtils { + private static final Logger log = LoggerFactory.getLogger(JavaxValidateUtils.class); + + public static void validate(T object) { + Set> violations = validator().validate(object, new Class[0]); + if (!violations.isEmpty()) { + ConstraintViolation firstViolation = (ConstraintViolation)CollUtil.getFirst(violations); + throw new ServiceException(messageFormat(firstViolation), RetCodeEnum.CORE_PARAM_ERROR.getKey()); + } + } + + public static void validate(T object, Function additionalCondition) { + Set> violations = validator().validate(object, new Class[0]); + if (!violations.isEmpty()) { + ConstraintViolation firstViolation = (ConstraintViolation)CollUtil.getFirst(violations); + throw new ServiceException(messageFormat(firstViolation), RetCodeEnum.CORE_PARAM_ERROR.getKey()); + } else if (additionalCondition != null && !(Boolean)additionalCondition.apply(object)) { + throw new ServiceException("请传入有效参数", RetCodeEnum.CORE_PARAM_ERROR.getKey()); + } + } + + private static String messageFormat(ConstraintViolation firstViolation) { + String fieldName = firstViolation.getPropertyPath().toString(); + String fieldDesc; + String errorMsg; + if (fieldName.contains(".")) { + errorMsg = (String)CollUtil.getLast(StrUtil.split(firstViolation.getPropertyPath().toString(), ".")); + fieldDesc = LogUtil.getDescOfField(firstViolation.getLeafBean().getClass(), errorMsg); + } else { + fieldDesc = LogUtil.getDescOfField(firstViolation.getRootBeanClass(), firstViolation.getPropertyPath().toString()); + } + + errorMsg = firstViolation.getMessage(); + if ((StrUtil.isBlank(errorMsg) || "请传入有效参数".equals(errorMsg)) && firstViolation.getConstraintDescriptor() != null) { + String messageTemplate = firstViolation.getConstraintDescriptor().getMessageTemplate(); + log.error(messageTemplate); + } + + if (StrUtil.isBlank(errorMsg)) { + errorMsg = "请传入有效参数"; + } + + log.error(fieldDesc + errorMsg + ": " + fieldName + "=" + String.valueOf(firstViolation.getInvalidValue())); + return fieldName + ": " + errorMsg; + } + + private static Validator validator() { + return (Validator)SpringContextHolder.getBean(Validator.class); + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/LogUtil.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/LogUtil.java new file mode 100644 index 00000000..552ff032 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/LogUtil.java @@ -0,0 +1,217 @@ +package com.bonus.core.common.utils; + +import cn.hutool.core.bean.BeanDesc; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.UUID; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.ClassUtil; +import cn.hutool.core.util.StrUtil; +import io.swagger.annotations.ApiModelProperty; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; +import org.springframework.context.annotation.Lazy; +import org.springframework.core.env.Environment; + +import java.lang.reflect.Field; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +public class LogUtil { + private static final Logger log = LoggerFactory.getLogger(LogUtil.class); + private static final String TRACE_KEY = "X-Trace-Id"; + private static final String ARG_SEPERATOR = " --> "; + private static final ThreadLocal THREAD_LOCAL_FLAG = new InheritableThreadLocal(); + @Lazy + private static final Environment environment = (Environment)SpringContextHolder.getBean(Environment.class); + + public static void generateNewLogTraceId() { + MDC.put("X-Trace-Id", UUID.fastUUID().toString(true)); + } + + public static void putLogTraceId(String traceId) { + MDC.put("X-Trace-Id", traceId); + } + + public static String getCurrentTraceId() { + return MDC.get("X-Trace-Id"); + } + + public static void printArgsIn(String tag, Object... args) { + if ((Boolean)environment.getProperty("system.args-print.enable", Boolean.class, Boolean.FALSE)) { + info(StrUtil.concat(true, new CharSequence[]{tag, "][入参"}), args); + } + } + + public static void printArgsOut(String tag, Object... args) { + if ((Boolean)environment.getProperty("system.args-print.enable", Boolean.class, Boolean.FALSE)) { + info(StrUtil.concat(true, new CharSequence[]{tag, "][出参"}), args); + } + } + + public static void printArgs(String tag, Object... args) { + if ((Boolean)environment.getProperty("system.args-print.enable", Boolean.class, Boolean.FALSE)) { + info(tag, args); + } + } + + public static void printF(String tag, Object... args) { + if (!Boolean.FALSE.equals(THREAD_LOCAL_FLAG.get())) { + info(tag, args); + } + } + + public static void setF(boolean flag) { + THREAD_LOCAL_FLAG.set(flag); + } + + public static void removeF() { + THREAD_LOCAL_FLAG.remove(); + } + + public static void info(String tag, Object... args) { + StringBuilder sb = new StringBuilder(); + sb.append(tag); + if (ArrayUtil.isNotEmpty(args)) { + Object[] var3 = args; + int var4 = args.length; + + for(int var5 = 0; var5 < var4; ++var5) { + Object arg = var3[var5]; + Object argStr = isBasicType(arg) ? arg : JacksonUtil.writeValueAsStringIgnoreNull(arg); + sb.append(" --> ").append(argStr); + } + } + + log.info(sb.toString()); + } + + public static void infoFields(String tag, Object arg, String... fieldNames) { + StringBuilder sb = new StringBuilder(); + sb.append(tag); + concatString(sb, arg, fieldNames); + log.info(sb.toString()); + } + + public static void infoFieldsX(String tag, Object... args) { + StringBuilder sb = new StringBuilder(); + sb.append(tag); + + for(int i = 0; i < args.length; ++i) { + if (i % 2 == 0) { + Object arg = args[i]; + String[] fieldNames = (String[])args[i + 1]; + concatString(sb, arg, fieldNames); + } + } + + log.info(sb.toString()); + } + + public static void infoDesc(String tag, Object... args) { + infoFieldsDesc(tag, args); + } + + public static void infoFieldsDesc(String tag, Object arg, String... fieldNames) { + StringBuilder sb = new StringBuilder(); + sb.append(tag); + concatStringWithDesc(sb, arg, fieldNames); + log.info(sb.toString()); + } + + public static String getDescOfField(Class aClass, String filedName) { + BeanDesc beanDesc = BeanUtil.getBeanDesc(aClass); + Field declaredField = beanDesc.getField(filedName); + if (declaredField == null) { + Class superclass = aClass.getSuperclass(); + return superclass != null ? getDescOfField(superclass, filedName) : ""; + } else { + return getDescOfField(declaredField); + } + } + + private static String getDescOfField(Field field) { + ApiModelProperty annotation = (ApiModelProperty)field.getAnnotation(ApiModelProperty.class); + if (annotation != null) { + StringBuilder sb = new StringBuilder(); + String annotationRemark = annotation.value(); + if (StrUtil.isNotEmpty(annotationRemark)) { + sb.append("【").append(StrUtil.isNotEmpty(annotationRemark) ? annotationRemark : "").append("】"); + } + + return sb.toString(); + } else { + return ""; + } + } + + private static Map descMapFroObj(Object arg, Class aClass, String... propertyNames) { + Map descMap = MapUtil.newHashMap(); + CopyOptions copyOptions = CopyOptions.create().setIgnoreNullValue(false).setFieldNameEditor((s) -> { + return !ArrayUtil.isEmpty(propertyNames) && !ArrayUtil.contains(propertyNames, s) ? null : s + getDescOfField(aClass, s); + }).setFieldValueEditor((s, o) -> { + if (isBasicType(o)) { + return o; + } else if (o instanceof Collection) { + List> listProps = CollUtil.newArrayList(new Map[0]); + ((Collection)o).forEach((o1) -> { + listProps.add(descMapFroObj(o1, ClassUtil.getClass(o1))); + }); + return listProps; + } else { + return descMapFroObj(o, ClassUtil.getClass(o)); + } + }); + BeanUtil.beanToMap(arg, descMap, copyOptions); + return descMap; + } + + private static void concatStringWithDesc(StringBuilder sb, Object arg, String... fieldNames) { + if (arg instanceof Collection) { + ArrayList list = CollUtil.newArrayList(new Object[0]); + ((Collection)arg).forEach((o) -> { + Class aClass = ClassUtil.getClass(arg); + Map descMap = descMapFroObj(arg, aClass, fieldNames); + list.add(descMap); + }); + sb.append(" --> ").append(JacksonUtil.writeValueAsStringIgnoreNull(list)); + } else if (arg != null) { + Class aClass = ClassUtil.getClass(arg); + Map descMap = descMapFroObj(arg, aClass, fieldNames); + sb.append(" --> ").append(JacksonUtil.writeValueAsStringIgnoreNull(descMap)); + } + + } + + private static void concatString(StringBuilder sb, Object arg, String[] fieldNames) { + if (arg instanceof Collection) { + ArrayList list = CollUtil.newArrayList(new Object[0]); + ((Collection)arg).forEach((o) -> { + Map descMap = MapUtil.newHashMap(); + Map stringObjectMap = BeanUtil.beanToMap(o, descMap, false, (s) -> { + return !ArrayUtil.isEmpty(fieldNames) && !ArrayUtil.contains(fieldNames, s) ? null : s; + }); + list.add(stringObjectMap); + }); + sb.append(" --> ").append(JacksonUtil.writeValueAsStringIgnoreNull(list)); + } else if (arg != null) { + Map descMap = MapUtil.newHashMap(); + BeanUtil.beanToMap(arg, descMap, false, (s) -> { + return !ArrayUtil.isEmpty(fieldNames) && !ArrayUtil.contains(fieldNames, s) ? null : s; + }); + sb.append(" --> ").append(JacksonUtil.writeValueAsStringIgnoreNull(descMap)); + } + + } + + private static boolean isBasicType(Object obj) { + return obj == null || ClassUtil.isBasicType(obj.getClass()) || ClassUtil.isSimpleValueType(obj.getClass()) || obj instanceof LocalDate || obj instanceof LocalDateTime || obj instanceof Map; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/device/api/DeviceApi.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/device/api/DeviceApi.java index 46f759ae..c0333baa 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/device/api/DeviceApi.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/device/api/DeviceApi.java @@ -181,10 +181,10 @@ public class DeviceApi { // public DeviceInfo getById(Long deviceId) { // return this.deviceInfoService.getById(deviceId); // } -// -// public DeviceInfo getBySn(String deviceSn) { -// return this.deviceInfoService.getBySn(deviceSn); -// } + + public DeviceInfo getBySn(String deviceSn) { + return this.deviceInfoService.getBySn(deviceSn); + } // // public DeviceInfo getByNum(String deviceNum) { // return this.deviceInfoService.getByNum(deviceNum); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/device/manage/service/DeviceInfoService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/device/manage/service/DeviceInfoService.java index 4fad4dd7..5e0170f9 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/device/manage/service/DeviceInfoService.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/device/manage/service/DeviceInfoService.java @@ -1,5 +1,7 @@ package com.bonus.core.device.manage.service; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.bonus.core.device.manage.dto.DeviceSearchDTO; import com.bonus.core.device.manage.mapper.DeviceInfoMapper; import com.bonus.core.device.manage.model.DeviceInfo; @@ -506,10 +508,11 @@ public class DeviceInfoService { // public DeviceInfo getById(Long deviceId) { // return (DeviceInfo)this.deviceInfoMapper.selectById(deviceId); // } -// -// public DeviceInfo getBySn(String deviceSn) { -// return (DeviceInfo)this.deviceInfoMapper.selectOne((Wrapper)Wrappers.lambdaQuery(DeviceInfo.class).eq(DeviceInfo::getDeviceSn, deviceSn)); -// } + + public DeviceInfo getBySn(String deviceSn) { + return (DeviceInfo)this.deviceInfoMapper.selectOne((Wrapper) Wrappers.lambdaQuery(DeviceInfo.class) + .eq(DeviceInfo::getDeviceSn, deviceSn)); + } // // public DeviceInfoInSystem getBySnInSys(String deviceSn) { // return (DeviceInfoInSystem)Executors.readInSystem(() -> { diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/api/MenuDishesApi.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/api/MenuDishesApi.java index 97d092e1..10c4cfd3 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/api/MenuDishesApi.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/api/MenuDishesApi.java @@ -1,11 +1,16 @@ package com.bonus.core.menu.api; +import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.bonus.constant.LeConstants; import com.bonus.core.menu.entity.MenuDishes; +import com.bonus.core.menu.mapper.MenuDishesMapper; +import com.bonus.core.menu.model.MenuDishesTypeModel; import com.bonus.core.menu.service.MenuDishesService; +import com.bonus.core.menu.utils.NutritionEntity; +import com.google.common.collect.Lists; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -13,6 +18,7 @@ import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; @Service public class MenuDishesApi { @@ -38,9 +44,9 @@ public class MenuDishesApi { // @Autowired // @Lazy // private MenuMaterialMapper menuMaterialMapper; -// @Autowired -// @Lazy -// private MenuDishesMapper menuDishesMapper; + @Autowired + @Lazy + private MenuDishesMapper menuDishesMapper; // @Autowired // @Lazy // private MenuRecipeMapper menuRecipeMapper; @@ -323,10 +329,11 @@ public class MenuDishesApi { // public List listDishesSizeModel() { // return this.menuDishesMapper.listDishesSizeModel(MenuSalesTypeEnum.PORTION_ON.key(), DelFlagEnum.DEL_FALSE.key()); // } -// -// public List getDishesTypeName(List dishesIdList) { -// return (List)(ObjectUtil.isEmpty(dishesIdList) ? Lists.newArrayList() : this.menuDishesMapper.selectDishesTypeNameAndIdList(dishesIdList)); -// } + + public List getDishesTypeName(List dishesIdList) { + return (List)(ObjectUtil.isEmpty(dishesIdList) ? Lists.newArrayList() : this.menuDishesMapper + .selectDishesTypeNameAndIdList(dishesIdList)); + } // // public void asyncUpdateDishesNutrition(Long materialId) { // log.info("异步更新菜品营养信息,输入id: {}", materialId); @@ -337,10 +344,10 @@ public class MenuDishesApi { // log.info("异步更新菜品营养信息,营养信息id: {}", nutritionId); // this.menuDishesService.updateDishesNutritionByNutritionId(nutritionId); // } -// -// public NutritionEntity getNutrientInfo(Map dishesQuantityMap) { -// return this.menuDishesService.getNutrientInfo(dishesQuantityMap); -// } + + public NutritionEntity getNutrientInfo(Map dishesQuantityMap) { + return this.menuDishesService.getNutrientInfo(dishesQuantityMap); + } // // public List nutritionGetDishes(NutritionGetDishesDto nutritionGetDishesDto) { // return this.menuDishesService.nutritionGetDishes(nutritionGetDishesDto); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/mapper/MenuDishesMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/mapper/MenuDishesMapper.java index 25c737a1..c4d7feca 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/mapper/MenuDishesMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/mapper/MenuDishesMapper.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.bonus.core.menu.entity.MenuDishes; +import com.bonus.core.menu.model.MenuDishesTypeModel; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; @@ -170,7 +171,7 @@ public interface MenuDishesMapper extends BaseMapper { // @Select({"select base_dishes_id, material_cost from menu_dishes ${ew.customSqlSegment}"}) // List selectMaterialCostList(@Param("ew") Wrapper wrapper); // -// List selectDishesTypeNameAndIdList(@Param("dishesIdList") List dishesIdList); + List selectDishesTypeNameAndIdList(@Param("dishesIdList") List dishesIdList); // // List getMealListByDishesIds(@Param("dishesIds") List dishesIds); // diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/model/MenuDishesTypeModel.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/model/MenuDishesTypeModel.java new file mode 100644 index 00000000..162bd349 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/model/MenuDishesTypeModel.java @@ -0,0 +1,35 @@ +package com.bonus.core.menu.model; + +import io.swagger.annotations.ApiModel; + +@ApiModel +public class MenuDishesTypeModel { + private Long dishesId; + private Long typeId; + private String typeName; + + public Long getDishesId() { + return this.dishesId; + } + + public Long getTypeId() { + return this.typeId; + } + + public String getTypeName() { + return this.typeName; + } + + public void setDishesId(final Long dishesId) { + this.dishesId = dishesId; + } + + public void setTypeId(final Long typeId) { + this.typeId = typeId; + } + + public void setTypeName(final String typeName) { + this.typeName = typeName; + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/service/MenuDishesService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/service/MenuDishesService.java index e0858039..d2beec13 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/service/MenuDishesService.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/service/MenuDishesService.java @@ -2,6 +2,9 @@ package com.bonus.core.menu.service; import com.baomidou.mybatisplus.extension.service.IService; import com.bonus.core.menu.entity.MenuDishes; +import com.bonus.core.menu.utils.NutritionEntity; + +import java.util.Map; public interface MenuDishesService extends IService { // Long addMenuDishes(MenuDishesAddDTO dishesAddDTO, Integer customId); @@ -98,7 +101,7 @@ public interface MenuDishesService extends IService { // // Map> selectMaterialByTypeAndDishesIds(List dishesIds); // -// NutritionEntity getNutrientInfo(Map dishesQuantityMap); + NutritionEntity getNutrientInfo(Map dishesQuantityMap); // // List getMenuDishesList(List dishesIdList); // diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/service/impl/MenuDishesServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/service/impl/MenuDishesServiceImpl.java index 90ab64da..82060c24 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/service/impl/MenuDishesServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/service/impl/MenuDishesServiceImpl.java @@ -1,13 +1,27 @@ package com.bonus.core.menu.service.impl; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bonus.constant.LeConstants; +import com.bonus.core.common.utils.LogUtil; import com.bonus.core.menu.entity.MenuDishes; import com.bonus.core.menu.mapper.MenuDishesMapper; import com.bonus.core.menu.service.MenuDishesService; +import com.bonus.core.menu.utils.NutritionEntity; +import com.bonus.core.menu.utils.NutritionEntityUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + @Service public class MenuDishesServiceImpl extends ServiceImpl implements MenuDishesService { private static final Logger log = LoggerFactory.getLogger(MenuDishesServiceImpl.class); @@ -2536,30 +2550,32 @@ public class MenuDishesServiceImpl extends ServiceImpl dishesQuantityMap) { -// LogUtil.info("查询营养信息", dishesQuantityMap); -// if (CollUtil.isNotEmpty(dishesQuantityMap)) { -// List dishesIdList = ListUtil.toList(dishesQuantityMap.keySet()); -// List menuDishesList = this.getMenuDishesList(dishesIdList); -// if (CollUtil.isNotEmpty(menuDishesList)) { -// List nutritionEntityList = (List)menuDishesList.stream().map((item) -> { -// Double weight = (Double)dishesQuantityMap.get(item.getDishesId()); -// NutritionEntity nutritionEntity = (NutritionEntity)BeanUtil.copyProperties(item, NutritionEntity.class, new String[0]); -// nutritionEntity.setWeight(weight); -// nutritionEntity.setBaseWeight(item.getWeight()); -// return nutritionEntity; -// }).collect(Collectors.toList()); -// return NutritionEntityUtil.countNutrition(nutritionEntityList); -// } -// } -// -// return new NutritionEntity(); -// } -// -// public List getMenuDishesList(List dishesIdList) { -// return this.list((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MenuDishes.class).in(MenuDishes::getDishesId, dishesIdList)).eq(MenuDishes::getDelFlag, LeConstants.COMMON_NO)); -// } + + @Override + public NutritionEntity getNutrientInfo(Map dishesQuantityMap) { + LogUtil.info("查询营养信息", dishesQuantityMap); + if (CollUtil.isNotEmpty(dishesQuantityMap)) { + List dishesIdList = ListUtil.toList(dishesQuantityMap.keySet()); + List menuDishesList = this.getMenuDishesList(dishesIdList); + if (CollUtil.isNotEmpty(menuDishesList)) { + List nutritionEntityList = (List)menuDishesList.stream().map((item) -> { + Double weight = (Double)dishesQuantityMap.get(item.getDishesId()); + NutritionEntity nutritionEntity = (NutritionEntity) BeanUtil.copyProperties(item, NutritionEntity.class, new String[0]); + nutritionEntity.setWeight(weight); + nutritionEntity.setBaseWeight(item.getWeight()); + return nutritionEntity; + }).collect(Collectors.toList()); + return NutritionEntityUtil.countNutrition(nutritionEntityList); + } + } + + return new NutritionEntity(); + } + + public List getMenuDishesList(List dishesIdList) { + return this.list((Wrapper)((LambdaQueryWrapper) Wrappers.lambdaQuery(MenuDishes.class) + .in(MenuDishes::getDishesId, dishesIdList)).eq(MenuDishes::getDelFlag, LeConstants.COMMON_NO)); + } // // public void updateDishesNutrition(List materialIds) { // List menuUpdateDishesModels = this.menuMaterialDishesService.selectDishesList(materialIds); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/utils/NutritionEntity.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/utils/NutritionEntity.java new file mode 100644 index 00000000..2491f878 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/utils/NutritionEntity.java @@ -0,0 +1,526 @@ +package com.bonus.core.menu.utils; + +public class NutritionEntity { + private Double edible; + private Double water; + private Double calories; + private Double protein; + private Double fat; + private Double carbohydrate; + private Double dietaryFiber; + private Double cholesterol; + private Double ash; + private Double vitaminA; + private Double carotene; + private Double retinol; + private Double thiamine; + private Double riboflavin; + private Double niacin; + private Double vitaminC; + private Double vitaminE; + private Double calcium; + private Double phosphorus; + private Double kalium; + private Double sodium; + private Double magnesium; + private Double iron; + private Double zinc; + private Double selenium; + private Double cuprum; + private Double manganese; + private Double isoleucine; + private Double leucine; + private Double lysine; + private Double saaTotal; + private Double aaaTotal; + private Double threonine; + private Double tryptophan; + private Double valine; + private Double arginine; + private Double histidine; + private Double alanine; + private Double asparticAcid; + private Double glutamate; + private Double glycine; + private Double proline; + private Double serine; + private Double fattyAcid; + private Double iodine; + private Double folic; + private Double choline; + private Double biotin; + private Double pantothenicAcid; + private Double guanine; + private Double adenine; + private Double hypoxanthine; + private Double xanthine; + private Double purine; + private Double glycemicIndex; + private Double weight; + private Double totalWeight; + private Double baseWeight; + + public Double getEdible() { + return this.edible; + } + + public Double getWater() { + return this.water; + } + + public Double getCalories() { + return this.calories; + } + + public Double getProtein() { + return this.protein; + } + + public Double getFat() { + return this.fat; + } + + public Double getCarbohydrate() { + return this.carbohydrate; + } + + public Double getDietaryFiber() { + return this.dietaryFiber; + } + + public Double getCholesterol() { + return this.cholesterol; + } + + public Double getAsh() { + return this.ash; + } + + public Double getVitaminA() { + return this.vitaminA; + } + + public Double getCarotene() { + return this.carotene; + } + + public Double getRetinol() { + return this.retinol; + } + + public Double getThiamine() { + return this.thiamine; + } + + public Double getRiboflavin() { + return this.riboflavin; + } + + public Double getNiacin() { + return this.niacin; + } + + public Double getVitaminC() { + return this.vitaminC; + } + + public Double getVitaminE() { + return this.vitaminE; + } + + public Double getCalcium() { + return this.calcium; + } + + public Double getPhosphorus() { + return this.phosphorus; + } + + public Double getKalium() { + return this.kalium; + } + + public Double getSodium() { + return this.sodium; + } + + public Double getMagnesium() { + return this.magnesium; + } + + public Double getIron() { + return this.iron; + } + + public Double getZinc() { + return this.zinc; + } + + public Double getSelenium() { + return this.selenium; + } + + public Double getCuprum() { + return this.cuprum; + } + + public Double getManganese() { + return this.manganese; + } + + public Double getIsoleucine() { + return this.isoleucine; + } + + public Double getLeucine() { + return this.leucine; + } + + public Double getLysine() { + return this.lysine; + } + + public Double getSaaTotal() { + return this.saaTotal; + } + + public Double getAaaTotal() { + return this.aaaTotal; + } + + public Double getThreonine() { + return this.threonine; + } + + public Double getTryptophan() { + return this.tryptophan; + } + + public Double getValine() { + return this.valine; + } + + public Double getArginine() { + return this.arginine; + } + + public Double getHistidine() { + return this.histidine; + } + + public Double getAlanine() { + return this.alanine; + } + + public Double getAsparticAcid() { + return this.asparticAcid; + } + + public Double getGlutamate() { + return this.glutamate; + } + + public Double getGlycine() { + return this.glycine; + } + + public Double getProline() { + return this.proline; + } + + public Double getSerine() { + return this.serine; + } + + public Double getFattyAcid() { + return this.fattyAcid; + } + + public Double getIodine() { + return this.iodine; + } + + public Double getFolic() { + return this.folic; + } + + public Double getCholine() { + return this.choline; + } + + public Double getBiotin() { + return this.biotin; + } + + public Double getPantothenicAcid() { + return this.pantothenicAcid; + } + + public Double getGuanine() { + return this.guanine; + } + + public Double getAdenine() { + return this.adenine; + } + + public Double getHypoxanthine() { + return this.hypoxanthine; + } + + public Double getXanthine() { + return this.xanthine; + } + + public Double getPurine() { + return this.purine; + } + + public Double getGlycemicIndex() { + return this.glycemicIndex; + } + + public Double getWeight() { + return this.weight; + } + + public Double getTotalWeight() { + return this.totalWeight; + } + + public Double getBaseWeight() { + return this.baseWeight; + } + + public void setEdible(final Double edible) { + this.edible = edible; + } + + public void setWater(final Double water) { + this.water = water; + } + + public void setCalories(final Double calories) { + this.calories = calories; + } + + public void setProtein(final Double protein) { + this.protein = protein; + } + + public void setFat(final Double fat) { + this.fat = fat; + } + + public void setCarbohydrate(final Double carbohydrate) { + this.carbohydrate = carbohydrate; + } + + public void setDietaryFiber(final Double dietaryFiber) { + this.dietaryFiber = dietaryFiber; + } + + public void setCholesterol(final Double cholesterol) { + this.cholesterol = cholesterol; + } + + public void setAsh(final Double ash) { + this.ash = ash; + } + + public void setVitaminA(final Double vitaminA) { + this.vitaminA = vitaminA; + } + + public void setCarotene(final Double carotene) { + this.carotene = carotene; + } + + public void setRetinol(final Double retinol) { + this.retinol = retinol; + } + + public void setThiamine(final Double thiamine) { + this.thiamine = thiamine; + } + + public void setRiboflavin(final Double riboflavin) { + this.riboflavin = riboflavin; + } + + public void setNiacin(final Double niacin) { + this.niacin = niacin; + } + + public void setVitaminC(final Double vitaminC) { + this.vitaminC = vitaminC; + } + + public void setVitaminE(final Double vitaminE) { + this.vitaminE = vitaminE; + } + + public void setCalcium(final Double calcium) { + this.calcium = calcium; + } + + public void setPhosphorus(final Double phosphorus) { + this.phosphorus = phosphorus; + } + + public void setKalium(final Double kalium) { + this.kalium = kalium; + } + + public void setSodium(final Double sodium) { + this.sodium = sodium; + } + + public void setMagnesium(final Double magnesium) { + this.magnesium = magnesium; + } + + public void setIron(final Double iron) { + this.iron = iron; + } + + public void setZinc(final Double zinc) { + this.zinc = zinc; + } + + public void setSelenium(final Double selenium) { + this.selenium = selenium; + } + + public void setCuprum(final Double cuprum) { + this.cuprum = cuprum; + } + + public void setManganese(final Double manganese) { + this.manganese = manganese; + } + + public void setIsoleucine(final Double isoleucine) { + this.isoleucine = isoleucine; + } + + public void setLeucine(final Double leucine) { + this.leucine = leucine; + } + + public void setLysine(final Double lysine) { + this.lysine = lysine; + } + + public void setSaaTotal(final Double saaTotal) { + this.saaTotal = saaTotal; + } + + public void setAaaTotal(final Double aaaTotal) { + this.aaaTotal = aaaTotal; + } + + public void setThreonine(final Double threonine) { + this.threonine = threonine; + } + + public void setTryptophan(final Double tryptophan) { + this.tryptophan = tryptophan; + } + + public void setValine(final Double valine) { + this.valine = valine; + } + + public void setArginine(final Double arginine) { + this.arginine = arginine; + } + + public void setHistidine(final Double histidine) { + this.histidine = histidine; + } + + public void setAlanine(final Double alanine) { + this.alanine = alanine; + } + + public void setAsparticAcid(final Double asparticAcid) { + this.asparticAcid = asparticAcid; + } + + public void setGlutamate(final Double glutamate) { + this.glutamate = glutamate; + } + + public void setGlycine(final Double glycine) { + this.glycine = glycine; + } + + public void setProline(final Double proline) { + this.proline = proline; + } + + public void setSerine(final Double serine) { + this.serine = serine; + } + + public void setFattyAcid(final Double fattyAcid) { + this.fattyAcid = fattyAcid; + } + + public void setIodine(final Double iodine) { + this.iodine = iodine; + } + + public void setFolic(final Double folic) { + this.folic = folic; + } + + public void setCholine(final Double choline) { + this.choline = choline; + } + + public void setBiotin(final Double biotin) { + this.biotin = biotin; + } + + public void setPantothenicAcid(final Double pantothenicAcid) { + this.pantothenicAcid = pantothenicAcid; + } + + public void setGuanine(final Double guanine) { + this.guanine = guanine; + } + + public void setAdenine(final Double adenine) { + this.adenine = adenine; + } + + public void setHypoxanthine(final Double hypoxanthine) { + this.hypoxanthine = hypoxanthine; + } + + public void setXanthine(final Double xanthine) { + this.xanthine = xanthine; + } + + public void setPurine(final Double purine) { + this.purine = purine; + } + + public void setGlycemicIndex(final Double glycemicIndex) { + this.glycemicIndex = glycemicIndex; + } + + public void setWeight(final Double weight) { + this.weight = weight; + } + + public void setTotalWeight(final Double totalWeight) { + this.totalWeight = totalWeight; + } + + public void setBaseWeight(final Double baseWeight) { + this.baseWeight = baseWeight; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/utils/NutritionEntityUtil.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/utils/NutritionEntityUtil.java new file mode 100644 index 00000000..00897dfe --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/utils/NutritionEntityUtil.java @@ -0,0 +1,80 @@ +package com.bonus.core.menu.utils; + +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.bonus.utils.Arith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.ReflectionUtils; + +import java.lang.reflect.Field; +import java.util.Iterator; +import java.util.List; + +public class NutritionEntityUtil { + private static final Logger log = LoggerFactory.getLogger(NutritionEntityUtil.class); + + private NutritionEntityUtil() { + } + + public static NutritionEntity countNutrition(List nutritionEntityList) { + if (CollectionUtils.isEmpty(nutritionEntityList)) { + return new NutritionEntity(); + } else { + NutritionEntity nutritionEntity = new NutritionEntity(); + Iterator var2 = nutritionEntityList.iterator(); + + while(var2.hasNext()) { + NutritionEntity tempNutrition = (NutritionEntity)var2.next(); + double proportion = Arith.div(tempNutrition.getWeight(), tempNutrition.getBaseWeight(), 4); + Field[] var6 = tempNutrition.getClass().getDeclaredFields(); + int var7 = var6.length; + + for(int var8 = 0; var8 < var7; ++var8) { + Field field = var6[var8]; + ReflectionUtils.makeAccessible(field); + + try { + String fieldName = field.getName(); + Object temp = field.get(tempNutrition); + double param = 0.0; + if (temp != null && (Double)temp != -1.0) { + param = (Double)temp; + } + + Field declaredField = nutritionEntity.getClass().getDeclaredField(fieldName); + ReflectionUtils.makeAccessible(declaredField); + Object tempObject = declaredField.get(nutritionEntity); + double lastValue = 0.0; + if (tempObject != null) { + lastValue = (Double)tempObject; + } + + double newValue = Arith.add(Arith.mul(param, proportion), lastValue); + declaredField.set(nutritionEntity, newValue); + } catch (NoSuchFieldException | IllegalAccessException var21) { + log.info("获取属性值异常 : {}", var21.getMessage()); + } + } + } + + Field[] var22 = nutritionEntity.getClass().getDeclaredFields(); + int var23 = var22.length; + + for(int var24 = 0; var24 < var23; ++var24) { + Field field = var22[var24]; + ReflectionUtils.makeAccessible(field); + + try { + Object tempObject = field.get(nutritionEntity); + if (tempObject != null && (Double)tempObject != -1.0) { + field.set(nutritionEntity, Arith.round((Double)tempObject, 2)); + } + } catch (Exception var20) { + log.info("最终获取属性值异常 : {}", var20.getMessage()); + } + } + + return nutritionEntity; + } + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/controller/OrderController.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/controller/OrderController.java new file mode 100644 index 00000000..b8544dda --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/controller/OrderController.java @@ -0,0 +1,29 @@ +package com.bonus.core.order.common.controller; + +import com.bonus.common.core.web.controller.BaseController; +import com.bonus.common.core.web.page.TableDataInfo; +import com.bonus.core.order.common.vo.OrderEnumVO; +import com.bonus.core.pay.common.constants.PayTypeEnum; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping({"/api/v2/order/enums"}) +@Api( + value = "orderEnum", + tags = {"订单相关枚举"} +) +public class OrderController extends BaseController { + @PostMapping({"/pay-type-list"}) + @ApiOperation("支付类型") + public TableDataInfo getPayTypeEnumList() { + List> allEnumsList = PayTypeEnum.getAllEnumsList(); + return getDataTable(OrderEnumVO.listOf(allEnumsList)); + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/mapper/OrderDeliveryMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/mapper/OrderDeliveryMapper.java new file mode 100644 index 00000000..150df6d8 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/mapper/OrderDeliveryMapper.java @@ -0,0 +1,15 @@ +package com.bonus.core.order.common.mapper; + +import com.baomidou.mybatisplus.annotation.InterceptorIgnore; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bonus.core.order.common.model.OrderDelivery; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.time.LocalDate; +import java.time.LocalDateTime; + +@Mapper +@InterceptorIgnore +public interface OrderDeliveryMapper extends BaseMapper { +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/mapper/OrderRefundDetailMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/mapper/OrderRefundDetailMapper.java new file mode 100644 index 00000000..ab51c761 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/mapper/OrderRefundDetailMapper.java @@ -0,0 +1,16 @@ +package com.bonus.core.order.common.mapper; + +import com.baomidou.mybatisplus.annotation.InterceptorIgnore; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bonus.core.order.common.model.OrderRefundDetail; +import com.bonus.core.order.weight.vo.RefundDetailStateVO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +@InterceptorIgnore +public interface OrderRefundDetailMapper extends BaseMapper { + List listRefundDetailState(@Param("orderId") Long orderId, @Param("macOrderId") String macOrderId); +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/model/OrderDelivery.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/model/OrderDelivery.java new file mode 100644 index 00000000..aa268aff --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/model/OrderDelivery.java @@ -0,0 +1,209 @@ +package com.bonus.core.order.common.model; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.bonus.core.common.enums.DeliveryTypeEnum; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDate; +import java.time.LocalDateTime; + +@TableName("order_delivery") +public class OrderDelivery { + private Long deliveryId; + @DateTimeFormat( + pattern = "yyyy-MM-dd" + ) + @JsonFormat( + pattern = "yyyy-MM-dd" + ) + private LocalDate orderDate; + private Long orderId; + private String deliveryCode; + private String consigneeName; + private String consigneeMobile; + private String consigneeAddress; + private Long deliveryRelatedId; + private String deliveryUserId; + private String deliveryName; + private String deliveryMobile; + @DateTimeFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + private LocalDateTime deliveryTime; + private Integer deliveryType; + @DateTimeFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + private LocalDateTime deliveryFinishTime; + @DateTimeFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + private LocalDateTime crtime; + @DateTimeFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + private LocalDateTime uptime; + + public static OrderDelivery newDefaultInstance() { + OrderDelivery orderDelivery = new OrderDelivery(); + orderDelivery.setDeliveryType(DeliveryTypeEnum.SELF_TAKE.getKey()); + return orderDelivery; + } + + public Long getDeliveryId() { + return this.deliveryId; + } + + public LocalDate getOrderDate() { + return this.orderDate; + } + + public Long getOrderId() { + return this.orderId; + } + + public String getDeliveryCode() { + return this.deliveryCode; + } + + public String getConsigneeName() { + return this.consigneeName; + } + + public String getConsigneeMobile() { + return this.consigneeMobile; + } + + public String getConsigneeAddress() { + return this.consigneeAddress; + } + + public Long getDeliveryRelatedId() { + return this.deliveryRelatedId; + } + + public String getDeliveryUserId() { + return this.deliveryUserId; + } + + public String getDeliveryName() { + return this.deliveryName; + } + + public String getDeliveryMobile() { + return this.deliveryMobile; + } + + public LocalDateTime getDeliveryTime() { + return this.deliveryTime; + } + + public Integer getDeliveryType() { + return this.deliveryType; + } + + public LocalDateTime getDeliveryFinishTime() { + return this.deliveryFinishTime; + } + + public LocalDateTime getCrtime() { + return this.crtime; + } + + public LocalDateTime getUptime() { + return this.uptime; + } + + public void setDeliveryId(final Long deliveryId) { + this.deliveryId = deliveryId; + } + + @JsonFormat( + pattern = "yyyy-MM-dd" + ) + public void setOrderDate(final LocalDate orderDate) { + this.orderDate = orderDate; + } + + public void setOrderId(final Long orderId) { + this.orderId = orderId; + } + + public void setDeliveryCode(final String deliveryCode) { + this.deliveryCode = deliveryCode; + } + + public void setConsigneeName(final String consigneeName) { + this.consigneeName = consigneeName; + } + + public void setConsigneeMobile(final String consigneeMobile) { + this.consigneeMobile = consigneeMobile; + } + + public void setConsigneeAddress(final String consigneeAddress) { + this.consigneeAddress = consigneeAddress; + } + + public void setDeliveryRelatedId(final Long deliveryRelatedId) { + this.deliveryRelatedId = deliveryRelatedId; + } + + public void setDeliveryUserId(final String deliveryUserId) { + this.deliveryUserId = deliveryUserId; + } + + public void setDeliveryName(final String deliveryName) { + this.deliveryName = deliveryName; + } + + public void setDeliveryMobile(final String deliveryMobile) { + this.deliveryMobile = deliveryMobile; + } + + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + public void setDeliveryTime(final LocalDateTime deliveryTime) { + this.deliveryTime = deliveryTime; + } + + public void setDeliveryType(final Integer deliveryType) { + this.deliveryType = deliveryType; + } + + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + public void setDeliveryFinishTime(final LocalDateTime deliveryFinishTime) { + this.deliveryFinishTime = deliveryFinishTime; + } + + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + public void setCrtime(final LocalDateTime crtime) { + this.crtime = crtime; + } + + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + public void setUptime(final LocalDateTime uptime) { + this.uptime = uptime; + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/model/OrderRefundDetail.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/model/OrderRefundDetail.java new file mode 100644 index 00000000..234b1802 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/model/OrderRefundDetail.java @@ -0,0 +1,148 @@ +package com.bonus.core.order.common.model; + +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@TableName("order_refund_detail") +public class OrderRefundDetail { + private Long orderRefundId; + private Long detailId; + private Integer quantity; + private BigDecimal refundAmount; + private Integer realQuantity; + private BigDecimal realRefundAmount; + private Integer restoreQuantity; + @DateTimeFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + private LocalDateTime crtime; + @DateTimeFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + private LocalDateTime uptime; + + public OrderRefundDetail() { + } + + public OrderRefundDetail(Long detailId, Integer quantity, Integer realQuantity) { + this.detailId = detailId; + this.quantity = quantity; + this.realQuantity = realQuantity; + } + + public OrderRefundDetail copyInstance() { + return (OrderRefundDetail)BeanUtil.copyProperties(this, OrderRefundDetail.class, new String[0]); + } + + public static OrderRefundDetail newDefaultInstance() { + OrderRefundDetail orderRefundDetail = (new OrderRefundDetail()).setQuantity(1).setRefundAmount(BigDecimal.ZERO).setRealQuantity(0).setRealRefundAmount(BigDecimal.ZERO).setRestoreQuantity(0); + return orderRefundDetail; + } + + public static OrderRefundDetail newRefundedInstance(BigDecimal refundAmount) { + OrderRefundDetail orderRefundDetail = (new OrderRefundDetail()).setQuantity(1).setRefundAmount(refundAmount).setRealQuantity(1).setRealRefundAmount(refundAmount).setRestoreQuantity(0); + return orderRefundDetail; + } + + public static String[] logFields() { + return new String[]{"orderRefundId", "detailId", "quantity", "refundAmount", "realQuantity", "realRefundAmount", "restoreQuantity"}; + } + + public Long getOrderRefundId() { + return this.orderRefundId; + } + + public Long getDetailId() { + return this.detailId; + } + + public Integer getQuantity() { + return this.quantity; + } + + public BigDecimal getRefundAmount() { + return this.refundAmount; + } + + public Integer getRealQuantity() { + return this.realQuantity; + } + + public BigDecimal getRealRefundAmount() { + return this.realRefundAmount; + } + + public Integer getRestoreQuantity() { + return this.restoreQuantity; + } + + public LocalDateTime getCrtime() { + return this.crtime; + } + + public LocalDateTime getUptime() { + return this.uptime; + } + + public OrderRefundDetail setOrderRefundId(final Long orderRefundId) { + this.orderRefundId = orderRefundId; + return this; + } + + public OrderRefundDetail setDetailId(final Long detailId) { + this.detailId = detailId; + return this; + } + + public OrderRefundDetail setQuantity(final Integer quantity) { + this.quantity = quantity; + return this; + } + + public OrderRefundDetail setRefundAmount(final BigDecimal refundAmount) { + this.refundAmount = refundAmount; + return this; + } + + public OrderRefundDetail setRealQuantity(final Integer realQuantity) { + this.realQuantity = realQuantity; + return this; + } + + public OrderRefundDetail setRealRefundAmount(final BigDecimal realRefundAmount) { + this.realRefundAmount = realRefundAmount; + return this; + } + + public OrderRefundDetail setRestoreQuantity(final Integer restoreQuantity) { + this.restoreQuantity = restoreQuantity; + return this; + } + + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + public OrderRefundDetail setCrtime(final LocalDateTime crtime) { + this.crtime = crtime; + return this; + } + + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + public OrderRefundDetail setUptime(final LocalDateTime uptime) { + this.uptime = uptime; + return this; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/OrderDeliveryService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/OrderDeliveryService.java new file mode 100644 index 00000000..363af528 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/OrderDeliveryService.java @@ -0,0 +1,12 @@ +package com.bonus.core.order.common.service; + + +import com.bonus.core.order.common.model.OrderDelivery; + +import java.time.LocalDate; +import java.util.Collection; +import java.util.List; + +public interface OrderDeliveryService { + OrderDelivery getByOrderId(Long orderId, LocalDate orderDate); +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/OrderDetailService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/OrderDetailService.java index 1a22d005..8fb9184d 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/OrderDetailService.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/OrderDetailService.java @@ -21,7 +21,7 @@ public interface OrderDetailService { // // void removeByDetailId(Long detailId, LocalDate orderDate); -// List getOrderDetailList(Long orderId, LocalDate orderDate); + List getOrderDetailList(Long orderId, LocalDate orderDate); // // List getOrderDetailList(List orderIdList, Collection orderDates); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/OrderInfoService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/OrderInfoService.java index cffc424e..d63f18a3 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/OrderInfoService.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/OrderInfoService.java @@ -4,6 +4,7 @@ import com.bonus.core.order.common.dto.OrderSearchParam; import com.bonus.core.order.common.model.OrderInfo; import com.bonus.core.order.common.vo.OrderIdDateVO; import com.bonus.core.order.common.vo.OrderInfoVO; +import com.bonus.core.order.mobile.vo.OrderInfoMobileVO; import com.bonus.core.order.mobile.vo.OrderListMobileVO; import com.bonus.core.order.web.dto.OrderUserPermissionDTO; @@ -88,7 +89,7 @@ public interface OrderInfoService { // // List getOrderRefundMobileList(List orderIds, List orderDates); // -// OrderInfoMobileVO getOrderInfoMobileByOrderId(Long orderId); + OrderInfoMobileVO getOrderInfoMobileByOrderId(Long orderId); // // List listOrderForAndroid(List orderIds, List orderDates); // diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/OrderRefundDetailService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/OrderRefundDetailService.java new file mode 100644 index 00000000..fa7a5805 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/OrderRefundDetailService.java @@ -0,0 +1,22 @@ +package com.bonus.core.order.common.service; + +import com.bonus.core.order.weight.vo.RefundDetailStateVO; + +import java.time.LocalDate; +import java.util.List; + +public interface OrderRefundDetailService { +// void batchInsertOrderRefundDetail(List orderRefundDetailList); +// +// void updateRefundDetailQuantity(List refundDetailList); +// +// void deleteByOrderRefundIds(List orderRefundIds); +// +// List listByOrderRefundId(Long orderRefundId); +// +// List listByOrderRefundIds(List orderRefundIds); +// +// List listOrderRefundDetailVO(List orderRefundIds, List orderDates); + + List listRefundDetailState(Long orderId, String macOrderId); +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/impl/OrderDeliveryServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/impl/OrderDeliveryServiceImpl.java new file mode 100644 index 00000000..aef93b15 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/impl/OrderDeliveryServiceImpl.java @@ -0,0 +1,24 @@ +package com.bonus.core.order.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bonus.core.order.common.mapper.OrderDeliveryMapper; +import com.bonus.core.order.common.model.OrderDelivery; +import com.bonus.core.order.common.service.OrderDeliveryService; +import org.springframework.stereotype.Service; + +import java.time.LocalDate; + +@Service +public class OrderDeliveryServiceImpl extends ServiceImpl implements OrderDeliveryService { + + @Override + public OrderDelivery getByOrderId(Long orderId, LocalDate orderDate) { + return orderId == null ? null : (OrderDelivery)((OrderDeliveryMapper)this.baseMapper) + .selectOne((Wrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(OrderDelivery.class) + .eq(OrderDelivery::getOrderId, orderId)).eq(orderDate != null, + OrderDelivery::getOrderDate, orderDate)).last("limit 1")); + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/impl/OrderDetailServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/impl/OrderDetailServiceImpl.java index 87d8b62f..223d4757 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/impl/OrderDetailServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/impl/OrderDetailServiceImpl.java @@ -73,16 +73,16 @@ public class OrderDetailServiceImpl extends ServiceImpl getOrderDetailList(Long orderId, LocalDate orderDate) { -// return (List)(!LeNumUtil.isValidId(orderId) ? CollUtil.newArrayList(new OrderDetail[0]) : -// this.getOrderDetailList((List)CollUtil.toList(new Long[]{orderId}), -// (Collection)(orderDate != null ? CollUtil.newArrayList(new LocalDate[]{orderDate}) : null))); -// } -// -// public List getOrderDetailList(List orderIdList, Collection orderDates) { -// return this.getOrderDetailList(orderIdList, orderDates, (List)null); -// } + @Override + public List getOrderDetailList(Long orderId, LocalDate orderDate) { + return (List)(!LeNumUtil.isValidId(orderId) ? CollUtil.newArrayList(new OrderDetail[0]) : + this.getOrderDetailList((List)CollUtil.toList(new Long[]{orderId}), + (Collection)(orderDate != null ? CollUtil.newArrayList(new LocalDate[]{orderDate}) : null))); + } + + public List getOrderDetailList(List orderIdList, Collection orderDates) { + return this.getOrderDetailList(orderIdList, orderDates, (List)null); + } @Override public List getOrderDetailList(List orderIdList, Collection orderDates, List detailStateList) { diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/impl/OrderInfoServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/impl/OrderInfoServiceImpl.java index c9ae28ef..68f8bead 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/impl/OrderInfoServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/impl/OrderInfoServiceImpl.java @@ -17,6 +17,7 @@ import com.bonus.core.order.common.mapper.OrderInfoMapper; import com.bonus.core.order.common.model.OrderInfo; import com.bonus.core.order.common.service.OrderInfoService; import com.bonus.core.order.common.vo.OrderIdDateVO; +import com.bonus.core.order.mobile.vo.OrderInfoMobileVO; import com.bonus.core.order.mobile.vo.OrderListMobileVO; import com.bonus.core.order.utils.LeOrderUtil; import com.bonus.core.order.web.dto.OrderUserPermissionDTO; @@ -78,29 +79,29 @@ public class OrderInfoServiceImpl extends ServiceImpl dateRange = LeOrderUtil.queryDateRange(id); -// orderInfo = (OrderInfo)((OrderInfoMapper)this.baseMapper).selectOne((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(OrderInfo.class).eq(OrderInfo::getOrderId, id)).between(OrderInfo::getOrderDate, dateRange.get(0), dateRange.get(1))); -// } -// -// if (orderInfo == null) { -// orderInfo = (OrderInfo)((OrderInfoMapper)this.baseMapper).selectOne((Wrapper)Wrappers.lambdaQuery(OrderInfo.class).eq(OrderInfo::getOrderId, id)); -// } -// -// return orderInfo; -// } -// } + + private OrderInfo getByIdDate(Long id, LocalDate... orderDates) { + if (id == null) { + return null; + } else { + int argLength = ArrayUtil.length(orderDates); + OrderInfo orderInfo; + if (argLength == 2) { + orderInfo = (OrderInfo)((OrderInfoMapper)this.baseMapper).selectOne((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(OrderInfo.class).eq(OrderInfo::getOrderId, id)).between(OrderInfo::getOrderDate, orderDates[0], orderDates[1])); + } else if (argLength == 1) { + orderInfo = (OrderInfo)((OrderInfoMapper)this.baseMapper).selectOne((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(OrderInfo.class).eq(OrderInfo::getOrderId, id)).eq(OrderInfo::getOrderDate, orderDates)); + } else { + List dateRange = LeOrderUtil.queryDateRange(id); + orderInfo = (OrderInfo)((OrderInfoMapper)this.baseMapper).selectOne((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(OrderInfo.class).eq(OrderInfo::getOrderId, id)).between(OrderInfo::getOrderDate, dateRange.get(0), dateRange.get(1))); + } + + if (orderInfo == null) { + orderInfo = (OrderInfo)((OrderInfoMapper)this.baseMapper).selectOne((Wrapper)Wrappers.lambdaQuery(OrderInfo.class).eq(OrderInfo::getOrderId, id)); + } + + return orderInfo; + } + } // // public OrderInfoVO getVoById(Long orderId, LocalDate... orderDate) { // return !LeNumUtil.isValidId(orderId) ? null : (OrderInfoVO)this.listVoByOrderIds(CollUtil.toList(new Long[]{orderId}), orderDate != null ? CollUtil.toList(orderDate) : null).stream().findFirst().orElse((Object)null); @@ -281,11 +282,12 @@ public class OrderInfoServiceImpl extends ServiceImpl listOrderInfoByMacOrderId(String macOrderId, LocalDate... orderDates) { // int argLength = ArrayUtil.length(orderDates); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/impl/OrderRefundDetailServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/impl/OrderRefundDetailServiceImpl.java new file mode 100644 index 00000000..19b16146 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/impl/OrderRefundDetailServiceImpl.java @@ -0,0 +1,97 @@ +package com.bonus.core.order.common.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bonus.core.order.common.mapper.OrderRefundDetailMapper; +import com.bonus.core.order.common.model.OrderRefundDetail; +import com.bonus.core.order.common.service.OrderRefundDetailService; +import com.bonus.core.order.weight.vo.RefundDetailStateVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.Serializable; +import java.lang.invoke.SerializedLambda; +import java.time.LocalDate; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + +@Service +public class OrderRefundDetailServiceImpl extends ServiceImpl implements OrderRefundDetailService { +// @Autowired +// @Lazy +// protected OrderDetailService orderDetailService; +// @Autowired +// @Lazy +// protected OrderRefundService orderRefundService; + +// public OrderRefundDetail getById(Serializable id) { +// return id == null ? null : (OrderRefundDetail)super.getById(id); +// } +// +// @Transactional( +// rollbackFor = {Exception.class} +// ) +// public void batchInsertOrderRefundDetail(List orderRefundDetailList) { +// if (!CollUtil.isEmpty(orderRefundDetailList)) { +// super.saveBatch(orderRefundDetailList); +// } +// } +// +// public void updateRefundDetailQuantity(List orderDetailList) { +// if (!CollUtil.isEmpty(orderDetailList)) { +// Iterator var2 = orderDetailList.iterator(); +// +// while(var2.hasNext()) { +// OrderRefundDetail orderRefundDetail = (OrderRefundDetail)var2.next(); +// ((OrderRefundDetailMapper)this.baseMapper).update((Object)null, (Wrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(OrderRefundDetail.class).set(orderRefundDetail.getQuantity() != null, OrderRefundDetail::getQuantity, orderRefundDetail.getQuantity())).set(orderRefundDetail.getRealQuantity() != null, OrderRefundDetail::getRealQuantity, orderRefundDetail.getRealQuantity())).set(orderRefundDetail.getRestoreQuantity() != null, OrderRefundDetail::getRestoreQuantity, orderRefundDetail.getRestoreQuantity())).set(orderRefundDetail.getRefundAmount() != null, OrderRefundDetail::getRefundAmount, orderRefundDetail.getRefundAmount())).set(orderRefundDetail.getRealRefundAmount() != null, OrderRefundDetail::getRealRefundAmount, orderRefundDetail.getRealRefundAmount())).eq(OrderRefundDetail::getOrderRefundId, orderRefundDetail.getOrderRefundId())).eq(OrderRefundDetail::getDetailId, orderRefundDetail.getDetailId())); +// } +// +// } +// } +// +// public void deleteByOrderRefundIds(List orderRefundIds) { +// if (!CollUtil.isEmpty(orderRefundIds)) { +// ((OrderRefundDetailMapper)this.baseMapper).delete((Wrapper)Wrappers.lambdaQuery(OrderRefundDetail.class).in(OrderRefundDetail::getOrderRefundId, orderRefundIds)); +// } +// } +// +// public List listByOrderRefundId(Long orderRefundId) { +// return ((OrderRefundDetailMapper)this.baseMapper).selectList((Wrapper)Wrappers.lambdaQuery(OrderRefundDetail.class).eq(OrderRefundDetail::getOrderRefundId, orderRefundId)); +// } +// +// public List listByOrderRefundIds(List orderRefundIds) { +// return (List)(CollUtil.isEmpty(orderRefundIds) ? CollUtil.newArrayList(new OrderRefundDetail[0]) : ((OrderRefundDetailMapper)this.baseMapper).selectList((Wrapper)Wrappers.lambdaQuery(OrderRefundDetail.class).in(OrderRefundDetail::getOrderRefundId, orderRefundIds))); +// } + + @Override + public List listRefundDetailState(Long orderId, String macOrderId) { + return ((OrderRefundDetailMapper)this.baseMapper).listRefundDetailState(orderId, macOrderId); + } + +// public List listOrderRefundDetailVO(List orderRefundIds, List orderDates) { +// if (CollUtil.isEmpty(orderRefundIds)) { +// return CollUtil.newArrayList(new OrderRefundDetailVO[0]); +// } else { +// List orderRefundDetails = ((OrderRefundDetailMapper)this.baseMapper).selectList((Wrapper)Wrappers.lambdaQuery(OrderRefundDetail.class).in(OrderRefundDetail::getOrderRefundId, orderRefundIds)); +// if (CollUtil.isEmpty(orderRefundDetails)) { +// return CollUtil.newArrayList(new OrderRefundDetailVO[0]); +// } else { +// List detailIds = (List)orderRefundDetails.stream().map(OrderRefundDetail::getDetailId).collect(Collectors.toList()); +// Map orderDetailMap = (Map)this.orderDetailService.listByDetailIds(detailIds, orderDates).stream().collect(Collectors.toMap(OrderDetail::getDetailId, Function.identity())); +// List voList = (List)orderRefundDetails.stream().map((s) -> { +// return OrderRefundDetailVO.of(s, (OrderDetail)orderDetailMap.get(s.getDetailId())); +// }).collect(Collectors.toList()); +// this.orderDetailService.fillOrderDetailImage(voList); +// return voList; +// } +// } +// } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/vo/OrderEnumVO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/vo/OrderEnumVO.java new file mode 100644 index 00000000..ef129f59 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/vo/OrderEnumVO.java @@ -0,0 +1,40 @@ +package com.bonus.core.order.common.vo; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; +import cn.hutool.core.map.MapUtil; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class OrderEnumVO { + private Integer key; + private String value; + + public static List listOf(List> allEnumsList) { + return CollUtil.isEmpty(allEnumsList) ? ListUtil.empty() : (List)allEnumsList.stream().map((map) -> { + OrderEnumVO orderEnumVO = new OrderEnumVO(); + orderEnumVO.setKey(MapUtil.getInt(map, "key")); + orderEnumVO.setValue(MapUtil.getStr(map, "value")); + return orderEnumVO; + }).collect(Collectors.toList()); + } + + public Integer getKey() { + return this.key; + } + + public String getValue() { + return this.value; + } + + public void setKey(final Integer key) { + this.key = key; + } + + public void setValue(final String value) { + this.value = value; + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/custom/OrderCustomMobileBusiness.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/custom/OrderCustomMobileBusiness.java index 3f42d5b8..7864f666 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/custom/OrderCustomMobileBusiness.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/custom/OrderCustomMobileBusiness.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import com.bonus.core.common.custom.business.CustomBusiness; import com.bonus.core.common.page.PageVO; import com.bonus.core.order.mobile.dto.OrderListMobileDTO; +import com.bonus.core.order.mobile.vo.OrderInfoMobileVO; import com.bonus.core.order.mobile.vo.OrderListMobileVO; import org.springframework.stereotype.Service; @@ -55,9 +56,9 @@ public class OrderCustomMobileBusiness implements CustomBusiness { public void didQueryOrderList(OrderListMobileDTO param, PageVO pageVO) { } -// public OrderInfoMobileVO didQueryOrderInfo(OrderInfoMobileVO orderInfoMobileVO) { -// return orderInfoMobileVO; -// } + public OrderInfoMobileVO didQueryOrderInfo(OrderInfoMobileVO orderInfoMobileVO) { + return orderInfoMobileVO; + } // // public UnifyPaySelectVO willReSyncOrderPayResult(Long orderId) { // return null; diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/controller/OrderInfoMobileController.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/controller/OrderInfoMobileController.java index 909df129..badd87fb 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/controller/OrderInfoMobileController.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/controller/OrderInfoMobileController.java @@ -1,11 +1,15 @@ package com.bonus.core.order.mobile.controller; +import com.bonus.common.core.domain.R; import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.page.TableDataInfo; import com.bonus.core.common.page.PageVO; +import com.bonus.core.common.utils.JavaxValidateUtils; import com.bonus.core.order.common.dto.RequestHeaderDTO; +import com.bonus.core.order.mobile.dto.OrderIdMobileDTO; import com.bonus.core.order.mobile.dto.OrderListMobileDTO; import com.bonus.core.order.mobile.service.OrderInfoMobileBusiness; +import com.bonus.core.order.mobile.vo.OrderInfoMobileVO; import com.bonus.core.order.mobile.vo.OrderListMobileVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -55,17 +59,17 @@ public class OrderInfoMobileController extends BaseController { // PageVO orderPage = this.orderInfoMobileBusiness.orderRefundList((OrderRefundListMobileQueryDTO)request.getContent(), headerDTO); // return LeResponse.succ(orderPage); // } -// -// @PostMapping({"/info"}) -// @ApiOperation( -// value = "获取订单详情", -// notes = "cmt-获取订单详情" -// ) -// public LeResponse orderInfo(@RequestBody LeRequest request) { -// JavaxValidateUtils.validate((OrderIdMobileDTO)request.getContent()); -// OrderInfoMobileVO orderInfo = this.orderInfoMobileBusiness.orderInfo(((OrderIdMobileDTO)request.getContent()).getOrderId()); -// return LeResponse.succ(orderInfo); -// } + + @PostMapping({"/info"}) + @ApiOperation( + value = "获取订单详情", + notes = "cmt-获取订单详情" + ) + public R orderInfo(@RequestBody OrderIdMobileDTO request) { + JavaxValidateUtils.validate((OrderIdMobileDTO)request); + OrderInfoMobileVO orderInfo = this.orderInfoMobileBusiness.orderInfo(request.getOrderId()); + return R.ok(orderInfo); + } // // @PostMapping({"/sync-pay-state"}) // public LeResponse orderSyncPayState(@RequestBody LeRequest request) { diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/dto/OrderIdMobileDTO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/dto/OrderIdMobileDTO.java new file mode 100644 index 00000000..4158f396 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/dto/OrderIdMobileDTO.java @@ -0,0 +1,18 @@ +package com.bonus.core.order.mobile.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel("移动端订单idDTO") +public class OrderIdMobileDTO { + @ApiModelProperty("订单号") + private Long orderId; + + public Long getOrderId() { + return this.orderId; + } + + public void setOrderId(final Long orderId) { + this.orderId = orderId; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/service/OrderInfoMobileBusiness.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/service/OrderInfoMobileBusiness.java index 693a7609..983a81e7 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/service/OrderInfoMobileBusiness.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/service/OrderInfoMobileBusiness.java @@ -3,6 +3,7 @@ package com.bonus.core.order.mobile.service; import com.bonus.core.common.page.PageVO; import com.bonus.core.order.common.dto.RequestHeaderDTO; import com.bonus.core.order.mobile.dto.OrderListMobileDTO; +import com.bonus.core.order.mobile.vo.OrderInfoMobileVO; import com.bonus.core.order.mobile.vo.OrderListMobileVO; import java.util.List; @@ -18,7 +19,7 @@ public interface OrderInfoMobileBusiness { // // PageVO orderRefundList(OrderRefundListMobileQueryDTO queryDTO, RequestHeaderDTO headerDTO); // -// OrderInfoMobileVO orderInfo(Long orderId); + OrderInfoMobileVO orderInfo(Long orderId); // // OrderInfoMobileVO weightOrderInfo(OrderInfoWeightMobileDTO queryDTO); // diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/service/impl/OrderInfoMobileBusinessImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/service/impl/OrderInfoMobileBusinessImpl.java index b5225893..4f346b85 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/service/impl/OrderInfoMobileBusinessImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/service/impl/OrderInfoMobileBusinessImpl.java @@ -9,22 +9,31 @@ import com.bonus.core.common.page.PageVO; import com.bonus.core.device.api.DeviceApi; import com.bonus.core.device.manage.dto.DeviceSearchDTO; import com.bonus.core.device.manage.model.DeviceInfo; +import com.bonus.core.menu.api.MenuDishesApi; +import com.bonus.core.menu.utils.NutritionEntity; import com.bonus.core.order.common.constants.CheckStateEnum; +import com.bonus.core.order.common.constants.DetailTypeEnum; +import com.bonus.core.order.common.constants.OrderTypeEnum; import com.bonus.core.order.common.dto.RequestHeaderDTO; +import com.bonus.core.order.common.model.OrderDelivery; import com.bonus.core.order.common.model.OrderRefund; import com.bonus.core.order.common.query.OrderQueryHelper; -import com.bonus.core.order.common.service.OrderDetailService; -import com.bonus.core.order.common.service.OrderInfoService; -import com.bonus.core.order.common.service.OrderRefundService; +import com.bonus.core.order.common.service.*; import com.bonus.core.order.common.vo.OrderIdDateVO; import com.bonus.core.order.custom.OrderCustomBusiness; import com.bonus.core.order.mobile.dto.OrderListMobileDTO; import com.bonus.core.order.mobile.service.OrderInfoMobileBusiness; import com.bonus.core.order.mobile.vo.OrderDetailMobileVO; +import com.bonus.core.order.mobile.vo.OrderInfoMobileVO; import com.bonus.core.order.mobile.vo.OrderListMobileVO; +import com.bonus.core.order.mobile.vo.OrderNutrientInfoVO; +import com.bonus.core.order.utils.LeNumUtil; import com.bonus.core.order.web.dto.OrderUserPermissionDTO; import com.bonus.core.order.weight.service.MacPlateidBindSerialService; import com.bonus.core.order.weight.model.MacPlateidBindSerial; +import com.bonus.core.order.weight.vo.RefundDetailStateVO; +import com.bonus.utils.AesEncryptUtil; +import com.bonus.core.menu.model.MenuDishesTypeModel; import com.github.pagehelper.page.PageMethod; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,6 +41,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.time.LocalDate; import java.util.*; import java.util.function.Function; @@ -45,6 +55,9 @@ public class OrderInfoMobileBusinessImpl implements OrderInfoMobileBusiness { protected OrderInfoService orderInfoService; @Lazy @Autowired + protected OrderDeliveryService orderDeliveryService; + @Lazy + @Autowired protected OrderDetailService orderDetailService; @Lazy @Autowired @@ -58,6 +71,15 @@ public class OrderInfoMobileBusinessImpl implements OrderInfoMobileBusiness { @Lazy @Autowired protected MacPlateidBindSerialService macPlateidBindSerialService; + @Lazy + @Autowired + protected AesEncryptUtil aesEncryptUtil; + @Lazy + @Autowired + protected MenuDishesApi menuDishesApi; + @Lazy + @Autowired + protected OrderRefundDetailService orderRefundDetailService; @Override public PageVO orderList(OrderListMobileDTO orderListDTO, RequestHeaderDTO headerDTO) { @@ -79,7 +101,8 @@ public class OrderInfoMobileBusinessImpl implements OrderInfoMobileBusiness { log.info("[移动端订单列表]查询订单详情:{}", orderList.size()); List orderIdList = (List)orderList.stream().map(OrderListMobileVO::getOrderId).collect(Collectors.toList()); List dateList = (List)orderList.stream().map(OrderListMobileVO::getOrderDate).collect(Collectors.toList()); - List orderDetailList = (List)this.orderDetailService.getOrderDetailList(orderIdList, dateList, (List)null).stream().map(OrderDetailMobileVO::of).collect(Collectors.toList()); + List orderDetailList = (List)this.orderDetailService.getOrderDetailList(orderIdList, dateList, (List)null) + .stream().map(OrderDetailMobileVO::of).collect(Collectors.toList()); this.orderDetailService.fillOrderDetailImage(orderDetailList); Map> orderDetailMap = (Map)orderDetailList.stream().collect(Collectors.groupingBy(OrderDetailMobileVO::getOrderId)); Map deviceMap = MapUtil.empty(); @@ -128,4 +151,104 @@ public class OrderInfoMobileBusinessImpl implements OrderInfoMobileBusiness { return k2; })); } + + @Override + public OrderInfoMobileVO orderInfo(Long orderId) { + OrderInfoMobileVO orderInfoVO = this.orderInfoService.getOrderInfoMobileByOrderId(orderId); + if (ObjectUtil.isNull(orderInfoVO)) { + return null; + } else { + List detailMobileList = (List)this.orderDetailService + .getOrderDetailList(orderId, orderInfoVO.getOrderDate()) + .stream().map(OrderDetailMobileVO::of).collect(Collectors.toList()); + orderInfoVO.setOrderDetailList(detailMobileList); + this.fillOrderInfoMobileDetail(orderInfoVO, detailMobileList); + this.fillOrderDetailMobileCheckState(orderInfoVO, detailMobileList); + this.fillWeightPlateNum(orderInfoVO); + orderInfoVO = this.orderCustomBusiness.mobile().didQueryOrderInfo(orderInfoVO); + return orderInfoVO; + } + } + + protected void fillOrderInfoMobileDetail(OrderInfoMobileVO orderInfoVO, List detailMobileList) { + log.info("[移动端订单详情]查询配送信息:{}", orderInfoVO.getOrderId()); + OrderDelivery deliveryInfo = this.orderDeliveryService.getByOrderId(orderInfoVO.getOrderId(), orderInfoVO.getOrderDate()); + if (ObjectUtil.isNotNull(deliveryInfo)) { + orderInfoVO.setConsigneeName(deliveryInfo.getConsigneeName()); + orderInfoVO.setConsigneeMobile(AesEncryptUtil.aesEncrypt(deliveryInfo.getConsigneeMobile())); + orderInfoVO.setConsigneeAddress(deliveryInfo.getConsigneeAddress()); + orderInfoVO.setDeliveryTime(deliveryInfo.getDeliveryTime()); + orderInfoVO.setDeliveryCode(deliveryInfo.getDeliveryCode()); + } + + if (OrderTypeEnum.BUFFET.getKey().equals(orderInfoVO.getOrderType()) && CollUtil.isNotEmpty(detailMobileList)) { + log.info("[移动端订单详情]查询营养信息:{}", orderInfoVO.getOrderId()); + Map dishesQuantityMap = (Map)detailMobileList.stream() + .collect(Collectors.toMap(OrderDetailMobileVO::getGoodsDishesId, OrderDetailMobileVO::totalGram, Double::sum)); + orderInfoVO.fillNutrientInfo(this.getNutrientInfo(dishesQuantityMap)); + } + + if (CharSequenceUtil.isNotEmpty(orderInfoVO.getMachineSn())) { + log.info("[移动端订单详情]查询设备信息:{}", orderInfoVO.getMachineSn()); + DeviceInfo deviceBySn = this.deviceApi.getBySn(orderInfoVO.getMachineSn()); + orderInfoVO.fillDeviceInfo(deviceBySn); + } + + log.info("[移动端订单详情]查询菜品分类名称:{}", orderInfoVO.getOrderId()); + List dishesIds = (List)detailMobileList.stream().filter((s) -> { + return DetailTypeEnum.isDishesCategory(s.getDetailType()); + }).map(OrderDetailMobileVO::getGoodsDishesId).filter(LeNumUtil::isValidId).collect(Collectors.toList()); + Map dishesTypeNameMap = (Map)this.menuDishesApi.getDishesTypeName(dishesIds).stream() + .collect(Collectors.toMap(MenuDishesTypeModel::getDishesId, MenuDishesTypeModel::getTypeName, (k1, k2) -> { + return k2; + })); + detailMobileList.forEach((s) -> { + s.setGoodsDishesTypeName((String)dishesTypeNameMap.get(s.getGoodsDishesId())); + }); + this.orderDetailService.fillOrderDetailImage(detailMobileList); + } + + public OrderNutrientInfoVO getNutrientInfo(Map dishesQuantityMap) { + NutritionEntity nutrientInfo = this.menuDishesApi.getNutrientInfo(dishesQuantityMap); + return OrderNutrientInfoVO.of(nutrientInfo); + } + + protected void fillOrderDetailMobileCheckState(OrderInfoMobileVO orderInfoVO, List detailMobileList) { + if (orderInfoVO != null && !CollUtil.isEmpty(detailMobileList)) { + log.info("[移动端订单详情]查询退款审核状态:{}", orderInfoVO.getOrderId()); + List refundDetailStateVOList = this.orderRefundDetailService.listRefundDetailState(CharSequenceUtil.isEmpty(orderInfoVO.getMacOrderId()) ? orderInfoVO.getOrderId() : null, CharSequenceUtil.isNotEmpty(orderInfoVO.getMacOrderId()) ? orderInfoVO.getMacOrderId() : null); + if (!CollUtil.isEmpty(refundDetailStateVOList)) { + Iterator var4 = detailMobileList.iterator(); + + while(var4.hasNext()) { + OrderDetailMobileVO orderDetailMobileVO = (OrderDetailMobileVO)var4.next(); + refundDetailStateVOList.stream().filter((s) -> { + return orderDetailMobileVO.getDetailId().equals(s.getMenuId()); + }).max(Comparator.comparing(RefundDetailStateVO::getOrderRefundId)).ifPresent((s) -> { + orderDetailMobileVO.setCheckState(s.getCheckState()); + }); + } + + refundDetailStateVOList.stream().filter((s) -> { + return orderInfoVO.getOrderId().equals(s.getOrderId()); + }).filter((s) -> { + return s.getFeeAmount().compareTo(BigDecimal.ZERO) > 0; + }).max(Comparator.comparing(RefundDetailStateVO::getOrderRefundId)).ifPresent((s) -> { + orderInfoVO.setCheckState(s.getCheckState()); + orderInfoVO.setRefundFeeAmount(s.getFeeAmount()); + }); + } + } + } + + public void fillWeightPlateNum(OrderInfoMobileVO orderInfoMobileVO) { + if (CharSequenceUtil.isNotBlank(orderInfoMobileVO.getPlateSerialNum())) { + List plates = this.macPlateidBindSerialService.queryBindByPlateSerialNumList(CollUtil.toList(new String[]{orderInfoMobileVO.getPlateSerialNum()})); + if (CollUtil.isNotEmpty(plates)) { + orderInfoMobileVO.setPlateNum(((MacPlateidBindSerial)plates.get(0)).getPlateId()); + } + } + + } + } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/vo/OrderInfoMobileVO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/vo/OrderInfoMobileVO.java new file mode 100644 index 00000000..5ef7533e --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/vo/OrderInfoMobileVO.java @@ -0,0 +1,585 @@ +package com.bonus.core.order.mobile.vo; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.NumberUtil; +import com.bonus.core.common.utils.SysUtil; +import com.bonus.core.device.manage.model.DeviceInfo; +import com.bonus.core.order.common.constants.OrderStateMixMobileEnum; +import com.bonus.core.order.common.model.OrderInfo; +import com.bonus.core.order.utils.LeNumUtil; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.List; + +@ApiModel("移动端订单详情VO") +public class OrderInfoMobileVO { + @ApiModelProperty("商家订单号") + private Long orderId; + @ApiModelProperty("设备订单号(设备下单时)") + private String macOrderId; + @ApiModelProperty("托盘物理号") + private String plateSerialNum; + @ApiModelProperty("托盘编号") + private String plateNum; + @ApiModelProperty("来源类型") + private Integer sourceType; + @ApiModelProperty("人员id") + private Long custId; + @ApiModelProperty("订单日期(区别于下单时间)") + private LocalDate orderDate; + @ApiModelProperty("食堂id") + private Long canteenId; + @ApiModelProperty("食堂名称") + private String canteenName; + @ApiModelProperty("档口id") + private Long stallId; + @ApiModelProperty("档口名称") + private String stallName; + @ApiModelProperty("餐次类型") + private String mealtimeType; + @ApiModelProperty("餐次名称") + private String mealtimeName; + @ApiModelProperty("设备序列号(设备下单时)") + private String machineSn; + @ApiModelProperty("设备编号(设备下单时)") + private String machineNum; + @ApiModelProperty("设备名称(设备下单时)") + private String machineName; + @ApiModelProperty("订单总金额 单位为分") + private BigDecimal payableAmount; + @ApiModelProperty("打折减免 单位为分") + private BigDecimal discountsAmount; + @ApiModelProperty("餐券抵扣金额 单位为分") + private BigDecimal couponAmount; + @ApiModelProperty("配送费 单位为分") + private BigDecimal deliveryAmount; + @ApiModelProperty("包装费") + private BigDecimal packingAmount; + @ApiModelProperty("送达时间") + private LocalDateTime deliveryTime; + @ApiModelProperty("实际付款金额 单位为分") + private BigDecimal realAmount; + @ApiModelProperty("实际应付款金额 单位为分") + private BigDecimal needPayAmount; + @ApiModelProperty("菜品实际应付款金额合计 单位为分") + private BigDecimal calcTotalAmount; + @ApiModelProperty("已退款金额") + private BigDecimal refundAmount; + @ApiModelProperty("下单时间") + private LocalDateTime orderTime; + @ApiModelProperty("支付时间") + private LocalDateTime payTime; + @ApiModelProperty("支付方式") + private Integer payType; + @ApiModelProperty("支付状态") + private Integer payState; + @ApiModelProperty("扣款类型 1 下单扣款 2 核销扣款") + private Integer deductionType; + @ApiModelProperty("订单类型") + private Integer orderType; + private Integer dishesState; + @ApiModelProperty("订单状态 1 已下单 2 已完成 3 已取消") + private Integer orderState; + private Integer orderRefundState; + @ApiModelProperty("审核状态 1 待审核 2 审核通过 3 审核失败") + private Integer checkState; + @ApiModelProperty("退款手续费") + private BigDecimal refundFeeAmount; + @ApiModelProperty("订单备注") + private String remark; + @ApiModelProperty("配送方式") + private Integer deliveryType; + @ApiModelProperty("收货人姓名") + private String consigneeName; + @ApiModelProperty("收货人手机号") + private String consigneeMobile; + @ApiModelProperty("收货人地址") + private String consigneeAddress; + @ApiModelProperty("配送码/取餐码") + private String deliveryCode; + @ApiModelProperty("订单图片") + private String imgUrl; + @ApiModelProperty("热量(千卡)") + private Double caloriesord; + @ApiModelProperty("蛋白质(g)") + private Double proteinord; + @ApiModelProperty("脂肪(g)") + private Double fatord; + @ApiModelProperty("纤维(g)") + private Double dietaryFiberord; + @ApiModelProperty("碳水物(g)") + private Double carbohydrateord; + @ApiModelProperty("胆固醇(mg)") + private Double cholesterolord; + @ApiModelProperty("流水号") + private String mealCode; + private Integer commentState; + private Integer orderStateMixMobile; + @ApiModelProperty("订单明细list") + private List orderDetailList; + + public static OrderInfoMobileVO of(OrderInfo orderInfo) { + return (OrderInfoMobileVO)BeanUtil.copyProperties(orderInfo, OrderInfoMobileVO.class, new String[0]); + } + + public String getImgUrl() { + return SysUtil.getCutFileUrl(this.imgUrl); + } + + public BigDecimal getNeedPayAmount() { + return NumberUtil.sub(this.payableAmount, this.discountsAmount); + } + + public BigDecimal getCalcTotalAmount() { + return LeNumUtil.sumField(this.orderDetailList, OrderDetailMobileVO::getCalcTotalAmount); + } + + public Integer getOrderStateMixMobile() { + return OrderStateMixMobileEnum.mixStateBy(this.orderState, this.payState, this.orderRefundState, this.dishesState); + } + + public void fillDeviceInfo(DeviceInfo deviceInfo) { + if (deviceInfo != null) { + this.machineSn = deviceInfo.getDeviceSn(); + this.machineNum = deviceInfo.getDeviceNum(); + this.machineName = deviceInfo.getDeviceName(); + } + + } + + public void fillNutrientInfo(OrderNutrientInfoVO nutrientInfo) { + if (nutrientInfo != null) { + this.caloriesord = nutrientInfo.getCaloriesord(); + this.proteinord = nutrientInfo.getProteinord(); + this.fatord = nutrientInfo.getFatord(); + this.dietaryFiberord = nutrientInfo.getDietaryFiberord(); + this.carbohydrateord = nutrientInfo.getCarbohydrateord(); + this.cholesterolord = nutrientInfo.getCholesterolord(); + } + + } + + public OrderInfoMobileVO() { + this.refundFeeAmount = BigDecimal.ZERO; + } + + public Long getOrderId() { + return this.orderId; + } + + public String getMacOrderId() { + return this.macOrderId; + } + + public String getPlateSerialNum() { + return this.plateSerialNum; + } + + public String getPlateNum() { + return this.plateNum; + } + + public Integer getSourceType() { + return this.sourceType; + } + + public Long getCustId() { + return this.custId; + } + + public LocalDate getOrderDate() { + return this.orderDate; + } + + public Long getCanteenId() { + return this.canteenId; + } + + public String getCanteenName() { + return this.canteenName; + } + + public Long getStallId() { + return this.stallId; + } + + public String getStallName() { + return this.stallName; + } + + public String getMealtimeType() { + return this.mealtimeType; + } + + public String getMealtimeName() { + return this.mealtimeName; + } + + public String getMachineSn() { + return this.machineSn; + } + + public String getMachineNum() { + return this.machineNum; + } + + public String getMachineName() { + return this.machineName; + } + + public BigDecimal getPayableAmount() { + return this.payableAmount; + } + + public BigDecimal getDiscountsAmount() { + return this.discountsAmount; + } + + public BigDecimal getCouponAmount() { + return this.couponAmount; + } + + public BigDecimal getDeliveryAmount() { + return this.deliveryAmount; + } + + public BigDecimal getPackingAmount() { + return this.packingAmount; + } + + public LocalDateTime getDeliveryTime() { + return this.deliveryTime; + } + + public BigDecimal getRealAmount() { + return this.realAmount; + } + + public BigDecimal getRefundAmount() { + return this.refundAmount; + } + + public LocalDateTime getOrderTime() { + return this.orderTime; + } + + public LocalDateTime getPayTime() { + return this.payTime; + } + + public Integer getPayType() { + return this.payType; + } + + public Integer getPayState() { + return this.payState; + } + + public Integer getDeductionType() { + return this.deductionType; + } + + public Integer getOrderType() { + return this.orderType; + } + + public Integer getDishesState() { + return this.dishesState; + } + + public Integer getOrderState() { + return this.orderState; + } + + public Integer getOrderRefundState() { + return this.orderRefundState; + } + + public Integer getCheckState() { + return this.checkState; + } + + public BigDecimal getRefundFeeAmount() { + return this.refundFeeAmount; + } + + public String getRemark() { + return this.remark; + } + + public Integer getDeliveryType() { + return this.deliveryType; + } + + public String getConsigneeName() { + return this.consigneeName; + } + + public String getConsigneeMobile() { + return this.consigneeMobile; + } + + public String getConsigneeAddress() { + return this.consigneeAddress; + } + + public String getDeliveryCode() { + return this.deliveryCode; + } + + public Double getCaloriesord() { + return this.caloriesord; + } + + public Double getProteinord() { + return this.proteinord; + } + + public Double getFatord() { + return this.fatord; + } + + public Double getDietaryFiberord() { + return this.dietaryFiberord; + } + + public Double getCarbohydrateord() { + return this.carbohydrateord; + } + + public Double getCholesterolord() { + return this.cholesterolord; + } + + public String getMealCode() { + return this.mealCode; + } + + public Integer getCommentState() { + return this.commentState; + } + + public List getOrderDetailList() { + return this.orderDetailList; + } + + public void setOrderId(final Long orderId) { + this.orderId = orderId; + } + + public void setMacOrderId(final String macOrderId) { + this.macOrderId = macOrderId; + } + + public void setPlateSerialNum(final String plateSerialNum) { + this.plateSerialNum = plateSerialNum; + } + + public void setPlateNum(final String plateNum) { + this.plateNum = plateNum; + } + + public void setSourceType(final Integer sourceType) { + this.sourceType = sourceType; + } + + public void setCustId(final Long custId) { + this.custId = custId; + } + + public void setOrderDate(final LocalDate orderDate) { + this.orderDate = orderDate; + } + + public void setCanteenId(final Long canteenId) { + this.canteenId = canteenId; + } + + public void setCanteenName(final String canteenName) { + this.canteenName = canteenName; + } + + public void setStallId(final Long stallId) { + this.stallId = stallId; + } + + public void setStallName(final String stallName) { + this.stallName = stallName; + } + + public void setMealtimeType(final String mealtimeType) { + this.mealtimeType = mealtimeType; + } + + public void setMealtimeName(final String mealtimeName) { + this.mealtimeName = mealtimeName; + } + + public void setMachineSn(final String machineSn) { + this.machineSn = machineSn; + } + + public void setMachineNum(final String machineNum) { + this.machineNum = machineNum; + } + + public void setMachineName(final String machineName) { + this.machineName = machineName; + } + + public void setPayableAmount(final BigDecimal payableAmount) { + this.payableAmount = payableAmount; + } + + public void setDiscountsAmount(final BigDecimal discountsAmount) { + this.discountsAmount = discountsAmount; + } + + public void setCouponAmount(final BigDecimal couponAmount) { + this.couponAmount = couponAmount; + } + + public void setDeliveryAmount(final BigDecimal deliveryAmount) { + this.deliveryAmount = deliveryAmount; + } + + public void setPackingAmount(final BigDecimal packingAmount) { + this.packingAmount = packingAmount; + } + + public void setDeliveryTime(final LocalDateTime deliveryTime) { + this.deliveryTime = deliveryTime; + } + + public void setRealAmount(final BigDecimal realAmount) { + this.realAmount = realAmount; + } + + public void setNeedPayAmount(final BigDecimal needPayAmount) { + this.needPayAmount = needPayAmount; + } + + public void setCalcTotalAmount(final BigDecimal calcTotalAmount) { + this.calcTotalAmount = calcTotalAmount; + } + + public void setRefundAmount(final BigDecimal refundAmount) { + this.refundAmount = refundAmount; + } + + public void setOrderTime(final LocalDateTime orderTime) { + this.orderTime = orderTime; + } + + public void setPayTime(final LocalDateTime payTime) { + this.payTime = payTime; + } + + public void setPayType(final Integer payType) { + this.payType = payType; + } + + public void setPayState(final Integer payState) { + this.payState = payState; + } + + public void setDeductionType(final Integer deductionType) { + this.deductionType = deductionType; + } + + public void setOrderType(final Integer orderType) { + this.orderType = orderType; + } + + public void setDishesState(final Integer dishesState) { + this.dishesState = dishesState; + } + + public void setOrderState(final Integer orderState) { + this.orderState = orderState; + } + + public void setOrderRefundState(final Integer orderRefundState) { + this.orderRefundState = orderRefundState; + } + + public void setCheckState(final Integer checkState) { + this.checkState = checkState; + } + + public void setRefundFeeAmount(final BigDecimal refundFeeAmount) { + this.refundFeeAmount = refundFeeAmount; + } + + public void setRemark(final String remark) { + this.remark = remark; + } + + public void setDeliveryType(final Integer deliveryType) { + this.deliveryType = deliveryType; + } + + public void setConsigneeName(final String consigneeName) { + this.consigneeName = consigneeName; + } + + public void setConsigneeMobile(final String consigneeMobile) { + this.consigneeMobile = consigneeMobile; + } + + public void setConsigneeAddress(final String consigneeAddress) { + this.consigneeAddress = consigneeAddress; + } + + public void setDeliveryCode(final String deliveryCode) { + this.deliveryCode = deliveryCode; + } + + public void setImgUrl(final String imgUrl) { + this.imgUrl = imgUrl; + } + + public void setCaloriesord(final Double caloriesord) { + this.caloriesord = caloriesord; + } + + public void setProteinord(final Double proteinord) { + this.proteinord = proteinord; + } + + public void setFatord(final Double fatord) { + this.fatord = fatord; + } + + public void setDietaryFiberord(final Double dietaryFiberord) { + this.dietaryFiberord = dietaryFiberord; + } + + public void setCarbohydrateord(final Double carbohydrateord) { + this.carbohydrateord = carbohydrateord; + } + + public void setCholesterolord(final Double cholesterolord) { + this.cholesterolord = cholesterolord; + } + + public void setMealCode(final String mealCode) { + this.mealCode = mealCode; + } + + public void setCommentState(final Integer commentState) { + this.commentState = commentState; + } + + public void setOrderStateMixMobile(final Integer orderStateMixMobile) { + this.orderStateMixMobile = orderStateMixMobile; + } + + public void setOrderDetailList(final List orderDetailList) { + this.orderDetailList = orderDetailList; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/vo/OrderNutrientInfoVO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/vo/OrderNutrientInfoVO.java new file mode 100644 index 00000000..6c78d1f2 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/vo/OrderNutrientInfoVO.java @@ -0,0 +1,89 @@ +package com.bonus.core.order.mobile.vo; + +import com.bonus.core.menu.utils.NutritionEntity; +import io.swagger.annotations.ApiModelProperty; + +public class OrderNutrientInfoVO { + @ApiModelProperty("热量(千卡)") + private Double caloriesord = 0.0; + @ApiModelProperty("蛋白质(g)") + private Double proteinord = 0.0; + @ApiModelProperty("脂肪(g)") + private Double fatord = 0.0; + @ApiModelProperty("纤维(g)") + private Double dietaryFiberord = 0.0; + @ApiModelProperty("碳水物(g)") + private Double carbohydrateord = 0.0; + @ApiModelProperty("胆固醇(mg)") + private Double cholesterolord = 0.0; + @ApiModelProperty("钠(mg)") + private Double sodium = 0.0; + + public static OrderNutrientInfoVO of(NutritionEntity nutrientInfo) { + OrderNutrientInfoVO vo = new OrderNutrientInfoVO(); + vo.setCaloriesord(nutrientInfo.getCalories()); + vo.setProteinord(nutrientInfo.getProtein()); + vo.setFatord(nutrientInfo.getFat()); + vo.setDietaryFiberord(nutrientInfo.getDietaryFiber()); + vo.setCarbohydrateord(nutrientInfo.getCarbohydrate()); + vo.setCholesterolord(nutrientInfo.getCholesterol()); + vo.setSodium(nutrientInfo.getSodium()); + return vo; + } + + public Double getCaloriesord() { + return this.caloriesord; + } + + public Double getProteinord() { + return this.proteinord; + } + + public Double getFatord() { + return this.fatord; + } + + public Double getDietaryFiberord() { + return this.dietaryFiberord; + } + + public Double getCarbohydrateord() { + return this.carbohydrateord; + } + + public Double getCholesterolord() { + return this.cholesterolord; + } + + public Double getSodium() { + return this.sodium; + } + + public void setCaloriesord(final Double caloriesord) { + this.caloriesord = caloriesord; + } + + public void setProteinord(final Double proteinord) { + this.proteinord = proteinord; + } + + public void setFatord(final Double fatord) { + this.fatord = fatord; + } + + public void setDietaryFiberord(final Double dietaryFiberord) { + this.dietaryFiberord = dietaryFiberord; + } + + public void setCarbohydrateord(final Double carbohydrateord) { + this.carbohydrateord = carbohydrateord; + } + + public void setCholesterolord(final Double cholesterolord) { + this.cholesterolord = cholesterolord; + } + + public void setSodium(final Double sodium) { + this.sodium = sodium; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/utils/LeNumUtil.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/utils/LeNumUtil.java index 51379431..4ee3d1c7 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/utils/LeNumUtil.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/utils/LeNumUtil.java @@ -1,11 +1,16 @@ package com.bonus.core.order.utils; +import cn.hutool.core.collection.CollUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; +import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.ZoneId; +import java.util.Collection; +import java.util.Objects; +import java.util.function.Function; @Component public class LeNumUtil { @@ -106,14 +111,14 @@ public class LeNumUtil { // return fieldSet.size() == 1 ? CollUtil.getFirst(fieldSet) : defaultValue; // } // } -// -// public static BigDecimal sumField(Collection dataList, Function func) { -// return CollUtil.isEmpty(dataList) ? BigDecimal.ZERO : (BigDecimal)dataList.stream().map(func).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); -// } -// -// public static int sumFieldInt(Collection dataList, Function func) { -// return CollUtil.isEmpty(dataList) ? 0 : (Integer)dataList.stream().map(func).filter(Objects::nonNull).reduce(0, Integer::sum); -// } + + public static BigDecimal sumField(Collection dataList, Function func) { + return CollUtil.isEmpty(dataList) ? BigDecimal.ZERO : (BigDecimal)dataList.stream().map(func).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); + } + + public static int sumFieldInt(Collection dataList, Function func) { + return CollUtil.isEmpty(dataList) ? 0 : (Integer)dataList.stream().map(func).filter(Objects::nonNull).reduce(0, Integer::sum); + } // // public static BigDecimal sumField(Collection dataList, Predicate filter, Function func) { // return CollUtil.isEmpty(dataList) ? BigDecimal.ZERO : (BigDecimal)dataList.stream().filter(filter).map(func).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/weight/vo/RefundDetailStateVO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/weight/vo/RefundDetailStateVO.java new file mode 100644 index 00000000..60a971da --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/weight/vo/RefundDetailStateVO.java @@ -0,0 +1,103 @@ +package com.bonus.core.order.weight.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiModelProperty; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@Api("纠错退款VO") +public class RefundDetailStateVO { + @ApiModelProperty("退款主键ID") + private Long orderRefundId; + @DateTimeFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @ApiModelProperty("申请时间") + private LocalDateTime applyTime; + @ApiModelProperty("申请理由/原因") + private String applyReason; + @ApiModelProperty("订单号") + private Long orderId; + @ApiModelProperty("审核状态 1 待审核 2 审核通过 3 拒绝") + private Integer checkState; + @ApiModelProperty("退款手续费 分") + private BigDecimal feeAmount; + @ApiModelProperty("实际退款金额 分") + private BigDecimal realRefundAmount; + @ApiModelProperty("订单下菜品主键ID") + private Long menuId; + + public Long getOrderRefundId() { + return this.orderRefundId; + } + + public LocalDateTime getApplyTime() { + return this.applyTime; + } + + public String getApplyReason() { + return this.applyReason; + } + + public Long getOrderId() { + return this.orderId; + } + + public Integer getCheckState() { + return this.checkState; + } + + public BigDecimal getFeeAmount() { + return this.feeAmount; + } + + public BigDecimal getRealRefundAmount() { + return this.realRefundAmount; + } + + public Long getMenuId() { + return this.menuId; + } + + public void setOrderRefundId(final Long orderRefundId) { + this.orderRefundId = orderRefundId; + } + + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + public void setApplyTime(final LocalDateTime applyTime) { + this.applyTime = applyTime; + } + + public void setApplyReason(final String applyReason) { + this.applyReason = applyReason; + } + + public void setOrderId(final Long orderId) { + this.orderId = orderId; + } + + public void setCheckState(final Integer checkState) { + this.checkState = checkState; + } + + public void setFeeAmount(final BigDecimal feeAmount) { + this.feeAmount = feeAmount; + } + + public void setRealRefundAmount(final BigDecimal realRefundAmount) { + this.realRefundAmount = realRefundAmount; + } + + public void setMenuId(final Long menuId) { + this.menuId = menuId; + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuDishesMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuDishesMapper.xml new file mode 100644 index 00000000..dbb91d92 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuDishesMapper.xml @@ -0,0 +1,1556 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/order/OrderRefundDetailMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/order/OrderRefundDetailMapper.xml new file mode 100644 index 00000000..5cb363ea --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/order/OrderRefundDetailMapper.xml @@ -0,0 +1,29 @@ + + + + + + +