From b34eaa2894fe4f19c3e76ff759a6f047dce72a4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=9B=E5=8F=89=E9=97=AA=E9=97=AA?= <18322780655@163.com> Date: Tue, 20 Aug 2024 15:53:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=80=97=E6=9D=90=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/dao/TbConsInfoMapper.java | 27 +++ .../cashierservice/dao/TbProskuConMapper.java | 37 ++++ .../cashierservice/entity/TbConsInfo.java | 169 +++++++++++++++ .../cashierservice/entity/TbProskuCon.java | 89 ++++++++ .../cashierservice/service/CartService.java | 26 +++ .../resources/mapper/TbConsInfoMapper.xml | 194 ++++++++++++++++++ .../resources/mapper/TbProskuConMapper.xml | 155 ++++++++++++++ 7 files changed, 697 insertions(+) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/dao/TbConsInfoMapper.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProskuConMapper.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TbConsInfo.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProskuCon.java create mode 100644 src/main/resources/mapper/TbConsInfoMapper.xml create mode 100644 src/main/resources/mapper/TbProskuConMapper.xml diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbConsInfoMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbConsInfoMapper.java new file mode 100644 index 0000000..f37b6d3 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbConsInfoMapper.java @@ -0,0 +1,27 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbConsInfo; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +@Mapper +public interface TbConsInfoMapper { + int deleteByPrimaryKey(Integer id); + + int insert(TbConsInfo record); + + int insertSelective(TbConsInfo record); + + TbConsInfo selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(TbConsInfo record); + + int updateByPrimaryKey(TbConsInfo record); + + int countAll(); + + List selectAllInfo(); +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProskuConMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProskuConMapper.java new file mode 100644 index 0000000..ceca300 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProskuConMapper.java @@ -0,0 +1,37 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbProskuCon; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +@Mapper +public interface TbProskuConMapper { + int deleteByPrimaryKey(Integer id); + + int insert(TbProskuCon record); + + int insertSelective(TbProskuCon record); + + TbProskuCon selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(TbProskuCon record); + + int updateByPrimaryKey(TbProskuCon record); + + + List selectBySkuIdAndShopId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId); + List selectBySkuIdAndShopIdAngCheck(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId); + + + List selectIdBySkuIdAndShopId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId); + + List selectByShopIdAndSkuIdAndProductId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId,@Param("productId") Integer productId); + List selectByShopIdAndSkuIdAndProductIdAndCheck(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId,@Param("productId") Integer productId); + + + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbConsInfo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbConsInfo.java new file mode 100644 index 0000000..f3b3d99 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbConsInfo.java @@ -0,0 +1,169 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +public class TbConsInfo implements Serializable { + private Integer id; + + private Integer shopId; + + private Integer conTypeId; + + private String conTypeName; + + private String conCode; + + private String conName; + + private BigDecimal stockNumber; + + private String conUnit; + + private BigDecimal lasterInStock; + + private BigDecimal conWarning; + + private BigDecimal stockConsume; + + private String status; + + private BigDecimal price; + + private Date createTime; + + private Date updateTime; + + private String isCheck; + + private static final long serialVersionUID = 1L; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + public Integer getConTypeId() { + return conTypeId; + } + + public void setConTypeId(Integer conTypeId) { + this.conTypeId = conTypeId; + } + + public String getConTypeName() { + return conTypeName; + } + + public void setConTypeName(String conTypeName) { + this.conTypeName = conTypeName == null ? null : conTypeName.trim(); + } + + public String getConCode() { + return conCode; + } + + public void setConCode(String conCode) { + this.conCode = conCode == null ? null : conCode.trim(); + } + + public String getConName() { + return conName; + } + + public void setConName(String conName) { + this.conName = conName == null ? null : conName.trim(); + } + + public BigDecimal getStockNumber() { + return stockNumber; + } + + public void setStockNumber(BigDecimal stockNumber) { + this.stockNumber = stockNumber; + } + + public String getConUnit() { + return conUnit; + } + + public void setConUnit(String conUnit) { + this.conUnit = conUnit == null ? null : conUnit.trim(); + } + + public BigDecimal getLasterInStock() { + return lasterInStock; + } + + public void setLasterInStock(BigDecimal lasterInStock) { + this.lasterInStock = lasterInStock; + } + + public BigDecimal getConWarning() { + return conWarning; + } + + public void setConWarning(BigDecimal conWarning) { + this.conWarning = conWarning; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public BigDecimal getStockConsume() { + return stockConsume; + } + + public void setStockConsume(BigDecimal stockConsume) { + this.stockConsume = stockConsume; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public String getIsCheck() { + return isCheck; + } + + public void setIsCheck(String isCheck) { + this.isCheck = isCheck; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProskuCon.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProskuCon.java new file mode 100644 index 0000000..e5912fa --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProskuCon.java @@ -0,0 +1,89 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +public class TbProskuCon implements Serializable { + private Integer id; + + private Integer shopId; + + private Integer productId; + + private Integer productSkuId; + + private Integer conInfoId; + + private BigDecimal surplusStock; + + private String status; + + private Date createTime; + + private static final long serialVersionUID = 1L; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + public Integer getProductId() { + return productId; + } + + public void setProductId(Integer productId) { + this.productId = productId; + } + + public Integer getProductSkuId() { + return productSkuId; + } + + public void setProductSkuId(Integer productSkuId) { + this.productSkuId = productSkuId; + } + + public Integer getConInfoId() { + return conInfoId; + } + + public void setConInfoId(Integer conInfoId) { + this.conInfoId = conInfoId; + } + + public BigDecimal getSurplusStock() { + return surplusStock; + } + + public void setSurplusStock(BigDecimal surplusStock) { + this.surplusStock = surplusStock; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status == null ? null : status.trim(); + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java index 2bdda19..1985f1a 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -85,6 +85,13 @@ public class CartService { private final RedisTemplate redisTemplate; + + @Autowired + private TbProskuConMapper tbProskuConMapper; + + @Autowired + TbConsInfoMapper tbConsInfoMapper; + public CartService(TbUserShopMsgMapper tbUserShopMsgMapper, WechatUtil wechatUtil, WxAccountUtil wxAccountUtil, TbShopOpenIdMapper shopOpenIdMapper, ProductService productService, TbProductMapper tbProductMapper, RedisTemplate redisTemplate) { this.tbUserShopMsgMapper = tbUserShopMsgMapper; this.wechatUtil = wechatUtil; @@ -171,6 +178,25 @@ public class CartService { } } } + + + + List proskuConList= tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(Integer.valueOf(skuId),Integer.valueOf(shopId),Integer.valueOf(productId)); + if(Objects.nonNull(proskuConList)&&proskuConList.size()>0){ + for (TbProskuCon proskuCon : proskuConList) { + if("1".equals(proskuCon.getStatus())){ + TbConsInfo consInfo= tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId()); + if("1".equals(consInfo.getIsCheck())){ + if(N.gt(proskuCon.getSurplusStock(),consInfo.getStockNumber().abs().subtract(consInfo.getStockConsume().abs()))){ + return Result.fail("商品:".concat(tbProduct.getName()).concat("对应的:").concat(consInfo.getConName()).concat("耗材不足")); + } + } + } + } + } + + + JSONArray jsonArray = new JSONArray(); BigDecimal amount = BigDecimal.ZERO; try{ diff --git a/src/main/resources/mapper/TbConsInfoMapper.xml b/src/main/resources/mapper/TbConsInfoMapper.xml new file mode 100644 index 0000000..ccd5270 --- /dev/null +++ b/src/main/resources/mapper/TbConsInfoMapper.xml @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + + + + id, shop_id, con_type_id, con_type_name, con_code, con_name, stock_number,price,stock_consume,status, con_unit, + laster_in_stock, con_warning, create_time, update_time,is_check + + + + delete from tb_cons_info + where id = #{id,jdbcType=INTEGER} + + + insert into tb_cons_info (id, shop_id, con_type_id, + con_type_name, con_code, con_name, + stock_number, con_unit, laster_in_stock, + con_warning, create_time, update_time + ) + values (#{id,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{conTypeId,jdbcType=INTEGER}, + #{conTypeName,jdbcType=VARCHAR}, #{conCode,jdbcType=VARCHAR}, #{conName,jdbcType=VARCHAR}, + #{stockNumber,jdbcType=DECIMAL}, #{conUnit,jdbcType=VARCHAR}, #{lasterInStock,jdbcType=DECIMAL}, + #{conWarning,jdbcType=DECIMAL}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP} + ) + + + insert into tb_cons_info + + + id, + + + shop_id, + + + con_type_id, + + + con_type_name, + + + con_code, + + + con_name, + + + stock_number, + + + con_unit, + + + laster_in_stock, + + + con_warning, + + + create_time, + + + update_time, + + + + + #{id,jdbcType=INTEGER}, + + + #{shopId,jdbcType=INTEGER}, + + + #{conTypeId,jdbcType=INTEGER}, + + + #{conTypeName,jdbcType=VARCHAR}, + + + #{conCode,jdbcType=VARCHAR}, + + + #{conName,jdbcType=VARCHAR}, + + + #{stockNumber,jdbcType=DECIMAL}, + + + #{conUnit,jdbcType=VARCHAR}, + + + #{lasterInStock,jdbcType=DECIMAL}, + + + #{conWarning,jdbcType=DECIMAL}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + + + update tb_cons_info + + + shop_id = #{shopId,jdbcType=INTEGER}, + + + con_type_id = #{conTypeId,jdbcType=INTEGER}, + + + con_type_name = #{conTypeName,jdbcType=VARCHAR}, + + + con_code = #{conCode,jdbcType=VARCHAR}, + + + con_name = #{conName,jdbcType=VARCHAR}, + + + stock_number = #{stockNumber,jdbcType=DECIMAL}, + + + con_unit = #{conUnit,jdbcType=VARCHAR}, + + + laster_in_stock = #{lasterInStock,jdbcType=DECIMAL}, + + + con_warning = #{conWarning,jdbcType=DECIMAL}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = #{updateTime,jdbcType=TIMESTAMP}, + + + where id = #{id,jdbcType=INTEGER} + + + update tb_cons_info + set shop_id = #{shopId,jdbcType=INTEGER}, + con_type_id = #{conTypeId,jdbcType=INTEGER}, + con_type_name = #{conTypeName,jdbcType=VARCHAR}, + con_code = #{conCode,jdbcType=VARCHAR}, + con_name = #{conName,jdbcType=VARCHAR}, + stock_number = #{stockNumber,jdbcType=DECIMAL}, + con_unit = #{conUnit,jdbcType=VARCHAR}, + laster_in_stock = #{lasterInStock,jdbcType=DECIMAL}, + con_warning = #{conWarning,jdbcType=DECIMAL}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + update_time = #{updateTime,jdbcType=TIMESTAMP}, + stock_consume=#{stockConsume,jdbcType=DECIMAL} + where id = #{id,jdbcType=INTEGER} + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/TbProskuConMapper.xml b/src/main/resources/mapper/TbProskuConMapper.xml new file mode 100644 index 0000000..0c4f495 --- /dev/null +++ b/src/main/resources/mapper/TbProskuConMapper.xml @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + id, shop_id,product_id ,product_sku_id, con_info_id, surplus_stock, status, create_time + + + + delete from tb_prosku_con + where id = #{id,jdbcType=INTEGER} + + + insert into tb_prosku_con (id, shop_id, product_sku_id, + con_info_id, surplus_stock, status, + create_time) + values (#{id,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{productSkuId,jdbcType=INTEGER}, + #{conInfoId,jdbcType=INTEGER}, #{surplusStock,jdbcType=DECIMAL}, #{status,jdbcType=VARCHAR}, + #{createTime,jdbcType=TIMESTAMP}) + + + insert into tb_prosku_con + + + id, + + + shop_id, + + + product_sku_id, + + + con_info_id, + + + surplus_stock, + + + status, + + + create_time, + + + + + #{id,jdbcType=INTEGER}, + + + #{shopId,jdbcType=INTEGER}, + + + #{productSkuId,jdbcType=INTEGER}, + + + #{conInfoId,jdbcType=INTEGER}, + + + #{surplusStock,jdbcType=DECIMAL}, + + + #{status,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + + + update tb_prosku_con + + + shop_id = #{shopId,jdbcType=INTEGER}, + + + product_sku_id = #{productSkuId,jdbcType=INTEGER}, + + + con_info_id = #{conInfoId,jdbcType=INTEGER}, + + + surplus_stock = #{surplusStock,jdbcType=DECIMAL}, + + + status = #{status,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + where id = #{id,jdbcType=INTEGER} + + + update tb_prosku_con + set shop_id = #{shopId,jdbcType=INTEGER}, + product_sku_id = #{productSkuId,jdbcType=INTEGER}, + con_info_id = #{conInfoId,jdbcType=INTEGER}, + surplus_stock = #{surplusStock,jdbcType=DECIMAL}, + status = #{status,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=TIMESTAMP} + where id = #{id,jdbcType=INTEGER} + + + + + + + + + + + + + + +