Browse Source

许多家需求优化

cangku
wangfukang 2 years ago
parent
commit
2381ff3d25
  1. 7
      hiver-admin/src/main/resources/application.yml
  2. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/service/impl/BillServiceImpl.java
  3. 14
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java
  4. 25
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java
  5. 44
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PurchaseController.java
  6. 57
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SaleController.java
  7. 42
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java
  8. 36
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SupplierControlller.java
  9. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/CustomerMapper.java
  10. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ProductMapper.java
  11. 10
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseDetailMapper.java
  12. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ReturnDetailMapper.java
  13. 1
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ReturnSaleMapper.java
  14. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleDetailMapper.java
  15. 1
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java
  16. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockLogMapper.java
  17. 5
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockMapper.java
  18. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Purchase.java
  19. 14
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/productpicture/service/impl/ProductPictureServiceImpl.java
  20. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/CustomerService.java
  21. 11
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductService.java
  22. 10
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseDetailService.java
  23. 22
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java
  24. 1
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ReturnDetailService.java
  25. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ReturnSaleService.java
  26. 9
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleDetailService.java
  27. 20
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleService.java
  28. 10
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockLogService.java
  29. 17
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockService.java
  30. 55
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesAndDetailsServiceImpl.java
  31. 8
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java
  32. 52
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java
  33. 13
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseDetailServiceImpl.java
  34. 184
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java
  35. 5
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ReturnDetailServiceImpl.java
  36. 5
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ReturnSaleServiceImpl.java
  37. 5
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleDetailServiceImpl.java
  38. 124
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java
  39. 19
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockLogServiceImpl.java
  40. 49
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java
  41. 33
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/utils/DateUtil.java
  42. 9
      hiver-modules/hiver-mall/src/main/resources/mapper/CustomerMapper.xml
  43. 6
      hiver-modules/hiver-mall/src/main/resources/mapper/ProductMapper.xml
  44. 12
      hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml
  45. 23
      hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml
  46. 6
      hiver-modules/hiver-mall/src/main/resources/mapper/ReturnDetailMapper.xml
  47. 6
      hiver-modules/hiver-mall/src/main/resources/mapper/ReturnSaleMapper.xml
  48. 11
      hiver-modules/hiver-mall/src/main/resources/mapper/SaleDetailMapper.xml
  49. 11
      hiver-modules/hiver-mall/src/main/resources/mapper/StockLogMapper.xml
  50. 15
      hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml

7
hiver-admin/src/main/resources/application.yml

@ -25,8 +25,8 @@ spring:
timeout-per-shutdown-phase: 10S timeout-per-shutdown-phase: 10S
# 数据源 # 数据源
datasource: 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://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://8.140.198.243:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: reddoor username: reddoor
# Jasypt加密 可到common-utils中找到JasyptUtil加解密工具类生成加密结果 格式为ENC(加密结果) 以下解密结果为123456 # Jasypt加密 可到common-utils中找到JasyptUtil加解密工具类生成加密结果 格式为ENC(加密结果) 以下解密结果为123456
password: ENC(Zla4U4+yRLPhicvuX2TmiEgxEpzP4dk8BHzFDEtiEhwLQIIaftZrrEUJZce6efoe) password: ENC(Zla4U4+yRLPhicvuX2TmiEgxEpzP4dk8BHzFDEtiEhwLQIIaftZrrEUJZce6efoe)
@ -67,7 +67,7 @@ spring:
ddl-auto: update ddl-auto: update
# Redis 若设有密码自行添加配置password # Redis 若设有密码自行添加配置password
redis: redis:
# host: 154.8.162.157 host: 154.8.162.157
# host: 8.140.198.243 # host: 8.140.198.243
password: reddoor168 password: reddoor168
# 数据库索引 默认0 # 数据库索引 默认0
@ -333,6 +333,7 @@ ignored:
# # 临时增加 # # 临时增加
- /hiver/app/purchase/getPurchaseListOfSupplier - /hiver/app/purchase/getPurchaseListOfSupplier
- /hiver/app/purchase/cancelPurchase
# 限流及黑名单不拦截的路径 # 限流及黑名单不拦截的路径
limitUrls: limitUrls:
- /**/*.js - /**/*.js

2
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(); final SupplierBillDataVo supplierBillDataVo = new SupplierBillDataVo();
supplierBillDataVo.setUserId(supplierBillQueryVo.getSupplierId()); supplierBillDataVo.setUserId(supplierBillQueryVo.getSupplierId());
// 获取客户信息 // 获取供应商信息
final Supplier supplier = supplierService.findById(supplierBillQueryVo.getSupplierId()); final Supplier supplier = supplierService.findById(supplierBillQueryVo.getSupplierId());
supplierBillDataVo.setUserName(supplier.getConsigneeName()); supplierBillDataVo.setUserName(supplier.getConsigneeName());
supplierBillDataVo.setQueryDate(DateUtil.COMMON_FULL.getDateText(new Date())); supplierBillDataVo.setQueryDate(DateUtil.COMMON_FULL.getDateText(new Date()));

14
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) @RequestMapping(value = "/list", method = RequestMethod.POST)
@ApiOperation("查询客户列表") @ApiOperation("查询客户列表")

25
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); product.setDelFlag(CommonConstant.DEL_FLAG_TRUE);
final boolean result = productService.save(product); final boolean result = productService.save(product);
// 如果有子图,那么新增子图信息 // 如果有子图,那么新增子图信息
List<ProductPicture> productPictures = productVo.getProductPictures(); final List<ProductPicture> productPictures = productVo.getProductPictures();
if (productPictures != null && !productPictures.isEmpty()) { if (productPictures != null && !productPictures.isEmpty()) {
for (ProductPicture productPicture : productPictures) { for (ProductPicture productPicture : productPictures) {
productPicture.setProductId(product.getId()); productPicture.setProductId(product.getId());
@ -107,7 +107,7 @@ public class ProductController {
} }
final boolean result = productService.updateById(product); final boolean result = productService.updateById(product);
// 如果有子图,那么新增子图信息 // 如果有子图,那么新增子图信息
List<ProductPicture> productPictures = productVo.getProductPictures(); final List<ProductPicture> productPictures = productVo.getProductPictures();
if (productPictures != null && !productPictures.isEmpty()) { if (productPictures != null && !productPictures.isEmpty()) {
// 先删除 // 先删除
productPictureService.deleteByProductId(productVo.getId()); 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) // @RequestMapping(value = "/listGoodsPages", method = RequestMethod.POST)
// @ApiOperation(value = "商品分页列表[服务端]") // @ApiOperation(value = "商品分页列表[服务端]")
// public Result<IPage<GoodsPageVO>> listGoodsPages(GoodsPageQuery queryParams) { // public Result<IPage<GoodsPageVO>> listGoodsPages(GoodsPageQuery queryParams) {

44
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 String shopId = securityUtil.getShopId();
final QueryWrapper<Purchase> querySaleWrapper = new QueryWrapper<>(); final QueryWrapper<Purchase> querySaleWrapper = new QueryWrapper<>();
querySaleWrapper.eq("shop_id", shopId) 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]); .eq("in_storage_status", StockConstant.IN_STORAGE_STATUS[0]);
final long waitReturnCount = purchaseService.count(querySaleWrapper); final long waitReturnCount = purchaseService.count(querySaleWrapper);
return ResultUtil.data(waitReturnCount); return ResultUtil.data(waitReturnCount);
@ -273,12 +273,14 @@ public class PurchaseController {
final PurchaseVo purchaseVo = purchaseService.getPurchaseAllDataOfAi(id); final PurchaseVo purchaseVo = purchaseService.getPurchaseAllDataOfAi(id);
return new ResultUtil<PurchaseVo>().setData(purchaseVo); return new ResultUtil<PurchaseVo>().setData(purchaseVo);
} }
/** /**
* 进货金额可查明细 * 进货金额可查明细
* @author 王富康 *
* @date 2024/6/29
* @param purchasePageQuery * @param purchasePageQuery
* @return Result * @return Result
* @author 王富康
* @date 2024/6/29
*/ */
@PostMapping("/purchasingCostDetail") @PostMapping("/purchasingCostDetail")
public Result purchasingCostDetail(@RequestBody PurchasePageQuery purchasePageQuery) { public Result purchasingCostDetail(@RequestBody PurchasePageQuery purchasePageQuery) {
@ -286,22 +288,23 @@ public class PurchaseController {
final Page<PurchasingCostDetailVo> purchasingCostDetail = purchaseService.purchasingCostDetail(purchasePageQuery); final Page<PurchasingCostDetailVo> purchasingCostDetail = purchaseService.purchasingCostDetail(purchasePageQuery);
return new ResultUtil<>().setData(purchasingCostDetail); return new ResultUtil<>().setData(purchasingCostDetail);
} catch (Exception e) { } catch (Exception e) {
log.info(e.getMessage(),e); log.info(e.getMessage(), e);
return ResultUtil.error("查询失败"); return ResultUtil.error("查询失败");
} }
} }
/** /**
* 请详细描述方法 * 请详细描述方法
* @author 王富康 *
* @date 2024/7/24
* @param purchasePageQuery * @param purchasePageQuery
* @return Result * @return Result
*/ * @author 王富康
* @date 2024/7/24
*/
@RequestMapping(value = "/getPurchaseListOfSupplier", method = RequestMethod.POST) @RequestMapping(value = "/getPurchaseListOfSupplier", method = RequestMethod.POST)
@ApiOperation("获取从某个供应商的拿货入库记录") @ApiOperation("获取从某个供应商的拿货入库记录")
public Result getPurchaseListOfSupplier(@RequestBody PurchasePageQuery purchasePageQuery) { public Result getPurchaseListOfSupplier(@RequestBody PurchasePageQuery purchasePageQuery) {
if(StringUtils.isEmpty(purchasePageQuery.getSupplierId())){ if (StringUtils.isEmpty(purchasePageQuery.getSupplierId())) {
return ResultUtil.error("供应商id不能为空!"); return ResultUtil.error("供应商id不能为空!");
} }
// shopId从缓存中设置 // shopId从缓存中设置
@ -310,4 +313,29 @@ public class PurchaseController {
final Page<PurchaseVo> purchaseVoList = purchaseService.getPurchaseListOfSupplier(purchasePageQuery); final Page<PurchaseVo> purchaseVoList = purchaseService.getPurchaseListOfSupplier(purchasePageQuery);
return ResultUtil.data(purchaseVoList); 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("撤销失败!");
}
}
} }

57
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()); saleQueryDTO.getSale().setShopName(shop.getShopName());
// 根据该客户的欠款信息 // 根据该客户的欠款信息
String userId = saleQueryDTO.getSale().getUserId(); String userId = saleQueryDTO.getSale().getUserId();
Debt debt = debtService.selectByUserId(shopId,userId); Debt debt = debtService.selectByUserId(shopId, userId);
BigDecimal amountOwed = debt.getAmountOwed(); BigDecimal amountOwed = debt.getAmountOwed();
// 20240616 开单可能值包含退货单 // 20240616 开单可能值包含退货单
Sale sale = saleQueryDTO.getSale(); Sale sale = saleQueryDTO.getSale();
@ -256,15 +256,7 @@ public class SaleController {
returnSaleService.saveOrUpdate(returnSale); returnSaleService.saveOrUpdate(returnSale);
} }
// 处理欠款信息 // 处理欠款信息
// 本单欠款 debtService.saleToDebt(saleQueryDTO);
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);
// }
return new ResultUtil<>().setData(sale.getId(), "下单成功"); return new ResultUtil<>().setData(sale.getId(), "下单成功");
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
@ -305,6 +297,10 @@ public class SaleController {
if (result) { if (result) {
// 删除子表数据 // 删除子表数据
saleDetailService.deleteBySaleId(id); saleDetailService.deleteBySaleId(id);
// 删除退货单的信息
returnSaleService.deleteBySaleId(id);
// 删除退货单的详细信息
returnDetailService.deleteBySaleId(id);
return ResultUtil.success("删除成功"); return ResultUtil.success("删除成功");
} }
return ResultUtil.error("删除失败"); return ResultUtil.error("删除失败");
@ -1012,7 +1008,7 @@ public class SaleController {
@RequestMapping(value = "/getCustomerBuyProductLog", method = RequestMethod.POST) @RequestMapping(value = "/getCustomerBuyProductLog", method = RequestMethod.POST)
@ApiOperation("下游客户查询商品购买记录") @ApiOperation("下游客户查询商品购买记录")
public Result getCustomerBuyProductLog(@RequestBody SalePageQuery salePageQuery) { public Result getCustomerBuyProductLog(@RequestBody SalePageQuery salePageQuery) {
if(StringUtils.isEmpty(salePageQuery.getShopId())){ if (StringUtils.isEmpty(salePageQuery.getShopId())) {
return ResultUtil.error("店铺id不能为空"); return ResultUtil.error("店铺id不能为空");
} }
final Page<CustomerBuyProductLogVo> salePage = saleService.getCustomerBuyProductLog(salePageQuery); final Page<CustomerBuyProductLogVo> salePage = saleService.getCustomerBuyProductLog(salePageQuery);
@ -1022,10 +1018,10 @@ public class SaleController {
@RequestMapping(value = "/getSupplierBuyProductLog", method = RequestMethod.POST) @RequestMapping(value = "/getSupplierBuyProductLog", method = RequestMethod.POST)
@ApiOperation("根据供应商查询商品购买记录") @ApiOperation("根据供应商查询商品购买记录")
public Result getSupplierBuyProductLog(@RequestBody SalePageQuery salePageQuery) { public Result getSupplierBuyProductLog(@RequestBody SalePageQuery salePageQuery) {
if(StringUtils.isEmpty(salePageQuery.getShopId())){ if (StringUtils.isEmpty(salePageQuery.getShopId())) {
return ResultUtil.error("店铺id不能为空"); return ResultUtil.error("店铺id不能为空");
} }
if(StringUtils.isEmpty(salePageQuery.getSupplierId())){ if (StringUtils.isEmpty(salePageQuery.getSupplierId())) {
return ResultUtil.error("供应商id不能为空"); return ResultUtil.error("供应商id不能为空");
} }
final Page<SupplierBuyProductLogVo> salePage = saleService.getSupplierBuyProductLog(salePageQuery); final Page<SupplierBuyProductLogVo> salePage = saleService.getSupplierBuyProductLog(salePageQuery);
@ -1156,17 +1152,18 @@ public class SaleController {
final Page<TotalAmountDetailVo> totalAmountDetail = saleService.totalAmountDetail(salePageQuery); final Page<TotalAmountDetailVo> totalAmountDetail = saleService.totalAmountDetail(salePageQuery);
return new ResultUtil<>().setData(totalAmountDetail); return new ResultUtil<>().setData(totalAmountDetail);
} catch (Exception e) { } catch (Exception e) {
log.info(e.getMessage(),e); log.info(e.getMessage(), e);
return ResultUtil.error("查询失败"); return ResultUtil.error("查询失败");
} }
} }
/** /**
* 实收金额明细 * 实收金额明细
* @author 王富康 *
* @date 2024/6/29
* @param salePageQuery * @param salePageQuery
* @return Result * @return Result
* @author 王富康
* @date 2024/6/29
*/ */
@PostMapping("/totalAlreadyEarnDetail") @PostMapping("/totalAlreadyEarnDetail")
public Result totalAlreadyEarnDetail(@RequestBody SalePageQuery salePageQuery) { public Result totalAlreadyEarnDetail(@RequestBody SalePageQuery salePageQuery) {
@ -1174,17 +1171,18 @@ public class SaleController {
final Page<TotalAlreadyEarnDetailDayVo> totalAlreadyEarnDetail = saleService.totalAlreadyEarnDetail(salePageQuery); final Page<TotalAlreadyEarnDetailDayVo> totalAlreadyEarnDetail = saleService.totalAlreadyEarnDetail(salePageQuery);
return new ResultUtil<>().setData(totalAlreadyEarnDetail); return new ResultUtil<>().setData(totalAlreadyEarnDetail);
} catch (Exception e) { } catch (Exception e) {
log.info(e.getMessage(),e); log.info(e.getMessage(), e);
return ResultUtil.error("查询失败"); return ResultUtil.error("查询失败");
} }
} }
/** /**
* 客户拿货统计 * 客户拿货统计
* @author 王富康 *
* @date 2024/6/29
* @param salePageQuery * @param salePageQuery
* @return Result * @return Result
* @author 王富康
* @date 2024/6/29
*/ */
@PostMapping("/customerSaleDetail") @PostMapping("/customerSaleDetail")
public Result customerSaleDetail(@RequestBody SalePageQuery salePageQuery) { public Result customerSaleDetail(@RequestBody SalePageQuery salePageQuery) {
@ -1192,8 +1190,27 @@ public class SaleController {
final Page<CustomerSaleDetailVo> customerSaleDetail = saleService.customerSaleDetail(salePageQuery); final Page<CustomerSaleDetailVo> customerSaleDetail = saleService.customerSaleDetail(salePageQuery);
return new ResultUtil<>().setData(customerSaleDetail); return new ResultUtil<>().setData(customerSaleDetail);
} catch (Exception e) { } catch (Exception e) {
log.info(e.getMessage(),e); log.info(e.getMessage(), e);
return ResultUtil.error("查询失败"); 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("暂存失败!");
}
}
} }

42
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java

@ -258,4 +258,46 @@ public class ShopController {
final Map<String,String> shopRebateBalance = shopService.getShopRebateBalance(); final Map<String,String> shopRebateBalance = shopService.getShopRebateBalance();
return ResultUtil.data(shopRebateBalance); 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("更新成功");
}
} }

36
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.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional; 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.math.BigDecimal;
import java.util.Date; import java.util.Date;
@ -30,7 +33,7 @@ import java.util.List;
@Slf4j @Slf4j
@RestController @RestController
@Api(tags = "供应商接口") @Api(tags = "供应商接口")
@RequestMapping(value = "/hiver/app/supplier/") @RequestMapping("/hiver/app/supplier/")
@Transactional @Transactional
public class SupplierControlller { public class SupplierControlller {
@Autowired @Autowired
@ -46,12 +49,12 @@ public class SupplierControlller {
private DealingsRecordService dealingsRecordService; private DealingsRecordService dealingsRecordService;
@RequestMapping(value = "/getByCondition", method = RequestMethod.POST) @RequestMapping(value = "/getByCondition", method = RequestMethod.POST)
@ApiOperation(value = "根据条件获得分页") @ApiOperation("根据条件获得分页")
public Result<Page<Supplier>> queryAll(Supplier supplierOfquery, PageVo pageVo) { public Result<Page<Supplier>> queryAll(Supplier supplierOfquery, PageVo pageVo) {
// 从缓存中拿到店铺id // 从缓存中拿到店铺id
final String shopId = securityUtil.getShopId(); final String shopId = securityUtil.getShopId();
supplierOfquery.setShopId(shopId); supplierOfquery.setShopId(shopId);
Page<Supplier> users = supplierService.queryAll(supplierOfquery, PageUtil.initPage(pageVo)); final Page<Supplier> users = supplierService.queryAll(supplierOfquery, PageUtil.initPage(pageVo));
return new ResultUtil<Page<Supplier>>().setData(users); return new ResultUtil<Page<Supplier>>().setData(users);
} }
@ -62,29 +65,29 @@ public class SupplierControlller {
* @return Result<List<Supplier>> * @return Result<List<Supplier>>
*/ */
@RequestMapping(value = "/getbyShopId", method = RequestMethod.POST) @RequestMapping(value = "/getbyShopId", method = RequestMethod.POST)
@ApiOperation(value = "获取当前店铺所有供应商") @ApiOperation("获取当前店铺所有供应商")
public Result<List<Supplier>> getbyShopId(String searchStr) { public Result<List<Supplier>> getbyShopId(String searchStr) {
// 从缓存中拿到店铺id // 从缓存中拿到店铺id
final String shopId = securityUtil.getShopId(); final String shopId = securityUtil.getShopId();
List<Supplier> suppliers = supplierService.getbyShopId(shopId,searchStr); final List<Supplier> suppliers = supplierService.getbyShopId(shopId,searchStr);
return new ResultUtil<List<Supplier>>().setData(suppliers); return new ResultUtil<List<Supplier>>().setData(suppliers);
} }
@RequestMapping(value = "/get/{id}", method = RequestMethod.GET) @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
@ApiOperation(value = "通过id获取") @ApiOperation("通过id获取")
public Result<Supplier> get(@PathVariable String id) { public Result<Supplier> get(@PathVariable String id) {
Supplier data = supplierService.findById(id); final Supplier data = supplierService.findById(id);
return new ResultUtil<Supplier>().setData(data); return new ResultUtil<Supplier>().setData(data);
} }
@RequestMapping(value = "/save", method = RequestMethod.POST) @RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(value = "保存数据") @ApiOperation("保存数据")
public Result<Supplier> save(Supplier entity) { public Result<Supplier> save(Supplier entity) {
// 从缓存中拿到店铺id // 从缓存中拿到店铺id
final String shopId = securityUtil.getShopId(); final String shopId = securityUtil.getShopId();
entity.setShopId(shopId); entity.setShopId(shopId);
entity.setDelFlag(CommonConstant.DEL_FLAG_FALSE); 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(); final BigDecimal noEarn = entity.getNoEarn() == null ? BigDecimal.ZERO : entity.getNoEarn();
@ -124,16 +127,16 @@ public class SupplierControlller {
} }
@RequestMapping(value = "/edit", method = RequestMethod.POST) @RequestMapping(value = "/edit", method = RequestMethod.POST)
@ApiOperation(value = "更新数据") @ApiOperation("更新数据")
public Result<Supplier> edit(Supplier entity) { public Result<Supplier> edit(Supplier entity) {
Supplier data = supplierService.findById(entity.getId()); final Supplier data = supplierService.findById(entity.getId());
data.setProvince(entity.getProvince()); data.setProvince(entity.getProvince());
data.setCity(entity.getCity()); data.setCity(entity.getCity());
data.setArea(entity.getArea()); data.setArea(entity.getArea());
data.setAddress(entity.getAddress()); data.setAddress(entity.getAddress());
data.setConsigneeName(entity.getConsigneeName()); data.setConsigneeName(entity.getConsigneeName());
data.setConsigneeMobile(entity.getConsigneeMobile()); data.setConsigneeMobile(entity.getConsigneeMobile());
Supplier supplier = supplierService.update(data); final Supplier supplier = supplierService.update(data);
return new ResultUtil<Supplier>().setData(supplier); return new ResultUtil<Supplier>().setData(supplier);
} }
@ -145,9 +148,10 @@ public class SupplierControlller {
* @return Result * @return Result
*/ */
@RequestMapping(value = "/delByIds", method = RequestMethod.POST) @RequestMapping(value = "/delByIds", method = RequestMethod.POST)
@ApiOperation(value = "批量通过ids删除") @ApiOperation("批量通过ids删除")
public Result delByIds(@RequestParam String[] ids) { public Result delByIds( String ids) {
for (String id : ids) { final String[] idsArray = ids.split(",");
for (String id : idsArray) {
supplierService.delById(id); supplierService.delById(id);
} }
return ResultUtil.success("批量通过id删除数据成功"); return ResultUtil.success("批量通过id删除数据成功");

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/CustomerMapper.java

@ -44,4 +44,6 @@ public interface CustomerMapper extends BaseMapper<Customer> {
Page<Customer> getCustomerList(Page<Customer> page,@Param("queryParams") CustomerPageQuery customerPageQuery); Page<Customer> getCustomerList(Page<Customer> page,@Param("queryParams") CustomerPageQuery customerPageQuery);
void updatePhone(@Param("newMobile")String newMobile,@Param("userId") String userId); void updatePhone(@Param("newMobile")String newMobile,@Param("userId") String userId);
boolean batchDeleteCustomer(@Param("idList") List<String> idList);
} }

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ProductMapper.java

@ -75,4 +75,6 @@ public interface ProductMapper extends BaseMapper<Product> {
* @date 2024/6/22 * @date 2024/6/22
*/ */
void batchUpdateDelFlag(@Param("idList") List<String> idList, @Param("delFlag") Integer delFlag); void batchUpdateDelFlag(@Param("idList") List<String> idList, @Param("delFlag") Integer delFlag);
void batchUpdatePurchasePrice(@Param("productList") List<Product> productList);
} }

10
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseDetailMapper.java

@ -44,4 +44,14 @@ public interface PurchaseDetailMapper extends BaseMapper<PurchaseDetail> {
void deleteByPurchaseId(@Param("purchaseId") String purchaseId); void deleteByPurchaseId(@Param("purchaseId") String purchaseId);
List<PurchaseDetail> getPurchaseDetails(@Param("purchaseIdList") List<String> purchaseIdList); List<PurchaseDetail> getPurchaseDetails(@Param("purchaseIdList") List<String> purchaseIdList);
/**
* 查询该商品除当前入库单的其他的入库记录
* @author 王富康
* @date 2024/7/27
* @param productIdList
* @param id
* @return List<PurchaseDetail>
*/
List<PurchaseDetail> getPurchaseDetailListByProductIds(@Param("productIdList") List<String> productIdList,@Param("id") String id);
} }

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ReturnDetailMapper.java

@ -49,4 +49,6 @@ public interface ReturnDetailMapper extends BaseMapper<ReturnDetail> {
List<ReturnDetail> getReturnDetailsByReturnId(@Param("returnSaleIdList") List<String> returnSaleIdList); List<ReturnDetail> getReturnDetailsByReturnId(@Param("returnSaleIdList") List<String> returnSaleIdList);
void putInUpdatePurchasePrice(@Param("purchaseDetails") List<PurchaseDetail> purchaseDetails); void putInUpdatePurchasePrice(@Param("purchaseDetails") List<PurchaseDetail> purchaseDetails);
void deleteBySaleId(@Param("saleId")String saleId);
} }

1
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ReturnSaleMapper.java

@ -81,4 +81,5 @@ public interface ReturnSaleMapper extends BaseMapper<ReturnSale> {
*/ */
Page<ReturnSaleVo> getReturnSaleListByUserId(Page<ReturnSaleVo> page, @Param("returnSalePageQuery") ReturnSalePageQuery returnSalePageQuery); Page<ReturnSaleVo> getReturnSaleListByUserId(Page<ReturnSaleVo> page, @Param("returnSalePageQuery") ReturnSalePageQuery returnSalePageQuery);
void deleteBySaleId(@Param("saleId") String saleId);
} }

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleDetailMapper.java

@ -43,4 +43,6 @@ public interface SaleDetailMapper extends BaseMapper<SaleDetail> {
void putInUpdatePurchasePrice(@Param("purchaseDetails") List<PurchaseDetail> purchaseDetails); void putInUpdatePurchasePrice(@Param("purchaseDetails") List<PurchaseDetail> purchaseDetails);
List<SaleDetail> getSaleDetails(@Param("saleIdList") List<String> saleIdList); List<SaleDetail> getSaleDetails(@Param("saleIdList") List<String> saleIdList);
List<SaleDetail> getSaleDetailListByProductIds(@Param("productIdList") List<String> productIdList);
} }

1
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java

@ -113,4 +113,5 @@ public interface SaleMapper extends BaseMapper<Sale> {
* @return Page<CustomerSaleDetailVo> * @return Page<CustomerSaleDetailVo>
*/ */
Page<CustomerSaleDetailVo> customerSaleDetail(Page<CustomerSaleDetailVo> page,@Param("salePageQuery") SalePageQuery salePageQuery); Page<CustomerSaleDetailVo> customerSaleDetail(Page<CustomerSaleDetailVo> page,@Param("salePageQuery") SalePageQuery salePageQuery);
} }

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockLogMapper.java

@ -43,4 +43,6 @@ public interface StockLogMapper extends BaseMapper<StockLog> {
void putInUpdatePurchasePrice(@Param("purchaseDetails") List<PurchaseDetail> purchaseDetails); void putInUpdatePurchasePrice(@Param("purchaseDetails") List<PurchaseDetail> purchaseDetails);
List<StockLog> getPurchaseDetails(@Param("purchaseIdList") List<String> purchaseIdList); List<StockLog> getPurchaseDetails(@Param("purchaseIdList") List<String> purchaseIdList);
List<StockLog> getByProductIds(@Param("purchaseId") String purchaseId,@Param("productIdList") List<String> productIdList);
} }

5
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.PurchaseDetail;
import cc.hiver.mall.entity.Stock; import cc.hiver.mall.entity.Stock;
import cc.hiver.mall.entity.StockExample; import cc.hiver.mall.entity.StockExample;
import cc.hiver.mall.entity.StockLog;
import cc.hiver.mall.pojo.query.StockPageQuery; import cc.hiver.mall.pojo.query.StockPageQuery;
import cc.hiver.mall.pojo.vo.ProductCategoryStockVo; import cc.hiver.mall.pojo.vo.ProductCategoryStockVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@ -51,4 +52,8 @@ public interface StockMapper extends BaseMapper<Stock> {
Stock getByProductIdAndAttributeList(@Param("productId") String productId, @Param("attributeList") String attributeList); Stock getByProductIdAndAttributeList(@Param("productId") String productId, @Param("attributeList") String attributeList);
List<Stock> getProductStockByAttrId(@Param("attrId") String attrId); List<Stock> getProductStockByAttrId(@Param("attrId") String attrId);
void batchDeleteStockByProductIds(@Param("productIdList") List<String> productIdList);
void batchReduceStockByLog(@Param("stockLogList") List<StockLog> stockLogList);
} }

3
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识别-实际识别的数量") @ApiModelProperty(value = "AI识别-实际识别的数量")
private Integer OcrCount; private Integer OcrCount;
@ApiModelProperty(value = "入库时间,20240727重新定义为入库单的创建时间,createTime为前台传递的入库单")
private Date purchaseTime;
public Date getStartDate() { public Date getStartDate() {
return startDate; return startDate;
} }

14
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; 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.entity.ProductPicture;
import cc.hiver.mall.productpicture.mapper.ProductPictureMapper; import cc.hiver.mall.productpicture.mapper.ProductPictureMapper;
import cc.hiver.mall.productpicture.service.ProductPictureService; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List; import java.util.List;
@Service @Service
@ -14,6 +18,9 @@ public class ProductPictureServiceImpl extends ServiceImpl<ProductPictureMapper,
@Autowired @Autowired
private ProductPictureMapper productPictureMapper; private ProductPictureMapper productPictureMapper;
@Autowired
private SecurityUtil securityUtil;
@Override @Override
public List<ProductPicture> getProductPictureByProductId(String productId) { public List<ProductPicture> getProductPictureByProductId(String productId) {
return productPictureMapper.getProductPictureByProductId(productId); return productPictureMapper.getProductPictureByProductId(productId);
@ -26,6 +33,13 @@ public class ProductPictureServiceImpl extends ServiceImpl<ProductPictureMapper,
@Override @Override
public void batchSaveProductPicture(List<ProductPicture> productPictures) { public void batchSaveProductPicture(List<ProductPicture> 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); productPictureMapper.batchSaveProductPicture(productPictures);
} }

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/CustomerService.java

@ -20,4 +20,6 @@ public interface CustomerService extends IService<Customer> {
Page<Customer> getCustomerList(CustomerPageQuery customerPageQuery); Page<Customer> getCustomerList(CustomerPageQuery customerPageQuery);
void updatePhone(String newMobile, String userId); void updatePhone(String newMobile, String userId);
boolean batchDeleteCustomer(String ids);
} }

11
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductService.java

@ -68,4 +68,15 @@ public interface ProductService extends IService<Product> {
* @date 2024/6/22 * @date 2024/6/22
*/ */
boolean batchDown(String ids); boolean batchDown(String ids);
/**
* 批量删除商品
* @author 王富康
* @date 2024/7/27
* @param ids
* @return boolean
*/
boolean batchDeleteProduct(String ids);
void batchUpdatePurchasePrice(List<Product> productList);
} }

10
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseDetailService.java

@ -22,4 +22,14 @@ public interface PurchaseDetailService extends IService<PurchaseDetail> {
void deleteByPurchaseId(String purchaseId); void deleteByPurchaseId(String purchaseId);
List<PurchaseDetail> getPurchaseDetails(List<String> purchaseIdList); List<PurchaseDetail> getPurchaseDetails(List<String> purchaseIdList);
/**
* 查询该商品除当前入库单的其他的入库记录
* @author 王富康
* @date 2024/7/27
* @param productIdList
* @param id
* @return List<PurchaseDetail>
*/
List<PurchaseDetail> getPurchaseDetailListByProductIds(List<String> productIdList, String id);
} }

22
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java

@ -43,16 +43,17 @@ public interface PurchaseService extends IService<Purchase> {
PurchaseVo getPurchaseAllDataOfAi(String id); PurchaseVo getPurchaseAllDataOfAi(String id);
void updateInStorageStatus(String id,int inStorageStatus); void updateInStorageStatus(String id, int inStorageStatus);
void deleteById(String id); void deleteById(String id);
/** /**
* 进货金额可查明细 * 进货金额可查明细
* @author 王富康 *
* @date 2024/6/29
* @param purchasePageQuery * @param purchasePageQuery
* @return List<PurchasingCostDetailVo> * @return List<PurchasingCostDetailVo>
* @author 王富康
* @date 2024/6/29
*/ */
Page<PurchasingCostDetailVo> purchasingCostDetail(PurchasePageQuery purchasePageQuery); Page<PurchasingCostDetailVo> purchasingCostDetail(PurchasePageQuery purchasePageQuery);
@ -60,10 +61,21 @@ public interface PurchaseService extends IService<Purchase> {
/** /**
* 获取从某个供应商的拿货入库记录(按入库单) * 获取从某个供应商的拿货入库记录(按入库单)
* @author 王富康 *
* @date 2024/7/24
* @param purchasePageQuery * @param purchasePageQuery
* @return Page<PurchaseVo> * @return Page<PurchaseVo>
* @author 王富康
* @date 2024/7/24
*/ */
Page<PurchaseVo> getPurchaseListOfSupplier(PurchasePageQuery purchasePageQuery); Page<PurchaseVo> getPurchaseListOfSupplier(PurchasePageQuery purchasePageQuery);
/**
* 撤销采购单
*
* @param id
* @author 王富康
* @date 2024/7/27
*/
void cancelPurchase(String id);
} }

1
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ReturnDetailService.java

@ -25,4 +25,5 @@ public interface ReturnDetailService extends IService<ReturnDetail> {
*/ */
List<ReturnDetail> getReturnDetailsByProductId(ReturnSalePageQuery returnSalePageQuery); List<ReturnDetail> getReturnDetailsByProductId(ReturnSalePageQuery returnSalePageQuery);
void deleteBySaleId(String saleId);
} }

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ReturnSaleService.java

@ -48,4 +48,6 @@ public interface ReturnSaleService extends IService<ReturnSale> {
* @date 2024/6/30 * @date 2024/6/30
*/ */
Page<ReturnSaleVo> getReturnSaleListByUserId(ReturnSalePageQuery returnSalePageQuery); Page<ReturnSaleVo> getReturnSaleListByUserId(ReturnSalePageQuery returnSalePageQuery);
void deleteBySaleId(String saleId);
} }

9
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleDetailService.java

@ -29,4 +29,13 @@ public interface SaleDetailService extends IService<SaleDetail> {
void putInUpdatePurchasePrice(List<PurchaseDetail> purchaseDetails); void putInUpdatePurchasePrice(List<PurchaseDetail> purchaseDetails);
List<SaleDetail> getSaleDetails(List<String> saleIdList); List<SaleDetail> getSaleDetails(List<String> saleIdList);
/**
* 根据商品id集合获取商品销售记录
* @author 王富康
* @date 2024/7/27
* @param productIdList
* @return List<SaleDetail>
*/
List<SaleDetail> getSaleDetailListByProductIds(List<String> productIdList);
} }

20
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.CustomerBillQueryVo;
import cc.hiver.mall.bill.vo.CustomerBillSaleVo; import cc.hiver.mall.bill.vo.CustomerBillSaleVo;
import cc.hiver.mall.entity.Sale; 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.SalePageQuery;
import cc.hiver.mall.pojo.query.SalesRankingQueryCriteria; import cc.hiver.mall.pojo.query.SalesRankingQueryCriteria;
import cc.hiver.mall.pojo.vo.*; import cc.hiver.mall.pojo.vo.*;
@ -101,19 +102,30 @@ public interface SaleService extends IService<Sale> {
/** /**
* 实收金额明细 * 实收金额明细
* @author 王富康 *
* @date 2024/6/29
* @param salePageQuery * @param salePageQuery
* @return List<TotalAlreadyEarnDetailDayVo> * @return List<TotalAlreadyEarnDetailDayVo>
* @author 王富康
* @date 2024/6/29
*/ */
Page<TotalAlreadyEarnDetailDayVo> totalAlreadyEarnDetail(SalePageQuery salePageQuery); Page<TotalAlreadyEarnDetailDayVo> totalAlreadyEarnDetail(SalePageQuery salePageQuery);
/** /**
* 客户拿货统计 * 客户拿货统计
* @author 王富康 *
* @date 2024/6/29
* @param salePageQuery * @param salePageQuery
* @return Page<CustomerSaleDetailVo> * @return Page<CustomerSaleDetailVo>
* @author 王富康
* @date 2024/6/29
*/ */
Page<CustomerSaleDetailVo> customerSaleDetail(SalePageQuery salePageQuery); Page<CustomerSaleDetailVo> customerSaleDetail(SalePageQuery salePageQuery);
/**
* 开单暂存为挂单
*
* @param saleQueryDTO
* @author 王富康
* @date 2024/7/26
*/
void temporarySaveSale(SaleQueryDTO saleQueryDTO);
} }

10
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockLogService.java

@ -15,4 +15,14 @@ public interface StockLogService extends IService<StockLog> {
void deleteByPurchaseId(String purchaseId); void deleteByPurchaseId(String purchaseId);
List<StockLog> getPurchaseDetails(List<String> purchaseIdList); List<StockLog> getPurchaseDetails(List<String> purchaseIdList);
/**
* 请详细描述方法
* @author 王富康
* @date 2024/7/27
* @param purchaseId
* @param productIds 逗号分隔的商品id
* @return List<StockLog>
*/
List<StockLog> getByProductIds(String purchaseId, String productIds);
} }

17
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.core.common.vo.Result;
import cc.hiver.mall.entity.Stock; import cc.hiver.mall.entity.Stock;
import cc.hiver.mall.entity.StockLog;
import cc.hiver.mall.pojo.query.StockPageQuery; import cc.hiver.mall.pojo.query.StockPageQuery;
import cc.hiver.mall.pojo.vo.ProductCategoryStockVo; import cc.hiver.mall.pojo.vo.ProductCategoryStockVo;
import cc.hiver.mall.pojo.vo.PurchaseVo; import cc.hiver.mall.pojo.vo.PurchaseVo;
@ -70,4 +71,20 @@ public interface StockService extends IService<Stock> {
* @return List<Stock> * @return List<Stock>
*/ */
List<Stock> getProductStockByAttrId(String attrId); List<Stock> 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<StockLog> stockLogList);
} }

55
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); sale.setCompanyPhone(transCompanyPhone);
} }
} }
// 如果是自送,状态为完成,其他使用平台的则为待取货 // 开单暂存位挂单不需要处理订单状态
if (SaleConstant.TRANSPORT_TYPE[2].equals(sale.getTransportType())) { if(!SaleConstant.SALE_STATUS[12].equals(sale.getStatus())){
sale.setStatus(SaleConstant.SALE_STATUS[4]);
// 自送如果选择了物流公司,也需要物流公司返佣 // 如果是自送,状态为完成,其他使用平台的则为待取货
// 选择物流公司才返佣,否则是没有选择物流公司的自提 if (SaleConstant.TRANSPORT_TYPE[2].equals(sale.getTransportType())) {
if (StringUtils.isNotEmpty(sale.getTransCompany())) { sale.setStatus(SaleConstant.SALE_STATUS[4]);
deductLogService.updateRebateAmount("", sale.getTransCompany(), sale.getShopId(), sale.getId(), sale.getTransportType()); // 自送如果选择了物流公司,也需要物流公司返佣
} // 选择物流公司才返佣,否则是没有选择物流公司的自提
} else if (SaleConstant.MODE_OF_SERVICE[2].equals(sale.getModeOfService())) { if (StringUtils.isNotEmpty(sale.getTransCompany())) {
// 物流自提 deductLogService.updateRebateAmount("", sale.getTransCompany(), sale.getShopId(), sale.getId(), sale.getTransportType());
sale.setStatus(SaleConstant.SALE_STATUS[13]); }
// 给物流公司发送一个短信 } else if (SaleConstant.MODE_OF_SERVICE[2].equals(sale.getModeOfService())) {
// shopId从缓存中设置 // 物流自提
final String shopId = securityUtil.getShopId(); sale.setStatus(SaleConstant.SALE_STATUS[13]);
final Shop shop = shopService.get(shopId); // 给物流公司发送一个短信
final String shopAddress = shop.getShopAddress(); // shopId从缓存中设置
smsUtil.sendSms(transCompanyPhone, "{\"shopAddress\":\"" + shopAddress + "\"}", "SMS_465354371"); final String shopId = securityUtil.getShopId();
} else { final Shop shop = shopService.get(shopId);
//0:待抢单 1:待取货 2:已作废 3:待送达 4:已完成 final String shopAddress = shop.getShopAddress();
//退货: smsUtil.sendSms(transCompanyPhone, "{\"shopAddress\":\"" + shopAddress + "\"}", "SMS_465354371");
//5:下游客户待退货 00:退货待抢单 01:退货待取货 02:退货已作废 03:退货待送达 04:待确认退货 4:已完成
if (StringUtils.isNotEmpty(saleDTO.getOrderByWorker())) {
// 指定了拉包工,直接为待取货
sale.setStatus(SaleConstant.SALE_STATUS[1]);
} else { } 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(); final User user = securityUtil.getCurrUser();
sale.setCreateByPhone(user.getMobile()); sale.setCreateByPhone(user.getMobile());

8
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 org.springframework.util.ObjectUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -204,4 +205,11 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
public void updatePhone(String newMobile, String userId) { public void updatePhone(String newMobile, String userId) {
customerMapper.updatePhone(newMobile, userId); customerMapper.updatePhone(newMobile, userId);
} }
@Override
public boolean batchDeleteCustomer(String ids) {
// ids 逗号分隔,然后转为list
final List<String> idList = Arrays.asList(ids.split(","));
return customerMapper.batchDeleteCustomer(idList);
}
} }

52
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.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -28,6 +29,7 @@ import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
@Service @Service
@Slf4j
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService { public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {
@Autowired @Autowired
@ -46,6 +48,29 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
public IPage<ProductPageVO> getShareList(ProductPageQuery productPageQuery) { public IPage<ProductPageVO> getShareList(ProductPageQuery productPageQuery) {
final Page<ProductPageVO> page = new Page<>(productPageQuery.getPageNum(), productPageQuery.getPageSize()); final Page<ProductPageVO> page = new Page<>(productPageQuery.getPageNum(), productPageQuery.getPageSize());
final List<ProductPageVO> list = baseMapper.getShareList(page, productPageQuery); final List<ProductPageVO> list = baseMapper.getShareList(page, productPageQuery);
// 获取商品子图
List<String> productIdList = new ArrayList<>();
for (ProductPageVO productPageVO : list) {
productIdList.add(productPageVO.getId());
}
// 获取子图
List<ProductPicture> productPictureByProductIds = productPictureService.getProductPictureByProductIds(productIdList);
Map<String, List<ProductPicture>> productPictureMap = new HashMap<>();
for (ProductPicture productPictureByProductId : productPictureByProductIds) {
if (productPictureMap.containsKey(productPictureByProductId.getProductId())) {
productPictureMap.get(productPictureByProductId.getProductId()).add(productPictureByProductId);
} else {
final List<ProductPicture> 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); page.setRecords(list);
return page; return page;
} }
@ -275,7 +300,34 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
productMapper.batchUpdateDelFlag(idList, ProductConstant.DEL_FLAG[0]); productMapper.batchUpdateDelFlag(idList, ProductConstant.DEL_FLAG[0]);
return true; return true;
} catch (Exception e) { } catch (Exception e) {
log.error("批量下架货品失败", e);
return false; return false;
} }
} }
/**
* 根据货品id批量删除货品
*
* @param ids
* @return boolean
* @author 王富康
* @date 2024/6/22
*/
@Override
public boolean batchDeleteProduct(String ids) {
// ids 逗号分隔转为list
try {
final List<String> 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<Product> productList) {
productMapper.batchUpdatePurchasePrice(productList);
}
} }

13
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseDetailServiceImpl.java

@ -86,4 +86,17 @@ public class PurchaseDetailServiceImpl extends ServiceImpl<PurchaseDetailMapper,
public List<PurchaseDetail> getPurchaseDetails(List<String> purchaseIdList) { public List<PurchaseDetail> getPurchaseDetails(List<String> purchaseIdList) {
return purchaseDetailMapper.getPurchaseDetails(purchaseIdList); return purchaseDetailMapper.getPurchaseDetails(purchaseIdList);
} }
/**
* 查询该商品除当前入库单的其他的入库记录
* @author 王富康
* @date 2024/7/27
* @param productIdList
* @param id
* @return List<PurchaseDetail>
*/
@Override
public List<PurchaseDetail> getPurchaseDetailListByProductIds(List<String> productIdList, String id) {
return purchaseDetailMapper.getPurchaseDetailListByProductIds(productIdList, id);
}
} }

184
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.ArrearsVo;
import cc.hiver.mall.bill.vo.SupplierBillQueryVo; import cc.hiver.mall.bill.vo.SupplierBillQueryVo;
import cc.hiver.mall.dao.mapper.PurchaseMapper; 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.entity.*;
import cc.hiver.mall.pojo.dto.DebtSupplier; import cc.hiver.mall.pojo.dto.DebtSupplier;
import cc.hiver.mall.pojo.query.PurchasePageQuery; 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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
@ -40,6 +43,9 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
@Autowired @Autowired
private PurchaseDetailService purchaseDetailService; private PurchaseDetailService purchaseDetailService;
@Autowired
private StockService stockService;
@Autowired @Autowired
private StockLogService stockLogService; private StockLogService stockLogService;
@ -61,6 +67,15 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
@Autowired @Autowired
private ProductService productService; private ProductService productService;
@Autowired
private SaleService saleService;
@Autowired
private SaleDetailService saleDetailService;
@Autowired
private DebtService debtService;
@Override @Override
public Page<DebtSupplier> getDebtByShopId(PurchasePageQuery purchasePageQuery) { public Page<DebtSupplier> getDebtByShopId(PurchasePageQuery purchasePageQuery) {
@ -499,10 +514,11 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
/** /**
* 获取从某个供应商的拿货入库记录(按入库单) * 获取从某个供应商的拿货入库记录(按入库单)
* @author 王富康 *
* @date 2024/7/24
* @param purchasePageQuery * @param purchasePageQuery
* @return Page<PurchaseVo> * @return Page<PurchaseVo>
* @author 王富康
* @date 2024/7/24
*/ */
@Override @Override
public Page<PurchaseVo> getPurchaseListOfSupplier(PurchasePageQuery purchasePageQuery) { public Page<PurchaseVo> getPurchaseListOfSupplier(PurchasePageQuery purchasePageQuery) {
@ -608,4 +624,168 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
} }
return purchaseVos; 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<String> purchaseIdList = new ArrayList<>();
purchaseIdList.add(id);
// 3. 商品及库存回退
// 查询商品是有有销售记录并且是不是有且只有这一次入库记录,是的话,直接删除商品及其库存信息,其他的只回退库存即可
final List<PurchaseDetail> byPurchaseIdList = purchaseDetailService.getByPurchaseIdList(purchaseIdList, "");
// 拿到商品id集合
final List<String> productIdList = new ArrayList<>();
for (PurchaseDetail purchaseDetail : byPurchaseIdList) {
productIdList.add(purchaseDetail.getProductId());
}
// 查询该商品除当前入库单的其他的入库记录
final List<PurchaseDetail> purductPurchaseList = purchaseDetailService.getPurchaseDetailListByProductIds(productIdList, id);
// 封装为商品id为key,List<PurchaseDetail>为value 的map
final Map<String, List<PurchaseDetail>> purductPurchaseMap = new HashMap<>();
for (PurchaseDetail purchaseDetail : purductPurchaseList) {
final String productId = purchaseDetail.getProductId();
if (purductPurchaseMap.containsKey(productId)) {
purductPurchaseMap.get(productId).add(purchaseDetail);
} else {
final List<PurchaseDetail> purchaseDetails = new ArrayList<>();
purchaseDetails.add(purchaseDetail);
purductPurchaseMap.put(productId, purchaseDetails);
}
}
// 查询该商品的销售记录
final List<SaleDetail> purductSaleList = saleDetailService.getSaleDetailListByProductIds(productIdList);
// 封装为商品id为key,List<SaleDetail>为value 的map
final Map<String, List<SaleDetail>> purductSaleMap = new HashMap<>();
for (SaleDetail saleDetail : purductSaleList) {
final String productId = saleDetail.getProductId();
if (purductSaleMap.containsKey(productId)) {
purductSaleMap.get(productId).add(saleDetail);
} else {
final List<SaleDetail> 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<StockLog> stockLogList = stockLogService.getByProductIds(id, needReduceStockProductId.toString());
// 根据入库记录减掉库存数
stockService.batchReduceStockByLog(stockLogList);
}
// 4. 根据采购单id删除库存记录
stockLogService.deleteByPurchaseId(id);
// 5. 计算平均采购价
// 获取该商品的历次入库记录,排除掉本次入库记录 入库的价格*入库数量/入库总数量
Map<String , BigDecimal> productPurchasePriceMap = new HashMap<>();
List<Product> productList = new ArrayList<>();
for (Map.Entry<String, List<PurchaseDetail>> stringListEntry : purductPurchaseMap.entrySet()) {
final String productId = stringListEntry.getKey();
List<PurchaseDetail> 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);
}
} }

5
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ReturnDetailServiceImpl.java

@ -46,4 +46,9 @@ public class ReturnDetailServiceImpl extends ServiceImpl<ReturnDetailMapper, Ret
public List<ReturnDetail> getReturnDetailsByProductId(ReturnSalePageQuery returnSalePageQuery) { public List<ReturnDetail> getReturnDetailsByProductId(ReturnSalePageQuery returnSalePageQuery) {
return returnDetailMapper.getReturnDetailsByProductId(returnSalePageQuery); return returnDetailMapper.getReturnDetailsByProductId(returnSalePageQuery);
} }
@Override
public void deleteBySaleId(String saleId) {
returnDetailMapper.deleteBySaleId(saleId);
}
} }

5
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ReturnSaleServiceImpl.java

@ -218,4 +218,9 @@ public class ReturnSaleServiceImpl extends ServiceImpl<ReturnSaleMapper, ReturnS
return returnSalePage; return returnSalePage;
} }
@Override
public void deleteBySaleId(String saleId) {
returnSaleMapper.deleteBySaleId(saleId);
}
} }

5
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleDetailServiceImpl.java

@ -76,4 +76,9 @@ public class SaleDetailServiceImpl extends ServiceImpl<SaleDetailMapper, SaleDet
public List<SaleDetail> getSaleDetails(List<String> saleIdList) { public List<SaleDetail> getSaleDetails(List<String> saleIdList) {
return saleDetailMapper.getSaleDetails(saleIdList); return saleDetailMapper.getSaleDetails(saleIdList);
} }
@Override
public List<SaleDetail> getSaleDetailListByProductIds(List<String> productIdList) {
return saleDetailMapper.getSaleDetailListByProductIds(productIdList);
}
} }

124
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.debt.service.DebtService;
import cc.hiver.mall.deductlog.service.DeductLogService; import cc.hiver.mall.deductlog.service.DeductLogService;
import cc.hiver.mall.entity.*; import cc.hiver.mall.entity.*;
import cc.hiver.mall.pojo.dto.SaleDetailDTO; import cc.hiver.mall.pojo.dto.*;
import cc.hiver.mall.pojo.dto.SaleDetailQueryDTO;
import cc.hiver.mall.pojo.query.SalePageQuery; import cc.hiver.mall.pojo.query.SalePageQuery;
import cc.hiver.mall.pojo.query.SalesRankingQueryCriteria; import cc.hiver.mall.pojo.query.SalesRankingQueryCriteria;
import cc.hiver.mall.pojo.vo.*; 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.entity.SaleAiMsg;
import cc.hiver.mall.saleaimsg.service.SaleAiMsgService; import cc.hiver.mall.saleaimsg.service.SaleAiMsgService;
import cc.hiver.mall.service.OrderService; import cc.hiver.mall.service.OrderService;
import cc.hiver.mall.service.SalesAndDetailsService;
import cc.hiver.mall.service.SendMessageService; import cc.hiver.mall.service.SendMessageService;
import cc.hiver.mall.service.ShopService;
import cc.hiver.mall.service.mybatis.*; import cc.hiver.mall.service.mybatis.*;
import cc.hiver.mall.utils.AliOcrUtil; import cc.hiver.mall.utils.AliOcrUtil;
import cc.hiver.mall.utils.DateUtil; import cc.hiver.mall.utils.DateUtil;
@ -111,6 +112,15 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
@Autowired @Autowired
private SendMessageService sendMessageService; private SendMessageService sendMessageService;
@Autowired
private ShopService shopService;
@Autowired
private SalesAndDetailsService salesAndDetailsService;
@Autowired
private ReturnDetailService returnDetailService;
@Override @Override
public void editPayPrice(String id, BigDecimal price, String dealingsWay) { public void editPayPrice(String id, BigDecimal price, String dealingsWay) {
// 修改采购单、实付、未付金额 // 修改采购单、实付、未付金额
@ -351,7 +361,7 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
*/ */
@Override @Override
public List<SalesRankingVo> getSalesRankingByShopId(SalesRankingQueryCriteria salesRankingQueryCriteria) { public List<SalesRankingVo> getSalesRankingByShopId(SalesRankingQueryCriteria salesRankingQueryCriteria) {
if(StringUtils.isNotEmpty(salesRankingQueryCriteria.getEndTime())){ if (StringUtils.isNotEmpty(salesRankingQueryCriteria.getEndTime())) {
salesRankingQueryCriteria.setEndTime(DateUtil.addDay(salesRankingQueryCriteria.getEndTime(), 1)); salesRankingQueryCriteria.setEndTime(DateUtil.addDay(salesRankingQueryCriteria.getEndTime(), 1));
} }
return saleMapper.getSalesRankingByShopId(salesRankingQueryCriteria); return saleMapper.getSalesRankingByShopId(salesRankingQueryCriteria);
@ -391,7 +401,7 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
} }
if (!productIds.isEmpty()) { if (!productIds.isEmpty()) {
// 获取商品各规格售卖的数量 // 获取商品各规格售卖的数量
final List<CustomerBuyProductDetailLogVo> customerBuyProductDetailLogVos = saleMapper.getCustomerBuyProductLogDetailLog(userId, salePageQuery.getShopId(), productIds,salePageQuery.getStartDate(),salePageQuery.getEndDate()); final List<CustomerBuyProductDetailLogVo> customerBuyProductDetailLogVos = saleMapper.getCustomerBuyProductLogDetailLog(userId, salePageQuery.getShopId(), productIds, salePageQuery.getStartDate(), salePageQuery.getEndDate());
// 进行数据封装Map<商品id,Map<销售单id,商品明细>> // 进行数据封装Map<商品id,Map<销售单id,商品明细>>
final Map<String, Map<String, List<CustomerBuyProductDetailLogVo>>> allMap = new HashMap<>(); final Map<String, Map<String, List<CustomerBuyProductDetailLogVo>>> allMap = new HashMap<>();
@ -924,7 +934,7 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
// 4. 订单款项记录作废 // 4. 订单款项记录作废
// 根据订单获取交易记录 // 根据订单获取交易记录
final String userId = sale.getUserId(); final String userId = sale.getUserId();
final Debt oldDebt = debtService.selectByUserId(sale.getShopId(),userId); final Debt oldDebt = debtService.selectByUserId(sale.getShopId(), userId);
if (oldDebt != null) { if (oldDebt != null) {
final BigDecimal newDebtAmount; final BigDecimal newDebtAmount;
final BigDecimal lastDebtAmount = oldDebt.getAmountOwed(); final BigDecimal lastDebtAmount = oldDebt.getAmountOwed();
@ -965,7 +975,7 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
dealingsRecordService.cancelRecord(id); dealingsRecordService.cancelRecord(id);
// 如果有配送单,那么就取消配送,并给快递员发送消息 // 如果有配送单,那么就取消配送,并给快递员发送消息
final OrderXd orderXd = orderService.findByOrderId(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())) { if (StringUtils.isNotEmpty(orderXd.getOrderByWorker())) {
// 如果订单被抢单了,那么需要给配送员发送消息 // 如果订单被抢单了,那么需要给配送员发送消息
sendMessageService.handleSendAppMessageOfQuxiao(orderXd.getOrderByWorker()); sendMessageService.handleSendAppMessageOfQuxiao(orderXd.getOrderByWorker());
@ -1006,10 +1016,11 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
/** /**
* 实收金额明细 * 实收金额明细
* @author 王富康 *
* @date 2024/6/29
* @param salePageQuery * @param salePageQuery
* @return List<TotalAlreadyEarnDetailDayVo> * @return List<TotalAlreadyEarnDetailDayVo>
* @author 王富康
* @date 2024/6/29
*/ */
@Override @Override
public Page<TotalAlreadyEarnDetailDayVo> totalAlreadyEarnDetail(SalePageQuery salePageQuery) { public Page<TotalAlreadyEarnDetailDayVo> totalAlreadyEarnDetail(SalePageQuery salePageQuery) {
@ -1027,10 +1038,11 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
/** /**
* 客户拿货统计 * 客户拿货统计
* @author 王富康 *
* @date 2024/6/29
* @param salePageQuery * @param salePageQuery
* @return Page<CustomerSaleDetailVo> * @return Page<CustomerSaleDetailVo>
* @author 王富康
* @date 2024/6/29
*/ */
@Override @Override
public Page<CustomerSaleDetailVo> customerSaleDetail(SalePageQuery salePageQuery) { public Page<CustomerSaleDetailVo> customerSaleDetail(SalePageQuery salePageQuery) {
@ -1046,6 +1058,98 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
return saleMapper.customerSaleDetail(page, salePageQuery); 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<String> returnSaleId = new ArrayList<>();
returnSaleId.add(returnSale.getId());
final List<ReturnDetail> returnDetails = returnDetailService.getReturnDetailsByReturnId(returnSaleId);
final List<ReturnSaleDetailDTO> 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<SaleDetailQueryDTO> 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字符 * 使用正则表达式替换输入字符串中连续的字符为相应数量的X字符
* *

19
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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List; import java.util.List;
@Service @Service
@ -21,7 +22,7 @@ public class StockLogServiceImpl extends ServiceImpl<StockLogMapper, StockLog> i
} }
@Override @Override
public List<StockLog> getByPurchaseIds(List<String> purchaseIds,String productId) { public List<StockLog> getByPurchaseIds(List<String> purchaseIds, String productId) {
return stockLogMapper.getByPurchaseIds(purchaseIds, productId); return stockLogMapper.getByPurchaseIds(purchaseIds, productId);
} }
@ -40,4 +41,20 @@ public class StockLogServiceImpl extends ServiceImpl<StockLogMapper, StockLog> i
return stockLogMapper.getPurchaseDetails(purchaseIdList); return stockLogMapper.getPurchaseDetails(purchaseIdList);
} }
/**
* 霍如入库单中某些商品的规格信息
*
* @param purchaseId
* @param productIds
* @return List<StockLog>
* @author 王富康
* @date 2024/7/27
*/
@Override
public List<StockLog> getByProductIds(String purchaseId, String productIds) {
final String[] split = productIds.split(",");
final List<String> productIdList = Arrays.asList(split);
return stockLogMapper.getByProductIds(purchaseId, productIdList);
}
} }

49
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java

@ -1,5 +1,6 @@
package cc.hiver.mall.serviceimpl.mybatis; 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.ProductConstant;
import cc.hiver.core.common.utils.ResultUtil; import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.utils.SecurityUtil; 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.entity.ProductPicture;
import cc.hiver.mall.productpicture.service.ProductPictureService; import cc.hiver.mall.productpicture.service.ProductPictureService;
import cc.hiver.mall.service.mybatis.*; import cc.hiver.mall.service.mybatis.*;
import cc.hiver.mall.utils.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -380,6 +382,22 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
final Purchase purchase = purchaseService.getById(id); final Purchase purchase = purchaseService.getById(id);
purchase.setUpdateTime(new Date()); purchase.setUpdateTime(new Date());
purchase.setUpdateBy(user.getId()); 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.setTotalAmount(putInPurchase.getTotalAmount());
purchase.setShouldPay(putInPurchase.getShouldPay()); purchase.setShouldPay(putInPurchase.getShouldPay());
purchase.setAlreadyPay(putInPurchase.getAlreadyPay()); purchase.setAlreadyPay(putInPurchase.getAlreadyPay());
@ -508,6 +526,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
stock.setProductIntro(purchaseDetail.getProductIntro()); stock.setProductIntro(purchaseDetail.getProductIntro());
stock.setSalesWeek(purchaseDetail.getSalesWeek()); stock.setSalesWeek(purchaseDetail.getSalesWeek());
stock.setStockCount(stockLog.getProductCount()); stock.setStockCount(stockLog.getProductCount());
stock.setDelFlag(CommonConstant.DEL_FLAG_FALSE);
// 实时更新库存信息 // 实时更新库存信息
stockService.save(stock); stockService.save(stock);
} }
@ -687,6 +706,23 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
final Purchase purchase = purchaseVo.getPurchase(); final Purchase purchase = purchaseVo.getPurchase();
purchase.setCreateByName(user.getNickname()); purchase.setCreateByName(user.getNickname());
purchase.setShopId(shopId); 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 // 语音入库没有入库id
String purchaseId = purchase.getId(); String purchaseId = purchase.getId();
if (StringUtils.isEmpty(purchaseId)){ if (StringUtils.isEmpty(purchaseId)){
@ -965,6 +1001,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
stock.setSalesWeek(purchaseDetail.getSalesWeek()); stock.setSalesWeek(purchaseDetail.getSalesWeek());
stock.setStockCount(stockLog.getProductCount()); stock.setStockCount(stockLog.getProductCount());
stock.setPurchasePrice(purchaseDetail.getPurchasePrice()); stock.setPurchasePrice(purchaseDetail.getPurchasePrice());
stock.setDelFlag(CommonConstant.DEL_FLAG_FALSE);
stockService.save(stock); stockService.save(stock);
} }
} }
@ -1113,4 +1150,16 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
public List<Stock> getProductStockByAttrId(String attrId) { public List<Stock> getProductStockByAttrId(String attrId) {
return stockMapper.getProductStockByAttrId(attrId); return stockMapper.getProductStockByAttrId(attrId);
} }
@Override
public void batchDeleteStockByProductIds(String productIds) {
// 根据逗号拆分为List
final List<String> productIdList = Arrays.asList(productIds.split(","));
stockMapper.batchDeleteStockByProductIds(productIdList);
}
@Override
public void batchReduceStockByLog(List<StockLog> stockLogList) {
stockMapper.batchReduceStockByLog(stockLogList);
}
} }

33
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/utils/DateUtil.java

@ -385,5 +385,38 @@ public class DateUtil {
} }
return ""; 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;
}
} }

9
hiver-modules/hiver-mall/src/main/resources/mapper/CustomerMapper.xml

@ -441,4 +441,13 @@
set phone = #{newMobile,jdbcType=VARCHAR} set phone = #{newMobile,jdbcType=VARCHAR}
where user_id = #{userId,jdbcType=VARCHAR} where user_id = #{userId,jdbcType=VARCHAR}
</update> </update>
<update id="batchDeleteCustomer">
update t_customer
set del_flag = '1'
where id in
<foreach close=")" collection="idList" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</update>
</mapper> </mapper>

6
hiver-modules/hiver-mall/src/main/resources/mapper/ProductMapper.xml

@ -756,4 +756,10 @@
#{listItem} #{listItem}
</foreach> </foreach>
</update> </update>
<update id="batchUpdatePurchasePrice" >
<foreach collection="productList" item="item" separator=";" open="" close="">
update t_product set purchase_price = #{item.purchasePrice} WHERE id = #{item.id}
</foreach>
</update>
</mapper> </mapper>

12
hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml

@ -641,4 +641,16 @@
#{listItem} #{listItem}
</foreach> </foreach>
</select> </select>
<select id="getPurchaseDetailListByProductIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_purchase_detail
where purchase_id != #{id,jdbcType=VARCHAR}
and del_flag = '0'
and product_id in
<foreach close=")" collection="productIdList" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</select>
</mapper> </mapper>

23
hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml

@ -20,6 +20,7 @@
<result column="in_storage_status" jdbcType="INTEGER" property="inStorageStatus" /> <result column="in_storage_status" jdbcType="INTEGER" property="inStorageStatus" />
<result column="remark" jdbcType="VARCHAR" property="remark" /> <result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="balance_deduction_amount" jdbcType="DECIMAL" property="balanceDeductionAmount" /> <result column="balance_deduction_amount" jdbcType="DECIMAL" property="balanceDeductionAmount" />
<result column="purchase_time" jdbcType="TIMESTAMP" property="purchaseTime" />
</resultMap> </resultMap>
<resultMap id="DebtResultMap" type="cc.hiver.mall.pojo.dto.DebtSupplier"> <resultMap id="DebtResultMap" type="cc.hiver.mall.pojo.dto.DebtSupplier">
@ -88,7 +89,8 @@
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, create_by,create_by_name, create_time, del_flag, update_by, update_time, supplier_id,supplier_name, shop_id, 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
</sql> </sql>
<select id="selectByExample" parameterType="cc.hiver.mall.entity.PurchaseExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="cc.hiver.mall.entity.PurchaseExample" resultMap="BaseResultMap">
select select
@ -124,13 +126,13 @@
insert into t_purchase (id, create_by, create_by_name, create_time, insert into t_purchase (id, create_by, create_by_name, create_time,
del_flag, update_by, update_time, del_flag, update_by, update_time,
supplier_id,supplier_name, shop_id, total_amount, supplier_id,supplier_name, shop_id, total_amount,
should_pay, already_pay, no_pay,other_pay, in_storage_status,remark, balance_deduction_amount should_pay, already_pay, no_pay,other_pay, in_storage_status,remark, balance_deduction_amount,purchase_time
) )
values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createByName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createByName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
#{supplierId,jdbcType=VARCHAR},#{supplierName,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR}, #{totalAmount,jdbcType=DECIMAL}, #{supplierId,jdbcType=VARCHAR},#{supplierName,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR}, #{totalAmount,jdbcType=DECIMAL},
#{shouldPay,jdbcType=DECIMAL}, #{alreadyPay,jdbcType=DECIMAL}, #{noPay,jdbcType=DECIMAL}, #{otherPay,jdbcType=DECIMAL}, #{inStorageStatus,jdbcType=INTEGER}, #{shouldPay,jdbcType=DECIMAL}, #{alreadyPay,jdbcType=DECIMAL}, #{noPay,jdbcType=DECIMAL}, #{otherPay,jdbcType=DECIMAL}, #{inStorageStatus,jdbcType=INTEGER},
#{remark,jdbcType=VARCHAR}, #{balanceDeductionAmount,jdbcType=DECIMAL} #{remark,jdbcType=VARCHAR}, #{balanceDeductionAmount,jdbcType=DECIMAL},#{purchaseTime,jdbcType=TIMESTAMP}
) )
</insert> </insert>
<insert id="insertSelective" parameterType="cc.hiver.mall.entity.Purchase"> <insert id="insertSelective" parameterType="cc.hiver.mall.entity.Purchase">
@ -190,6 +192,9 @@
<if test="balanceDeductionAmount != null"> <if test="balanceDeductionAmount != null">
balance_deduction_amount, balance_deduction_amount,
</if> </if>
<if test="purchaseTime != null">
purchase_time,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
@ -299,6 +304,9 @@
<if test="record.balanceDeductionAmount != null"> <if test="record.balanceDeductionAmount != null">
balance_deduction_amount = #{record.balanceDeductionAmount,jdbcType=DECIMAL}, balance_deduction_amount = #{record.balanceDeductionAmount,jdbcType=DECIMAL},
</if> </if>
<if test="record.purchaseTime != null">
purchase_time = #{record.purchaseTime,jdbcType=TIMESTAMP},
</if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
@ -323,7 +331,8 @@
other_pay = #{record.otherPay,jdbcType=DECIMAL}, other_pay = #{record.otherPay,jdbcType=DECIMAL},
in_storage_status = #{record.inStorageStatus,jdbcType=INTEGER}, in_storage_status = #{record.inStorageStatus,jdbcType=INTEGER},
remark = #{record.remark,jdbcType=VARCHAR}, remark = #{record.remark,jdbcType=VARCHAR},
balance_deduction_amount = #{record.balanceDeductionAmount,jdbcType=DECIMAL} balance_deduction_amount = #{record.balanceDeductionAmount,jdbcType=DECIMAL},
purchase_time = #{record.purchaseTime,jdbcType=TIMESTAMP}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -382,6 +391,9 @@
<if test="balanceDeductionAmount != null"> <if test="balanceDeductionAmount != null">
balance_deduction_amount = #{balanceDeductionAmount,jdbcType=DECIMAL}, balance_deduction_amount = #{balanceDeductionAmount,jdbcType=DECIMAL},
</if> </if>
<if test="purchaseTime != null">
purchase_time = #{purchaseTime,jdbcType=TIMESTAMP},
</if>
</set> </set>
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
@ -403,7 +415,8 @@
other_pay = #{otherPay,jdbcType=DECIMAL}, other_pay = #{otherPay,jdbcType=DECIMAL},
in_storage_status = #{inStorageStatus,jdbcType=INTEGER}, in_storage_status = #{inStorageStatus,jdbcType=INTEGER},
remark = #{remark,jdbcType=INTEGER}, remark = #{remark,jdbcType=INTEGER},
balance_deduction_amount = #{balanceDeductionAmount,jdbcType=DECIMAL} balance_deduction_amount = #{balanceDeductionAmount,jdbcType=DECIMAL},
purchase_time = #{purchaseTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>

6
hiver-modules/hiver-mall/src/main/resources/mapper/ReturnDetailMapper.xml

@ -544,4 +544,10 @@
update t_return_detail set purchase_price = #{item.purchasePrice} WHERE product_id = #{item.productId} and purchase_price is null update t_return_detail set purchase_price = #{item.purchasePrice} WHERE product_id = #{item.productId} and purchase_price is null
</foreach> </foreach>
</update> </update>
<!--根据销售单id 删除之前所有商品信息-->
<delete id="deleteBySaleId" parameterType="java.lang.String">
delete from t_return_detail
where sale_id = #{saleId,jdbcType=VARCHAR}
</delete>
</mapper> </mapper>

6
hiver-modules/hiver-mall/src/main/resources/mapper/ReturnSaleMapper.xml

@ -689,5 +689,9 @@
order by order by
trs.create_time desc trs.create_time desc
</select> </select>
<!--根据销售单id 删除之前所有商品信息-->
<delete id="deleteBySaleId" parameterType="java.lang.String">
delete from t_return_sale
where sale_id = #{saleId,jdbcType=VARCHAR}
</delete>
</mapper> </mapper>

11
hiver-modules/hiver-mall/src/main/resources/mapper/SaleDetailMapper.xml

@ -522,4 +522,15 @@
#{listItem} #{listItem}
</foreach> </foreach>
</select> </select>
<select id="getSaleDetailListByProductIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_sale_detail
where del_flag = '0'
and product_id in
<foreach close=")" collection="productIdList" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</select>
</mapper> </mapper>

11
hiver-modules/hiver-mall/src/main/resources/mapper/StockLogMapper.xml

@ -468,4 +468,15 @@
#{listItem} #{listItem}
</foreach> </foreach>
</select> </select>
<select id="getByProductIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_stock_log
where order_id = #{purchaseId,jdbcType=VARCHAR}
and product_id in
<foreach close=")" collection="productIdList" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</select>
</mapper> </mapper>

15
hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml

@ -671,4 +671,19 @@
t_stock s t_stock s
where s.product_id = (select id from t_product where attr_id = #{attrId}) where s.product_id = (select id from t_product where attr_id = #{attrId})
</select> </select>
<update id="batchDeleteStockByProductIds" >
update t_stock s
set s.del_flag = '1'
where s.product_id in
<foreach item="item" index="index" collection="productIdList" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
<update id="batchReduceStockByLog">
<foreach collection="stockLogList" item="item" separator=";" open="" close="">
update t_stock set stock_count = stock_count - #{item.productCount} WHERE product_id = #{item.productId} and attribute_list = #{item.attributeList}
</foreach>
</update>
</mapper> </mapper>
Loading…
Cancel
Save