From 3899e726b76143a1190a42a455821d07e6327d66 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Wed, 6 Dec 2023 17:18:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/cweb/config/AuthConfig.java | 2 + .../com/cweb/controller/TestController.java | 13 +- .../BsStoreProductCategoryController.java | 2 +- .../meal/BsMealShopCartController.java | 2 +- .../meal/BsMealTableOrderController.java | 50 +++-- .../hfkj/dao/BsMealTableOrderChildMapper.java | 25 ++- ...BsMealTableOrderChildProductMapperExt.java | 36 +++- .../dao/BsMealTableOrderChildSqlProvider.java | 22 +-- .../dao/BsMealTableOrderProductMapperExt.java | 36 +++- .../hfkj/entity/BsMealTableOrderChild.java | 22 +-- .../entity/BsMealTableOrderChildExample.java | 90 +-------- .../group/impl/BsStoreGroupServiceImpl.java | 6 +- .../service/meal/BsMealShopCartService.java | 6 + .../meal/BsMealTableOrderChildService.java | 13 ++ .../meal/BsMealTableOrderProductService.java | 22 ++- .../meal/impl/BsMealShopCartServiceImpl.java | 42 ++-- .../BsMealTableOrderChildServiceImpl.java | 183 +++++++++++++++++- .../BsMealTableOrderProductServiceImpl.java | 63 ++++++ 18 files changed, 457 insertions(+), 178 deletions(-) create mode 100644 service/src/main/java/com/hfkj/service/meal/impl/BsMealTableOrderProductServiceImpl.java diff --git a/cweb/src/main/java/com/cweb/config/AuthConfig.java b/cweb/src/main/java/com/cweb/config/AuthConfig.java index 2b6cb6f..1fa8015 100644 --- a/cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -123,6 +123,8 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/mealTableOrder/*") .excludePathPatterns("/storeProductCategory/getStoreProduct") .excludePathPatterns("/storeProductCategory/search") + .excludePathPatterns("/mealTable/getTable") + .excludePathPatterns("/mealTableOrder/*") .excludePathPatterns("/ocr/*") .excludePathPatterns("/openGroup/*") ; diff --git a/cweb/src/main/java/com/cweb/controller/TestController.java b/cweb/src/main/java/com/cweb/controller/TestController.java index e90a254..38ffc0c 100644 --- a/cweb/src/main/java/com/cweb/controller/TestController.java +++ b/cweb/src/main/java/com/cweb/controller/TestController.java @@ -605,14 +605,15 @@ public class TestController { @ApiOperation(value = "saasActivity") public ResponseData saasActivity(@RequestParam(value = "code", required = false) String code) { try { - // return ResponseMsgUtil.success(saasActivityService.queryAgentActivityStatus("73")); - // return ResponseMsgUtil.success(saasActivityService.agentRegisterActivity("73")); + // return ResponseMsgUtil.success(saasActivityService.queryAgentActivityStatus("193")); + // return ResponseMsgUtil.success(saasActivityService.agentRegisterActivity("193")); // return ResponseMsgUtil.success(saasActivityService.queryAgentActivityList()); + return ResponseMsgUtil.success(saasActivityService.referee("8226900542202CG")); // return ResponseMsgUtil.success(saasActivityService.queryCustomerActivityStatus("73", "8226900445800HB")); /*********** 活动报名 *************/ - List externalCustomerNos = new ArrayList<>(); - externalCustomerNos.add(code); + /* List externalCustomerNos = new ArrayList<>(); + externalCustomerNos.add(code);*/ // externalCustomerNos.add("8226900566100K0"); // externalCustomerNos.add("82269005714051G"); // externalCustomerNos.add("8226900899900CW"); @@ -639,10 +640,10 @@ public class TestController { // return ResponseMsgUtil.success(saasActivityService.customerRegisterActivity("73", "315653020019", "0",externalCustomerNos)); // return ResponseMsgUtil.success(saasActivityService.referee(code)); /******* 配置活动费率 *******/ - String activityId = "73"; + /* String activityId = "73"; String externalCustomerNo = code; JSONArray jsonArray = saasActivityService.queryCustomerRates(activityId, externalCustomerNo); - return ResponseMsgUtil.success(jsonArray); + return ResponseMsgUtil.success(jsonArray);*/ /* Map rate; List> rates = new ArrayList<>(); diff --git a/cweb/src/main/java/com/cweb/controller/group/BsStoreProductCategoryController.java b/cweb/src/main/java/com/cweb/controller/group/BsStoreProductCategoryController.java index 5701729..2ac5873 100644 --- a/cweb/src/main/java/com/cweb/controller/group/BsStoreProductCategoryController.java +++ b/cweb/src/main/java/com/cweb/controller/group/BsStoreProductCategoryController.java @@ -215,7 +215,7 @@ public class BsStoreProductCategoryController { @ResponseBody @ApiOperation(value = "【菜单】搜索") public ResponseData search(@RequestParam(value = "storeId" , required = true) Long storeId, - @RequestParam(value = "name" , required = true) Long name, + @RequestParam(value = "name" , required = true) String name, @RequestParam(value = "pageNum" , required = true) Integer pageNum, @RequestParam(value = "pageSize" , required = true) Integer pageSize) { diff --git a/cweb/src/main/java/com/cweb/controller/meal/BsMealShopCartController.java b/cweb/src/main/java/com/cweb/controller/meal/BsMealShopCartController.java index a76c0e5..256a4c1 100644 --- a/cweb/src/main/java/com/cweb/controller/meal/BsMealShopCartController.java +++ b/cweb/src/main/java/com/cweb/controller/meal/BsMealShopCartController.java @@ -46,7 +46,7 @@ public class BsMealShopCartController { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - mealShopCartService.addProduct(body.getString("serialNumber"),body.getLong("productId"),body.getString("userIdentity")); + mealShopCartService.addProduct(body.getString("serialNumber"), body.getLong("productId"), body.getString("userIdentity")); return ResponseMsgUtil.success("操作成功"); diff --git a/cweb/src/main/java/com/cweb/controller/meal/BsMealTableOrderController.java b/cweb/src/main/java/com/cweb/controller/meal/BsMealTableOrderController.java index f9e7c0d..cd69873 100644 --- a/cweb/src/main/java/com/cweb/controller/meal/BsMealTableOrderController.java +++ b/cweb/src/main/java/com/cweb/controller/meal/BsMealTableOrderController.java @@ -5,8 +5,13 @@ import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.entity.BsMealTableOrder; +import com.hfkj.entity.BsMealTableOrderProduct; import com.hfkj.model.ResponseData; import com.hfkj.service.meal.BsMealShopCartService; +import com.hfkj.service.meal.BsMealTableOrderChildService; +import com.hfkj.service.meal.BsMealTableOrderProductService; +import com.hfkj.service.meal.BsMealTableOrderService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -33,26 +38,23 @@ public class BsMealTableOrderController { Logger log = LoggerFactory.getLogger(BsMealTableController.class); + @Resource + private BsMealTableOrderChildService mealTableOrderChildService; + @Resource + private BsMealTableOrderService mealTableOrderService; + @Resource + private BsMealTableOrderProductService mealTableOrderProductService; @RequestMapping(value="/createOrder",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建订单") public ResponseData createOrder(@RequestBody JSONObject body) { try { - if (body == null - || StringUtils.isBlank(body.getString("serialNumber")) - || body.getJSONArray("productArray") == null) { + if (body == null || StringUtils.isBlank(body.getString("serialNumber"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - for (Object obj : body.getJSONArray("productArray")) { - JSONObject product = (JSONObject) obj; - if (product == null - || product.getLong("productId") == null || product.getInteger("number") == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "产品参数校验未通过"); - } - } - + mealTableOrderChildService.createChildOrder(body.getString("serialNumber"), body.getString("userIdentity")); return ResponseMsgUtil.success("操作成功"); @@ -61,4 +63,30 @@ public class BsMealTableOrderController { return ResponseMsgUtil.exception(e); } } + + @RequestMapping(value="/queryCurrentOrder",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询当前订单") + public ResponseData queryCurrentOrder(@RequestParam(value = "serialNumber" , required = true) String serialNumber) { + try { + // 查询桌台当前订单 + BsMealTableOrder tableOrder = mealTableOrderService.getCurrentTableOrder(serialNumber); + if (tableOrder == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当初桌台未开台"); + } + Map map = new HashMap<>(); + map.put("order", tableOrder); + + Map param = new HashMap<>(); + param.put("orderNo", tableOrder.getOrderNo()); + map.put("product", mealTableOrderProductService.getOrderProductList(param)); + return ResponseMsgUtil.success(map); + + } catch (Exception e) { + log.error(e.getMessage(), e); + return ResponseMsgUtil.exception(e); + } + } } + + diff --git a/service/src/main/java/com/hfkj/dao/BsMealTableOrderChildMapper.java b/service/src/main/java/com/hfkj/dao/BsMealTableOrderChildMapper.java index 6c70868..f70c5aa 100644 --- a/service/src/main/java/com/hfkj/dao/BsMealTableOrderChildMapper.java +++ b/service/src/main/java/com/hfkj/dao/BsMealTableOrderChildMapper.java @@ -45,18 +45,18 @@ public interface BsMealTableOrderChildMapper extends BsMealTableOrderChildMapper "serial_number, table_number, ", "`table_name`, order_no, ", "child_order_no, child_order_amount, ", - "`status`, pay_time, ", - "create_time, update_time, ", - "ext_1, ext_2, ext_3)", + "`status`, create_time, ", + "update_time, ext_1, ", + "ext_2, ext_3)", "values (#{merId,jdbcType=BIGINT}, #{merNo,jdbcType=VARCHAR}, ", "#{merName,jdbcType=VARCHAR}, #{merAbbreviate,jdbcType=VARCHAR}, ", "#{storeId,jdbcType=BIGINT}, #{storeName,jdbcType=VARCHAR}, ", - "#{serialNumber,jdbcType=VARCHAR}, #{tableNumber,jdbcType=VARCHAR}, ", + "#{serialNumber,jdbcType=VARCHAR}, #{tableNumber,jdbcType=INTEGER}, ", "#{tableName,jdbcType=VARCHAR}, #{orderNo,jdbcType=VARCHAR}, ", "#{childOrderNo,jdbcType=VARCHAR}, #{childOrderAmount,jdbcType=DECIMAL}, ", - "#{status,jdbcType=INTEGER}, #{payTime,jdbcType=TIMESTAMP}, ", - "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ", - "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" + "#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", + "#{updateTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ", + "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(BsMealTableOrderChild record); @@ -75,13 +75,12 @@ public interface BsMealTableOrderChildMapper extends BsMealTableOrderChildMapper @Result(column="store_id", property="storeId", jdbcType=JdbcType.BIGINT), @Result(column="store_name", property="storeName", jdbcType=JdbcType.VARCHAR), @Result(column="serial_number", property="serialNumber", jdbcType=JdbcType.VARCHAR), - @Result(column="table_number", property="tableNumber", jdbcType=JdbcType.VARCHAR), + @Result(column="table_number", property="tableNumber", jdbcType=JdbcType.INTEGER), @Result(column="table_name", property="tableName", jdbcType=JdbcType.VARCHAR), @Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR), @Result(column="child_order_no", property="childOrderNo", jdbcType=JdbcType.VARCHAR), @Result(column="child_order_amount", property="childOrderAmount", jdbcType=JdbcType.DECIMAL), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), - @Result(column="pay_time", property="payTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), @@ -94,7 +93,7 @@ public interface BsMealTableOrderChildMapper extends BsMealTableOrderChildMapper "select", "id, mer_id, mer_no, mer_name, mer_abbreviate, store_id, store_name, serial_number, ", "table_number, `table_name`, order_no, child_order_no, child_order_amount, `status`, ", - "pay_time, create_time, update_time, ext_1, ext_2, ext_3", + "create_time, update_time, ext_1, ext_2, ext_3", "from bs_meal_table_order_child", "where id = #{id,jdbcType=BIGINT}" }) @@ -107,13 +106,12 @@ public interface BsMealTableOrderChildMapper extends BsMealTableOrderChildMapper @Result(column="store_id", property="storeId", jdbcType=JdbcType.BIGINT), @Result(column="store_name", property="storeName", jdbcType=JdbcType.VARCHAR), @Result(column="serial_number", property="serialNumber", jdbcType=JdbcType.VARCHAR), - @Result(column="table_number", property="tableNumber", jdbcType=JdbcType.VARCHAR), + @Result(column="table_number", property="tableNumber", jdbcType=JdbcType.INTEGER), @Result(column="table_name", property="tableName", jdbcType=JdbcType.VARCHAR), @Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR), @Result(column="child_order_no", property="childOrderNo", jdbcType=JdbcType.VARCHAR), @Result(column="child_order_amount", property="childOrderAmount", jdbcType=JdbcType.DECIMAL), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), - @Result(column="pay_time", property="payTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), @@ -140,13 +138,12 @@ public interface BsMealTableOrderChildMapper extends BsMealTableOrderChildMapper "store_id = #{storeId,jdbcType=BIGINT},", "store_name = #{storeName,jdbcType=VARCHAR},", "serial_number = #{serialNumber,jdbcType=VARCHAR},", - "table_number = #{tableNumber,jdbcType=VARCHAR},", + "table_number = #{tableNumber,jdbcType=INTEGER},", "`table_name` = #{tableName,jdbcType=VARCHAR},", "order_no = #{orderNo,jdbcType=VARCHAR},", "child_order_no = #{childOrderNo,jdbcType=VARCHAR},", "child_order_amount = #{childOrderAmount,jdbcType=DECIMAL},", "`status` = #{status,jdbcType=INTEGER},", - "pay_time = #{payTime,jdbcType=TIMESTAMP},", "create_time = #{createTime,jdbcType=TIMESTAMP},", "update_time = #{updateTime,jdbcType=TIMESTAMP},", "ext_1 = #{ext1,jdbcType=VARCHAR},", diff --git a/service/src/main/java/com/hfkj/dao/BsMealTableOrderChildProductMapperExt.java b/service/src/main/java/com/hfkj/dao/BsMealTableOrderChildProductMapperExt.java index e581f55..bd1e2b7 100644 --- a/service/src/main/java/com/hfkj/dao/BsMealTableOrderChildProductMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/BsMealTableOrderChildProductMapperExt.java @@ -1,7 +1,41 @@ package com.hfkj.dao; +import com.hfkj.entity.BsMealTableOrderChildProduct; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + /** * mapper扩展类 */ public interface BsMealTableOrderChildProductMapperExt { -} \ No newline at end of file + + + @Insert(value = { + "" + }) + void addPatch(@Param(value = "dataList") List dataList); +} diff --git a/service/src/main/java/com/hfkj/dao/BsMealTableOrderChildSqlProvider.java b/service/src/main/java/com/hfkj/dao/BsMealTableOrderChildSqlProvider.java index fffdc6f..eff01e3 100644 --- a/service/src/main/java/com/hfkj/dao/BsMealTableOrderChildSqlProvider.java +++ b/service/src/main/java/com/hfkj/dao/BsMealTableOrderChildSqlProvider.java @@ -57,7 +57,7 @@ public class BsMealTableOrderChildSqlProvider { } if (record.getTableNumber() != null) { - sql.VALUES("table_number", "#{tableNumber,jdbcType=VARCHAR}"); + sql.VALUES("table_number", "#{tableNumber,jdbcType=INTEGER}"); } if (record.getTableName() != null) { @@ -80,10 +80,6 @@ public class BsMealTableOrderChildSqlProvider { sql.VALUES("`status`", "#{status,jdbcType=INTEGER}"); } - if (record.getPayTime() != null) { - sql.VALUES("pay_time", "#{payTime,jdbcType=TIMESTAMP}"); - } - if (record.getCreateTime() != null) { sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); } @@ -127,7 +123,6 @@ public class BsMealTableOrderChildSqlProvider { sql.SELECT("child_order_no"); sql.SELECT("child_order_amount"); sql.SELECT("`status`"); - sql.SELECT("pay_time"); sql.SELECT("create_time"); sql.SELECT("update_time"); sql.SELECT("ext_1"); @@ -183,7 +178,7 @@ public class BsMealTableOrderChildSqlProvider { } if (record.getTableNumber() != null) { - sql.SET("table_number = #{record.tableNumber,jdbcType=VARCHAR}"); + sql.SET("table_number = #{record.tableNumber,jdbcType=INTEGER}"); } if (record.getTableName() != null) { @@ -206,10 +201,6 @@ public class BsMealTableOrderChildSqlProvider { sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); } - if (record.getPayTime() != null) { - sql.SET("pay_time = #{record.payTime,jdbcType=TIMESTAMP}"); - } - if (record.getCreateTime() != null) { sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); } @@ -246,13 +237,12 @@ public class BsMealTableOrderChildSqlProvider { sql.SET("store_id = #{record.storeId,jdbcType=BIGINT}"); sql.SET("store_name = #{record.storeName,jdbcType=VARCHAR}"); sql.SET("serial_number = #{record.serialNumber,jdbcType=VARCHAR}"); - sql.SET("table_number = #{record.tableNumber,jdbcType=VARCHAR}"); + sql.SET("table_number = #{record.tableNumber,jdbcType=INTEGER}"); sql.SET("`table_name` = #{record.tableName,jdbcType=VARCHAR}"); sql.SET("order_no = #{record.orderNo,jdbcType=VARCHAR}"); sql.SET("child_order_no = #{record.childOrderNo,jdbcType=VARCHAR}"); sql.SET("child_order_amount = #{record.childOrderAmount,jdbcType=DECIMAL}"); sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); - sql.SET("pay_time = #{record.payTime,jdbcType=TIMESTAMP}"); sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); @@ -297,7 +287,7 @@ public class BsMealTableOrderChildSqlProvider { } if (record.getTableNumber() != null) { - sql.SET("table_number = #{tableNumber,jdbcType=VARCHAR}"); + sql.SET("table_number = #{tableNumber,jdbcType=INTEGER}"); } if (record.getTableName() != null) { @@ -320,10 +310,6 @@ public class BsMealTableOrderChildSqlProvider { sql.SET("`status` = #{status,jdbcType=INTEGER}"); } - if (record.getPayTime() != null) { - sql.SET("pay_time = #{payTime,jdbcType=TIMESTAMP}"); - } - if (record.getCreateTime() != null) { sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); } diff --git a/service/src/main/java/com/hfkj/dao/BsMealTableOrderProductMapperExt.java b/service/src/main/java/com/hfkj/dao/BsMealTableOrderProductMapperExt.java index c776d87..963bb6f 100644 --- a/service/src/main/java/com/hfkj/dao/BsMealTableOrderProductMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/BsMealTableOrderProductMapperExt.java @@ -1,7 +1,41 @@ package com.hfkj.dao; +import com.hfkj.entity.BsMealTableOrderChildProduct; +import com.hfkj.entity.BsMealTableOrderProduct; +import com.hfkj.entity.CmsPatch; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + /** * mapper扩展类 */ public interface BsMealTableOrderProductMapperExt { -} \ No newline at end of file + + @Insert(value = { + "" + }) + void addPatch(@Param(value = "dataList") List dataList); + +} diff --git a/service/src/main/java/com/hfkj/entity/BsMealTableOrderChild.java b/service/src/main/java/com/hfkj/entity/BsMealTableOrderChild.java index 39867c0..700bd25 100644 --- a/service/src/main/java/com/hfkj/entity/BsMealTableOrderChild.java +++ b/service/src/main/java/com/hfkj/entity/BsMealTableOrderChild.java @@ -54,7 +54,7 @@ public class BsMealTableOrderChild implements Serializable { /** * 桌子编号 */ - private String tableNumber; + private Integer tableNumber; /** * 桌子名称 @@ -81,11 +81,6 @@ public class BsMealTableOrderChild implements Serializable { */ private Integer status; - /** - * 支付时间 - */ - private Date payTime; - /** * 创建时间 */ @@ -168,11 +163,11 @@ public class BsMealTableOrderChild implements Serializable { this.serialNumber = serialNumber; } - public String getTableNumber() { + public Integer getTableNumber() { return tableNumber; } - public void setTableNumber(String tableNumber) { + public void setTableNumber(Integer tableNumber) { this.tableNumber = tableNumber; } @@ -216,14 +211,6 @@ public class BsMealTableOrderChild implements Serializable { this.status = status; } - public Date getPayTime() { - return payTime; - } - - public void setPayTime(Date payTime) { - this.payTime = payTime; - } - public Date getCreateTime() { return createTime; } @@ -290,7 +277,6 @@ public class BsMealTableOrderChild implements Serializable { && (this.getChildOrderNo() == null ? other.getChildOrderNo() == null : this.getChildOrderNo().equals(other.getChildOrderNo())) && (this.getChildOrderAmount() == null ? other.getChildOrderAmount() == null : this.getChildOrderAmount().equals(other.getChildOrderAmount())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) - && (this.getPayTime() == null ? other.getPayTime() == null : this.getPayTime().equals(other.getPayTime())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) && (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1())) @@ -316,7 +302,6 @@ public class BsMealTableOrderChild implements Serializable { result = prime * result + ((getChildOrderNo() == null) ? 0 : getChildOrderNo().hashCode()); result = prime * result + ((getChildOrderAmount() == null) ? 0 : getChildOrderAmount().hashCode()); result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); - result = prime * result + ((getPayTime() == null) ? 0 : getPayTime().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode()); @@ -345,7 +330,6 @@ public class BsMealTableOrderChild implements Serializable { sb.append(", childOrderNo=").append(childOrderNo); sb.append(", childOrderAmount=").append(childOrderAmount); sb.append(", status=").append(status); - sb.append(", payTime=").append(payTime); sb.append(", createTime=").append(createTime); sb.append(", updateTime=").append(updateTime); sb.append(", ext1=").append(ext1); diff --git a/service/src/main/java/com/hfkj/entity/BsMealTableOrderChildExample.java b/service/src/main/java/com/hfkj/entity/BsMealTableOrderChildExample.java index 7f94b95..891605a 100644 --- a/service/src/main/java/com/hfkj/entity/BsMealTableOrderChildExample.java +++ b/service/src/main/java/com/hfkj/entity/BsMealTableOrderChildExample.java @@ -666,62 +666,52 @@ public class BsMealTableOrderChildExample { return (Criteria) this; } - public Criteria andTableNumberEqualTo(String value) { + public Criteria andTableNumberEqualTo(Integer value) { addCriterion("table_number =", value, "tableNumber"); return (Criteria) this; } - public Criteria andTableNumberNotEqualTo(String value) { + public Criteria andTableNumberNotEqualTo(Integer value) { addCriterion("table_number <>", value, "tableNumber"); return (Criteria) this; } - public Criteria andTableNumberGreaterThan(String value) { + public Criteria andTableNumberGreaterThan(Integer value) { addCriterion("table_number >", value, "tableNumber"); return (Criteria) this; } - public Criteria andTableNumberGreaterThanOrEqualTo(String value) { + public Criteria andTableNumberGreaterThanOrEqualTo(Integer value) { addCriterion("table_number >=", value, "tableNumber"); return (Criteria) this; } - public Criteria andTableNumberLessThan(String value) { + public Criteria andTableNumberLessThan(Integer value) { addCriterion("table_number <", value, "tableNumber"); return (Criteria) this; } - public Criteria andTableNumberLessThanOrEqualTo(String value) { + public Criteria andTableNumberLessThanOrEqualTo(Integer value) { addCriterion("table_number <=", value, "tableNumber"); return (Criteria) this; } - public Criteria andTableNumberLike(String value) { - addCriterion("table_number like", value, "tableNumber"); - return (Criteria) this; - } - - public Criteria andTableNumberNotLike(String value) { - addCriterion("table_number not like", value, "tableNumber"); - return (Criteria) this; - } - - public Criteria andTableNumberIn(List values) { + public Criteria andTableNumberIn(List values) { addCriterion("table_number in", values, "tableNumber"); return (Criteria) this; } - public Criteria andTableNumberNotIn(List values) { + public Criteria andTableNumberNotIn(List values) { addCriterion("table_number not in", values, "tableNumber"); return (Criteria) this; } - public Criteria andTableNumberBetween(String value1, String value2) { + public Criteria andTableNumberBetween(Integer value1, Integer value2) { addCriterion("table_number between", value1, value2, "tableNumber"); return (Criteria) this; } - public Criteria andTableNumberNotBetween(String value1, String value2) { + public Criteria andTableNumberNotBetween(Integer value1, Integer value2) { addCriterion("table_number not between", value1, value2, "tableNumber"); return (Criteria) this; } @@ -1056,66 +1046,6 @@ public class BsMealTableOrderChildExample { return (Criteria) this; } - public Criteria andPayTimeIsNull() { - addCriterion("pay_time is null"); - return (Criteria) this; - } - - public Criteria andPayTimeIsNotNull() { - addCriterion("pay_time is not null"); - return (Criteria) this; - } - - public Criteria andPayTimeEqualTo(Date value) { - addCriterion("pay_time =", value, "payTime"); - return (Criteria) this; - } - - public Criteria andPayTimeNotEqualTo(Date value) { - addCriterion("pay_time <>", value, "payTime"); - return (Criteria) this; - } - - public Criteria andPayTimeGreaterThan(Date value) { - addCriterion("pay_time >", value, "payTime"); - return (Criteria) this; - } - - public Criteria andPayTimeGreaterThanOrEqualTo(Date value) { - addCriterion("pay_time >=", value, "payTime"); - return (Criteria) this; - } - - public Criteria andPayTimeLessThan(Date value) { - addCriterion("pay_time <", value, "payTime"); - return (Criteria) this; - } - - public Criteria andPayTimeLessThanOrEqualTo(Date value) { - addCriterion("pay_time <=", value, "payTime"); - return (Criteria) this; - } - - public Criteria andPayTimeIn(List values) { - addCriterion("pay_time in", values, "payTime"); - return (Criteria) this; - } - - public Criteria andPayTimeNotIn(List values) { - addCriterion("pay_time not in", values, "payTime"); - return (Criteria) this; - } - - public Criteria andPayTimeBetween(Date value1, Date value2) { - addCriterion("pay_time between", value1, value2, "payTime"); - return (Criteria) this; - } - - public Criteria andPayTimeNotBetween(Date value1, Date value2) { - addCriterion("pay_time not between", value1, value2, "payTime"); - return (Criteria) this; - } - public Criteria andCreateTimeIsNull() { addCriterion("create_time is null"); return (Criteria) this; diff --git a/service/src/main/java/com/hfkj/service/group/impl/BsStoreGroupServiceImpl.java b/service/src/main/java/com/hfkj/service/group/impl/BsStoreGroupServiceImpl.java index 602c642..2ebdf01 100644 --- a/service/src/main/java/com/hfkj/service/group/impl/BsStoreGroupServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/group/impl/BsStoreGroupServiceImpl.java @@ -11,8 +11,10 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; @Service("bsStoreGroupService") public class BsStoreGroupServiceImpl implements BsStoreGroupService { @@ -96,7 +98,6 @@ public class BsStoreGroupServiceImpl implements BsStoreGroupService { @Override public List getStoreProductByList(Map map) { - BsStoreProductExample example = new BsStoreProductExample(); BsStoreProductExample.Criteria criteria = example.createCriteria(); @@ -105,10 +106,9 @@ public class BsStoreGroupServiceImpl implements BsStoreGroupService { } if (StringUtils.isNotBlank(MapUtils.getString(map, "name"))) { - criteria.andNameLike("%" + MapUtils.getLong(map, "name") + "%"); + criteria.andNameLike("%" + MapUtils.getString(map, "name") + "%"); } - return storeProductMapper.selectByExample(example); } diff --git a/service/src/main/java/com/hfkj/service/meal/BsMealShopCartService.java b/service/src/main/java/com/hfkj/service/meal/BsMealShopCartService.java index 505de20..1530388 100644 --- a/service/src/main/java/com/hfkj/service/meal/BsMealShopCartService.java +++ b/service/src/main/java/com/hfkj/service/meal/BsMealShopCartService.java @@ -39,6 +39,12 @@ public interface BsMealShopCartService { */ void clear(String serialNumber,String userIdentity); + /** + * 清楚产品数据 + * @param serialNumber + */ + void clearData(String serialNumber); + /** * 查询购物车产品 * @param orderNo 订单号 diff --git a/service/src/main/java/com/hfkj/service/meal/BsMealTableOrderChildService.java b/service/src/main/java/com/hfkj/service/meal/BsMealTableOrderChildService.java index 6051300..24168f9 100644 --- a/service/src/main/java/com/hfkj/service/meal/BsMealTableOrderChildService.java +++ b/service/src/main/java/com/hfkj/service/meal/BsMealTableOrderChildService.java @@ -1,7 +1,11 @@ package com.hfkj.service.meal; +import com.alibaba.fastjson.JSONArray; import com.hfkj.entity.BsMealTableOrderChild; +import java.util.List; +import java.util.Map; + /** * @className: BsMealTableOrderChildService * @author: HuRui @@ -15,4 +19,13 @@ public interface BsMealTableOrderChildService { */ void editData(BsMealTableOrderChild data); + /** + * 创建订单 + * @param serialNumber + * @param userIdentity + * @return + */ + void createChildOrder(String serialNumber, String userIdentity); + + } diff --git a/service/src/main/java/com/hfkj/service/meal/BsMealTableOrderProductService.java b/service/src/main/java/com/hfkj/service/meal/BsMealTableOrderProductService.java index 1b177ad..d69e87d 100644 --- a/service/src/main/java/com/hfkj/service/meal/BsMealTableOrderProductService.java +++ b/service/src/main/java/com/hfkj/service/meal/BsMealTableOrderProductService.java @@ -1,6 +1,9 @@ package com.hfkj.service.meal; -import com.hfkj.entity.BsMealTableOrderChild; +import com.hfkj.entity.BsMealTableOrderProduct; + +import java.util.List; +import java.util.Map; /** * @className: BsMealTableOrderProductService @@ -13,5 +16,20 @@ public interface BsMealTableOrderProductService { * 编辑数据 * @param data */ - void editData(BsMealTableOrderChild data); + void editData(BsMealTableOrderProduct data); + + /** + * 查询订单产品列表 + * @param param + * @return + */ + List getOrderProductList(Map param); + + /** + * 查询产品 + * @param orderNo + * @param productId + */ + BsMealTableOrderProduct getOrderProduct(String orderNo,Long productId); + } diff --git a/service/src/main/java/com/hfkj/service/meal/impl/BsMealShopCartServiceImpl.java b/service/src/main/java/com/hfkj/service/meal/impl/BsMealShopCartServiceImpl.java index 2dc152b..7516965 100644 --- a/service/src/main/java/com/hfkj/service/meal/impl/BsMealShopCartServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/meal/impl/BsMealShopCartServiceImpl.java @@ -82,25 +82,25 @@ public class BsMealShopCartServiceImpl implements BsMealShopCartService { // 查询购物车中的产品 BsMealShopCart shopCart = getShopCartProduct(tableOrder.getOrderNo(), productId); if (shopCart == null) { - BsMealShopCart mealShopCart = new BsMealShopCart(); - mealShopCart.setStoreId(tableOrder.getStoreId()); - mealShopCart.setStoreName(tableOrder.getStoreName()); - mealShopCart.setSerialNumber(tableOrder.getSerialNumber()); - mealShopCart.setTableNumber(tableOrder.getTableNumber()); - mealShopCart.setTableName(tableOrder.getTableName()); - mealShopCart.setOrderNo(tableOrder.getOrderNo()); - mealShopCart.setProductCategoryId(product.getProductCategoryId()); - mealShopCart.setProductCategoryName(product.getProductCategoryName()); - mealShopCart.setProductId(product.getId()); - mealShopCart.setProductImg(product.getImg()); - mealShopCart.setProductName(product.getName()); - mealShopCart.setProductSpec(product.getSpec()); - mealShopCart.setProductPrice(product.getPrice()); - mealShopCart.setProductNum(1); + shopCart = new BsMealShopCart(); + shopCart.setStoreId(tableOrder.getStoreId()); + shopCart.setStoreName(tableOrder.getStoreName()); + shopCart.setSerialNumber(tableOrder.getSerialNumber()); + shopCart.setTableNumber(tableOrder.getTableNumber()); + shopCart.setTableName(tableOrder.getTableName()); + shopCart.setOrderNo(tableOrder.getOrderNo()); + shopCart.setProductCategoryId(product.getProductCategoryId()); + shopCart.setProductCategoryName(product.getProductCategoryName()); + shopCart.setProductId(product.getId()); + shopCart.setProductImg(product.getImg()); + shopCart.setProductName(product.getName()); + shopCart.setProductSpec(product.getSpec()); + shopCart.setProductPrice(product.getPrice()); + shopCart.setProductNum(1); // 数量 * 产品单价 - mealShopCart.setProductTotalPrice(new BigDecimal(mealShopCart.getProductNum().toString()).multiply(product.getPrice())); - mealShopCart.setStatus(1); - editData(mealShopCart); + shopCart.setProductTotalPrice(new BigDecimal(shopCart.getProductNum().toString()).multiply(product.getPrice())); + shopCart.setStatus(1); + editData(shopCart); } else { // 增加数量 shopCart.setProductNum(shopCart.getProductNum()+1); @@ -242,6 +242,11 @@ public class BsMealShopCartServiceImpl implements BsMealShopCartService { } } + @Override + public void clearData(String serialNumber) { + mealShopCartMapper.clear(serialNumber); + } + @Override public BsMealShopCart getShopCartProduct(String orderNo, Long productId) { BsMealShopCartExample example = new BsMealShopCartExample(); @@ -279,6 +284,7 @@ enum CmdTypeEnum { type3(3, "删除产品"), type4(4, "减少产品数量"), type5(5, "清空购物车"), + type6(6, "提交订单"), ; private Integer number; diff --git a/service/src/main/java/com/hfkj/service/meal/impl/BsMealTableOrderChildServiceImpl.java b/service/src/main/java/com/hfkj/service/meal/impl/BsMealTableOrderChildServiceImpl.java index c28477b..460c774 100644 --- a/service/src/main/java/com/hfkj/service/meal/impl/BsMealTableOrderChildServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/meal/impl/BsMealTableOrderChildServiceImpl.java @@ -1,12 +1,28 @@ package com.hfkj.service.meal.impl; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.hfkj.common.exception.BaseException; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; +import com.hfkj.common.utils.GenerateUtil; +import com.hfkj.config.mqtt.MqttProviderService; import com.hfkj.dao.BsMealTableOrderChildMapper; -import com.hfkj.entity.BsMealTableOrderChild; -import com.hfkj.service.meal.BsMealTableOrderChildService; +import com.hfkj.dao.BsMealTableOrderChildProductMapper; +import com.hfkj.dao.BsMealTableOrderProductMapper; +import com.hfkj.entity.*; +import com.hfkj.service.BsDeviceService; +import com.hfkj.service.group.BsStoreGroupService; +import com.hfkj.service.meal.*; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.Date; +import java.math.BigDecimal; +import java.util.*; /** * @className: BsMealTableOrderChildServiceImpl @@ -19,6 +35,30 @@ public class BsMealTableOrderChildServiceImpl implements BsMealTableOrderChildSe @Resource private BsMealTableOrderChildMapper mealTableOrderChildMapper; + @Resource + private BsMealTableOrderChildProductMapper mealTableOrderChildProductMapper; + + @Resource + private BsMealTableOrderService mealTableOrderService; + + @Resource + private BsMealTableOrderProductService mealTableOrderProductService; + + @Resource + private BsStoreGroupService storeGroupService; + + @Resource + private BsMealShopCartService mealShopCartService; + + @Resource + private RedisTemplate redisTemplate; + + @Resource + private MqttProviderService mqttProviderService; + + @Resource + private BsDeviceService deviceService; + @Override public void editData(BsMealTableOrderChild data) { if (data.getId() == null) { @@ -30,4 +70,141 @@ public class BsMealTableOrderChildServiceImpl implements BsMealTableOrderChildSe mealTableOrderChildMapper.updateByPrimaryKey(data); } } + + @Override + @Transactional(propagation= Propagation.REQUIRES_NEW) + public void createChildOrder(String serialNumber, String userIdentity) { + String lockKey = "MEAL_SHOP_CART_" + serialNumber; + try { + Boolean lock = redisTemplate.opsForValue().setIfAbsent(lockKey, null); + if(lock) { + // 加锁成功 + // 查询当前开台订单 + BsMealTableOrder tableOrder = mealTableOrderService.getCurrentTableOrder(serialNumber); + if (tableOrder == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "桌台未开台,订单创建失败!"); + } + BsMealTableOrderChild tableOrderChild = new BsMealTableOrderChild(); + tableOrderChild.setMerId(tableOrder.getMerId()); + tableOrderChild.setMerNo(tableOrder.getMerNo()); + tableOrderChild.setMerName(tableOrder.getMerName()); + tableOrderChild.setMerAbbreviate(tableOrder.getMerAbbreviate()); + tableOrderChild.setStoreId(tableOrder.getStoreId()); + tableOrderChild.setStoreName(tableOrder.getStoreName()); + tableOrderChild.setSerialNumber(tableOrder.getSerialNumber()); + tableOrderChild.setTableNumber(tableOrder.getTableNumber()); + tableOrderChild.setTableName(tableOrder.getTableName()); + tableOrderChild.setOrderNo(tableOrder.getOrderNo()); + tableOrderChild.setChildOrderNo(System.currentTimeMillis()+ GenerateUtil.generateRandomString(1)); + tableOrderChild.setChildOrderAmount(new BigDecimal("0")); + tableOrderChild.setStatus(1); + editData(tableOrderChild); + + List childProductList = new ArrayList<>(); + BsMealTableOrderChildProduct childProduct; + + // 查询购物车 + Map shopCardParam = new HashMap<>(); + shopCardParam.put("serialNumber", serialNumber); + List cartProductList = mealShopCartService.getShopCartProductList(shopCardParam); + if (cartProductList.isEmpty()) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请选择产品"); + } + for (BsMealShopCart cartProduct : cartProductList) { + // 查询交易订单中的产品 + BsMealTableOrderProduct orderProduct = mealTableOrderProductService.getOrderProduct(tableOrder.getOrderNo(), cartProduct.getProductId()); + if (orderProduct == null) { + orderProduct = new BsMealTableOrderProduct(); + orderProduct.setOrderId(tableOrderChild.getStoreId()); + orderProduct.setOrderNo(tableOrderChild.getStoreName()); + orderProduct.setProductCategoryId(cartProduct.getProductCategoryId()); + orderProduct.setProductCategoryName(cartProduct.getProductCategoryName()); + orderProduct.setProductId(cartProduct.getId()); + orderProduct.setProductImg(cartProduct.getProductImg()); + orderProduct.setProductName(cartProduct.getProductName()); + orderProduct.setProductSpec(cartProduct.getProductSpec()); + orderProduct.setProductPrice(cartProduct.getProductPrice()); + orderProduct.setProductNum(cartProduct.getProductNum()); + orderProduct.setProductTotalPrice(new BigDecimal(orderProduct.getProductNum().toString()).multiply(orderProduct.getProductPrice())); + orderProduct.setStatus(1); + } else { + orderProduct.setProductNum(orderProduct.getProductNum() + cartProduct.getProductNum()); + orderProduct.setProductTotalPrice(new BigDecimal(orderProduct.getProductNum().toString()).multiply(orderProduct.getProductPrice())); + } + mealTableOrderProductService.editData(orderProduct); + + + childProduct = new BsMealTableOrderChildProduct(); + childProduct.setStoreId(tableOrderChild.getStoreId()); + childProduct.setStoreName(tableOrderChild.getStoreName()); + childProduct.setChildOrderId(tableOrderChild.getId()); + childProduct.setChildOrderNo(tableOrderChild.getChildOrderNo()); + childProduct.setProductCategoryId(cartProduct.getProductCategoryId()); + childProduct.setProductCategoryName(cartProduct.getProductCategoryName()); + childProduct.setProductId(cartProduct.getId()); + childProduct.setProductImg(cartProduct.getProductImg()); + childProduct.setProductName(cartProduct.getProductName()); + childProduct.setProductSpec(cartProduct.getProductSpec()); + childProduct.setProductPrice(cartProduct.getProductPrice()); + childProduct.setProductNum(cartProduct.getProductNum()); + childProduct.setProductTotalPrice(new BigDecimal(childProduct.getProductNum().toString()).multiply(childProduct.getProductPrice())); + childProduct.setStatus(1); + childProduct.setCreateTime(new Date()); + childProduct.setUpdateTime(new Date()); + childProductList.add(childProduct); + // 计算子订单总金额 + tableOrderChild.setChildOrderAmount(tableOrderChild.getChildOrderAmount().add(childProduct.getProductTotalPrice())); + } + editData(tableOrderChild); + + // 批量插入子订单产品数据 + mealTableOrderChildProductMapper.addPatch(childProductList); + + // 修改交易订单数据 + tableOrder.setOrderAmount(tableOrder.getOrderAmount().add(tableOrderChild.getChildOrderAmount())); + mealTableOrderService.editData(tableOrder); + + // 清楚购物车数据 + mealShopCartService.clearData(serialNumber); + + // 推送MQTT + Map pushParam = new HashMap<>(); + pushParam.put("userIdentity", userIdentity); + pushParam.put("cmdType", CmdTypeEnum.type6.getNumber()); + pushParam.put("productList", new JSONArray()); + mqttProviderService.publish(2, false, "MEAL_TABLE_" + serialNumber, JSONObject.toJSONString(pushParam)); + + // todo 打印小票 + + + + + + + + + + + + + + + + + redisTemplate.delete(lockKey); + + } else { + System.out.println("加锁失败"); + Thread.sleep(100); // 加锁失败,重试 + createChildOrder(serialNumber, userIdentity); + } + } catch (BaseException baseException) { + redisTemplate.delete(lockKey); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, baseException.getErrorMsg()); + + } catch (Exception e) { + redisTemplate.delete(lockKey); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知错误"); + } + } } diff --git a/service/src/main/java/com/hfkj/service/meal/impl/BsMealTableOrderProductServiceImpl.java b/service/src/main/java/com/hfkj/service/meal/impl/BsMealTableOrderProductServiceImpl.java new file mode 100644 index 0000000..255ea91 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/meal/impl/BsMealTableOrderProductServiceImpl.java @@ -0,0 +1,63 @@ +package com.hfkj.service.meal.impl; + +import com.hfkj.dao.BsMealTableOrderProductMapper; +import com.hfkj.entity.BsMealTableOrderChild; +import com.hfkj.entity.BsMealTableOrderProduct; +import com.hfkj.entity.BsMealTableOrderProductExample; +import com.hfkj.service.meal.BsMealTableOrderProductService; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @className: BsMealTableOrderProductServiceImpl + * @author: HuRui + * @date: 2023/12/6 + **/ +@Service("mealTableOrderProductService") +public class BsMealTableOrderProductServiceImpl implements BsMealTableOrderProductService { + + @Resource + private BsMealTableOrderProductMapper mealTableOrderProductMapper; + + @Override + public void editData(BsMealTableOrderProduct data) { + if (data.getId() == null) { + data.setCreateTime(new Date()); + data.setUpdateTime(new Date()); + mealTableOrderProductMapper.insert(data); + } else { + data.setUpdateTime(new Date()); + mealTableOrderProductMapper.updateByPrimaryKey(data); + } + } + + @Override + public List getOrderProductList(Map param) { + BsMealTableOrderProductExample example = new BsMealTableOrderProductExample(); + BsMealTableOrderProductExample.Criteria criteria = example.createCriteria().andStatusNotEqualTo(0); + + if (StringUtils.isNotBlank(MapUtils.getString(param, "orderNo"))) { + criteria.andOrderNoEqualTo(MapUtils.getString(param, "orderNo")); + } + + example.setOrderByClause("create_time desc"); + return mealTableOrderProductMapper.selectByExample(example); + } + + @Override + public BsMealTableOrderProduct getOrderProduct(String orderNo, Long productId) { + BsMealTableOrderProductExample example = new BsMealTableOrderProductExample(); + example.createCriteria().andOrderNoEqualTo(orderNo).andStatusNotEqualTo(0); + List list = mealTableOrderProductMapper.selectByExample(example); + if (!list.isEmpty()) { + return list.get(0); + } + return null; + } +}