From d042b14c6a82a9d25482da7a6ad8ab2b3beeba54 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: Mon, 15 Jul 2024 11:05:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=80=97=E6=9D=90=E6=B6=88?= =?UTF-8?q?=E8=80=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/service/ConsService.java | 33 ++++++++++++++----- .../resources/mapper/TbConsInfoMapper.xml | 3 +- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ConsService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ConsService.java index 5575562..75bb673 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ConsService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ConsService.java @@ -11,6 +11,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; +import java.sql.Timestamp; import java.util.*; @Slf4j @@ -76,32 +77,46 @@ public class ConsService { amount=proskuCon.getSurplusStock().multiply(new BigDecimal(orderDetail.getNum())); flow.setAmount(amount); - flow.setBalance(tbConsInfo.getStockNumber().subtract(amount).subtract(tbConsInfo.getStockConsume())); + flow.setBizCode("createCart"); flow.setBizName("销售扣除"); flow.setBizType("-"); + + tbConsInfo.setStockConsume(tbConsInfo.getStockConsume().add(amount)); + flow.setBalance(tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume())); + tbConsInfo.setUpdateTime(new Timestamp(System.currentTimeMillis())); + }else if("delete".equals(type)){ amount=proskuCon.getSurplusStock().multiply(new BigDecimal(orderDetail.getNum())).negate(); flow.setAmount(amount.abs()); - flow.setBalance(tbConsInfo.getStockNumber().subtract(amount).subtract(tbConsInfo.getStockConsume())); flow.setBizCode("cancelCart"); flow.setBizName("退单返还"); flow.setBizType("+"); + + tbConsInfo.setStockConsume(tbConsInfo.getStockConsume().add(amount)); + + flow.setBalance(tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume())); + tbConsInfo.setUpdateTime(new Timestamp(System.currentTimeMillis())); } - ConsInfoPO consInfoPO=new ConsInfoPO(tbConsInfo.getId(),amount); - consInfoPOS.add(consInfoPO); +// ConsInfoPO consInfoPO=new ConsInfoPO(tbConsInfo.getId(),amount); +// consInfoPOS.add(consInfoPO); flow.setCreateTime(new Date()); - flow.setUpdateTime(new Date()); - consInfoFlows.add(flow); +// flow.setUpdateTime(new Date()); +// consInfoFlows.add(flow); + + tbConsInfoMapper.updateByPrimaryKey(tbConsInfo); + tbConsInfoFlowMapper.insert(flow); + + } } //更新耗材信息 - tbConsInfoMapper.batchStock(consInfoPOS); - //记录更新日志 - tbConsInfoFlowMapper.insertBatch(consInfoFlows); +// tbConsInfoMapper.batchStock(consInfoPOS); +// //记录更新日志 +// tbConsInfoFlowMapper.insertBatch(consInfoFlows); } } } diff --git a/src/main/resources/mapper/TbConsInfoMapper.xml b/src/main/resources/mapper/TbConsInfoMapper.xml index 0949fca..92ec252 100644 --- a/src/main/resources/mapper/TbConsInfoMapper.xml +++ b/src/main/resources/mapper/TbConsInfoMapper.xml @@ -174,7 +174,8 @@ laster_in_stock = #{lasterInStock,jdbcType=DECIMAL}, con_warning = #{conWarning,jdbcType=DECIMAL}, create_time = #{createTime,jdbcType=TIMESTAMP}, - update_time = #{updateTime,jdbcType=TIMESTAMP} + update_time = #{updateTime,jdbcType=TIMESTAMP}, + stock_consume=#{stockConsume,jdbcType=DECIMAL} where id = #{id,jdbcType=INTEGER}