From 83988f934fc102a4c792d41872a5e4c51066804e Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Sat, 3 Aug 2024 13:45:41 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E5=9B=BE=E6=A0=87=E5=8F=8A=E5=9C=B0=E5=9D=80=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E6=9B=B4=E6=96=B0=E5=BA=97=E9=93=BA=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=90=8E=E5=BA=97=E9=93=BA=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E8=A6=81=E6=96=B0=E5=A2=9E=E5=AD=97=E6=AE=B5=EF=BC=8C=E7=8E=B0?= =?UTF-8?q?=E5=9C=A8=E7=94=A8=E4=BD=9C=E5=BA=97=E9=93=BA=E4=BA=8C=E7=BB=B4?= =?UTF-8?q?=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cc/hiver/mall/controller/ShopController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java index 337e6965..b6245094 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java @@ -291,8 +291,9 @@ public class ShopController { return ResultUtil.error("店铺id不能为空"); } final Shop oldShop = shopService.get(id); - if(shop.getShopIcon() != null){ - oldShop.setShopIcon(shop.getShopIcon()); + // 20240803 不更新店铺图标,可更新店铺地址 + if(shop.getShopAddress() != null){ + oldShop.setShopAddress(shop.getShopAddress()); } if(shop.getRemark() != null){ oldShop.setRemark(shop.getRemark()); From fc2a462ce0edd7c50aa84c34c6a82e18f331563b Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Sat, 3 Aug 2024 18:45:57 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hiver-admin/src/main/resources/application.yml | 4 ++-- hiver-admin/test-output/test-report.html | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hiver-admin/src/main/resources/application.yml b/hiver-admin/src/main/resources/application.yml index b423c524..e0ca79a7 100644 --- a/hiver-admin/src/main/resources/application.yml +++ b/hiver-admin/src/main/resources/application.yml @@ -330,10 +330,10 @@ ignored: - /hiver/app/sale/get/** - /hiver/app/return/list - /hiver/app/return/get/** + # 根据商品id获取商品子图,分享订单,客户查看商品子图使用 + - /hiver/app/productPicture/getProductPictureByProductId # # 临时增加 - - /hiver/app/purchase/getPurchaseListOfSupplier - - /hiver/app/purchase/cancelPurchase # 限流及黑名单不拦截的路径 limitUrls: - /**/*.js diff --git a/hiver-admin/test-output/test-report.html b/hiver-admin/test-output/test-report.html index f600fc08..53d45f86 100644 --- a/hiver-admin/test-output/test-report.html +++ b/hiver-admin/test-output/test-report.html @@ -35,7 +35,7 @@ Hiver
  • - 02, 2024 22:25:05 + 03, 2024 18:35:09
  • @@ -84,7 +84,7 @@

    passTest

    -

    22:25:06 / 0.015 secs

    +

    18:35:10 / 0.018 secs

    @@ -92,9 +92,9 @@
    #test-id=1
    passTest
    -08.02.2024 22:25:06 -08.02.2024 22:25:06 -0.015 secs +08.03.2024 18:35:10 +08.03.2024 18:35:10 +0.018 secs
    @@ -104,7 +104,7 @@ Pass - 22:25:06 + 18:35:10 Test passed @@ -128,13 +128,13 @@

    Started

    -

    02, 2024 22:25:05

    +

    03, 2024 18:35:09

    Ended

    -

    02, 2024 22:25:06

    +

    03, 2024 18:35:10

    From d622e9ec72b82088ebd5d16eeb16a1c358656c65 Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Sun, 4 Aug 2024 08:41:17 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E5=BA=97=E9=93=BA=E8=8E=B7=E5=8F=96=E5=BA=97=E9=93=BA=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=EF=BC=88=E5=AD=98=E7=9A=84=E6=98=AF=E4=BA=8C=E7=BB=B4?= =?UTF-8?q?=E7=A0=81=EF=BC=89=EF=BC=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 10 ++-- hiver-admin/test-output/test-report.html | 16 +++--- .../hiver/mall/controller/ShopController.java | 50 ++++++++++++++----- 3 files changed, 52 insertions(+), 24 deletions(-) diff --git a/hiver-admin/src/main/resources/application.yml b/hiver-admin/src/main/resources/application.yml index e0ca79a7..4afd4e51 100644 --- a/hiver-admin/src/main/resources/application.yml +++ b/hiver-admin/src/main/resources/application.yml @@ -25,8 +25,8 @@ spring: timeout-per-shutdown-phase: 10S # 数据源 datasource: - url: jdbc:mysql://154.8.162.157:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true -# url: jdbc:mysql://8.140.198.243:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true +# url: jdbc:mysql://154.8.162.157:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true + url: jdbc:mysql://8.140.198.243:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true username: reddoor # Jasypt加密 可到common-utils中找到JasyptUtil加解密工具类生成加密结果 格式为ENC(加密结果) 以下解密结果为123456 password: ENC(Zla4U4+yRLPhicvuX2TmiEgxEpzP4dk8BHzFDEtiEhwLQIIaftZrrEUJZce6efoe) @@ -67,8 +67,8 @@ spring: ddl-auto: update # Redis 若设有密码自行添加配置password redis: - host: 154.8.162.157 -# host: 8.140.198.243 +# host: 154.8.162.157 + host: 8.140.198.243 password: reddoor168 # 数据库索引 默认0 database: 1 @@ -332,6 +332,8 @@ ignored: - /hiver/app/return/get/** # 根据商品id获取商品子图,分享订单,客户查看商品子图使用 - /hiver/app/productPicture/getProductPictureByProductId + # 根据店铺id获取店铺二维码信息 + - /hiver/app/shop/getshopIconById # # 临时增加 # 限流及黑名单不拦截的路径 diff --git a/hiver-admin/test-output/test-report.html b/hiver-admin/test-output/test-report.html index 53d45f86..65e80678 100644 --- a/hiver-admin/test-output/test-report.html +++ b/hiver-admin/test-output/test-report.html @@ -35,7 +35,7 @@ Hiver
  • - 03, 2024 18:35:09 + 03, 2024 19:26:13
  • @@ -84,7 +84,7 @@

    passTest

    -

    18:35:10 / 0.018 secs

    +

    19:26:14 / 0.017 secs

    @@ -92,9 +92,9 @@
    #test-id=1
    passTest
    -08.03.2024 18:35:10 -08.03.2024 18:35:10 -0.018 secs +08.03.2024 19:26:14 +08.03.2024 19:26:14 +0.017 secs
    @@ -104,7 +104,7 @@ Pass - 18:35:10 + 19:26:14 Test passed @@ -128,13 +128,13 @@

    Started

    -

    03, 2024 18:35:09

    +

    03, 2024 19:26:13

    Ended

    -

    03, 2024 18:35:10

    +

    03, 2024 19:26:14

    diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java index b6245094..4c0655bd 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java @@ -254,51 +254,77 @@ public class ShopController { @RequestMapping(value = "/getShopRebateBalance", method = RequestMethod.POST) @ApiOperation("获取返佣余额及累计返佣") - public Result getShopRebateBalance(){ - final Map shopRebateBalance = shopService.getShopRebateBalance(); + public Result getShopRebateBalance() { + final Map shopRebateBalance = shopService.getShopRebateBalance(); return ResultUtil.data(shopRebateBalance); } /** * 根据店铺id获取店铺信息 - * @author 王富康 - * @date 2024/7/27 + * * @param id * @return Result + * @author 王富康 + * @date 2024/7/27 */ @RequestMapping(value = "/getShopInfoById", method = RequestMethod.POST) @ApiOperation("根据店铺id获取店铺信息") - public Result getShopInfoById(String id){ - if(StringUtils.isEmpty(id)){ + public Result getShopInfoById(String id) { + if (StringUtils.isEmpty(id)) { return ResultUtil.error("店铺id不能为空"); } - final Shop shop = shopService.findById(id); + final Shop shop = shopService.findById(id); return ResultUtil.data(shop); } /** * 更新店铺图标及备注 - * @author 王富康 - * @date 2024/7/27 + * * @param shop * @return Result + * @author 王富康 + * @date 2024/7/27 */ @RequestMapping(value = "/updateShopIconAndRemark", method = RequestMethod.POST) @ApiOperation("更新店铺图标及备注") public Result updateShopIconAndRemark(@RequestBody Shop shop) { final String id = shop.getId(); - if(StringUtils.isEmpty(id)){ + if (StringUtils.isEmpty(id)) { return ResultUtil.error("店铺id不能为空"); } final Shop oldShop = shopService.get(id); // 20240803 不更新店铺图标,可更新店铺地址 - if(shop.getShopAddress() != null){ + if (shop.getShopAddress() != null) { oldShop.setShopAddress(shop.getShopAddress()); } - if(shop.getRemark() != null){ + if (shop.getRemark() != null) { oldShop.setRemark(shop.getRemark()); } shopService.update(oldShop); return ResultUtil.success("更新成功"); } + + /** + * 根据店铺id获取店铺shopIcon(二维码信息) + * + * @param id + * @return Result + * @author 王富康 + * @date 2024/8/3 + */ + @RequestMapping(value = "/getshopIconById", method = RequestMethod.POST) + @ApiOperation("根据店铺id获取店铺shopIcon") + public Result getshopIconById(String id) { + if (StringUtils.isEmpty(id)) { + return ResultUtil.error("店铺id不能为空"); + } + final Shop shop = shopService.findById(id); + if (shop == null) { + return ResultUtil.error("店铺不存在"); + } + if (StringUtils.isEmpty(shop.getShopIcon())) { + return ResultUtil.error("店铺图标不存在"); + } + return ResultUtil.data(shop.getShopIcon()); + } } From 613404c14d7acdca435169f0cefd17aba22bd0eb Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Sun, 4 Aug 2024 14:38:18 +0800 Subject: [PATCH 4/6] =?UTF-8?q?app/product/getShareList=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=9D=87=E8=89=B2=E5=9D=87=E7=A0=81=E7=9A=84=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E6=95=B0=E6=9F=A5=E8=AF=A2=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 8 ++++---- hiver-admin/test-output/test-report.html | 16 +++++++-------- .../cc/hiver/mall/dao/mapper/StockMapper.java | 2 ++ .../cc/hiver/mall/pojo/vo/ProductPageVO.java | 3 +++ .../mall/service/mybatis/StockService.java | 9 +++++++++ .../mybatis/ProductServiceImpl.java | 20 +++++++++++++++++++ .../serviceimpl/mybatis/StockServiceImpl.java | 5 +++++ .../src/main/resources/mapper/StockMapper.xml | 13 ++++++++++++ 8 files changed, 64 insertions(+), 12 deletions(-) diff --git a/hiver-admin/src/main/resources/application.yml b/hiver-admin/src/main/resources/application.yml index 4afd4e51..5350c274 100644 --- a/hiver-admin/src/main/resources/application.yml +++ b/hiver-admin/src/main/resources/application.yml @@ -25,8 +25,8 @@ spring: timeout-per-shutdown-phase: 10S # 数据源 datasource: -# url: jdbc:mysql://154.8.162.157:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true - url: jdbc:mysql://8.140.198.243:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true + url: jdbc:mysql://154.8.162.157:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true +# url: jdbc:mysql://8.140.198.243:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true username: reddoor # Jasypt加密 可到common-utils中找到JasyptUtil加解密工具类生成加密结果 格式为ENC(加密结果) 以下解密结果为123456 password: ENC(Zla4U4+yRLPhicvuX2TmiEgxEpzP4dk8BHzFDEtiEhwLQIIaftZrrEUJZce6efoe) @@ -67,8 +67,8 @@ spring: ddl-auto: update # Redis 若设有密码自行添加配置password redis: -# host: 154.8.162.157 - host: 8.140.198.243 + host: 154.8.162.157 +# host: 8.140.198.243 password: reddoor168 # 数据库索引 默认0 database: 1 diff --git a/hiver-admin/test-output/test-report.html b/hiver-admin/test-output/test-report.html index 65e80678..de2c08d2 100644 --- a/hiver-admin/test-output/test-report.html +++ b/hiver-admin/test-output/test-report.html @@ -35,7 +35,7 @@ Hiver
  • - 03, 2024 19:26:13 + 04, 2024 12:12:02
  • @@ -84,7 +84,7 @@

    passTest

    -

    19:26:14 / 0.017 secs

    +

    12:12:02 / 0.016 secs

    @@ -92,9 +92,9 @@
    #test-id=1
    passTest
    -08.03.2024 19:26:14 -08.03.2024 19:26:14 -0.017 secs +08.04.2024 12:12:02 +08.04.2024 12:12:02 +0.016 secs
    @@ -104,7 +104,7 @@ Pass - 19:26:14 + 12:12:02 Test passed @@ -128,13 +128,13 @@

    Started

    -

    03, 2024 19:26:13

    +

    04, 2024 12:12:02

    Ended

    -

    03, 2024 19:26:14

    +

    04, 2024 12:12:02

    diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockMapper.java index 2c504b6f..5202f584 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockMapper.java @@ -56,4 +56,6 @@ public interface StockMapper extends BaseMapper { void batchDeleteStockByProductIds(@Param("productIdList") List productIdList); void batchReduceStockByLog(@Param("stockLogList") List stockLogList); + + List getDefaultStockCount(@Param("productIdList") List productIdList); } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductPageVO.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductPageVO.java index 0ccac3fe..5c1bcc2c 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductPageVO.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductPageVO.java @@ -106,4 +106,7 @@ public class ProductPageVO { @ApiModelProperty(value = "商品子图") private List productPictures; + + @ApiModelProperty(value = "商品均色均码总库存") + private Integer defaultStockCount; } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockService.java index 9d35c941..2282ef2e 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockService.java @@ -87,4 +87,13 @@ public interface StockService extends IService { * @param stockLogList */ void batchReduceStockByLog(List stockLogList); + + /** + * 获取某些商品均色均码的库存数 + * @author 王富康 + * @date 2024/8/4 + * @param productIdList + * @return List + */ + List getDefaultStockCount(List productIdList); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java index 2987612c..72e71e9d 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java @@ -7,6 +7,7 @@ import cc.hiver.core.entity.User; import cc.hiver.mall.common.constant.PurchaseConstant; import cc.hiver.mall.dao.mapper.ProductMapper; import cc.hiver.mall.entity.Product; +import cc.hiver.mall.entity.Stock; import cc.hiver.mall.pojo.dto.SaleDetailDTO; import cc.hiver.mall.pojo.dto.SaleDetailQueryDTO; import cc.hiver.mall.pojo.dto.SaleQueryDTO; @@ -16,6 +17,7 @@ import cc.hiver.mall.productpicture.entity.ProductPicture; import cc.hiver.mall.productpicture.service.ProductPictureService; import cc.hiver.mall.service.mybatis.ProductCategoryService; import cc.hiver.mall.service.mybatis.ProductService; +import cc.hiver.mall.service.mybatis.StockService; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -44,6 +46,9 @@ public class ProductServiceImpl extends ServiceImpl impl @Autowired private ProductCategoryService productCategoryService; + @Autowired + private StockService stockService; + @Override public IPage getShareList(ProductPageQuery productPageQuery) { final Page page = new Page<>(productPageQuery.getPageNum(), productPageQuery.getPageSize()); @@ -72,6 +77,21 @@ public class ProductServiceImpl extends ServiceImpl impl productPageVO.setProductPictures(productPictureMap.get(productId)); } } + // 获取商品均色均码的库存数 + List stockList = stockService.getDefaultStockCount(productIdList); + // 处理为map, key为productId + final Map stockMap = new HashMap<>(); + for (Stock stock : stockList) { + stockMap.put(stock.getProductId(), stock); + } + for (ProductPageVO productPageVO : list) { + final String productId = productPageVO.getId(); + if (stockMap.containsKey(productId)) { + productPageVO.setDefaultStockCount(stockMap.get(productId).getStockCount()); + }else{ + productPageVO.setDefaultStockCount(0); + } + } } page.setRecords(list); return page; diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java index 0dd583f7..860c67a0 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java @@ -1181,4 +1181,9 @@ public class StockServiceImpl extends ServiceImpl implements public void batchReduceStockByLog(List stockLogList) { stockMapper.batchReduceStockByLog(stockLogList); } + + @Override + public List getDefaultStockCount(List productIdList) { + return stockMapper.getDefaultStockCount(productIdList); + } } diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml index 37e1b968..7cf654ee 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml @@ -686,4 +686,17 @@ update t_stock set stock_count = stock_count - #{item.productCount} WHERE product_id = #{item.productId} and attribute_list = #{item.attributeList} + + \ No newline at end of file From ca0ffb9f8032ed31b5cc36efce95a1b7996af093 Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Sun, 4 Aug 2024 16:59:45 +0800 Subject: [PATCH 5/6] =?UTF-8?q?AI=E5=9B=BE=E7=89=87=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E7=9C=9F=E5=88=A0=E9=99=A4=E8=AF=A6=E6=83=85=E5=92=8Cstocklog;?= =?UTF-8?q?=20=E6=92=A4=E9=94=80=E9=87=87=E8=B4=AD=E5=8D=95=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E5=88=A0=E9=99=A4=E5=95=86=E5=93=81=EF=BC=8C=E5=8F=AA?= =?UTF-8?q?=E5=9B=9E=E9=80=80=E5=BA=93=E5=AD=98=E6=95=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hiver-admin/test-output/test-report.html | 14 ++--- .../mall/dao/mapper/PurchaseDetailMapper.java | 2 + .../hiver/mall/dao/mapper/StockLogMapper.java | 2 + .../cc/hiver/mall/entity/PurchaseDetail.java | 4 ++ .../cc/hiver/mall/pojo/vo/PurchaseOcrVo.java | 3 ++ .../mybatis/PurchaseDetailService.java | 2 + .../mall/service/mybatis/StockLogService.java | 2 + .../mybatis/PurchaseDetailServiceImpl.java | 5 ++ .../mybatis/PurchaseServiceImpl.java | 54 ++----------------- .../mybatis/StockLogServiceImpl.java | 5 ++ .../serviceimpl/mybatis/StockServiceImpl.java | 6 +-- .../java/cc/hiver/mall/utils/AliOcrUtil.java | 2 + .../resources/mapper/PurchaseDetailMapper.xml | 38 ++++++++++--- .../main/resources/mapper/StockLogMapper.xml | 9 +++- 14 files changed, 79 insertions(+), 69 deletions(-) diff --git a/hiver-admin/test-output/test-report.html b/hiver-admin/test-output/test-report.html index de2c08d2..a9d737d9 100644 --- a/hiver-admin/test-output/test-report.html +++ b/hiver-admin/test-output/test-report.html @@ -35,7 +35,7 @@ Hiver
  • - 04, 2024 12:12:02 + 04, 2024 16:50:15
  • @@ -84,7 +84,7 @@

    passTest

    -

    12:12:02 / 0.016 secs

    +

    16:50:16 / 0.016 secs

    @@ -92,8 +92,8 @@
    #test-id=1
    passTest
    -08.04.2024 12:12:02 -08.04.2024 12:12:02 +08.04.2024 16:50:16 +08.04.2024 16:50:16 0.016 secs
    @@ -104,7 +104,7 @@ Pass - 12:12:02 + 16:50:16 Test passed @@ -128,13 +128,13 @@

    Started

    -

    04, 2024 12:12:02

    +

    04, 2024 16:50:15

    Ended

    -

    04, 2024 12:12:02

    +

    04, 2024 16:50:16

    diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseDetailMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseDetailMapper.java index f6a85a52..6d0b3b83 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseDetailMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseDetailMapper.java @@ -54,4 +54,6 @@ public interface PurchaseDetailMapper extends BaseMapper { * @return List */ List getPurchaseDetailListByProductIds(@Param("productIdList") List productIdList,@Param("id") String id); + + void realDeleteByPurchaseId(@Param("purchaseId") String purchaseId); } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockLogMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockLogMapper.java index e91c764a..af52e705 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockLogMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockLogMapper.java @@ -45,4 +45,6 @@ public interface StockLogMapper extends BaseMapper { List getPurchaseDetails(@Param("purchaseIdList") List purchaseIdList); List getByProductIds(@Param("purchaseId") String purchaseId,@Param("productIdList") List productIdList); + + void realDeleteByPurchaseId(@Param("purchaseId") String purchaseId); } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/PurchaseDetail.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/PurchaseDetail.java index e974bf6f..5d16139c 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/PurchaseDetail.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/PurchaseDetail.java @@ -98,6 +98,10 @@ public class PurchaseDetail extends HiverBaseEntity { @ApiModelProperty(value = "识别图片id") private String ocrPicturePath; + + @ApiModelProperty(value = "排序") + private Integer sort; + @Transient @TableField(exist = false) @ApiModelProperty(value = "入库商品规格明细表") diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/PurchaseOcrVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/PurchaseOcrVo.java index 11b76a67..f130493a 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/PurchaseOcrVo.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/PurchaseOcrVo.java @@ -21,6 +21,9 @@ public class PurchaseOcrVo { @ApiModelProperty(value = "数量") private Integer productCount; + @ApiModelProperty(value = "排序") + private Integer sort; + @ApiModelProperty(value = "单位") private CopyOnWriteArrayList attributeList; } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseDetailService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseDetailService.java index 2ed062da..8fcabc44 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseDetailService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseDetailService.java @@ -21,6 +21,8 @@ public interface PurchaseDetailService extends IService { void deleteByPurchaseId(String purchaseId); + void realDeleteByPurchaseId(String purchaseId); + List getPurchaseDetails(List purchaseIdList); /** diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockLogService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockLogService.java index d903a5fb..c6eb9390 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockLogService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockLogService.java @@ -25,4 +25,6 @@ public interface StockLogService extends IService { * @return List */ List getByProductIds(String purchaseId, String productIds); + + void realDeleteByPurchaseId(String purchaseId); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseDetailServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseDetailServiceImpl.java index bd63197f..ac6cc886 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseDetailServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseDetailServiceImpl.java @@ -82,6 +82,11 @@ public class PurchaseDetailServiceImpl extends ServiceImpl getPurchaseDetails(List purchaseIdList) { return purchaseDetailMapper.getPurchaseDetails(purchaseIdList); diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java index 1c615b2e..3d98cd95 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java @@ -436,7 +436,7 @@ public class PurchaseServiceImpl extends ServiceImpl i stockLogMap.put(mapKey, stockLogs); } } - final Map> purchaseDetailMap = new HashMap<>(); + final LinkedHashMap> purchaseDetailMap = new LinkedHashMap<>(); for (PurchaseDetail purchaseDetail : purchaseDetails) { // 这里对purchaseDetail做个合并处理,优先根据商品id分组,如果商品id为空,那就就根据商品货号分组,如果商品货号为空,则根据商品名称分组, // 重复的直接覆盖即可 @@ -651,7 +651,7 @@ public class PurchaseServiceImpl extends ServiceImpl i for (PurchaseDetail purchaseDetail : byPurchaseIdList) { productIdList.add(purchaseDetail.getProductId()); } - // 查询该商品除当前入库单的其他的入库记录 + // 查询该商品除当前入库单的其他的入库记录,用于计算平均采购价 final List purductPurchaseList = purchaseDetailService.getPurchaseDetailListByProductIds(productIdList, id); // 封装为商品id为key,List为value 的map final Map> purductPurchaseMap = new HashMap<>(); @@ -665,59 +665,15 @@ public class PurchaseServiceImpl extends ServiceImpl i purductPurchaseMap.put(productId, purchaseDetails); } } - // 查询该商品的销售记录 - final List purductSaleList = saleDetailService.getSaleDetailListByProductIds(productIdList); - // 封装为商品id为key,List为value 的map - final Map> purductSaleMap = new HashMap<>(); - for (SaleDetail saleDetail : purductSaleList) { - final String productId = saleDetail.getProductId(); - if (purductSaleMap.containsKey(productId)) { - purductSaleMap.get(productId).add(saleDetail); - } else { - final List saleDetails = new ArrayList<>(); - saleDetails.add(saleDetail); - purductSaleMap.put(productId, saleDetails); - } - } - // - final StringJoiner needDeleteProductId = new StringJoiner(","); - final StringJoiner needDeleteStockProductId = new StringJoiner(","); - final StringJoiner needReduceStockProductId = new StringJoiner(","); - - for (PurchaseDetail purchaseDetail : byPurchaseIdList) { - final String productId = purchaseDetail.getProductId(); - if (!purductPurchaseMap.containsKey(productId) && !purductSaleMap.containsKey(productId)) { - // 可以删除商品的相关信息 - needDeleteProductId.add(productId); - // 库存删除 - needDeleteStockProductId.add(productId); - } else { - // 商品保留,库存扣减 - needReduceStockProductId.add(productId); - } + final List stockLogList = stockLogService.getByPurchaseId(id); + // 根据入库记录减掉库存数 + stockService.batchReduceStockByLog(stockLogList); - } - // 执行删除商品 - if (StringUtils.isNotEmpty(needDeleteProductId.toString())) { - productService.batchDeleteProduct(needDeleteProductId.toString()); - } - // 执行删除库存 - if (StringUtils.isNotEmpty(needReduceStockProductId.toString())) { - stockService.batchDeleteStockByProductIds(needDeleteStockProductId.toString()); - } - // 执行扣减库存 - if (StringUtils.isNotEmpty(needReduceStockProductId.toString())) { - // 获取当前入库单各商品的规格及数量信息 - final List stockLogList = stockLogService.getByProductIds(id, needReduceStockProductId.toString()); - // 根据入库记录减掉库存数 - stockService.batchReduceStockByLog(stockLogList); - } // 4. 根据采购单id删除库存记录 stockLogService.deleteByPurchaseId(id); // 5. 计算平均采购价 // 获取该商品的历次入库记录,排除掉本次入库记录 入库的价格*入库数量/入库总数量 - final Map productPurchasePriceMap = new HashMap<>(); final List productList = new ArrayList<>(); for (Map.Entry> stringListEntry : purductPurchaseMap.entrySet()) { diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockLogServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockLogServiceImpl.java index 3ccab6fe..b81fed99 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockLogServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockLogServiceImpl.java @@ -57,4 +57,9 @@ public class StockLogServiceImpl extends ServiceImpl i return stockLogMapper.getByProductIds(purchaseId, productIdList); } + @Override + public void realDeleteByPurchaseId(String purchaseId) { + stockLogMapper.realDeleteByPurchaseId(purchaseId); + } + } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java index 860c67a0..7d2b0e59 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java @@ -736,9 +736,9 @@ public class StockServiceImpl extends ServiceImpl implements insertFlag = false; } - // 先根据入库单id 删除详情及库存履历表信息 - purchaseDetailService.deleteByPurchaseId(purchaseId); - stockLogService.deleteByPurchaseId(purchaseId); + // 先根据入库单id 删除详情及库存履历表信息(真删除) + purchaseDetailService.realDeleteByPurchaseId(purchaseId); + stockLogService.realDeleteByPurchaseId(purchaseId); // 获取前台入库商品信息 final List purchaseDetails = purchaseVo.getPurchaseDetails(); diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/utils/AliOcrUtil.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/utils/AliOcrUtil.java index 68cf0efd..b23b6d2c 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/utils/AliOcrUtil.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/utils/AliOcrUtil.java @@ -654,6 +654,7 @@ public class AliOcrUtil { } purchaseOcrVo.setAttributeList(attributeList); + purchaseOcrVo.setSort(i); purchaseOcrVos.add(purchaseOcrVo); // 处理当前识别的货号及名称,现在需要特殊处理的 是货号:去掉“/”,或者是“/"在货号或者名称中间的,需要分隔为货号及名称 @@ -809,6 +810,7 @@ public class AliOcrUtil { } stockLogList.add(stockLog); purchaseDetail.setStockLogList1(stockLogList); + purchaseDetail.setSort(purchaseOcrVo.getSort()); // 如果货号为空,那么就拿商品名称作为key purchaseDetailMap.put(StringUtils.isEmpty(productSn) ? productName : productSn, purchaseDetail); } diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml index d4119787..3454961b 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml @@ -30,6 +30,7 @@ + @@ -93,7 +94,7 @@ id, create_by, create_time, del_flag, update_by, update_time, purchase_id, product_id, product_name, unit, shop_id, category_id, attribute_list, supplier_id,supplier_name, product_sn, barcode, price, purchase_price, wholesale_price, product_picture, product_video, - product_intro, sales_week, tail_warn, print_barcode, product_count,ocr_picture_path + product_intro, sales_week, tail_warn, print_barcode, product_count,ocr_picture_path,sort @@ -414,6 +421,9 @@ ocr_picture_path = #{record.ocrPicturePath,jdbcType=VARCHAR}, + + sort = #{record.sort,jdbcType=INTEGER}, + @@ -448,7 +458,8 @@ tail_warn = #{record.tailWarn,jdbcType=INTEGER}, print_barcode = #{record.printBarcode,jdbcType=VARCHAR}, product_count = #{record.productCount,jdbcType=INTEGER}, - ocr_picture_path = #{record.ocrPicturePath,jdbcType=VARCHAR} + ocr_picture_path = #{record.ocrPicturePath,jdbcType=VARCHAR}, + sort = #{record.sort,jdbcType=INTEGER} @@ -537,6 +548,9 @@ ocr_picture_path = #{ocrPicturePath,jdbcType=VARCHAR}, + + sort = #{sort,jdbcType=INTEGER}, + where id = #{id,jdbcType=VARCHAR} @@ -568,7 +582,8 @@ tail_warn = #{tailWarn,jdbcType=INTEGER}, print_barcode = #{printBarcode,jdbcType=VARCHAR}, product_count = #{productCount,jdbcType=INTEGER}, - ocr_picture_path = #{ocrPicturePath,jdbcType=VARCHAR} + ocr_picture_path = #{ocrPicturePath,jdbcType=VARCHAR}, + sort = #{sort,jdbcType=INTEGER} where id = #{id,jdbcType=VARCHAR} @@ -578,7 +593,7 @@ from t_purchase_detail where purchase_id = #{id,jdbcType=VARCHAR} - order by create_time desc + order by create_time desc ,sort asc select diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/StockLogMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/StockLogMapper.xml index ddad9cdb..af5803e9 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/StockLogMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/StockLogMapper.xml @@ -448,10 +448,15 @@ - update t_stock_log set del_flag ='1' - where order_id = #{purchaseId,jdbcType=VARCHAR} + update t_stock_log set del_flag = '1' where order_id = #{purchaseId,jdbcType=VARCHAR} + + + delete from t_stock_log + where order_id = #{purchaseId,jdbcType=VARCHAR} + + update t_stock_log set purchase_price = #{item.purchasePrice} WHERE product_id = #{item.productId} and purchase_price is null From 8e52e4d51d87b5722e9d21820e964138801f78e2 Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Sun, 4 Aug 2024 18:36:25 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E3=80=81=E4=BE=9B?= =?UTF-8?q?=E5=BA=94=E5=95=86=E6=9C=9F=E6=9C=AB=E6=AC=A0=E6=AC=BE=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hiver-admin/test-output/test-report.html | 16 ++--- .../bill/service/impl/BillServiceImpl.java | 58 ++++++++++--------- .../mall/dao/mapper/DealingsRecordMapper.java | 4 ++ .../mybatis/DealingsRecordService.java | 20 +++++++ .../mybatis/DealingsRecordServiceImpl.java | 10 ++++ .../resources/mapper/DealingsRecordMapper.xml | 47 +++++++++++++++ .../main/resources/mapper/PurchaseMapper.xml | 1 + 7 files changed, 120 insertions(+), 36 deletions(-) diff --git a/hiver-admin/test-output/test-report.html b/hiver-admin/test-output/test-report.html index a9d737d9..41886bb1 100644 --- a/hiver-admin/test-output/test-report.html +++ b/hiver-admin/test-output/test-report.html @@ -35,7 +35,7 @@ Hiver
  • - 04, 2024 16:50:15 + 04, 2024 18:32:59
  • @@ -84,7 +84,7 @@

    passTest

    -

    16:50:16 / 0.016 secs

    +

    18:32:59 / 0.026 secs

    @@ -92,9 +92,9 @@
    #test-id=1
    passTest
    -08.04.2024 16:50:16 -08.04.2024 16:50:16 -0.016 secs +08.04.2024 18:32:59 +08.04.2024 18:32:59 +0.026 secs
    @@ -104,7 +104,7 @@ Pass - 16:50:16 + 18:32:59 Test passed @@ -128,13 +128,13 @@

    Started

    -

    04, 2024 16:50:15

    +

    04, 2024 18:32:59

    Ended

    -

    04, 2024 16:50:16

    +

    04, 2024 18:32:59

    diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/service/impl/BillServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/service/impl/BillServiceImpl.java index 764dc485..3109f309 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/service/impl/BillServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/service/impl/BillServiceImpl.java @@ -81,7 +81,7 @@ public class BillServiceImpl implements BillService { if (saleArrearsVo != null) { customerBillDataVo.setArrears(saleArrearsVo.getArrears()); customerBillDataVo.setTotalSale(saleArrearsVo.getTotalSale()); - }else{ + } else { customerBillDataVo.setArrears(BigDecimal.ZERO); customerBillDataVo.setTotalSale(BigDecimal.ZERO); } @@ -90,7 +90,7 @@ public class BillServiceImpl implements BillService { final ArrearsVo returnSaleArrearsVo = returnSaleService.getTotalReturn(customerBillQueryVo); if (returnSaleArrearsVo != null) { customerBillDataVo.setTotalReturn(returnSaleArrearsVo.getTotalReturn()); - }else{ + } else { customerBillDataVo.setTotalReturn(BigDecimal.ZERO); } // 根据客户id及日期范围对账单明细 @@ -99,13 +99,13 @@ public class BillServiceImpl implements BillService { // 获取saleId,去查询销售单的商品明细,及退货单的商品明细 final List saleIdList = new ArrayList<>(); - if(records.isEmpty()){ + if (records.isEmpty()) { //未开单,查询客户欠款,作为初期欠款和期末欠款 - final Debt debt = debtService.selectByUserId(customerBillQueryVo.getShopId(),customerBillQueryVo.getCustomerId()); + final Debt debt = debtService.selectByUserId(customerBillQueryVo.getShopId(), customerBillQueryVo.getCustomerId()); // 要查新客户的创建时间,根据用户的创建时间来判断; // 如果查询时间小于创建时间,那么初期欠款和期末欠款应该为0 // 如果查询的时间大于创建时间,那么初期欠款和期末欠款应该为客户欠款 - if(debt != null){ + if (debt != null) { final Date createTime = debt.getCreateTime(); final String endDate = customerBillQueryVo.getEndDate(); final Date enddate; @@ -115,18 +115,18 @@ public class BillServiceImpl implements BillService { throw new RuntimeException(e); } // 以为现在创建客户就创建了欠款信息,那么就按照欠款信息的创建时间作为标识 - if(createTime.after(enddate)){ + if (createTime.after(enddate)) { customerBillDataVo.setInitialArrears(BigDecimal.ZERO); customerBillDataVo.setEndArrears(BigDecimal.ZERO); - }else{ + } else { customerBillDataVo.setInitialArrears(debt.getAmountOwed()); customerBillDataVo.setEndArrears(debt.getAmountOwed()); } } - }else{ + } else { for (int i = 0; i < records.size(); i++) { - if(StringUtils.isNotEmpty(records.get(i).getSaleId())){ + if (StringUtils.isNotEmpty(records.get(i).getSaleId())) { saleIdList.add(records.get(i).getSaleId()); } // 根据时间升序查询的,这里获取第一个的初期欠款当做本次查询的初期欠款 @@ -134,11 +134,10 @@ public class BillServiceImpl implements BillService { final BigDecimal lastDebtAmount = records.get(0).getLastDebtAmount(); customerBillDataVo.setInitialArrears(lastDebtAmount); } - // 获取最后一个的剩余欠款当做本次查询的剩余欠款 - if (i == records.size() - 1) { - customerBillDataVo.setEndArrears(records.get(i).getBalanceDue()); - } } + // 因为记录分页了,所以这里不能获取最后一条数据作为获期末欠款,应该单独查询一下 + final BigDecimal arrearsByUserId = dealingsRecordService.getArrearsByUserId(customerBillQueryVo); + customerBillDataVo.setEndArrears(arrearsByUserId); } if (!saleIdList.isEmpty()) { @@ -272,10 +271,11 @@ public class BillServiceImpl implements BillService { /** * 获取供应商对账单 - * @author 王富康 - * @date 2024/7/23 + * * @param supplierBillQueryVo * @return SupplierBillDataVo + * @author 王富康 + * @date 2024/7/23 */ @Override public SupplierBillDataVo getPurchaseBill(SupplierBillQueryVo supplierBillQueryVo) { @@ -295,8 +295,10 @@ public class BillServiceImpl implements BillService { // 获取本期全部拿货总金额 final ArrearsVo saleArrearsVo = purchaseService.getArrearsAndTotalSale(supplierBillQueryVo); if (saleArrearsVo != null) { + supplierBillDataVo.setArrears(saleArrearsVo.getArrears()); supplierBillDataVo.setTotalSale(saleArrearsVo.getTotalSale()); - }else{ + } else { + supplierBillDataVo.setArrears(BigDecimal.ZERO); supplierBillDataVo.setTotalSale(BigDecimal.ZERO); } @@ -306,13 +308,13 @@ public class BillServiceImpl implements BillService { // 获取saleId,去查询销售单的商品明细,及退货单的商品明细 final List purchaseIdList = new ArrayList<>(); - if(records.isEmpty()){ + if (records.isEmpty()) { //未开单,查询客户欠款,作为初期欠款和期末欠款 - final Debt debt = debtService.selectByUserId(supplierBillQueryVo.getShopId(),supplierBillQueryVo.getSupplierId()); + final Debt debt = debtService.selectByUserId(supplierBillQueryVo.getShopId(), supplierBillQueryVo.getSupplierId()); // 要查新客户的创建时间,根据用户的创建时间来判断; // 如果查询时间小于创建时间,那么初期欠款和期末欠款应该为0 // 如果查询的时间大于创建时间,那么初期欠款和期末欠款应该为客户欠款 - if(debt != null){ + if (debt != null) { final Date createTime = debt.getCreateTime(); final String endDate = supplierBillQueryVo.getEndDate(); Date enddate = new Date(); @@ -324,18 +326,18 @@ public class BillServiceImpl implements BillService { throw new RuntimeException(e); } // 以为现在创建客户就创建了欠款信息,那么就按照欠款信息的创建时间作为标识 - if(createTime.after(enddate)){ + if (createTime.after(enddate)) { supplierBillDataVo.setInitialArrears(BigDecimal.ZERO); supplierBillDataVo.setEndArrears(BigDecimal.ZERO); - }else{ + } else { supplierBillDataVo.setInitialArrears(debt.getAmountOwed()); supplierBillDataVo.setEndArrears(debt.getAmountOwed()); } } - }else{ + } else { for (int i = 0; i < records.size(); i++) { - if(StringUtils.isNotEmpty(records.get(i).getPurchaseId())){ + if (StringUtils.isNotEmpty(records.get(i).getPurchaseId())) { purchaseIdList.add(records.get(i).getPurchaseId()); } // 根据时间升序查询的,这里获取第一个的初期欠款当做本次查询的初期欠款 @@ -343,11 +345,11 @@ public class BillServiceImpl implements BillService { final BigDecimal lastDebtAmount = records.get(0).getLastDebtAmount(); supplierBillDataVo.setInitialArrears(lastDebtAmount); } - // 获取最后一个的剩余欠款当做本次查询的剩余欠款 - if (i == records.size() - 1) { - supplierBillDataVo.setEndArrears(records.get(i).getBalanceDue()); - } } + // 因为记录分页了,所以这里不能获取最后一条数据作为获期末欠款,应该单独查询一下 + final BigDecimal arrearsBySupplierId = dealingsRecordService.getArrearsBySupplierId(supplierBillQueryVo); + supplierBillDataVo.setEndArrears(arrearsBySupplierId); + } if (!purchaseIdList.isEmpty()) { @@ -368,7 +370,7 @@ public class BillServiceImpl implements BillService { } // 获取入库单规格明细 final List stockLogList = stockLogService.getPurchaseDetails(purchaseIdList); - final Map> stockLogMap = new HashMap<>(); + final Map> stockLogMap = new HashMap<>(); for (StockLog stockLog : stockLogList) { final String detailId = stockLog.getDetailId(); if (stockLogMap.containsKey(detailId)) { diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/DealingsRecordMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/DealingsRecordMapper.java index 749e22e5..a68b55c0 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/DealingsRecordMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/DealingsRecordMapper.java @@ -69,4 +69,8 @@ public interface DealingsRecordMapper extends BaseMapper { * @date 2024/8/2 */ void deleteDealingsRecord(@Param("id") String id); + + BigDecimal getArrearsByUserId(@Param("customerBillQueryVo") CustomerBillQueryVo customerBillQueryVo); + + BigDecimal getArrearsBySupplierId(@Param("supplierBillQueryVo") SupplierBillQueryVo supplierBillQueryVo); } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/DealingsRecordService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/DealingsRecordService.java index 4daba7b2..200a9141 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/DealingsRecordService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/DealingsRecordService.java @@ -63,4 +63,24 @@ public interface DealingsRecordService extends IService { * @date 2024/8/2 */ void deleteDealingsRecord(String id); + + /** + * 获取客户期末欠款 + * + * @param customerBillQueryVo + * @return Page + * @author 王富康 + * @date 2024/7/6 + */ + BigDecimal getArrearsByUserId(CustomerBillQueryVo customerBillQueryVo); + + /** + * 获取供应商期末欠款 + * + * @param supplierBillQueryVo + * @return Page + * @author 王富康 + * @date 2024/7/6 + */ + BigDecimal getArrearsBySupplierId(SupplierBillQueryVo supplierBillQueryVo); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/DealingsRecordServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/DealingsRecordServiceImpl.java index 3075c98d..96987be1 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/DealingsRecordServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/DealingsRecordServiceImpl.java @@ -85,4 +85,14 @@ public class DealingsRecordServiceImpl extends ServiceImpl + + + + \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml index e923e16d..aa904b50 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml @@ -550,6 +550,7 @@