From 9afd7c55ae087f1dcf03010c98542eb02d750435 Mon Sep 17 00:00:00 2001 From: skjia <106962133@qq.com> Date: Mon, 10 Feb 2025 18:07:50 +0800 Subject: [PATCH] =?UTF-8?q?jsk=20--=E9=A2=84=E8=AE=A2=E9=A4=90=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20=E5=8F=8A=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bonus-modules/bonus-smart-canteen/pom.xml | 5 + .../controller/AllocCanteenController.java | 15 +- .../holiday/config/RestTemplateConfig.java | 17 + .../service/impl/MktHolidayServiceImpl.java | 4 +- .../core/common/constant/LeRetCodeEnum.java | 188 ++++++++ .../bonus/core/common/redis/RedisUtil.java | 10 + .../controller/AppletRecipeV2Controller.java | 12 +- .../menu/dto/AppletReserveCanteenDTO.java | 2 +- .../core/menu/dto/AppletReserveRecipeDTO.java | 2 +- .../service/impl/MenuRecipeServiceImpl.java | 4 +- .../common/constants/OrderCacheConstants.java | 95 ++++ .../order/common/constants/OrderTips.java | 54 +++ .../service/OrderShoppingCartService.java | 10 + .../impl/OrderShoppingCartServiceImpl.java | 38 +- .../custom/OrderCustomMobileBusiness.java | 35 +- .../controller/OrderInfoMobileController.java | 40 +- .../mobile/dto/OrderShoppingCartAddDTO.java | 342 ++++++++++++++ .../mobile/dto/OrderShoppingCartClearDTO.java | 89 ++++ .../dto/OrderShoppingCartUpdateDTO.java | 115 +++++ .../mobile/service/ShoppingCartBusiness.java | 10 + .../impl/ShoppingCartBusinessImpl.java | 136 +++++- .../vo/OrderShoppingCartAddResultVO.java | 419 ++++++++++++++++++ .../mapper/holiday}/MktHolidayMapper.xml | 0 23 files changed, 1583 insertions(+), 59 deletions(-) create mode 100644 bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/holiday/config/RestTemplateConfig.java create mode 100644 bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/constant/LeRetCodeEnum.java create mode 100644 bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/constants/OrderCacheConstants.java create mode 100644 bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/constants/OrderTips.java create mode 100644 bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/dto/OrderShoppingCartAddDTO.java create mode 100644 bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/dto/OrderShoppingCartClearDTO.java create mode 100644 bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/dto/OrderShoppingCartUpdateDTO.java create mode 100644 bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/vo/OrderShoppingCartAddResultVO.java rename bonus-modules/bonus-smart-canteen/src/main/{java/com/bonus/core/allocation/holiday/mapper => resources/mapper/holiday}/MktHolidayMapper.xml (100%) diff --git a/bonus-modules/bonus-smart-canteen/pom.xml b/bonus-modules/bonus-smart-canteen/pom.xml index 9043f3ca..3ab48522 100644 --- a/bonus-modules/bonus-smart-canteen/pom.xml +++ b/bonus-modules/bonus-smart-canteen/pom.xml @@ -147,6 +147,11 @@ hutool-all 5.8.11 + + org.redisson + redisson + 3.43.0 + diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/controller/AllocCanteenController.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/controller/AllocCanteenController.java index 10afa055..d57e8787 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/controller/AllocCanteenController.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/controller/AllocCanteenController.java @@ -11,12 +11,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.validation.Valid; import java.time.LocalDate; import java.util.List; @@ -49,9 +47,14 @@ public class AllocCanteenController { } } + /** + * @author jsk + * @param bean + * @return + */ @ApiOperation("移动端-查询预订日期列表") @PostMapping({"/list-reserve-date"}) - public List listReserveDate(@RequestBody AllocMobileCanteenQueryDTO bean) { - return this.allocStallService.listReserveDate(bean); + public AjaxResult listReserveDate(@RequestBody AllocMobileCanteenQueryDTO bean) { + return AjaxResult.success(this.allocStallService.listReserveDate(bean)); } } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/holiday/config/RestTemplateConfig.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/holiday/config/RestTemplateConfig.java new file mode 100644 index 00000000..b316969b --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/holiday/config/RestTemplateConfig.java @@ -0,0 +1,17 @@ +package com.bonus.core.allocation.holiday.config; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestTemplate; + +@Configuration +public class RestTemplateConfig { + private static final Logger log = LoggerFactory.getLogger(RestTemplateConfig.class); + + @Bean({"holidayRest"}) + public RestTemplate createRest() { + return new RestTemplate(); + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/holiday/service/impl/MktHolidayServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/holiday/service/impl/MktHolidayServiceImpl.java index 09b5a84f..1e6477bf 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/holiday/service/impl/MktHolidayServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/holiday/service/impl/MktHolidayServiceImpl.java @@ -9,7 +9,6 @@ import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.parser.Feature; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -25,7 +24,6 @@ import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; import javax.annotation.Resource; -import java.lang.reflect.Type; import java.time.*; import java.util.*; @@ -64,7 +62,7 @@ public class MktHolidayServiceImpl extends ServiceImpl>((Type) this) { + dateList = (List)JSON.parseObject(deductionConfJsonStr, new TypeReference>() { }, new Feature[0]); } catch (Exception var5) { log.error("[节假日]读取节假日缓存失败," + var5.getMessage(), var5); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/constant/LeRetCodeEnum.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/constant/LeRetCodeEnum.java new file mode 100644 index 00000000..d3ad7592 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/constant/LeRetCodeEnum.java @@ -0,0 +1,188 @@ +package com.bonus.core.common.constant; + +public enum LeRetCodeEnum { + SUCC(10000, "成功"), + SUCC_MAC_ORD(10001, "设备单号重复,特殊成功标识"), + FAIL(40004, "失败"), + PAY_BALANCE_NO_ENOUGH(50001, "余额不足"), + PAY_PERSONAL_NO_EXIT(50002, "人员不存在"), + PAY_CARD_NO_EXIT(50003, "卡号不正确"), + PAY_CARD_STATE_ABNORMAL(50004, "卡片异常"), + PAY_ACC_STATE_ABNORMAL(50005, "账户异常"), + PAY_MACHINE_NO_EXIT(50006, "设备不存在"), + PAY_MACHINE_NO_ALLOW(50007, "不允许当前设备消费"), + PAY_PERSONAL_NO_ALLOWTYPE(50008, "当前人员未设置类别消费"), + PAY_TIME_NO_EXIT(50009, "时间段错误"), + PAY_TIME_QUOTA_LIMIT(50010, "超出限额限次"), + PAY_SELECT_ORD_NO_EXIT(50011, "订单号不存在"), + PAY_QRCODE_ORD_ERROR(50012, "扫码支付失败"), + PAY_QRCODE_ING(50013, "扫码支付中"), + PAY_TYPE_NO_OPEN(50014, "支付方式未开通"), + PAY_ORD_ID_EXIT(50015, "该订单已存在"), + PAY_RECHARGE_NO_EXIT(50016, "充值记录不存在"), + PAY_THIRD_PAY_FAIL(50017, "第三方支付失败"), + PAY_QR_ILLEGAL(50018, "非法二维码"), + PAY_QR_NOT_PAY(50019, "费支付二维码"), + PAY_COUPON_UNIVERSAL_DISABLED(50020, "通用券不可用"), + PAY_ORD_LOSE(50021, "该订单已失效"), + PAY_ORD_CANCEL(50022, "该订单已取消"), + PAY_ORD_ING(50023, "订单进行中"), + PAY_ORD_END(50024, "该订单已完结"), + PAY_ORD_EXISTS_UN_PAY(50025, "存在未支付订单"), + PAY_ORD_LESS_THAN_DELIVERY_MIN_AMOUNT(50026, "未达到起送金额"), + CORE_PARAM_ERROR(50501, "上送参数错误"), + BAS_CONF_NOT_SET(50502, "基础配置没有设置"), + CORE_DATE_START_GREATER_END(50503, "开始时间大于结束时间"), + BAS_INTERVAL_NO_EXIT(50504, "餐次信息不存在"), + CORE_IMPORT_FORMAT_ERR(50601, "导入格式错误"), + CORE_IMPORT_EMPTY(50602, "导入对象为空"), + CORE_IMPORT_FIELD_EMPTY(50603, "导入字段为空"), + ACC_CRAD_NUM_EXIST(51001, "餐卡卡序列号已经存在"), + ACC_STATE_EXCEPTION(51002, "账户状态异常"), + ACC_CARD_NUM_MAX_LIMIT(51003, "卡号已经达到最大限制"), + ACC_DATA_ALREADY_EXIST(51004, "数据已经存在"), + ACC_SUBRULE_ALREADY_EXIST(51005, "存在其他类型的补贴规则"), + RECHARGE_NO_AUTH(51006, "充值没有权限"), + ACC_INFO_NO_EXIT(51007, "账户信息不存在"), + RECHARGE_NO_EXIST(51008, "充值记录不存在"), + REFUND_AMOUNT_GREATER(51009, "退款金额大于对应金额"), + PAY_FAIL_REFUSE_REFUND(51010, "未支付成功,不允许退款"), + CUST_CLOSE_REFUSE_REFUND(51011, "人员注销,不允许退款"), + NOT_REPEAT_REFUND(51012, "不允许重复退款"), + ACC_BAL_NOT_ENOUGH(51013, "账户余额不足"), + BAS_TABLE_IN_USE(51501, "餐桌正在使用中"), + BAS_TABLE_NOT_IN_USE(51502, "餐桌非使用中"), + BAS_TABLE_NOT_BIND_ORD(51503, "餐桌没有绑定订单"), + BAS_CANTEEN_NO_EXIT(51504, "食堂信息不存在"), + BAS_NO_SYS_CARDINFO(51505, "系统卡信息为空"), + CUST_PERSONAL_NO_EXIT(52001, "人员不存在"), + CUST_CASUAL_NO_BIND(52002, "临时人员没有绑定"), + CUSTINFO_ALREADY_EXISTS(52003, "人员信息已经存在"), + CUST_ROOT_DEL_NOT_ALLOW(52004, "根节点不允许删除"), + CUST_EXIST_RELAT(52005, "存在人员关联"), + CUST_PHOTO_FACE_FAIL(52006, "生成失败"), + CUST_STATE_EXCEPTION(52007, "人员状态异常"), + CUST_LIMIT_ID_MAX_LIMIT(52008, "人员限制id已经达到最大限制"), + CUST_PSN_TYPE_OUT_RANGE(52009, "人员类别超出范围"), + CUST_CASUAL_UNABLE_BIND(52010, "临时人员无法绑定"), + CUST_IMPORT_FORMAT_ERR(52011, "导入字段格式错误"), + MAC_NO_HEADER_SN(53001, "缺少SN"), + MAC_APP_VERSION_NOEXIT(53002, "未找到更新包"), + MAC_APP_VERSION_NOTUP(53003, "APP已是最新版本"), + MAC_IS_NOT_EMPTY_MEALS_COUNTER(53004, "取餐柜不是空的"), + MAC_NO_PARAM_LIST(53005, "list参数为空"), + MAC_NO_PARAM_ENTITY(53006, "实体参数为空"), + MAC_NO_PARAM_VARIABLE(53007, "变量参数为空"), + MAC_ERR_SQL_DATE(53008, "数据库数据错误"), + MAC_ERR_BIND(53009, "绑定餐盘失败"), + MAC_MACHINE_NO_EXIT(53010, "设备资料不存在"), + MAC_MACHINE_NO_BIND_CANTEEN(53011, "该设备没有绑定食堂"), + MENU_NO_RECIPE(53501, "传入菜谱不存在"), + MENU_NO_RECIPE_TYPE(53502, "传入菜谱类型不存在"), + MENU_REPEAT_NAME(53503, "名称重复"), + MENU_IS_USED_DISHES_COOK(53504, "菜品灶类已使用"), + MENU_REPEAT_DISHES_LABEL(53505, "菜品标签名称重复"), + MENU_IS_USED_DISHES_LABEL(53506, "菜品标签已使用"), + MENU_EXCEED_MAX_LIMIT(53507, "超出数量限制"), + MENU_NO_MATERIAL(53508, "菜品没有原材料"), + MENU_IS_USED_DISHES(53509, "菜品已使用"), + MENU_NOT_EXIST_DISHES(53510, "菜品不存在"), + MENU_NOT_EXIST_RECIPE_DETAIL(53511, "菜谱详情不存在"), + MENU_NOT_EXIST_RECIPE(53512, "菜谱不存在"), + MENU_REPEAT_DISHES_TASTE(53513, "菜品口味名称重复"), + MENU_IS_USED_DISHES_TASTE(53514, "菜品口味已使用"), + MENU_REPEAT_DISHES_TYPE(53515, "菜品类型名称重复"), + MENU_IS_USED_DISHES_TYPE(53516, "菜品类型已使用"), + MENU_IS_USED_MATERIAL(53517, "菜品原料已使用"), + MENU_NO_DISHES(53518, "没有菜品"), + MENU_NOT_EXIST_PACKAGE_MEAL(53519, "套餐不存在"), + MENU_NO_PROPORTION(53520, "没有占比"), + MENU_IS_USED_PRODUCT(53521, "商品已使用"), + MENU_NOT_EXIST_PRODUCT(53522, "商品不存在"), + MENU_ERR_RECIPE_TYPE(53523, "菜谱类型错误"), + MENU_ERR_RECIPE_DEFAULT_LIMIT(53524, "默认菜谱数量错误"), + MENU_REPEAT_DISHES(53525, "菜品重复"), + MENU_REPEAT_PRODUCT(53526, "商品重复"), + MENU_REPEAT_PACKAGE_MEAL(53527, "套餐重复"), + MENU_NO_APPLY_DATE(53528, "没有启用日期"), + MENU_NO_PARAM_LIST(53529, "list参数为空"), + MENU_NO_PARAM_ENTITY(53530, "实体参数为空"), + MENU_NO_PARAM_VARIABLE(53531, "变量参数为空"), + MENU_ERR_SQL_DATE(53532, "数据库数据错误"), + MENU_EXCEED_RESTRICT_NUM(53533, "超出个人限购数量"), + MENU_EXCEED_SURPLUS_NUM(53534, "库存不足或者超出个人限购数量"), + MENU_NOT_EXIST_TIME_INTERVAL(53535, "餐次不存在"), + MENU_REPEAT_RECIPE(53536, "菜谱重复"), + MENU_NOT_IN_TIME_INTERVAL(53537, "不在时间段内"), + MENU_REPEAT_DISHES_COOK(53538, "名称重复"), + MENU_IS_USED_DISHES_CLASSIFY(53539, "菜品分类已使用"), + MENU_IS_USED_DISHES_EFFECT(53540, "菜品功效已使用"), + MENU_IS_USED_DISHES_STYLE(53541, "菜系已使用"), + MENU_IS_USED_DISHES_SUIT(53542, "适宜人群已使用"), + MERCHANT_NOT_REGISTER(54001, "商家未注册"), + MKT_ERROR_PARAM(54501, "入参错误"), + MGR_REPEAT_ROLE_NAME(57001, "角色名称重复"), + MGR_REPEAT_USER_NAME(57002, "用户名称重复"), + DRP_NO_SUPPLIER_ID(57501, "传入的供应商id为空"), + DRP_NO_WAREHOUSE_ID(57502, "传入的仓库id为空"), + DRP_NO_UNIT_ID(57503, "传入的计量单位id为空"), + DRP_REPEAT_UNIT(53504, "计量单位名称重复"), + DRP_REPEAT_HOUSE_MATERIAL(53505, "仓库原料重复"), + DRP_EXIST_MATERIAL_NUM(53506, "库存不为0"), + DRP_NOT_EXIST_HOUSE_MATERIAL(53507, "库存配置不存在"), + DRP_IS_USED_HOUSE_MATERIAL(53508, "库存配置已使用"), + DRP_ERR_SQL_DATE(53509, "数据库数据错误"), + DRP_NOT_EXIST_INTO_INVENTORY(53521, "入库记录不存在"), + DRP_ALREADY_INTO_INVENTORY(53511, "已入库"), + DRP_INVENTORY_DEFICIENCY(53512, "原料库存不足"), + DRP_NOT_EXIST_OUT_INVENTORY(53513, "出库记录不存在"), + DRP_ALREADY_OUT_INVENTORY(53514, "已入库"), + DRP_NOT_EXIST_PURCHASE_ORDER(53515, "采购订单不存在"), + DRP_NOT_EXIST_PURCHASE_PLAN(53516, "采购计划不存在"), + DRP_NOT_EXIST_ISSUE(53517, "采购计划不存在"), + DRP_REPEAT_MATERIAL_CATEGORY(53518, "原料类别名称重复"), + DRP_NOT_EXIST_CHECK_INVENTORY(53519, "盘点记录不存在"), + DRP_ALREADY_CHECK_INVENTORY(53520, "已盘点"), + ORD_TRADE_ASSEM_ERR(55001, "组装交易明细数据错误"), + ORD_REFUND_FAIL(55002, "订单退款失败"), + ORD_INFO_NO_EXIT(55003, "订单信息不存在"), + ORD_UNABLE_SUBSCRIBE(55004, "不能预订订单"), + ORD_STATE_ERR(55005, "订单状态错误"), + PRE_ORDER_FAIL(56501, "预下单失败"), + PRE_API_FAIL(56502, "API调用失败"), + CUSTOM_FLOW_EXE_FAIL(56503, "流程执行结果失败"), + CUSTOM_FLOW_EXE_EXCEPTION(56504, "流程执行异常(非自定义异常)"), + MENUAI_NO_CONFIG(57051, "该档口菜品识别服务未配置!"), + MENUAI_NO_UPLOAD_DTO(57052, "菜品图片上传接口缺少入参"), + MENUAI_NO_RECIPE(57053, "今日菜谱该餐次无菜,请先配置菜谱"), + MENUAI_REGIST_EXCEPTION(57080, "注册异常"), + MENUAI_REGISTING(57081, "注册中..."), + DD_LACK_DD_CONFIG_PARAM(57151, "缺少公司id和应用id入参!"), + DD_NOT_EXIT_SOURCE(57152, "不存在此来源!"), + FACE_REGISTER_FAIL(59000, "人脸照片上传注册失败!"); + + private final Integer key; + private final String desc; + + private LeRetCodeEnum(Integer key, String desc) { + this.key = key; + this.desc = desc; + } + + public static boolean ifSuccess(Integer code) { + return SUCC.getKey().equals(code); + } + + public Integer getKey() { + return this.key; + } + + public String getDesc() { + return this.desc; + } + + // $FF: synthetic method + private static LeRetCodeEnum[] $values() { + return new LeRetCodeEnum[]{SUCC, SUCC_MAC_ORD, FAIL, PAY_BALANCE_NO_ENOUGH, PAY_PERSONAL_NO_EXIT, PAY_CARD_NO_EXIT, PAY_CARD_STATE_ABNORMAL, PAY_ACC_STATE_ABNORMAL, PAY_MACHINE_NO_EXIT, PAY_MACHINE_NO_ALLOW, PAY_PERSONAL_NO_ALLOWTYPE, PAY_TIME_NO_EXIT, PAY_TIME_QUOTA_LIMIT, PAY_SELECT_ORD_NO_EXIT, PAY_QRCODE_ORD_ERROR, PAY_QRCODE_ING, PAY_TYPE_NO_OPEN, PAY_ORD_ID_EXIT, PAY_RECHARGE_NO_EXIT, PAY_THIRD_PAY_FAIL, PAY_QR_ILLEGAL, PAY_QR_NOT_PAY, PAY_COUPON_UNIVERSAL_DISABLED, PAY_ORD_LOSE, PAY_ORD_CANCEL, PAY_ORD_ING, PAY_ORD_END, PAY_ORD_EXISTS_UN_PAY, PAY_ORD_LESS_THAN_DELIVERY_MIN_AMOUNT, CORE_PARAM_ERROR, BAS_CONF_NOT_SET, CORE_DATE_START_GREATER_END, BAS_INTERVAL_NO_EXIT, CORE_IMPORT_FORMAT_ERR, CORE_IMPORT_EMPTY, CORE_IMPORT_FIELD_EMPTY, ACC_CRAD_NUM_EXIST, ACC_STATE_EXCEPTION, ACC_CARD_NUM_MAX_LIMIT, ACC_DATA_ALREADY_EXIST, ACC_SUBRULE_ALREADY_EXIST, RECHARGE_NO_AUTH, ACC_INFO_NO_EXIT, RECHARGE_NO_EXIST, REFUND_AMOUNT_GREATER, PAY_FAIL_REFUSE_REFUND, CUST_CLOSE_REFUSE_REFUND, NOT_REPEAT_REFUND, ACC_BAL_NOT_ENOUGH, BAS_TABLE_IN_USE, BAS_TABLE_NOT_IN_USE, BAS_TABLE_NOT_BIND_ORD, BAS_CANTEEN_NO_EXIT, BAS_NO_SYS_CARDINFO, CUST_PERSONAL_NO_EXIT, CUST_CASUAL_NO_BIND, CUSTINFO_ALREADY_EXISTS, CUST_ROOT_DEL_NOT_ALLOW, CUST_EXIST_RELAT, CUST_PHOTO_FACE_FAIL, CUST_STATE_EXCEPTION, CUST_LIMIT_ID_MAX_LIMIT, CUST_PSN_TYPE_OUT_RANGE, CUST_CASUAL_UNABLE_BIND, CUST_IMPORT_FORMAT_ERR, MAC_NO_HEADER_SN, MAC_APP_VERSION_NOEXIT, MAC_APP_VERSION_NOTUP, MAC_IS_NOT_EMPTY_MEALS_COUNTER, MAC_NO_PARAM_LIST, MAC_NO_PARAM_ENTITY, MAC_NO_PARAM_VARIABLE, MAC_ERR_SQL_DATE, MAC_ERR_BIND, MAC_MACHINE_NO_EXIT, MAC_MACHINE_NO_BIND_CANTEEN, MENU_NO_RECIPE, MENU_NO_RECIPE_TYPE, MENU_REPEAT_NAME, MENU_IS_USED_DISHES_COOK, MENU_REPEAT_DISHES_LABEL, MENU_IS_USED_DISHES_LABEL, MENU_EXCEED_MAX_LIMIT, MENU_NO_MATERIAL, MENU_IS_USED_DISHES, MENU_NOT_EXIST_DISHES, MENU_NOT_EXIST_RECIPE_DETAIL, MENU_NOT_EXIST_RECIPE, MENU_REPEAT_DISHES_TASTE, MENU_IS_USED_DISHES_TASTE, MENU_REPEAT_DISHES_TYPE, MENU_IS_USED_DISHES_TYPE, MENU_IS_USED_MATERIAL, MENU_NO_DISHES, MENU_NOT_EXIST_PACKAGE_MEAL, MENU_NO_PROPORTION, MENU_IS_USED_PRODUCT, MENU_NOT_EXIST_PRODUCT, MENU_ERR_RECIPE_TYPE, MENU_ERR_RECIPE_DEFAULT_LIMIT, MENU_REPEAT_DISHES, MENU_REPEAT_PRODUCT, MENU_REPEAT_PACKAGE_MEAL, MENU_NO_APPLY_DATE, MENU_NO_PARAM_LIST, MENU_NO_PARAM_ENTITY, MENU_NO_PARAM_VARIABLE, MENU_ERR_SQL_DATE, MENU_EXCEED_RESTRICT_NUM, MENU_EXCEED_SURPLUS_NUM, MENU_NOT_EXIST_TIME_INTERVAL, MENU_REPEAT_RECIPE, MENU_NOT_IN_TIME_INTERVAL, MENU_REPEAT_DISHES_COOK, MENU_IS_USED_DISHES_CLASSIFY, MENU_IS_USED_DISHES_EFFECT, MENU_IS_USED_DISHES_STYLE, MENU_IS_USED_DISHES_SUIT, MERCHANT_NOT_REGISTER, MKT_ERROR_PARAM, MGR_REPEAT_ROLE_NAME, MGR_REPEAT_USER_NAME, DRP_NO_SUPPLIER_ID, DRP_NO_WAREHOUSE_ID, DRP_NO_UNIT_ID, DRP_REPEAT_UNIT, DRP_REPEAT_HOUSE_MATERIAL, DRP_EXIST_MATERIAL_NUM, DRP_NOT_EXIST_HOUSE_MATERIAL, DRP_IS_USED_HOUSE_MATERIAL, DRP_ERR_SQL_DATE, DRP_NOT_EXIST_INTO_INVENTORY, DRP_ALREADY_INTO_INVENTORY, DRP_INVENTORY_DEFICIENCY, DRP_NOT_EXIST_OUT_INVENTORY, DRP_ALREADY_OUT_INVENTORY, DRP_NOT_EXIST_PURCHASE_ORDER, DRP_NOT_EXIST_PURCHASE_PLAN, DRP_NOT_EXIST_ISSUE, DRP_REPEAT_MATERIAL_CATEGORY, DRP_NOT_EXIST_CHECK_INVENTORY, DRP_ALREADY_CHECK_INVENTORY, ORD_TRADE_ASSEM_ERR, ORD_REFUND_FAIL, ORD_INFO_NO_EXIT, ORD_UNABLE_SUBSCRIBE, ORD_STATE_ERR, PRE_ORDER_FAIL, PRE_API_FAIL, CUSTOM_FLOW_EXE_FAIL, CUSTOM_FLOW_EXE_EXCEPTION, MENUAI_NO_CONFIG, MENUAI_NO_UPLOAD_DTO, MENUAI_NO_RECIPE, MENUAI_REGIST_EXCEPTION, MENUAI_REGISTING, DD_LACK_DD_CONFIG_PARAM, DD_NOT_EXIT_SOURCE, FACE_REGISTER_FAIL}; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/redis/RedisUtil.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/redis/RedisUtil.java index 954ccfb2..8ff95b73 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/redis/RedisUtil.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/redis/RedisUtil.java @@ -2,6 +2,9 @@ package com.bonus.core.common.redis; import cn.hutool.core.collection.CollUtil; import com.bonus.core.common.utils.SpringContextHolder; +import org.redisson.RedissonLock; +import org.redisson.api.RLock; +import org.redisson.api.RedissonClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.env.Environment; @@ -122,4 +125,11 @@ public class RedisUtil { private static Environment environment() { return (Environment)SpringContextHolder.getBean(Environment.class); } + + public static RLock getLock(String key) { + return redissonClient().getLock(key); + } + private static RedissonClient redissonClient() { + return (RedissonClient)SpringContextHolder.getBean(RedissonClient.class); + } } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/controller/AppletRecipeV2Controller.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/controller/AppletRecipeV2Controller.java index 167cd15c..fb9b257f 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/controller/AppletRecipeV2Controller.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/controller/AppletRecipeV2Controller.java @@ -55,7 +55,11 @@ public class AppletRecipeV2Controller extends BaseController { } } - + /** + * @author jsk + * @param content + * @return + */ @ApiOperation("获取预定餐食堂列表") @GetMapping({"/list/reserve/canteen/shopstall"}) public TableDataInfo getReserveMealCanteenList(@Valid AppletReserveCanteenDTO content) { @@ -67,7 +71,11 @@ public class AppletRecipeV2Controller extends BaseController { return getDataTable(null); } } - + /** + * @author jsk + * @param content + * @return + */ @ApiOperation("获取预定餐菜谱详情") @GetMapping({"/reserve/recipe/detail"}) public TableDataInfo getReserveRecipeDetailList(@Valid AppletReserveRecipeDTO content) { diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/dto/AppletReserveCanteenDTO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/dto/AppletReserveCanteenDTO.java index 03607607..e46db8e5 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/dto/AppletReserveCanteenDTO.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/dto/AppletReserveCanteenDTO.java @@ -9,7 +9,7 @@ import java.time.LocalDate; @Data public class AppletReserveCanteenDTO { @ApiModelProperty("菜谱日期") - private @NotNull(message = "菜谱id不能为空") LocalDate applyDate; + private @NotNull(message = "菜谱id不能为空") String applyDate; @ApiModelProperty("人员id") private Long custId; @ApiModelProperty("菜谱id") diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/dto/AppletReserveRecipeDTO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/dto/AppletReserveRecipeDTO.java index 14522574..07343829 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/dto/AppletReserveRecipeDTO.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/dto/AppletReserveRecipeDTO.java @@ -9,7 +9,7 @@ import java.time.LocalDate; @Data public class AppletReserveRecipeDTO { @ApiModelProperty("菜谱日期") - private @NotNull(message = "菜谱id不能为空") LocalDate applyDate; + private @NotNull(message = "菜谱id不能为空") String applyDate; @ApiModelProperty("人员id") private Long custId; @ApiModelProperty("菜谱id") diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/service/impl/MenuRecipeServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/service/impl/MenuRecipeServiceImpl.java index ee9ab243..c5eddbc9 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/service/impl/MenuRecipeServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/service/impl/MenuRecipeServiceImpl.java @@ -220,7 +220,7 @@ public class MenuRecipeServiceImpl extends ServiceImpl getReserveRecipeDetailList(AppletReserveRecipeDTO content) { - List resultList = ((MenuRecipeMapper)this.baseMapper).selectReserveRecipe(content.getApplyDate(), content.getRecipeId()); + List resultList = ((MenuRecipeMapper)this.baseMapper).selectReserveRecipe(LocalDate.parse(content.getApplyDate()), content.getRecipeId()); if (ObjectUtil.isEmpty(resultList)) { return resultList; } else { @@ -242,7 +242,7 @@ public class MenuRecipeServiceImpl extends ServiceImpl { return LocalTime.now().isBefore(time.getStartTime()); }).collect(Collectors.toList()); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/constants/OrderCacheConstants.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/constants/OrderCacheConstants.java new file mode 100644 index 00000000..f327ce33 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/constants/OrderCacheConstants.java @@ -0,0 +1,95 @@ +package com.bonus.core.order.common.constants; + + +import com.bonus.core.common.utils.TenantContextHolder; + +public class OrderCacheConstants { + public static final Long TWENTY_FOUR_HOURS = 86400L; + public static final Integer TWO_SECONDS = 2; + public static final Integer MOBILE_PAY_INTERVAL = 3; + public static final Long INVENTORY_CACHE_SECONDS = 3600L; + public static final Long WEIGHT_CACHE_SECONDS = 14400L; + public static final Long CALL_CACHE_SECONDS = 300L; + + public static String getOrderAmountChangeKey(Long tradeId) { + Long var10000 = TenantContextHolder.getTenantId(); + return "yst:" + var10000 + ":order:amount:change:" + tradeId; + } + + public static String mobileShopInventoryLockKey(Long supermarketId) { + Long var10000 = TenantContextHolder.getTenantId(); + return "yst:" + var10000 + ":order:mobileShopInventoryLock:" + supermarketId; + } + + public static String mobileShopInventoryCacheKey(Long orderId) { + Long var10000 = TenantContextHolder.getTenantId(); + return "yst:" + var10000 + ":order:mobileShopInventoryCache:" + orderId; + } + + public static String orderSubmitRepeatKey(String repeatedId) { + Long var10000 = TenantContextHolder.getTenantId(); + return "yst:" + var10000 + ":order:repeated:" + repeatedId; + } + + public static String orderHandleLockKey(String lockId) { + Long var10000 = TenantContextHolder.getTenantId(); + return "yst:" + var10000 + ":order:handle:" + lockId; + } + + public static String weightOrderHandleLockKey(String lockId) { + Long var10000 = TenantContextHolder.getTenantId(); + return "yst:" + var10000 + ":order:weight-handle:" + lockId; + } + + public static String orderCacheKey(String macOrderId) { + Long var10000 = TenantContextHolder.getTenantId(); + return "yst:" + var10000 + ":order:weight:" + macOrderId; + } + + public static String orderCacheSaveLockKey(String macOrderId) { + Long var10000 = TenantContextHolder.getTenantId(); + return "yst:" + var10000 + ":order:weight-save:" + macOrderId; + } + + public static String orderAsyncPayResultLockKey(String macOrderId) { + Long var10000 = TenantContextHolder.getTenantId(); + return "yst:" + var10000 + ":order:async-pay-result:" + macOrderId; + } + + public static String payQueryKey(Long tradeId) { + Long var10000 = TenantContextHolder.getTenantId(); + return "yst:" + var10000 + ":order:pay-query:" + tradeId; + } + + public static String payQueryTimesKey(Long tradeId) { + Long var10000 = TenantContextHolder.getTenantId(); + return "yst:" + var10000 + ":order:pay-query-times:" + tradeId; + } + + public static String orderCallHandleLockKey(Long orderId) { + Long var10000 = TenantContextHolder.getTenantId(); + return "yst:" + var10000 + ":order:call-handle:" + orderId; + } + + public static String orderMakingPartCompleteCacheKey(Long orderId) { + Long var10000 = TenantContextHolder.getTenantId(); + return "yst:" + var10000 + ":order:making-part-complete:" + orderId; + } + + public static String orderCallCacheKey(Long stallId, Integer mealtimeType) { + return "yst:" + TenantContextHolder.getTenantId() + ":order:call:" + stallId + ":" + mealtimeType; + } + + public static String orderCallCacheLockKey(Long stallId, Integer mealtimeType) { + return "yst:" + TenantContextHolder.getTenantId() + ":order:call-lock:" + stallId + ":" + mealtimeType; + } + + public static String shoppingCartLockKey(Long custId) { + Long var10000 = TenantContextHolder.getTenantId(); + return "yst:" + var10000 + ":order:shopping-cart:" + custId; + } + + public static String orderExportLockKey() { + return "yst:" + TenantContextHolder.getTenantId() + ":order:export-lock"; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/constants/OrderTips.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/constants/OrderTips.java new file mode 100644 index 00000000..ea59fd6f --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/constants/OrderTips.java @@ -0,0 +1,54 @@ +package com.bonus.core.order.common.constants; + + +import com.bonus.core.common.enums.AllocMealtimeTypeEnum; +import com.bonus.i18n.I18n; + +import java.time.LocalTime; + +public class OrderTips { + private OrderTips() { + throw new IllegalStateException("Utility class"); + } + + public static String noOrder() { + return I18n.getMessage("order.no-order", new Object[0]); + } + + public static String orderStateWrong(Integer orderState) { + return I18n.getMessage("order.wrong-order-state", new Object[]{OrderStateEnum.getDesc(orderState)}); + } + + public static String correctOrderStateWrong(Integer orderState) { + return I18n.getMessage("order.buffet.correct-pay-state-wrong", new Object[]{OrderStateEnum.getDesc(orderState)}); + } + + public static String refundLackDetail() { + return I18n.getMessage("order.refund.lack-detail", new Object[0]); + } + + public static String refundDetailNotExists() { + return I18n.getMessage("order.refund.detail-not-exists", new Object[0]); + } + + public static String refundOutOfTime(String deadLineTime) { + return I18n.getMessage("order.refund.out-of-time", new Object[]{deadLineTime}); + } + + public static String refundFailedOfTime(Integer mealtimeType, LocalTime deadLineTime) { + return I18n.getMessage("order.refund.failed-by-time", new Object[]{AllocMealtimeTypeEnum.getDescByKey(mealtimeType), deadLineTime}); + } + + public static String mobileNoDelivery() { + return I18n.getMessage("order.mobile.no-delivery", new Object[0]); + } + + public static String stallInRest(String stallName) { + return I18n.getMessage("alloc_stall_is_rest", new Object[]{stallName}); + } + + public static String paramIllegal(String paramName) { + String var10000 = I18n.getMessage("order.param-illegal", new Object[0]); + return var10000 + paramName; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/OrderShoppingCartService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/OrderShoppingCartService.java index 675cc1df..b4cc8629 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/OrderShoppingCartService.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/OrderShoppingCartService.java @@ -4,9 +4,19 @@ package com.bonus.core.order.common.service; import com.bonus.core.order.common.model.OrderShoppingCart; import com.bonus.core.order.mobile.dto.OrderShoppingSearchDTO; +import java.util.Collection; import java.util.List; public interface OrderShoppingCartService { List listByCust(OrderShoppingSearchDTO param); + void plusQuantity(Long shoppingCartId, Integer quantity); + + void insert(OrderShoppingCart entity) ; + + void updateQuantity(Long shoppingCartId, Integer quantity); + + void removeByIds(Collection shoppingCartIds); + + void removeByCust(Long custId, Integer orderType, List canteenId); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/impl/OrderShoppingCartServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/impl/OrderShoppingCartServiceImpl.java index d4634d4c..630a6238 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/impl/OrderShoppingCartServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/common/service/impl/OrderShoppingCartServiceImpl.java @@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.bonus.core.order.common.mapper.OrderShoppingCartMapper; import com.bonus.core.order.common.model.OrderShoppingCart; import com.bonus.core.order.common.service.OrderShoppingCartService; @@ -13,8 +12,8 @@ import com.bonus.core.order.utils.LeNumUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import java.lang.invoke.SerializedLambda; import java.util.Collection; import java.util.List; @@ -28,8 +27,39 @@ public class OrderShoppingCartServiceImpl implements OrderShoppingCartService { @Override public List listByCust(OrderShoppingSearchDTO param) { - //jsk - return this.baseMapper.selectList((Wrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(OrderShoppingCart.class).eq(OrderShoppingCart::getCustId, param.getCustId())).eq(LeNumUtil.isValidId(param.getOrderType()), 2, param.getOrderType())).eq(CollUtil.isNotEmpty(param.getCanteenIdList()), 1, param.getCanteenIdList())).eq(LeNumUtil.isValidId(param.getStallId()), 1, param.getStallId())).orderByAsc(3)); + return this.baseMapper.selectList(((LambdaQueryWrapper)((LambdaQueryWrapper) Wrappers + .lambdaQuery(OrderShoppingCart.class).eq(OrderShoppingCart::getCustId, param.getCustId()) + .eq(LeNumUtil.isValidId(param.getOrderType()), OrderShoppingCart::getOrderType, param.getOrderType())) + .apply("canteen_id IN ({0})", param.getCanteenIdList())) + .eq(LeNumUtil.isValidId(param.getStallId()), OrderShoppingCart::getStallId, param.getStallId()).orderByAsc(OrderShoppingCart::getShoppingCartId)); } + @Override + public void plusQuantity(Long shoppingCartId, Integer quantity) { + this.baseMapper.update(null, (Wrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(OrderShoppingCart.class).eq(OrderShoppingCart::getShoppingCartId, shoppingCartId)).setSql("quantity = quantity + " + quantity, new Object[0])); + } + + @Override + public void insert(OrderShoppingCart entity) { + this.baseMapper.insert(entity); + } + + @Override + public void updateQuantity(Long shoppingCartId, Integer quantity) { + this.baseMapper.update(null, Wrappers.lambdaUpdate(OrderShoppingCart.class).eq(OrderShoppingCart::getShoppingCartId, shoppingCartId).set(OrderShoppingCart::getQuantity, quantity)); + } + + @Override + public void removeByIds(Collection shoppingCartIds) { + if (!CollUtil.isEmpty(shoppingCartIds)) { + this.baseMapper.deleteBatchIds(shoppingCartIds); + } + } + + @Override + public void removeByCust(Long custId, Integer orderType, List canteenId) { + if (LeNumUtil.isValidId(custId)) { + this.baseMapper.delete(Wrappers.lambdaQuery(OrderShoppingCart.class).eq(OrderShoppingCart::getCustId, custId).in(CollUtil.isNotEmpty(canteenId), OrderShoppingCart::getCanteenId, canteenId).eq(LeNumUtil.isValidId(orderType), OrderShoppingCart::getOrderType, orderType)); + } + } } 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 b6a7f7e0..cd4f915e 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,9 +4,12 @@ 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.dto.OrderShoppingCartAddDTO; +import com.bonus.core.order.mobile.dto.OrderShoppingCartUpdateDTO; import com.bonus.core.order.mobile.dto.OrderShoppingSearchDTO; import com.bonus.core.order.mobile.vo.OrderInfoMobileVO; import com.bonus.core.order.mobile.vo.OrderListMobileVO; +import com.bonus.core.order.mobile.vo.OrderShoppingCartAddResultVO; import com.bonus.core.order.mobile.vo.OrderShoppingCartListMobileVO; import org.springframework.stereotype.Service; @@ -70,27 +73,27 @@ public class OrderCustomMobileBusiness implements CustomBusiness { return resultList; } // -// public OrderShoppingCartAddResultVO willAddShoppingCart(OrderShoppingCartAddDTO addDTO) { -// return null; -// } + public OrderShoppingCartAddResultVO willAddShoppingCart(OrderShoppingCartAddDTO addDTO) { + return null; + } // -// public OrderShoppingCartAddResultVO didAddShoppingCart(OrderShoppingCartAddDTO addDTO, OrderShoppingCartAddResultVO resultVO) { -// return resultVO; -// } + public OrderShoppingCartAddResultVO didAddShoppingCart(OrderShoppingCartAddDTO addDTO, OrderShoppingCartAddResultVO resultVO) { + return resultVO; + } // -// public boolean willUpdateShoppingCart(OrderShoppingCartUpdateDTO updateDTO) { -// return true; -// } + public boolean willUpdateShoppingCart(OrderShoppingCartUpdateDTO updateDTO) { + return true; + } // -// public void didUpdateShoppingCart(OrderShoppingCartUpdateDTO updateDTO) { -// } + public void didUpdateShoppingCart(OrderShoppingCartUpdateDTO updateDTO) { + } // -// public boolean willClearShoppingCart(Collection shoppingCartIds) { -// return true; -// } + public boolean willClearShoppingCart(Collection shoppingCartIds) { + return true; + } // -// public void didClearShoppingCart(Collection shoppingCartIds) { -// } + public void didClearShoppingCart(Collection shoppingCartIds) { + } // // public List willFilterInvalidByCartIds(Integer orderType, Long custId, List orderDetailPayDTOList) { // 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 46d8c10e..8ab5dea1 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 @@ -5,13 +5,12 @@ import com.bonus.common.core.web.controller.BaseController; 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.dto.OrderShoppingSearchDTO; +import com.bonus.core.order.mobile.dto.*; import com.bonus.core.order.mobile.service.OrderInfoMobileBusiness; import com.bonus.core.order.mobile.service.ShoppingCartBusiness; import com.bonus.core.order.mobile.vo.OrderInfoMobileVO; import com.bonus.core.order.mobile.vo.OrderListMobileVO; +import com.bonus.core.order.mobile.vo.OrderShoppingCartAddResultVO; import com.bonus.core.order.mobile.vo.OrderShoppingCartListMobileVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -139,26 +138,23 @@ public class OrderInfoMobileController extends BaseController { // return LeResponse.succ(preBookExists ? LeConstants.COMMON_YES : LeConstants.COMMON_NO); // } // -// @PostMapping({"/shopping-cart/add"}) -// public LeResponse addShoppingCart(@RequestHeader Map headers, @RequestBody LeRequest request) { -// ((OrderShoppingCartAddDTO)request.getContent()).setCustId(HeaderFetchUtil.getCustId(headers)); -// OrderShoppingCartAddResultVO result = this.shoppingCartBusiness.add((OrderShoppingCartAddDTO)request.getContent()); -// return LeResponse.succ(result); -// } + @PostMapping({"/shopping-cart/add"}) + public R addShoppingCart(@RequestHeader Map headers, @RequestBody OrderShoppingCartAddDTO request) { + OrderShoppingCartAddResultVO result = this.shoppingCartBusiness.add(request); + return R.ok(result); + } // -// @PostMapping({"/shopping-cart/update"}) -// public LeResponse updateShoppingCart(@RequestHeader Map headers, @RequestBody LeRequest request) { -// ((OrderShoppingCartUpdateDTO)request.getContent()).setCustId(HeaderFetchUtil.getCustId(headers)); -// this.shoppingCartBusiness.update((OrderShoppingCartUpdateDTO)request.getContent()); -// return LeResponse.succ(); -// } -// -// @PostMapping({"/shopping-cart/clear"}) -// public LeResponse removeShoppingCart(@RequestHeader Map headers, @RequestBody LeRequest request) { -// ((OrderShoppingCartClearDTO)request.getContent()).setCustId(HeaderFetchUtil.getCustId(headers)); -// this.shoppingCartBusiness.clear((OrderShoppingCartClearDTO)request.getContent()); -// return LeResponse.succ(); -// } + @PostMapping({"/shopping-cart/update"}) + public R updateShoppingCart(@RequestHeader Map headers, @RequestBody OrderShoppingCartUpdateDTO request) { + this.shoppingCartBusiness.update(request); + return R.ok(); + } + + @PostMapping({"/shopping-cart/clear"}) + public R removeShoppingCart(@RequestHeader Map headers, @RequestBody OrderShoppingCartClearDTO request) { + this.shoppingCartBusiness.clear(request); + return R.ok(); + } // @PostMapping({"/shopping-cart/list-cust"}) @ApiOperation( diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/dto/OrderShoppingCartAddDTO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/dto/OrderShoppingCartAddDTO.java new file mode 100644 index 00000000..93530d91 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/dto/OrderShoppingCartAddDTO.java @@ -0,0 +1,342 @@ +package com.bonus.core.order.mobile.dto; + +import cn.hutool.core.bean.BeanUtil; +import com.bonus.core.order.common.model.OrderShoppingCart; +import com.fasterxml.jackson.databind.JsonNode; +import com.sun.istack.internal.NotNull; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotEmpty; +import java.time.LocalDate; + +public class OrderShoppingCartAddDTO { + @ApiModelProperty( + value = "人员id", + hidden = true + ) + private Long custId; + @ApiModelProperty("菜谱id") + private Long menuId; + @ApiModelProperty("商品/菜品id") + private @NotNull + Long goodsDishesId; + @ApiModelProperty("食堂/超市id") + private Long canteenId; + @ApiModelProperty("档口id") + private Long stallId; + @ApiModelProperty("商品/菜品名称") + private @NotNull @NotEmpty String goodsDishesName; + @ApiModelProperty("订单类型") + private @NotNull Integer orderType; + @ApiModelProperty("明细类型") + private @NotNull Integer detailType; + @ApiModelProperty("数量/重量") + private @NotNull @Min(1L) Integer quantity; + @ApiModelProperty("订单日期") + private LocalDate orderDate; + @ApiModelProperty("餐次") + private Integer mealtimeType; + private JsonNode extParam; + + public OrderShoppingCart convertToEntity() { + OrderShoppingCart entity = (OrderShoppingCart)BeanUtil.copyProperties(this, OrderShoppingCart.class, new String[0]); + return entity; + } + + public Long getCustId() { + return this.custId; + } + + public Long getMenuId() { + return this.menuId; + } + + public Long getGoodsDishesId() { + return this.goodsDishesId; + } + + public Long getCanteenId() { + return this.canteenId; + } + + public Long getStallId() { + return this.stallId; + } + + public String getGoodsDishesName() { + return this.goodsDishesName; + } + + public Integer getOrderType() { + return this.orderType; + } + + public Integer getDetailType() { + return this.detailType; + } + + public Integer getQuantity() { + return this.quantity; + } + + public LocalDate getOrderDate() { + return this.orderDate; + } + + public Integer getMealtimeType() { + return this.mealtimeType; + } + + public JsonNode getExtParam() { + return this.extParam; + } + + public void setCustId(final Long custId) { + this.custId = custId; + } + + public void setMenuId(final Long menuId) { + this.menuId = menuId; + } + + public void setGoodsDishesId(final Long goodsDishesId) { + this.goodsDishesId = goodsDishesId; + } + + public void setCanteenId(final Long canteenId) { + this.canteenId = canteenId; + } + + public void setStallId(final Long stallId) { + this.stallId = stallId; + } + + public void setGoodsDishesName(final String goodsDishesName) { + this.goodsDishesName = goodsDishesName; + } + + public void setOrderType(final Integer orderType) { + this.orderType = orderType; + } + + public void setDetailType(final Integer detailType) { + this.detailType = detailType; + } + + public void setQuantity(final Integer quantity) { + this.quantity = quantity; + } + + public void setOrderDate(final LocalDate orderDate) { + this.orderDate = orderDate; + } + + public void setMealtimeType(final Integer mealtimeType) { + this.mealtimeType = mealtimeType; + } + + public void setExtParam(final JsonNode extParam) { + this.extParam = extParam; + } + + @Override + public boolean equals(final Object o) { + if (o == this) { + return true; + } else if (!(o instanceof OrderShoppingCartAddDTO)) { + return false; + } else { + OrderShoppingCartAddDTO other = (OrderShoppingCartAddDTO)o; + if (!other.canEqual(this)) { + return false; + } else { + label155: { + Object this$custId = this.getCustId(); + Object other$custId = other.getCustId(); + if (this$custId == null) { + if (other$custId == null) { + break label155; + } + } else if (this$custId.equals(other$custId)) { + break label155; + } + + return false; + } + + Object this$menuId = this.getMenuId(); + Object other$menuId = other.getMenuId(); + if (this$menuId == null) { + if (other$menuId != null) { + return false; + } + } else if (!this$menuId.equals(other$menuId)) { + return false; + } + + Object this$goodsDishesId = this.getGoodsDishesId(); + Object other$goodsDishesId = other.getGoodsDishesId(); + if (this$goodsDishesId == null) { + if (other$goodsDishesId != null) { + return false; + } + } else if (!this$goodsDishesId.equals(other$goodsDishesId)) { + return false; + } + + label134: { + Object this$canteenId = this.getCanteenId(); + Object other$canteenId = other.getCanteenId(); + if (this$canteenId == null) { + if (other$canteenId == null) { + break label134; + } + } else if (this$canteenId.equals(other$canteenId)) { + break label134; + } + + return false; + } + + label127: { + Object this$stallId = this.getStallId(); + Object other$stallId = other.getStallId(); + if (this$stallId == null) { + if (other$stallId == null) { + break label127; + } + } else if (this$stallId.equals(other$stallId)) { + break label127; + } + + return false; + } + + label120: { + Object this$orderType = this.getOrderType(); + Object other$orderType = other.getOrderType(); + if (this$orderType == null) { + if (other$orderType == null) { + break label120; + } + } else if (this$orderType.equals(other$orderType)) { + break label120; + } + + return false; + } + + Object this$detailType = this.getDetailType(); + Object other$detailType = other.getDetailType(); + if (this$detailType == null) { + if (other$detailType != null) { + return false; + } + } else if (!this$detailType.equals(other$detailType)) { + return false; + } + + label106: { + Object this$quantity = this.getQuantity(); + Object other$quantity = other.getQuantity(); + if (this$quantity == null) { + if (other$quantity == null) { + break label106; + } + } else if (this$quantity.equals(other$quantity)) { + break label106; + } + + return false; + } + + Object this$mealtimeType = this.getMealtimeType(); + Object other$mealtimeType = other.getMealtimeType(); + if (this$mealtimeType == null) { + if (other$mealtimeType != null) { + return false; + } + } else if (!this$mealtimeType.equals(other$mealtimeType)) { + return false; + } + + label92: { + Object this$goodsDishesName = this.getGoodsDishesName(); + Object other$goodsDishesName = other.getGoodsDishesName(); + if (this$goodsDishesName == null) { + if (other$goodsDishesName == null) { + break label92; + } + } else if (this$goodsDishesName.equals(other$goodsDishesName)) { + break label92; + } + + return false; + } + + Object this$orderDate = this.getOrderDate(); + Object other$orderDate = other.getOrderDate(); + if (this$orderDate == null) { + if (other$orderDate != null) { + return false; + } + } else if (!this$orderDate.equals(other$orderDate)) { + return false; + } + + Object this$extParam = this.getExtParam(); + Object other$extParam = other.getExtParam(); + if (this$extParam == null) { + if (other$extParam != null) { + return false; + } + } else if (!this$extParam.equals(other$extParam)) { + return false; + } + + return true; + } + } + } + + protected boolean canEqual(final Object other) { + return other instanceof OrderShoppingCartAddDTO; + } + + @Override + public int hashCode() { + int result = 1; + Object $custId = this.getCustId(); + result = result * 59 + ($custId == null ? 43 : $custId.hashCode()); + Object $menuId = this.getMenuId(); + result = result * 59 + ($menuId == null ? 43 : $menuId.hashCode()); + Object $goodsDishesId = this.getGoodsDishesId(); + result = result * 59 + ($goodsDishesId == null ? 43 : $goodsDishesId.hashCode()); + Object $canteenId = this.getCanteenId(); + result = result * 59 + ($canteenId == null ? 43 : $canteenId.hashCode()); + Object $stallId = this.getStallId(); + result = result * 59 + ($stallId == null ? 43 : $stallId.hashCode()); + Object $orderType = this.getOrderType(); + result = result * 59 + ($orderType == null ? 43 : $orderType.hashCode()); + Object $detailType = this.getDetailType(); + result = result * 59 + ($detailType == null ? 43 : $detailType.hashCode()); + Object $quantity = this.getQuantity(); + result = result * 59 + ($quantity == null ? 43 : $quantity.hashCode()); + Object $mealtimeType = this.getMealtimeType(); + result = result * 59 + ($mealtimeType == null ? 43 : $mealtimeType.hashCode()); + Object $goodsDishesName = this.getGoodsDishesName(); + result = result * 59 + ($goodsDishesName == null ? 43 : $goodsDishesName.hashCode()); + Object $orderDate = this.getOrderDate(); + result = result * 59 + ($orderDate == null ? 43 : $orderDate.hashCode()); + Object $extParam = this.getExtParam(); + result = result * 59 + ($extParam == null ? 43 : $extParam.hashCode()); + return result; + } + + @Override + public String toString() { + Long var10000 = this.getCustId(); + return "OrderShoppingCartAddDTO(custId=" + var10000 + ", menuId=" + this.getMenuId() + ", goodsDishesId=" + this.getGoodsDishesId() + ", canteenId=" + this.getCanteenId() + ", stallId=" + this.getStallId() + ", goodsDishesName=" + this.getGoodsDishesName() + ", orderType=" + this.getOrderType() + ", detailType=" + this.getDetailType() + ", quantity=" + this.getQuantity() + ", orderDate=" + String.valueOf(this.getOrderDate()) + ", mealtimeType=" + this.getMealtimeType() + ", extParam=" + String.valueOf(this.getExtParam()) + ")"; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/dto/OrderShoppingCartClearDTO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/dto/OrderShoppingCartClearDTO.java new file mode 100644 index 00000000..e1c9e594 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/dto/OrderShoppingCartClearDTO.java @@ -0,0 +1,89 @@ +package com.bonus.core.order.mobile.dto; + +import com.sun.istack.internal.NotNull; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; + +public class OrderShoppingCartClearDTO { + @ApiModelProperty("购物车id集合") + private @NotNull + List shoppingCartIds; + @ApiModelProperty( + value = "人员id", + hidden = true + ) + private @NotNull Long custId; + + public List getShoppingCartIds() { + return this.shoppingCartIds; + } + + public Long getCustId() { + return this.custId; + } + + public void setShoppingCartIds(final List shoppingCartIds) { + this.shoppingCartIds = shoppingCartIds; + } + + public void setCustId(final Long custId) { + this.custId = custId; + } + + @Override + public boolean equals(final Object o) { + if (o == this) { + return true; + } else if (!(o instanceof OrderShoppingCartClearDTO)) { + return false; + } else { + OrderShoppingCartClearDTO other = (OrderShoppingCartClearDTO)o; + if (!other.canEqual(this)) { + return false; + } else { + Object this$custId = this.getCustId(); + Object other$custId = other.getCustId(); + if (this$custId == null) { + if (other$custId != null) { + return false; + } + } else if (!this$custId.equals(other$custId)) { + return false; + } + + Object this$shoppingCartIds = this.getShoppingCartIds(); + Object other$shoppingCartIds = other.getShoppingCartIds(); + if (this$shoppingCartIds == null) { + if (other$shoppingCartIds != null) { + return false; + } + } else if (!this$shoppingCartIds.equals(other$shoppingCartIds)) { + return false; + } + + return true; + } + } + } + + protected boolean canEqual(final Object other) { + return other instanceof OrderShoppingCartClearDTO; + } + + @Override + public int hashCode() { + int result = 1; + Object $custId = this.getCustId(); + result = result * 59 + ($custId == null ? 43 : $custId.hashCode()); + Object $shoppingCartIds = this.getShoppingCartIds(); + result = result * 59 + ($shoppingCartIds == null ? 43 : $shoppingCartIds.hashCode()); + return result; + } + + @Override + public String toString() { + String var10000 = String.valueOf(this.getShoppingCartIds()); + return "OrderShoppingCartClearDTO(shoppingCartIds=" + var10000 + ", custId=" + this.getCustId() + ")"; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/dto/OrderShoppingCartUpdateDTO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/dto/OrderShoppingCartUpdateDTO.java new file mode 100644 index 00000000..59a4cbee --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/dto/OrderShoppingCartUpdateDTO.java @@ -0,0 +1,115 @@ +package com.bonus.core.order.mobile.dto; + +import com.sun.istack.internal.NotNull; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.constraints.Min; + +public class OrderShoppingCartUpdateDTO { + @ApiModelProperty("购物车id") + private @NotNull + Long shoppingCartId; + @ApiModelProperty("数量/重量") + private @NotNull @Min(0L) Integer quantity; + @ApiModelProperty( + value = "人员id", + hidden = true + ) + private @NotNull Long custId; + + public Long getShoppingCartId() { + return this.shoppingCartId; + } + + public Integer getQuantity() { + return this.quantity; + } + + public Long getCustId() { + return this.custId; + } + + public void setShoppingCartId(final Long shoppingCartId) { + this.shoppingCartId = shoppingCartId; + } + + public void setQuantity(final Integer quantity) { + this.quantity = quantity; + } + + public void setCustId(final Long custId) { + this.custId = custId; + } + + @Override + public boolean equals(final Object o) { + if (o == this) { + return true; + } else if (!(o instanceof OrderShoppingCartUpdateDTO)) { + return false; + } else { + OrderShoppingCartUpdateDTO other = (OrderShoppingCartUpdateDTO)o; + if (!other.canEqual(this)) { + return false; + } else { + label47: { + Object this$shoppingCartId = this.getShoppingCartId(); + Object other$shoppingCartId = other.getShoppingCartId(); + if (this$shoppingCartId == null) { + if (other$shoppingCartId == null) { + break label47; + } + } else if (this$shoppingCartId.equals(other$shoppingCartId)) { + break label47; + } + + return false; + } + + Object this$quantity = this.getQuantity(); + Object other$quantity = other.getQuantity(); + if (this$quantity == null) { + if (other$quantity != null) { + return false; + } + } else if (!this$quantity.equals(other$quantity)) { + return false; + } + + Object this$custId = this.getCustId(); + Object other$custId = other.getCustId(); + if (this$custId == null) { + if (other$custId != null) { + return false; + } + } else if (!this$custId.equals(other$custId)) { + return false; + } + + return true; + } + } + } + + protected boolean canEqual(final Object other) { + return other instanceof OrderShoppingCartUpdateDTO; + } + + @Override + public int hashCode() { + int result = 1; + Object $shoppingCartId = this.getShoppingCartId(); + result = result * 59 + ($shoppingCartId == null ? 43 : $shoppingCartId.hashCode()); + Object $quantity = this.getQuantity(); + result = result * 59 + ($quantity == null ? 43 : $quantity.hashCode()); + Object $custId = this.getCustId(); + result = result * 59 + ($custId == null ? 43 : $custId.hashCode()); + return result; + } + + @Override + public String toString() { + Long var10000 = this.getShoppingCartId(); + return "OrderShoppingCartUpdateDTO(shoppingCartId=" + var10000 + ", quantity=" + this.getQuantity() + ", custId=" + this.getCustId() + ")"; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/service/ShoppingCartBusiness.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/service/ShoppingCartBusiness.java index dba1b323..6eb4478e 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/service/ShoppingCartBusiness.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/service/ShoppingCartBusiness.java @@ -1,11 +1,21 @@ package com.bonus.core.order.mobile.service; +import com.bonus.core.order.mobile.dto.OrderShoppingCartAddDTO; +import com.bonus.core.order.mobile.dto.OrderShoppingCartClearDTO; +import com.bonus.core.order.mobile.dto.OrderShoppingCartUpdateDTO; import com.bonus.core.order.mobile.dto.OrderShoppingSearchDTO; +import com.bonus.core.order.mobile.vo.OrderShoppingCartAddResultVO; import com.bonus.core.order.mobile.vo.OrderShoppingCartListMobileVO; import java.util.List; public interface ShoppingCartBusiness { + OrderShoppingCartAddResultVO add(OrderShoppingCartAddDTO addDTO); + + void update(OrderShoppingCartUpdateDTO updateDTO); + + void clear(OrderShoppingCartClearDTO removeDTO); + List listByCust(OrderShoppingSearchDTO searchDTO); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/service/impl/ShoppingCartBusinessImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/service/impl/ShoppingCartBusinessImpl.java index 92eb86c4..9ce0f4bc 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/service/impl/ShoppingCartBusinessImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/service/impl/ShoppingCartBusinessImpl.java @@ -5,29 +5,39 @@ import cn.hutool.core.map.MapUtil; import com.bonus.core.allocation.canteen.model.AllocCanteen; import com.bonus.core.allocation.canteen.model.AllocStall; import com.bonus.core.common.enums.AllocMealtimeTypeEnum; +import com.bonus.core.common.redis.RedisUtil; import com.bonus.core.common.utils.JavaxValidateUtils; import com.bonus.core.common.utils.LogUtil; import com.bonus.core.menu.dto.CheckDishesDto; import com.bonus.core.menu.model.AllocMealtimeModel; import com.bonus.core.menu.vo.CheckDishesVo; +import com.bonus.core.order.common.constants.DetailTypeEnum; +import com.bonus.core.order.common.constants.OrderCacheConstants; +import com.bonus.core.order.common.constants.OrderTips; import com.bonus.core.order.common.constants.OrderTypeEnum; import com.bonus.core.order.common.model.OrderShoppingCart; import com.bonus.core.order.common.service.OrderShoppingCartService; import com.bonus.core.order.custom.OrderCustomBusiness; +import com.bonus.core.order.mobile.dto.OrderShoppingCartAddDTO; +import com.bonus.core.order.mobile.dto.OrderShoppingCartClearDTO; +import com.bonus.core.order.mobile.dto.OrderShoppingCartUpdateDTO; import com.bonus.core.order.mobile.dto.OrderShoppingSearchDTO; import com.bonus.core.order.mobile.service.ShoppingCartBusiness; +import com.bonus.core.order.mobile.vo.OrderShoppingCartAddResultVO; import com.bonus.core.order.mobile.vo.OrderShoppingCartListMobileVO; import com.bonus.core.order.utils.LeNumUtil; import com.bonus.core.supermarket.api.SupermarketApi; import com.bonus.core.supermarket.dto.SupermarketNotRemovedProductListDTO; import com.bonus.core.supermarket.model.SupermarketInfo; import com.bonus.core.supermarket.vo.SupermarketNotRemovedProductListVO; +import com.bonus.i18n.I18n; +import com.bonus.utils.id.Id; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; - +import org.redisson.api.RLock; import java.time.LocalDate; import java.time.LocalTime; import java.util.*; @@ -48,6 +58,79 @@ public class ShoppingCartBusinessImpl implements ShoppingCartBusiness { @Lazy protected SupermarketApi supermarketApi; + @Override + public OrderShoppingCartAddResultVO add(OrderShoppingCartAddDTO addDTO) { + OrderShoppingCartAddResultVO customVO = this.orderCustomBusiness.mobile().willAddShoppingCart(addDTO); + if (customVO != null) { + return customVO; + } else { + try{ + this.checkSubmitParam(addDTO); + }catch (Exception e){ + + } +// RLock lock = RedisUtil.getLock(OrderCacheConstants.shoppingCartLockKey(addDTO.getCustId())); + + OrderShoppingCart entity; + try { + OrderShoppingCart sameShoppingCart = (OrderShoppingCart)this.orderShoppingCartService.listByCust((new OrderShoppingSearchDTO()).setCustId(addDTO.getCustId()).setOrderType(addDTO.getOrderType())).stream().filter((s) -> { + return this.isSameDishes(s, addDTO); + }).findFirst().orElse(null); + if (sameShoppingCart != null) { + log.info("购物车已存在,更新数量:{} {} {}", new Object[]{sameShoppingCart.getShoppingCartId(), sameShoppingCart.getQuantity(), addDTO.getQuantity()}); + entity = sameShoppingCart; + this.orderShoppingCartService.plusQuantity(sameShoppingCart.getShoppingCartId(), addDTO.getQuantity()); + sameShoppingCart.setQuantity(sameShoppingCart.getQuantity() + addDTO.getQuantity()); + } else { + log.info("购物车不存在,新增:{}", addDTO); + entity = addDTO.convertToEntity(); + entity.setShoppingCartId(Id.next()); + if (OrderTypeEnum.isCurrMealType(addDTO.getOrderType())) { + addDTO.setOrderDate((LocalDate)null); + addDTO.setMealtimeType((Integer)null); + } + + this.orderShoppingCartService.insert(entity); + } + } finally { + try { +// if (lock.isHeldByCurrentThread() && lock.isLocked()) { +// lock.unlock(); +// } + } catch (Exception var11) { + log.error("解锁异常", var11); + } + + } + + OrderShoppingCartAddResultVO resultVO = OrderShoppingCartAddResultVO.of(entity); + return this.orderCustomBusiness.mobile().didAddShoppingCart(addDTO, resultVO); + } + } + + @Override + public void update(OrderShoppingCartUpdateDTO updateDTO) { + if (this.orderCustomBusiness.mobile().willUpdateShoppingCart(updateDTO)) { + JavaxValidateUtils.validate(updateDTO); + if (updateDTO.getQuantity() > 0) { + this.orderShoppingCartService.updateQuantity(updateDTO.getShoppingCartId(), updateDTO.getQuantity()); + } else { + this.orderShoppingCartService.removeByIds(CollUtil.newArrayList(new Long[]{updateDTO.getShoppingCartId()})); + } + + this.orderCustomBusiness.mobile().didUpdateShoppingCart(updateDTO); + } + } + + @Override + public void clear(OrderShoppingCartClearDTO removeDTO) { + if (this.orderCustomBusiness.mobile().willClearShoppingCart(removeDTO.getShoppingCartIds())) { + JavaxValidateUtils.validate(removeDTO); + this.orderShoppingCartService.removeByIds(removeDTO.getShoppingCartIds()); + this.orderCustomBusiness.mobile().didClearShoppingCart(removeDTO.getShoppingCartIds()); + } + } + @Override public List listByCust(OrderShoppingSearchDTO searchDTO) { JavaxValidateUtils.validate(searchDTO); @@ -122,6 +205,15 @@ public class ShoppingCartBusinessImpl implements ShoppingCartBusiness { return cart.getGoodsDishesId().equals(checkDishes.getGoodsDishesId()) && cart.getMenuId().equals(checkDishes.getRecipeId()) && cart.getOrderDate().equals(checkDishes.getOrderDate()) && cart.getMealtimeType().equals(checkDishes.getMealtimeType()); } } + protected boolean isSameDishes(OrderShoppingCart cart, OrderShoppingCartAddDTO addDTO) { + if (OrderTypeEnum.isShopCategory(addDTO.getOrderType()) && OrderTypeEnum.isShopCategory(cart.getOrderType())) { + return cart.getGoodsDishesId().equals(addDTO.getGoodsDishesId()) && cart.getCanteenId().equals(addDTO.getCanteenId()); + } else if (OrderTypeEnum.isCurrMealType(addDTO.getOrderType()) && OrderTypeEnum.isCurrMealType(cart.getOrderType())) { + return cart.getGoodsDishesId().equals(addDTO.getGoodsDishesId()) && cart.getMenuId().equals(addDTO.getMenuId()) && cart.getCanteenId().equals(addDTO.getCanteenId()) && cart.getStallId().equals(addDTO.getStallId()); + } else { + return cart.getGoodsDishesId().equals(addDTO.getGoodsDishesId()) && cart.getMenuId().equals(addDTO.getMenuId()) && cart.getCanteenId().equals(addDTO.getCanteenId()) && cart.getStallId().equals(addDTO.getStallId()) && cart.getOrderDate().equals(addDTO.getOrderDate()) && cart.getMealtimeType().equals(addDTO.getMealtimeType()); + } + } protected void fillCanteenStallMealtimeName(List voList) { Map canteenNameMapById = MapUtil.newHashMap(); Map stallMapById = MapUtil.newHashMap(); @@ -166,6 +258,46 @@ public class ShoppingCartBusinessImpl implements ShoppingCartBusiness { } } } - } + protected void checkSubmitParam(OrderShoppingCartAddDTO addDTO) throws Exception { + JavaxValidateUtils.validate(addDTO); + if (!this.supportOrderTypes().contains(addDTO.getOrderType())) { + throw new Exception(I18n.getMessage("order.un-support-order-type", new Object[0])); + } else { + if (OrderTypeEnum.isCanteenCategory(addDTO.getOrderType())) { + if (addDTO.getOrderDate() == null || !LeNumUtil.isValidId(addDTO.getMealtimeType())) { + throw new Exception(I18n.getMessage("order.mobile.cart-need-date-mealtime", new Object[0])); + } + + if (!DetailTypeEnum.isDishesCategory(addDTO.getDetailType())) { + throw new Exception(I18n.getMessage("order.un-support-detail-type", new Object[0])); + } + + if (!LeNumUtil.isValidId(addDTO.getMenuId())) { + throw new Exception(OrderTips.paramIllegal(":menuId(菜谱id)")); + } + + if (!LeNumUtil.isValidId(addDTO.getCanteenId())) { + throw new Exception(OrderTips.paramIllegal(":canteenId(食堂id)")); + } + + if (!LeNumUtil.isValidId(addDTO.getStallId())) { + throw new Exception(OrderTips.paramIllegal(":stallId(档口id)")); + } + } else if (OrderTypeEnum.isShopCategory(addDTO.getOrderType())) { + if (!DetailTypeEnum.isProductType(addDTO.getDetailType())) { + throw new Exception(I18n.getMessage("order.un-support-detail-type", new Object[0])); + } + + if (!LeNumUtil.isValidId(addDTO.getCanteenId())) { + throw new Exception(OrderTips.paramIllegal(":canteenId(超市id)")); + } + } + + } + } + public List supportOrderTypes() { + return CollUtil.toList(new Integer[]{OrderTypeEnum.CURR_MEAL.getKey(), OrderTypeEnum.RESERVE_MEAL.getKey(), OrderTypeEnum.SHOP.getKey(), OrderTypeEnum.RESERVE_SHOP.getKey()}); + } + } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/vo/OrderShoppingCartAddResultVO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/vo/OrderShoppingCartAddResultVO.java new file mode 100644 index 00000000..9140bb8c --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/order/mobile/vo/OrderShoppingCartAddResultVO.java @@ -0,0 +1,419 @@ +package com.bonus.core.order.mobile.vo; + +import cn.hutool.core.bean.BeanUtil; +import com.bonus.core.common.constant.LeRetCodeEnum; +import com.bonus.core.common.utils.SysUtil; +import com.bonus.core.order.common.model.OrderShoppingCart; +import com.fasterxml.jackson.databind.JsonNode; + +import java.time.LocalDate; + +public class OrderShoppingCartAddResultVO { + private Integer code; + private String msg; + private Long shoppingCartId; + private Long custId; + private Long menuId; + private Long goodsDishesId; + private String goodsDishesName; + private String goodsDishesImgUrl; + private Long canteenId; + private Long stallId; + private Integer detailType; + private Integer orderType; + private LocalDate orderDate; + private Integer mealtimeType; + private Integer quantity; + private JsonNode extParam; + + public String getGoodsDishesImgUrl() { + return SysUtil.getCutFileUrl(this.goodsDishesImgUrl); + } + + public static OrderShoppingCartAddResultVO of(OrderShoppingCart orderShoppingCart) { + OrderShoppingCartAddResultVO vo = (OrderShoppingCartAddResultVO)BeanUtil.copyProperties(orderShoppingCart, OrderShoppingCartAddResultVO.class, new String[0]); + vo.setCode(LeRetCodeEnum.SUCC.getKey()); + vo.setMsg(LeRetCodeEnum.SUCC.getDesc()); + return vo; + } + + public Integer getCode() { + return this.code; + } + + public String getMsg() { + return this.msg; + } + + public Long getShoppingCartId() { + return this.shoppingCartId; + } + + public Long getCustId() { + return this.custId; + } + + public Long getMenuId() { + return this.menuId; + } + + public Long getGoodsDishesId() { + return this.goodsDishesId; + } + + public String getGoodsDishesName() { + return this.goodsDishesName; + } + + public Long getCanteenId() { + return this.canteenId; + } + + public Long getStallId() { + return this.stallId; + } + + public Integer getDetailType() { + return this.detailType; + } + + public Integer getOrderType() { + return this.orderType; + } + + public LocalDate getOrderDate() { + return this.orderDate; + } + + public Integer getMealtimeType() { + return this.mealtimeType; + } + + public Integer getQuantity() { + return this.quantity; + } + + public JsonNode getExtParam() { + return this.extParam; + } + + public void setCode(final Integer code) { + this.code = code; + } + + public void setMsg(final String msg) { + this.msg = msg; + } + + public void setShoppingCartId(final Long shoppingCartId) { + this.shoppingCartId = shoppingCartId; + } + + public void setCustId(final Long custId) { + this.custId = custId; + } + + public void setMenuId(final Long menuId) { + this.menuId = menuId; + } + + public void setGoodsDishesId(final Long goodsDishesId) { + this.goodsDishesId = goodsDishesId; + } + + public void setGoodsDishesName(final String goodsDishesName) { + this.goodsDishesName = goodsDishesName; + } + + public void setGoodsDishesImgUrl(final String goodsDishesImgUrl) { + this.goodsDishesImgUrl = goodsDishesImgUrl; + } + + public void setCanteenId(final Long canteenId) { + this.canteenId = canteenId; + } + + public void setStallId(final Long stallId) { + this.stallId = stallId; + } + + public void setDetailType(final Integer detailType) { + this.detailType = detailType; + } + + public void setOrderType(final Integer orderType) { + this.orderType = orderType; + } + + public void setOrderDate(final LocalDate orderDate) { + this.orderDate = orderDate; + } + + public void setMealtimeType(final Integer mealtimeType) { + this.mealtimeType = mealtimeType; + } + + public void setQuantity(final Integer quantity) { + this.quantity = quantity; + } + + public void setExtParam(final JsonNode extParam) { + this.extParam = extParam; + } + + @Override + public boolean equals(final Object o) { + if (o == this) { + return true; + } else if (!(o instanceof OrderShoppingCartAddResultVO)) { + return false; + } else { + OrderShoppingCartAddResultVO other = (OrderShoppingCartAddResultVO)o; + if (!other.canEqual(this)) { + return false; + } else { + label203: { + Object this$code = this.getCode(); + Object other$code = other.getCode(); + if (this$code == null) { + if (other$code == null) { + break label203; + } + } else if (this$code.equals(other$code)) { + break label203; + } + + return false; + } + + Object this$shoppingCartId = this.getShoppingCartId(); + Object other$shoppingCartId = other.getShoppingCartId(); + if (this$shoppingCartId == null) { + if (other$shoppingCartId != null) { + return false; + } + } else if (!this$shoppingCartId.equals(other$shoppingCartId)) { + return false; + } + + Object this$custId = this.getCustId(); + Object other$custId = other.getCustId(); + if (this$custId == null) { + if (other$custId != null) { + return false; + } + } else if (!this$custId.equals(other$custId)) { + return false; + } + + label182: { + Object this$menuId = this.getMenuId(); + Object other$menuId = other.getMenuId(); + if (this$menuId == null) { + if (other$menuId == null) { + break label182; + } + } else if (this$menuId.equals(other$menuId)) { + break label182; + } + + return false; + } + + label175: { + Object this$goodsDishesId = this.getGoodsDishesId(); + Object other$goodsDishesId = other.getGoodsDishesId(); + if (this$goodsDishesId == null) { + if (other$goodsDishesId == null) { + break label175; + } + } else if (this$goodsDishesId.equals(other$goodsDishesId)) { + break label175; + } + + return false; + } + + label168: { + Object this$canteenId = this.getCanteenId(); + Object other$canteenId = other.getCanteenId(); + if (this$canteenId == null) { + if (other$canteenId == null) { + break label168; + } + } else if (this$canteenId.equals(other$canteenId)) { + break label168; + } + + return false; + } + + Object this$stallId = this.getStallId(); + Object other$stallId = other.getStallId(); + if (this$stallId == null) { + if (other$stallId != null) { + return false; + } + } else if (!this$stallId.equals(other$stallId)) { + return false; + } + + label154: { + Object this$detailType = this.getDetailType(); + Object other$detailType = other.getDetailType(); + if (this$detailType == null) { + if (other$detailType == null) { + break label154; + } + } else if (this$detailType.equals(other$detailType)) { + break label154; + } + + return false; + } + + Object this$orderType = this.getOrderType(); + Object other$orderType = other.getOrderType(); + if (this$orderType == null) { + if (other$orderType != null) { + return false; + } + } else if (!this$orderType.equals(other$orderType)) { + return false; + } + + label140: { + Object this$mealtimeType = this.getMealtimeType(); + Object other$mealtimeType = other.getMealtimeType(); + if (this$mealtimeType == null) { + if (other$mealtimeType == null) { + break label140; + } + } else if (this$mealtimeType.equals(other$mealtimeType)) { + break label140; + } + + return false; + } + + Object this$quantity = this.getQuantity(); + Object other$quantity = other.getQuantity(); + if (this$quantity == null) { + if (other$quantity != null) { + return false; + } + } else if (!this$quantity.equals(other$quantity)) { + return false; + } + + Object this$msg = this.getMsg(); + Object other$msg = other.getMsg(); + if (this$msg == null) { + if (other$msg != null) { + return false; + } + } else if (!this$msg.equals(other$msg)) { + return false; + } + + label119: { + Object this$goodsDishesName = this.getGoodsDishesName(); + Object other$goodsDishesName = other.getGoodsDishesName(); + if (this$goodsDishesName == null) { + if (other$goodsDishesName == null) { + break label119; + } + } else if (this$goodsDishesName.equals(other$goodsDishesName)) { + break label119; + } + + return false; + } + + label112: { + Object this$goodsDishesImgUrl = this.getGoodsDishesImgUrl(); + Object other$goodsDishesImgUrl = other.getGoodsDishesImgUrl(); + if (this$goodsDishesImgUrl == null) { + if (other$goodsDishesImgUrl == null) { + break label112; + } + } else if (this$goodsDishesImgUrl.equals(other$goodsDishesImgUrl)) { + break label112; + } + + return false; + } + + Object this$orderDate = this.getOrderDate(); + Object other$orderDate = other.getOrderDate(); + if (this$orderDate == null) { + if (other$orderDate != null) { + return false; + } + } else if (!this$orderDate.equals(other$orderDate)) { + return false; + } + + Object this$extParam = this.getExtParam(); + Object other$extParam = other.getExtParam(); + if (this$extParam == null) { + if (other$extParam != null) { + return false; + } + } else if (!this$extParam.equals(other$extParam)) { + return false; + } + + return true; + } + } + } + + protected boolean canEqual(final Object other) { + return other instanceof OrderShoppingCartAddResultVO; + } + + @Override + public int hashCode() { + int result = 1; + Object $code = this.getCode(); + result = result * 59 + ($code == null ? 43 : $code.hashCode()); + Object $shoppingCartId = this.getShoppingCartId(); + result = result * 59 + ($shoppingCartId == null ? 43 : $shoppingCartId.hashCode()); + Object $custId = this.getCustId(); + result = result * 59 + ($custId == null ? 43 : $custId.hashCode()); + Object $menuId = this.getMenuId(); + result = result * 59 + ($menuId == null ? 43 : $menuId.hashCode()); + Object $goodsDishesId = this.getGoodsDishesId(); + result = result * 59 + ($goodsDishesId == null ? 43 : $goodsDishesId.hashCode()); + Object $canteenId = this.getCanteenId(); + result = result * 59 + ($canteenId == null ? 43 : $canteenId.hashCode()); + Object $stallId = this.getStallId(); + result = result * 59 + ($stallId == null ? 43 : $stallId.hashCode()); + Object $detailType = this.getDetailType(); + result = result * 59 + ($detailType == null ? 43 : $detailType.hashCode()); + Object $orderType = this.getOrderType(); + result = result * 59 + ($orderType == null ? 43 : $orderType.hashCode()); + Object $mealtimeType = this.getMealtimeType(); + result = result * 59 + ($mealtimeType == null ? 43 : $mealtimeType.hashCode()); + Object $quantity = this.getQuantity(); + result = result * 59 + ($quantity == null ? 43 : $quantity.hashCode()); + Object $msg = this.getMsg(); + result = result * 59 + ($msg == null ? 43 : $msg.hashCode()); + Object $goodsDishesName = this.getGoodsDishesName(); + result = result * 59 + ($goodsDishesName == null ? 43 : $goodsDishesName.hashCode()); + Object $goodsDishesImgUrl = this.getGoodsDishesImgUrl(); + result = result * 59 + ($goodsDishesImgUrl == null ? 43 : $goodsDishesImgUrl.hashCode()); + Object $orderDate = this.getOrderDate(); + result = result * 59 + ($orderDate == null ? 43 : $orderDate.hashCode()); + Object $extParam = this.getExtParam(); + result = result * 59 + ($extParam == null ? 43 : $extParam.hashCode()); + return result; + } + + @Override + public String toString() { + Integer var10000 = this.getCode(); + return "OrderShoppingCartAddResultVO(code=" + var10000 + ", msg=" + this.getMsg() + ", shoppingCartId=" + this.getShoppingCartId() + ", custId=" + this.getCustId() + ", menuId=" + this.getMenuId() + ", goodsDishesId=" + this.getGoodsDishesId() + ", goodsDishesName=" + this.getGoodsDishesName() + ", goodsDishesImgUrl=" + this.getGoodsDishesImgUrl() + ", canteenId=" + this.getCanteenId() + ", stallId=" + this.getStallId() + ", detailType=" + this.getDetailType() + ", orderType=" + this.getOrderType() + ", orderDate=" + String.valueOf(this.getOrderDate()) + ", mealtimeType=" + this.getMealtimeType() + ", quantity=" + this.getQuantity() + ", extParam=" + String.valueOf(this.getExtParam()) + ")"; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/holiday/mapper/MktHolidayMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/holiday/MktHolidayMapper.xml similarity index 100% rename from bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/holiday/mapper/MktHolidayMapper.xml rename to bonus-modules/bonus-smart-canteen/src/main/resources/mapper/holiday/MktHolidayMapper.xml