Browse Source

对账单、销售到撤销及其他BUG修改

cangku
wangfukang 2 years ago
parent
commit
909ee4e9b2
  1. 4
      hiver-admin/src/main/resources/application.yml
  2. 16
      hiver-admin/test-output/test-report.html
  3. 15
      hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/AuthController.java
  4. 51
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/controller/BillController.java
  5. 17
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/service/BillService.java
  6. 210
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/service/impl/BillServiceImpl.java
  7. 18
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/ArrearsVo.java
  8. 19
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/BillAttributeListVo.java
  9. 35
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/BillProductDetailVo.java
  10. 44
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/CustomerBillDataVo.java
  11. 23
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/CustomerBillQueryVo.java
  12. 64
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/CustomerBillSaleVo.java
  13. 15
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/common/constant/StockLogConstant.java
  14. 73
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java
  15. 41
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ReturnSaleController.java
  16. 60
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SaleController.java
  17. 8
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/DealingsRecordMapper.java
  18. 18
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ProductMapper.java
  19. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ReturnDetailMapper.java
  20. 13
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ReturnSaleMapper.java
  21. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleDetailMapper.java
  22. 7
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java
  23. 4
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockMapper.java
  24. 4
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/mapper/DebtMapper.java
  25. 19
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/DebtService.java
  26. 22
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/impl/DebtServiceImpl.java
  27. 201
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/ReturnDetail.java
  28. 5
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Sale.java
  29. 5
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Supplier.java
  30. 6
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/ReturnSaleDetailDTO.java
  31. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/SaleDetailDTO.java
  32. 42
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/ReturnSalePageQuery.java
  33. 6
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/CustomerBuyProductDetailLogVo.java
  34. 4
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/CustomerBuyProductLogVo.java
  35. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/CustomerBuySaleVo.java
  36. 5
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductPageVO.java
  37. 18
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ReturnSaleVo.java
  38. 8
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SaleNewVO.java
  39. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/productpicture/mapper/ProductPictureMapper.java
  40. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/productpicture/service/ProductPictureService.java
  41. 5
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/productpicture/service/impl/ProductPictureServiceImpl.java
  42. 18
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchaseocr/service/impl/PurchaseOcrPictureServiceImpl.java
  43. 8
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/DealingsRecordService.java
  44. 20
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductService.java
  45. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ReturnDetailService.java
  46. 14
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ReturnSaleService.java
  47. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleDetailService.java
  48. 19
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleService.java
  49. 4
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockService.java
  50. 34
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ProductShareServiceImpl.java
  51. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesAndDetailsServiceImpl.java
  52. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/StockAndLogServiceImpl.java
  53. 35
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SupplierServiceImpl.java
  54. 11
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/DealingsRecordServiceImpl.java
  55. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductCategoryServiceImpl.java
  56. 63
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java
  57. 9
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ReturnDetailServiceImpl.java
  58. 41
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ReturnSaleServiceImpl.java
  59. 5
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleDetailServiceImpl.java
  60. 165
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java
  61. 34
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java
  62. 6
      hiver-modules/hiver-mall/src/main/resources/mapper/DealingsRecordMapper.xml
  63. 11
      hiver-modules/hiver-mall/src/main/resources/mapper/DebtMapper.xml
  64. 6
      hiver-modules/hiver-mall/src/main/resources/mapper/ProductAttributeMapper.xml
  65. 9
      hiver-modules/hiver-mall/src/main/resources/mapper/ProductMapper.xml
  66. 12
      hiver-modules/hiver-mall/src/main/resources/mapper/ProductPictureMapper.xml
  67. 67
      hiver-modules/hiver-mall/src/main/resources/mapper/ReturnDetailMapper.xml
  68. 106
      hiver-modules/hiver-mall/src/main/resources/mapper/ReturnSaleMapper.xml
  69. 10
      hiver-modules/hiver-mall/src/main/resources/mapper/SaleDetailMapper.xml
  70. 93
      hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml
  71. 22
      hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml

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

@ -317,9 +317,11 @@ ignored:
- /hiver/app/stock/productCount
# 选择物流公司
- /hiver/app/logitics/chooseCompany
# 下游客户查询商品购买记录
- /hiver/app/sale/getCustomerBuyProductLog
# # 临时增加
- /hiver/app/bill/getCustomerBill
# 限流及黑名单不拦截的路径
limitUrls:
- /**/*.js

16
hiver-admin/test-output/test-report.html

@ -35,7 +35,7 @@
<a href="#"><span class="badge badge-primary">Hiver</span></a>
</li>
<li class="m-r-10">
<a href="#"><span class="badge badge-primary">六月 20, 2024 12:29:14</span></a>
<a href="#"><span class="badge badge-primary">六月 28, 2024 09:09:27</span></a>
</li>
</ul>
</div>
@ -84,7 +84,7 @@
<div class="test-detail">
<span class="meta text-white badge badge-sm"></span>
<p class="name">passTest</p>
<p class="text-sm"><span>12:29:15 下</span> / <span>0.015 secs</span></p>
<p class="text-sm"><span>09:09:28 上</span> / <span>0.019 secs</span></p>
</div>
<div class="test-contents d-none">
<div class="detail-head">
@ -92,9 +92,9 @@
<div class="info">
<div class='float-right'><span class='badge badge-default'>#test-id=1</span></div>
<h5 class="test-status text-pass">passTest</h5>
<span class='badge badge-success'>06.20.2024 12:29:15</span>
<span class='badge badge-danger'>06.20.2024 12:29:15</span>
<span class='badge badge-default'>0.015 secs</span>
<span class='badge badge-success'>06.28.2024 09:09:28</span>
<span class='badge badge-danger'>06.28.2024 09:09:28</span>
<span class='badge badge-default'>0.019 secs</span>
</div>
<div class="m-t-10 m-l-5"></div>
</div>
@ -104,7 +104,7 @@
<tbody>
<tr class="event-row">
<td><span class="badge log pass-bg">Pass</span></td>
<td>12:29:15</td>
<td>9:09:28</td>
<td>
Test passed
</td>
@ -128,13 +128,13 @@
<div class="col-md-3">
<div class="card"><div class="card-body">
<p class="m-b-0">Started</p>
<h3>六月 20, 2024 12:29:14</h3>
<h3>六月 28, 2024 09:09:27</h3>
</div></div>
</div>
<div class="col-md-3">
<div class="card"><div class="card-body">
<p class="m-b-0">Ended</p>
<h3>六月 20, 2024 12:29:15</h3>
<h3>六月 28, 2024 09:09:28</h3>
</div></div>
</div>
<div class="col-md-3">

15
hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/AuthController.java

@ -6,6 +6,7 @@ import cc.hiver.base.vo.RegisterShopVo;
import cc.hiver.core.common.annotation.RateLimiter;
import cc.hiver.core.common.annotation.SystemLog;
import cc.hiver.core.common.constant.AppToBConstant;
import cc.hiver.core.common.constant.CommonConstant;
import cc.hiver.core.common.constant.SecurityConstant;
import cc.hiver.core.common.constant.UserConstant;
import cc.hiver.core.common.enums.LogType;
@ -22,12 +23,14 @@ import cc.hiver.core.service.UserRoleService;
import cc.hiver.core.service.UserService;
import cc.hiver.mall.entity.Shop;
import cc.hiver.mall.entity.ShopUser;
import cc.hiver.mall.entity.Supplier;
import cc.hiver.mall.invitelog.constant.InviteLogConstant;
import cc.hiver.mall.invitelog.entity.InviteLog;
import cc.hiver.mall.invitelog.service.InviteLogService;
import cc.hiver.mall.pojo.vo.ShopVo;
import cc.hiver.mall.service.ShopService;
import cc.hiver.mall.service.ShopUserService;
import cc.hiver.mall.service.SupplierService;
import cc.hiver.mall.service.mybatis.ProductCategoryService;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.IdUtil;
@ -105,6 +108,9 @@ public class AuthController {
@Autowired
private InviteLogService inviteLogService;
@Autowired
private SupplierService supplierService;
@RequestMapping(value = "/login", method = RequestMethod.POST)
@SystemLog(description = "账号登录", type = LogType.LOGIN)
@ApiOperation("账号/手机/邮箱登录")
@ -417,6 +423,15 @@ public class AuthController {
final String categoryId = productCategoryService.addCategoryOfShop();
shop.setAttrId(categoryId);
shopService.save(shop);
// 20240625新增默认供应商
final Supplier supplier = new Supplier();
supplier.setShopId(shop.getId());
supplier.setConsigneeName("默认供应商");
supplier.setCreateBy(user.getId());
supplier.setCreateTime(new Date());
supplier.setConsigneeMobile("");
supplier.setDelFlag(CommonConstant.DEL_FLAG_FALSE);
supplierService.save(supplier);
return ResultUtil.data(user);
}

51
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/controller/BillController.java

@ -0,0 +1,51 @@
package cc.hiver.mall.bill.controller;
import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.vo.Result;
import cc.hiver.mall.bill.service.BillService;
import cc.hiver.mall.bill.vo.CustomerBillDataVo;
import cc.hiver.mall.bill.vo.CustomerBillQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 对账单
*
* @author 王富康
* @date 2024/6/26
*/
@Slf4j
@RestController
@Api(tags = "盘点接口")
@RequestMapping("/hiver/app/bill/")
public class BillController {
@Autowired
private BillService billService;
/**
* 获取客户对账单
*
* @param customerBillQueryVo
* @return Result
* @author 王富康
* @date 2024/6/26
*/
@PostMapping("/getCustomerBill")
@ApiOperation("获取客户对账单")
public Result getCustomerBill(@RequestBody CustomerBillQueryVo customerBillQueryVo) {
try {
final CustomerBillDataVo customerBill = billService.getCustomerBill(customerBillQueryVo);
return new ResultUtil<>().setData(customerBill);
} catch (Exception e) {
log.error("获取客户对账单异常", e);
return ResultUtil.error("获取客户对账单异常");
}
}
}

17
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/service/BillService.java

@ -0,0 +1,17 @@
package cc.hiver.mall.bill.service;
import cc.hiver.mall.bill.vo.CustomerBillDataVo;
import cc.hiver.mall.bill.vo.CustomerBillQueryVo;
public interface BillService {
/**
* 获取客户对账单
*
* @param customerBillQueryVo
* @return Result
* @author 王富康
* @date 2024/6/26
*/
CustomerBillDataVo getCustomerBill(CustomerBillQueryVo customerBillQueryVo);
}

210
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/service/impl/BillServiceImpl.java

@ -0,0 +1,210 @@
package cc.hiver.mall.bill.service.impl;
import cc.hiver.mall.bill.service.BillService;
import cc.hiver.mall.bill.vo.*;
import cc.hiver.mall.entity.Customer;
import cc.hiver.mall.entity.ReturnDetail;
import cc.hiver.mall.entity.SaleDetail;
import cc.hiver.mall.service.mybatis.*;
import cc.hiver.mall.utils.DateUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
@Service
public class BillServiceImpl implements BillService {
@Autowired
private SaleService saleService;
@Autowired
private CustomerService customerService;
@Autowired
private SaleDetailService saleDetailService;
@Autowired
private ReturnSaleService returnSaleService;
@Autowired
private ReturnDetailService returnDetailService;
/**
* 获取客户对账单
*
* @param customerBillQueryVo
* @return Result
* @author 王富康
* @date 2024/6/26
*/
@Override
public CustomerBillDataVo getCustomerBill(CustomerBillQueryVo customerBillQueryVo) {
final CustomerBillDataVo customerBillDataVo = new CustomerBillDataVo();
customerBillDataVo.setUserId(customerBillQueryVo.getCustomerId());
// 获取客户信息
final Customer customer = customerService.getById(customerBillQueryVo.getCustomerId());
customerBillDataVo.setUserName(customer.getName());
customerBillDataVo.setQueryDate(DateUtil.COMMON_FULL.getDateText(new Date()));
// 获取本期全部欠款及拿货总金额
final ArrearsVo saleArrearsVo = saleService.getArrearsAndTotalSale(customerBillQueryVo);
if (saleArrearsVo != null) {
customerBillDataVo.setArrears(saleArrearsVo.getArrears());
customerBillDataVo.setTotalSale(saleArrearsVo.getTotalSale());
}
// 获取退货总金额
final ArrearsVo returnSaleArrearsVo = returnSaleService.getTotalReturn(customerBillQueryVo);
if (returnSaleArrearsVo != null) {
customerBillDataVo.setTotalReturn(returnSaleArrearsVo.getTotalReturn());
}
// 获取退货总金额
// 根据客户id及日期范围分页查询订单
final Page<CustomerBillSaleVo> salePage = saleService.getCustomerBill(customerBillQueryVo);
final List<CustomerBillSaleVo> records = salePage.getRecords();
// 获取saleId,去查询销售单的商品明细,及退货单的商品明细
final List<String> saleIdList = new ArrayList<>();
for (int i = 0; i < records.size(); i++) {
saleIdList.add(records.get(i).getSaleId());
// 根据时间升序查询的,这里获取第一个的初期欠款当做本次查询的初期欠款
if (i == 0) {
final BigDecimal lastDebtAmount = records.get(0).getLastDebtAmount();
customerBillDataVo.setInitialArrears(lastDebtAmount);
}
// 获取最后一个的剩余欠款当做本次查询的剩余欠款
if (i == records.size() - 1) {
customerBillDataVo.setEndArrears(records.get(i).getBalanceDue());
}
}
if (!saleIdList.isEmpty()) {
// 获取销售单明细
final List<SaleDetail> saleDetailList = saleDetailService.getSaleDetails(saleIdList);
// 将销售明细封装到销售单对象中
final Map<String, List<SaleDetail>> saleDetailMap = new HashMap<>();
for (SaleDetail saleDetail : saleDetailList) {
final String saleId = saleDetail.getSaleId();
if (saleDetailMap.containsKey(saleId)) {
final List<SaleDetail> saleDetailListOfMap = saleDetailMap.get(saleId);
saleDetailListOfMap.add(saleDetail);
} else {
final List<SaleDetail> saleDetailListOfMap = new ArrayList<>();
saleDetailListOfMap.add(saleDetail);
saleDetailMap.put(saleId, saleDetailListOfMap);
}
}
// 获取退货单明细
final List<ReturnDetail> returnDetails = returnDetailService.getReturnDetails(saleIdList);
final Map<String, List<ReturnDetail>> returnSaleDetailMap = new HashMap<>();
for (ReturnDetail returnDetail : returnDetails) {
final String saleId = returnDetail.getSaleId();
if (returnSaleDetailMap.containsKey(saleId)) {
final List<ReturnDetail> returnDetailListOfMap = returnSaleDetailMap.get(saleId);
returnDetailListOfMap.add(returnDetail);
} else {
final List<ReturnDetail> returnDetailListOfMap = new ArrayList<>();
returnDetailListOfMap.add(returnDetail);
returnSaleDetailMap.put(saleId, returnDetailListOfMap);
}
}
// 开始封装数据
for (CustomerBillSaleVo customerBillSaleVo : records) {
final String saleId = customerBillSaleVo.getSaleId();
// 封装销售单信息
final List<SaleDetail> saleDetails = saleDetailMap.get(saleId);
// 根据商品id分类
final Map<String, List<SaleDetail>> saleDetailMapOfSale = new HashMap<>();
if (saleDetails != null && !saleDetails.isEmpty()) {
for (SaleDetail saleDetail : saleDetails) {
final String productId = saleDetail.getProductId();
if (saleDetailMapOfSale.containsKey(productId)) {
final List<SaleDetail> saleDetailListOfMap = saleDetailMapOfSale.get(productId);
saleDetailListOfMap.add(saleDetail);
} else {
final List<SaleDetail> saleDetailListOfMap = new ArrayList<>();
saleDetailListOfMap.add(saleDetail);
saleDetailMapOfSale.put(productId, saleDetailListOfMap);
}
}
final List<BillProductDetailVo> billSaleDetailVos = new ArrayList<>();
for (Map.Entry<String, List<SaleDetail>> stringListEntry : saleDetailMapOfSale.entrySet()) {
final List<SaleDetail> value = stringListEntry.getValue();
final BillProductDetailVo billProductDetailVo = new BillProductDetailVo();
// 同一款商品,不同规格,商品信息值几钱取第一个
billProductDetailVo.setProductSn(value.get(0).getProductSn());
billProductDetailVo.setProductName(value.get(0).getProductName());
billProductDetailVo.setDiscountAmount(value.get(0).getDiscountAmount());
int productCount = 0;
BigDecimal totalAmount = BigDecimal.ZERO;
final List<BillAttributeListVo> billAttributeListVos = new ArrayList<>();
for (SaleDetail saleDetail : value) {
final BillAttributeListVo billAttributeListVo = new BillAttributeListVo();
billAttributeListVo.setAttributeList(saleDetail.getAttributeList());
billAttributeListVo.setProductCount(saleDetail.getProductCount());
billAttributeListVos.add(billAttributeListVo);
// 计算数量
productCount += saleDetail.getProductCount();
// 计算总金额
totalAmount = totalAmount.add(saleDetail.getDiscountAmount().multiply(BigDecimal.valueOf(saleDetail.getProductCount())));
}
billProductDetailVo.setProductCount(productCount);
billProductDetailVo.setTotalAmount(totalAmount);
billProductDetailVo.setBillAttributeListVos(billAttributeListVos);
billSaleDetailVos.add(billProductDetailVo);
}
customerBillSaleVo.setBillSaleDetailVos(billSaleDetailVos);
}
// 封装退货单信息
final List<ReturnDetail> returnDetailsOfSale = returnSaleDetailMap.get(saleId);
if (returnDetailsOfSale != null && !returnDetailsOfSale.isEmpty()) {
// 根据商品id分类
final Map<String, List<ReturnDetail>> returnSaleDetailMapOfSale = new HashMap<>();
for (ReturnDetail returnDetail : returnDetailsOfSale) {
final String productId = returnDetail.getProductId();
if (returnSaleDetailMapOfSale.containsKey(productId)) {
final List<ReturnDetail> returnSaleDetails = returnSaleDetailMapOfSale.get(productId);
returnSaleDetails.add(returnDetail);
} else {
final List<ReturnDetail> returnDetailListOfMap = new ArrayList<>();
returnDetailListOfMap.add(returnDetail);
returnSaleDetailMapOfSale.put(productId, returnDetailListOfMap);
}
}
final List<BillProductDetailVo> billReturnSaleDetailVos = new ArrayList<>();
for (Map.Entry<String, List<ReturnDetail>> stringListEntry : returnSaleDetailMapOfSale.entrySet()) {
final List<ReturnDetail> returnDetailList = stringListEntry.getValue();
final BillProductDetailVo billProductDetailVo = new BillProductDetailVo();
// 同一款商品,不同规格,商品信息值几钱取第一个
billProductDetailVo.setProductSn(returnDetailList.get(0).getProductSn());
billProductDetailVo.setProductName(returnDetailList.get(0).getProductName());
billProductDetailVo.setDiscountAmount(returnDetailList.get(0).getDiscountAmount());
int productCount = 0;
BigDecimal totalAmount = BigDecimal.ZERO;
final List<BillAttributeListVo> billAttributeListVos = new ArrayList<>();
for (ReturnDetail saleDetail : returnDetailList) {
final BillAttributeListVo billAttributeListVo = new BillAttributeListVo();
billAttributeListVo.setAttributeList(saleDetail.getAttributeList());
billAttributeListVo.setProductCount(saleDetail.getProductCount());
billAttributeListVos.add(billAttributeListVo);
// 计算数量
productCount += saleDetail.getProductCount();
// 计算总金额
totalAmount = totalAmount.add(saleDetail.getDiscountAmount().multiply(BigDecimal.valueOf(saleDetail.getProductCount())));
}
billProductDetailVo.setProductCount(productCount);
billProductDetailVo.setTotalAmount(totalAmount);
billProductDetailVo.setBillAttributeListVos(billAttributeListVos);
billReturnSaleDetailVos.add(billProductDetailVo);
}
customerBillSaleVo.setBillReturnSaleDetailVos(billReturnSaleDetailVos);
}
}
}
customerBillDataVo.setCustomerBillSaleVos(records);
return customerBillDataVo;
}
}

18
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/ArrearsVo.java

@ -0,0 +1,18 @@
package cc.hiver.mall.bill.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class ArrearsVo {
@ApiModelProperty(value = "本期欠款金额")
private BigDecimal arrears;
@ApiModelProperty(value = "拿货总金额")
private BigDecimal totalSale;
@ApiModelProperty(value = "退货总金额")
private BigDecimal totalReturn;
}

19
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/BillAttributeListVo.java

@ -0,0 +1,19 @@
package cc.hiver.mall.bill.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 规格明细
* @author 王富康
* @date 2024/6/26
*/
@Data
public class BillAttributeListVo {
@ApiModelProperty(value = "商品具体属性")
private String attributeList;
@ApiModelProperty(value = "销售数量")
private Integer productCount;
}

35
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/BillProductDetailVo.java

@ -0,0 +1,35 @@
package cc.hiver.mall.bill.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* 商品明细
*
* @author 王富康
* @date 2024/6/26
*/
@Data
public class BillProductDetailVo {
@ApiModelProperty(value = "商品名称")
private String productName;
@ApiModelProperty(value = "货号")
private String productSn;
@ApiModelProperty(value = "销售数量")
private Integer productCount;
@ApiModelProperty(value = "优惠金额")
private BigDecimal discountAmount;
@ApiModelProperty(value = "总价")
private BigDecimal totalAmount;
@ApiModelProperty(value = "同一件商品购买属性列表")
private List<BillAttributeListVo> billAttributeListVos;
}

44
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/CustomerBillDataVo.java

@ -0,0 +1,44 @@
package cc.hiver.mall.bill.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* 对账单信息
* @author 王富康
* @date 2024/6/26
*/
@Data
public class CustomerBillDataVo {
@ApiModelProperty(value = "客户id")
private String userId;
@ApiModelProperty(value = "客户名称")
private String userName;
@ApiModelProperty(value = "对账单日期")
private String queryDate;
@ApiModelProperty(value = "初期欠款金额")
private BigDecimal initialArrears;
@ApiModelProperty(value = "期末欠款金额")
private BigDecimal endArrears;
@ApiModelProperty(value = "本期欠款金额")
private BigDecimal arrears;
@ApiModelProperty(value = "拿货总金额")
private BigDecimal totalSale;
@ApiModelProperty(value = "退货总金额")
private BigDecimal totalReturn;
@ApiModelProperty(value = "销售单明细")
private List<CustomerBillSaleVo> customerBillSaleVos;
}

23
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/CustomerBillQueryVo.java

@ -0,0 +1,23 @@
package cc.hiver.mall.bill.vo;
import cc.hiver.core.base.HiverBasePageQuery;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 对账单查询参数
* @author 王富康
* @date 2024/6/26
*/
@Data
public class CustomerBillQueryVo extends HiverBasePageQuery {
@ApiModelProperty(value = "客户id")
private String customerId;
@ApiModelProperty(value = "开始时间")
private String startDate;
@ApiModelProperty(value = "结束时间")
private String endDate;
}

64
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/CustomerBillSaleVo.java

@ -0,0 +1,64 @@
package cc.hiver.mall.bill.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* 销售单明细
* @author 王富康
* @date 2024/6/26
*/
@Data
public class CustomerBillSaleVo {
@ApiModelProperty(value = "销售单号")
private String saleId;
@ApiModelProperty(value = "操作人")
private String createByName;
@ApiModelProperty(value = "日期")
private String createTime;
@ApiModelProperty(value = "订单金额(销售金额)")
private BigDecimal totalAmount;
@ApiModelProperty(value="退款总金额")
private BigDecimal returnSaleTotalAmount;
@ApiModelProperty(value="欠款抵扣金额")
private BigDecimal debtDeductionAmount;
@ApiModelProperty(value="销售抵扣金额")
private BigDecimal saleDeductionAmount;
@ApiModelProperty(value="余额抵扣金额")
private BigDecimal balanceDeductionAmount;
@ApiModelProperty(value = "实收金额")
private BigDecimal realAmount;
@ApiModelProperty(value = "已收")
private BigDecimal alreadyEarn;
@ApiModelProperty(value = "上次欠款")
private BigDecimal lastDebtAmount;
@ApiModelProperty(value = "本单欠款")
private BigDecimal amount;
@ApiModelProperty(value = "剩余欠款-更新后欠款")
private BigDecimal balanceDue;
@ApiModelProperty(value = "交易类型:0:开单;1:退货;2:回款")
private Integer dealingsType;
@ApiModelProperty(value = "销售明细")
private List<BillProductDetailVo> billSaleDetailVos;
@ApiModelProperty(value = "退货明细")
private List<BillProductDetailVo> billReturnSaleDetailVos;
}

15
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/common/constant/StockLogConstant.java

@ -0,0 +1,15 @@
package cc.hiver.mall.common.constant;
/**
* 店铺常量
*
* @author cc
*/
public interface StockLogConstant {
/**
* 出入库类型0-入库1-出库
*/
Integer[] CHANGE_TYPE = {0,1};
}

73
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java

@ -59,10 +59,10 @@ public class ProductController {
final String attrId = productCategoryService.batchSaveCategoryAndAttribute(productCategoryVo);
// 更新店铺尺码库
productCategoryService.batchSaveCategoryOfShop(productCategoryVo);
if(StringUtils.isNotEmpty(attrId)){
if (StringUtils.isNotEmpty(attrId)) {
// 回填分类id
product.setAttrId(attrId);
}else{
} else {
return ResultUtil.error("添加分类信息失败");
}
// shopId从缓存中设置
@ -99,10 +99,10 @@ public class ProductController {
final String attrId = productCategoryService.batchSaveCategoryAndAttribute(productCategoryVo);
// 更新店铺尺码库
productCategoryService.batchSaveCategoryOfShop(productCategoryVo);
if(StringUtils.isNotEmpty(attrId)){
if (StringUtils.isNotEmpty(attrId)) {
// 回填分类id
product.setAttrId(attrId);
}else{
} else {
return ResultUtil.error("添加分类信息失败");
}
final boolean result = productService.updateById(product);
@ -138,6 +138,36 @@ public class ProductController {
}
}
/**
* 根据货品id批量上架货品
*
* @param ids
* @return Result
* @author 王富康
* @date 2024/6/22
*/
@RequestMapping(value = "/batchUp", method = RequestMethod.POST)
@ApiOperation("根据货品id批量上架货品")
public Result batchUp(String ids) {
if (StringUtils.isEmpty(ids)) {
return ResultUtil.error("请选择要上架的货品");
}
final boolean result = productService.batchUp(ids);
if (result) {
return ResultUtil.success("上架成功");
} else {
return ResultUtil.error("上架失败");
}
}
/**
* 根据货品id下架货品
*
* @param id
* @return Result
* @author 王富康
* @date 2024/6/22
*/
@RequestMapping(value = "/down", method = RequestMethod.POST)
@ApiOperation("根据货品id下架货品")
public Result down(String id) {
@ -152,6 +182,28 @@ public class ProductController {
}
}
/**
* 根据货品id批量下架货品
*
* @param ids
* @return Result
* @author 王富康
* @date 2024/6/22
*/
@RequestMapping(value = "/batchDown", method = RequestMethod.POST)
@ApiOperation("根据货品id批量下架货品")
public Result batchDown(String ids) {
if (StringUtils.isEmpty(ids)) {
return ResultUtil.error("请选择要下架的货品");
}
final boolean result = productService.batchDown(ids);
if (result) {
return ResultUtil.success("下架成功");
} else {
return ResultUtil.error("下架失败");
}
}
@RequestMapping(value = "/delById", method = RequestMethod.POST)
@ApiOperation("根据id删除货品")
public Result delete(String id) {
@ -186,7 +238,7 @@ public class ProductController {
final QueryWrapper<Product> queryWrapper = new QueryWrapper<>();
// shopId从缓存中设置
final String shopId = securityUtil.getShopId();
queryWrapper.eq("shop_id",shopId);
queryWrapper.eq("shop_id", shopId);
final List<Product> list = productService.list(queryWrapper);
return new ResultUtil<List<Product>>().setData(list);
}
@ -198,7 +250,7 @@ public class ProductController {
queryWrapper.eq("del_flag", 1);
// shopId从缓存中设置
final String shopId = securityUtil.getShopId();
queryWrapper.eq("shop_id",shopId);
queryWrapper.eq("shop_id", shopId);
final List<Product> list = productService.list(queryWrapper);
return new ResultUtil<List<Product>>().setData(list);
}
@ -210,7 +262,7 @@ public class ProductController {
queryWrapper.like("product_name", name);
// shopId从缓存中设置
final String shopId = securityUtil.getShopId();
queryWrapper.eq("shop_id",shopId);
queryWrapper.eq("shop_id", shopId);
final List<Product> list = productService.list(queryWrapper);
return new ResultUtil<List<Product>>().setData(list);
}
@ -249,13 +301,14 @@ public class ProductController {
public Result<List<Product>> getByProductSn(String productSn) {
// shopId从缓存中设置
final String shopId = securityUtil.getShopId();
final List<Product> byProductSn = productService.getByProductSn(productSn,shopId);
final List<Product> byProductSn = productService.getByProductSn(productSn, shopId);
if (byProductSn != null) {
return new ResultUtil<List<Product>>().setData(byProductSn);
} else {
return ResultUtil.success("未查到对应商品信息!");
}
}
@RequestMapping(value = "/getByBarcode", method = RequestMethod.POST)
@ApiOperation("根据条码获取商品信息")
public Result<List<Product>> getByBarcode(String barcode) {
@ -269,9 +322,9 @@ public class ProductController {
@RequestMapping(value = "/getByUserIdAndProductId", method = RequestMethod.POST)
@ApiOperation("获取客户最近购买的商品价格及数量")
public Result getByUserIdAndProductId(String userId,String productId) {
public Result getByUserIdAndProductId(String userId, String productId) {
final ProductLastBuyVo byProductSn = productService.getByUserIdAndProductId( userId, productId);
final ProductLastBuyVo byProductSn = productService.getByUserIdAndProductId(userId, productId);
if (byProductSn != null) {
return new ResultUtil<ProductLastBuyVo>().setData(byProductSn);
} else {

41
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ReturnSaleController.java

@ -15,6 +15,8 @@ import cc.hiver.mall.pojo.dto.ReturnSaleDetailDTO;
import cc.hiver.mall.pojo.dto.SaleDetailDTO;
import cc.hiver.mall.pojo.dto.SaleDetailQueryDTO;
import cc.hiver.mall.pojo.dto.SaleReturnDTO;
import cc.hiver.mall.pojo.query.ReturnSalePageQuery;
import cc.hiver.mall.pojo.vo.ReturnSaleVo;
import cc.hiver.mall.pojo.vo.SaleComVO;
import cc.hiver.mall.pojo.vo.SaleQueryVO;
import cc.hiver.mall.pojo.vo.SaleReturnVO;
@ -22,6 +24,7 @@ import cc.hiver.mall.service.*;
import cc.hiver.mall.service.mybatis.*;
import cn.hutool.core.text.CharSequenceUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -100,10 +103,10 @@ public class ReturnSaleController {
final ReturnSale returnSale = returnSaleService.getById(id);
// 增加配送人员信息
final String transportType = returnSale.getTransportType();
if(!SaleConstant.TRANSPORT_TYPE[2].equals(transportType)){
if (!SaleConstant.TRANSPORT_TYPE[2].equals(transportType)) {
//非自提查询配送人员信息
final OrderXd orderData = orderService.findByOrderId(id);
if(orderData != null && StringUtils.isNotEmpty(orderData.getOrderByWorker())){
if (orderData != null && StringUtils.isNotEmpty(orderData.getOrderByWorker())) {
final String workerName = orderData.getWorker().getWorkerName();
// 查询到之后回填值列表
returnSale.setWorkerName(workerName);
@ -135,6 +138,8 @@ public class ReturnSaleController {
saleDetailDTO.setDiscount(returnDetail.getDiscount());
saleDetailDTO.setDiscountAmount(returnDetail.getDiscountAmount());
saleDetailDTO.setRealPrice(returnDetail.getRealPrice());
saleDetailDTO.setProductPicture(returnDetail.getProductPicture());
saleDetailDTO.setProductSn(returnDetail.getProductSn());
final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO();
saleDetailQueryDTO.setAttributeList(returnDetail.getAttributeList());
@ -343,7 +348,7 @@ public class ReturnSaleController {
if (!StringUtils.isEmpty(saleComVO.getSaleId())) {
// 根据销售单id,查询该销售单所有的退货信息
queryWrapper.eq("sale_id", saleComVO.getSaleId());
}else{
} else {
// 如果没有saleId,则说明店铺查询所有的欠款列表。
// shopId从缓存中设置
final String shopId = securityUtil.getShopId();
@ -379,11 +384,11 @@ public class ReturnSaleController {
for (ReturnSale record : saleList) {
final String id = record.getId();
final String transportType = record.getTransportType();
if(!SaleConstant.TRANSPORT_TYPE[2].equals(transportType)){
if (!SaleConstant.TRANSPORT_TYPE[2].equals(transportType)) {
//非自提查询配送人员信息
final OrderXd orderData = orderService.findByOrderId(id);
// 订单的所属拉包工不为空的时候订单中的woker才会有值,所以这里判断所属拉包工id是否为空。
if(orderData != null && orderData.getWorker() != null && StringUtils.isNotEmpty(orderData.getOrderByWorker())){
if (orderData != null && orderData.getWorker() != null && StringUtils.isNotEmpty(orderData.getOrderByWorker())) {
final String workerName = orderData.getWorker().getWorkerName();
// 查询到之后回填值列表
record.setWorkerName(workerName);
@ -441,4 +446,30 @@ public class ReturnSaleController {
orderService.delete(orderId);
return ResultUtil.success("取消配送成功");
}
/**
* 查询退货单列表接口deflag=0(根据阶段日期操作人客户模糊搜索+指定客户搜索)需要关联查出来 退货金额之前欠款欠款抵扣笨蛋欠款累计欠款等数据加分页
*
* @param returnSaleVo
* @return Result
* @author 王富康
* @date 2024/6/26
*/
@RequestMapping(value = "/getReturnSaleList", method = RequestMethod.POST)
@ApiOperation("退货列表")
public Result getReturnSaleList(@RequestBody ReturnSaleVo returnSaleVo) {
// shopId从缓存中设置
final String shopId = securityUtil.getShopId();
returnSaleVo.setShopId(shopId);
final IPage<ReturnSaleVo> result = returnSaleService.getReturnSaleList(returnSaleVo);
return new ResultUtil<IPage<ReturnSaleVo>>().setData(result);
}
@RequestMapping(value = "/getReturnSaleListByProductId", method = RequestMethod.POST)
@ApiOperation("根据商品id分页获取退货历史")
public Result getReturnSaleListByProductId(ReturnSalePageQuery returnSalePageQuery) {
// 分页获取销售单历史
final Page<SaleReturnDTO> salePage = returnSaleService.getReturnSaleListByProductId(returnSalePageQuery);
return ResultUtil.data(salePage);
}
}

60
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SaleController.java

@ -1,6 +1,7 @@
package cc.hiver.mall.controller;
import cc.hiver.core.common.annotation.RateLimiter;
import cc.hiver.core.common.constant.CommonConstant;
import cc.hiver.core.common.constant.SaleConstant;
import cc.hiver.core.common.constant.WorkerConstant;
import cc.hiver.core.common.utils.BeanUtils;
@ -146,7 +147,7 @@ public class SaleController {
// 20240616 开单可能值包含退货单
Sale sale = saleQueryDTO.getSale();
// 处理销售商品信息
if(saleQueryDTO.getSaleDetailList() != null && !saleQueryDTO.getSaleDetailList().isEmpty()){
if (saleQueryDTO.getSaleDetailList() != null && !saleQueryDTO.getSaleDetailList().isEmpty()) {
// 1. 处理商品信息,新商品进行新商品的新增,分类及规格的新增,分类库的新增,子图的新增
saleQueryDTO = productService.handleProduct(saleQueryDTO);
// 2.处理订单表模块
@ -187,15 +188,23 @@ public class SaleController {
}
}
}else{
} 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[4]);
saleService.save(sale);
// 只有退货,单独处理下客户欠款
}
// 如果退货信息不为空,那么则代表需要退货,处理退货信息
// 处理退货信息
if(saleQueryDTO.getSaleReturnDTO() != null ){
if (saleQueryDTO.getSaleReturnDTO() != null) {
//处理退货信息
final SaleReturnDTO saleReturnDTO = saleQueryDTO.getSaleReturnDTO();
// 回填销售单id
@ -217,12 +226,12 @@ public class SaleController {
final BigDecimal debtDeductionAmount = saleQueryDTO.getSale().getDebtDeductionAmount();
// 余额抵扣金额
final BigDecimal balanceDeductionAmount = saleQueryDTO.getSale().getBalanceDeductionAmount();
if(noEarn.compareTo(BigDecimal.valueOf(0)) != 0 || debtDeductionAmount.compareTo(BigDecimal.valueOf(0)) != 0 || balanceDeductionAmount.compareTo(BigDecimal.valueOf(0)) != 0){
if (noEarn.compareTo(BigDecimal.valueOf(0)) != 0 || debtDeductionAmount.compareTo(BigDecimal.valueOf(0)) != 0 || balanceDeductionAmount.compareTo(BigDecimal.valueOf(0)) != 0) {
debtService.saleToDebt(saleQueryDTO);
}
return new ResultUtil<>().setData(sale.getId(),"下单成功");
}catch (Exception e){
log.error(e.getMessage(),e);
return new ResultUtil<>().setData(sale.getId(), "下单成功");
} catch (Exception e) {
log.error(e.getMessage(), e);
return ResultUtil.error("下单失败");
}
}
@ -464,6 +473,13 @@ public class SaleController {
final String shopId = sale.getShopId();
final Shop shop = shopService.get(shopId);
saleNewVO.setShop(shop);
// 获取本单的欠款交易记录
final List<DealingsRecord> dealingsRecords = dealingsRecordService.getDealingsRecordList(id);
// 正常一个单子只会生成一条交易记录,这里直接获取第一条就行
if (dealingsRecords != null && !dealingsRecords.isEmpty()) {
saleNewVO.setDealingsRecord(dealingsRecords.get(0));
}
return new ResultUtil<SaleNewVO>().setData(saleNewVO);
}
@ -542,10 +558,10 @@ public class SaleController {
}
final String dateText = DateUtil.COMMON.getDateText(new Date());
startTime = saleVO.getStartTime() == null ? dateText : saleVO.getStartTime();
if(StringUtils.isEmpty(saleVO.getEndTime())){
if (StringUtils.isEmpty(saleVO.getEndTime())) {
// 为空,使用当前日期+1
endTime = DateUtil.getAfterDayTime(dateText, 1);
}else{
} else {
// 不为空,使用传参日期+1
endTime = DateUtil.getAfterDayTime(saleVO.getEndTime(), 1);
}
@ -1057,4 +1073,30 @@ public class SaleController {
return ResultUtil.error("转单失败!");
}
}
/**
* 撤销销售单
* 1订单回退订单作废库存退回
* 2款项记录作废查询的时候也要关联deflag=0同时把款项回退当前欠款+欠款抵扣-余额抵扣-笨蛋欠款
* 3如果有退货退货表和detail作废同时把库存退回去
*
* @param id
* @return Result
* @author 王富康
* @date 2024/6/26
*/
@RequestMapping(value = "/cancelSale", method = RequestMethod.POST)
@ApiOperation("撤销销售单")
public Result cancelSale(String id) {
if (StringUtils.isEmpty(id)) {
ResultUtil.error("订单id不能为空!");
}
try {
saleService.cancelSale(id);
return ResultUtil.success("撤销成功");
} catch (Exception e) {
log.error(e.getMessage(), e);
return ResultUtil.error("撤销失败!");
}
}
}

8
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/DealingsRecordMapper.java

@ -24,4 +24,12 @@ public interface DealingsRecordMapper extends BaseMapper<DealingsRecord> {
* @date 2024/6/16
*/
List<DealingsRecord> getDealingsRecordListByUserId(@Param("userId") String userId, @Param("shopId") String shopId);
/**
* 作废交易记录
* @author 王富康
* @date 2024/6/26
* @param saleId
*/
void cancelRecord(@Param("saleId") String saleId);
}

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

@ -43,17 +43,17 @@ public interface ProductMapper extends BaseMapper<Product> {
List<Product> getProductListOfShop(String shopId);
CopyOnWriteArrayList<Product> getByProductSn(@Param("productSn")String productSn,@Param("shopId") String shopId);
CopyOnWriteArrayList<Product> getByProductSn(@Param("productSn") String productSn, @Param("shopId") String shopId);
ProductLastBuyVo getByUserIdAndProductId(@Param("userId")String userId, @Param("productId") String productId);
ProductLastBuyVo getByUserIdAndProductId(@Param("userId") String userId, @Param("productId") String productId);
Product getByIdOrBrcode(String id);
List<Product> getByBarcode(@Param("barcode")String barcode,@Param("shopId") String shopId);
List<Product> getByBarcode(@Param("barcode") String barcode, @Param("shopId") String shopId);
CopyOnWriteArrayList<Product> getProductByProductSnList(@Param("productSnList") List<String> productSnList, @Param("shopId") String shopId);
CopyOnWriteArrayList<Product> getProductByProductNameList(@Param("productNameList") List<String> productNameList,@Param("shopId") String shopId);
CopyOnWriteArrayList<Product> getProductByProductNameList(@Param("productNameList") List<String> productNameList, @Param("shopId") String shopId);
/**
* 删除分类时根据分类id删除商品信息
@ -65,4 +65,14 @@ public interface ProductMapper extends BaseMapper<Product> {
void deleteProductByCategoryId(@Param("categoryId") String categoryId);
void batchSaveProduct(@Param("addProductList") List<Product> addProductList);
/**
* 批量上架下架删除
*
* @param idList
* @param delFlag
* @author 王富康
* @date 2024/6/22
*/
void batchUpdateDelFlag(@Param("idList") List<String> idList, @Param("delFlag") Integer delFlag);
}

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

@ -2,7 +2,6 @@ package cc.hiver.mall.dao.mapper;
import cc.hiver.mall.entity.ReturnDetail;
import cc.hiver.mall.entity.ReturnDetailExample;
import cc.hiver.mall.entity.Sale;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@ -32,4 +31,6 @@ public interface ReturnDetailMapper extends BaseMapper<ReturnDetail> {
int updateByPrimaryKeySelective(ReturnDetail record);
int updateByPrimaryKey(ReturnDetail record);
List<ReturnDetail> getReturnDetails(@Param("saleIdList") List<String> saleIdList);
}

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

@ -1,11 +1,14 @@
package cc.hiver.mall.dao.mapper;
import cc.hiver.mall.entity.ReturnDetail;
import cc.hiver.mall.bill.vo.ArrearsVo;
import cc.hiver.mall.bill.vo.CustomerBillQueryVo;
import cc.hiver.mall.entity.ReturnSale;
import cc.hiver.mall.entity.ReturnSaleExample;
import cc.hiver.mall.entity.SaleExample;
import cc.hiver.mall.pojo.dto.SaleReturnDTO;
import cc.hiver.mall.pojo.vo.ReturnSaleVo;
import cc.hiver.mall.pojo.vo.SaleAllVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@ -39,4 +42,10 @@ public interface ReturnSaleMapper extends BaseMapper<ReturnSale> {
SaleAllVO saleMaxAmount(ReturnSaleExample returnSaleExample);
ReturnSale getBySaleId(String id);
List<ReturnSaleVo> getReturnSaleList(Page<ReturnSaleVo> page,@Param("queryParams") ReturnSaleVo returnSaleVo);
ArrearsVo getTotalReturn(@Param("customerBillQueryVo") CustomerBillQueryVo customerBillQueryVo);
Page<SaleReturnDTO> getReturnSaleListByProductId(Page<SaleReturnDTO> page,@Param("productId") String productId);
}

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

@ -41,4 +41,6 @@ public interface SaleDetailMapper extends BaseMapper<SaleDetail> {
List<SaleDetail> listOfShopAll(@Param("shopId") String shopId,@Param("startDate") String startDate,@Param("endDate") String endDate);
void putInUpdatePurchasePrice(@Param("purchaseDetails") List<PurchaseDetail> purchaseDetails);
List<SaleDetail> getSaleDetails(@Param("saleIdList") List<String> saleIdList);
}

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

@ -1,5 +1,8 @@
package cc.hiver.mall.dao.mapper;
import cc.hiver.mall.bill.vo.ArrearsVo;
import cc.hiver.mall.bill.vo.CustomerBillQueryVo;
import cc.hiver.mall.bill.vo.CustomerBillSaleVo;
import cc.hiver.mall.entity.Sale;
import cc.hiver.mall.entity.SaleExample;
import cc.hiver.mall.pojo.dto.ShopRevenue;
@ -84,4 +87,8 @@ public interface SaleMapper extends BaseMapper<Sale> {
void updateStatus(@Param("id")String id, @Param("status") Integer status);
List<TotalAlreadyEarnDetailVo> queryTotalAlreadyEarnDetail(@Param("shopId") String shopId,@Param("startTime") String startTime,@Param("endTime") String endTime);
Page<CustomerBillSaleVo> getCustomerBill(Page<CustomerBillSaleVo> page,@Param("customerBillQueryVo") CustomerBillQueryVo customerBillQueryVo);
ArrearsVo getArrearsAndTotalSale( @Param("customerBillQueryVo") CustomerBillQueryVo customerBillQueryVo);
}

4
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockMapper.java

@ -44,5 +44,9 @@ public interface StockMapper extends BaseMapper<Stock> {
List<Stock> getProductStock(@Param("productId")String productId);
List<Stock> getProductsStock(@Param("productIds")List<String> productIds);
void putInUpdatePurchasePrice(@Param("purchaseDetails") List<PurchaseDetail> purchaseDetails);
Stock getByProductIdAndAttributeList(@Param("productId") String productId, @Param("attributeList") String attributeList);
}

4
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/mapper/DebtMapper.java

@ -6,8 +6,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface DebtMapper extends BaseMapper<Debt> {
Page<Debt> getDebtByShopId(Page<QueryDebtVo> page, @Param("queryDebtVo") QueryDebtVo queryDebtVo);
Debt selectByUserId(@Param("shopId")String shopId, @Param("userId") String userId);
List<Debt> getDebtByUserIds(@Param("userIds") List<String> userIds);
}

19
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/DebtService.java

@ -5,6 +5,8 @@ import cc.hiver.mall.debt.vo.QueryDebtVo;
import cc.hiver.mall.pojo.dto.SaleQueryDTO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
public interface DebtService {
/**
@ -41,6 +43,21 @@ public interface DebtService {
*/
// void returnSaleToDebt(SaleQueryDTO saleQueryDTO);
// 回款20240610新回款
/**
* 根据客户或者供应商id获取欠款信息
* @author 王富康
* @date 2024/6/22
* @param userIds
* @return List<Debt>
*/
List<Debt> getDebtByUserIds(List<String> userIds);
/**
* 根据客户id获取欠款信息
* @author 王富康
* @date 2024/6/26
* @param userId
* @return Debt
*/
Debt selectByUserId(String userId);
}

22
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/impl/DebtServiceImpl.java

@ -23,6 +23,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@Service
public class DebtServiceImpl extends ServiceImpl<DebtMapper, Debt> implements DebtService {
@ -201,9 +202,18 @@ public class DebtServiceImpl extends ServiceImpl<DebtMapper, Debt> implements De
dealingsRecord.setDealingsWay("开单");
dealingsRecord.setShopId(shopId);
// 销售金额
dealingsRecord.setSaleAmount(saleQueryDTO.getSale().getTotalAmount());
if(!saleQueryDTO.getSaleDetailList().isEmpty()){
dealingsRecord.setSaleAmount(saleQueryDTO.getSale().getTotalAmount());
}else{
dealingsRecord.setSaleAmount(BigDecimal.valueOf(0));
}
// 退货金额
dealingsRecord.setReturnAmount(saleQueryDTO.getSaleReturnDTO().getReturnSale().getTotalAmount());
if(saleQueryDTO.getSaleReturnDTO() != null){
dealingsRecord.setReturnAmount(saleQueryDTO.getSaleReturnDTO().getReturnSale().getTotalAmount());
}else{
dealingsRecord.setReturnAmount(BigDecimal.valueOf(0));
}
// 上次欠款
dealingsRecord.setLastDebtAmount(lastDebtAmount);
// 最新欠款
@ -212,4 +222,12 @@ public class DebtServiceImpl extends ServiceImpl<DebtMapper, Debt> implements De
dealingsRecord.setDealingsType(DealingsRecordConstant.DEALINGS_TYPE[0]);
dealingsRecordService.save(dealingsRecord);
}
@Override
public List<Debt> getDebtByUserIds(List<String> userIds) {
return debtMapper.getDebtByUserIds(userIds);
}
public Debt selectByUserId(String userId){
return debtMapper.selectByUserId(securityUtil.getShopId(),userId);
}
}

201
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/ReturnDetail.java

@ -3,11 +3,13 @@ package cc.hiver.mall.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Data
@ApiModel(value = "退货单明细表")
@TableName(value = "t_return_detail", autoResultMap = true)
public class ReturnDetail implements Serializable {
@ -68,200 +70,11 @@ public class ReturnDetail implements Serializable {
@ApiModelProperty(value = "实际价格")
private BigDecimal realPrice;
private static final long serialVersionUID = 1L;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Integer getDelFlag() {
return delFlag;
}
public void setDelFlag(Integer delFlag) {
this.delFlag = delFlag;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getSaleId() {
return saleId;
}
public void setSaleId(String saleId) {
this.saleId = saleId;
}
public String getProductId() {
return productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public String getShopId() {
return shopId;
}
@ApiModelProperty(value = "商品图片")
private String productPicture;
public void setShopId(String shopId) {
this.shopId = shopId;
}
@ApiModelProperty(value = "货号")
private String productSn;
public String getCategoryId() {
return categoryId;
}
public void setCategoryId(String categoryId) {
this.categoryId = categoryId;
}
public String getAttributeList() {
return attributeList;
}
public void setAttributeList(String attributeList) {
this.attributeList = attributeList;
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
public BigDecimal getPurchasePrice() {
return purchasePrice;
}
public void setPurchasePrice(BigDecimal purchasePrice) {
this.purchasePrice = purchasePrice;
}
public BigDecimal getWholesalePrice() {
return wholesalePrice;
}
public void setWholesalePrice(BigDecimal wholesalePrice) {
this.wholesalePrice = wholesalePrice;
}
public Integer getProductCount() {
return productCount;
}
public void setProductCount(Integer productCount) {
this.productCount = productCount;
}
public BigDecimal getDiscount() {
return discount;
}
public void setDiscount(BigDecimal discount) {
this.discount = discount;
}
public BigDecimal getDiscountAmount() {
return discountAmount;
}
public void setDiscountAmount(BigDecimal discountAmount) {
this.discountAmount = discountAmount;
}
public BigDecimal getRealPrice() {
return realPrice;
}
public void setRealPrice(BigDecimal realPrice) {
this.realPrice = realPrice;
}
public String getReturnSaleId() {
return returnSaleId;
}
public void setReturnSaleId(String returnSaleId) {
this.returnSaleId = returnSaleId;
}
@Override
public String toString() {
return "ReturnDetail{" +
"id='" + id + '\'' +
", createBy='" + createBy + '\'' +
", createTime=" + createTime +
", delFlag=" + delFlag +
", updateBy='" + updateBy + '\'' +
", updateTime=" + updateTime +
", saleId='" + saleId + '\'' +
", returnSaleId='" + returnSaleId + '\'' +
", productId='" + productId + '\'' +
", productName='" + productName + '\'' +
", unit='" + unit + '\'' +
", shopId='" + shopId + '\'' +
", categoryId='" + categoryId + '\'' +
", attributeList='" + attributeList + '\'' +
", price=" + price +
", purchasePrice=" + purchasePrice +
", wholesalePrice=" + wholesalePrice +
", productCount=" + productCount +
", discount=" + discount +
", discountAmount=" + discountAmount +
", realPrice=" + realPrice +
'}';
}
private static final long serialVersionUID = 1L;
}

5
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Sale.java

@ -163,6 +163,11 @@ public class Sale implements Serializable {
@ApiModelProperty(value="退款数量")
private int returnSaleProductCount;
@Transient
@TableField(exist = false)
@ApiModelProperty(value="退款总金额")
private BigDecimal returnSaleTotalAmount;
@ApiModelProperty(value="欠款抵扣金额")
private BigDecimal debtDeductionAmount;

5
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Supplier.java

@ -1,6 +1,7 @@
package cc.hiver.mall.entity;
import cc.hiver.core.base.HiverBaseEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -42,4 +43,8 @@ public class Supplier extends HiverBaseEntity {
@ApiModelProperty(value = "供应商联系方式")
private String consigneeMobile;
@TableField(exist = false)
@ApiModelProperty(value = "欠款")
private String noEarn;
}

6
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/ReturnSaleDetailDTO.java

@ -60,6 +60,12 @@ public class ReturnSaleDetailDTO implements Serializable {
@ApiModelProperty(value = "实际价格")
private BigDecimal realPrice;
@ApiModelProperty(value = "商品图片")
private String productPicture;
@ApiModelProperty(value = "货号")
private String productSn;
private static final long serialVersionUID = 1L;

3
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/SaleDetailDTO.java

@ -16,6 +16,9 @@ public class SaleDetailDTO implements Serializable {
@ApiModelProperty(value = "销售单ID")
private String saleId;
@ApiModelProperty(value = "销售单明细ID")
private String detailId;
@ApiModelProperty(value = "商品ID")
private String productId;

42
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/ReturnSalePageQuery.java

@ -0,0 +1,42 @@
/*
Copyright [2022] [https://hiver.cc]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cc.hiver.mall.pojo.query;
import cc.hiver.core.base.HiverBasePageQuery;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 分享页查询对象
*
* @author 王富康
* @date 2023/10/14
*/
@ApiModel("分享页查询对象")
@Data
public class ReturnSalePageQuery extends HiverBasePageQuery {
@ApiModelProperty("商品ID")
private String productId;
@ApiModelProperty("开始时间")
private String startDate;
@ApiModelProperty("结束时间")
private String endDate;
}

6
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/CustomerBuyProductDetailLogVo.java

@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
@ApiModel(value = "客户商品购买记录")
@ -28,6 +29,9 @@ public class CustomerBuyProductDetailLogVo implements Serializable {
private Integer productCount;
@ApiModelProperty(value = "实际价格")
private Integer realPrice;
private BigDecimal realPrice;
@ApiModelProperty(value = "实际价格")
private BigDecimal purchasePrice;
}

4
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/CustomerBuyProductLogVo.java

@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
@Data
@ -22,6 +23,9 @@ public class CustomerBuyProductLogVo implements Serializable {
@ApiModelProperty(value = "商品货号")
private String productSn;
@ApiModelProperty(value = "采购价")
private BigDecimal purchasePrice;
@ApiModelProperty(value = "历次销售单")
private List<CustomerBuySaleVo> customerBuySaleVoList;
}

3
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/CustomerBuySaleVo.java

@ -22,6 +22,9 @@ public class CustomerBuySaleVo implements Serializable {
@ApiModelProperty(value = "销售时间")
private String realPrice;
@ApiModelProperty(value = "商品数量")
private String productCount;
@ApiModelProperty(value = "属性")
private List<CustomerBuyProductDetailLogVo> customerBuyProductDetailLogVos;
}

5
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductPageVO.java

@ -15,6 +15,7 @@ limitations under the License.
*/
package cc.hiver.mall.pojo.vo;
import cc.hiver.mall.productpicture.entity.ProductPicture;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -22,6 +23,7 @@ import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 商品分页查询对应Vo
@ -101,4 +103,7 @@ public class ProductPageVO {
@ApiModelProperty(value = "入库状态:0:待入库(未维护对应的采购价信息);1:已入库;新增商品时为已入库")
private Integer inStorageStatus;
@ApiModelProperty(value = "商品子图")
private List<ProductPicture> productPictures;
}

18
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ReturnSaleVo.java

@ -89,5 +89,23 @@ public class ReturnSaleVo extends HiverBasePageQuery implements Serializable {
@ApiModelProperty(value = "配送人员姓名")
private int workerName;
@ApiModelProperty(value = "开始时间")
private String startTime;
@ApiModelProperty(value = "结束时间")
private String endTime;
@ApiModelProperty(value = "退货金额")
private String returnAmount;
@ApiModelProperty(value = "之前欠款")
private String lastDebtAmount;
@ApiModelProperty(value = "欠款抵扣")
private String debtDeductionAmount;
@ApiModelProperty(value = "累计欠款")
private String balanceDue;
private static final long serialVersionUID = 1L;
}

8
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SaleNewVO.java

@ -1,10 +1,7 @@
package cc.hiver.mall.pojo.vo;
import cc.hiver.core.entity.LogiticsCompany;
import cc.hiver.mall.entity.Customer;
import cc.hiver.mall.entity.OrderXd;
import cc.hiver.mall.entity.Sale;
import cc.hiver.mall.entity.Shop;
import cc.hiver.mall.entity.*;
import cc.hiver.mall.pojo.dto.SaleDetailDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -35,4 +32,7 @@ public class SaleNewVO implements Serializable {
@ApiModelProperty(value = "店铺信息")
private Shop shop;
@ApiModelProperty(value = "本单的欠款交易记录")
private DealingsRecord dealingsRecord;
}

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/productpicture/mapper/ProductPictureMapper.java

@ -13,4 +13,6 @@ public interface ProductPictureMapper extends BaseMapper<ProductPicture> {
void batchSaveProductPicture(@Param("productPictures") List<ProductPicture> productPictures);
void deleteByProductId(@Param("productId") String productId);
List<ProductPicture> getProductPictureByProductIds(@Param("productIds") List<String> productIds);
}

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/productpicture/service/ProductPictureService.java

@ -7,8 +7,10 @@ import java.util.List;
public interface ProductPictureService extends IService<ProductPicture> {
List<ProductPicture> getProductPictureByProductId(String productId);
List<ProductPicture> getProductPictureByProductIds(List<String> productIds);
void batchSaveProductPicture(List<ProductPicture> productPictures);
void deleteByProductId(String productId);
}

5
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/productpicture/service/impl/ProductPictureServiceImpl.java

@ -19,6 +19,11 @@ public class ProductPictureServiceImpl extends ServiceImpl<ProductPictureMapper,
return productPictureMapper.getProductPictureByProductId(productId);
}
@Override
public List<ProductPicture> getProductPictureByProductIds(List<String> productIds) {
return productPictureMapper.getProductPictureByProductIds(productIds);
}
@Override
public void batchSaveProductPicture(List<ProductPicture> productPictures) {
productPictureMapper.batchSaveProductPicture(productPictures);

18
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchaseocr/service/impl/PurchaseOcrPictureServiceImpl.java

@ -45,7 +45,7 @@ import java.util.regex.Pattern;
public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService {
private static final Pattern productSn = Pattern.compile("货号");
private static final Pattern COMPILE = Pattern.compile("\\D+");
private static final Pattern COMPILE = Pattern.compile("-?\\d+");
private static final Pattern SYYS = Pattern.compile("所有颜色", Pattern.LITERAL);
private static final Pattern SYCM = Pattern.compile("所有尺码", Pattern.LITERAL);
@ -262,7 +262,7 @@ public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService
// 获取商品分类及规格信息
final List<String> categoryIdList = new ArrayList<>();
String attrId = product.getAttrId();
final String attrId = product.getAttrId();
categoryIdList.add(attrId);
final List<ProductCategoryVo> shopCategory = productCategoryService.getShopCategory(categoryIdList);
final ProductCategoryVo productCategoryVo = shopCategory.get(0);
@ -296,7 +296,12 @@ public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService
String color = attributeListObject.getString("color").toUpperCase();
String size = attributeListObject.getString("size").toUpperCase();
final String productCount1 = attributeListObject.getString("productCount");
final int productCount = Integer.parseInt(COMPILE.matcher(productCount1).replaceAll(""));
final Matcher countMatchered = COMPILE.matcher(productCount1);
String replaced = "";
if (countMatchered.find()) {
replaced = countMatchered.group();
}
final int productCount = Integer.parseInt(StringUtils.isEmpty(replaced) ? "0" : replaced);
// 20240330 只能新增颜色和尺码,颜色统一改为*色、尺码统一转大写,加‘码’;
// 根据规格id规格是颜色、还是尺码。
if (!color.contains("色")) {
@ -384,7 +389,12 @@ public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService
String color = attributeListObject.getString("color").toUpperCase();
String size = attributeListObject.getString("size").toUpperCase();
final String productCount1 = attributeListObject.getString("productCount");
final int productCount = Integer.parseInt(COMPILE.matcher(productCount1).replaceAll(""));
final Matcher countMatchered = COMPILE.matcher(productCount1);
String replaced = "";
if (countMatchered.find()) {
replaced = countMatchered.group();
}
final int productCount = Integer.parseInt(StringUtils.isEmpty(replaced) ? "0" : replaced);
// 20240330 只能新增颜色和尺码,颜色统一改为*色、尺码统一转大写,加‘码’;
// 根据规格id规格是颜色、还是尺码。
if (!color.contains("色")) {

8
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/DealingsRecordService.java

@ -20,4 +20,12 @@ public interface DealingsRecordService extends IService<DealingsRecord> {
* @date 2024/6/16
*/
List<DealingsRecord> getDealingsRecordListByUserId(String userId);
/**
* 作废交易记录
* @author 王富康
* @date 2024/6/26
* @param saleId
*/
void cancelRecord(String saleId);
}

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

@ -48,4 +48,24 @@ public interface ProductService extends IService<Product> {
void deleteProductByCategoryId(String categoryId);
SaleQueryDTO handleProduct(SaleQueryDTO saleQueryDTO);
/**
* 根据货品id批量上架货品
*
* @param ids
* @return boolean
* @author 王富康
* @date 2024/6/22
*/
boolean batchUp(String ids);
/**
* 根据货品id批量下架货品
*
* @param ids
* @return boolean
* @author 王富康
* @date 2024/6/22
*/
boolean batchDown(String ids);
}

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

@ -11,4 +11,6 @@ public interface ReturnDetailService extends IService<ReturnDetail> {
public List<String> selectByCondition1(QueryWrapper queryWrapper);
List<ReturnDetail> getReturnDetails(List<String> saleIdList);
}

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

@ -1,11 +1,23 @@
package cc.hiver.mall.service.mybatis;
import cc.hiver.mall.bill.vo.ArrearsVo;
import cc.hiver.mall.bill.vo.CustomerBillQueryVo;
import cc.hiver.mall.entity.ReturnSale;
import cc.hiver.mall.entity.Sale;
import cc.hiver.mall.pojo.dto.SaleReturnDTO;
import cc.hiver.mall.pojo.query.ReturnSalePageQuery;
import cc.hiver.mall.pojo.vo.ReturnSaleVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
public interface ReturnSaleService extends IService<ReturnSale> {
ReturnSale getBySaleId(String id);
IPage<ReturnSaleVo> getReturnSaleList(ReturnSaleVo returnSaleVo);
ArrearsVo getTotalReturn(CustomerBillQueryVo customerBillQueryVo);
Page<SaleReturnDTO> getReturnSaleListByProductId(ReturnSalePageQuery returnSalePageQuery);
}

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

@ -27,4 +27,6 @@ public interface SaleDetailService extends IService<SaleDetail> {
* @param purchaseDetails
*/
void putInUpdatePurchasePrice(List<PurchaseDetail> purchaseDetails);
List<SaleDetail> getSaleDetails(List<String> saleIdList);
}

19
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleService.java

@ -1,5 +1,8 @@
package cc.hiver.mall.service.mybatis;
import cc.hiver.mall.bill.vo.ArrearsVo;
import cc.hiver.mall.bill.vo.CustomerBillQueryVo;
import cc.hiver.mall.bill.vo.CustomerBillSaleVo;
import cc.hiver.mall.entity.Sale;
import cc.hiver.mall.pojo.query.SalePageQuery;
import cc.hiver.mall.pojo.query.SalesRankingQueryCriteria;
@ -69,4 +72,20 @@ public interface SaleService extends IService<Sale> {
* @date 2024/4/27
*/
void changeCompany(String saleId, String companyId);
/**
* 撤销销售单
* 1订单回退订单作废库存退回
* 2款项记录作废查询的时候也要关联deflag=0同时把款项回退当前欠款+欠款抵扣-余额抵扣-笨蛋欠款
* 3如果有退货退货表和detail作废同时把库存退回去
*
* @param id
* @author 王富康
* @date 2024/6/26
*/
void cancelSale(String id);
Page<CustomerBillSaleVo> getCustomerBill(CustomerBillQueryVo customerBillQueryVo);
ArrearsVo getArrearsAndTotalSale(CustomerBillQueryVo customerBillQueryVo);
}

4
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockService.java

@ -57,4 +57,8 @@ public interface StockService extends IService<Stock> {
* @return List<Stock>
*/
List<Stock> getProductStock(String productId);
List<Stock> getProductStock(List<String> productIds);
Stock getByProductIdAndAttributeList(String productId, String attributeList);
}

34
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ProductShareServiceImpl.java

@ -10,6 +10,8 @@ import cc.hiver.mall.pojo.query.ProductPageQuery;
import cc.hiver.mall.pojo.query.SharetPageQuery;
import cc.hiver.mall.pojo.vo.ProductPageVO;
import cc.hiver.mall.pojo.vo.ShareVO;
import cc.hiver.mall.productpicture.entity.ProductPicture;
import cc.hiver.mall.productpicture.service.ProductPictureService;
import cc.hiver.mall.service.ProductShareService;
import cc.hiver.mall.service.ShopService;
import cc.hiver.mall.service.mybatis.ProductService;
@ -18,8 +20,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.Map;
import java.util.*;
@Service
public class ProductShareServiceImpl implements ProductShareService {
@ -35,6 +36,9 @@ public class ProductShareServiceImpl implements ProductShareService {
@Autowired
private ShopService shopService;
@Autowired
private ProductPictureService productPictureService;
/**
* 新增分享链接
*
@ -92,6 +96,32 @@ public class ProductShareServiceImpl implements ProductShareService {
productPageQuery.setSearchStr(sharetPageQuery.getSearchStr());
// 获取商品信息
final IPage<ProductPageVO> shareList = productService.getShareList(productPageQuery);
// 获取商品的返回结果的商品信息id,后边获取商品子图
final List<String> productIds = new ArrayList<>();
for (ProductPageVO record : shareList.getRecords()) {
productIds.add(record.getId());
}
if(!productIds.isEmpty()){
// 封装商品子图
final List<ProductPicture> productPictureByProductIds = productPictureService.getProductPictureByProductIds(productIds);
// 将productPictureByProductIds封装为map,key为商品id,value为实体
final Map<String,List<ProductPicture>> productPictureMap = new HashMap<>();
for (ProductPicture productPictureByProductId : productPictureByProductIds) {
if (productPictureMap.containsKey(productPictureByProductId.getProductId())) {
final String productId = productPictureByProductId.getProductId();
final List<ProductPicture> productPictures = productPictureMap.get(productId);
productPictures.add(productPictureByProductId);
} else {
final List<ProductPicture> productPictures = new ArrayList<>();
productPictures.add(productPictureByProductId);
productPictureMap.put(productPictureByProductId.getProductId(),productPictures);
}
}
// 封装到实体中去。
shareList.getRecords().forEach(productPageVO -> {
productPageVO.setProductPictures(productPictureMap.get(productPageVO.getId()));
});
}
shareVO.setShareList(shareList);
return shareVO;
}

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesAndDetailsServiceImpl.java

@ -379,6 +379,8 @@ public class SalesAndDetailsServiceImpl implements SalesAndDetailsService {
returnSaleDetailDTO.setWholesalePrice(product.getWholesalePrice());
returnSaleDetailDTO.setPurchasePrice(product.getPurchasePrice());
returnSaleDetailDTO.setReturnSaleId(returnSaleId);
returnSaleDetailDTO.setProductPicture(product.getProductPicture());
returnSaleDetailDTO.setProductSn(product.getProductSn());
for(SaleDetailQueryDTO saleDetailQueryDTO : returnSaleDetailDTO.getStockLogList1()){
final ReturnDetail returnDetail = new ReturnDetail();
returnSaleDetailDTO.setAttributeList(saleDetailQueryDTO.getAttributeList());

3
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/StockAndLogServiceImpl.java

@ -140,6 +140,7 @@ public class StockAndLogServiceImpl implements StockAndLogService {
//以商品维度,如果没有库存反向插入一条负库存入库
stockLog.setChangeType("0");
stockLog.setOrderId(saleId);
stockLog.setDetailId(saleDetailDTO.getDetailId());
stockLog.setProductId(productId);
stockLog.setAttributeList(saleDetailQueryDTO.getAttributeList());
stockLog.setStock(stockCount);//出库前数量
@ -218,6 +219,7 @@ public class StockAndLogServiceImpl implements StockAndLogService {
//2.记录库存履历
final StockLog stockLog = new StockLog();
stockLog.setOrderId(saleDetailDTO.getSaleId());
stockLog.setChangeType("0");//以商品维度,如果没有库存反向插入一条正库存入库
stockLog.setProductId(productId);
stockLog.setAttributeList(saleDetailQueryDTO.getAttributeList());
@ -235,6 +237,7 @@ public class StockAndLogServiceImpl implements StockAndLogService {
//2.记录库存履历
final StockLog stockLog = new StockLog();
stockLog.setOrderId(saleDetailDTO.getSaleId());
stockLog.setChangeType("0");//出库
stockLog.setProductId(productId);
stockLog.setAttributeList(saleDetailQueryDTO.getAttributeList());

35
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SupplierServiceImpl.java

@ -4,6 +4,8 @@ import cc.hiver.core.base.HiverBaseDao;
import cc.hiver.core.common.constant.CommonConstant;
import cc.hiver.core.common.utils.QueryHelp;
import cc.hiver.mall.dao.SupplierDao;
import cc.hiver.mall.debt.entity.Debt;
import cc.hiver.mall.debt.service.DebtService;
import cc.hiver.mall.entity.Supplier;
import cc.hiver.mall.pojo.query.SupplierQueryCriteria;
import cc.hiver.mall.service.SupplierService;
@ -14,7 +16,11 @@ import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
@Slf4j
@Service
@ -23,6 +29,9 @@ public class SupplierServiceImpl implements SupplierService {
@Autowired
private SupplierDao supplierDao;
@Autowired
private DebtService debtService;
@Override
public HiverBaseDao<Supplier, String> getRepository() {
return supplierDao;
@ -32,13 +41,33 @@ public class SupplierServiceImpl implements SupplierService {
public Page<Supplier> queryAll(SupplierQueryCriteria criteria, Pageable pageable) {
// 添加未删除标记
criteria.setDelFlag(CommonConstant.DEL_FLAG_FALSE);
Page<Supplier> list = supplierDao.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
final Page<Supplier> list = supplierDao.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
// 添加欠款信息
// 获取供应商的id
final List<String> idList = new ArrayList<>();
list.forEach(supplier -> {
// 获取供应商的id
final String id = supplier.getId();
// 添加到id列表中
idList.add(id);
});
// 获取供应商的欠款信息
final List<Debt> debtByUserIds = debtService.getDebtByUserIds(idList);
// 变为map,key为userid,
final Map<String, Debt> debtMap = debtByUserIds.stream().collect(Collectors.toMap(Debt::getUserId, Function.identity()));
list.forEach(supplier -> {
final String id = supplier.getId();
final Debt debt = debtMap.get(id);
if (debt != null) {
supplier.setNoEarn(debt.getAmountOwed().toString());
}
});
return list;
}
@Override
public List<Supplier> getbyShopId(String shopId,String searchStr) {
return supplierDao.getbyShopId(shopId,searchStr);
public List<Supplier> getbyShopId(String shopId, String searchStr) {
return supplierDao.getbyShopId(shopId, searchStr);
}
@Override

11
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/DealingsRecordServiceImpl.java

@ -49,4 +49,15 @@ public class DealingsRecordServiceImpl extends ServiceImpl<DealingsRecordMapper,
return dealingsRecordMapper.getDealingsRecordListByUserId(userId, shopId);
}
/**
* 作废交易记录
* @author 王富康
* @date 2024/6/26
* @param saleId
*/
@Override
public void cancelRecord(String saleId) {
dealingsRecordMapper.cancelRecord(saleId);
}
}

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductCategoryServiceImpl.java

@ -248,7 +248,7 @@ public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMappe
// 查询规格
final List<ProductAttributeOfAddVo> productAttributeOfAddVos = productAttributeService.selectAttributeListByCategoryId(categoryIdList);
final List<String> attributeIds = new ArrayList<>();
final Map<String, ProductAttributeOfAddVo> productAttributeOfAddVoMap = new HashMap<>();
final Map<String, ProductAttributeOfAddVo> productAttributeOfAddVoMap = new LinkedHashMap<>();
for (ProductAttributeOfAddVo productAttributeOfAddVo : productAttributeOfAddVos) {
attributeIds.add(productAttributeOfAddVo.getAttributeId());
productAttributeOfAddVoMap.put(productAttributeOfAddVo.getAttributeId(), productAttributeOfAddVo);

63
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java

@ -160,7 +160,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
// 放到要查询的id中
// 填充前台传过来的数据
saleDetailDTO.setProductId(product.getId());
if(saleDetailDTO.getProductPictures() != null ){
if (saleDetailDTO.getProductPictures() != null) {
// 新增商品图片子图
for (ProductPicture productPicture : saleDetailDTO.getProductPictures()) {
productPicture.setProductId(product.getId());
@ -175,7 +175,22 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
final JSONObject jsonObject = JSONUtil.parseObj(attributeList);
for (Map.Entry<String, Object> stringObjectEntry : jsonObject.entrySet()) {
final String key = stringObjectEntry.getKey();
final String value = String.valueOf(stringObjectEntry.getValue());
String value = String.valueOf(stringObjectEntry.getValue());
// 根据规格id规格是颜色、还是尺码。
if ("颜色".equals(key)) {
if (!value.contains("色")) {
value += '色';
}
} else if ("尺码".equals(key)) {
final String valueUpperCase = value.toUpperCase();
if (value.contains("码")) {
value = valueUpperCase;
} else {
value = valueUpperCase + '码';
}
} else {
// 暂不支持其他规格
}
if (attributeValueMap.containsKey(key)) {
final List<String> strings = attributeValueMap.get(key);
if (!strings.contains(value)) {
@ -213,14 +228,54 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
addProductList.add(product);
}
}
if(!addProductList.isEmpty()){
if (!addProductList.isEmpty()) {
// 批量插入商品
productMapper.batchSaveProduct(addProductList);
}
if(!addProductPictureList.isEmpty()){
if (!addProductPictureList.isEmpty()) {
// 批量插入商品图片
productPictureService.batchSaveProductPicture(addProductPictureList);
}
return saleQueryDTO;
}
/**
* 根据货品id批量上架货品
*
* @param ids
* @return boolean
* @author 王富康
* @date 2024/6/22
*/
@Override
public boolean batchUp(String ids) {
// ids 逗号分隔转为list
try {
final List<String> idList = Arrays.asList(ids.split(","));
productMapper.batchUpdateDelFlag(idList, ProductConstant.DEL_FLAG[1]);
return true;
} catch (Exception e) {
return false;
}
}
/**
* 根据货品id批量下架货品
*
* @param ids
* @return boolean
* @author 王富康
* @date 2024/6/22
*/
@Override
public boolean batchDown(String ids) {
// ids 逗号分隔转为list
try {
final List<String> idList = Arrays.asList(ids.split(","));
productMapper.batchUpdateDelFlag(idList, ProductConstant.DEL_FLAG[0]);
return true;
} catch (Exception e) {
return false;
}
}
}

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

@ -1,12 +1,8 @@
package cc.hiver.mall.serviceimpl.mybatis;
import cc.hiver.mall.dao.mapper.ReturnDetailMapper;
import cc.hiver.mall.dao.mapper.ReturnSaleMapper;
import cc.hiver.mall.dao.mapper.SaleDetailMapper;
import cc.hiver.mall.entity.ReturnDetail;
import cc.hiver.mall.entity.SaleDetail;
import cc.hiver.mall.service.mybatis.ReturnDetailService;
import cc.hiver.mall.service.mybatis.SaleDetailService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
@ -26,4 +22,9 @@ public class ReturnDetailServiceImpl extends ServiceImpl<ReturnDetailMapper, Ret
List<String> list = returnDetailMapper.selectObjs(queryWrapper);
return list;
}
@Override
public List<ReturnDetail> getReturnDetails(List<String> saleIdList) {
return returnDetailMapper.getReturnDetails(saleIdList);
}
}

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

@ -1,15 +1,23 @@
package cc.hiver.mall.serviceimpl.mybatis;
import cc.hiver.mall.bill.vo.ArrearsVo;
import cc.hiver.mall.bill.vo.CustomerBillQueryVo;
import cc.hiver.mall.dao.mapper.ReturnSaleMapper;
import cc.hiver.mall.dao.mapper.SaleMapper;
import cc.hiver.mall.entity.ReturnSale;
import cc.hiver.mall.entity.Sale;
import cc.hiver.mall.pojo.dto.SaleReturnDTO;
import cc.hiver.mall.pojo.query.ReturnSalePageQuery;
import cc.hiver.mall.pojo.vo.ReturnSaleVo;
import cc.hiver.mall.service.mybatis.ReturnSaleService;
import cc.hiver.mall.service.mybatis.SaleService;
import cc.hiver.mall.utils.DateUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ReturnSaleServiceImpl extends ServiceImpl<ReturnSaleMapper, ReturnSale> implements ReturnSaleService {
@ -20,4 +28,31 @@ public class ReturnSaleServiceImpl extends ServiceImpl<ReturnSaleMapper, ReturnS
public ReturnSale getBySaleId(String id) {
return returnSaleMapper.getBySaleId(id);
}
@Override
public IPage<ReturnSaleVo> getReturnSaleList(ReturnSaleVo returnSaleVo) {
final Page<ReturnSaleVo> page = new Page<>(returnSaleVo.getPageNum(), returnSaleVo.getPageSize());
if(StringUtils.isNotEmpty(returnSaleVo.getEndTime())){
// 日期加一天
returnSaleVo.setEndTime(DateUtil.addDay(returnSaleVo.getEndTime(), 1));
}
final List<ReturnSaleVo> list = returnSaleMapper.getReturnSaleList(page, returnSaleVo);
page.setRecords(list);
return page;
}
@Override
public ArrearsVo getTotalReturn(CustomerBillQueryVo customerBillQueryVo) {
return returnSaleMapper.getTotalReturn(customerBillQueryVo);
}
@Override
public Page<SaleReturnDTO> getReturnSaleListByProductId(ReturnSalePageQuery returnSalePageQuery) {
final Page<SaleReturnDTO> page = new Page<>(returnSalePageQuery.getPageNum(), returnSalePageQuery.getPageSize());
final Page<SaleReturnDTO> salePage = returnSaleMapper.getReturnSaleListByProductId(page, returnSalePageQuery.getProductId());
final List<SaleReturnDTO> saleList = salePage.getRecords();
return null;
}
}

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

@ -66,4 +66,9 @@ public class SaleDetailServiceImpl extends ServiceImpl<SaleDetailMapper, SaleDet
stockMapper.putInUpdatePurchasePrice(purchaseDetails);
stockLogMapper.putInUpdatePurchasePrice(purchaseDetails);
}
@Override
public List<SaleDetail> getSaleDetails(List<String> saleIdList) {
return saleDetailMapper.getSaleDetails(saleIdList);
}
}

165
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java

@ -1,5 +1,6 @@
package cc.hiver.mall.serviceimpl.mybatis;
import cc.hiver.core.common.constant.CommonConstant;
import cc.hiver.core.common.constant.DealingsRecordConstant;
import cc.hiver.core.common.constant.SaleConstant;
import cc.hiver.core.common.utils.CommonUtil;
@ -9,9 +10,15 @@ import cc.hiver.core.common.utils.ThreadPoolUtil;
import cc.hiver.core.entity.LogiticsCompany;
import cc.hiver.core.entity.User;
import cc.hiver.core.service.LogiticsCompanyService;
import cc.hiver.mall.bill.vo.ArrearsVo;
import cc.hiver.mall.bill.vo.CustomerBillQueryVo;
import cc.hiver.mall.bill.vo.CustomerBillSaleVo;
import cc.hiver.mall.common.constant.StockConstant;
import cc.hiver.mall.common.constant.StockLogConstant;
import cc.hiver.mall.config.thread.AiSaleThread;
import cc.hiver.mall.dao.mapper.SaleMapper;
import cc.hiver.mall.debt.entity.Debt;
import cc.hiver.mall.debt.service.DebtService;
import cc.hiver.mall.deductlog.service.DeductLogService;
import cc.hiver.mall.entity.*;
import cc.hiver.mall.pojo.dto.SaleDetailDTO;
@ -93,6 +100,12 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
@Autowired
private OrderService orderService;
@Autowired
private StockLogService stockLogService;
@Autowired
private DebtService debtService;
@Override
public void editPayPrice(String id, BigDecimal price, String dealingsWay) {
// 修改采购单、实付、未付金额
@ -195,8 +208,10 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
saleDetailDTO.setDiscountAmount(saleDetail.getDiscountAmount());
saleDetailDTO.setRealPrice(saleDetail.getRealPrice());
// 回填商品的的图片及货号
saleDetailDTO.setProductPicture(productMap.get(productId).getProductPicture());
saleDetailDTO.setProductSn(productMap.get(productId).getProductSn());
if (productMap.containsKey(productId)) {
saleDetailDTO.setProductPicture(productMap.get(productId).getProductPicture());
saleDetailDTO.setProductSn(productMap.get(productId).getProductSn());
}
final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO();
saleDetailQueryDTO.setAttributeList(saleDetail.getAttributeList());
@ -395,6 +410,13 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
allMap.put(productId, stringListMap);
}
}
// 获取商品的信息
final List<Product> productList = productService.getProductList(productIds);
final Map<String, Product> productMap = new HashMap<>();
for (Product product : productList) {
productMap.put(product.getId(), product);
}
for (CustomerBuyProductLogVo record : records) {
final String productId = record.getProductId();
if (allMap.containsKey(productId)) {
@ -418,6 +440,9 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
}
}
}
if (productMap.containsKey(record.getProductId())) {
record.setPurchasePrice(productMap.get(record.getProductId()).getPurchasePrice());
}
}
}
// 封装到商品中
@ -695,16 +720,16 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
continue;
}
if ("SYCM码".equals(size)) {
// 所有尺码,固定颜色
for (ProductAttributeValueVo attributeValueVo : sizeProductAttributeValueVoList) {
final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO();
final String attribute = "{\"颜色\":\"" + color + "\",\"尺码\":\"" + attributeValueVo.getValue() + "\"}";
saleDetailQueryDTO.setAttributeList(attribute);
saleDetailQueryDTO.setProductCount(productCount);
saleDetailQueryDTO.setStockCount(stockMap.getOrDefault(attribute, null));
saleDetailDTO.setProductCount(saleDetailDTO.getProductCount() + productCount);
saleDetailQueryDTOS.add(saleDetailQueryDTO);
}
// 所有尺码,固定颜色
for (ProductAttributeValueVo attributeValueVo : sizeProductAttributeValueVoList) {
final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO();
final String attribute = "{\"颜色\":\"" + color + "\",\"尺码\":\"" + attributeValueVo.getValue() + "\"}";
saleDetailQueryDTO.setAttributeList(attribute);
saleDetailQueryDTO.setProductCount(productCount);
saleDetailQueryDTO.setStockCount(stockMap.getOrDefault(attribute, null));
saleDetailDTO.setProductCount(saleDetailDTO.getProductCount() + productCount);
saleDetailQueryDTOS.add(saleDetailQueryDTO);
}
continue;
}
@ -808,6 +833,122 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
saleMapper.updateById(sale);
}
/**
* 撤销销售单
* 1订单回退订单作废库存退回
* 2款项记录作废查询的时候也要关联deflag=0同时把款项回退当前欠款+欠款抵扣-余额抵扣-笨蛋欠款
* 3如果有退货退货表和detail作废同时把库存退回去
*
* @param id
* @author 王富康
* @date 2024/6/26
*/
@Override
public void cancelSale(String id) {
// 1. 修改订单状态为作废
final Sale sale = saleMapper.selectById(id);
sale.setStatus(SaleConstant.SALE_STATUS[2]);
saleService.updateById(sale);
// 2. 如果有退货单,那么退货单作废
// 根据订单id获取退货单
final ReturnSale bySaleId = returnSaleService.getBySaleId(id);
if (bySaleId != null) {
// 退货单作废
bySaleId.setStatus(SaleConstant.SALE_STATUS[8]);
returnSaleService.saveOrUpdate(bySaleId);
}
// 3.库存回退
final List<StockLog> stockLogs = stockLogService.getByPurchaseId(id);
// 退还库存,并记录履历
// 拿到所有商品的库存
final List<String> productIds = new ArrayList<>();
for (StockLog stockLog : stockLogs) {
// 这个时候库存中肯定有这个商品规格的库存数,直接根据商品id和规格查询库存。
final String productId = stockLog.getProductId();
productIds.add(productId);
}
final List<Stock> productStock = stockService.getProductStock(productIds);
// 商品id为键,规格为值
final Map<String, Map<String, Stock>> productStockMap = new HashMap<>();
for (Stock stock : productStock) {
final String productId = stock.getProductId();
if (productStockMap.containsKey(productId)) {
final Map<String, Stock> stockMap = productStockMap.get(productId);
stockMap.put(stock.getAttributeList(), stock);
} else {
final Map<String, Stock> attributeListMap = new HashMap<>();
attributeListMap.put(stock.getAttributeList(), stock);
productStockMap.put(productId, attributeListMap);
}
}
final List<Stock> changeStockList = new ArrayList<>();
for (StockLog stockLog : stockLogs) {
stockLog.setDelFlag(CommonConstant.DEL_FLAG_TRUE);
final String productId = stockLog.getProductId();
final String attributeList = stockLog.getAttributeList();
// 出入库类型(0-入库;1-出库)
final String changeType = stockLog.getChangeType();
if (productStockMap.containsKey(productId)) {
if (productStockMap.get(productId).containsKey(attributeList)) {
final Stock stock = productStockMap.get(productId).get(attributeList);
final Integer stockCount = stock.getStockCount();
final Integer productCount = stockLog.getProductCount();
if (StockLogConstant.CHANGE_TYPE[0].equals(changeType)) {
// 入库
stock.setStockCount(stockCount - productCount);
} else {
// 出库
stock.setStockCount(stockCount + productCount);
}
stock.setStockCount(stockCount + productCount);
changeStockList.add(stock);
}
}
}
// 批量更新库存
stockService.updateBatchById(changeStockList);
// 批量作废库存履历
stockLogService.saveOrUpdateBatch(stockLogs);
// 4. 订单款项记录作废
// 根据订单获取交易记录
final String userId = sale.getUserId();
final Debt oldDebt = debtService.selectByUserId(userId);
if(oldDebt != null){
final BigDecimal newDebtAmount;
// 欠款抵扣,需要单独从欠款中减掉
final BigDecimal debtDeductionAmount = sale.getDebtDeductionAmount() == null ? BigDecimal.valueOf(0) : sale.getDebtDeductionAmount();
// 余额抵扣,需要从欠款中减掉
final BigDecimal balanceDeductionAmount = sale.getBalanceDeductionAmount() == null ? BigDecimal.valueOf(0) : sale.getBalanceDeductionAmount();
// 本单欠款
final BigDecimal noEarn = sale.getNoEarn() == null ? BigDecimal.valueOf(0) : sale.getNoEarn();
// 计算欠款
newDebtAmount = oldDebt.getAmountOwed().subtract(noEarn).add(debtDeductionAmount).subtract(balanceDeductionAmount);
oldDebt.setAmountOwed(newDebtAmount);
debtService.saveOrUpdateDebt(oldDebt);
}
// 作废当前订单的欠款记录
dealingsRecordService.cancelRecord(id);
}
@Override
public Page<CustomerBillSaleVo> getCustomerBill(CustomerBillQueryVo customerBillQueryVo) {
final Page<CustomerBillSaleVo> page = new Page<>(customerBillQueryVo.getPageNum(), customerBillQueryVo.getPageSize());
//结束时间-1天
if (StringUtils.isNotEmpty(customerBillQueryVo.getEndDate())) {
final String endDate = DateUtil.addDay(customerBillQueryVo.getEndDate(), 1);
customerBillQueryVo.setEndDate(endDate);
}
final Page<CustomerBillSaleVo> customerBillSaleVoPage = saleMapper.getCustomerBill(page, customerBillQueryVo);
return customerBillSaleVoPage;
}
@Override
public ArrearsVo getArrearsAndTotalSale(CustomerBillQueryVo customerBillQueryVo) {
return saleMapper.getArrearsAndTotalSale(customerBillQueryVo);
}
/**
* 使用正则表达式替换输入字符串中连续的字符为相应数量的X字符
*

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

@ -570,10 +570,14 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
for (Stock stock : stockList) {
final Product product = productMap.get(stock.getProductId());
if(!productMap.containsKey(stock.getProductId())){
// 如果没有商品信息那么就进行下一个循环,暂时不计算该商品的采购价及其他信息
continue;
}
// 商品的库存预警
final Integer tailWarn = product.getTailWarn();
//平均采购价
final BigDecimal purchasePrice = product.getPurchasePrice();
final BigDecimal purchasePrice = product.getPurchasePrice() == null ? new BigDecimal(0) : product.getPurchasePrice();
final Integer thisStockCount = stock.getStockCount();
// 计算成本,负数按0计算
if (thisStockCount > 0) {
@ -673,6 +677,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
// Ai已经生成了入库单主表信息
final Purchase purchase = purchaseVo.getPurchase();
purchase.setCreateByName(user.getNickname());
purchase.setShopId(shopId);
final String purchaseId = purchase.getId();
// 先根据入库单id 删除详情及库存履历表信息
@ -744,7 +749,22 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
final JSONObject jsonObject = JSON.parseObject(attributeList);
for (Map.Entry<String, Object> stringObjectEntry : jsonObject.entrySet()) {
final String key = stringObjectEntry.getKey();
final String value = String.valueOf(stringObjectEntry.getValue());
String value = String.valueOf(stringObjectEntry.getValue());
// 根据规格id规格是颜色、还是尺码。
if ("颜色".equals(key)) {
if (!value.contains("色")) {
value += '色';
}
} else if ("尺码".equals(key)) {
final String valueUpperCase = value.toUpperCase();
if (value.contains("码")) {
value = valueUpperCase;
} else {
value = valueUpperCase + '码';
}
} else {
// 暂不支持其他规格
}
if (attributeValueMap.containsKey(key)) {
final List<String> strings = attributeValueMap.get(key);
if (!strings.contains(value)) {
@ -1059,4 +1079,14 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
public List<Stock> getProductStock(String productId) {
return stockMapper.getProductStock(productId);
}
@Override
public List<Stock> getProductStock(List<String> productIds) {
return stockMapper.getProductsStock(productIds);
}
@Override
public Stock getByProductIdAndAttributeList(String productId, String attributeList) {
return stockMapper.getByProductIdAndAttributeList(productId,attributeList);
}
}

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

@ -118,4 +118,10 @@
order by create_time desc
</select>
<!-- cancelRecord-->
<update id="cancelRecord">
update t_dealings_record
set del_flag = 1
where sale_id = #{saleId}
</update>
</mapper>

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

@ -40,4 +40,15 @@
and shop_id = #{shopId,jdbcType=VARCHAR}
and user_id = #{userId,jdbcType=VARCHAR}
</select>
<select id="getDebtByUserIds" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_debt
where del_flag = 0
and user_id in
<foreach close=")" collection="userIds" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</select>
</mapper>

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

@ -286,6 +286,12 @@
<foreach close=")" collection="categoryIdList" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
order by
case
attribute_name
when '颜色' then 1
when '尺码' then 2
else 3 end ,create_time ,create_time
</select>
<delete id="deleteByCategoryId" parameterType="java.lang.String">

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

@ -747,4 +747,13 @@
</foreach>
</insert>
<update id="batchUpdateDelFlag" >
update t_product
set del_flag = #{delFlag,jdbcType=INTEGER}
where id in
<foreach close=")" collection="idList" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</update>
</mapper>

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

@ -25,6 +25,18 @@
and product_id = #{productId,jdbcType=VARCHAR}
</select>
<!--根据商品id查询商品子图-->
<select id="getProductPictureByProductIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_product_picture
where del_flag = 0
and product_id in
<foreach close=")" collection="productIds" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</select>
<!--批量新增商品子图-->
<insert id="batchSaveProductPicture" parameterType="java.util.List">
insert into t_product_picture (id, create_by, create_time, del_flag, update_by, update_time,product_id, product_picture) values

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

@ -22,6 +22,9 @@
<result column="discount" jdbcType="DECIMAL" property="discount" />
<result column="discount_amount" jdbcType="DECIMAL" property="discountAmount" />
<result column="real_price" jdbcType="DECIMAL" property="realPrice" />
<result column="return_sale_id" jdbcType="VARCHAR" property="returnSaleId" />
<result column="product_picture" jdbcType="VARCHAR" property="productPicture" />
<result column="product_sn" jdbcType="VARCHAR" property="productSn" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -84,7 +87,8 @@
<sql id="Base_Column_List">
id, create_by, create_time, del_flag, update_by, update_time, sale_id, product_id,
product_name, unit, shop_id, category_id, attribute_list, price, purchase_price,
wholesale_price, product_count, discount, discount_amount, real_price
wholesale_price, product_count, discount, discount_amount, real_price, return_sale_id,
product_picture, product_sn
</sql>
<select id="selectByExample" parameterType="cc.hiver.mall.entity.ReturnDetailExample" resultMap="BaseResultMap">
select
@ -123,14 +127,15 @@
unit, shop_id, category_id,
attribute_list, price, purchase_price,
wholesale_price, product_count, discount,
discount_amount, real_price,return_sale_id)
discount_amount, real_price,return_sale_id,product_picture,product_sn)
values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
#{saleId,jdbcType=VARCHAR}, #{productId,jdbcType=VARCHAR}, #{productName,jdbcType=VARCHAR},
#{unit,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR}, #{categoryId,jdbcType=VARCHAR},
#{attributeList,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL}, #{purchasePrice,jdbcType=DECIMAL},
#{wholesalePrice,jdbcType=DECIMAL}, #{productCount,jdbcType=INTEGER}, #{discount,jdbcType=DECIMAL},
#{discountAmount,jdbcType=DECIMAL}, #{realPrice,jdbcType=DECIMAL},#{returnSaleId,jdbcType=VARCHAR})
#{discountAmount,jdbcType=DECIMAL}, #{realPrice,jdbcType=DECIMAL},#{returnSaleId,jdbcType=VARCHAR},
#{productPicture,jdbcType=VARCHAR},#{productSn,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="cc.hiver.mall.entity.ReturnDetail">
insert into t_return_detail
@ -195,6 +200,15 @@
<if test="realPrice != null">
real_price,
</if>
<if test="returnSaleId != null">
return_sale_id,
</if>
<if test="productPicture != null">
product_picture,
</if>
<if test="productSn != null">
product_sn,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -257,6 +271,15 @@
<if test="realPrice != null">
#{realPrice,jdbcType=DECIMAL},
</if>
<if test="returnSaleId != null">
#{returnSaleId,jdbcType=VARCHAR},
</if>
<if test="productPicture != null">
#{productPicture,jdbcType=VARCHAR},
</if>
<if test="productSn != null">
#{productSn,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="cc.hiver.mall.entity.ReturnDetailExample" resultType="java.lang.Long">
@ -328,6 +351,15 @@
<if test="record.realPrice != null">
real_price = #{record.realPrice,jdbcType=DECIMAL},
</if>
<if test="record.returnSaleId != null">
return_sale_id = #{record.returnSaleId,jdbcType=VARCHAR},
</if>
<if test="record.productPicture != null">
product_picture = #{record.productPicture,jdbcType=VARCHAR},
</if>
<if test="record.productSn != null">
product_sn = #{record.productSn,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -354,7 +386,10 @@
product_count = #{record.productCount,jdbcType=INTEGER},
discount = #{record.discount,jdbcType=DECIMAL},
discount_amount = #{record.discountAmount,jdbcType=DECIMAL},
real_price = #{record.realPrice,jdbcType=DECIMAL}
real_price = #{record.realPrice,jdbcType=DECIMAL},
return_sale_id = #{record.returnSaleId,jdbcType=VARCHAR},
product_picture = #{record.productPicture,jdbcType=VARCHAR},
product_sn = #{record.productSn,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -419,6 +454,15 @@
<if test="realPrice != null">
real_price = #{realPrice,jdbcType=DECIMAL},
</if>
<if test="returnSaleId != null">
return_sale_id = #{returnSaleId,jdbcType=VARCHAR},
</if>
<if test="productPicture != null">
product_picture = #{productPicture,jdbcType=VARCHAR},
</if>
<if test="productSn != null">
product_sn = #{productSn,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -442,7 +486,20 @@
product_count = #{productCount,jdbcType=INTEGER},
discount = #{discount,jdbcType=DECIMAL},
discount_amount = #{discountAmount,jdbcType=DECIMAL},
real_price = #{realPrice,jdbcType=DECIMAL}
real_price = #{realPrice,jdbcType=DECIMAL},
return_sale_id = #{returnSaleId,jdbcType=VARCHAR},
product_picture = #{productPicture,jdbcType=VARCHAR},
product_sn = #{productSn,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<select id="getReturnDetails" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_return_detail
where sale_id in
<foreach close=")" collection="saleIdList" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</select>
</mapper>

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

@ -26,6 +26,9 @@
<result column="province" jdbcType="VARCHAR" property="province" />
<result column="city" jdbcType="VARCHAR" property="city" />
<result column="area" jdbcType="VARCHAR" property="area" />
<result column="trans_company" jdbcType="VARCHAR" property="transCompany" />
<result column="trans_company_name" jdbcType="VARCHAR" property="transCompanyName" />
<result column="product_count" jdbcType="INTEGER" property="productCount" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -88,7 +91,8 @@
<sql id="Base_Column_List">
id, sale_id, create_by, create_time, del_flag, update_by, update_time, user_id,user_name, shop_id,
total_amount, discount, discount_amount, real_amount, already_earn, no_earn, pay_status,
status, transport_type, share_address, receive_address, province, city, area
status, transport_type, share_address, receive_address, province, city, area, trans_company,
trans_company_name, product_count
</sql>
<select id="selectByExample" parameterType="cc.hiver.mall.entity.ReturnSaleExample" resultMap="BaseResultMap">
select
@ -128,7 +132,7 @@
real_amount, already_earn, no_earn,
pay_status, status, transport_type,
share_address, receive_address, province,
city, area)
city, area,trans_company, trans_company_name, product_count)
values (#{id,jdbcType=VARCHAR}, #{saleId,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR},
#{updateTime,jdbcType=TIMESTAMP}, #{userId,jdbcType=VARCHAR},#{userName,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR},
@ -136,7 +140,7 @@
#{realAmount,jdbcType=DECIMAL}, #{alreadyEarn,jdbcType=DECIMAL}, #{noEarn,jdbcType=DECIMAL},
#{payStatus,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{transportType,jdbcType=VARCHAR},
#{shareAddress,jdbcType=VARCHAR}, #{receiveAddress,jdbcType=VARCHAR}, #{province,jdbcType=VARCHAR},
#{city,jdbcType=VARCHAR}, #{area,jdbcType=VARCHAR})
#{city,jdbcType=VARCHAR}, #{area,jdbcType=VARCHAR},#{transCompany,jdbcType=VARCHAR}, #{transCompanyName,jdbcType=VARCHAR}, #{productCount,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="cc.hiver.mall.entity.ReturnSale">
insert into t_return_sale
@ -397,7 +401,10 @@
receive_address = #{record.receiveAddress,jdbcType=VARCHAR},
province = #{record.province,jdbcType=VARCHAR},
city = #{record.city,jdbcType=VARCHAR},
area = #{record.area,jdbcType=VARCHAR}
area = #{record.area,jdbcType=VARCHAR},
trans_company = #{record.transCompany,jdbcType=VARCHAR},
trans_company_name = #{record.transCompanyName,jdbcType=VARCHAR},
product_count = #{record.productCount,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -501,7 +508,10 @@
receive_address = #{receiveAddress,jdbcType=VARCHAR},
province = #{province,jdbcType=VARCHAR},
city = #{city,jdbcType=VARCHAR},
area = #{area,jdbcType=VARCHAR}
area = #{area,jdbcType=VARCHAR},
trans_company = #{transCompany,jdbcType=VARCHAR},
trans_company_name = #{transCompanyName,jdbcType=VARCHAR},
product_count = #{productCount,jdbcType=INTEGER}
where id = #{id,jdbcType=VARCHAR}
</update>
<select id="saleSumAndCount" parameterType="cc.hiver.mall.entity.ReturnSaleExample" resultType="cc.hiver.mall.pojo.vo.SaleAllVO">
@ -523,4 +533,90 @@
from t_return_sale
where sale_id = #{id,jdbcType=VARCHAR}
</select>
<select id="getReturnSaleList" parameterType="cc.hiver.mall.pojo.vo.ReturnSaleVo" resultType="cc.hiver.mall.pojo.vo.ReturnSaleVo">
select
trs.id,trs.sale_id,trs.create_by,trs.create_time,trs.del_flag,trs.update_by,trs.update_time,trs.user_id,user_name,trs.shop_id,
trs.total_amount,trs.discount,trs.discount_amount,trs.real_amount,trs.already_earn,trs.no_earn,trs.pay_status,
trs.status,trs.transport_type,trs.share_address,trs.receive_address,trs.province,trs.city,trs.area,
tdr.return_amount,
tdr.last_debt_amount,
ts.debt_deduction_amount,
ts.no_earn,
tdr.balance_due
from
t_return_sale trs
left join t_sale ts on trs.sale_id = ts.id
left join t_dealings_record tdr ON trs.sale_id = tdr.sale_id
<where>
<!--已上架的-->
and trs.del_flag = '0'
<!-- 店铺ID-->
and trs.shop_id = #{queryParams.shopId,jdbcType=VARCHAR}
<if test="queryParams != null">
<!--阶段日期-->
<if test="queryParams.startTime != null and queryPatams.endTime != null">
and trs.create_time BETWEEN #{queryParams.startTime,jdbcType=VARCHAR} AND #{queryParams.endTime,jdbcType=VARCHAR}
</if>
<!--操作人-->
<if test="queryParams.createByName != null">
and create_by_name like concat('%',#{queryParams.createByName,jdbcType=VARCHAR},'%')
</if>
<!--客户名称模糊匹配-->
<if test="queryParams.userName != null">
and user_name like concat('%',#{queryParams.userName,jdbcType=VARCHAR},'%')
</if>
<!--客户id精准匹配-->
<if test="queryParams.userId != null">
and user_id = #{queryParams.userId,jdbcType=VARCHAR}
</if>
</if>
</where>
<!--根据创建时间倒序-->
order by trs.create_time desc
</select>
<select id="getTotalReturn" resultType="cc.hiver.mall.bill.vo.ArrearsVo">
select
sum(ts.total_amount) as total_return
from
t_return_sale ts
WHERE
ts.user_id = #{customerBillQueryVo.customerId}
<!--订单状态不为:02:退货已作废-->
and ts.status not in ( '02' )
<if test='customerBillQueryVo.startDate !=null and customerBillQueryVo.endDate !=null'>
and ts.create_time BETWEEN #{customerBillQueryVo.startDate} AND #{customerBillQueryVo.endDate}
</if>
order by ts.create_time asc
</select>
<select id="getReturnSaleListByProductId" resultMap="BaseResultMap">
select
ts.id,ts.create_by,ts.create_by_name,ts.create_time,ts.del_flag,ts.update_by,ts.update_by_name,ts.update_time,ts.user_id,ts.user_name,
ts.shop_id,ts.shop_name,ts.total_amount,ts.discount,ts.discount_amount,ts.real_amount,ts.debt_deduction_amount,ts.sale_deduction_amount,ts.balance_deduction_amount ,ts.already_earn,ts.no_earn,ts.pay_status,
ts.pay_type,ts.status,ts.other_expense,ts.transport_type,ts.share_address,ts.receive_address,ts.province,ts.city,ts.area,
ts.trans_company,ts.company_name,ts.product_count,ts.remark,ts.sale_name,ts.company_phone,ts.create_by_phone,ts.mode_of_service,
ts.ai_flag,ts.ai_result,ts.ai_not_recognition,
ss.return_sale_product_count,ss.return_sale_amount
from
t_sale ts
left join (
select
sale_id,
sum( trs.product_count ) as return_sale_product_count,
sum( trs.total_amount ) as return_sale_amount
from
t_return_sale trs
where
trs.sale_id in ( select sale_id from t_sale_detail where product_id = #{productId} )
group by
trs.sale_id
) ss on ts.id = ss.sale_id
where
ts.id in ( select sale_id from t_sale_detail where product_id = #{productId} )
and ts.status not in ( '2', '6', '7' )
order by
ts.create_time desc
</select>
</mapper>

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

@ -512,4 +512,14 @@
update t_sale_detail set purchase_price = #{item.purchasePrice} WHERE product_id = #{item.productId} and purchase_price is null
</foreach>
</update>
<select id="getSaleDetails" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_sale_detail
where sale_id in
<foreach close=")" collection="saleIdList" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</select>
</mapper>

93
hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml

@ -815,37 +815,46 @@ trans_company, company_name, product_count, remark, sale_name, company_phone, cr
DATE_FORMAT( create_time, '%Y-%m-%d' ) DESC
</select>
<select id="queryPage" parameterType="cc.hiver.mall.pojo.vo.SaleVO" resultMap="BaseResultMap">
<select id="queryPage" parameterType="cc.hiver.mall.pojo.vo.SaleVO" resultType="cc.hiver.mall.entity.Sale">
SELECT
<include refid="Base_Column_List" />
ts.id,ts.create_by,ts.create_by_name,ts.create_time,ts.del_flag,ts.update_by,ts.update_by_name,ts.update_time,ts.user_id,ts.user_name,
ts.shop_id,ts.shop_name,ts.total_amount,ts.discount,ts.discount_amount,ts.real_amount,ts.debt_deduction_amount,
ts.sale_deduction_amount,ts.balance_deduction_amount ,ts.already_earn,ts.no_earn,ts.pay_status,ts.pay_type,ts.status,
ts.other_expense,ts.transport_type,ts.share_address,ts.receive_address,ts.province,ts.city,ts.area,
ts.trans_company,ts.company_name,ts.product_count,ts.remark,ts.sale_name,ts.company_phone,ts.create_by_phone,ts.mode_of_service,
ts.ai_flag,ts.ai_result,ts.ai_not_recognition,
trs.return_sale_total_amount ,trs.return_sale_product_count
FROM
t_sale
t_sale ts
left join (
select n.sale_id,sum(n.total_amount) as return_sale_total_amount ,sum(n.product_count) as return_sale_product_count from t_sale m left join t_return_sale n on m.id = n.sale_id group by n.sale_id
) trs on ts.id = trs.sale_id
<where>
and shop_id = #{saleVO.shopId}
and ts.shop_id = #{saleVO.shopId}
<if test='saleVO.payStatus!=null'>
and pay_status = #{saleVO.payStatus}
and ts.pay_status = #{saleVO.payStatus}
</if>
<if test='saleVO.payType!=null'>
and pay_type = #{saleVO.payType}
and ts.pay_type = #{saleVO.payType}
</if>
<if test='saleVO.status!=null'>
and status = #{saleVO.status}
and ts.status = #{saleVO.status}
</if>
<if test='saleVO.transportType!=null'>
and transport_type = #{saleVO.transportType}
and ts.transport_type = #{saleVO.transportType}
</if>
<if test='saleVO.userId!=null'>
and user_id = #{saleVO.userId}
and ts.user_id = #{saleVO.userId}
</if>
<!--时间查询-->
<if test='saleVO.startTime!=null'>
and create_time BETWEEN #{saleVO.startTime} AND #{saleVO.endTime}
and ts.create_time BETWEEN #{saleVO.startTime} AND #{saleVO.endTime}
</if>
<if test='saleVO.searchStr!=null'>
and (user_name like concat('%',#{saleVO.searchStr},'%') or create_by_name like concat('%',#{saleVO.searchStr},'%'))
and (ts.user_name like concat('%',#{saleVO.searchStr},'%') or ts.create_by_name like concat('%',#{saleVO.searchStr},'%'))
</if>
</where>
order by create_time desc
order by ts.create_time desc
</select>
<select id="getCustomerBuyProductLog" resultType="cc.hiver.mall.pojo.vo.CustomerBuyProductLogVo">
@ -863,7 +872,7 @@ trans_company, company_name, product_count, remark, sale_name, company_phone, cr
<select id="getCustomerBuyProductLogDetailLog" resultType="cc.hiver.mall.pojo.vo.CustomerBuyProductDetailLogVo">
SELECT
create_time,sale_id, product_id,attribute_list, discount_amount as real_price,product_count
create_time,sale_id, product_id,attribute_list, discount_amount as real_price,product_count,purchase_price
FROM
t_sale_detail
WHERE
@ -877,7 +886,7 @@ trans_company, company_name, product_count, remark, sale_name, company_phone, cr
<select id="getByUserId" resultType="cc.hiver.mall.pojo.vo.CustomerBuySaleVo">
SELECT
id,create_time
id,create_time,product_count
FROM t_sale
WHERE
user_id = #{userId}
@ -926,7 +935,7 @@ trans_company, company_name, product_count, remark, sale_name, company_phone, cr
WHERE
t.shop_id = #{shopId}
and t.del_flag != 1
AND purchase_id IN ( SELECT id FROM t_purchase WHERE del_flag = 0 and in_storage_status = 1 and supplier_id = #{supplierId} )
AND t.purchase_id IN ( SELECT id FROM t_purchase WHERE del_flag = 0 and in_storage_status = 1 and supplier_id = #{supplierId} )
and t.product_id in
<foreach close=")" collection="productIds" item="listItem" open="(" separator=",">
#{listItem}
@ -993,4 +1002,58 @@ trans_company, company_name, product_count, remark, sale_name, company_phone, cr
status = #{status,jdbcType=INTEGER}
where id = #{id,jdbcType=VARCHAR}
</update>
<select id="getCustomerBill" resultType="cc.hiver.mall.bill.vo.CustomerBillSaleVo">
select
ts.id as sale_id,
ts.create_by_name,
ts.create_time,
ts.total_amount,
ts.debt_deduction_amount,
ts.sale_deduction_amount,
ts.balance_deduction_amount,
ts.real_amount,
ts.already_earn,
trs.return_sale_total_amount ,
tdr.amount,
tdr.balance_due,
tdr.dealings_type
from
t_sale ts
left join (
select
n.sale_id,
sum( n.total_amount ) as return_sale_total_amount
from
t_sale m
left join t_return_sale n on m.id = n.sale_id
group by
n.sale_id
) trs on ts.id = trs.sale_id
left join t_dealings_record tdr on ts.id = tdr.sale_id
WHERE
ts.user_id = #{customerBillQueryVo.customerId}
<!--订单状态不为:2:已作废;分享页提交订单:6:待配货;挂单页提交订单:7:挂单-->
and ts.status not in ( '2', '6', '7' )
<if test='customerBillQueryVo.startDate !=null and customerBillQueryVo.endDate !=null'>
and ts.create_time BETWEEN #{customerBillQueryVo.startDate} AND #{customerBillQueryVo.endDate}
</if>
order by ts.create_time asc
</select>
<select id="getArrearsAndTotalSale" resultType="cc.hiver.mall.bill.vo.ArrearsVo">
select
sum(ts.no_earn) as arrears,
sum(ts.total_amount) as total_sale
from
t_sale ts
WHERE
ts.user_id = #{customerBillQueryVo.customerId}
<!--订单状态不为:2:已作废;分享页提交订单:6:待配货;挂单页提交订单:7:挂单-->
and ts.status not in ( '2', '6', '7' )
<if test='customerBillQueryVo.startDate !=null and customerBillQueryVo.endDate !=null'>
and ts.create_time BETWEEN #{customerBillQueryVo.startDate} AND #{customerBillQueryVo.endDate}
</if>
order by ts.create_time asc
</select>
</mapper>

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

@ -636,9 +636,31 @@
where s.product_id= #{productId,jdbcType=VARCHAR}
</select>
<select id="getProductsStock" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM
t_stock s
where s.product_id in
<foreach item="item" index="index" collection="productIds" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<update id="putInUpdatePurchasePrice">
<foreach collection="purchaseDetails" item="item" separator=";" open="" close="">
update t_stock set purchase_price = #{item.purchasePrice},supplier_id = #{item.supplierId},supplier_name = #{item.supplierName} WHERE product_id = #{item.productId} and purchase_price is null
</foreach>
</update>
<select id="getByProductIdAndAttributeList" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_stock
<where>
and product_id = #{productId,jdbcType=VARCHAR}
and attribute_list = #{attributeList,jdbcType=VARCHAR}
</where>
</select>
</mapper>
Loading…
Cancel
Save