diff --git a/hiver-admin/src/main/resources/application.yml b/hiver-admin/src/main/resources/application.yml index 767060e1..b423c524 100644 --- a/hiver-admin/src/main/resources/application.yml +++ b/hiver-admin/src/main/resources/application.yml @@ -25,8 +25,8 @@ spring: timeout-per-shutdown-phase: 10S # 数据源 datasource: -# url: jdbc:mysql://154.8.162.157:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true - url: jdbc:mysql://8.140.198.243:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true + url: jdbc:mysql://154.8.162.157:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true +# url: jdbc:mysql://8.140.198.243:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true username: reddoor # Jasypt加密 可到common-utils中找到JasyptUtil加解密工具类生成加密结果 格式为ENC(加密结果) 以下解密结果为123456 password: ENC(Zla4U4+yRLPhicvuX2TmiEgxEpzP4dk8BHzFDEtiEhwLQIIaftZrrEUJZce6efoe) @@ -67,7 +67,7 @@ spring: ddl-auto: update # Redis 若设有密码自行添加配置password redis: -# host: 154.8.162.157 + host: 154.8.162.157 # host: 8.140.198.243 password: reddoor168 # 数据库索引 默认0 @@ -333,6 +333,7 @@ ignored: # # 临时增加 - /hiver/app/purchase/getPurchaseListOfSupplier + - /hiver/app/purchase/cancelPurchase # 限流及黑名单不拦截的路径 limitUrls: - /**/*.js 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 2af5580e..764dc485 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 @@ -288,7 +288,7 @@ public class BillServiceImpl implements BillService { final SupplierBillDataVo supplierBillDataVo = new SupplierBillDataVo(); supplierBillDataVo.setUserId(supplierBillQueryVo.getSupplierId()); - // 获取客户信息 + // 获取供应商信息 final Supplier supplier = supplierService.findById(supplierBillQueryVo.getSupplierId()); supplierBillDataVo.setUserName(supplier.getConsigneeName()); supplierBillDataVo.setQueryDate(DateUtil.COMMON_FULL.getDateText(new Date())); diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java index 3b74f3b0..413a9555 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java @@ -149,6 +149,20 @@ public class CustomerController { } } + @RequestMapping(value = "/batchDeleteCustomer", method = RequestMethod.POST) + @ApiOperation("批量删除客户") + public Result batchDeleteCustomer(String ids) { + if (StringUtils.isEmpty(ids)) { + return ResultUtil.error("客户id不能为空"); + } + final boolean result = customerService.batchDeleteCustomer(ids); + if (result) { + return ResultUtil.success("删除成功"); + } else { + return ResultUtil.error("删除失败"); + } + } + @RequestMapping(value = "/list", method = RequestMethod.POST) @ApiOperation("查询客户列表") diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java index f6e4f427..6eb3b514 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java @@ -72,7 +72,7 @@ public class ProductController { product.setDelFlag(CommonConstant.DEL_FLAG_TRUE); final boolean result = productService.save(product); // 如果有子图,那么新增子图信息 - List productPictures = productVo.getProductPictures(); + final List productPictures = productVo.getProductPictures(); if (productPictures != null && !productPictures.isEmpty()) { for (ProductPicture productPicture : productPictures) { productPicture.setProductId(product.getId()); @@ -107,7 +107,7 @@ public class ProductController { } final boolean result = productService.updateById(product); // 如果有子图,那么新增子图信息 - List productPictures = productVo.getProductPictures(); + final List productPictures = productVo.getProductPictures(); if (productPictures != null && !productPictures.isEmpty()) { // 先删除 productPictureService.deleteByProductId(productVo.getId()); @@ -218,6 +218,27 @@ public class ProductController { } } + /** + * 根据货品id批量删除商品 + * @author 王富康 + * @date 2024/7/27 + * @param ids + * @return Result + */ + @RequestMapping(value = "/batchDeleteProduct", method = RequestMethod.POST) + @ApiOperation("根据货品id批量删除商品") + public Result batchDeleteProduct(String ids) { + if (StringUtils.isEmpty(ids)) { + return ResultUtil.error("请选择要删除的商品!"); + } + final boolean result = productService.batchDeleteProduct(ids); + if (result) { + return ResultUtil.success("删除成功"); + } else { + return ResultUtil.error("删除失败"); + } + } + // @RequestMapping(value = "/listGoodsPages", method = RequestMethod.POST) // @ApiOperation(value = "商品分页列表[服务端]") // public Result> listGoodsPages(GoodsPageQuery queryParams) { diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PurchaseController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PurchaseController.java index c0634d46..de419295 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PurchaseController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PurchaseController.java @@ -250,7 +250,7 @@ public class PurchaseController { final String shopId = securityUtil.getShopId(); final QueryWrapper querySaleWrapper = new QueryWrapper<>(); querySaleWrapper.eq("shop_id", shopId) - .eq("del_flag",CommonConstant.STATUS_NORMAL) + .eq("del_flag", CommonConstant.STATUS_NORMAL) .eq("in_storage_status", StockConstant.IN_STORAGE_STATUS[0]); final long waitReturnCount = purchaseService.count(querySaleWrapper); return ResultUtil.data(waitReturnCount); @@ -273,12 +273,14 @@ public class PurchaseController { final PurchaseVo purchaseVo = purchaseService.getPurchaseAllDataOfAi(id); return new ResultUtil().setData(purchaseVo); } + /** * 进货金额可查明细 - * @author 王富康 - * @date 2024/6/29 + * * @param purchasePageQuery * @return Result + * @author 王富康 + * @date 2024/6/29 */ @PostMapping("/purchasingCostDetail") public Result purchasingCostDetail(@RequestBody PurchasePageQuery purchasePageQuery) { @@ -286,22 +288,23 @@ public class PurchaseController { final Page purchasingCostDetail = purchaseService.purchasingCostDetail(purchasePageQuery); return new ResultUtil<>().setData(purchasingCostDetail); } catch (Exception e) { - log.info(e.getMessage(),e); + log.info(e.getMessage(), e); return ResultUtil.error("查询失败"); } } /** * 请详细描述方法 - * @author 王富康 - * @date 2024/7/24 + * * @param purchasePageQuery * @return Result - */ + * @author 王富康 + * @date 2024/7/24 + */ @RequestMapping(value = "/getPurchaseListOfSupplier", method = RequestMethod.POST) @ApiOperation("获取从某个供应商的拿货入库记录") public Result getPurchaseListOfSupplier(@RequestBody PurchasePageQuery purchasePageQuery) { - if(StringUtils.isEmpty(purchasePageQuery.getSupplierId())){ + if (StringUtils.isEmpty(purchasePageQuery.getSupplierId())) { return ResultUtil.error("供应商id不能为空!"); } // shopId从缓存中设置 @@ -310,4 +313,29 @@ public class PurchaseController { final Page purchaseVoList = purchaseService.getPurchaseListOfSupplier(purchasePageQuery); return ResultUtil.data(purchaseVoList); } + + /** + * 撤销采购单 + * (1)订单回退(订单作废、库存退回) + * (2)款项记录作废(查询的时候也要关联deflag=0),同时把款项回退 + * + * @param id + * @return Result + * @author 王富康 + * @date 2024/6/26 + */ + @RequestMapping(value = "/cancelPurchase", method = RequestMethod.POST) + @ApiOperation("撤销入库单") + public Result cancelPurchase(String id) { + if (StringUtils.isEmpty(id)) { + ResultUtil.error("订单id不能为空!"); + } + try { + purchaseService.cancelPurchase(id); + return ResultUtil.success("撤销成功"); + } catch (Exception e) { + log.error(e.getMessage(), e); + return ResultUtil.error("撤销失败!"); + } + } } 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 5a8c3bef..1597ee99 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 @@ -147,7 +147,7 @@ public class SaleController { saleQueryDTO.getSale().setShopName(shop.getShopName()); // 根据该客户的欠款信息 String userId = saleQueryDTO.getSale().getUserId(); - Debt debt = debtService.selectByUserId(shopId,userId); + Debt debt = debtService.selectByUserId(shopId, userId); BigDecimal amountOwed = debt.getAmountOwed(); // 20240616 开单可能值包含退货单 Sale sale = saleQueryDTO.getSale(); @@ -256,15 +256,7 @@ public class SaleController { returnSaleService.saveOrUpdate(returnSale); } // 处理欠款信息 - // 本单欠款 - final BigDecimal noEarn = saleQueryDTO.getSale().getNoEarn(); - // 销售抵扣金额 - final BigDecimal debtDeductionAmount = saleQueryDTO.getSale().getDebtDeductionAmount(); - // 余额抵扣金额 - final BigDecimal balanceDeductionAmount = saleQueryDTO.getSale().getBalanceDeductionAmount(); - // if (noEarn.compareTo(BigDecimal.ZERO) != 0 || debtDeductionAmount.compareTo(BigDecimal.ZERO) != 0 || balanceDeductionAmount.compareTo(BigDecimal.ZERO) != 0) { - debtService.saleToDebt(saleQueryDTO); - // } + debtService.saleToDebt(saleQueryDTO); return new ResultUtil<>().setData(sale.getId(), "下单成功"); } catch (Exception e) { log.error(e.getMessage(), e); @@ -305,6 +297,10 @@ public class SaleController { if (result) { // 删除子表数据 saleDetailService.deleteBySaleId(id); + // 删除退货单的信息 + returnSaleService.deleteBySaleId(id); + // 删除退货单的详细信息 + returnDetailService.deleteBySaleId(id); return ResultUtil.success("删除成功"); } return ResultUtil.error("删除失败"); @@ -1012,7 +1008,7 @@ public class SaleController { @RequestMapping(value = "/getCustomerBuyProductLog", method = RequestMethod.POST) @ApiOperation("下游客户查询商品购买记录") public Result getCustomerBuyProductLog(@RequestBody SalePageQuery salePageQuery) { - if(StringUtils.isEmpty(salePageQuery.getShopId())){ + if (StringUtils.isEmpty(salePageQuery.getShopId())) { return ResultUtil.error("店铺id不能为空"); } final Page salePage = saleService.getCustomerBuyProductLog(salePageQuery); @@ -1022,10 +1018,10 @@ public class SaleController { @RequestMapping(value = "/getSupplierBuyProductLog", method = RequestMethod.POST) @ApiOperation("根据供应商查询商品购买记录") public Result getSupplierBuyProductLog(@RequestBody SalePageQuery salePageQuery) { - if(StringUtils.isEmpty(salePageQuery.getShopId())){ + if (StringUtils.isEmpty(salePageQuery.getShopId())) { return ResultUtil.error("店铺id不能为空"); } - if(StringUtils.isEmpty(salePageQuery.getSupplierId())){ + if (StringUtils.isEmpty(salePageQuery.getSupplierId())) { return ResultUtil.error("供应商id不能为空"); } final Page salePage = saleService.getSupplierBuyProductLog(salePageQuery); @@ -1156,17 +1152,18 @@ public class SaleController { final Page totalAmountDetail = saleService.totalAmountDetail(salePageQuery); return new ResultUtil<>().setData(totalAmountDetail); } catch (Exception e) { - log.info(e.getMessage(),e); + log.info(e.getMessage(), e); return ResultUtil.error("查询失败"); } } - /** + /** * 实收金额明细 + * + * @param salePageQuery + * @return Result * @author 王富康 * @date 2024/6/29 - * @param salePageQuery - * @return Result */ @PostMapping("/totalAlreadyEarnDetail") public Result totalAlreadyEarnDetail(@RequestBody SalePageQuery salePageQuery) { @@ -1174,17 +1171,18 @@ public class SaleController { final Page totalAlreadyEarnDetail = saleService.totalAlreadyEarnDetail(salePageQuery); return new ResultUtil<>().setData(totalAlreadyEarnDetail); } catch (Exception e) { - log.info(e.getMessage(),e); + log.info(e.getMessage(), e); return ResultUtil.error("查询失败"); } } /** * 客户拿货统计 - * @author 王富康 - * @date 2024/6/29 + * * @param salePageQuery * @return Result + * @author 王富康 + * @date 2024/6/29 */ @PostMapping("/customerSaleDetail") public Result customerSaleDetail(@RequestBody SalePageQuery salePageQuery) { @@ -1192,8 +1190,27 @@ public class SaleController { final Page customerSaleDetail = saleService.customerSaleDetail(salePageQuery); return new ResultUtil<>().setData(customerSaleDetail); } catch (Exception e) { - log.info(e.getMessage(),e); + log.info(e.getMessage(), e); return ResultUtil.error("查询失败"); } } + + /** + * 开单暂存为挂单 + * + * @param saleQueryDTO + * @return Result + * @author 王富康 + * @date 2024/7/26 + */ + @PostMapping("/temporarySaveSale") + public Result temporarySaveSale(@RequestBody SaleQueryDTO saleQueryDTO) { + try { + saleService.temporarySaveSale(saleQueryDTO); + return ResultUtil.success("暂存成功!"); + } 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 8a8ef546..cef17dcc 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 @@ -258,4 +258,46 @@ public class ShopController { final Map shopRebateBalance = shopService.getShopRebateBalance(); return ResultUtil.data(shopRebateBalance); } + + /** + * 根据店铺id获取店铺信息 + * @author 王富康 + * @date 2024/7/27 + * @param id + * @return Result + */ + @RequestMapping(value = "/getShopInfoById", method = RequestMethod.POST) + @ApiOperation("根据店铺id获取店铺信息") + public Result getShopInfoById(String id){ + if(StringUtils.isEmpty(id)){ + return ResultUtil.error("店铺id不能为空"); + } + final Shop shop = shopService.findById(id); + return ResultUtil.data(shop); + } + + /** + * 更新店铺图标及备注 + * @author 王富康 + * @date 2024/7/27 + * @param shop + * @return Result + */ + @RequestMapping(value = "/updateShopIconAndRemark", method = RequestMethod.PUT) + @ApiOperation("更新店铺图标及备注") + public Result updateShopIconAndRemark(@RequestBody Shop shop) { + final String id = shop.getId(); + if(StringUtils.isEmpty(id)){ + return ResultUtil.error("店铺id不能为空"); + } + final Shop oldShop = shopService.get(id); + if(shop.getShopIcon() != null){ + oldShop.setShopIcon(shop.getShopIcon()); + } + if(shop.getRemark() != null){ + oldShop.setRemark(shop.getRemark()); + } + shopService.update(oldShop); + return ResultUtil.success("更新成功"); + } } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SupplierControlller.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SupplierControlller.java index ef3cdae4..ba3873a2 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SupplierControlller.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SupplierControlller.java @@ -21,7 +21,10 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; import java.math.BigDecimal; import java.util.Date; @@ -30,7 +33,7 @@ import java.util.List; @Slf4j @RestController @Api(tags = "供应商接口") -@RequestMapping(value = "/hiver/app/supplier/") +@RequestMapping("/hiver/app/supplier/") @Transactional public class SupplierControlller { @Autowired @@ -46,12 +49,12 @@ public class SupplierControlller { private DealingsRecordService dealingsRecordService; @RequestMapping(value = "/getByCondition", method = RequestMethod.POST) - @ApiOperation(value = "根据条件获得分页") + @ApiOperation("根据条件获得分页") public Result> queryAll(Supplier supplierOfquery, PageVo pageVo) { // 从缓存中拿到店铺id final String shopId = securityUtil.getShopId(); supplierOfquery.setShopId(shopId); - Page users = supplierService.queryAll(supplierOfquery, PageUtil.initPage(pageVo)); + final Page users = supplierService.queryAll(supplierOfquery, PageUtil.initPage(pageVo)); return new ResultUtil>().setData(users); } @@ -62,29 +65,29 @@ public class SupplierControlller { * @return Result> */ @RequestMapping(value = "/getbyShopId", method = RequestMethod.POST) - @ApiOperation(value = "获取当前店铺所有供应商") + @ApiOperation("获取当前店铺所有供应商") public Result> getbyShopId(String searchStr) { // 从缓存中拿到店铺id final String shopId = securityUtil.getShopId(); - List suppliers = supplierService.getbyShopId(shopId,searchStr); + final List suppliers = supplierService.getbyShopId(shopId,searchStr); return new ResultUtil>().setData(suppliers); } @RequestMapping(value = "/get/{id}", method = RequestMethod.GET) - @ApiOperation(value = "通过id获取") + @ApiOperation("通过id获取") public Result get(@PathVariable String id) { - Supplier data = supplierService.findById(id); + final Supplier data = supplierService.findById(id); return new ResultUtil().setData(data); } @RequestMapping(value = "/save", method = RequestMethod.POST) - @ApiOperation(value = "保存数据") + @ApiOperation("保存数据") public Result save(Supplier entity) { // 从缓存中拿到店铺id final String shopId = securityUtil.getShopId(); entity.setShopId(shopId); entity.setDelFlag(CommonConstant.DEL_FLAG_FALSE); - Supplier supplier = supplierService.save(entity); + final Supplier supplier = supplierService.save(entity); // 新增供应商欠款 // 客户欠款信息 final BigDecimal noEarn = entity.getNoEarn() == null ? BigDecimal.ZERO : entity.getNoEarn(); @@ -124,16 +127,16 @@ public class SupplierControlller { } @RequestMapping(value = "/edit", method = RequestMethod.POST) - @ApiOperation(value = "更新数据") + @ApiOperation("更新数据") public Result edit(Supplier entity) { - Supplier data = supplierService.findById(entity.getId()); + final Supplier data = supplierService.findById(entity.getId()); data.setProvince(entity.getProvince()); data.setCity(entity.getCity()); data.setArea(entity.getArea()); data.setAddress(entity.getAddress()); data.setConsigneeName(entity.getConsigneeName()); data.setConsigneeMobile(entity.getConsigneeMobile()); - Supplier supplier = supplierService.update(data); + final Supplier supplier = supplierService.update(data); return new ResultUtil().setData(supplier); } @@ -145,9 +148,10 @@ public class SupplierControlller { * @return Result */ @RequestMapping(value = "/delByIds", method = RequestMethod.POST) - @ApiOperation(value = "批量通过ids删除") - public Result delByIds(@RequestParam String[] ids) { - for (String id : ids) { + @ApiOperation("批量通过ids删除") + public Result delByIds( String ids) { + final String[] idsArray = ids.split(","); + for (String id : idsArray) { supplierService.delById(id); } return ResultUtil.success("批量通过id删除数据成功"); diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/CustomerMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/CustomerMapper.java index e2a89b41..ec18b52f 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/CustomerMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/CustomerMapper.java @@ -44,4 +44,6 @@ public interface CustomerMapper extends BaseMapper { Page getCustomerList(Page page,@Param("queryParams") CustomerPageQuery customerPageQuery); void updatePhone(@Param("newMobile")String newMobile,@Param("userId") String userId); + + boolean batchDeleteCustomer(@Param("idList") List idList); } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ProductMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ProductMapper.java index bd944b6a..f91fb371 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ProductMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ProductMapper.java @@ -75,4 +75,6 @@ public interface ProductMapper extends BaseMapper { * @date 2024/6/22 */ void batchUpdateDelFlag(@Param("idList") List idList, @Param("delFlag") Integer delFlag); + + void batchUpdatePurchasePrice(@Param("productList") List productList); } \ No newline at end of file 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 bda47ec2..f6a85a52 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 @@ -44,4 +44,14 @@ public interface PurchaseDetailMapper extends BaseMapper { void deleteByPurchaseId(@Param("purchaseId") String purchaseId); List getPurchaseDetails(@Param("purchaseIdList") List purchaseIdList); + + /** + * 查询该商品除当前入库单的其他的入库记录 + * @author 王富康 + * @date 2024/7/27 + * @param productIdList + * @param id + * @return List + */ + List getPurchaseDetailListByProductIds(@Param("productIdList") List productIdList,@Param("id") String id); } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ReturnDetailMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ReturnDetailMapper.java index 947e2461..b6d3f4a9 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ReturnDetailMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ReturnDetailMapper.java @@ -49,4 +49,6 @@ public interface ReturnDetailMapper extends BaseMapper { List getReturnDetailsByReturnId(@Param("returnSaleIdList") List returnSaleIdList); void putInUpdatePurchasePrice(@Param("purchaseDetails") List purchaseDetails); + + void deleteBySaleId(@Param("saleId")String saleId); } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ReturnSaleMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ReturnSaleMapper.java index dbcd73e4..7586b5b2 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ReturnSaleMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ReturnSaleMapper.java @@ -81,4 +81,5 @@ public interface ReturnSaleMapper extends BaseMapper { */ Page getReturnSaleListByUserId(Page page, @Param("returnSalePageQuery") ReturnSalePageQuery returnSalePageQuery); + void deleteBySaleId(@Param("saleId") String saleId); } \ 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 f2655005..f68086c1 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 @@ -43,4 +43,6 @@ public interface SaleDetailMapper extends BaseMapper { void putInUpdatePurchasePrice(@Param("purchaseDetails") List purchaseDetails); List getSaleDetails(@Param("saleIdList") List saleIdList); + + List getSaleDetailListByProductIds(@Param("productIdList") List productIdList); } \ 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 daf79645..736fd3dc 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 @@ -113,4 +113,5 @@ public interface SaleMapper extends BaseMapper { * @return Page */ Page customerSaleDetail(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/StockLogMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockLogMapper.java index f05858a0..e91c764a 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockLogMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockLogMapper.java @@ -43,4 +43,6 @@ public interface StockLogMapper extends BaseMapper { void putInUpdatePurchasePrice(@Param("purchaseDetails") List purchaseDetails); List getPurchaseDetails(@Param("purchaseIdList") List purchaseIdList); + + List getByProductIds(@Param("purchaseId") String purchaseId,@Param("productIdList") List productIdList); } \ 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 b218f57b..2c504b6f 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 @@ -3,6 +3,7 @@ package cc.hiver.mall.dao.mapper; import cc.hiver.mall.entity.PurchaseDetail; import cc.hiver.mall.entity.Stock; import cc.hiver.mall.entity.StockExample; +import cc.hiver.mall.entity.StockLog; import cc.hiver.mall.pojo.query.StockPageQuery; import cc.hiver.mall.pojo.vo.ProductCategoryStockVo; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -51,4 +52,8 @@ public interface StockMapper extends BaseMapper { Stock getByProductIdAndAttributeList(@Param("productId") String productId, @Param("attributeList") String attributeList); List getProductStockByAttrId(@Param("attrId") String attrId); + + void batchDeleteStockByProductIds(@Param("productIdList") List productIdList); + + void batchReduceStockByLog(@Param("stockLogList") List stockLogList); } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Purchase.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Purchase.java index f7c747b9..c0be507b 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Purchase.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Purchase.java @@ -77,6 +77,9 @@ public class Purchase extends HiverBaseEntity { @ApiModelProperty(value = "AI识别-实际识别的数量") private Integer OcrCount; + @ApiModelProperty(value = "入库时间,20240727重新定义为入库单的创建时间,createTime为前台传递的入库单") + private Date purchaseTime; + public Date getStartDate() { return startDate; } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/productpicture/service/impl/ProductPictureServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/productpicture/service/impl/ProductPictureServiceImpl.java index 34134a80..3c5ff6b4 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/productpicture/service/impl/ProductPictureServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/productpicture/service/impl/ProductPictureServiceImpl.java @@ -1,5 +1,8 @@ package cc.hiver.mall.productpicture.service.impl; +import cc.hiver.core.common.constant.CommonConstant; +import cc.hiver.core.common.utils.SecurityUtil; +import cc.hiver.core.entity.User; import cc.hiver.mall.productpicture.entity.ProductPicture; import cc.hiver.mall.productpicture.mapper.ProductPictureMapper; import cc.hiver.mall.productpicture.service.ProductPictureService; @@ -7,6 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Date; import java.util.List; @Service @@ -14,6 +18,9 @@ public class ProductPictureServiceImpl extends ServiceImpl getProductPictureByProductId(String productId) { return productPictureMapper.getProductPictureByProductId(productId); @@ -26,6 +33,13 @@ public class ProductPictureServiceImpl extends ServiceImpl productPictures) { + for (ProductPicture productPicture : productPictures) { + // 设置一些基本字段项的值 + final User user = securityUtil.getCurrUser(); + productPicture.setCreateBy(user.getId()); + productPicture.setDelFlag(CommonConstant.DEL_FLAG_FALSE); + productPicture.setCreateTime(new Date()); + } productPictureMapper.batchSaveProductPicture(productPictures); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/CustomerService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/CustomerService.java index 7a13d4d3..bf8b3aaf 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/CustomerService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/CustomerService.java @@ -20,4 +20,6 @@ public interface CustomerService extends IService { Page getCustomerList(CustomerPageQuery customerPageQuery); void updatePhone(String newMobile, String userId); + + boolean batchDeleteCustomer(String ids); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductService.java index 1f716d38..916370e1 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductService.java @@ -68,4 +68,15 @@ public interface ProductService extends IService { * @date 2024/6/22 */ boolean batchDown(String ids); + + /** + * 批量删除商品 + * @author 王富康 + * @date 2024/7/27 + * @param ids + * @return boolean + */ + boolean batchDeleteProduct(String ids); + + void batchUpdatePurchasePrice(List productList); } 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 8268a692..2ed062da 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 @@ -22,4 +22,14 @@ public interface PurchaseDetailService extends IService { void deleteByPurchaseId(String purchaseId); List getPurchaseDetails(List purchaseIdList); + + /** + * 查询该商品除当前入库单的其他的入库记录 + * @author 王富康 + * @date 2024/7/27 + * @param productIdList + * @param id + * @return List + */ + List getPurchaseDetailListByProductIds(List productIdList, String id); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java index b0fa54e3..62cad720 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java @@ -43,16 +43,17 @@ public interface PurchaseService extends IService { PurchaseVo getPurchaseAllDataOfAi(String id); - void updateInStorageStatus(String id,int inStorageStatus); + void updateInStorageStatus(String id, int inStorageStatus); void deleteById(String id); /** * 进货金额可查明细 - * @author 王富康 - * @date 2024/6/29 + * * @param purchasePageQuery * @return List + * @author 王富康 + * @date 2024/6/29 */ Page purchasingCostDetail(PurchasePageQuery purchasePageQuery); @@ -60,10 +61,21 @@ public interface PurchaseService extends IService { /** * 获取从某个供应商的拿货入库记录(按入库单) - * @author 王富康 - * @date 2024/7/24 + * * @param purchasePageQuery * @return Page + * @author 王富康 + * @date 2024/7/24 */ Page getPurchaseListOfSupplier(PurchasePageQuery purchasePageQuery); + + /** + * 撤销采购单 + * + * @param id + * @author 王富康 + * @date 2024/7/27 + */ + void cancelPurchase(String id); + } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ReturnDetailService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ReturnDetailService.java index 6dcd896c..bb78cfe0 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ReturnDetailService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ReturnDetailService.java @@ -25,4 +25,5 @@ public interface ReturnDetailService extends IService { */ List getReturnDetailsByProductId(ReturnSalePageQuery returnSalePageQuery); + void deleteBySaleId(String saleId); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ReturnSaleService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ReturnSaleService.java index 377d9bbf..25a9736b 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ReturnSaleService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ReturnSaleService.java @@ -48,4 +48,6 @@ public interface ReturnSaleService extends IService { * @date 2024/6/30 */ Page getReturnSaleListByUserId(ReturnSalePageQuery returnSalePageQuery); + + void deleteBySaleId(String saleId); } 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 1ab6d25d..f0847dfc 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 @@ -29,4 +29,13 @@ public interface SaleDetailService extends IService { void putInUpdatePurchasePrice(List purchaseDetails); List getSaleDetails(List saleIdList); + + /** + * 根据商品id集合获取商品销售记录 + * @author 王富康 + * @date 2024/7/27 + * @param productIdList + * @return List + */ + List getSaleDetailListByProductIds(List productIdList); } 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 9212c651..e0bb083c 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 @@ -4,6 +4,7 @@ import cc.hiver.mall.bill.vo.ArrearsVo; import cc.hiver.mall.bill.vo.CustomerBillQueryVo; import cc.hiver.mall.bill.vo.CustomerBillSaleVo; import cc.hiver.mall.entity.Sale; +import cc.hiver.mall.pojo.dto.SaleQueryDTO; import cc.hiver.mall.pojo.query.SalePageQuery; import cc.hiver.mall.pojo.query.SalesRankingQueryCriteria; import cc.hiver.mall.pojo.vo.*; @@ -101,19 +102,30 @@ public interface SaleService extends IService { /** * 实收金额明细 - * @author 王富康 - * @date 2024/6/29 + * * @param salePageQuery * @return List + * @author 王富康 + * @date 2024/6/29 */ Page totalAlreadyEarnDetail(SalePageQuery salePageQuery); /** * 客户拿货统计 - * @author 王富康 - * @date 2024/6/29 + * * @param salePageQuery * @return Page + * @author 王富康 + * @date 2024/6/29 */ Page customerSaleDetail(SalePageQuery salePageQuery); + + /** + * 开单暂存为挂单 + * + * @param saleQueryDTO + * @author 王富康 + * @date 2024/7/26 + */ + void temporarySaveSale(SaleQueryDTO saleQueryDTO); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockLogService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockLogService.java index 6b210680..d903a5fb 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockLogService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockLogService.java @@ -15,4 +15,14 @@ public interface StockLogService extends IService { void deleteByPurchaseId(String purchaseId); List getPurchaseDetails(List purchaseIdList); + + /** + * 请详细描述方法 + * @author 王富康 + * @date 2024/7/27 + * @param purchaseId + * @param productIds 逗号分隔的商品id + * @return List + */ + List getByProductIds(String purchaseId, String productIds); } 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 b250eaeb..9d35c941 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 @@ -2,6 +2,7 @@ package cc.hiver.mall.service.mybatis; import cc.hiver.core.common.vo.Result; import cc.hiver.mall.entity.Stock; +import cc.hiver.mall.entity.StockLog; import cc.hiver.mall.pojo.query.StockPageQuery; import cc.hiver.mall.pojo.vo.ProductCategoryStockVo; import cc.hiver.mall.pojo.vo.PurchaseVo; @@ -70,4 +71,20 @@ public interface StockService extends IService { * @return List */ List getProductStockByAttrId(String attrId); + + /** + * 根据商品id批量删除库存 + * @author 王富康 + * @date 2024/7/27 + * @param productIds + */ + void batchDeleteStockByProductIds(String productIds); + + /** + * 根据入库记录减掉库存数 + * @author 王富康 + * @date 2024/7/27 + * @param stockLogList + */ + void batchReduceStockByLog(List stockLogList); } 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 68c328ae..c82571c9 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 @@ -230,34 +230,39 @@ public class SalesAndDetailsServiceImpl implements SalesAndDetailsService { sale.setCompanyPhone(transCompanyPhone); } } - // 如果是自送,状态为完成,其他使用平台的则为待取货 - if (SaleConstant.TRANSPORT_TYPE[2].equals(sale.getTransportType())) { - sale.setStatus(SaleConstant.SALE_STATUS[4]); - // 自送如果选择了物流公司,也需要物流公司返佣 - // 选择物流公司才返佣,否则是没有选择物流公司的自提 - if (StringUtils.isNotEmpty(sale.getTransCompany())) { - deductLogService.updateRebateAmount("", sale.getTransCompany(), sale.getShopId(), sale.getId(), sale.getTransportType()); - } - } else if (SaleConstant.MODE_OF_SERVICE[2].equals(sale.getModeOfService())) { - // 物流自提 - sale.setStatus(SaleConstant.SALE_STATUS[13]); - // 给物流公司发送一个短信 - // shopId从缓存中设置 - final String shopId = securityUtil.getShopId(); - final Shop shop = shopService.get(shopId); - final String shopAddress = shop.getShopAddress(); - smsUtil.sendSms(transCompanyPhone, "{\"shopAddress\":\"" + shopAddress + "\"}", "SMS_465354371"); - } else { - //0:待抢单 1:待取货 2:已作废 3:待送达 4:已完成 - //退货: - //5:下游客户待退货 00:退货待抢单 01:退货待取货 02:退货已作废 03:退货待送达 04:待确认退货 4:已完成 - if (StringUtils.isNotEmpty(saleDTO.getOrderByWorker())) { - // 指定了拉包工,直接为待取货 - sale.setStatus(SaleConstant.SALE_STATUS[1]); + // 开单暂存位挂单不需要处理订单状态 + if(!SaleConstant.SALE_STATUS[12].equals(sale.getStatus())){ + + // 如果是自送,状态为完成,其他使用平台的则为待取货 + if (SaleConstant.TRANSPORT_TYPE[2].equals(sale.getTransportType())) { + sale.setStatus(SaleConstant.SALE_STATUS[4]); + // 自送如果选择了物流公司,也需要物流公司返佣 + // 选择物流公司才返佣,否则是没有选择物流公司的自提 + if (StringUtils.isNotEmpty(sale.getTransCompany())) { + deductLogService.updateRebateAmount("", sale.getTransCompany(), sale.getShopId(), sale.getId(), sale.getTransportType()); + } + } else if (SaleConstant.MODE_OF_SERVICE[2].equals(sale.getModeOfService())) { + // 物流自提 + sale.setStatus(SaleConstant.SALE_STATUS[13]); + // 给物流公司发送一个短信 + // shopId从缓存中设置 + final String shopId = securityUtil.getShopId(); + final Shop shop = shopService.get(shopId); + final String shopAddress = shop.getShopAddress(); + smsUtil.sendSms(transCompanyPhone, "{\"shopAddress\":\"" + shopAddress + "\"}", "SMS_465354371"); } else { - sale.setStatus(SaleConstant.SALE_STATUS[0]); + //0:待抢单 1:待取货 2:已作废 3:待送达 4:已完成 + //退货: + //5:下游客户待退货 00:退货待抢单 01:退货待取货 02:退货已作废 03:退货待送达 04:待确认退货 4:已完成 + if (StringUtils.isNotEmpty(saleDTO.getOrderByWorker())) { + // 指定了拉包工,直接为待取货 + sale.setStatus(SaleConstant.SALE_STATUS[1]); + } else { + sale.setStatus(SaleConstant.SALE_STATUS[0]); + } } } + // 获取销售员的手机号 final User user = securityUtil.getCurrUser(); sale.setCreateByPhone(user.getMobile()); diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java index 1b0a807d..751a748d 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java @@ -31,6 +31,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.ObjectUtils; import java.math.BigDecimal; +import java.util.Arrays; import java.util.Date; import java.util.List; @@ -204,4 +205,11 @@ public class CustomerServiceImpl extends ServiceImpl i public void updatePhone(String newMobile, String userId) { customerMapper.updatePhone(newMobile, userId); } + + @Override + public boolean batchDeleteCustomer(String ids) { + // ids 逗号分隔,然后转为list + final List idList = Arrays.asList(ids.split(",")); + return customerMapper.batchDeleteCustomer(idList); + } } 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 22459e69..60cff8e7 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 @@ -21,6 +21,7 @@ import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -28,6 +29,7 @@ import java.util.*; import java.util.concurrent.CopyOnWriteArrayList; @Service +@Slf4j public class ProductServiceImpl extends ServiceImpl implements ProductService { @Autowired @@ -46,6 +48,29 @@ public class ProductServiceImpl extends ServiceImpl impl public IPage getShareList(ProductPageQuery productPageQuery) { final Page page = new Page<>(productPageQuery.getPageNum(), productPageQuery.getPageSize()); final List list = baseMapper.getShareList(page, productPageQuery); + // 获取商品子图 + List productIdList = new ArrayList<>(); + for (ProductPageVO productPageVO : list) { + productIdList.add(productPageVO.getId()); + } + // 获取子图 + List productPictureByProductIds = productPictureService.getProductPictureByProductIds(productIdList); + Map> productPictureMap = new HashMap<>(); + for (ProductPicture productPictureByProductId : productPictureByProductIds) { + if (productPictureMap.containsKey(productPictureByProductId.getProductId())) { + productPictureMap.get(productPictureByProductId.getProductId()).add(productPictureByProductId); + } else { + final List productPictureList = new ArrayList<>(); + productPictureList.add(productPictureByProductId); + productPictureMap.put(productPictureByProductId.getProductId(), productPictureList); + } + } + for (ProductPageVO productPageVO : list) { + String productId = productPageVO.getId(); + if (productPictureMap.containsKey(productId)) { + productPageVO.setProductPictures(productPictureMap.get(productId)); + } + } page.setRecords(list); return page; } @@ -275,7 +300,34 @@ public class ProductServiceImpl extends ServiceImpl impl productMapper.batchUpdateDelFlag(idList, ProductConstant.DEL_FLAG[0]); return true; } catch (Exception e) { + log.error("批量下架货品失败", e); return false; } } + + /** + * 根据货品id批量删除货品 + * + * @param ids + * @return boolean + * @author 王富康 + * @date 2024/6/22 + */ + @Override + public boolean batchDeleteProduct(String ids) { + // ids 逗号分隔转为list + try { + final List idList = Arrays.asList(ids.split(",")); + productMapper.batchUpdateDelFlag(idList, ProductConstant.DEL_FLAG[2]); + return true; + } catch (Exception e) { + log.error("批量下架货品失败", e); + return false; + } + } + + @Override + public void batchUpdatePurchasePrice(List productList) { + productMapper.batchUpdatePurchasePrice(productList); + } } 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 990f84ad..bd63197f 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 @@ -86,4 +86,17 @@ public class PurchaseDetailServiceImpl extends ServiceImpl getPurchaseDetails(List purchaseIdList) { return purchaseDetailMapper.getPurchaseDetails(purchaseIdList); } + + /** + * 查询该商品除当前入库单的其他的入库记录 + * @author 王富康 + * @date 2024/7/27 + * @param productIdList + * @param id + * @return List + */ + @Override + public List getPurchaseDetailListByProductIds(List productIdList, String id) { + return purchaseDetailMapper.getPurchaseDetailListByProductIds(productIdList, id); + } } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java index 738cef77..832ee079 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java @@ -7,6 +7,8 @@ import cc.hiver.core.entity.User; import cc.hiver.mall.bill.vo.ArrearsVo; import cc.hiver.mall.bill.vo.SupplierBillQueryVo; import cc.hiver.mall.dao.mapper.PurchaseMapper; +import cc.hiver.mall.debt.entity.Debt; +import cc.hiver.mall.debt.service.DebtService; import cc.hiver.mall.entity.*; import cc.hiver.mall.pojo.dto.DebtSupplier; import cc.hiver.mall.pojo.query.PurchasePageQuery; @@ -23,6 +25,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.util.*; @@ -40,6 +43,9 @@ public class PurchaseServiceImpl extends ServiceImpl i @Autowired private PurchaseDetailService purchaseDetailService; + @Autowired + private StockService stockService; + @Autowired private StockLogService stockLogService; @@ -61,6 +67,15 @@ public class PurchaseServiceImpl extends ServiceImpl i @Autowired private ProductService productService; + @Autowired + private SaleService saleService; + + @Autowired + private SaleDetailService saleDetailService; + + @Autowired + private DebtService debtService; + @Override public Page getDebtByShopId(PurchasePageQuery purchasePageQuery) { @@ -499,10 +514,11 @@ public class PurchaseServiceImpl extends ServiceImpl i /** * 获取从某个供应商的拿货入库记录(按入库单) - * @author 王富康 - * @date 2024/7/24 + * * @param purchasePageQuery * @return Page + * @author 王富康 + * @date 2024/7/24 */ @Override public Page getPurchaseListOfSupplier(PurchasePageQuery purchasePageQuery) { @@ -608,4 +624,168 @@ public class PurchaseServiceImpl extends ServiceImpl i } return purchaseVos; } + + /** + * 撤销采购单 + * + * @param id + * @author 王富康 + * @date 2024/7/27 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void cancelPurchase(String id) { + + // 获取采购单信息 + Purchase purchase = purchaseService.getById(id); + List purchaseIdList = new ArrayList<>(); + purchaseIdList.add(id); + // 3. 商品及库存回退 + // 查询商品是有有销售记录并且是不是有且只有这一次入库记录,是的话,直接删除商品及其库存信息,其他的只回退库存即可 + final List byPurchaseIdList = purchaseDetailService.getByPurchaseIdList(purchaseIdList, ""); + // 拿到商品id集合 + final List productIdList = new ArrayList<>(); + for (PurchaseDetail purchaseDetail : byPurchaseIdList) { + productIdList.add(purchaseDetail.getProductId()); + } + // 查询该商品除当前入库单的其他的入库记录 + final List purductPurchaseList = purchaseDetailService.getPurchaseDetailListByProductIds(productIdList, id); + // 封装为商品id为key,List为value 的map + final Map> purductPurchaseMap = new HashMap<>(); + for (PurchaseDetail purchaseDetail : purductPurchaseList) { + final String productId = purchaseDetail.getProductId(); + if (purductPurchaseMap.containsKey(productId)) { + purductPurchaseMap.get(productId).add(purchaseDetail); + } else { + final List purchaseDetails = new ArrayList<>(); + purchaseDetails.add(purchaseDetail); + purductPurchaseMap.put(productId, purchaseDetails); + } + } + // 查询该商品的销售记录 + final List purductSaleList = saleDetailService.getSaleDetailListByProductIds(productIdList); + // 封装为商品id为key,List为value 的map + final Map> purductSaleMap = new HashMap<>(); + for (SaleDetail saleDetail : purductSaleList) { + final String productId = saleDetail.getProductId(); + if (purductSaleMap.containsKey(productId)) { + purductSaleMap.get(productId).add(saleDetail); + } else { + final List saleDetails = new ArrayList<>(); + saleDetails.add(saleDetail); + purductSaleMap.put(productId, saleDetails); + } + } + + // + final StringJoiner needDeleteProductId = new StringJoiner(","); + final StringJoiner needDeleteStockProductId = new StringJoiner(","); + final StringJoiner needReduceStockProductId = new StringJoiner(","); + + for (PurchaseDetail purchaseDetail : byPurchaseIdList) { + final String productId = purchaseDetail.getProductId(); + if (!purductPurchaseMap.containsKey(productId) && !purductSaleMap.containsKey(productId)) { + // 可以删除商品的相关信息 + needDeleteProductId.add(productId); + // 库存删除 + needDeleteStockProductId.add(productId); + }else{ + // 商品保留,库存扣减 + needReduceStockProductId.add(productId); + } + + } + // 执行删除商品 + if(StringUtils.isNotEmpty(needDeleteProductId.toString())){ + productService.batchDeleteProduct(needDeleteProductId.toString()); + } + // 执行删除库存 + if(StringUtils.isNotEmpty(needReduceStockProductId.toString())){ + stockService.batchDeleteStockByProductIds(needDeleteStockProductId.toString()); + } + // 执行扣减库存 + if(StringUtils.isNotEmpty(needReduceStockProductId.toString())){ + // 获取当前入库单各商品的规格及数量信息 + final List stockLogList = stockLogService.getByProductIds(id, needReduceStockProductId.toString()); + // 根据入库记录减掉库存数 + stockService.batchReduceStockByLog(stockLogList); + } + // 4. 根据采购单id删除库存记录 + stockLogService.deleteByPurchaseId(id); + // 5. 计算平均采购价 + // 获取该商品的历次入库记录,排除掉本次入库记录 入库的价格*入库数量/入库总数量 + Map productPurchasePriceMap = new HashMap<>(); + + List productList = new ArrayList<>(); + for (Map.Entry> stringListEntry : purductPurchaseMap.entrySet()) { + final String productId = stringListEntry.getKey(); + List purchaseDetail = stringListEntry.getValue(); + // 计算该商品的平均采购价 = (当前入库价格*当前入库数量 + 历史入库价格*历史入库数量)/(当前入库数量+历史入库数量) + // 总入库数量 + int totalInStorageCount = 0; + // 总入库金额 + BigDecimal totalInStoragePrice = BigDecimal.ZERO; + for (PurchaseDetail detail : purchaseDetail) { + totalInStorageCount += detail.getProductCount(); + BigDecimal bigDecimalOfProductCount = new BigDecimal(detail.getProductCount()); + BigDecimal purchasePrice = detail.getPurchasePrice(); + totalInStoragePrice = totalInStoragePrice.add(purchasePrice.multiply(bigDecimalOfProductCount)); + } + // 平均采购价为 总入库金额 / 总入库数量 + BigDecimal newPurchasePrice = totalInStoragePrice.divide(BigDecimal.valueOf(totalInStorageCount)); + Product product = new Product(); + product.setId(productId); + product.setPurchasePrice(newPurchasePrice); + productList.add(product); + } + + // 执行更新平均采购价 + if(!productList.isEmpty()){ + productService.batchUpdatePurchasePrice(productList); + } + // 6. 欠款回退 + // 4. 订单款项记录作废 + // 根据订单获取交易记录 + final String supplierId = purchase.getSupplierId(); + final Debt oldDebt = debtService.selectByUserId(purchase.getShopId(), supplierId); + if (oldDebt != null) { + final BigDecimal newDebtAmount; + final BigDecimal lastDebtAmount = oldDebt.getAmountOwed(); + // 余额抵扣,需要从欠款中减掉 + final BigDecimal balanceDeductionAmount = purchase.getBalanceDeductionAmount() == null ? BigDecimal.ZERO : purchase.getBalanceDeductionAmount(); + // 本单欠款 + final BigDecimal noPay = purchase.getNoPay() == null ? BigDecimal.ZERO : purchase.getNoPay(); + // 计算欠款 + newDebtAmount = oldDebt.getAmountOwed().subtract(noPay).subtract(balanceDeductionAmount); + oldDebt.setAmountOwed(newDebtAmount); + debtService.updateById(oldDebt); + + // 2. 新增欠款记录 + // 创建人 + final User user = securityUtil.getCurrUser(); + final DealingsRecord dealingsRecord = new DealingsRecord(); + dealingsRecord.setCreateBy(user.getId()); + dealingsRecord.setCreateByName(user.getNickname()); + dealingsRecord.setCreateTime(new Date()); + dealingsRecord.setDealingsUserId(purchase.getSupplierId()); + dealingsRecord.setDealingsUserName(purchase.getSupplierName()); + dealingsRecord.setDealingsWay("订单撤销"); + dealingsRecord.setShopId(purchase.getShopId()); + // 上次欠款 + dealingsRecord.setLastDebtAmount(lastDebtAmount); + // 最新欠款 + dealingsRecord.setBalanceDue(newDebtAmount); + // 金额 + dealingsRecord.setAmount(noPay); + dealingsRecord.setDealingsType(DealingsRecordConstant.DEALINGS_TYPE[6]); + dealingsRecord.setUserType(DealingsRecordConstant.TYPE[0]); + dealingsRecordService.save(dealingsRecord); + } + // 作废当前订单的欠款记录 + dealingsRecordService.cancelRecord(id); + // 1. 将订单状态设置为删除状态 + purchaseService.deleteById(id); + // 2. 将订单详情设置为删除状态 + purchaseDetailService.deleteByPurchaseId(id); + } } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ReturnDetailServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ReturnDetailServiceImpl.java index e58ff4d8..c47a9a99 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ReturnDetailServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ReturnDetailServiceImpl.java @@ -46,4 +46,9 @@ public class ReturnDetailServiceImpl extends ServiceImpl getReturnDetailsByProductId(ReturnSalePageQuery returnSalePageQuery) { return returnDetailMapper.getReturnDetailsByProductId(returnSalePageQuery); } + + @Override + public void deleteBySaleId(String saleId) { + returnDetailMapper.deleteBySaleId(saleId); + } } 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 844d0b76..3c988824 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 @@ -218,4 +218,9 @@ public class ReturnSaleServiceImpl extends ServiceImpl getSaleDetails(List saleIdList) { return saleDetailMapper.getSaleDetails(saleIdList); } + + @Override + public List getSaleDetailListByProductIds(List productIdList) { + return saleDetailMapper.getSaleDetailListByProductIds(productIdList); + } } 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 31c86040..b30096d8 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 @@ -22,8 +22,7 @@ import cc.hiver.mall.debt.entity.Debt; import cc.hiver.mall.debt.service.DebtService; import cc.hiver.mall.deductlog.service.DeductLogService; import cc.hiver.mall.entity.*; -import cc.hiver.mall.pojo.dto.SaleDetailDTO; -import cc.hiver.mall.pojo.dto.SaleDetailQueryDTO; +import cc.hiver.mall.pojo.dto.*; import cc.hiver.mall.pojo.query.SalePageQuery; import cc.hiver.mall.pojo.query.SalesRankingQueryCriteria; import cc.hiver.mall.pojo.vo.*; @@ -31,7 +30,9 @@ import cc.hiver.mall.saleaimsg.constant.SaleAiMsgConstant; import cc.hiver.mall.saleaimsg.entity.SaleAiMsg; import cc.hiver.mall.saleaimsg.service.SaleAiMsgService; import cc.hiver.mall.service.OrderService; +import cc.hiver.mall.service.SalesAndDetailsService; import cc.hiver.mall.service.SendMessageService; +import cc.hiver.mall.service.ShopService; import cc.hiver.mall.service.mybatis.*; import cc.hiver.mall.utils.AliOcrUtil; import cc.hiver.mall.utils.DateUtil; @@ -111,6 +112,15 @@ public class SaleServiceImpl extends ServiceImpl implements Sa @Autowired private SendMessageService sendMessageService; + @Autowired + private ShopService shopService; + + @Autowired + private SalesAndDetailsService salesAndDetailsService; + + @Autowired + private ReturnDetailService returnDetailService; + @Override public void editPayPrice(String id, BigDecimal price, String dealingsWay) { // 修改采购单、实付、未付金额 @@ -351,7 +361,7 @@ public class SaleServiceImpl extends ServiceImpl implements Sa */ @Override public List getSalesRankingByShopId(SalesRankingQueryCriteria salesRankingQueryCriteria) { - if(StringUtils.isNotEmpty(salesRankingQueryCriteria.getEndTime())){ + if (StringUtils.isNotEmpty(salesRankingQueryCriteria.getEndTime())) { salesRankingQueryCriteria.setEndTime(DateUtil.addDay(salesRankingQueryCriteria.getEndTime(), 1)); } return saleMapper.getSalesRankingByShopId(salesRankingQueryCriteria); @@ -391,7 +401,7 @@ public class SaleServiceImpl extends ServiceImpl implements Sa } if (!productIds.isEmpty()) { // 获取商品各规格售卖的数量 - final List customerBuyProductDetailLogVos = saleMapper.getCustomerBuyProductLogDetailLog(userId, salePageQuery.getShopId(), productIds,salePageQuery.getStartDate(),salePageQuery.getEndDate()); + final List customerBuyProductDetailLogVos = saleMapper.getCustomerBuyProductLogDetailLog(userId, salePageQuery.getShopId(), productIds, salePageQuery.getStartDate(), salePageQuery.getEndDate()); // 进行数据封装Map<商品id,Map<销售单id,商品明细>> final Map>> allMap = new HashMap<>(); @@ -924,7 +934,7 @@ public class SaleServiceImpl extends ServiceImpl implements Sa // 4. 订单款项记录作废 // 根据订单获取交易记录 final String userId = sale.getUserId(); - final Debt oldDebt = debtService.selectByUserId(sale.getShopId(),userId); + final Debt oldDebt = debtService.selectByUserId(sale.getShopId(), userId); if (oldDebt != null) { final BigDecimal newDebtAmount; final BigDecimal lastDebtAmount = oldDebt.getAmountOwed(); @@ -965,7 +975,7 @@ public class SaleServiceImpl extends ServiceImpl implements Sa dealingsRecordService.cancelRecord(id); // 如果有配送单,那么就取消配送,并给快递员发送消息 final OrderXd orderXd = orderService.findByOrderId(id); - if(orderXd != null && (orderXd.getOrderStatus().equals(OrderConstant.ORDER_STATUS[0]) || orderXd.getOrderStatus().equals(OrderConstant.ORDER_STATUS[1]))){ + if (orderXd != null && (orderXd.getOrderStatus().equals(OrderConstant.ORDER_STATUS[0]) || orderXd.getOrderStatus().equals(OrderConstant.ORDER_STATUS[1]))) { if (StringUtils.isNotEmpty(orderXd.getOrderByWorker())) { // 如果订单被抢单了,那么需要给配送员发送消息 sendMessageService.handleSendAppMessageOfQuxiao(orderXd.getOrderByWorker()); @@ -1006,10 +1016,11 @@ public class SaleServiceImpl extends ServiceImpl implements Sa /** * 实收金额明细 - * @author 王富康 - * @date 2024/6/29 + * * @param salePageQuery * @return List + * @author 王富康 + * @date 2024/6/29 */ @Override public Page totalAlreadyEarnDetail(SalePageQuery salePageQuery) { @@ -1027,10 +1038,11 @@ public class SaleServiceImpl extends ServiceImpl implements Sa /** * 客户拿货统计 - * @author 王富康 - * @date 2024/6/29 + * * @param salePageQuery * @return Page + * @author 王富康 + * @date 2024/6/29 */ @Override public Page customerSaleDetail(SalePageQuery salePageQuery) { @@ -1046,6 +1058,98 @@ public class SaleServiceImpl extends ServiceImpl implements Sa return saleMapper.customerSaleDetail(page, salePageQuery); } + /** + * 开单暂存为挂单 + * + * @param saleQueryDTO + * @author 王富康 + * @date 2024/7/26 + */ + @Override + public void temporarySaveSale(SaleQueryDTO saleQueryDTO) { + + try { + // 设置店铺id为缓存中的内容 + // shopId从缓存中设置 + final String shopId = securityUtil.getShopId(); + final Shop shop = shopService.get(shopId); + saleQueryDTO.getSale().setShopId(shopId); + saleQueryDTO.getSale().setShopName(shop.getShopName()); + // 20240616 开单可能值包含退货单 + Sale sale = saleQueryDTO.getSale(); + // 处理销售商品信息 + if (saleQueryDTO.getSaleDetailList() != null && !saleQueryDTO.getSaleDetailList().isEmpty()) { + // 1. 处理商品信息,新商品进行新商品的新增,分类及规格的新增,分类库的新增,子图的新增 + saleQueryDTO = productService.handleProduct(saleQueryDTO); + // 2.处理订单表模块 + sale = salesAndDetailsService.handleSalesDetails(saleQueryDTO); + // 更新sale + saleQueryDTO.setSale(sale); + } else { + // 销售单只有退货信息,补充一些基本信息,保存销售单 + // 获取销售员的手机号 + final User currUser = securityUtil.getCurrUser(); + sale.setCreateBy(currUser.getId()); + sale.setCreateByName(currUser.getNickname()); + sale.setCreateByPhone(currUser.getMobile()); + sale.setCreateTime(new Date()); + sale.setDelFlag(CommonConstant.DEL_FLAG_FALSE); + sale.setStatus(SaleConstant.SALE_STATUS[12]); + saleService.save(sale); + // 只有退货,单独处理下客户欠款 + } + + // 如果退货信息不为空,那么则代表需要退货,处理退货信息 + // 处理退货信息 + if (saleQueryDTO.getSaleReturnDTO() != null) { + //处理退货信息 + final SaleReturnDTO saleReturnDTO = saleQueryDTO.getSaleReturnDTO(); + // 回填销售单id + saleReturnDTO.getReturnSale().setSaleId(sale.getId()); + // 申请退货 + final ReturnSale returnSale = salesAndDetailsService.handleBackSalesDetails(saleReturnDTO); + // 如确认退货 + //扣减库存 + final List returnSaleId = new ArrayList<>(); + returnSaleId.add(returnSale.getId()); + final List returnDetails = returnDetailService.getReturnDetailsByReturnId(returnSaleId); + final List returnSaleDetailDTOList = new ArrayList<>(); + for (ReturnDetail returnDetail : returnDetails) { + final ReturnSaleDetailDTO returnSaleDetailDTO = new ReturnSaleDetailDTO(); + returnSaleDetailDTO.setSaleId(returnDetail.getSaleId()); + returnSaleDetailDTO.setReturnSaleId(returnDetail.getReturnSaleId()); + returnSaleDetailDTO.setProductId(returnDetail.getProductId()); + returnSaleDetailDTO.setProductName(returnDetail.getProductName()); + returnSaleDetailDTO.setUnit(returnDetail.getUnit()); + returnSaleDetailDTO.setShopId(returnDetail.getShopId()); + returnSaleDetailDTO.setCategoryId(returnDetail.getCategoryId()); + returnSaleDetailDTO.setAttributeList(returnDetail.getAttributeList()); + returnSaleDetailDTO.setPrice(returnDetail.getPrice()); + returnSaleDetailDTO.setPurchasePrice(returnDetail.getPurchasePrice()); + returnSaleDetailDTO.setWholesalePrice(returnDetail.getWholesalePrice()); + returnSaleDetailDTO.setProductCount(returnDetail.getProductCount()); + returnSaleDetailDTO.setDiscount(returnDetail.getDiscount()); + returnSaleDetailDTO.setDiscountAmount(returnDetail.getDiscountAmount()); + returnSaleDetailDTO.setRealPrice(returnDetail.getRealPrice()); + returnSaleDetailDTO.setDetailId(returnDetail.getId()); + final List saleDetailQueryDTOS = new ArrayList<>(); + final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO(); + saleDetailQueryDTO.setAttributeList(returnDetail.getAttributeList()); + saleDetailQueryDTO.setProductCount(returnDetail.getProductCount()); + saleDetailQueryDTOS.add(saleDetailQueryDTO); + returnSaleDetailDTO.setStockLogList1(saleDetailQueryDTOS); + returnSaleDetailDTOList.add(returnSaleDetailDTO); + } + // 更新退货单机销售单的状态为已完成 + returnSale.setUpdateTime(new Date()); + returnSale.setStatus(SaleConstant.SALE_STATUS[12]); + returnSaleService.saveOrUpdate(returnSale); + } + } catch (Exception e) { + log.error(e.getMessage(), e); + } + } + /** * 使用正则表达式替换输入字符串中连续的“叉”字符为相应数量的“X”字符。 * diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockLogServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockLogServiceImpl.java index 5cf181b1..3ccab6fe 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockLogServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockLogServiceImpl.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Arrays; import java.util.List; @Service @@ -21,7 +22,7 @@ public class StockLogServiceImpl extends ServiceImpl i } @Override - public List getByPurchaseIds(List purchaseIds,String productId) { + public List getByPurchaseIds(List purchaseIds, String productId) { return stockLogMapper.getByPurchaseIds(purchaseIds, productId); } @@ -40,4 +41,20 @@ public class StockLogServiceImpl extends ServiceImpl i return stockLogMapper.getPurchaseDetails(purchaseIdList); } + /** + * 霍如入库单中某些商品的规格信息 + * + * @param purchaseId + * @param productIds + * @return List + * @author 王富康 + * @date 2024/7/27 + */ + @Override + public List getByProductIds(String purchaseId, String productIds) { + final String[] split = productIds.split(","); + final List productIdList = Arrays.asList(split); + return stockLogMapper.getByProductIds(purchaseId, productIdList); + } + } 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 552beeba..1af0fa5d 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 @@ -1,5 +1,6 @@ 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.utils.ResultUtil; import cc.hiver.core.common.utils.SecurityUtil; @@ -17,6 +18,7 @@ import cc.hiver.mall.pojo.vo.*; import cc.hiver.mall.productpicture.entity.ProductPicture; import cc.hiver.mall.productpicture.service.ProductPictureService; import cc.hiver.mall.service.mybatis.*; +import cc.hiver.mall.utils.DateUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -380,6 +382,22 @@ public class StockServiceImpl extends ServiceImpl implements final Purchase purchase = purchaseService.getById(id); purchase.setUpdateTime(new Date()); purchase.setUpdateBy(user.getId()); + // 入库时间,约定前台肯定传 + final Date purchaseTime = purchase.getPurchaseTime(); + if(purchaseTime == null){ + // 如果前台没有传入库时间,就存当前时间,这里应该不会进入 + purchase.setPurchaseTime(new Date()); + }else{ + // 前台传的是不带时分秒的,如果是今天,那么使用当前时间,否则使用前台传的时间 + if(DateUtil.isSameDay(new Date(),purchaseTime)){ + purchase.setCreateTime(new Date()); + purchase.setPurchaseTime(new Date()); + }else{ + // 因为现在对账单或者是列表排序等都是根据creTime去排序和展示的,所以这里createTime 为入库时间,前台传,PurchaseTime为入库单创建时间 + purchase.setCreateTime(purchaseTime); + purchase.setPurchaseTime(new Date()); + } + } purchase.setTotalAmount(putInPurchase.getTotalAmount()); purchase.setShouldPay(putInPurchase.getShouldPay()); purchase.setAlreadyPay(putInPurchase.getAlreadyPay()); @@ -508,6 +526,7 @@ public class StockServiceImpl extends ServiceImpl implements stock.setProductIntro(purchaseDetail.getProductIntro()); stock.setSalesWeek(purchaseDetail.getSalesWeek()); stock.setStockCount(stockLog.getProductCount()); + stock.setDelFlag(CommonConstant.DEL_FLAG_FALSE); // 实时更新库存信息 stockService.save(stock); } @@ -687,6 +706,23 @@ public class StockServiceImpl extends ServiceImpl implements final Purchase purchase = purchaseVo.getPurchase(); purchase.setCreateByName(user.getNickname()); purchase.setShopId(shopId); + // 入库时间,约定前台肯定传 + final Date purchaseTime = purchase.getPurchaseTime(); + if(purchaseTime == null){ + // 如果前台没有传入库时间,就存当前时间,这里应该不会进入 + purchase.setPurchaseTime(new Date()); + }else{ + // 前台传的是不带时分秒的,如果是今天,那么使用当前时间,否则使用前台传的时间 + if(DateUtil.isSameDay(new Date(),purchaseTime)){ + purchase.setCreateTime(new Date()); + purchase.setPurchaseTime(new Date()); + }else{ + // 因为现在对账单或者是列表排序等都是根据creTime去排序和展示的,所以这里createTime 为入库时间,前台传,PurchaseTime为入库单创建时间 + purchase.setCreateTime(purchaseTime); + purchase.setPurchaseTime(new Date()); + } + } + // 语音入库没有入库id String purchaseId = purchase.getId(); if (StringUtils.isEmpty(purchaseId)){ @@ -965,6 +1001,7 @@ public class StockServiceImpl extends ServiceImpl implements stock.setSalesWeek(purchaseDetail.getSalesWeek()); stock.setStockCount(stockLog.getProductCount()); stock.setPurchasePrice(purchaseDetail.getPurchasePrice()); + stock.setDelFlag(CommonConstant.DEL_FLAG_FALSE); stockService.save(stock); } } @@ -1113,4 +1150,16 @@ public class StockServiceImpl extends ServiceImpl implements public List getProductStockByAttrId(String attrId) { return stockMapper.getProductStockByAttrId(attrId); } + + @Override + public void batchDeleteStockByProductIds(String productIds) { + // 根据逗号拆分为List + final List productIdList = Arrays.asList(productIds.split(",")); + stockMapper.batchDeleteStockByProductIds(productIdList); + } + + @Override + public void batchReduceStockByLog(List stockLogList) { + stockMapper.batchReduceStockByLog(stockLogList); + } } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/utils/DateUtil.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/utils/DateUtil.java index 2ebbbcb1..fa6342a6 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/utils/DateUtil.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/utils/DateUtil.java @@ -385,5 +385,38 @@ public class DateUtil { } return ""; } + + /** + * 是否是同一天 + * @author 王富康 + * @date 2024/7/27 + * @param date1 + * @param date2 + * @return boolean + */ + public static boolean isSameDay(Date date1, Date date2) { + Calendar cal1 = Calendar.getInstance(); + Calendar cal2 = Calendar.getInstance(); + + cal1.setTime(date1); + cal2.setTime(date2); + + // 比较年份 + if (cal1.get(Calendar.YEAR) != cal2.get(Calendar.YEAR)) { + return false; + } + + // 比较月份 + if (cal1.get(Calendar.MONTH) != cal2.get(Calendar.MONTH)) { + return false; + } + + // 比较天数 + if (cal1.get(Calendar.DAY_OF_MONTH) != cal2.get(Calendar.DAY_OF_MONTH)) { + return false; + } + + return true; + } } 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 0577e399..5bcc72e0 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/CustomerMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/CustomerMapper.xml @@ -441,4 +441,13 @@ set phone = #{newMobile,jdbcType=VARCHAR} where user_id = #{userId,jdbcType=VARCHAR} + + + update t_customer + set del_flag = '1' + where id in + + #{listItem} + + \ No newline at end of file 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 9f5594ab..c83c9ac1 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/ProductMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/ProductMapper.xml @@ -756,4 +756,10 @@ #{listItem} + + + + update t_product set purchase_price = #{item.purchasePrice} WHERE id = #{item.id} + + \ No newline at end of file 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 4ba9c6eb..ab83258c 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml @@ -641,4 +641,16 @@ #{listItem} + + \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml index 3aae2652..16f143c8 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml @@ -20,6 +20,7 @@ + @@ -88,7 +89,8 @@ 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 + total_amount, should_pay, already_pay, no_pay,other_pay, in_storage_status,remark, balance_deduction_amount, + purchase_time - + + + delete from t_return_sale + where sale_id = #{saleId,jdbcType=VARCHAR} + \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/SaleDetailMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/SaleDetailMapper.xml index 55ed9b7c..fa81b5bc 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/SaleDetailMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/SaleDetailMapper.xml @@ -522,4 +522,15 @@ #{listItem} + + \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/StockLogMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/StockLogMapper.xml index 0bcbc52a..6c11577c 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/StockLogMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/StockLogMapper.xml @@ -468,4 +468,15 @@ #{listItem} + + \ 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 37c059c0..37e1b968 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml @@ -671,4 +671,19 @@ t_stock s where s.product_id = (select id from t_product where attr_id = #{attrId}) + + + update t_stock s + set s.del_flag = '1' + where s.product_id in + + #{item} + + + + + + update t_stock set stock_count = stock_count - #{item.productCount} WHERE product_id = #{item.productId} and attribute_list = #{item.attributeList} + + \ No newline at end of file