From 42cf6f27de70434af3ca0204466644c88eae3b0e Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Sat, 24 Aug 2024 11:40:58 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E8=B4=AD=E9=80=80=E8=B4=A7=20?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E9=97=AE=E9=A2=98=E4=BC=98=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 +- .../constant/DealingsRecordConstant.java | 4 +- .../core/common/constant/SaleConstant.java | 5 + .../properties/HiverTokenProperties.java | 2 +- .../controller/manage/AuthController.java | 56 +-- .../controller/manage/UserController.java | 10 +- .../bill/service/impl/BillServiceImpl.java | 143 ++++-- .../java/cc/hiver/mall/bill/vo/ArrearsVo.java | 6 + .../mall/bill/vo/CustomerBillDataVo.java | 6 + .../mall/bill/vo/CustomerBillSaleVo.java | 3 + .../mall/bill/vo/SupplierBillDataVo.java | 3 + .../mall/bill/vo/SupplierBillPurchaseVo.java | 3 + .../service/impl/CheckStockServiceImpl.java | 3 +- .../mall/common/constant/StockConstant.java | 2 +- .../common/constant/StockLogConstant.java | 4 +- .../mall/controller/ProductController.java | 22 +- .../hiver/mall/controller/SaleController.java | 94 +++- .../hiver/mall/controller/ShopController.java | 12 +- .../mall/controller/StockController.java | 7 + .../java/cc/hiver/mall/dao/ShopUserDao.java | 2 + .../mall/dao/mapper/PurchaseDetailMapper.java | 3 + .../mall/dao/mapper/SaleDetailMapper.java | 6 + .../cc/hiver/mall/dao/mapper/SaleMapper.java | 53 ++- .../cc/hiver/mall/dao/mapper/StockMapper.java | 2 + .../hiver/mall/debt/service/DebtService.java | 3 + .../debt/service/impl/DebtServiceImpl.java | 61 +++ .../mall/pojo/dto/SaleDetailQueryDTO.java | 3 + .../mall/pojo/query/ProductPageQuery.java | 6 + .../cc/hiver/mall/pojo/vo/ProductPageVO.java | 4 + .../java/cc/hiver/mall/pojo/vo/SaleAllVO.java | 3 + .../vo/TotalAmountDetailByCustomerVo.java | 25 ++ .../pojo/vo/TotalAmountDetailByProductVo.java | 28 ++ .../impl/PurchaseOcrPictureServiceImpl.java | 9 +- .../constant/PurchaseReturnConstant.java | 7 + .../controller/PurchaseReturnController.java | 92 ++++ .../PurchaseReturnDetailController.java | 26 ++ .../purchasereturn/entity/PurchaseReturn.java | 76 ++++ .../entity/PurchaseReturnDetail.java | 117 +++++ .../mapper/PurchaseReturnDetailMapper.java | 28 ++ .../mapper/PurchaseReturnMapper.java | 30 ++ .../service/PurchaseReturnDetailService.java | 36 ++ .../service/PurchaseReturnService.java | 45 ++ .../impl/PurchaseReturnDetailServiceImpl.java | 51 +++ .../impl/PurchaseReturnServiceImpl.java | 234 ++++++++++ .../vo/PurchaseReturnDataVo.java | 29 ++ .../vo/PurchaseReturnQueryVo.java | 18 + .../purchasereturn/vo/PurchaseReturnVo.java | 29 ++ .../hiver/mall/service/ShopUserService.java | 1 + .../mybatis/PurchaseDetailService.java | 3 + .../service/mybatis/SaleDetailService.java | 15 + .../mall/service/mybatis/SaleService.java | 20 + .../mall/service/mybatis/StockService.java | 11 + .../SalesAndDetailsServiceImpl.java | 1 + .../SalesCalculateServiceImpl.java | 27 +- .../mall/serviceimpl/ShopUserServiceImpl.java | 5 + .../serviceimpl/StockAndLogServiceImpl.java | 4 +- .../mybatis/ProductServiceImpl.java | 182 ++++---- .../mybatis/PurchaseDetailServiceImpl.java | 6 + .../mybatis/ReturnSaleServiceImpl.java | 88 +++- .../mybatis/SaleDetailServiceImpl.java | 12 + .../serviceimpl/mybatis/SaleServiceImpl.java | 94 +++- .../serviceimpl/mybatis/StockServiceImpl.java | 421 ++++++++++++------ .../java/cc/hiver/mall/utils/AliOcrUtil.java | 13 +- .../main/resources/mapper/CustomerMapper.xml | 2 +- .../resources/mapper/DealingsRecordMapper.xml | 35 +- .../main/resources/mapper/ProductMapper.xml | 27 +- .../resources/mapper/PurchaseDetailMapper.xml | 24 + .../mapper/PurchaseReturnDetailMapper.xml | 239 ++++++++++ .../resources/mapper/PurchaseReturnMapper.xml | 73 +++ .../resources/mapper/ReturnSaleMapper.xml | 3 +- .../resources/mapper/SaleDetailMapper.xml | 55 ++- .../src/main/resources/mapper/SaleMapper.xml | 140 +++++- .../src/main/resources/mapper/StockMapper.xml | 6 + 73 files changed, 2548 insertions(+), 386 deletions(-) create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/TotalAmountDetailByCustomerVo.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/TotalAmountDetailByProductVo.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/constant/PurchaseReturnConstant.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/controller/PurchaseReturnController.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/controller/PurchaseReturnDetailController.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/entity/PurchaseReturn.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/entity/PurchaseReturnDetail.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/mapper/PurchaseReturnDetailMapper.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/mapper/PurchaseReturnMapper.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/service/PurchaseReturnDetailService.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/service/PurchaseReturnService.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/service/impl/PurchaseReturnDetailServiceImpl.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/service/impl/PurchaseReturnServiceImpl.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/vo/PurchaseReturnDataVo.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/vo/PurchaseReturnQueryVo.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/vo/PurchaseReturnVo.java create mode 100644 hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseReturnDetailMapper.xml create mode 100644 hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseReturnMapper.xml diff --git a/hiver-admin/test-output/test-report.html b/hiver-admin/test-output/test-report.html index d1a84232..1c37bf37 100644 --- a/hiver-admin/test-output/test-report.html +++ b/hiver-admin/test-output/test-report.html @@ -35,7 +35,7 @@ Hiver
  • -八月 12, 2024 09:47:24 +八月 24, 2024 11:36:29
  • @@ -84,7 +84,7 @@

    passTest

    -

    09:47:25 上午 / 0.017 secs

    +

    11:36:29 上午 / 0.019 secs

    @@ -92,9 +92,9 @@
    #test-id=1
    passTest
    -08.12.2024 09:47:25 -08.12.2024 09:47:25 -0.017 secs +08.24.2024 11:36:29 +08.24.2024 11:36:29 +0.019 secs
    @@ -104,7 +104,7 @@ Pass - 9:47:25 + 11:36:29 Test passed @@ -128,13 +128,13 @@

    Started

    -

    八月 12, 2024 09:47:24

    +

    八月 24, 2024 11:36:29

    Ended

    -

    八月 12, 2024 09:47:25

    +

    八月 24, 2024 11:36:29

    diff --git a/hiver-core/src/main/java/cc/hiver/core/common/constant/DealingsRecordConstant.java b/hiver-core/src/main/java/cc/hiver/core/common/constant/DealingsRecordConstant.java index cc7a609f..49df3ddb 100644 --- a/hiver-core/src/main/java/cc/hiver/core/common/constant/DealingsRecordConstant.java +++ b/hiver-core/src/main/java/cc/hiver/core/common/constant/DealingsRecordConstant.java @@ -13,8 +13,8 @@ public interface DealingsRecordConstant { Integer[] TYPE = {0, 1}; /** - * 浜ゆ槗绫诲瀷锛0:寮鍗曪紱1锛氶璐(搴旇鏄病鐢ㄥ埌)锛2锛氬洖娆撅紝3锛氭柊澧炲鎴/渚涘簲鍟嗘瑺娆撅紝4锛氬厖鍊硷紱5锛氳拷鍔犳瑺娆;6:鎾ら攢璁㈠崟;7:鍏ュ簱锛8锛氬垹闄や氦鏄撹褰 + * 浜ゆ槗绫诲瀷锛0:寮鍗曪紱1锛氶璐(搴旇鏄病鐢ㄥ埌)锛2锛氬洖娆撅紝3锛氭柊澧炲鎴/渚涘簲鍟嗘瑺娆撅紝4锛氬厖鍊硷紱5锛氳拷鍔犳瑺娆;6:鎾ら攢璁㈠崟;7:鍏ュ簱锛8锛氬垹闄や氦鏄撹褰; 9:鍏ュ簱閫璐э紱10锛氭挙閿鍏ュ簱閫璐 */ - Integer[] DEALINGS_TYPE = {0, 1, 2, 3, 4, 5, 6, 7, 8}; + Integer[] DEALINGS_TYPE = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; } diff --git a/hiver-core/src/main/java/cc/hiver/core/common/constant/SaleConstant.java b/hiver-core/src/main/java/cc/hiver/core/common/constant/SaleConstant.java index 618916c2..ec5c662d 100644 --- a/hiver-core/src/main/java/cc/hiver/core/common/constant/SaleConstant.java +++ b/hiver-core/src/main/java/cc/hiver/core/common/constant/SaleConstant.java @@ -49,4 +49,9 @@ public interface SaleConstant { * 鏄惁鏄疉I鐨勬爣璇嗭細0锛氫笉鏄疉I锛1锛氭槸锛圓I鏈瘑鍒級, 2锛圓I璇嗗埆鎴愬姛锛夛紝3锛圓I璇嗗埆澶辫触 */ int[] AI_FLAG = {0, 1, 2, 3}; + + /** + * 鏄惁璐拱杩囷細0锛氭病涔拌繃锛1锛氫拱杩 + */ + int[] IS_PURCHASED_BEFORE = {0, 1}; } diff --git a/hiver-core/src/main/java/cc/hiver/core/config/properties/HiverTokenProperties.java b/hiver-core/src/main/java/cc/hiver/core/config/properties/HiverTokenProperties.java index c8424561..490732f4 100644 --- a/hiver-core/src/main/java/cc/hiver/core/config/properties/HiverTokenProperties.java +++ b/hiver-core/src/main/java/cc/hiver/core/config/properties/HiverTokenProperties.java @@ -36,7 +36,7 @@ public class HiverTokenProperties { /** * 鐢ㄦ埛閫夋嫨淇濆瓨鐧诲綍鐘舵佸搴攖oken杩囨湡鏃堕棿锛堝ぉ锛 */ - private Integer saveLoginTime = 7; + private Integer saveLoginTime = 365; /** * 闄愬埗鐢ㄦ埛鐧婚檰閿欒娆℃暟锛堟锛 diff --git a/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/AuthController.java b/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/AuthController.java index 91df83ac..14a7cd42 100644 --- a/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/AuthController.java +++ b/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/AuthController.java @@ -176,24 +176,19 @@ public class AuthController { if (UserConstant.USER_TYPE_NORMAL.equals(type)) { // 鑾峰彇 final List shopUsers = shopUserService.selectByUserId(user.getId()); - if(shopUsers != null && !shopUsers.isEmpty()){ + if (shopUsers != null && !shopUsers.isEmpty()) { // 鑾峰彇搴椾富鎵嬫満鍙 - final Shop shop = shopService.findById(shopUsers.get(0).getShopId()); - if(shop != null && shop.getShopOwnerId() != null && StringUtils.isNotEmpty(shop.getShopOwnerId())){ - final User shopOwner = userService.get(shop.getShopOwnerId()); - for (ShopUser shopUser : shopUsers) { - shopUser.setShopOwnerName(shopOwner.getNickname()); - shopUser.setShopOwnerPhone(shopOwner.getMobile()); + for (ShopUser shopUser : shopUsers) { + final Shop shop = shopService.findById(shopUser.getShopId()); + if (shop != null && shop.getShopOwnerId() != null && StringUtils.isNotEmpty(shop.getShopOwnerId())) { + final User shopOwner = userService.findById(shop.getShopOwnerId()); + if(shopOwner != null){ + shopUser.setShopOwnerName(shopOwner.getNickname()); + shopUser.setShopOwnerPhone(shopOwner.getMobile()); + } + } } - } - if (!shopUsers.isEmpty()) { - /*if (shopUsers.size() == 1) { - // 濡傛灉鍙湁涓涓晢閾猴紝鐩存帴鏀惧埌缂撳瓨涓彇 - final ShopUser shopUser = shopUsers.get(0); - final Shop shop = shopService.get(shopUser.getShopId()); - securityUtil.chooseShop(shopUser.getShopId(), shop.getRegionId(), accessToken); - }*/ result.put("shopList", shopUsers); } else { return ResultUtil.error("搴楅摵鏈紑閫氾紒"); @@ -227,12 +222,17 @@ public class AuthController { // 鑾峰彇 final List shopUsers = shopUserService.selectByUserId(user.getId()); if (!shopUsers.isEmpty()) { - /*if (shopUsers.size() == 1) { - // 濡傛灉鍙湁涓涓晢閾猴紝鐩存帴鏀惧埌缂撳瓨涓彇 - final ShopUser shopUser = shopUsers.get(0); - final Shop shop = shopService.get(shopUser.getShopId()); - securityUtil.chooseShop(shopUser.getShopId(), shop.getRegionId(), accessToken); - }*/ + // 鑾峰彇搴椾富鎵嬫満鍙 + for (ShopUser shopUser : shopUsers) { + final Shop shop = shopService.findById(shopUser.getShopId()); + if (shop != null && shop.getShopOwnerId() != null && StringUtils.isNotEmpty(shop.getShopOwnerId())) { + final User shopOwner = userService.findById(shop.getShopOwnerId()); + if(shopOwner != null){ + shopUser.setShopOwnerName(shopOwner.getNickname()); + shopUser.setShopOwnerPhone(shopOwner.getMobile()); + } + } + } result.put("shopList", shopUsers); } else { return ResultUtil.error("搴楅摵鏈紑閫氾紒"); @@ -517,12 +517,14 @@ public class AuthController { final List shopUsers = shopUserService.selectByUserId(u.getId()); if(shopUsers != null && !shopUsers.isEmpty()){ // 鑾峰彇搴椾富鎵嬫満鍙 - final Shop shop = shopService.findById(shopUsers.get(0).getShopId()); - if(shop != null && shop.getShopOwnerId() != null && StringUtils.isNotEmpty(shop.getShopOwnerId())){ - final User user = userService.get(shop.getShopOwnerId()); - for (ShopUser shopUser : shopUsers) { - shopUser.setShopOwnerName(user.getNickname()); - shopUser.setShopOwnerPhone(user.getMobile()); + for (ShopUser shopUser : shopUsers) { + final Shop shop = shopService.findById(shopUser.getShopId()); + if (shop != null && shop.getShopOwnerId() != null && StringUtils.isNotEmpty(shop.getShopOwnerId())) { + final User shopOwner = userService.findById(shop.getShopOwnerId()); + if(shopOwner != null){ + shopUser.setShopOwnerName(shopOwner.getNickname()); + shopUser.setShopOwnerPhone(shopOwner.getMobile()); + } } } } diff --git a/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/UserController.java b/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/UserController.java index bc528b4f..22dc6119 100644 --- a/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/UserController.java +++ b/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/UserController.java @@ -141,12 +141,16 @@ public class UserController { @ApiParam("鎵嬫満鍙") @RequestParam String mobile, @ApiParam("鏃у瘑鐮") @RequestParam String password, @ApiParam("鏂板瘑鐮") @RequestParam String newPass) { + if(StringUtils.isEmpty(mobile) && StringUtils.isEmpty(newPass)){ + return ResultUtil.error("鏈慨鏀逛换浣曚俊鎭紒"); + } final User user = userService.findById(userId); // 淇敼浜嗗瘑鐮 - if (StringUtils.isNotEmpty(password) && StringUtils.isNotEmpty(newPass)) { - if (!new BCryptPasswordEncoder().matches(password, user.getPassword())) { + if (StringUtils.isNotEmpty(newPass)) { + // 20240819 淇敼浣嶄笉鏍¢獙鏃у瘑鐮侊紝鐩存帴鏇存柊涓烘柊瀵嗙爜 + /*if (!new BCryptPasswordEncoder().matches(password, user.getPassword())) { return ResultUtil.error("鏃у瘑鐮佷笉姝g‘"); - } + }*/ final String newEncryptPass = new BCryptPasswordEncoder().encode(newPass); user.setPassword(newEncryptPass); } 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 3109f309..eb01bee5 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 @@ -6,6 +6,8 @@ import cc.hiver.mall.bill.vo.*; import cc.hiver.mall.debt.entity.Debt; import cc.hiver.mall.debt.service.DebtService; import cc.hiver.mall.entity.*; +import cc.hiver.mall.purchasereturn.entity.PurchaseReturnDetail; +import cc.hiver.mall.purchasereturn.service.PurchaseReturnDetailService; import cc.hiver.mall.service.SupplierService; import cc.hiver.mall.service.mybatis.*; import cc.hiver.mall.utils.DateUtil; @@ -38,6 +40,9 @@ public class BillServiceImpl implements BillService { @Autowired private PurchaseDetailService purchaseDetailService; + @Autowired + private PurchaseReturnDetailService purchaseReturnDetailService; + @Autowired private StockLogService stockLogService; @@ -81,9 +86,11 @@ public class BillServiceImpl implements BillService { if (saleArrearsVo != null) { customerBillDataVo.setArrears(saleArrearsVo.getArrears()); customerBillDataVo.setTotalSale(saleArrearsVo.getTotalSale()); + customerBillDataVo.setSaleProductCount(saleArrearsVo.getSaleProductCount()); } else { customerBillDataVo.setArrears(BigDecimal.ZERO); customerBillDataVo.setTotalSale(BigDecimal.ZERO); + customerBillDataVo.setSaleProductCount(0); } // 鑾峰彇閫璐ф婚噾棰 @@ -301,6 +308,9 @@ public class BillServiceImpl implements BillService { supplierBillDataVo.setArrears(BigDecimal.ZERO); supplierBillDataVo.setTotalSale(BigDecimal.ZERO); } + // 鑾峰彇杩涜揣鎬讳欢鏁 + final Integer purchasingCount = purchaseDetailService.queryPurchasingCount(supplierBillQueryVo); + supplierBillDataVo.setPurchasingCount(purchasingCount); // 鏍规嵁瀹㈡埛id鍙婃棩鏈熻寖鍥村璐﹀崟鏄庣粏 final Page dealingRecordPage = dealingsRecordService.getDealingsRecordPageBySupplierId(supplierBillQueryVo); @@ -368,6 +378,20 @@ public class BillServiceImpl implements BillService { purchaseDetailMap.put(purchaseId, purchaseDetailArrayList); } } + // 鑾峰彇鍏ュ簱閫璐у崟鍟嗗搧鏄庣粏 + final List purchaseReturnDetails = purchaseReturnDetailService.getPurchaseReturnDetails(purchaseIdList); + final Map> purchaseReturnDetailMap = new HashMap<>(); + for (PurchaseReturnDetail purchaseReturnDetail : purchaseReturnDetails) { + final String purchaseId = purchaseReturnDetail.getPurchaseId(); + if (purchaseReturnDetailMap.containsKey(purchaseId)) { + final List purchaseReturnDetailList = purchaseReturnDetailMap.get(purchaseId); + purchaseReturnDetailList.add(purchaseReturnDetail); + } else { + final List purchaseReturnDetailArrayList = new ArrayList<>(); + purchaseReturnDetailArrayList.add(purchaseReturnDetail); + purchaseReturnDetailMap.put(purchaseId, purchaseReturnDetailArrayList); + } + } // 鑾峰彇鍏ュ簱鍗曡鏍兼槑缁 final List stockLogList = stockLogService.getPurchaseDetails(purchaseIdList); final Map> stockLogMap = new HashMap<>(); @@ -386,48 +410,95 @@ public class BillServiceImpl implements BillService { // 寮濮嬪皝瑁呮暟鎹 for (SupplierBillPurchaseVo supplierBillPurchaseVo : records) { final String purchaseId = supplierBillPurchaseVo.getPurchaseId(); - // 灏佽閿鍞崟淇℃伅 - final List purchaseDetailList = purchaseDetailMap.get(purchaseId); - // 鏍规嵁鍟嗗搧id鍒嗙被 - final Map> purchaseDetailMapOfSale = new HashMap<>(); - if (purchaseDetailList != null && !purchaseDetailList.isEmpty()) { - for (PurchaseDetail purchaseDetail : purchaseDetailList) { - final String productId = purchaseDetail.getProductId(); - if (purchaseDetailMapOfSale.containsKey(productId)) { - final List purchaseDetailsOfMap = purchaseDetailMapOfSale.get(productId); - purchaseDetailsOfMap.add(purchaseDetail); - } else { - final List purchaseDetailArrayList = new ArrayList<>(); - purchaseDetailArrayList.add(purchaseDetail); - purchaseDetailMapOfSale.put(productId, purchaseDetailArrayList); + if(purchaseDetailMap.containsKey(purchaseId)){ + // 灏佽鍏ュ簱鍗曚俊鎭 + final List purchaseDetailList = purchaseDetailMap.get(purchaseId); + // 鏍规嵁鍟嗗搧id鍒嗙被 + final Map> purchaseDetailMapOfSale = new HashMap<>(); + if (purchaseDetailList != null && !purchaseDetailList.isEmpty()) { + for (PurchaseDetail purchaseDetail : purchaseDetailList) { + final String productId = purchaseDetail.getProductId(); + if (purchaseDetailMapOfSale.containsKey(productId)) { + final List purchaseDetailsOfMap = purchaseDetailMapOfSale.get(productId); + purchaseDetailsOfMap.add(purchaseDetail); + } else { + final List purchaseDetailArrayList = new ArrayList<>(); + purchaseDetailArrayList.add(purchaseDetail); + purchaseDetailMapOfSale.put(productId, purchaseDetailArrayList); + } + } + final List billSaleDetailVos = new ArrayList<>(); + for (Map.Entry> stringListEntry : purchaseDetailMapOfSale.entrySet()) { + final List value = stringListEntry.getValue(); + final BillProductDetailVo billProductDetailVo = new BillProductDetailVo(); + // 鍚屼竴娆惧晢鍝侊紝涓嶅悓瑙勬牸锛屽晢鍝佷俊鎭彧鍙栫涓涓 + billProductDetailVo.setProductSn(value.get(0).getProductSn()); + billProductDetailVo.setProductName(value.get(0).getProductName()); + final List billAttributeListVos = new ArrayList<>(); + final List stockLogList1 = stockLogMap.get(value.get(0).getId()); + if (stockLogList1 != null && !stockLogList1.isEmpty()) { + for (StockLog stockLog : stockLogList1) { + final BillAttributeListVo billAttributeListVo = new BillAttributeListVo(); + billAttributeListVo.setAttributeList(stockLog.getAttributeList()); + billAttributeListVo.setProductCount(stockLog.getProductCount()); + billAttributeListVos.add(billAttributeListVo); + } + } + billProductDetailVo.setProductCount(value.get(0).getProductCount()); + final BigDecimal purchasePrice = value.get(0).getPurchasePrice() == null ? BigDecimal.ZERO : value.get(0).getPurchasePrice(); + final BigDecimal productCount = value.get(0).getProductCount() == null ? BigDecimal.ZERO : BigDecimal.valueOf(value.get(0).getProductCount()); + billProductDetailVo.setTotalAmount(purchasePrice.multiply(productCount)); + billProductDetailVo.setBillAttributeListVos(billAttributeListVos); + billSaleDetailVos.add(billProductDetailVo); } + supplierBillPurchaseVo.setBillSaleDetailVos(billSaleDetailVos); } - final List billSaleDetailVos = new ArrayList<>(); - for (Map.Entry> stringListEntry : purchaseDetailMapOfSale.entrySet()) { - final List value = stringListEntry.getValue(); - final BillProductDetailVo billProductDetailVo = new BillProductDetailVo(); - // 鍚屼竴娆惧晢鍝侊紝涓嶅悓瑙勬牸锛屽晢鍝佷俊鎭煎嚑閽卞彇绗竴涓 - billProductDetailVo.setProductSn(value.get(0).getProductSn()); - billProductDetailVo.setProductName(value.get(0).getProductName()); - final List billAttributeListVos = new ArrayList<>(); - final List stockLogList1 = stockLogMap.get(value.get(0).getId()); - if (stockLogList1 != null && !stockLogList1.isEmpty()) { - for (StockLog stockLog : stockLogList1) { - final BillAttributeListVo billAttributeListVo = new BillAttributeListVo(); - billAttributeListVo.setAttributeList(stockLog.getAttributeList()); - billAttributeListVo.setProductCount(stockLog.getProductCount()); - billAttributeListVos.add(billAttributeListVo); + } + if(purchaseReturnDetailMap.containsKey(purchaseId)){ + // 灏佽鍏ュ簱鍗曚俊鎭 + final List purchaseReturnDetailList = purchaseReturnDetailMap.get(purchaseId); + // 鏍规嵁鍟嗗搧id鍒嗙被 + final Map> purchaseDetailMapOfSale = new HashMap<>(); + if (purchaseReturnDetailList != null && !purchaseReturnDetailList.isEmpty()) { + for (PurchaseReturnDetail purchaseReturnDetail : purchaseReturnDetailList) { + final String productId = purchaseReturnDetail.getProductId(); + if (purchaseDetailMapOfSale.containsKey(productId)) { + final List purchaseDetailsOfMap = purchaseDetailMapOfSale.get(productId); + purchaseDetailsOfMap.add(purchaseReturnDetail); + } else { + final List purchaseDetailArrayList = new ArrayList<>(); + purchaseDetailArrayList.add(purchaseReturnDetail); + purchaseDetailMapOfSale.put(productId, purchaseDetailArrayList); } } - billProductDetailVo.setProductCount(value.get(0).getProductCount()); - final BigDecimal purchasePrice = value.get(0).getPurchasePrice() == null ? BigDecimal.ZERO : value.get(0).getPurchasePrice(); - final BigDecimal productCount = value.get(0).getProductCount() == null ? BigDecimal.ZERO : BigDecimal.valueOf(value.get(0).getProductCount()); - billProductDetailVo.setTotalAmount(purchasePrice.multiply(productCount)); - billProductDetailVo.setBillAttributeListVos(billAttributeListVos); - billSaleDetailVos.add(billProductDetailVo); + final List billSaleDetailVos = new ArrayList<>(); + for (Map.Entry> stringListEntry : purchaseDetailMapOfSale.entrySet()) { + final List value = stringListEntry.getValue(); + final BillProductDetailVo billProductDetailVo = new BillProductDetailVo(); + // 鍚屼竴娆惧晢鍝侊紝涓嶅悓瑙勬牸锛屽晢鍝佷俊鎭彧鍙栫涓涓 + billProductDetailVo.setProductSn(value.get(0).getProductSn()); + billProductDetailVo.setProductName(value.get(0).getProductName()); + final List billAttributeListVos = new ArrayList<>(); + final List stockLogList1 = stockLogMap.get(value.get(0).getId()); + if (stockLogList1 != null && !stockLogList1.isEmpty()) { + for (StockLog stockLog : stockLogList1) { + final BillAttributeListVo billAttributeListVo = new BillAttributeListVo(); + billAttributeListVo.setAttributeList(stockLog.getAttributeList()); + billAttributeListVo.setProductCount(stockLog.getProductCount()); + billAttributeListVos.add(billAttributeListVo); + } + } + billProductDetailVo.setProductCount(value.get(0).getProductCount()); + final BigDecimal purchasePrice = value.get(0).getPurchasePrice() == null ? BigDecimal.ZERO : value.get(0).getPurchasePrice(); + final BigDecimal productCount = value.get(0).getProductCount() == null ? BigDecimal.ZERO : BigDecimal.valueOf(value.get(0).getProductCount()); + billProductDetailVo.setTotalAmount(purchasePrice.multiply(productCount)); + billProductDetailVo.setBillAttributeListVos(billAttributeListVos); + billSaleDetailVos.add(billProductDetailVo); + } + supplierBillPurchaseVo.setBillSaleDetailVos(billSaleDetailVos); } - supplierBillPurchaseVo.setBillSaleDetailVos(billSaleDetailVos); } + } } // 灏嗛攢鍞俊鎭瓨鏀惧埌瀵硅处鍗曚腑 diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/ArrearsVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/ArrearsVo.java index f84e4c60..b715552b 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/ArrearsVo.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/ArrearsVo.java @@ -13,6 +13,12 @@ public class ArrearsVo { @ApiModelProperty(value = "鎷胯揣鎬婚噾棰") private BigDecimal totalSale; + @ApiModelProperty(value = "鎷胯揣鏁伴噺") + private Integer saleProductCount; + @ApiModelProperty(value = "閫璐ф婚噾棰") private BigDecimal totalReturn; + + @ApiModelProperty(value = "閫璐ф绘暟閲") + private Integer returnProductCount; } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/CustomerBillDataVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/CustomerBillDataVo.java index 27069999..b37c1929 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/CustomerBillDataVo.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/CustomerBillDataVo.java @@ -35,9 +35,15 @@ public class CustomerBillDataVo { @ApiModelProperty(value = "鎷胯揣鎬婚噾棰") private BigDecimal totalSale; + @ApiModelProperty(value = "鎷胯揣鎬绘暟閲") + private Integer saleProductCount; + @ApiModelProperty(value = "閫璐ф婚噾棰") private BigDecimal totalReturn; + @ApiModelProperty(value = "閫璐ф绘暟閲") + private Integer returnProductCount; + @ApiModelProperty(value = "閿鍞崟鏄庣粏") private Page customerBillSaleVos; diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/CustomerBillSaleVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/CustomerBillSaleVo.java index 07ee93ee..3c7ec7da 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/CustomerBillSaleVo.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/CustomerBillSaleVo.java @@ -62,6 +62,9 @@ public class CustomerBillSaleVo { @ApiModelProperty(value = "鍒犻櫎鏍囪瘑") private Integer delFlag; + @ApiModelProperty(value = "澶囨敞") + private String remark; + @ApiModelProperty(value = "閿鍞槑缁") private List billSaleDetailVos; diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillDataVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillDataVo.java index 33134b72..61d56cd5 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillDataVo.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillDataVo.java @@ -35,6 +35,9 @@ public class SupplierBillDataVo { @ApiModelProperty(value = "鎷胯揣鎬婚噾棰") private BigDecimal totalSale; + @ApiModelProperty(value = "鎷胯揣鎬绘暟閲") + private Integer purchasingCount; + @ApiModelProperty(value = "鍏ュ簱鍗曟槑缁") private Page supplierBillSaleVos; diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillPurchaseVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillPurchaseVo.java index 2e131800..d8c54cad 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillPurchaseVo.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillPurchaseVo.java @@ -53,6 +53,9 @@ public class SupplierBillPurchaseVo { @ApiModelProperty(value = "鍒犻櫎鏍囪瘑") private Integer delFlag; + @ApiModelProperty(value = "澶囨敞") + private String remark; + @ApiModelProperty(value = "閿鍞槑缁") private List billSaleDetailVos; diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/service/impl/CheckStockServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/service/impl/CheckStockServiceImpl.java index 40b194f7..12441134 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/service/impl/CheckStockServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/service/impl/CheckStockServiceImpl.java @@ -12,6 +12,7 @@ import cc.hiver.mall.checkstock.vo.CheckStockAttributeVo; import cc.hiver.mall.checkstock.vo.CheckStockDetailVo; import cc.hiver.mall.checkstock.vo.CheckStockPageVo; import cc.hiver.mall.checkstock.vo.CheckStockVo; +import cc.hiver.mall.common.constant.StockLogConstant; import cc.hiver.mall.entity.Shop; import cc.hiver.mall.entity.Stock; import cc.hiver.mall.entity.StockLog; @@ -150,7 +151,7 @@ public class CheckStockServiceImpl extends ServiceImpl oldProductListBySn = productService.getByProductSn(productVo.getProductSn(), shopId); + if (oldProductListBySn != null && !oldProductListBySn.isEmpty()) { + return ResultUtil.error("鎮ㄥ凡鏈夎揣鍙"+productVo.getProductSn()+"鐨勫晢鍝侊紝璇锋洿鎹㈣揣鍙"); + } final Product product = new Product(); BeanUtils.copyBeanProp(product, productVo); // 鏂板鍟嗗搧涓撳睘鍒嗙被淇℃伅 @@ -65,8 +74,6 @@ public class ProductController { } else { return ResultUtil.error("娣诲姞鍒嗙被淇℃伅澶辫触"); } - // shopId浠庣紦瀛樹腑璁剧疆 - final String shopId = securityUtil.getShopId(); product.setShopId(shopId); // 鏂板鐨勯粯璁や负宸蹭笂鏋 product.setDelFlag(CommonConstant.DEL_FLAG_TRUE); @@ -89,6 +96,17 @@ public class ProductController { @RequestMapping(value = "/edit", method = RequestMethod.POST) @ApiOperation("鏍规嵁璐у搧id淇敼璐у搧") public Result edit(@RequestBody ProductVo productVo) { + // 20240824 澧炲姞淇敼鐨勫晢鍝佽揣鍙蜂笉鑳介噸澶 + // 鏍规嵁璐у彿鏌ヨ鍟嗗搧鏄惁瀛樺湪 + // shopId浠庣紦瀛樹腑璁剧疆 + final String shopId = securityUtil.getShopId(); + final CopyOnWriteArrayList oldProductListBySn = productService.getByProductSn(productVo.getProductSn(), shopId); + if (oldProductListBySn != null && !oldProductListBySn.isEmpty()) { + // 濡傛灉鏃у晢鍝乮d涓嶇瓑浜庡墠鍙颁紶閫掔殑鍟嗗搧id,鍒欒繑鍥炰俊鎭 + if (!productVo.getId().equals(oldProductListBySn.get(0).getId())) { + return ResultUtil.error("鎮ㄥ凡鏈夎揣鍙"+productVo.getProductSn()+"鐨勫晢鍝侊紝璇锋洿鎹㈣揣鍙"); + } + } final Product product = new Product(); BeanUtils.copyBeanProp(product, productVo); // 鍒犻櫎鍟嗗搧涓撳睘鍒嗙被淇℃伅 diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SaleController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SaleController.java index 1597ee99..89d95c95 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SaleController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SaleController.java @@ -40,10 +40,7 @@ import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.*; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; @Slf4j @RestController @@ -146,9 +143,9 @@ public class SaleController { saleQueryDTO.getSale().setShopId(shopId); saleQueryDTO.getSale().setShopName(shop.getShopName()); // 鏍规嵁璇ュ鎴风殑娆犳淇℃伅 - String userId = saleQueryDTO.getSale().getUserId(); - Debt debt = debtService.selectByUserId(shopId, userId); - BigDecimal amountOwed = debt.getAmountOwed(); + final String userId = saleQueryDTO.getSale().getUserId(); + final Debt debt = debtService.selectByUserId(shopId, userId); + final BigDecimal amountOwed = debt.getAmountOwed(); // 20240616 寮鍗曞彲鑳藉煎寘鍚璐у崟 Sale sale = saleQueryDTO.getSale(); sale.setLastDebtAmount(amountOwed); @@ -452,6 +449,34 @@ public class SaleController { .eq("sale_id", id) .groupBy("product_id"); final List list = saleDetailService.selectByCondition1(queryWrapper); + // 鏌ヨ瀹㈡埛闄ゆ湰鍗曞鍏朵粬鎷胯揣淇℃伅 + // 瀹㈡埛id + // 灏佽涓哄晢鍝乮d+瑙勬牸鍊间负key鐨刴ap + final Map> historySaleDetailMap = new HashMap<>(); + if (list != null && !list.isEmpty()) { + final List historySaleDetailList = saleDetailService.selectDetailListByProductIds(list, sale); + for (SaleDetail saleDetail : historySaleDetailList) { + final String productId = StringUtils.isEmpty(saleDetail.getProductId()) ? "" : saleDetail.getProductId(); + final String attributeList = StringUtils.isEmpty(saleDetail.getAttributeList()) ? "" : saleDetail.getAttributeList(); + final String key = productId + attributeList; + if (historySaleDetailMap.containsKey(key)) { + historySaleDetailMap.get(key).add(saleDetail); + } else { + final List saleDetailList = new ArrayList<>(); + saleDetailList.add(saleDetail); + historySaleDetailMap.put(key, saleDetailList); + } + } + } + // + final Map productMap = new HashMap<>(); + if(list != null && !list.isEmpty()){ + final List productList = productService.getProductList(list); + for (Product product : productList) { + productMap.putIfAbsent(product.getId(), product); + } + } + final List saleDetailDTOS = new ArrayList<>(); for (String productId : list) { final QueryWrapper queryPWrapper = new QueryWrapper<>(); @@ -468,7 +493,14 @@ public class SaleController { saleDetailDTO.setSaleId(saleDetail.getSaleId()); saleDetailDTO.setPrice(saleDetail.getPrice()); saleDetailDTO.setWholesalePrice(saleDetail.getWholesalePrice()); - saleDetailDTO.setPurchasePrice(saleDetail.getPurchasePrice()); + // 鍟嗗搧鏈夐噰璐环灏变娇鐢ㄥ晢鍝佺殑閲囪喘浠 + if (productMap.containsKey(productId)) { + final BigDecimal purchasePrice = productMap.get(productId).getPurchasePrice() == null ? BigDecimal.ZERO : productMap.get(productId).getPurchasePrice(); + saleDetailDTO.setPurchasePrice(purchasePrice); + } else { + saleDetailDTO.setPurchasePrice(saleDetail.getPurchasePrice()); + } + saleDetailDTO.setDiscount(saleDetail.getDiscount()); saleDetailDTO.setDiscountAmount(saleDetail.getDiscountAmount()); saleDetailDTO.setRealPrice(saleDetail.getRealPrice()); @@ -477,6 +509,12 @@ public class SaleController { final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO(); saleDetailQueryDTO.setAttributeList(saleDetail.getAttributeList()); saleDetailQueryDTO.setProductCount(saleDetail.getProductCount()); + // 鍒ゆ柇涔嬪墠鏄惁鎷胯繃璐 + if (historySaleDetailMap.containsKey(productId + saleDetail.getAttributeList())) { + saleDetailQueryDTO.setIsPurchasedBefore(SaleConstant.IS_PURCHASED_BEFORE[1]); + } else { + saleDetailQueryDTO.setIsPurchasedBefore(SaleConstant.IS_PURCHASED_BEFORE[0]); + } saleDetailQueryDTOS.add(saleDetailQueryDTO); } saleDetailDTO.setStockLogList1(saleDetailQueryDTOS); @@ -611,6 +649,8 @@ public class SaleController { // 杩涜揣鎴愭湰 final BigDecimal purchasingCost = purchaseService.getPurchasingCost(shopId, startTime, endTime); saleAllVO.setPurchasingCost(purchasingCost); + + } catch (Exception e) { log.error(e.getMessage(), e); return ResultUtil.error(500, e.getMessage()); @@ -1157,6 +1197,44 @@ public class SaleController { } } + /** + * 鍒╂鼎鏄庣粏-鎸夊鎴 + * + * @param salePageQuery + * @return Result + * @author 鐜嬪瘜搴 + * @date 2024/8/18 + */ + @PostMapping("/totalAmountDetailByCustomer") + public Result totalAmountDetailByCustomer(@RequestBody SalePageQuery salePageQuery) { + try { + final Page totalAmountDetailByCustomer = saleService.totalAmountDetailByCustomer(salePageQuery); + return new ResultUtil<>().setData(totalAmountDetailByCustomer); + } catch (Exception e) { + log.info(e.getMessage(), e); + return ResultUtil.error("鏌ヨ澶辫触"); + } + } + + /** + * 鍒╂鼎鏄庣粏-鎸夊晢鍝 + * + * @param salePageQuery + * @return Result + * @author 鐜嬪瘜搴 + * @date 2024/8/18 + */ + @PostMapping("/totalAmountDetailByProduct") + public Result totalAmountDetailByProduct(@RequestBody SalePageQuery salePageQuery) { + try { + final Page totalAmountDetailByProduct = saleService.totalAmountDetailByProduct(salePageQuery); + return new ResultUtil<>().setData(totalAmountDetailByProduct); + } catch (Exception e) { + log.info(e.getMessage(), e); + return ResultUtil.error("鏌ヨ澶辫触"); + } + } + /** * 瀹炴敹閲戦鏄庣粏 * 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 4c0655bd..21398b4a 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 @@ -130,6 +130,8 @@ public class ShopController { @ResponseBody @ApiOperation("缂栬緫") public Result edit(Shop shop) { + // 鑾峰彇鏃у簵閾轰俊鎭 + Shop oldShop = shopService.get(shop.getId()); if (CharSequenceUtil.isNotBlank(shop.getShopArea())) { final ShopArea d = shopAreaService.get(shop.getShopArea()); if (d != null) { @@ -147,10 +149,12 @@ public class ShopController { } shopService.update(shop); - // 鍒犻櫎搴楅摵鐢ㄦ埛 - shopUserService.deleteAllByShopId(shop.getId()); - //閲嶆柊娣诲姞搴楅暱 - if (shop.getShopMangerId() != null) { + + //濡傛灉鏇存崲搴椾富锛岄偅涔堝氨閲嶆柊璁剧疆搴椾富鍙婂簵鍛樹俊鎭 + if (shop.getShopMangerId() != null && oldShop.getShopOwnerId().equals(shop.getShopMangerId())) { + // 鍒犻櫎鍘熷簵涓诲叧鑱斿叧绯 + shopUserService.deleteAllByShopIdAndUserId(oldShop.getId(),oldShop.getShopOwnerId()); + // 娣诲姞瑙掕壊 final List shopUsers = Collections.singletonList(shop.getShopMangerId()).stream().map(e -> { return new ShopUser().setShopId(shop.getId()).setShopName(shop.getShopName()).setUserId(e).setType(ShopUserConstant.SHOP_ADMIN_COST[0]); diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/StockController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/StockController.java index ce087896..75ebba90 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/StockController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/StockController.java @@ -9,6 +9,7 @@ import cc.hiver.mall.pojo.vo.ProductCategoryStockVo; import cc.hiver.mall.pojo.vo.PurchaseVo; import cc.hiver.mall.pojo.vo.ShopStockVo; import cc.hiver.mall.pojo.vo.StockProductVo; +import cc.hiver.mall.purchasereturn.vo.PurchaseReturnVo; import cc.hiver.mall.service.mybatis.StockService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.swagger.annotations.Api; @@ -79,6 +80,12 @@ public class StockController { return stockService.putInPrice(purchaseVo); } + @RequestMapping(value = "/putOutPrice", method = RequestMethod.POST) + @ApiOperation("閲囪喘鍗曢璐") + public Result putOutPrice(@RequestBody PurchaseReturnVo purchaseReturnVo) { + return stockService.putOutPrice(purchaseReturnVo); + } + @RequestMapping(value = "/putInPriceOfAi", method = RequestMethod.POST) @ApiOperation("AI纭鍏ュ簱") @Transactional diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/ShopUserDao.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/ShopUserDao.java index 912ce37f..3affaf5d 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/ShopUserDao.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/ShopUserDao.java @@ -23,4 +23,6 @@ public interface ShopUserDao extends HiverBaseDao { * @return List */ List findByShopId(String shopId); + + void deleteAllByShopIdAndUserId(String shopId, String shopOwnerId); } 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 6d0b3b83..8f2c9771 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 @@ -1,5 +1,6 @@ package cc.hiver.mall.dao.mapper; +import cc.hiver.mall.bill.vo.SupplierBillQueryVo; import cc.hiver.mall.entity.PurchaseDetail; import cc.hiver.mall.entity.PurchaseDetailExample; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -56,4 +57,6 @@ public interface PurchaseDetailMapper extends BaseMapper { List getPurchaseDetailListByProductIds(@Param("productIdList") List productIdList,@Param("id") String id); void realDeleteByPurchaseId(@Param("purchaseId") String purchaseId); + + int queryPurchasingCount(@Param("supplierBillQueryVo") SupplierBillQueryVo supplierBillQueryVo); } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleDetailMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleDetailMapper.java index f68086c1..b9226aad 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleDetailMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleDetailMapper.java @@ -1,12 +1,14 @@ package cc.hiver.mall.dao.mapper; import cc.hiver.mall.entity.PurchaseDetail; +import cc.hiver.mall.entity.Sale; import cc.hiver.mall.entity.SaleDetail; import cc.hiver.mall.entity.SaleDetailExample; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; +import java.math.BigDecimal; import java.util.List; @Repository public interface SaleDetailMapper extends BaseMapper { @@ -45,4 +47,8 @@ public interface SaleDetailMapper extends BaseMapper { List getSaleDetails(@Param("saleIdList") List saleIdList); List getSaleDetailListByProductIds(@Param("productIdList") List productIdList); + + List selectDetailListByProductIds(@Param("productIdList")List productIdList,@Param("sale") Sale sale); + + BigDecimal getTotalProfit(@Param("shopId") String shopId,@Param("startDate") String startDate,@Param("endDate") String endDate); } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java index f94480d0..6701c74c 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java @@ -65,7 +65,7 @@ public interface SaleMapper extends BaseMapper { Page getCustomerBuyProductLog(Page page, @Param("salePageQuery") SalePageQuery salePageQuery); - List getCustomerBuyProductLogDetailLog(@Param("userId") String userId, @Param("shopId") String shopId, @Param("productIds") List productIds,@Param("startTime") String startTime, @Param("endTime") String endTime); + List getCustomerBuyProductLogDetailLog(@Param("userId") String userId, @Param("shopId") String shopId, @Param("productIds") List productIds, @Param("startTime") String startTime, @Param("endTime") String endTime); BigDecimal queryTotalAlreadyEarn(@Param("shopId") String shopId, @Param("startTime") String startTime, @Param("endTime") String endTime); @@ -75,44 +75,69 @@ public interface SaleMapper extends BaseMapper { List getSupplierBuyProductLogDetailLog(@Param("supplierId") String supplierId, @Param("shopId") String shopId, @Param("productIds") List productIds); - Page getSupplierBuyProductLog(Page page,@Param("salePageQuery") SalePageQuery salePageQuery); + Page getSupplierBuyProductLog(Page page, @Param("salePageQuery") SalePageQuery salePageQuery); Page getSaleByCompanyId(Page page, @Param("salePageQuery") SalePageQuery salePageQuery); - void companyGetSale(@Param("saleId")String saleId); + void companyGetSale(@Param("saleId") String saleId); - void updateAiMsg(@Param("aiMsg") String aiMsg,@Param("saleId") String saleId); + void updateAiMsg(@Param("aiMsg") String aiMsg, @Param("saleId") String saleId); - void updateAiFlag(@Param("id")String id, @Param("status") Integer status); - void updateStatus(@Param("id")String id, @Param("status") Integer status); + void updateAiFlag(@Param("id") String id, @Param("status") Integer status); - List queryTotalAlreadyEarnDetail(@Param("shopId") String shopId,@Param("startTime") String startTime,@Param("endTime") String endTime); + void updateStatus(@Param("id") String id, @Param("status") Integer status); + + List queryTotalAlreadyEarnDetail(@Param("shopId") String shopId, @Param("startTime") String startTime, @Param("endTime") String endTime); List getCustomerBill(@Param("customerBillQueryVo") CustomerBillQueryVo customerBillQueryVo); - ArrearsVo getArrearsAndTotalSale( @Param("customerBillQueryVo") CustomerBillQueryVo customerBillQueryVo); + ArrearsVo getArrearsAndTotalSale(@Param("customerBillQueryVo") CustomerBillQueryVo customerBillQueryVo); Page totalAmountDetail(Page page, @Param("salePageQuery") SalePageQuery salePageQuery); /** * 瀹炴敹閲戦鏄庣粏 - * @author 鐜嬪瘜搴 - * @date 2024/6/29 + * * @param page * @param salePageQuery * @return List + * @author 鐜嬪瘜搴 + * @date 2024/6/29 */ - Page totalAlreadyEarnDetail(Page page,@Param("salePageQuery") SalePageQuery salePageQuery); + Page totalAlreadyEarnDetail(Page page, @Param("salePageQuery") SalePageQuery salePageQuery); /** * 瀹㈡埛鎷胯揣缁熻 + * + * @param page + * @param salePageQuery + * @return Page * @author 鐜嬪瘜搴 * @date 2024/6/29 + */ + Page customerSaleDetail(Page page, @Param("salePageQuery") SalePageQuery salePageQuery); + + int queryTotalJCount(@Param("shopId") String shopId, @Param("startTime") String startTime, @Param("endTime") String endTime); + + /** + * 鍒╂鼎鏄庣粏-鎸夊鎴 + * * @param page * @param salePageQuery - * @return Page + * @return Page + * @author 鐜嬪瘜搴 + * @date 2024/8/18 */ - Page customerSaleDetail(Page page,@Param("salePageQuery") SalePageQuery salePageQuery); + Page totalAmountDetailByCustomer(Page page, @Param("salePageQuery") SalePageQuery salePageQuery); - int queryTotalJCount(@Param("shopId") String shopId,@Param("startTime") String startTime, @Param("endTime") String endTime); + /** + * 鍒╂鼎鏄庣粏-鎸夊晢鍝 + * + * @param page + * @param salePageQuery + * @return Page + * @author 鐜嬪瘜搴 + * @date 2024/8/18 + */ + Page totalAmountDetailByProduct(Page page, @Param("salePageQuery") SalePageQuery salePageQuery); } \ No newline at end of file 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 5202f584..47f1fd30 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 @@ -58,4 +58,6 @@ public interface StockMapper extends BaseMapper { void batchReduceStockByLog(@Param("stockLogList") List stockLogList); List getDefaultStockCount(@Param("productIdList") List productIdList); + + void batchIncreaseStockByLog(@Param("stockLogList") List stockLogList); } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/DebtService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/DebtService.java index 2fe68044..ce580a3a 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/DebtService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/DebtService.java @@ -5,6 +5,7 @@ import cc.hiver.mall.debt.vo.DebtOfShopVo; import cc.hiver.mall.debt.vo.QueryDebtVo; import cc.hiver.mall.entity.Purchase; import cc.hiver.mall.pojo.dto.SaleQueryDTO; +import cc.hiver.mall.purchasereturn.entity.PurchaseReturn; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; @@ -81,4 +82,6 @@ public interface DebtService extends IService { Debt recharge(Debt debt); DebtOfShopVo getAllDebtByShopId(QueryDebtVo queryDebtVo); + + void purchaseReturnToDebt(PurchaseReturn putOutPurchase, String type); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/impl/DebtServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/impl/DebtServiceImpl.java index 070ab4b8..00af41de 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/impl/DebtServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/impl/DebtServiceImpl.java @@ -1,6 +1,7 @@ package cc.hiver.mall.debt.service.impl; import cc.hiver.core.common.constant.DealingsRecordConstant; +import cc.hiver.core.common.exception.HiverException; import cc.hiver.core.common.utils.SecurityUtil; import cc.hiver.core.entity.User; import cc.hiver.mall.debt.constant.DebtConstant; @@ -14,6 +15,8 @@ import cc.hiver.mall.entity.DealingsRecord; import cc.hiver.mall.entity.Purchase; import cc.hiver.mall.entity.Supplier; import cc.hiver.mall.pojo.dto.SaleQueryDTO; +import cc.hiver.mall.purchasereturn.constant.PurchaseReturnConstant; +import cc.hiver.mall.purchasereturn.entity.PurchaseReturn; import cc.hiver.mall.service.SupplierService; import cc.hiver.mall.service.mybatis.CustomerService; import cc.hiver.mall.service.mybatis.DealingsRecordService; @@ -236,6 +239,9 @@ public class DebtServiceImpl extends ServiceImpl implements De public void purchaseToDebt(Purchase purchase) { final String shopId = securityUtil.getShopId(); final Debt oldDebt = debtMapper.selectByUserId(shopId, purchase.getSupplierId()); + if (oldDebt == null) { + throw new HiverException("渚涘簲鍟嗕笉瀛樺湪!"); + } BigDecimal lastDebtAmount = BigDecimal.ZERO; BigDecimal newDebtAmount; // 鏈崟娆犳 @@ -334,4 +340,59 @@ public class DebtServiceImpl extends ServiceImpl implements De public DebtOfShopVo getAllDebtByShopId(QueryDebtVo queryDebtVo) { return debtMapper.getAllDebtByShopId(queryDebtVo); } + + @Override + public void purchaseReturnToDebt(PurchaseReturn putOutPurchase, String type) { + final String shopId = securityUtil.getShopId(); + final Debt oldDebt = debtMapper.selectByUserId(shopId, putOutPurchase.getSupplierId()); + if (oldDebt == null) { + throw new HiverException("渚涘簲鍟嗕笉瀛樺湪!"); + } + BigDecimal lastDebtAmount = BigDecimal.ZERO; + BigDecimal newDebtAmount; + // 鏈崟娆犳 + BigDecimal alreadyPay = putOutPurchase.getAlreadyPay() == null ? BigDecimal.ZERO : putOutPurchase.getAlreadyPay(); + // 涓婃娆犳 + lastDebtAmount = oldDebt.getAmountOwed() == null ? BigDecimal.ZERO : oldDebt.getAmountOwed(); + // 璁$畻娆犳 + if (PurchaseReturnConstant.TYPE[0].equals(type)) { + newDebtAmount = oldDebt.getAmountOwed().subtract(alreadyPay); + } else { + newDebtAmount = oldDebt.getAmountOwed().add(alreadyPay); + } + + oldDebt.setAmountOwed(newDebtAmount); + debtMapper.updateById(oldDebt); + // 2. 鏂板娆犳璁板綍 + final DealingsRecord dealingsRecord = new DealingsRecord(); + // 鍒涘缓浜 + final User user = securityUtil.getCurrUser(); + + dealingsRecord.setCreateBy(user.getId()); + dealingsRecord.setCreateByName(user.getNickname()); + dealingsRecord.setCreateTime(new Date()); + dealingsRecord.setSaleId(putOutPurchase.getId()); + dealingsRecord.setDealingsUserId(putOutPurchase.getSupplierId()); + dealingsRecord.setDealingsUserName(putOutPurchase.getSupplierName()); + dealingsRecord.setUserType(DealingsRecordConstant.TYPE[0]); + if (PurchaseReturnConstant.TYPE[0].equals(type)) { + dealingsRecord.setDealingsWay("鍏ュ簱閫璐"); + } else { + dealingsRecord.setDealingsWay("鎾ら攢鍏ュ簱閫璐"); + } + dealingsRecord.setShopId(shopId); + // 涓婃娆犳 + dealingsRecord.setLastDebtAmount(lastDebtAmount); + // 鏈鏂版瑺娆 + dealingsRecord.setBalanceDue(newDebtAmount); + // 鏈娆犳 + dealingsRecord.setAmount(alreadyPay); + if (PurchaseReturnConstant.TYPE[0].equals(type)) { + dealingsRecord.setDealingsType(DealingsRecordConstant.DEALINGS_TYPE[9]); + } else { + dealingsRecord.setDealingsType(DealingsRecordConstant.DEALINGS_TYPE[10]); + } + + dealingsRecordService.save(dealingsRecord); + } } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/SaleDetailQueryDTO.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/SaleDetailQueryDTO.java index 4c5c9ebc..f9d62445 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/SaleDetailQueryDTO.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/SaleDetailQueryDTO.java @@ -19,5 +19,8 @@ public class SaleDetailQueryDTO implements Serializable { @ApiModelProperty(value = "搴撳瓨鏁伴噺") private Integer stockCount; + @ApiModelProperty(value = "涔嬪墠鏄惁璐拱杩囷細0锛氭病涔拌繃锛1锛氫拱杩") + private Integer isPurchasedBefore; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/ProductPageQuery.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/ProductPageQuery.java index e9e93891..8939ed03 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/ProductPageQuery.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/ProductPageQuery.java @@ -66,4 +66,10 @@ public class ProductPageQuery extends HiverBasePageQuery { @ApiModelProperty("鏌ヨ鏉′欢") private String searchStr; + + @ApiModelProperty("寮濮嬫椂闂") + private String startDate; + + @ApiModelProperty("缁撴潫鏃堕棿") + private String endDate; } 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 5c1bcc2c..fbafaa6f 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 @@ -109,4 +109,8 @@ public class ProductPageVO { @ApiModelProperty(value = "鍟嗗搧鍧囪壊鍧囩爜鎬诲簱瀛") private Integer defaultStockCount; + + + @ApiModelProperty(value = "鍟嗗搧鎬婚攢閲") + private Integer totalSold; } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SaleAllVO.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SaleAllVO.java index 7d48474e..5aafda77 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SaleAllVO.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SaleAllVO.java @@ -59,4 +59,7 @@ public class SaleAllVO implements Serializable { @ApiModelProperty(value = "杩涜揣鎴愭湰") private BigDecimal purchasingCost; + + @ApiModelProperty(value = "杩涜揣鎬讳欢鏁") + private int purchasingCount; } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/TotalAmountDetailByCustomerVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/TotalAmountDetailByCustomerVo.java new file mode 100644 index 00000000..c77ddde8 --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/TotalAmountDetailByCustomerVo.java @@ -0,0 +1,25 @@ +package cc.hiver.mall.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class TotalAmountDetailByCustomerVo { + private static final long serialVersionUID = 1L; + + + @ApiModelProperty(value = " 瀹㈡埛id") + private String userId; + + @ApiModelProperty(value = " 瀹㈡埛鍚嶇О") + private String userName; + + @ApiModelProperty(value = "鍒╂鼎") + private BigDecimal profit; + + @ApiModelProperty(value = "鍒╂鼎鍗犳瘮") + private BigDecimal profitProportion; + +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/TotalAmountDetailByProductVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/TotalAmountDetailByProductVo.java new file mode 100644 index 00000000..11e63991 --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/TotalAmountDetailByProductVo.java @@ -0,0 +1,28 @@ +package cc.hiver.mall.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class TotalAmountDetailByProductVo { + private static final long serialVersionUID = 1L; + + + @ApiModelProperty(value = " 鍟嗗搧id") + private String productId; + + @ApiModelProperty(value = " 鍟嗗搧鍚嶇О") + private String productName; + + @ApiModelProperty(value = " 鍟嗗搧璐у彿") + private String productSn; + + @ApiModelProperty(value = "鍒╂鼎") + private BigDecimal profit; + + @ApiModelProperty(value = "鍒╂鼎鍗犳瘮") + private BigDecimal profitProportion; + +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchaseocr/service/impl/PurchaseOcrPictureServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchaseocr/service/impl/PurchaseOcrPictureServiceImpl.java index 38865108..ec96a8e8 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchaseocr/service/impl/PurchaseOcrPictureServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchaseocr/service/impl/PurchaseOcrPictureServiceImpl.java @@ -409,9 +409,12 @@ public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService final List stockLogList = new ArrayList<>(); for (int j = 0; j < attributeListJsonArray.size(); j++) { final JSONObject attributeListObject = attributeListJsonArray.getJSONObject(j); - String color = attributeListObject.getString("color").toUpperCase(); - String size = attributeListObject.getString("size").toUpperCase(); - final String productCount1 = attributeListObject.getString("productCount"); + String color = attributeListObject.getString("color"); + color = StringUtils.isEmpty(color) ? "鍧囪壊" :color.toUpperCase(); + String size = attributeListObject.getString("size"); + size = StringUtils.isEmpty(size) ? "鍧囩爜" :size.toUpperCase(); + String productCount1 = attributeListObject.getString("productCount"); + productCount1 = StringUtils.isEmpty(productCount1) ? "0" : productCount1; final Matcher countMatchered = COMPILE.matcher(productCount1); String replaced = ""; if (countMatchered.find()) { diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/constant/PurchaseReturnConstant.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/constant/PurchaseReturnConstant.java new file mode 100644 index 00000000..b96d8d47 --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/constant/PurchaseReturnConstant.java @@ -0,0 +1,7 @@ +package cc.hiver.mall.purchasereturn.constant; + +public interface PurchaseReturnConstant { + + // 璁㈠崟绫诲瀷锛0锛氭柊澧炲叆搴撻璐э紱 1锛氭挙閿鍏ュ簱閫璐 + String[] TYPE = {"0","1"}; +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/controller/PurchaseReturnController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/controller/PurchaseReturnController.java new file mode 100644 index 00000000..f2dc6838 --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/controller/PurchaseReturnController.java @@ -0,0 +1,92 @@ +package cc.hiver.mall.purchasereturn.controller; + +import cc.hiver.core.common.utils.ResultUtil; +import cc.hiver.core.common.vo.Result; +import cc.hiver.mall.purchasereturn.entity.PurchaseReturn; +import cc.hiver.mall.purchasereturn.service.PurchaseReturnService; +import cc.hiver.mall.purchasereturn.vo.PurchaseReturnDataVo; +import cc.hiver.mall.purchasereturn.vo.PurchaseReturnQueryVo; +import com.baomidou.mybatisplus.core.metadata.IPage; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +/** + * 閲囪喘閫璐ф帴鍙 + * + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ +@Slf4j +@RestController +@Api(tags = "閲囪喘閫璐ф帴鍙") +@RequestMapping("/hiver/app/purchaseReturn/") +@Transactional +public class PurchaseReturnController { + + @Autowired + private PurchaseReturnService purchaseReturnService; + + /** + * 鍒嗛〉鑾峰彇閲囪喘閫璐у垪琛 + * + * @param purchaseReturnQueryVo + * @return Result> + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ + @RequestMapping(value = "/getPurchaseReturnList", method = RequestMethod.POST) + @ApiOperation(value = "鍒嗛〉鑾峰彇閲囪喘閫璐у垪琛") + public Result> getPurchaseReturnList(@RequestBody PurchaseReturnQueryVo purchaseReturnQueryVo) { + final IPage result = purchaseReturnService.getPurchaseReturnList(purchaseReturnQueryVo); + return new ResultUtil>().setData(result); + } + + /** + * 鏍规嵁id鑾峰彇閲囪喘閫璐 + * + * @param id + * @return Result + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ + @RequestMapping(value = "/getPurchaseReturnById", method = RequestMethod.POST) + @ApiOperation(value = "鏍规嵁id鑾峰彇閲囪喘閫璐") + public Result getPurchaseReturnById(String id) { + if (StringUtils.isEmpty(id)) { + return ResultUtil.error("id涓嶈兘涓虹┖"); + } + final PurchaseReturnDataVo result = purchaseReturnService.getPurchaseReturnById(id); + return new ResultUtil().setData(result); + } + + /** + * 鎾ら攢閲囪喘鍗曢璐 + * + * @param id + * @return Result + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ + @RequestMapping(value = "/cancelPurchaseReturn", method = RequestMethod.POST) + @ApiOperation(value = "鎾ら攢閲囪喘鍗曢璐") + public Result cancelPurchaseReturn(String id) { + if (StringUtils.isEmpty(id)) { + return ResultUtil.error("id涓嶈兘涓虹┖"); + } + try { + purchaseReturnService.cancelPurchaseReturn(id); + return ResultUtil.success("鎾ら攢閲囪喘鍗曢璐ф垚鍔"); + } catch (Exception e) { + log.error("鎾ら攢閲囪喘鍗曢璐уけ璐", e); + return ResultUtil.error("鎾ら攢閲囪喘鍗曢璐уけ璐"); + } + } +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/controller/PurchaseReturnDetailController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/controller/PurchaseReturnDetailController.java new file mode 100644 index 00000000..49efd06d --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/controller/PurchaseReturnDetailController.java @@ -0,0 +1,26 @@ +package cc.hiver.mall.purchasereturn.controller; + +import cc.hiver.mall.purchasereturn.service.PurchaseReturnDetailService; +import io.swagger.annotations.Api; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 閲囪喘閫璐ф槑缁嗘帴鍙 + * + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ +@Slf4j +@RestController +@Api(tags = "閲囪喘閫璐ф槑缁嗘帴鍙") +@RequestMapping("/hiver/app/purchaseReturnDetail/") +@Transactional +public class PurchaseReturnDetailController { + + @Autowired + private PurchaseReturnDetailService purchaseReturnDetailService; +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/entity/PurchaseReturn.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/entity/PurchaseReturn.java new file mode 100644 index 00000000..29e62773 --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/entity/PurchaseReturn.java @@ -0,0 +1,76 @@ +package cc.hiver.mall.purchasereturn.entity; + +import cc.hiver.core.base.HiverBaseEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.persistence.Transient; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 閲囪喘閫璐ц〃 + * + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ +@Data +@ApiModel(value = "閲囪喘閫璐") +@TableName(value = "t_purchase_return", autoResultMap = true) +public class PurchaseReturn extends HiverBaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "渚涘簲鍟咺D") + private String createByName; + + @ApiModelProperty(value = "渚涘簲鍟咺D") + private String supplierId; + + @ApiModelProperty(value = "渚涘簲鍟嗗悕绉") + private String supplierName; + + @ApiModelProperty(value = "搴楅摵ID") + private String shopId; + + @ApiModelProperty(value = "璁㈠崟閲戦") + private BigDecimal totalAmount; + + @ApiModelProperty(value = "搴斾粯") + private BigDecimal shouldPay; + + @ApiModelProperty(value = "宸蹭粯") + private BigDecimal alreadyPay; + + @ApiModelProperty(value = "鏈粯") + private BigDecimal noPay; + + @ApiModelProperty(value = "鍏朵粬璐圭敤") + private BigDecimal otherPay; + + @ApiModelProperty(value = "鍏ュ簱鐘舵侊細0锛氬緟鍏ュ簱锛堟湭缁存姢瀵瑰簲鐨勯噰璐环淇℃伅锛夛紱1锛氬凡鍏ュ簱锛") + private Integer inStorageStatus; + + @ApiModelProperty(value = "澶囨敞") + private String remark; + + @ApiModelProperty(value = "浣欓鎶垫墸") + private BigDecimal balanceDeductionAmount; + + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty(value = "鍏ュ簱鏃堕棿锛20240727閲嶆柊瀹氫箟涓哄叆搴撳崟鐨勫垱寤烘椂闂达紝createTime涓哄墠鍙颁紶閫掔殑鍏ュ簱鍗") + private Date purchaseTime; + + @Transient + @TableField(exist = false) + @ApiModelProperty(value = "閫璐у崟璇︽儏") + private List purchaseReturnDetails; + +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/entity/PurchaseReturnDetail.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/entity/PurchaseReturnDetail.java new file mode 100644 index 00000000..d51e052f --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/entity/PurchaseReturnDetail.java @@ -0,0 +1,117 @@ +package cc.hiver.mall.purchasereturn.entity; + +import cc.hiver.core.base.HiverBaseEntity; +import cc.hiver.mall.entity.StockLog; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.persistence.Transient; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 閲囪喘閫璐ц鎯呰〃 + * + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ +@Data +@ApiModel(value = "閲囪喘閫璐ц鎯") +@TableName(value = "t_purchase_return_detail", autoResultMap = true) +public class PurchaseReturnDetail extends HiverBaseEntity { + + + @ApiModelProperty(value = "閲囪喘鍗旾D") + private String purchaseId; + + @ApiModelProperty(value = "鍟嗗搧ID") + private String productId; + + @ApiModelProperty(value = "鍟嗗搧鍚嶇О") + private String productName; + + @ApiModelProperty(value = "鍗曚綅") + private String unit; + + @ApiModelProperty(value = "搴楅摵ID") + private String shopId; + + @ApiModelProperty(value = "鍟嗗搧鍒嗙被") + private String categoryId; + + @ApiModelProperty(value = "鍟嗗搧鍒嗙被") + private String attrId; + + @Transient + @TableField(exist = false) + @ApiModelProperty(value = "鍒嗙被鍚嶇О") + private String categoryName; + + @ApiModelProperty(value = "鍟嗗搧灞炴у垪琛") + private String attributeList; + + @ApiModelProperty(value = "渚涘簲鍟") + private String supplierId; + + @ApiModelProperty(value = "渚涘簲鍟嗗悕绉") + private String supplierName; + + @ApiModelProperty(value = "璐у彿") + private String productSn; + + @ApiModelProperty(value = "鏉$爜") + private String barcode; + + @ApiModelProperty(value = "闆跺敭浠") + private BigDecimal price; + + @Transient + @TableField(exist = false) + @ApiModelProperty(value = "闆跺敭浠(鍗曠函鐢ㄤ簬鎺ユ敹鍓嶅彴浼犲弬)") + private BigDecimal lsPrice; + + @ApiModelProperty(value = "閲囪喘浠") + private BigDecimal purchasePrice; + + @ApiModelProperty(value = "鎵瑰彂浠") + private BigDecimal wholesalePrice; + + @ApiModelProperty(value = "璐у搧鍥剧墖") + private String productPicture; + + @ApiModelProperty(value = "璐у搧瑙嗛") + private String productVideo; + + @ApiModelProperty(value = "璐у搧绠浠") + private String productIntro; + + @ApiModelProperty(value = "閿鍞懆鏈") + private Date salesWeek; + + @ApiModelProperty(value = "灏捐揣棰勮") + private Integer tailWarn; + + @ApiModelProperty(value = "鎵撳嵃鏉$爜锛堣嚜宸卞埗浣滅殑锛") + private String printBarcode; + + @ApiModelProperty(value = "閲囪喘鏁伴噺") + private Integer productCount; + + @ApiModelProperty(value = "璇嗗埆鍥剧墖id") + private String ocrPicturePath; + + + @ApiModelProperty(value = "鎺掑簭") + private Integer sort; + + @Transient + @TableField(exist = false) + @ApiModelProperty(value = "鍏ュ簱鍟嗗搧瑙勬牸鏄庣粏琛") + private List stockLogList1; + + private static final long serialVersionUID = 1L; +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/mapper/PurchaseReturnDetailMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/mapper/PurchaseReturnDetailMapper.java new file mode 100644 index 00000000..1efa5f03 --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/mapper/PurchaseReturnDetailMapper.java @@ -0,0 +1,28 @@ +package cc.hiver.mall.purchasereturn.mapper; + +import cc.hiver.mall.purchasereturn.entity.PurchaseReturnDetail; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 閲囪喘閫璐ф槑缁哅apper + * + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ +public interface PurchaseReturnDetailMapper extends BaseMapper { + List getByPurchaseReturnId(@Param("id") String id); + + /** + * 鎾ら攢鍏ュ簱鏄庣粏 + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + * @param purchaseId + */ + void cancelByPurchaseReturnId(@Param("purchaseId") String purchaseId); + + List getPurchaseReturnDetails(@Param("purchaseIdList") List purchaseIdList); + +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/mapper/PurchaseReturnMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/mapper/PurchaseReturnMapper.java new file mode 100644 index 00000000..8c118d2a --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/mapper/PurchaseReturnMapper.java @@ -0,0 +1,30 @@ +package cc.hiver.mall.purchasereturn.mapper; + +import cc.hiver.mall.purchasereturn.entity.PurchaseReturn; +import cc.hiver.mall.purchasereturn.vo.PurchaseReturnQueryVo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; + +/** + * 閲囪喘閫璐apper + * + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ +public interface PurchaseReturnMapper extends BaseMapper { + + /** + * 鍒嗛〉鑾峰彇閲囪喘閫璐у垪琛 + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + * @param page + * @param purchaseReturnQueryVo + * @return IPage + */ + IPage getPurchaseReturnList(Page page, @Param("queryParams") PurchaseReturnQueryVo purchaseReturnQueryVo); + + void cancelPurchaseReturnById(@Param("id") String id); + +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/service/PurchaseReturnDetailService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/service/PurchaseReturnDetailService.java new file mode 100644 index 00000000..2d3aba38 --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/service/PurchaseReturnDetailService.java @@ -0,0 +1,36 @@ +package cc.hiver.mall.purchasereturn.service; + +import cc.hiver.mall.purchasereturn.entity.PurchaseReturnDetail; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; + +/** + * 閲囪喘閫璐ф槑缁 Service + * + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ +public interface PurchaseReturnDetailService extends IService { + + /** + * 鏍规嵁鍏ュ簱閫璐d鑾峰彇鍟嗗搧淇℃伅 + * + * @param id + * @return List + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ + List getByPurchaseReturnId(String id); + + /** + * 鎾ら攢鍏ュ簱鏄庣粏 + * + * @param id + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ + void cancelByPurchaseReturnId(String id); + + List getPurchaseReturnDetails(List purchaseIdList); +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/service/PurchaseReturnService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/service/PurchaseReturnService.java new file mode 100644 index 00000000..6d6511b3 --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/service/PurchaseReturnService.java @@ -0,0 +1,45 @@ +package cc.hiver.mall.purchasereturn.service; + +import cc.hiver.mall.purchasereturn.entity.PurchaseReturn; +import cc.hiver.mall.purchasereturn.vo.PurchaseReturnDataVo; +import cc.hiver.mall.purchasereturn.vo.PurchaseReturnQueryVo; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 閲囪喘閫璐 Service + * + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ +public interface PurchaseReturnService extends IService { + + /** + * 鍒嗛〉鑾峰彇閲囪喘閫璐у垪琛 + * + * @param purchaseReturnQueryVo + * @return IPage + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ + IPage getPurchaseReturnList(PurchaseReturnQueryVo purchaseReturnQueryVo); + + /** + * 鏍规嵁id鑾峰彇閲囪喘閫璐 + * + * @param id + * @return PurchaseReturnDataVo + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ + PurchaseReturnDataVo getPurchaseReturnById(String id); + + /** + * 鎾ら攢閲囪喘鍗曢璐 + * + * @param id + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ + void cancelPurchaseReturn(String id); +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/service/impl/PurchaseReturnDetailServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/service/impl/PurchaseReturnDetailServiceImpl.java new file mode 100644 index 00000000..b984711f --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/service/impl/PurchaseReturnDetailServiceImpl.java @@ -0,0 +1,51 @@ +package cc.hiver.mall.purchasereturn.service.impl; + +import cc.hiver.mall.purchasereturn.entity.PurchaseReturnDetail; +import cc.hiver.mall.purchasereturn.mapper.PurchaseReturnDetailMapper; +import cc.hiver.mall.purchasereturn.service.PurchaseReturnDetailService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 閲囪喘閫璐ф槑缁嗘湇鍔″疄鐜扮被 + * + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ +@Service +public class PurchaseReturnDetailServiceImpl extends ServiceImpl implements PurchaseReturnDetailService { + + @Autowired + private PurchaseReturnDetailMapper purchaseReturnDetailMapper; + + /** + * 鏍规嵁鍏ュ簱閫璐d鑾峰彇鍟嗗搧淇℃伅 + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + * @param id + * @return List + */ + @Override + public List getByPurchaseReturnId(String id) { + return purchaseReturnDetailMapper.getByPurchaseReturnId(id); + } + + /** + * 鎾ら攢鍏ュ簱鏄庣粏 + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + * @param purchaseId + */ + @Override + public void cancelByPurchaseReturnId(String purchaseId) { + purchaseReturnDetailMapper.cancelByPurchaseReturnId(purchaseId); + } + + @Override + public List getPurchaseReturnDetails(List purchaseIdList) { + return purchaseReturnDetailMapper.getPurchaseReturnDetails(purchaseIdList); + } +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/service/impl/PurchaseReturnServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/service/impl/PurchaseReturnServiceImpl.java new file mode 100644 index 00000000..d86c5835 --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/service/impl/PurchaseReturnServiceImpl.java @@ -0,0 +1,234 @@ +package cc.hiver.mall.purchasereturn.service.impl; + +import cc.hiver.core.common.exception.HiverException; +import cc.hiver.core.common.utils.SecurityUtil; +import cc.hiver.mall.common.constant.StockLogConstant; +import cc.hiver.mall.debt.service.DebtService; +import cc.hiver.mall.entity.Product; +import cc.hiver.mall.entity.Stock; +import cc.hiver.mall.entity.StockLog; +import cc.hiver.mall.entity.Supplier; +import cc.hiver.mall.purchasereturn.constant.PurchaseReturnConstant; +import cc.hiver.mall.purchasereturn.entity.PurchaseReturn; +import cc.hiver.mall.purchasereturn.entity.PurchaseReturnDetail; +import cc.hiver.mall.purchasereturn.mapper.PurchaseReturnMapper; +import cc.hiver.mall.purchasereturn.service.PurchaseReturnDetailService; +import cc.hiver.mall.purchasereturn.service.PurchaseReturnService; +import cc.hiver.mall.purchasereturn.vo.PurchaseReturnDataVo; +import cc.hiver.mall.purchasereturn.vo.PurchaseReturnQueryVo; +import cc.hiver.mall.service.SupplierService; +import cc.hiver.mall.service.mybatis.DealingsRecordService; +import cc.hiver.mall.service.mybatis.ProductService; +import cc.hiver.mall.service.mybatis.StockLogService; +import cc.hiver.mall.service.mybatis.StockService; +import cc.hiver.mall.utils.DateUtil; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 閲囪喘閫璐 鏈嶅姟瀹炵幇绫 + * + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ +@Service +public class PurchaseReturnServiceImpl extends ServiceImpl implements PurchaseReturnService { + + @Autowired + private PurchaseReturnMapper purchaseReturnMapper; + + @Autowired + private SupplierService supplierService; + + @Autowired + private PurchaseReturnDetailService purchaseReturnDetailService; + + @Autowired + private StockLogService stockLogService; + + @Autowired + ProductService productService; + + @Autowired + private DealingsRecordService dealingsRecordService; + + @Autowired + private StockService stockService; + + @Autowired + private SecurityUtil securityUtil; + + @Autowired + private DebtService debtService; + + /** + * 鍒嗛〉鑾峰彇閲囪喘閫璐у垪琛 + * + * @param purchaseReturnQueryVo + * @return IPage + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ + @Override + public IPage getPurchaseReturnList(PurchaseReturnQueryVo purchaseReturnQueryVo) { + //瑙i噴鏃堕棿鍔1澶 + if (StringUtils.isNotEmpty(purchaseReturnQueryVo.getEndDate())) { + purchaseReturnQueryVo.setEndDate(DateUtil.addDay(purchaseReturnQueryVo.getEndDate(), 1)); + } + final String shopId = securityUtil.getShopId(); + purchaseReturnQueryVo.setShopId(shopId); + final Page page = new Page<>(purchaseReturnQueryVo.getPageNum(), purchaseReturnQueryVo.getPageSize()); + return purchaseReturnMapper.getPurchaseReturnList(page, purchaseReturnQueryVo); + } + + /** + * 鏍规嵁id鑾峰彇閲囪喘閫璐 + * + * @param id + * @return PurchaseReturnDataVo + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ + @Override + public PurchaseReturnDataVo getPurchaseReturnById(String id) { + final PurchaseReturnDataVo purchaseReturnDataVo = new PurchaseReturnDataVo(); + // 鑾峰彇閲囪喘鍗曚俊鎭 + final PurchaseReturn purchaseReturn = purchaseReturnMapper.selectById(id); + purchaseReturnDataVo.setPurchaseReturn(purchaseReturn); + // 鑾峰彇渚涘簲鍟嗕俊鎭 + final String supplierId = purchaseReturn.getSupplierId(); + if (StringUtils.isNotEmpty(supplierId)) { + final Supplier supplier = supplierService.findById(supplierId); + purchaseReturnDataVo.setSupplier(supplier); + } + // 鑾峰彇鍟嗗搧淇℃伅 + final List purchaseReturnDetails = purchaseReturnDetailService.getByPurchaseReturnId(id); + // 鑾峰彇瑙勬牸淇℃伅 + final List stockLogList = stockLogService.getByPurchaseId(id); + final Map> stockLogMap = new HashMap<>(); + // 灏佽瑙勬牸灞炴 + for (StockLog stockLog : stockLogList) { + final String productId = stockLog.getProductId(); + if (stockLogMap.containsKey(productId)) { + stockLogMap.get(productId).add(stockLog); + } else { + final List stockLogs = new ArrayList<>(); + stockLogs.add(stockLog); + stockLogMap.put(productId, stockLogs); + } + } + final List productIdList = new ArrayList<>(); + for (PurchaseReturnDetail returnDetail : purchaseReturnDetails) { + final String productId = returnDetail.getProductId(); + returnDetail.setStockLogList1(stockLogMap.get(productId)); + productIdList.add(productId); + } + if (!productIdList.isEmpty()) { + // 20240602 灏嗗晢鍝佺殑閲囪喘浠枫侀浂鍞环銆佹壒鍙戜环鍥炲~鍥炴潵 + // 鑾峰彇鍟嗗搧 + final List productList = productService.getProductList(productIdList); + // 灏嗗晢鍝佸皝瑁呬负map,key涓哄晢鍝乮d,value涓哄晢鍝佷俊鎭 + final Map productMap = productList.stream().collect(Collectors.toMap(Product::getId, product -> product)); + for (PurchaseReturnDetail purchaseReturnDetail : purchaseReturnDetails) { + final String productId = purchaseReturnDetail.getProductId(); + if (productMap.containsKey(productId)) { + final Product product = productMap.get(productId); + purchaseReturnDetail.setPrice(product.getPrice()); + purchaseReturnDetail.setWholesalePrice(product.getWholesalePrice()); + purchaseReturnDetail.setPurchasePrice(product.getPurchasePrice()); + } + } + purchaseReturnDataVo.setPurchaseReturnDetails(purchaseReturnDetails); + } + + // 鑾峰彇璇ュ叆搴撳崟鐨勬瑺娆炬洿鏂拌褰 + purchaseReturnDataVo.setDealingsRecords(dealingsRecordService.getDealingsRecordList(id)); + return purchaseReturnDataVo; + } + + /** + * 鎾ら攢閲囪喘鍗曢璐 + * + * @param id + * @author 鐜嬪瘜搴 + * @date 2024/8/17 + */ + @Override + public void cancelPurchaseReturn(String id) { + PurchaseReturnDataVo purchaseReturnById = getPurchaseReturnById(id); + + // 1. 鍒犻櫎鍏ュ簱鍗曚富琛ㄤ俊鎭 + purchaseReturnMapper.cancelPurchaseReturnById(id); + // 2. 鍒犻櫎閫璐ф槑缁 + purchaseReturnDetailService.cancelByPurchaseReturnId(id); + // 闇瑕佹柊澧炵殑灞ュ巻闆嗗悎 + final List stockLogAddList = new ArrayList<>(); + // 2. 鍥為搴撳瓨 + // 鑾峰彇鍓嶅彴鍏ュ簱鍟嗗搧淇℃伅 + final List purchaseReturnDetails = purchaseReturnById.getPurchaseReturnDetails(); + // 闇瑕佷慨鏀圭殑鍟嗗搧淇℃伅闆嗗悎锛屽晢鍝佷腑鐨勫钩鍧囬噰璐环闇瑕佽绠 + final List productIdList = new ArrayList<>(); + for (PurchaseReturnDetail purchaseReturnDetail : purchaseReturnDetails) { + productIdList.add(purchaseReturnDetail.getProductId()); + } + // 鏍规嵁鍟嗗搧id闆嗗悎鑾峰彇搴撳瓨淇℃伅 + final List productStock = stockService.getProductStock(productIdList); + // 灏佽涓哄晢鍝乮d+鍟嗗搧灞炴т负key ,Stock涓簐alue鐨刴ap + final Map stockMap = new HashMap<>(); + for (Stock stock : productStock) { + stockMap.put(stock.getProductId() + stock.getAttributeList(), stock); + } + for (PurchaseReturnDetail purchaseReturnDetail : purchaseReturnDetails) { + final List changeStockLogs = purchaseReturnDetail.getStockLogList1(); + for (StockLog changeStockLog : changeStockLogs) { + StockLog returnStockLog = new StockLog(); + // 鑾峰彇鍟嗗搧id+鍟嗗搧灞炴т负key ,Stock涓簐alue鐨刴ap + final String changeProductId = changeStockLog.getProductId(); + final String changeAttributeList = changeStockLog.getAttributeList(); + final String getKey = changeProductId + changeAttributeList; + if (stockMap.containsKey(getKey)) { + final Stock stock = stockMap.get(getKey); + //鎾ら攢鍓嶆暟閲 + returnStockLog.setStock(stock.getStockCount()); + } else { + // 涓嶅瓨鍦ㄥ簱瀛橈紵搴旇娌℃湁鍚 + throw new HiverException("鍟嗗搧id涓" + changeProductId + "鐨勫晢鍝佸睘鎬т负" + changeAttributeList + "鐨勫晢鍝佸簱瀛樹笉瀛樺湪"); + } + // shopId浠庣紦瀛樹腑璁剧疆 + final String shopId = securityUtil.getShopId(); + // 鏁寸悊鍏ュ簱鍟嗗搧瑙勬牸鏄庣粏琛ㄦ暟鎹 + // 璁板綍搴撳瓨灞ュ巻 + returnStockLog.setProductId(changeProductId); + returnStockLog.setOrderId(id); + returnStockLog.setDetailId(purchaseReturnDetail.getId()); + //鍏ュ簱 + returnStockLog.setChangeType(StockLogConstant.CHANGE_TYPE[0]); + returnStockLog.setShopId(shopId); + returnStockLog.setPurchasePrice(purchaseReturnDetail.getPurchasePrice()); + returnStockLog.setProductCount(changeStockLog.getProductCount()); + returnStockLog.setAttributeList(changeStockLog.getAttributeList()); + stockLogAddList.add(returnStockLog); + } + } + // 鎵归噺鏇存柊搴撳瓨鏁 + stockService.batchIncreaseStockByLog(stockLogAddList); + // 搴撳瓨璁板綍 + stockLogService.saveBatch(stockLogAddList); + // 3. 鍥為渚涘簲鍟嗘瑺娆 + // 寮傛鏇存柊渚涘簲鍟嗘瑺娆句俊鎭満娆犳璁板綍 + debtService.purchaseReturnToDebt(purchaseReturnById.getPurchaseReturn(), PurchaseReturnConstant.TYPE[1]); + // 浣滃簾褰撳墠璁㈠崟鐨勬瑺娆捐褰 + dealingsRecordService.cancelRecord(id); + + } +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/vo/PurchaseReturnDataVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/vo/PurchaseReturnDataVo.java new file mode 100644 index 00000000..cf655787 --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/vo/PurchaseReturnDataVo.java @@ -0,0 +1,29 @@ +package cc.hiver.mall.purchasereturn.vo; + +import cc.hiver.mall.entity.DealingsRecord; +import cc.hiver.mall.entity.Supplier; +import cc.hiver.mall.purchasereturn.entity.PurchaseReturn; +import cc.hiver.mall.purchasereturn.entity.PurchaseReturnDetail; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.List; + +@Data +@Accessors(chain = true) +public class PurchaseReturnDataVo { + + @ApiModelProperty(value = "渚涘簲鍟嗕俊鎭") + private Supplier supplier; + + @ApiModelProperty(value = "閲囪喘鍗曚富琛") + private PurchaseReturn purchaseReturn; + + @ApiModelProperty(value = "閲囪喘鍗曞瓙琛") + private List purchaseReturnDetails; + + @ApiModelProperty(value = "娆犳淇℃伅") + private List dealingsRecords; + +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/vo/PurchaseReturnQueryVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/vo/PurchaseReturnQueryVo.java new file mode 100644 index 00000000..7e55192d --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/vo/PurchaseReturnQueryVo.java @@ -0,0 +1,18 @@ +package cc.hiver.mall.purchasereturn.vo; + +import cc.hiver.core.base.HiverBasePageQuery; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class PurchaseReturnQueryVo extends HiverBasePageQuery implements Serializable { + + private String shopId; + + private String queryStr; + + private String startDate; + + private String endDate; +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/vo/PurchaseReturnVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/vo/PurchaseReturnVo.java new file mode 100644 index 00000000..a63008d7 --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchasereturn/vo/PurchaseReturnVo.java @@ -0,0 +1,29 @@ +package cc.hiver.mall.purchasereturn.vo; + +import cc.hiver.mall.entity.DealingsRecord; +import cc.hiver.mall.entity.Supplier; +import cc.hiver.mall.purchasereturn.entity.PurchaseReturn; +import cc.hiver.mall.purchasereturn.entity.PurchaseReturnDetail; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.List; + +@Data +@Accessors(chain = true) +public class PurchaseReturnVo { + + @ApiModelProperty(value = "渚涘簲鍟嗕俊鎭") + private Supplier supplier; + + @ApiModelProperty(value = "閲囪喘鍗曢璐т富琛") + private PurchaseReturn purchase; + + @ApiModelProperty(value = "閲囪喘鍗曢璐у瓙琛") + private List purchaseDetails; + + @ApiModelProperty(value = "娆犳淇℃伅") + private List dealingsRecords; + +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/ShopUserService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/ShopUserService.java index 8f97f8e2..c216f3a4 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/ShopUserService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/ShopUserService.java @@ -23,4 +23,5 @@ public interface ShopUserService extends HiverBaseService { */ List findByShopId(String shopId); + void deleteAllByShopIdAndUserId(String shopId, String shopOwnerId); } 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 8fcabc44..4312462e 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 @@ -1,5 +1,6 @@ package cc.hiver.mall.service.mybatis; +import cc.hiver.mall.bill.vo.SupplierBillQueryVo; import cc.hiver.mall.entity.PurchaseDetail; import com.baomidou.mybatisplus.extension.service.IService; @@ -34,4 +35,6 @@ public interface PurchaseDetailService extends IService { * @return List */ List getPurchaseDetailListByProductIds(List productIdList, String id); + + Integer queryPurchasingCount(SupplierBillQueryVo supplierBillQueryVo); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleDetailService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleDetailService.java index f0847dfc..28cb5c44 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleDetailService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleDetailService.java @@ -1,11 +1,13 @@ package cc.hiver.mall.service.mybatis; import cc.hiver.mall.entity.PurchaseDetail; +import cc.hiver.mall.entity.Sale; import cc.hiver.mall.entity.SaleDetail; import cc.hiver.mall.entity.SaleDetailExample; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.IService; +import java.math.BigDecimal; import java.util.List; public interface SaleDetailService extends IService { @@ -38,4 +40,17 @@ public interface SaleDetailService extends IService { * @return List */ List getSaleDetailListByProductIds(List productIdList); + + List selectDetailListByProductIds(List list, Sale sale); + + /** + * 鑾峰彇鍒╂鼎 + * @author 鐜嬪瘜搴 + * @date 2024/8/18 + * @param shopId + * @param startTime + * @param endTime + * @return BigDecimal + */ + BigDecimal getTotalProfit(String shopId, String startTime, String endTime); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleService.java index e0bb083c..6439371a 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleService.java @@ -128,4 +128,24 @@ public interface SaleService extends IService { * @date 2024/7/26 */ void temporarySaveSale(SaleQueryDTO saleQueryDTO); + + /** + * 鍒╂鼎鏄庣粏-鎸夊鎴 + * + * @param salePageQuery + * @return Page + * @author 鐜嬪瘜搴 + * @date 2024/8/18 + */ + Page totalAmountDetailByCustomer(SalePageQuery salePageQuery); + + /** + * 鍒╂鼎鏄庣粏-鎸夊晢鍝 + * + * @param salePageQuery + * @return Page + * @author 鐜嬪瘜搴 + * @date 2024/8/18 + */ + Page totalAmountDetailByProduct(SalePageQuery salePageQuery); } 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 1b2e90b2..71d29e8e 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 @@ -8,6 +8,7 @@ import cc.hiver.mall.pojo.vo.ProductCategoryStockVo; import cc.hiver.mall.pojo.vo.PurchaseVo; import cc.hiver.mall.pojo.vo.ShopStockVo; import cc.hiver.mall.pojo.vo.StockProductVo; +import cc.hiver.mall.purchasereturn.vo.PurchaseReturnVo; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; @@ -95,6 +96,14 @@ public interface StockService extends IService { */ void batchReduceStockByLog(List stockLogList); + /** + * 鏍规嵁鍏ュ簱璁板綍澧炲姞搴撳瓨鏁 + * @author 鐜嬪瘜搴 + * @date 2024/8/19 + * @param stockLogList + */ + void batchIncreaseStockByLog(List stockLogList); + /** * 鑾峰彇鏌愪簺鍟嗗搧鍧囪壊鍧囩爜鐨勫簱瀛樻暟 * @@ -113,4 +122,6 @@ public interface StockService extends IService { * @date 2024/8/8 */ void deleteStockById(String id); + + Result putOutPrice(PurchaseReturnVo purchaseReturnVo); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesAndDetailsServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesAndDetailsServiceImpl.java index c82571c9..de1c7995 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesAndDetailsServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesAndDetailsServiceImpl.java @@ -307,6 +307,7 @@ public class SalesAndDetailsServiceImpl implements SalesAndDetailsService { BeanUtils.copyBeanProp(saleDetail, saleDetailDTO); saleDetail.setCreateTime(sale.getCreateTime()); saleDetail.setCreateBy(sale.getCreateBy()); + saleDetail.setDelFlag(CommonConstant.DEL_FLAG_FALSE); saleDetailList2.add(saleDetail); } } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesCalculateServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesCalculateServiceImpl.java index 9ce8a748..d35a0437 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesCalculateServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesCalculateServiceImpl.java @@ -3,11 +3,12 @@ package cc.hiver.mall.serviceimpl; import cc.hiver.core.common.constant.CommonConstant; import cc.hiver.core.common.constant.SaleConstant; import cc.hiver.core.common.utils.SecurityUtil; +import cc.hiver.mall.bill.vo.SupplierBillQueryVo; +import cc.hiver.mall.dao.mapper.PurchaseDetailMapper; import cc.hiver.mall.dao.mapper.ReturnSaleMapper; import cc.hiver.mall.dao.mapper.SaleMapper; import cc.hiver.mall.entity.ReturnSaleExample; import cc.hiver.mall.entity.Sale; -import cc.hiver.mall.entity.SaleDetail; import cc.hiver.mall.entity.SaleExample; import cc.hiver.mall.pojo.vo.SaleAllVO; import cc.hiver.mall.pojo.vo.TotalAlreadyEarnDetailVo; @@ -52,6 +53,9 @@ public class SalesCalculateServiceImpl implements SalesCalculateService { @Autowired private SecurityUtil securityUtil; + @Autowired + private PurchaseDetailMapper purchaseDetailMapper; + @Override public SaleAllVO calculateService(String startTime, String endTime){ @@ -113,7 +117,7 @@ public class SalesCalculateServiceImpl implements SalesCalculateService { // saleAllVO.setReturnTotalAmount(totalAmount2); - saleAllVO.setReturnTotalCount(totalCount2); + saleAllVO.setReturnTotalCount(totalJCount2); // 鎬讳欢鏁版殏鏃舵病鐢ㄧ潃 // saleAllVO.setTotalJCount(totalJCount1 - totalJCount2); @@ -133,13 +137,13 @@ public class SalesCalculateServiceImpl implements SalesCalculateService { }*/ //鑾峰彇褰撴棩闂ㄥ簵鍒╂鼎(褰撴棩鎬昏惀鏀-褰撴棩鎬绘垚鏈+锛堥璐ф昏惀鏀-閫璐ф绘垚鏈級) - BigDecimal totalPurchasePrice = new BigDecimal("0.0"); + /*BigDecimal totalPurchasePrice = new BigDecimal("0.0"); final List list = saleDetailService.listOfShopAll(shopId,startTime,endTime); for (SaleDetail saleDetail : list) { final BigDecimal purchasePrice = saleDetail.getPurchasePrice() == null ? BigDecimal.ZERO :saleDetail.getPurchasePrice(); final int productCount = saleDetail.getProductCount() == null ? 0 : saleDetail.getProductCount(); totalPurchasePrice = totalPurchasePrice.add(purchasePrice.multiply(new BigDecimal(productCount))); - } + }*/ /*final QueryWrapper returnDetailQueryWrapper = new QueryWrapper<>(); returnDetailQueryWrapper.eq("shop_id", shopId) .between("create_time", startDate, endDate); @@ -150,8 +154,9 @@ public class SalesCalculateServiceImpl implements SalesCalculateService { final int productCount = returnDetail.getProductCount(); totalReturnPurchasePrice = totalReturnPurchasePrice.add(purchasePrice.multiply(new BigDecimal(productCount))); }*/ - // 鍒╂鼎= 閿鍞婚噾棰-鎴愭湰 - saleAllVO.setTotalProfit(saleAllVO.getTotalAmount().subtract(totalPurchasePrice)); + // 鍒╂鼎 + BigDecimal totalPurchasePrice = saleDetailService.getTotalProfit(shopId,startTime,endTime); + saleAllVO.setTotalProfit(totalPurchasePrice); //鑾峰彇褰撴棩闂ㄥ簵涓嬪崟瀹㈡埛鏁 final QueryWrapper querySaleWrapper = new QueryWrapper<>(); @@ -181,9 +186,17 @@ public class SalesCalculateServiceImpl implements SalesCalculateService { // 20240805 澧炲姞闇瑕佸姞涓涓粖鏃ラ攢鍞讳欢鏁帮細鏌ale琛ㄧ殑prodect_count鎬诲拰 鐘舵乨elflag=0锛泂tatus=4鐨 - //鑾峰彇浠婃棩瀹炴敹 + //鑾峰彇閿鍞讳欢鏁 final int totalJCount = saleMapper.queryTotalJCount(shopId,startTime,endTime); saleAllVO.setTotalJCount(totalJCount); + + //鑾峰彇杩涜揣鎬讳欢鏁 + SupplierBillQueryVo supplierBillQueryVo = new SupplierBillQueryVo(); + supplierBillQueryVo.setShopId(shopId); + supplierBillQueryVo.setStartDate(startTime); + supplierBillQueryVo.setEndDate(endTime); + final int purchasingCount = purchaseDetailMapper.queryPurchasingCount(supplierBillQueryVo); + saleAllVO.setPurchasingCount(purchasingCount); return saleAllVO; } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ShopUserServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ShopUserServiceImpl.java index 87184458..bdea6d0e 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ShopUserServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ShopUserServiceImpl.java @@ -50,4 +50,9 @@ public class ShopUserServiceImpl implements ShopUserService { public List findByShopId(String shopId){ return shopUserDao.findByShopId(shopId); } + + @Override + public void deleteAllByShopIdAndUserId(String shopId, String shopOwnerId) { + shopUserDao.deleteAllByShopIdAndUserId(shopId, shopOwnerId); + } } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/StockAndLogServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/StockAndLogServiceImpl.java index 5033b65f..03b8ad27 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/StockAndLogServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/StockAndLogServiceImpl.java @@ -53,7 +53,7 @@ public class StockAndLogServiceImpl implements StockAndLogService { //2.璁板綍搴撳瓨灞ュ巻 final StockLog stockLog = new StockLog(); - stockLog.setChangeType("1");//鍑哄簱 + stockLog.setChangeType(StockLogConstant.CHANGE_TYPE[1]);//鍑哄簱 stockLog.setProductId(saleDetail.getProductId()); stockLog.setAttributeList(saleDetail.getAttributeList()); stockLog.setStock(stockCount);//鍑哄簱鍓嶆暟閲 @@ -84,7 +84,7 @@ public class StockAndLogServiceImpl implements StockAndLogService { //2.璁板綍搴撳瓨灞ュ巻 final StockLog stockLog = new StockLog(); - stockLog.setChangeType("0");//閫璐-鍏ュ簱 + stockLog.setChangeType(StockLogConstant.CHANGE_TYPE[0]);//閫璐-鍏ュ簱 stockLog.setProductId(saleDetail.getProductId()); stockLog.setAttributeList(saleDetail.getAttributeList()); stockLog.setStock(stockCount);//閫璐-鍏ュ簱鍓嶆暟閲 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 72e71e9d..47075691 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 @@ -183,96 +183,118 @@ public class ProductServiceImpl extends ServiceImpl impl // shopId浠庣紦瀛樹腑璁剧疆 // 鍒ゆ柇鏄惁鏂扮殑鍟嗗搧锛屾柊鐨勫晢鍝佽繘琛屾柊澧 final String productId = saleDetailDTO.getProductId(); - if (StringUtils.isEmpty(productId)) { - // 鏂板鍟嗗搧 - final Product product = new Product(); - product.setCreateBy(user.getId()); - product.setCreateTime(new Date()); - product.setProductName(saleDetailDTO.getProductName()); - product.setShopId(shopId); - // 榛樿涓哄凡涓婃灦鐨 - product.setDelFlag(ProductConstant.DEL_FLAG[1]); - product.setCategoryId(saleDetailDTO.getCategoryId()); - product.setSupplierName(saleDetailDTO.getSupplierName()); - product.setProductSn(saleDetailDTO.getProductSn()); - // 闆跺敭浠 - product.setPrice(saleDetailDTO.getPrice()); - // 閲囪喘浠 - product.setPurchasePrice(saleDetailDTO.getPurchasePrice()); - // 鎵瑰彂浠 - product.setWholesalePrice(saleDetailDTO.getWholesalePrice()); - product.setProductPicture(saleDetailDTO.getProductPicture()); - product.setInStorageStatus(PurchaseConstant.IN_STORAGE_STATUS[1]); + if (StringUtils.isEmpty(productId) ) { + // 璐у彿鎴栬呭晢鍝佸悕绉伴兘涓虹┖鐨勬椂鍊欎笉鏂板锛屽叾浠栨椂鍊欐柊澧炲晢鍝 + if (StringUtils.isEmpty(saleDetailDTO.getProductSn()) && StringUtils.isEmpty(saleDetailDTO.getProductName())) { + continue; + } + // 鏍规嵁璐у彿鏌ヨ鍟嗗搧鏄惁瀛樺湪 + CopyOnWriteArrayList oldProductListBySn = getByProductSn(saleDetailDTO.getProductSn(), shopId); + if (oldProductListBySn != null && !oldProductListBySn.isEmpty()) { + // 鏃у晢鍝侊紝璧嬪煎晢鍝乮d + saleDetailDTO.setProductId(oldProductListBySn.get(0).getId()); + }else{ + // 鏂板鍟嗗搧 + final Product product = new Product(); + product.setCreateBy(user.getId()); + product.setCreateTime(new Date()); + product.setProductName(saleDetailDTO.getProductName()); + product.setShopId(shopId); + // 榛樿涓哄凡涓婃灦鐨 + product.setDelFlag(ProductConstant.DEL_FLAG[1]); + product.setCategoryId(saleDetailDTO.getCategoryId()); + product.setSupplierName(saleDetailDTO.getSupplierName()); + product.setProductSn(saleDetailDTO.getProductSn()); + // 闆跺敭浠 + product.setPrice(saleDetailDTO.getPrice()); + // 閲囪喘浠 + product.setPurchasePrice(saleDetailDTO.getPurchasePrice()); + // 鎵瑰彂浠 + product.setWholesalePrice(saleDetailDTO.getWholesalePrice()); + product.setProductPicture(saleDetailDTO.getProductPicture()); + product.setInStorageStatus(PurchaseConstant.IN_STORAGE_STATUS[1]); - // 鏀惧埌瑕佹煡璇㈢殑id涓 - // 濉厖鍓嶅彴浼犺繃鏉ョ殑鏁版嵁 - saleDetailDTO.setProductId(product.getId()); - if (saleDetailDTO.getProductPictures() != null) { - // 鏂板鍟嗗搧鍥剧墖瀛愬浘 - for (ProductPicture productPicture : saleDetailDTO.getProductPictures()) { - productPicture.setProductId(product.getId()); + // 鏀惧埌瑕佹煡璇㈢殑id涓 + // 濉厖鍓嶅彴浼犺繃鏉ョ殑鏁版嵁 + saleDetailDTO.setProductId(product.getId()); + if (saleDetailDTO.getProductPictures() != null) { + // 鏂板鍟嗗搧鍥剧墖瀛愬浘 + for (ProductPicture productPicture : saleDetailDTO.getProductPictures()) { + productPicture.setProductId(product.getId()); + } + addProductPictureList.addAll(saleDetailDTO.getProductPictures()); } - addProductPictureList.addAll(saleDetailDTO.getProductPictures()); - } - // 灏嗚鏍煎強瑙勬牸涓嬬殑瑙勬牸鍊兼彁鍙栧嚭鏉 - final List stockLogList1 = saleDetailDTO.getStockLogList1(); - for (SaleDetailQueryDTO saleDetailQueryDTO : stockLogList1) { - final String attributeList = saleDetailQueryDTO.getAttributeList(); - final JSONObject jsonObject = JSONUtil.parseObj(attributeList); - for (Map.Entry stringObjectEntry : jsonObject.entrySet()) { - final String key = stringObjectEntry.getKey(); - String value = String.valueOf(stringObjectEntry.getValue()); - // 鏍规嵁瑙勬牸id瑙勬牸鏄鑹层佽繕鏄昂鐮併 - if ("棰滆壊".equals(key)) { - if (!value.contains("鑹")) { - value += '鑹'; - } - } else if ("灏虹爜".equals(key)) { - final String valueUpperCase = value.toUpperCase(); - if (value.contains("鐮")) { - value = valueUpperCase; + // 灏嗚鏍煎強瑙勬牸涓嬬殑瑙勬牸鍊兼彁鍙栧嚭鏉 + final List stockLogList1 = saleDetailDTO.getStockLogList1(); + for (SaleDetailQueryDTO saleDetailQueryDTO : stockLogList1) { + final String attributeList = saleDetailQueryDTO.getAttributeList(); + final StringBuilder newAttributeList = new StringBuilder(); + newAttributeList.append("{"); + StringBuilder colorStr = new StringBuilder("\"棰滆壊\":"); + StringBuilder sizeStr = new StringBuilder("\"灏虹爜\":"); + final JSONObject jsonObject = JSONUtil.parseObj(attributeList); + for (Map.Entry stringObjectEntry : jsonObject.entrySet()) { + final String key = stringObjectEntry.getKey(); + String value = String.valueOf(stringObjectEntry.getValue()); + // 鏍规嵁瑙勬牸id瑙勬牸鏄鑹层佽繕鏄昂鐮併 + if ("棰滆壊".equals(key)) { + if (!value.contains("鑹")) { + value += '鑹'; + } + colorStr.append('"' +value+ '"'); + } else if ("灏虹爜".equals(key)) { + final String valueUpperCase = value.toUpperCase(); + if (value.contains("鐮")) { + value = valueUpperCase; + } else { + value = valueUpperCase + '鐮'; + } + sizeStr.append('"' +value+ '"'); } else { - value = valueUpperCase + '鐮'; + // 鏆備笉鏀寔鍏朵粬瑙勬牸 } - } else { - // 鏆備笉鏀寔鍏朵粬瑙勬牸 - } - if (attributeValueMap.containsKey(key)) { - final List strings = attributeValueMap.get(key); - if (!strings.contains(value)) { - strings.add(value); + if (attributeValueMap.containsKey(key)) { + final List strings = attributeValueMap.get(key); + if (!strings.contains(value)) { + strings.add(value); + } + } else { + final List valueList = new ArrayList<>(); + valueList.add(value); + attributeValueMap.put(key, valueList); } - } else { - final List valueList = new ArrayList<>(); - valueList.add(value); - attributeValueMap.put(key, valueList); } + newAttributeList.append(colorStr); + newAttributeList.append(','); + newAttributeList.append(sizeStr); + newAttributeList.append('}'); + saleDetailQueryDTO.setAttributeList(newAttributeList.toString()); } - } - final CopyOnWriteArrayList productAttributeOfAddVos = new CopyOnWriteArrayList<>(); - for (Map.Entry> stringListEntry : attributeValueMap.entrySet()) { - final String key = stringListEntry.getKey(); - final List entryValue = stringListEntry.getValue(); - final ProductAttributeOfAddVo productAttributeOfAddVo = new ProductAttributeOfAddVo(); - productAttributeOfAddVo.setAttributeName(key); - final CopyOnWriteArrayList productAttributeValueVoList = new CopyOnWriteArrayList<>(); - for (String s : entryValue) { - final ProductAttributeValueVo productAttributeValueVo = new ProductAttributeValueVo(); - productAttributeValueVo.setValue(s); - productAttributeValueVoList.add(productAttributeValueVo); + final CopyOnWriteArrayList productAttributeOfAddVos = new CopyOnWriteArrayList<>(); + for (Map.Entry> stringListEntry : attributeValueMap.entrySet()) { + final String key = stringListEntry.getKey(); + final List entryValue = stringListEntry.getValue(); + final ProductAttributeOfAddVo productAttributeOfAddVo = new ProductAttributeOfAddVo(); + productAttributeOfAddVo.setAttributeName(key); + final CopyOnWriteArrayList productAttributeValueVoList = new CopyOnWriteArrayList<>(); + for (String s : entryValue) { + final ProductAttributeValueVo productAttributeValueVo = new ProductAttributeValueVo(); + productAttributeValueVo.setValue(s); + productAttributeValueVoList.add(productAttributeValueVo); + } + productAttributeOfAddVo.setProductAttributeValueVoList(productAttributeValueVoList); + productAttributeOfAddVos.add(productAttributeOfAddVo); } - productAttributeOfAddVo.setProductAttributeValueVoList(productAttributeValueVoList); - productAttributeOfAddVos.add(productAttributeOfAddVo); + productCategoryVo.setProductAttributeOfAddVos(productAttributeOfAddVos); + // 鎵归噺鍘绘柊澧烇紝骞舵嬁鍒板垎绫籭d锛屽洖濉晢鍝 + // 缁存姢璇ュ晢鍝佷笓灞炲垎绫 + final String s = productCategoryService.batchSaveCategoryAndAttribute(productCategoryVo); + // 缁存姢璇ュ簵閾虹殑涓撳睘鍒嗙被 + productCategoryService.batchSaveCategoryOfShop(productCategoryVo); + product.setAttrId(s); + addProductList.add(product); } - productCategoryVo.setProductAttributeOfAddVos(productAttributeOfAddVos); - // 鎵归噺鍘绘柊澧烇紝骞舵嬁鍒板垎绫籭d锛屽洖濉晢鍝 - // 缁存姢璇ュ晢鍝佷笓灞炲垎绫 - final String s = productCategoryService.batchSaveCategoryAndAttribute(productCategoryVo); - // 缁存姢璇ュ簵閾虹殑涓撳睘鍒嗙被 - productCategoryService.batchSaveCategoryOfShop(productCategoryVo); - product.setAttrId(s); - addProductList.add(product); } } if (!addProductList.isEmpty()) { 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 ac6cc886..72906e0b 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 @@ -1,5 +1,6 @@ package cc.hiver.mall.serviceimpl.mybatis; +import cc.hiver.mall.bill.vo.SupplierBillQueryVo; import cc.hiver.mall.dao.mapper.PurchaseDetailMapper; import cc.hiver.mall.entity.PurchaseDetail; import cc.hiver.mall.entity.StockLog; @@ -104,4 +105,9 @@ public class PurchaseDetailServiceImpl extends ServiceImpl getPurchaseDetailListByProductIds(List productIdList, String id) { return purchaseDetailMapper.getPurchaseDetailListByProductIds(productIdList, id); } + + @Override + public Integer queryPurchasingCount(SupplierBillQueryVo supplierBillQueryVo) { + return purchaseDetailMapper.queryPurchasingCount(supplierBillQueryVo); + } } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ReturnSaleServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ReturnSaleServiceImpl.java index 3c988824..7f672f17 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ReturnSaleServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ReturnSaleServiceImpl.java @@ -4,6 +4,7 @@ import cc.hiver.core.common.utils.SecurityUtil; import cc.hiver.mall.bill.vo.ArrearsVo; import cc.hiver.mall.bill.vo.CustomerBillQueryVo; import cc.hiver.mall.dao.mapper.ReturnSaleMapper; +import cc.hiver.mall.entity.Product; import cc.hiver.mall.entity.ReturnDetail; import cc.hiver.mall.entity.ReturnSale; import cc.hiver.mall.pojo.dto.ReturnSaleDetailDTO; @@ -11,6 +12,7 @@ import cc.hiver.mall.pojo.dto.SaleDetailQueryDTO; import cc.hiver.mall.pojo.query.ReturnSalePageQuery; import cc.hiver.mall.pojo.vo.ReturnSaleVo; import cc.hiver.mall.pojo.vo.ReturnTotalAmountDetailVo; +import cc.hiver.mall.service.mybatis.ProductService; import cc.hiver.mall.service.mybatis.ReturnDetailService; import cc.hiver.mall.service.mybatis.ReturnSaleService; import cc.hiver.mall.utils.DateUtil; @@ -21,6 +23,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -38,6 +41,9 @@ public class ReturnSaleServiceImpl extends ServiceImpl returnSalePage = returnSaleMapper.getReturnSaleListByUserId(page, returnSalePageQuery); final List returnSaleList = returnSalePage.getRecords(); // 鏍规嵁鍟嗗搧id鑾峰彇閫璐ц缁嗕俊鎭 - List returnSaleIdList = new ArrayList<>(); + final List returnSaleIdList = new ArrayList<>(); for (ReturnSaleVo returnSaleVo : returnSaleList) { returnSaleIdList.add(returnSaleVo.getId()); } @@ -172,6 +187,7 @@ public class ReturnSaleServiceImpl extends ServiceImpl returnDetails = returnDetailService.getReturnDetailsByReturnId(returnSaleIdList); // 灏唕eturnDetails 鏀惧埌浠eturn_sale_id 涓簁ey ReturnDetail涓簐alue鐨刴ap涓幓 final Map> returnSaleMap = new HashMap<>(); + final List productIdList = new ArrayList<>(); for (ReturnDetail returnDetail : returnDetails) { final String returnSaleId = returnDetail.getReturnSaleId(); if (returnSaleMap.containsKey(returnSaleId)) { @@ -183,34 +199,68 @@ public class ReturnSaleServiceImpl extends ServiceImpl productList = productService.getProductList(productIdList); + // 灏佽涓簃ap + final Map productMap = new HashMap<>(); + for (Product product : productList) { + productMap.putIfAbsent(product.getId(), product); } // 灏嗚缁嗕俊鎭皝瑁呭埌杩斿洖缁撴灉涓幓 for (ReturnSaleVo returnSaleVo : returnSaleList) { final String id = returnSaleVo.getId(); // 浠巖eturnSaleMap鑾峰彇锛屽苟灏佽 if (returnSaleMap.containsKey(id)) { - // 杩欐槸鏄牴鎹鍟嗗搧id鏌ヨ鐨勶紝鎵浠ヨ偗瀹氭槸鍚屼竴浠跺晢鍝侊紝骞朵笖鍦ㄥ悓涓涓鍗曚腑閲囪喘浠风瓑涔熸槸涓鏍 - // 鎵浠ュ晢鍝佷俊鎭惊鐜鐩栧嵆鍙紝姣忎竴涓鎯呯浉褰撲簬涓绉嶈鏍 + final List returnSaleDetailList = new ArrayList<>(); - final ReturnSaleDetailDTO returnSaleDetailDTO = new ReturnSaleDetailDTO(); + final List returnDetailList = returnSaleMap.get(id); - final List stockLogList1 = new ArrayList<>(); + + // 鏍规嵁productId 鍒嗙粍涓簃ap + final Map> returnDetailMap = new HashMap<>(); for (ReturnDetail returnDetail : returnDetailList) { - returnSaleDetailDTO.setProductId(returnDetail.getProductId()); - returnSaleDetailDTO.setProductName(returnDetail.getProductName()); - returnSaleDetailDTO.setProductCount(returnDetail.getProductCount()); - returnSaleDetailDTO.setRealPrice(returnDetail.getRealPrice()); - returnSaleDetailDTO.setProductSn(returnDetail.getProductSn()); - returnSaleDetailDTO.setPurchasePrice(returnDetail.getPurchasePrice()); - returnSaleDetailDTO.setDiscountAmount(returnDetail.getDiscountAmount()); + if (returnDetailMap.containsKey(returnDetail.getProductId())){ + returnDetailMap.get(returnDetail.getProductId()).add(returnDetail); + }else{ + final List thisProductReturnDetailList = new ArrayList<>(); + thisProductReturnDetailList.add(returnDetail); + returnDetailMap.put(returnDetail.getProductId(),thisProductReturnDetailList); + } + } + + for (Map.Entry> entry : returnDetailMap.entrySet()) { + final List thisProductReturnDetailList = entry.getValue(); + // 鍚屼竴娆惧晢鍝佸尯绗竴涓嵆鍙紝瑙勬牸涓嶅悓鑰屽凡 + final ReturnDetail firstReturnDetail = thisProductReturnDetailList.get(0); + + final ReturnSaleDetailDTO returnSaleDetailDTO = new ReturnSaleDetailDTO(); + final List stockLogList1 = new ArrayList<>(); + returnSaleDetailDTO.setProductId(firstReturnDetail.getProductId()); + returnSaleDetailDTO.setProductName(firstReturnDetail.getProductName()); + returnSaleDetailDTO.setProductCount(firstReturnDetail.getProductCount()); + returnSaleDetailDTO.setRealPrice(firstReturnDetail.getRealPrice()); + returnSaleDetailDTO.setProductSn(firstReturnDetail.getProductSn()); + if(productMap.containsKey(firstReturnDetail.getProductId())){ + final Product product = productMap.get(firstReturnDetail.getProductId()); + final BigDecimal purchasePrice = product.getPurchasePrice() == null ? BigDecimal.ZERO : product.getPurchasePrice(); + returnSaleDetailDTO.setPurchasePrice(purchasePrice); + }else{ + returnSaleDetailDTO.setPurchasePrice(firstReturnDetail.getPurchasePrice()); + } + returnSaleDetailDTO.setPurchasePrice(firstReturnDetail.getPurchasePrice()); + returnSaleDetailDTO.setDiscountAmount(firstReturnDetail.getDiscountAmount()); // 璇︾粏瑙勬牸 - final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO(); - saleDetailQueryDTO.setAttributeList(returnDetail.getAttributeList()); - saleDetailQueryDTO.setProductCount(returnDetail.getProductCount()); - stockLogList1.add(saleDetailQueryDTO); + for (ReturnDetail returnDetail : thisProductReturnDetailList) { + final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO(); + saleDetailQueryDTO.setAttributeList(returnDetail.getAttributeList()); + saleDetailQueryDTO.setProductCount(returnDetail.getProductCount()); + stockLogList1.add(saleDetailQueryDTO); + } + returnSaleDetailDTO.setStockLogList1(stockLogList1); + returnSaleDetailList.add(returnSaleDetailDTO); } - returnSaleDetailDTO.setStockLogList1(stockLogList1); - returnSaleDetailList.add(returnSaleDetailDTO); + returnSaleVo.setReturnSaleDetailList(returnSaleDetailList); } } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleDetailServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleDetailServiceImpl.java index bc6ae838..e0d0495d 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleDetailServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleDetailServiceImpl.java @@ -5,6 +5,7 @@ import cc.hiver.mall.dao.mapper.SaleDetailMapper; import cc.hiver.mall.dao.mapper.StockLogMapper; import cc.hiver.mall.dao.mapper.StockMapper; import cc.hiver.mall.entity.PurchaseDetail; +import cc.hiver.mall.entity.Sale; import cc.hiver.mall.entity.SaleDetail; import cc.hiver.mall.entity.SaleDetailExample; import cc.hiver.mall.service.mybatis.SaleDetailService; @@ -13,6 +14,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.util.List; @Service @@ -81,4 +83,14 @@ public class SaleDetailServiceImpl extends ServiceImpl getSaleDetailListByProductIds(List productIdList) { return saleDetailMapper.getSaleDetailListByProductIds(productIdList); } + + @Override + public List selectDetailListByProductIds(List productIdList, Sale sale) { + return saleDetailMapper.selectDetailListByProductIds(productIdList,sale); + } + + @Override + public BigDecimal getTotalProfit(String shopId, String startTime, String endTime) { + return saleDetailMapper.getTotalProfit(shopId, startTime, endTime); + } } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java index 7fda31de..ac8aa036 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java @@ -213,14 +213,18 @@ public class SaleServiceImpl extends ServiceImpl implements Sa saleDetailDTO.setSaleId(saleDetail.getSaleId()); saleDetailDTO.setPrice(saleDetail.getPrice()); saleDetailDTO.setWholesalePrice(saleDetail.getWholesalePrice()); - saleDetailDTO.setPurchasePrice(saleDetail.getPurchasePrice()); + saleDetailDTO.setDiscount(saleDetail.getDiscount()); saleDetailDTO.setDiscountAmount(saleDetail.getDiscountAmount()); saleDetailDTO.setRealPrice(saleDetail.getRealPrice()); // 鍥炲~鍟嗗搧鐨勭殑鍥剧墖鍙婅揣鍙 if (productMap.containsKey(productId)) { + BigDecimal purchasePrice = productMap.get(productId).getPurchasePrice() == null ? BigDecimal.ZERO : productMap.get(productId).getPurchasePrice(); + saleDetailDTO.setPurchasePrice(purchasePrice); saleDetailDTO.setProductPicture(productMap.get(productId).getProductPicture()); saleDetailDTO.setProductSn(productMap.get(productId).getProductSn()); + }else{ + saleDetailDTO.setPurchasePrice(saleDetail.getPurchasePrice()); } final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO(); @@ -298,7 +302,18 @@ public class SaleServiceImpl extends ServiceImpl implements Sa queryPWrapper.eq("product_id", salePageQuery.getProductId()); queryPWrapper.in("sale_id", saleIdList); final List saleDetailList = saleDetailService.list(queryPWrapper); - + // 鑾峰彇鍟嗗搧id + List productIdList = new ArrayList<>(); + for (SaleDetail saleDetail : saleDetailList) { + productIdList.add(saleDetail.getProductId()); + } + // 鏍规嵁鍟嗗搧id缁撳悎鑾峰彇鍟嗗搧淇℃伅 + final List productList = productService.getProductList(productIdList); + // 灏嗗晢鍝佷俊鎭浆涓簃ap ,鏂逛究鑾峰彇 + final Map productMap = new HashMap<>(); + for (Product product : productList) { + productMap.putIfAbsent(product.getId(), product); + } // 杞崲涓篠aleDetailDTO final List saleDetailDTOS = new ArrayList<>(); for (SaleDetail saleDetail : saleDetailList) { @@ -311,7 +326,15 @@ public class SaleServiceImpl extends ServiceImpl implements Sa saleDetailDTO.setSaleId(saleDetail.getSaleId()); saleDetailDTO.setPrice(saleDetail.getPrice()); saleDetailDTO.setWholesalePrice(saleDetail.getWholesalePrice()); - saleDetailDTO.setPurchasePrice(saleDetail.getPurchasePrice()); + // 鍙栧晢鍝佺殑閲囪喘浠 + if(productMap.containsKey(saleDetail.getProductId())){ + Product product = productMap.get(saleDetail.getProductId()); + BigDecimal purchasePrice = product.getPurchasePrice() == null ? BigDecimal.ZERO : product.getPurchasePrice(); + saleDetailDTO.setPurchasePrice(purchasePrice); + }else{ + saleDetailDTO.setPurchasePrice(saleDetail.getPurchasePrice()); + } + saleDetailDTO.setDiscount(saleDetail.getDiscount()); saleDetailDTO.setDiscountAmount(saleDetail.getDiscountAmount()); saleDetailDTO.setRealPrice(saleDetail.getRealPrice()); @@ -635,6 +658,16 @@ public class SaleServiceImpl extends ServiceImpl implements Sa // 灏濊瘯浠庤揣鍙蜂腑鎻愬彇姝g‘鐨勮揣鍙凤紝鍥犱负璐у彿鍙兘鍖呭惈棰滆壊绛変俊鎭 productSn = CommonUtil.getProductSn(productSn); final String attributeList = object.getString("attributeList"); + String wholesalePriceStr = object.getString("wholesalePrice"); + BigDecimal wholesalePrice = BigDecimal.ZERO; + // 浣跨敤姝e垯琛ㄨ揪寮忔彁鍙栨暟瀛楅儴鍒 + final Pattern pattern = Pattern.compile("-?\\d+(\\.\\d+)?"); + final Matcher matcher = pattern.matcher(wholesalePriceStr); + if (matcher.find()) { + // 鑾峰彇鍖归厤鍒扮殑鏁板瓧瀛楃涓插苟杞崲涓築igDecimal + final String numericPart = matcher.group(); + wholesalePrice = new BigDecimal(numericPart); + } final JSONArray attributeListJsonArray = JSON.parseArray(attributeList); // 瀹氫箟涓涓猰ap,璐у彿涓簁ey,purchaseDetail 涓簐alue final Map purchaseDetailMap = new HashMap<>(); @@ -659,7 +692,13 @@ public class SaleServiceImpl extends ServiceImpl implements Sa saleDetailDTO.setCategoryId(categoryId); saleDetailDTO.setPrice(product.getPrice()); saleDetailDTO.setPurchasePrice(product.getPurchasePrice()); - saleDetailDTO.setWholesalePrice(product.getWholesalePrice()); + // 濡傛灉閫氫箟鍗冮棶杩斿洖浜嗘壒鍙戜环锛岄偅涔堝氨浣跨敤閫氫箟鍗冮棶杩斿洖鐨勬壒鍙戜环 + if (wholesalePrice.compareTo(BigDecimal.ZERO) > 0) { + saleDetailDTO.setWholesalePrice(wholesalePrice); + } else { + saleDetailDTO.setWholesalePrice(product.getWholesalePrice()); + } + saleDetailDTO.setProductPicture(product.getProductPicture()); saleDetailDTO.setProductSn(product.getProductSn()); saleDetailDTO.setProductCount(0); @@ -770,6 +809,7 @@ public class SaleServiceImpl extends ServiceImpl implements Sa // 娌℃煡鍒,灏佽鏁版嵁锛岃揣鍙蜂负id final SaleDetailDTO saleDetailDTO = new SaleDetailDTO(); saleDetailDTO.setProductSn(productSn); + saleDetailDTO.setWholesalePrice(wholesalePrice); saleDetailDTO.setProductCount(0); // 鑾峰彇榛樿鍒嗙被 final ProductCategoryVo defaultCategory = productCategoryService.getDefaultCategory(shopId); @@ -1162,6 +1202,52 @@ public class SaleServiceImpl extends ServiceImpl implements Sa } } + /** + * 鍒╂鼎鏄庣粏-鎸夊鎴 + * + * @param salePageQuery + * @return Page + * @author 鐜嬪瘜搴 + * @date 2024/8/18 + */ + @Override + public Page totalAmountDetailByCustomer(SalePageQuery salePageQuery) { + //缁撴潫鏃堕棿+1澶 + if (StringUtils.isNotEmpty(salePageQuery.getEndDate())) { + final String endDate = DateUtil.addDay(salePageQuery.getEndDate(), 1); + salePageQuery.setEndDate(endDate); + } + final Page page = new Page<>(salePageQuery.getPageNum(), salePageQuery.getPageSize()); + // shopId浠庣紦瀛樹腑璁剧疆 + final String shopId = securityUtil.getShopId(); + salePageQuery.setShopId(shopId); + Page totalAmountDetailByCustomerVoPage = saleMapper.totalAmountDetailByCustomer(page, salePageQuery); + return totalAmountDetailByCustomerVoPage; + } + + /** + * 鍒╂鼎鏄庣粏-鎸夊晢鍝 + * + * @param salePageQuery + * @return Page + * @author 鐜嬪瘜搴 + * @date 2024/8/18 + */ + @Override + public Page totalAmountDetailByProduct(SalePageQuery salePageQuery) { + //缁撴潫鏃堕棿+1澶 + if (StringUtils.isNotEmpty(salePageQuery.getEndDate())) { + final String endDate = DateUtil.addDay(salePageQuery.getEndDate(), 1); + salePageQuery.setEndDate(endDate); + } + final Page page = new Page<>(salePageQuery.getPageNum(), salePageQuery.getPageSize()); + // shopId浠庣紦瀛樹腑璁剧疆 + final String shopId = securityUtil.getShopId(); + salePageQuery.setShopId(shopId); + Page totalAmountDetailByProductVoPage = saleMapper.totalAmountDetailByProduct(page, salePageQuery); + return totalAmountDetailByProductVoPage; + } + /** * 浣跨敤姝e垯琛ㄨ揪寮忔浛鎹㈣緭鍏ュ瓧绗︿覆涓繛缁殑鈥滃弶鈥濆瓧绗︿负鐩稿簲鏁伴噺鐨勨淴鈥濆瓧绗︺ * 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 c64b2f96..27992318 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 @@ -2,6 +2,8 @@ package cc.hiver.mall.serviceimpl.mybatis; import cc.hiver.core.common.constant.CommonConstant; import cc.hiver.core.common.constant.ProductConstant; +import cc.hiver.core.common.constant.UserConstant; +import cc.hiver.core.common.exception.HiverException; import cc.hiver.core.common.utils.ResultUtil; import cc.hiver.core.common.utils.SecurityUtil; import cc.hiver.core.common.utils.SnowFlakeUtil; @@ -10,6 +12,7 @@ import cc.hiver.core.common.vo.Result; import cc.hiver.core.entity.User; import cc.hiver.mall.common.constant.PurchaseConstant; import cc.hiver.mall.common.constant.StockConstant; +import cc.hiver.mall.common.constant.StockLogConstant; import cc.hiver.mall.dao.mapper.StockMapper; import cc.hiver.mall.debt.service.DebtService; import cc.hiver.mall.entity.*; @@ -17,6 +20,12 @@ import cc.hiver.mall.pojo.query.StockPageQuery; import cc.hiver.mall.pojo.vo.*; import cc.hiver.mall.productpicture.entity.ProductPicture; import cc.hiver.mall.productpicture.service.ProductPictureService; +import cc.hiver.mall.purchasereturn.constant.PurchaseReturnConstant; +import cc.hiver.mall.purchasereturn.entity.PurchaseReturn; +import cc.hiver.mall.purchasereturn.entity.PurchaseReturnDetail; +import cc.hiver.mall.purchasereturn.service.PurchaseReturnDetailService; +import cc.hiver.mall.purchasereturn.service.PurchaseReturnService; +import cc.hiver.mall.purchasereturn.vo.PurchaseReturnVo; import cc.hiver.mall.service.mybatis.*; import cc.hiver.mall.utils.DateUtil; import com.alibaba.fastjson.JSON; @@ -68,6 +77,12 @@ public class StockServiceImpl extends ServiceImpl implements @Autowired private DebtService debtService; + @Autowired + private PurchaseReturnService purchaseReturnService; + + @Autowired + private PurchaseReturnDetailService purchaseReturnDetailService; + @Transactional @Override public Result putIn(PurchaseVo purchaseVo) { @@ -332,7 +347,7 @@ public class StockServiceImpl extends ServiceImpl implements stockLog.setProductId(purchaseDetail.getProductId()); stockLog.setOrderId(purchase.getId()); //鍏ュ簱 - stockLog.setChangeType("0"); + stockLog.setChangeType(StockLogConstant.CHANGE_TYPE[0]); //鍏ュ簱鍓嶆暟閲 stockLog.setStock(stockCount); stockLog.setShopId(shopId); @@ -459,7 +474,7 @@ public class StockServiceImpl extends ServiceImpl implements // 涓庝箣鍓嶇浉绛夛紝涓嶅彉 } else { for (Stock stock : productStockList) { - final int oldStockCount = stock.getStockCount(); + final int oldStockCount = stock.getStockCount() == null ? 0 : stock.getStockCount(); if (oldStockCount <= 0) { // 濡傛灉搴撳瓨涓鸿礋鏁帮紝閭d箞灏遍渶瑕佷互鏂板叆搴撶殑閲囪喘浠疯绠楁垚鏈 newProductCount += Math.abs(oldStockCount); @@ -541,7 +556,7 @@ public class StockServiceImpl extends ServiceImpl implements if (purchaseDetailService.saveOrUpdateBatch(purchaseDetails)) { // 鏇存柊鍟嗗搧淇℃伅 productService.saveOrUpdateBatch(updateProductList); - // 寮傛鏇存柊渚涘簲鍟嗘瑺娆句俊鎭満娆犳璁板綍 + // 鏇存柊渚涘簲鍟嗘瑺娆句俊鎭満娆犳璁板綍 debtService.purchaseToDebt(purchase); return ResultUtil.success("娣诲姞鎴愬姛"); } else { @@ -604,7 +619,7 @@ public class StockServiceImpl extends ServiceImpl implements final Integer tailWarn = product.getTailWarn(); //骞冲潎閲囪喘浠 final BigDecimal purchasePrice = product.getPurchasePrice() == null ? new BigDecimal(0) : product.getPurchasePrice(); - final Integer thisStockCount = stock.getStockCount()==null?0:stock.getStockCount(); + final Integer thisStockCount = stock.getStockCount() == null ? 0 : stock.getStockCount(); // 璁$畻鎴愭湰锛岃礋鏁版寜0璁$畻 if (thisStockCount > 0) { final BigDecimal thisStockCost = purchasePrice.multiply(BigDecimal.valueOf(thisStockCount)); @@ -759,103 +774,124 @@ public class StockServiceImpl extends ServiceImpl implements // 闇瑕佹柊澧炵殑 final Map> attributeValueMap = new HashMap<>(); if (StringUtils.isEmpty(productId)) { - // 鏂板鍟嗗搧 - final Product product = new Product(); - product.setCreateBy(user.getId()); - product.setCreateTime(new Date()); - product.setProductName(purchaseDetail.getProductName()); - product.setShopId(shopId); - // 榛樿涓哄凡涓婃灦鐨 - product.setDelFlag(ProductConstant.DEL_FLAG[1]); - product.setCategoryId(purchaseDetail.getCategoryId()); - // 鏂板晢鍝佺殑涓撳睘鍒嗙被id浣跨敤鍟嗗搧id - // product.setAttrId(product.getId()); - product.setSupplierId(purchaseDetail.getSupplierId()); - product.setSupplierName(purchaseDetail.getSupplierName()); - product.setProductSn(purchaseDetail.getProductSn()); - product.setBarcode(purchaseDetail.getBarcode()); - // 闆跺敭浠 - product.setPrice(purchaseDetail.getPrice()); - // 閲囪喘浠 - product.setPurchasePrice(purchaseDetail.getPurchasePrice()); - // 鎵瑰彂浠 - product.setWholesalePrice(purchaseDetail.getWholesalePrice()); - product.setProductPicture(purchaseDetail.getProductPicture()); - product.setProductIntro(purchaseDetail.getProductIntro()); - product.setSalesWeek(purchaseDetail.getSalesWeek()); - product.setPrintBarcode(purchaseDetail.getPrintBarcode()); - product.setTailWarn(purchaseDetail.getTailWarn()); - product.setInStorageStatus(PurchaseConstant.IN_STORAGE_STATUS[1]); - addProductList.add(product); - // 鏀惧埌瑕佹煡璇㈢殑id涓 - productIdList.add(product.getId()); - // 濉厖鍓嶅彴浼犺繃鏉ョ殑鏁版嵁 - purchaseDetail.setProductId(product.getId()); - // 鏂板鍟嗗搧鍥剧墖瀛愬浘 - if (purchaseDetail.getProductPictures() != null) { - for (ProductPicture productPicture : purchaseDetail.getProductPictures()) { - productPicture.setProductId(product.getId()); + // 20240824 澧炲姞璐у彿鍒ゆ柇鏄惁涓烘棫鍟嗗搧 + + // 鏍规嵁璐у彿鏌ヨ鍟嗗搧鏄惁瀛樺湪 + CopyOnWriteArrayList oldProductListBySn = productService.getByProductSn(purchaseDetail.getProductSn(), shopId); + if (oldProductListBySn != null && !oldProductListBySn.isEmpty()) { + // 鏃у晢鍝侊紝璧嬪煎晢鍝乮d + purchaseDetail.setProductId(oldProductListBySn.get(0).getId()); + // 鏃у晢鍝 + productIdList.add(productId); + }else{ + // 鏂板鍟嗗搧 + final Product product = new Product(); + product.setCreateBy(user.getId()); + product.setCreateTime(new Date()); + product.setProductName(purchaseDetail.getProductName()); + product.setShopId(shopId); + // 榛樿涓哄凡涓婃灦鐨 + product.setDelFlag(ProductConstant.DEL_FLAG[1]); + product.setCategoryId(purchaseDetail.getCategoryId()); + // 鏂板晢鍝佺殑涓撳睘鍒嗙被id浣跨敤鍟嗗搧id + // product.setAttrId(product.getId()); + product.setSupplierId(purchaseDetail.getSupplierId()); + product.setSupplierName(purchaseDetail.getSupplierName()); + product.setProductSn(purchaseDetail.getProductSn()); + product.setBarcode(purchaseDetail.getBarcode()); + // 闆跺敭浠 + product.setPrice(purchaseDetail.getPrice()); + // 閲囪喘浠 + product.setPurchasePrice(purchaseDetail.getPurchasePrice()); + // 鎵瑰彂浠 + product.setWholesalePrice(purchaseDetail.getWholesalePrice()); + product.setProductPicture(purchaseDetail.getProductPicture()); + product.setProductIntro(purchaseDetail.getProductIntro()); + product.setSalesWeek(purchaseDetail.getSalesWeek()); + product.setPrintBarcode(purchaseDetail.getPrintBarcode()); + product.setTailWarn(purchaseDetail.getTailWarn()); + product.setInStorageStatus(PurchaseConstant.IN_STORAGE_STATUS[1]); + addProductList.add(product); + // 鏀惧埌瑕佹煡璇㈢殑id涓 + productIdList.add(product.getId()); + // 濉厖鍓嶅彴浼犺繃鏉ョ殑鏁版嵁 + purchaseDetail.setProductId(product.getId()); + // 鏂板鍟嗗搧鍥剧墖瀛愬浘 + if (purchaseDetail.getProductPictures() != null) { + for (ProductPicture productPicture : purchaseDetail.getProductPictures()) { + productPicture.setProductId(product.getId()); + } + addProductPictureList.addAll(purchaseDetail.getProductPictures()); } - addProductPictureList.addAll(purchaseDetail.getProductPictures()); - } - // 灏嗚鏍煎強瑙勬牸涓嬬殑瑙勬牸鍊兼彁鍙栧嚭鏉 - final List stockLogList1 = purchaseDetail.getStockLogList1(); - for (StockLog stockLog : stockLogList1) { - final String attributeList = stockLog.getAttributeList(); - final JSONObject jsonObject = JSON.parseObject(attributeList); - for (Map.Entry stringObjectEntry : jsonObject.entrySet()) { - final String key = stringObjectEntry.getKey(); - String value = String.valueOf(stringObjectEntry.getValue()); - // 鏍规嵁瑙勬牸id瑙勬牸鏄鑹层佽繕鏄昂鐮併 - if ("棰滆壊".equals(key)) { - if (!value.contains("鑹")) { - value += '鑹'; - } - } else if ("灏虹爜".equals(key)) { - final String valueUpperCase = value.toUpperCase(); - if (value.contains("鐮")) { - value = valueUpperCase; + // 灏嗚鏍煎強瑙勬牸涓嬬殑瑙勬牸鍊兼彁鍙栧嚭鏉 + final List stockLogList1 = purchaseDetail.getStockLogList1(); + for (StockLog stockLog : stockLogList1) { + final String attributeList = stockLog.getAttributeList(); + final StringBuilder newAttributeList = new StringBuilder(); + newAttributeList.append("{"); + StringBuilder colorStr = new StringBuilder("\"棰滆壊\":"); + StringBuilder sizeStr = new StringBuilder("\"灏虹爜\":"); + final JSONObject jsonObject = JSON.parseObject(attributeList); + for (Map.Entry stringObjectEntry : jsonObject.entrySet()) { + final String key = stringObjectEntry.getKey(); + String value = String.valueOf(stringObjectEntry.getValue()); + // 鏍规嵁瑙勬牸id瑙勬牸鏄鑹层佽繕鏄昂鐮併 + if ("棰滆壊".equals(key)) { + if (!value.contains("鑹")) { + value += '鑹'; + } + colorStr.append('"' +value+ '"'); + } else if ("灏虹爜".equals(key)) { + final String valueUpperCase = value.toUpperCase(); + if (value.contains("鐮")) { + value = valueUpperCase; + } else { + value = valueUpperCase + '鐮'; + } + sizeStr.append('"' +value+ '"'); } else { - value = valueUpperCase + '鐮'; + // 鏆備笉鏀寔鍏朵粬瑙勬牸 } - } else { - // 鏆備笉鏀寔鍏朵粬瑙勬牸 - } - if (attributeValueMap.containsKey(key)) { - final List strings = attributeValueMap.get(key); - if (!strings.contains(value)) { - strings.add(value); + if (attributeValueMap.containsKey(key)) { + final List strings = attributeValueMap.get(key); + if (!strings.contains(value)) { + strings.add(value); + } + } else { + final List valueList = new ArrayList<>(); + valueList.add(value); + attributeValueMap.put(key, valueList); } - } else { - final List valueList = new ArrayList<>(); - valueList.add(value); - attributeValueMap.put(key, valueList); } + newAttributeList.append(colorStr); + newAttributeList.append(','); + newAttributeList.append(sizeStr); + newAttributeList.append('}'); + stockLog.setAttributeList(newAttributeList.toString()); } - } - final CopyOnWriteArrayList productAttributeOfAddVos = new CopyOnWriteArrayList<>(); - for (Map.Entry> stringListEntry : attributeValueMap.entrySet()) { - final String key = stringListEntry.getKey(); - final List entryValue = stringListEntry.getValue(); - final ProductAttributeOfAddVo productAttributeOfAddVo = new ProductAttributeOfAddVo(); - productAttributeOfAddVo.setAttributeName(key); - final CopyOnWriteArrayList productAttributeValueVoList = new CopyOnWriteArrayList<>(); - for (String s : entryValue) { - final ProductAttributeValueVo productAttributeValueVo = new ProductAttributeValueVo(); - productAttributeValueVo.setValue(s); - productAttributeValueVoList.add(productAttributeValueVo); + final CopyOnWriteArrayList productAttributeOfAddVos = new CopyOnWriteArrayList<>(); + for (Map.Entry> stringListEntry : attributeValueMap.entrySet()) { + final String key = stringListEntry.getKey(); + final List entryValue = stringListEntry.getValue(); + final ProductAttributeOfAddVo productAttributeOfAddVo = new ProductAttributeOfAddVo(); + productAttributeOfAddVo.setAttributeName(key); + final CopyOnWriteArrayList productAttributeValueVoList = new CopyOnWriteArrayList<>(); + for (String s : entryValue) { + final ProductAttributeValueVo productAttributeValueVo = new ProductAttributeValueVo(); + productAttributeValueVo.setValue(s); + productAttributeValueVoList.add(productAttributeValueVo); + } + productAttributeOfAddVo.setProductAttributeValueVoList(productAttributeValueVoList); + productAttributeOfAddVos.add(productAttributeOfAddVo); } - productAttributeOfAddVo.setProductAttributeValueVoList(productAttributeValueVoList); - productAttributeOfAddVos.add(productAttributeOfAddVo); + productCategoryVo.setProductAttributeOfAddVos(productAttributeOfAddVos); + // 鎵归噺鍘绘柊澧烇紝骞舵嬁鍒板垎绫籭d锛屽洖濉晢鍝 + // 缁存姢璇ュ晢鍝佷笓灞炲垎绫 + final String s = productCategoryService.batchSaveCategoryAndAttribute(productCategoryVo); + // 缁存姢璇ュ簵閾虹殑涓撳睘鍒嗙被 + // productCategoryService.batchSaveCategoryOfShop(productCategoryVo); + product.setAttrId(s); } - productCategoryVo.setProductAttributeOfAddVos(productAttributeOfAddVos); - // 鎵归噺鍘绘柊澧烇紝骞舵嬁鍒板垎绫籭d锛屽洖濉晢鍝 - // 缁存姢璇ュ晢鍝佷笓灞炲垎绫 - final String s = productCategoryService.batchSaveCategoryAndAttribute(productCategoryVo); - // 缁存姢璇ュ簵閾虹殑涓撳睘鍒嗙被 - // productCategoryService.batchSaveCategoryOfShop(productCategoryVo); - product.setAttrId(s); - } else { // 鏃у晢鍝侊紝鏇存柊鎵瑰彂浠峰拰闆跺敭浠 productIdList.add(productId); @@ -905,7 +941,7 @@ public class StockServiceImpl extends ServiceImpl implements stockQueryWrapper.eq("shop_id", shopId); final List productStockList = list(stockQueryWrapper); - if (purchaseDetail.getPurchasePrice() == null) { + if (purchaseDetail.getPurchasePrice() == null && user.getType().equals(UserConstant.USER_TYPE_NORMAL)) { // 鏈淮鎶ら噰璐环锛岃缃鍗曠姸鎬佷负寰呭叆搴擄紝杩欓噷鏄惊鐜殑锛屽墠绔鎺у埗鏈夊氨鍏ㄩ儴閮借鏈夛紝娌℃湁灏卞叏閮ㄦ病鏈夈 // 璁剧疆涓烘湭鍏ュ簱锛屽晢鍝佷笉璁$畻骞冲潎閲囪喘浠 purchase.setInStorageStatus(StockConstant.IN_STORAGE_STATUS[0]); @@ -916,7 +952,7 @@ public class StockServiceImpl extends ServiceImpl implements product.setInStorageStatus(StockConstant.IN_STORAGE_STATUS[1]); if (!productStockList.isEmpty()) { // 鏈夊簱瀛 - final BigDecimal newPurchasePrice = purchaseDetail.getPurchasePrice(); + final BigDecimal newPurchasePrice = purchaseDetail.getPurchasePrice() == null ? BigDecimal.ZERO : purchaseDetail.getPurchasePrice(); int newProductCount = purchaseDetail.getProductCount(); int oldProductCount = 0; final BigDecimal oldPurchasePrice = product.getPurchasePrice(); @@ -973,6 +1009,65 @@ public class StockServiceImpl extends ServiceImpl implements // 鏇存柊搴撳瓨鏁 final String categoryId = purchaseDetail.getCategoryId(); final String attrId = purchaseDetail.getAttrId(); + + for (StockLog stockLog : stockLogList) { + final String attributeList = stockLog.getAttributeList(); + final StringBuilder newAttributeList = new StringBuilder(); + newAttributeList.append("{"); + StringBuilder colorStr = new StringBuilder("\"棰滆壊\":"); + StringBuilder sizeStr = new StringBuilder("\"灏虹爜\":"); + // Ai鍏ュ簱鍙兘璇嗗埆棰滆壊鍜屽昂鐮侊紝鎵浠ヨ繖閲屽彲浠ョ洿鎺ュ啓姝 + final JSONObject jsonObject = JSON.parseObject(attributeList); + // 閫氳繃 keySet() 鏂规硶鑾峰彇鎵鏈 key 鍊煎苟閬嶅巻 + for (Map.Entry entry : jsonObject.entrySet()) { + // 鏍规嵁 key 鍊艰幏鍙栫浉搴旂殑 value + String value = (String) entry.getValue(); + // 瀵箆alue 杩涜瑙f瀽 + final String key = entry.getKey(); + // 20240330 鍙兘鏂板棰滆壊鍜屽昂鐮侊紝棰滆壊缁熶竴鏀逛负*鑹层佸昂鐮佺粺涓杞ぇ鍐欙紝鍔犫樼爜鈥; + // 鏍规嵁瑙勬牸id瑙勬牸鏄鑹层佽繕鏄昂鐮併 + if ("棰滆壊".equals(key)) { + if (!value.contains("鑹")) { + value += '鑹'; + } + colorStr.append('"' +value+ '"'); + } else if ("灏虹爜".equals(key)) { + final String valueUpperCase = value.toUpperCase(); + if (value.contains("鐮")) { + value = valueUpperCase; + } else { + value = valueUpperCase + '鐮'; + } + sizeStr.append('"' +value+ '"'); + } else { + // 鏆備笉鏀寔鍏朵粬瑙勬牸 + } + if (stringListMap.containsKey(attrId)) { + final Map> stringListMap1 = stringListMap.get(attrId); + if (stringListMap1.containsKey(key)) { + final List stringList = stringListMap1.get(key); + if (!stringList.contains(value)) { + stringList.add(value); + } + } else { + final List stringList = new ArrayList<>(); + stringList.add(value); + stringListMap1.put(key, stringList); + } + } else { + final Map> attributeListMap = new HashMap<>(); + final List stringList = new ArrayList<>(); + stringList.add(value); + attributeListMap.put(key, stringList); + stringListMap.put(attrId, attributeListMap); + } + } + newAttributeList.append(colorStr); + newAttributeList.append(','); + newAttributeList.append(sizeStr); + newAttributeList.append('}'); + stockLog.setAttributeList(newAttributeList.toString()); + } for (StockLog stockLog : stockLogList) { // 鏍规嵁鍟嗗搧id銆佸簵閾篿d銆佸晢鍝佸睘鎬ц幏鍙栧綋鍓嶅簱瀛 int stockCount = 0; @@ -1022,7 +1117,7 @@ public class StockServiceImpl extends ServiceImpl implements stockLog.setOrderId(purchaseId); stockLog.setDetailId(purchaseDetail.getId()); //鍏ュ簱 - stockLog.setChangeType("0"); + stockLog.setChangeType(StockLogConstant.CHANGE_TYPE[0]); //鍏ュ簱鍓嶆暟閲 stockLog.setStock(stockCount); stockLog.setShopId(shopId); @@ -1030,55 +1125,6 @@ public class StockServiceImpl extends ServiceImpl implements stockLog.setPurchasePrice(purchaseDetail.getPurchasePrice()); stockLogAddList.add(stockLog); } - - - for (StockLog stockLog : stockLogList) { - final String attributeList = stockLog.getAttributeList(); - // Ai鍏ュ簱鍙兘璇嗗埆棰滆壊鍜屽昂鐮侊紝鎵浠ヨ繖閲屽彲浠ョ洿鎺ュ啓姝 - final JSONObject jsonObject = JSON.parseObject(attributeList); - // 閫氳繃 keySet() 鏂规硶鑾峰彇鎵鏈 key 鍊煎苟閬嶅巻 - for (Map.Entry entry : jsonObject.entrySet()) { - // 鏍规嵁 key 鍊艰幏鍙栫浉搴旂殑 value - String value = (String) entry.getValue(); - // 瀵箆alue 杩涜瑙f瀽 - final String key = entry.getKey(); - // 20240330 鍙兘鏂板棰滆壊鍜屽昂鐮侊紝棰滆壊缁熶竴鏀逛负*鑹层佸昂鐮佺粺涓杞ぇ鍐欙紝鍔犫樼爜鈥; - // 鏍规嵁瑙勬牸id瑙勬牸鏄鑹层佽繕鏄昂鐮併 - if ("棰滆壊".equals(key)) { - if (!value.contains("鑹")) { - value += '鑹'; - } - } else if ("灏虹爜".equals(key)) { - final String valueUpperCase = value.toUpperCase(); - if (value.contains("鐮")) { - value = valueUpperCase; - } else { - value = valueUpperCase + '鐮'; - } - } else { - // 鏆備笉鏀寔鍏朵粬瑙勬牸 - } - if (stringListMap.containsKey(attrId)) { - final Map> stringListMap1 = stringListMap.get(attrId); - if (stringListMap1.containsKey(key)) { - final List stringList = stringListMap1.get(key); - if (!stringList.contains(value)) { - stringList.add(value); - } - } else { - final List stringList = new ArrayList<>(); - stringList.add(value); - stringListMap1.put(key, stringList); - } - } else { - final Map> attributeListMap = new HashMap<>(); - final List stringList = new ArrayList<>(); - stringList.add(value); - attributeListMap.put(key, stringList); - stringListMap.put(attrId, attributeListMap); - } - } - } } // 鍘绘柊澧炶鏍煎強灞炴т俊鎭 @@ -1184,6 +1230,11 @@ public class StockServiceImpl extends ServiceImpl implements stockMapper.batchReduceStockByLog(stockLogList); } + @Override + public void batchIncreaseStockByLog(List stockLogList) { + stockMapper.batchIncreaseStockByLog(stockLogList); + } + @Override public List getDefaultStockCount(List productIdList) { return stockMapper.getDefaultStockCount(productIdList); @@ -1200,4 +1251,84 @@ public class StockServiceImpl extends ServiceImpl implements public void deleteStockById(String id) { stockMapper.deleteById(id); } + + @Override + public Result putOutPrice(PurchaseReturnVo purchaseReturnVo) { + + // shopId浠庣紦瀛樹腑璁剧疆 + final String shopId = securityUtil.getShopId(); + // 鑾峰彇褰撳墠鐧诲綍浜 + final User user = securityUtil.getCurrUser(); + + // 1. 鍏ュ簱鍗曚富琛ㄤ俊鎭 + final PurchaseReturn putOutPurchase = purchaseReturnVo.getPurchase(); + putOutPurchase.setCreateByName(user.getNickname()); + putOutPurchase.setShopId(shopId); + putOutPurchase.setTotalAmount(putOutPurchase.getTotalAmount()); + putOutPurchase.setShouldPay(putOutPurchase.getShouldPay()); + putOutPurchase.setAlreadyPay(putOutPurchase.getAlreadyPay()); + putOutPurchase.setNoPay(putOutPurchase.getNoPay()); + putOutPurchase.setOtherPay(putOutPurchase.getOtherPay()); + // 鍏堜繚瀛樹竴閬嶏紝鍥犱负鍚庤竟鐢ㄥ埌浜嗗叆搴撳崟鐨刬d + purchaseReturnService.saveOrUpdate(putOutPurchase); + // 闇瑕佹柊澧炵殑灞ュ巻闆嗗悎 + final List stockLogAddList = new ArrayList<>(); + + // 2. 淇濆瓨鍟嗗搧鏄庣粏 + final List purchaseReturnDetails = purchaseReturnVo.getPurchaseDetails(); + // 2. 鎵e噺搴撳瓨 + // 闇瑕佷慨鏀圭殑鍟嗗搧淇℃伅闆嗗悎锛屽晢鍝佷腑鐨勫钩鍧囬噰璐环闇瑕佽绠 + final List productIdList = new ArrayList<>(); + for (PurchaseReturnDetail purchaseReturnDetail : purchaseReturnDetails) { + productIdList.add(purchaseReturnDetail.getProductId()); + // 灏嗛璐d鏀捐繘鍘 + purchaseReturnDetail.setPurchaseId(putOutPurchase.getId()); + // 灏佽涓浜涘叾浠栧弬鏁 + purchaseReturnDetail.setShopId(shopId); + } + purchaseReturnDetailService.saveBatch(purchaseReturnDetails); + // 鏍规嵁鍟嗗搧id闆嗗悎鑾峰彇搴撳瓨淇℃伅 + final List productStock = stockService.getProductStock(productIdList); + // 灏佽涓哄晢鍝乮d+鍟嗗搧灞炴т负key ,Stock涓簐alue鐨刴ap + final Map stockMap = new HashMap<>(); + for (Stock stock : productStock) { + stockMap.put(stock.getProductId() + stock.getAttributeList(), stock); + } + for (PurchaseReturnDetail purchaseReturnDetail : purchaseReturnDetails) { + final List changeStockLogs = purchaseReturnDetail.getStockLogList1(); + for (StockLog changeStockLog : changeStockLogs) { + // 鑾峰彇鍟嗗搧id+鍟嗗搧灞炴т负key ,Stock涓簐alue鐨刴ap + final String changeProductId = purchaseReturnDetail.getProductId(); + final String changeAttributeList = changeStockLog.getAttributeList(); + final String getKey = changeProductId + changeAttributeList; + if (stockMap.containsKey(getKey)) { + final Stock stock = stockMap.get(getKey); + //鍏ュ簱鍓嶆暟閲 + changeStockLog.setStock(stock.getStockCount()); + } else { + // 涓嶅瓨鍦ㄥ簱瀛橈紵搴旇娌℃湁鍚 + throw new HiverException("鍟嗗搧id涓" + changeProductId + "鐨勫晢鍝佸睘鎬т负" + changeAttributeList + "鐨勫晢鍝佸簱瀛樹笉瀛樺湪"); + } + // 鏁寸悊鍏ュ簱鍟嗗搧瑙勬牸鏄庣粏琛ㄦ暟鎹 + // 璁板綍搴撳瓨灞ュ巻 + changeStockLog.setProductId(purchaseReturnDetail.getProductId()); + changeStockLog.setOrderId(putOutPurchase.getId()); + changeStockLog.setDetailId(purchaseReturnDetail.getId()); + //鍏ュ簱 + changeStockLog.setChangeType(StockLogConstant.CHANGE_TYPE[1]); + changeStockLog.setShopId(shopId); + changeStockLog.setPurchasePrice(purchaseReturnDetail.getPurchasePrice()); + stockLogAddList.add(changeStockLog); + } + } + // 鎵归噺鏇存柊搴撳瓨鏁 + stockService.batchReduceStockByLog(stockLogAddList); + // 搴撳瓨璁板綍 + stockLogService.saveBatch(stockLogAddList); + // 3. 鍥為渚涘簲鍟嗘瑺娆 + // 寮傛鏇存柊渚涘簲鍟嗘瑺娆句俊鎭満娆犳璁板綍 + debtService.purchaseReturnToDebt(putOutPurchase, PurchaseReturnConstant.TYPE[0]); + + return ResultUtil.success("閫璐ф垚鍔燂紒"); + } } 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 81b07fe8..109b3ebb 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 @@ -837,13 +837,15 @@ public class AliOcrUtil { final Message systemMsg = Message.builder().role(Role.SYSTEM.getValue()).content("You are a helpful assistant.").build(); //questionMsg += "璇峰府鎴戞妸鎵鏈夊唴瀹瑰皝瑁呬负JSON锛宩son鏍煎紡涓猴細[{ \"productSn\": \"璐у彿\", \"attributeList\": [{\"color\":\"棰滆壊\",\"size\":\"灏虹爜\",\"productCount\": \"鏁伴噺\"}] }]銆備互涓嬫槸鍑犵偣瑕佹眰锛 1.鈥滆揣鍙封濅袱涓瓧鍜岄鑹蹭腑闂寸殑鍐呭浠h〃productSn锛宲roductSn鍙兘鍖呭惈\"鏂癨"銆乗"閫\"銆乗"鏃"銆乗"鎹"銆乗"琛"銆 2.\"SYYS鑹瞈"浠h〃鈥滄墍鏈夐鑹测濓紝\"color\"瀛楁杩斿洖鈥淪YYS鑹测濄 3.\"SYCM鐮乗"浠h〃鈥滄墍鏈夊昂鐮佲濓紝\"size\"瀛楁杩斿洖鈥淪YCM鐮佲濄 4.鍙緭鍑篔SON鏁版嵁鍗冲彲锛屼笉鐢ㄨ繑鍥炲瓧娈垫弿杩板拰瑙f瀽杩囩▼銆"; - questionMsg += "浣犳槸涓涓湇瑁呰涓氬簱绠′笓瀹讹紝璇峰府鎴戞妸鎵鏈夊唴瀹瑰皝瑁呬负JSON锛宩son鏍煎紡涓猴細[{ \"productSn\": \"璐у彿\", \"attributeList\": [{\"color\":\"棰滆壊\",\"size\":\"灏虹爜\",\"productCount\": \"鏁伴噺\"}] }]锛孿n" + + questionMsg += "浣犳槸涓涓湇瑁呰涓氬簱绠′笓瀹讹紝璇峰府鎴戞妸鎵鏈夊唴瀹瑰皝瑁呬负JSON锛宩son鏍煎紡涓猴細[{ \"productSn\": \"璐у彿\", \"attributeList\": [{\"color\":\"棰滆壊\",\"size\":\"灏虹爜\",\"productCount\": \"鏁伴噺\"}] }, \"wholesalePrice\":\"浠锋牸\"]锛孿n" + "1.productSn鐨勮繑鍥炲间腑鍘绘帀棰滆壊锛屽昂鐮佺瓑淇℃伅锛孿n" + "2.濡傛灉娌℃湁璇嗗埆鍒癨"color\"鐨勫唴瀹癸紝鍒橽"color\"璧嬪尖滃潎鑹测濄傚鏋滄病鏈夎瘑鍒埌\"size\"鐨勫唴瀹癸紝鍒橽"size\"璧嬪尖滃潎鐮佲濓紝杩斿洖1鏉SON鏁版嵁鍗冲彲銆俓n" + "3.濡傛灉鎸囦护鍐呭涓湁\"SYYS鑹瞈"鍒橽"color\"瀛楁杩斿洖鈥淪YYS鑹测濆嵆鍙紝濡傛灉鎸囦护鍐呭涓湁\"SYCM鐮乗"鍒橽"size\"瀛楁杩斿洖鈥淪YCM鐮佲濆嵆鍙紝娌℃湁鍒欏拷鐣ャ俓n" + "4.濡傛灉鎸囦护涓湁鈥滃悇N浠垛濓紝鍒欐瘡涓昂鐮佹暟閲忚繑鍥濶銆俓n" + "5.濡傛灉鎸囦护涓昂鐮佹槸锛熺爜鍒帮紵鐮侊紝璇峰畬鏁磋繑鍥炶法搴﹀唴鎵鏈夊昂鐮丣SON銆俓n" + - "6.鍙緭鍑篔SON鏁版嵁鍗冲彲锛岀姝㈣繑鍥為櫎JSON鏁版嵁澶栫殑浠讳綍鍐呭锛"; + "6.濡傛灉娌℃湁璇嗗埆鍒癨"wholesalePrice\"鐨勫唴瀹癸紝鍒橽"wholesalePrice\"璧嬪糪"0\"銆俓n" + + "7.鍙緭鍑篔SON鏁版嵁鍗冲彲锛岀姝㈣繑鍥為櫎JSON鏁版嵁澶栫殑浠讳綍鍐呭锛" + + "8.杩斿洖鐨凧SON鏁版嵁涓嶇敤鎹㈣锛屼互鏈蹇殑閫熷害杩斿洖锛"; final Message userMsg = Message.builder().role(Role.USER.getValue()).content(questionMsg).build(); msgManager.add(systemMsg); msgManager.add(userMsg); @@ -888,14 +890,15 @@ public class AliOcrUtil { final Message systemMsg = Message.builder().role(Role.SYSTEM.getValue()).content("You are a helpful assistant.").build(); // questionMsg += "璇峰府鎴戞妸鎵鏈夊唴瀹瑰皝瑁呬负JSON锛宩son鏍煎紡涓猴細[{ \"productSn\": \"璐у彿\", \"productName\": \"鍚嶇О\" , \"price\":\"鍗曚环\",\"attributeList\": [{\"color\":\"棰滆壊\",\"size\":\"灏虹爜\",\"productCount\": \"鏁伴噺\"}] }]銆備互涓嬫槸鍑犵偣瑕佹眰锛 1.鈥滆揣鍙封濅袱涓瓧鍜孿"鍚嶇О\"涓や釜瀛椾腑闂寸殑鍐呭浠h〃productSn鐨勫,濡傛灉娌℃湁鍚嶇О鍒欌滆揣鍙封濅袱涓瓧鍜岄鑹蹭腑闂寸殑鍐呭浠h〃productSn鐨勫硷紝productSn鍙兘鍖呭惈\"鏂癨"銆乗"閫\"銆乗"鏃"銆乗"鎹"銆乗"琛"銆2.\"SYYS鑹瞈"浠h〃鈥滄墍鏈夐鑹测濓紝\"color\"瀛楁杩斿洖鈥淪YYS鑹测濄 3.\"SYCM鐮乗"浠h〃鈥滄墍鏈夊昂鐮佲濓紝\"size\"瀛楁杩斿洖鈥淪YCM鐮佲濄4.濡傛灉娌℃湁鍚嶇О锛宲roductName瀛楁杩斿洖\"\"銆5.鍙緭鍑篔SON鏁版嵁鍗冲彲锛屼笉鐢ㄨ繑鍥炲瓧娈垫弿杩板拰瑙f瀽杩囩▼銆"; - questionMsg += "浣犳槸涓涓湇瑁呰涓氬簱绠′笓瀹讹紝璇峰府鎴戞妸鎵鏈夊唴瀹瑰皝瑁呬负JSON锛宩son鏍煎紡涓猴細[{ \"productSn\": \"璐у彿\", \"productName\": \"鍚嶇О\" , \"attributeList\": [{\"color\":\"棰滆壊\",\"size\":\"灏虹爜\",\"productCount\": \"鏁伴噺\"}], \"price\":\"鍗曚环\" , \"wholesalePrice\":\"鎵瑰彂浠穃" }]锛孿n" + + questionMsg += "浣犳槸涓涓湇瑁呰涓氬簱绠′笓瀹讹紝璇峰府鎴戞妸鎵鏈夊唴瀹瑰皝瑁呬负JSON锛宩son鏍煎紡涓猴細[{ \"productSn\": \"璐у彿\", \"productName\": \"鍚嶇О\" , \"attributeList\": [{\"color\":\"棰滆壊\",\"size\":\"灏虹爜\",\"productCount\": \"鏁伴噺\"}], \"price\":\"鍗曚环\" , \"wholesalePrice\":\"鎵瑰彂浠穃" }]\n" + "1.濡傛灉娌℃湁璇嗗埆鍒癨"price\"鐨勫唴瀹癸紝鍒橽"price\"璧嬪糪"0\"銆傚鏋滄病鏈夎瘑鍒埌\"wholesalePrice\"鐨勫唴瀹癸紝鍒橽"wholesalePrice\"璧嬪糪"0\"銆俓n" + "2.濡傛灉娌℃湁璇嗗埆鍒癨"productSn\"鐨勫唴瀹癸紝鍒橽"productSn\"璧嬪糪"\"銆俓n" + "3.濡傛灉娌℃湁璇嗗埆鍒癨"productName\"鐨勫唴瀹癸紝鍒橽"productName\"浣跨敤\"productSn\"鐨勫煎~鍏呫俓n" + "4.濡傛灉娌℃湁璇嗗埆鍒癨"color\"鐨勫唴瀹癸紝鍒橽"color\"璧嬪尖滃潎鑹测濓紝濡傛灉娌℃湁璇嗗埆鍒癨"size\"鐨勫唴瀹癸紝鍒橽"size\"璧嬪尖滃潎鐮佲濓紝杩斿洖涓鏉SON鏁版嵁鍗冲彲銆俓n" + "5.濡傛灉鎸囦护涓湁鈥滃悇N浠垛濓紝鍒欐瘡涓昂鐮佹暟閲忚繑鍥濶銆俓n" + - "6.濡傛灉鎸囦护涓昂鐮佹槸锛熺爜鍒帮紵鐮侊紝璇峰畬鏁磋繑鍥炶法搴﹀唴鎵鏈夊昂鐮丣SON銆俓n" + - "6.鍙緭鍑篔SON鏁版嵁鍗冲彲锛岀姝㈣繑鍥為櫎JSON鏁版嵁澶栫殑浠讳綍鍐呭锛"; + "6.濡傛灉鎸囦护涓昂鐮佹槸锛熺爜鍒帮紵鐮侊紝璇风粨鍚堟湇瑁呴瀷甯藉昂鐮佽鍒欏畬鏁磋繑鍥炶法搴﹀唴鎵鏈夊昂鐮丣SON銆俓n" + + "7.杩斿洖鐨凧SON鏁版嵁涓嶇敤鎹㈣锛屼互鏈蹇殑閫熷害杩斿洖锛乗n" + + "8.鍙緭鍑篔SON鏁版嵁鍗冲彲锛岀姝㈣繑鍥為櫎JSON鏁版嵁澶栫殑浠讳綍鍐呭锛"; final Message userMsg = Message.builder().role(Role.USER.getValue()).content(questionMsg).build(); msgManager.add(systemMsg); msgManager.add(userMsg); diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/CustomerMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/CustomerMapper.xml index 6c96956c..2067b6b3 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/CustomerMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/CustomerMapper.xml @@ -403,7 +403,7 @@ and name like concat('%',#{queryParams.searchStr},'%') - and t.not_buy_days > #{queryParams.notBuyDays} + and t.not_buy_days >= #{queryParams.notBuyDays} diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/DealingsRecordMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/DealingsRecordMapper.xml index 0ef1a055..2709d060 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/DealingsRecordMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/DealingsRecordMapper.xml @@ -148,6 +148,7 @@ ts.balance_deduction_amount, ts.real_amount, ts.already_earn, + ts.remark, trs.return_sale_total_amount from t_dealings_record tdr @@ -187,7 +188,8 @@ ts.should_pay, ts.balance_deduction_amount, ts.already_pay, - ts.create_time as purchase_time + ts.create_time as purchase_time, + ts.remark from t_dealings_record tdr left join t_purchase ts on ts.id = tdr.sale_id and ts.shop_id = #{supplierBillQueryVo.shopId} @@ -200,7 +202,36 @@ and tdr.create_time BETWEEN #{supplierBillQueryVo.startDate} AND #{supplierBillQueryVo.endDate} - order by tdr.create_time asc + + UNION + select + tdr.id, + tdr.sale_id as purchase_id, + tdr.create_by_name, + tdr.create_time, + tdr.last_debt_amount, + tdr.amount, + tdr.balance_due, + tdr.dealings_type, + tdr.del_flag, + ts.should_pay, + ts.balance_deduction_amount, + ts.already_pay, + ts.create_time as purchase_time, + ts.remark + from + t_dealings_record tdr + left join t_purchase_return ts on ts.id = tdr.sale_id and ts.shop_id = #{supplierBillQueryVo.shopId} + WHERE + + tdr.del_flag != 2 + and tdr.dealings_type in ('9','10') + and tdr.dealings_user_id = #{supplierBillQueryVo.supplierId} + and tdr.shop_id = #{supplierBillQueryVo.shopId} + + and tdr.create_time BETWEEN #{supplierBillQueryVo.startDate} AND #{supplierBillQueryVo.endDate} + + order by create_time asc diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/ProductMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/ProductMapper.xml index 471d3a51..d8cbc886 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/ProductMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/ProductMapper.xml @@ -558,7 +558,8 @@ t.print_barcode, t.tail_warn, t.in_storage_status, - (CASE WHEN ss.stock_count is NULL THEN 0 ELSE ss.stock_count END) as stock_count + COALESCE(ss.stock_count, 0) AS stock_count, + COALESCE(sd.total_sold, 0) AS total_sold FROM t_product t LEFT JOIN ( SELECT @@ -573,6 +574,25 @@ ) ss ON ss.product_id = t.id and ss.shop_id = t.shop_id + LEFT JOIN ( + SELECT + sd.product_id, + SUM(sd.product_count) AS total_sold + FROM + t_sale_detail sd + INNER JOIN t_sale s ON sd.sale_id = s.id + WHERE + s.del_flag = '0' + AND s.status = '4' + + and s.create_time BETWEEN #{queryParams.startDate} AND #{queryParams.endDate} + + + and s.create_time >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) + + GROUP BY + product_id + ) sd ON t.id = sd.product_id AND t.del_flag != '2' @@ -616,8 +636,9 @@ ORDER BY - - #{queryParams.sortField} #{queryParams.sort} , + + + sd.total_sold desc, t.in_storage_status asc, t.del_flag desc,t.create_time desc, id 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 ab116b61..b055f690 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml @@ -681,4 +681,28 @@ #{listItem} + + \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseReturnDetailMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseReturnDetailMapper.xml new file mode 100644 index 00000000..3cd56cbf --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseReturnDetailMapper.xml @@ -0,0 +1,239 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + 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,sort + + + + + + delete from t_purchase_return_detail + where id = #{id,jdbcType=VARCHAR} + + + + insert into t_purchase_return_detail (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,sort) + values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, + #{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, + #{purchaseId,jdbcType=VARCHAR}, #{productId,jdbcType=VARCHAR}, #{productName,jdbcType=VARCHAR}, + #{unit,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR}, #{categoryId,jdbcType=VARCHAR}, + #{attributeList,jdbcType=VARCHAR}, #{supplierId,jdbcType=VARCHAR},#{supplierName,jdbcType=VARCHAR}, #{productSn,jdbcType=VARCHAR}, + #{barcode,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL}, #{purchasePrice,jdbcType=DECIMAL}, + #{wholesalePrice,jdbcType=DECIMAL}, #{productPicture,jdbcType=VARCHAR}, #{productVideo,jdbcType=VARCHAR}, + #{productIntro,jdbcType=VARCHAR}, #{salesWeek,jdbcType=TIMESTAMP}, #{tailWarn,jdbcType=INTEGER}, + #{printBarcode,jdbcType=VARCHAR}, #{productCount,jdbcType=INTEGER},#{ocrPicturePath,jdbcType=VARCHAR},#{sort,jdbcType=INTEGER}) + + + + + + + + + insert into t_purchase_return_detail (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,sort) values + + (#{purchaseDetail.id}, #{purchaseDetail.createBy}, #{purchaseDetail.createTime}, #{purchaseDetail.delFlag}, + #{purchaseDetail.updateBy}, #{purchaseDetail.updateTime}, #{purchaseDetail.purchaseId}, #{purchaseDetail.productId}, + #{purchaseDetail.productName}, #{purchaseDetail.unit}, #{purchaseDetail.shopId}, #{purchaseDetail.categoryId}, + #{purchaseDetail.attributeList}, #{purchaseDetail.supplierId}, #{purchaseDetail.supplierName}, #{purchaseDetail.productSn}, + #{purchaseDetail.barcode}, #{purchaseDetail.price}, #{purchaseDetail.purchasePrice}, #{purchaseDetail.wholesalePrice}, + #{purchaseDetail.productPicture}, #{purchaseDetail.productVideo}, #{purchaseDetail.productIntro}, + #{purchaseDetail.salesWeek}, #{purchaseDetail.tailWarn}, #{purchaseDetail.printBarcode}, #{purchaseDetail.productCount}, + #{purchaseDetail.ocrPicturePath},#{purchaseDetail.sort}) + + + + + + + + + update t_purchase_return_detail set product_count = #{item.productCount} WHERE id = #{item.id} + + + + + update t_purchase_return_detail set del_flag = '1' where purchase_id = #{purchaseId,jdbcType=VARCHAR} + + + + + delete from t_purchase_return_detail + where purchase_id = #{purchaseId,jdbcType=VARCHAR} + + + + + + + + + + \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseReturnMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseReturnMapper.xml new file mode 100644 index 00000000..cca964ae --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseReturnMapper.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + id, create_by,create_by_name, create_time, del_flag, update_by, update_time, supplier_id,supplier_name, shop_id, + total_amount, should_pay, already_pay, no_pay,other_pay, in_storage_status,remark, balance_deduction_amount, + purchase_time + + + + + + delete from t_purchase_return + where id = #{id,jdbcType=VARCHAR} + + + + + + + update t_purchase_return + set del_flag = '1' + where id = #{id} + + + + \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/ReturnSaleMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/ReturnSaleMapper.xml index 452b9472..32dd6d3e 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/ReturnSaleMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/ReturnSaleMapper.xml @@ -594,7 +594,8 @@ + + + + \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml index 46b5187d..3d9f3210 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml @@ -1087,7 +1087,8 @@ GROUP BY + + + + \ No newline at end of file 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 7cf654ee..abee9fea 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml @@ -687,6 +687,12 @@ + + + update t_stock set stock_count = stock_count + #{item.productCount} WHERE product_id = #{item.productId} and attribute_list = #{item.attributeList} + + +