Browse Source

供应商欠款优化。

cangku
wangfukang 2 years ago
parent
commit
5f0bed48d7
  1. 9
      hiver-admin/src/main/resources/application.yml
  2. 16
      hiver-admin/test-output/test-report.html
  3. 4
      hiver-core/src/main/java/cc/hiver/core/common/constant/DealingsRecordConstant.java
  4. 20
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/controller/BillController.java
  5. 11
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/service/BillService.java
  6. 180
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/service/impl/BillServiceImpl.java
  7. 41
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillDataVo.java
  8. 50
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillPurchaseVo.java
  9. 26
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillQueryVo.java
  10. 20
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PurchaseController.java
  11. 6
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SaleController.java
  12. 4
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/DealingsRecordMapper.java
  13. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseDetailMapper.java
  14. 14
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseMapper.java
  15. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java
  16. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockLogMapper.java
  17. 36
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/controller/DebtController.java
  18. 33
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/DebtService.java
  19. 47
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/impl/DebtServiceImpl.java
  20. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Purchase.java
  21. 4
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/PurchaseVo.java
  22. 12
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/DealingsRecordService.java
  23. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseDetailService.java
  24. 13
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java
  25. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockLogService.java
  26. 8
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/DealingsRecordServiceImpl.java
  27. 5
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseDetailServiceImpl.java
  28. 121
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java
  29. 8
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java
  30. 5
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockLogServiceImpl.java
  31. 8
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java
  32. 25
      hiver-modules/hiver-mall/src/main/resources/mapper/DealingsRecordMapper.xml
  33. 12
      hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml
  34. 57
      hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml
  35. 7
      hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml
  36. 12
      hiver-modules/hiver-mall/src/main/resources/mapper/StockLogMapper.xml

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

@ -25,8 +25,8 @@ spring:
timeout-per-shutdown-phase: 10S
# 数据源
datasource:
url: jdbc:mysql://154.8.162.157:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true
# url: jdbc:mysql://8.140.198.243:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true
# url: jdbc:mysql://154.8.162.157:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true
url: jdbc:mysql://8.140.198.243:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: reddoor
# Jasypt加密 可到common-utils中找到JasyptUtil加解密工具类生成加密结果 格式为ENC(加密结果) 以下解密结果为123456
password: ENC(Zla4U4+yRLPhicvuX2TmiEgxEpzP4dk8BHzFDEtiEhwLQIIaftZrrEUJZce6efoe)
@ -67,7 +67,7 @@ spring:
ddl-auto: update
# Redis 若设有密码自行添加配置password
redis:
host: 154.8.162.157
# host: 154.8.162.157
# host: 8.140.198.243
password: reddoor168
# 数据库索引 默认0
@ -321,6 +321,8 @@ ignored:
- /hiver/app/sale/getCustomerBuyProductLog
# 客户对账单
- /hiver/app/bill/getCustomerBill
# 供应商对账单
- /hiver/app/bill/getSupplierBill
# 根据客户id分页获取退货历史
- /hiver/app/return/getReturnSaleListByUserId
# 根据客户id分页获取销售历史(按销售单)
@ -330,6 +332,7 @@ ignored:
- /hiver/app/return/get/**
# # 临时增加
- /hiver/app/purchase/getPurchaseListOfSupplier
# 限流及黑名单不拦截的路径
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">七月 17, 2024 16:39:09</span></a>
<a href="#"><span class="badge badge-primary">七月 25, 2024 22:04:43</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>16:39:10 下午</span> / <span>0.017 secs</span></p>
<p class="text-sm"><span>22:04:43 下午</span> / <span>0.016 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'>07.17.2024 16:39:10</span>
<span class='badge badge-danger'>07.17.2024 16:39:10</span>
<span class='badge badge-default'>0.017 secs</span>
<span class='badge badge-success'>07.25.2024 22:04:43</span>
<span class='badge badge-danger'>07.25.2024 22:04:43</span>
<span class='badge badge-default'>0.016 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>16:39:10</td>
<td>22:04:43</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>七月 17, 2024 16:39:09</h3>
<h3>七月 25, 2024 22:04:43</h3>
</div></div>
</div>
<div class="col-md-3">
<div class="card"><div class="card-body">
<p class="m-b-0">Ended</p>
<h3>七月 17, 2024 16:39:10</h3>
<h3>七月 25, 2024 22:04:43</h3>
</div></div>
</div>
<div class="col-md-3">

4
hiver-core/src/main/java/cc/hiver/core/common/constant/DealingsRecordConstant.java

@ -13,8 +13,8 @@ public interface DealingsRecordConstant {
Integer[] TYPE = {0, 1};
/**
* 交易类型0:开单1退货(应该是没用到)2回款3新增客户/供应商欠款4充值5追加欠款;6:撤销订单;
* 交易类型0:开单1退货(应该是没用到)2回款3新增客户/供应商欠款4充值5追加欠款;6:撤销订单;7:入库
*/
Integer[] DEALINGS_TYPE = {0, 1, 2, 3, 4, 5, 6};
Integer[] DEALINGS_TYPE = {0, 1, 2, 3, 4, 5, 6,7};
}

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

@ -5,6 +5,8 @@ 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 cc.hiver.mall.bill.vo.SupplierBillDataVo;
import cc.hiver.mall.bill.vo.SupplierBillQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@ -55,4 +57,22 @@ public class BillController {
return ResultUtil.error("获取客户对账单异常");
}
}
@PostMapping("/getSupplierBill")
@ApiOperation("获取供应商对账单")
public Result getPurchaseBill(@RequestBody SupplierBillQueryVo supplierBillQueryVo) {
if(StringUtils.isEmpty(supplierBillQueryVo.getSupplierId())){
return ResultUtil.error("供应商id不能为空");
}
if(StringUtils.isEmpty(supplierBillQueryVo.getShopId())){
return ResultUtil.error("店铺id不能为空");
}
try {
final SupplierBillDataVo supplierBillDataVo = billService.getPurchaseBill(supplierBillQueryVo);
return new ResultUtil<>().setData(supplierBillDataVo);
} catch (Exception e) {
log.error("获取供应商对账单异常", e);
return ResultUtil.error("获取供应商对账单异常");
}
}
}

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

@ -2,6 +2,8 @@ package cc.hiver.mall.bill.service;
import cc.hiver.mall.bill.vo.CustomerBillDataVo;
import cc.hiver.mall.bill.vo.CustomerBillQueryVo;
import cc.hiver.mall.bill.vo.SupplierBillDataVo;
import cc.hiver.mall.bill.vo.SupplierBillQueryVo;
public interface BillService {
@ -14,4 +16,13 @@ public interface BillService {
* @date 2024/6/26
*/
CustomerBillDataVo getCustomerBill(CustomerBillQueryVo customerBillQueryVo);
/**
* 获取供应商对账单
* @author 王富康
* @date 2024/7/23
* @param supplierBillQueryVo
* @return SupplierBillDataVo
*/
SupplierBillDataVo getPurchaseBill(SupplierBillQueryVo supplierBillQueryVo);
}

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

@ -5,9 +5,8 @@ import cc.hiver.mall.bill.service.BillService;
import cc.hiver.mall.bill.vo.*;
import cc.hiver.mall.debt.entity.Debt;
import cc.hiver.mall.debt.service.DebtService;
import cc.hiver.mall.entity.Customer;
import cc.hiver.mall.entity.ReturnDetail;
import cc.hiver.mall.entity.SaleDetail;
import cc.hiver.mall.entity.*;
import cc.hiver.mall.service.SupplierService;
import cc.hiver.mall.service.mybatis.*;
import cc.hiver.mall.utils.DateUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -24,12 +23,24 @@ public class BillServiceImpl implements BillService {
@Autowired
private SaleService saleService;
@Autowired
private PurchaseService purchaseService;
@Autowired
private CustomerService customerService;
@Autowired
private SupplierService supplierService;
@Autowired
private SaleDetailService saleDetailService;
@Autowired
private PurchaseDetailService purchaseDetailService;
@Autowired
private StockLogService stockLogService;
@Autowired
private ReturnSaleService returnSaleService;
@ -258,4 +269,167 @@ public class BillServiceImpl implements BillService {
customerBillDataVo.setCustomerBillSaleVos(dealingRecordPage);
return customerBillDataVo;
}
/**
* 获取供应商对账单
* @author 王富康
* @date 2024/7/23
* @param supplierBillQueryVo
* @return SupplierBillDataVo
*/
@Override
public SupplierBillDataVo getPurchaseBill(SupplierBillQueryVo supplierBillQueryVo) {
//结束时间+1天
if (StringUtils.isNotEmpty(supplierBillQueryVo.getEndDate())) {
final String endDate = DateUtil.addDay(supplierBillQueryVo.getEndDate(), 1);
supplierBillQueryVo.setEndDate(endDate);
}
final SupplierBillDataVo supplierBillDataVo = new SupplierBillDataVo();
supplierBillDataVo.setUserId(supplierBillQueryVo.getSupplierId());
// 获取客户信息
final Supplier supplier = supplierService.findById(supplierBillQueryVo.getSupplierId());
supplierBillDataVo.setUserName(supplier.getConsigneeName());
supplierBillDataVo.setQueryDate(DateUtil.COMMON_FULL.getDateText(new Date()));
// 获取本期全部拿货总金额
final ArrearsVo saleArrearsVo = purchaseService.getArrearsAndTotalSale(supplierBillQueryVo);
if (saleArrearsVo != null) {
supplierBillDataVo.setTotalSale(saleArrearsVo.getTotalSale());
}else{
supplierBillDataVo.setTotalSale(BigDecimal.ZERO);
}
// 根据客户id及日期范围对账单明细
final Page<SupplierBillPurchaseVo> dealingRecordPage = dealingsRecordService.getDealingsRecordPageBySupplierId(supplierBillQueryVo);
final List<SupplierBillPurchaseVo> records = dealingRecordPage.getRecords();
// 获取saleId,去查询销售单的商品明细,及退货单的商品明细
final List<String> purchaseIdList = new ArrayList<>();
if(records.isEmpty()){
//未开单,查询客户欠款,作为初期欠款和期末欠款
final Debt debt = debtService.selectByUserId(supplierBillQueryVo.getShopId(),supplierBillQueryVo.getSupplierId());
// 要查新客户的创建时间,根据用户的创建时间来判断;
// 如果查询时间小于创建时间,那么初期欠款和期末欠款应该为0
// 如果查询的时间大于创建时间,那么初期欠款和期末欠款应该为客户欠款
if(debt != null){
final Date createTime = debt.getCreateTime();
final String endDate = supplierBillQueryVo.getEndDate();
Date enddate = new Date();
try {
if (StringUtils.isNotEmpty(endDate)) {
enddate = DateUtil.COMMON.getTextDate(endDate);
}
} catch (ParseException e) {
throw new RuntimeException(e);
}
// 以为现在创建客户就创建了欠款信息,那么就按照欠款信息的创建时间作为标识
if(createTime.after(enddate)){
supplierBillDataVo.setInitialArrears(BigDecimal.ZERO);
supplierBillDataVo.setEndArrears(BigDecimal.ZERO);
}else{
supplierBillDataVo.setInitialArrears(debt.getAmountOwed());
supplierBillDataVo.setEndArrears(debt.getAmountOwed());
}
}
}else{
for (int i = 0; i < records.size(); i++) {
if(StringUtils.isNotEmpty(records.get(i).getPurchaseId())){
purchaseIdList.add(records.get(i).getPurchaseId());
}
// 根据时间升序查询的,这里获取第一个的初期欠款当做本次查询的初期欠款
if (i == 0) {
final BigDecimal lastDebtAmount = records.get(0).getLastDebtAmount();
supplierBillDataVo.setInitialArrears(lastDebtAmount);
}
// 获取最后一个的剩余欠款当做本次查询的剩余欠款
if (i == records.size() - 1) {
supplierBillDataVo.setEndArrears(records.get(i).getBalanceDue());
}
}
}
if (!purchaseIdList.isEmpty()) {
// 获取入库单商品明细
final List<PurchaseDetail> purchaseDetails = purchaseDetailService.getPurchaseDetails(purchaseIdList);
// 将销售明细封装到销售单对象中
final Map<String, List<PurchaseDetail>> purchaseDetailMap = new HashMap<>();
for (PurchaseDetail purchaseDetail : purchaseDetails) {
final String purchaseId = purchaseDetail.getPurchaseId();
if (purchaseDetailMap.containsKey(purchaseId)) {
final List<PurchaseDetail> purchaseDetailList = purchaseDetailMap.get(purchaseId);
purchaseDetailList.add(purchaseDetail);
} else {
final List<PurchaseDetail> purchaseDetailArrayList = new ArrayList<>();
purchaseDetailArrayList.add(purchaseDetail);
purchaseDetailMap.put(purchaseId, purchaseDetailArrayList);
}
}
// 获取入库单规格明细
final List<StockLog> stockLogList = stockLogService.getPurchaseDetails(purchaseIdList);
final Map<String,List<StockLog>> stockLogMap = new HashMap<>();
for (StockLog stockLog : stockLogList) {
final String detailId = stockLog.getDetailId();
if (stockLogMap.containsKey(detailId)) {
final List<StockLog> stockLogListOfMap = stockLogMap.get(detailId);
stockLogListOfMap.add(stockLog);
} else {
final List<StockLog> stockLogListOfMap = new ArrayList<>();
stockLogListOfMap.add(stockLog);
stockLogMap.put(detailId, stockLogListOfMap);
}
}
// 开始封装数据
for (SupplierBillPurchaseVo supplierBillPurchaseVo : records) {
final String purchaseId = supplierBillPurchaseVo.getPurchaseId();
// 封装销售单信息
final List<PurchaseDetail> purchaseDetailList = purchaseDetailMap.get(purchaseId);
// 根据商品id分类
final Map<String, List<PurchaseDetail>> purchaseDetailMapOfSale = new HashMap<>();
if (purchaseDetailList != null && !purchaseDetailList.isEmpty()) {
for (PurchaseDetail purchaseDetail : purchaseDetailList) {
final String productId = purchaseDetail.getProductId();
if (purchaseDetailMapOfSale.containsKey(productId)) {
final List<PurchaseDetail> purchaseDetailsOfMap = purchaseDetailMapOfSale.get(productId);
purchaseDetailsOfMap.add(purchaseDetail);
} else {
final List<PurchaseDetail> purchaseDetailArrayList = new ArrayList<>();
purchaseDetailArrayList.add(purchaseDetail);
purchaseDetailMapOfSale.put(productId, purchaseDetailArrayList);
}
}
final List<BillProductDetailVo> billSaleDetailVos = new ArrayList<>();
for (Map.Entry<String, List<PurchaseDetail>> stringListEntry : purchaseDetailMapOfSale.entrySet()) {
final List<PurchaseDetail> value = stringListEntry.getValue();
final BillProductDetailVo billProductDetailVo = new BillProductDetailVo();
// 同一款商品,不同规格,商品信息值几钱取第一个
billProductDetailVo.setProductSn(value.get(0).getProductSn());
billProductDetailVo.setProductName(value.get(0).getProductName());
final List<BillAttributeListVo> billAttributeListVos = new ArrayList<>();
final List<StockLog> stockLogList1 = stockLogMap.get(value.get(0).getId());
if (stockLogList1 != null && !stockLogList1.isEmpty()) {
for (StockLog stockLog : stockLogList1) {
final BillAttributeListVo billAttributeListVo = new BillAttributeListVo();
billAttributeListVo.setAttributeList(stockLog.getAttributeList());
billAttributeListVo.setProductCount(stockLog.getProductCount());
billAttributeListVos.add(billAttributeListVo);
}
}
billProductDetailVo.setProductCount(value.get(0).getProductCount());
final BigDecimal purchasePrice = value.get(0).getPurchasePrice() == null ? BigDecimal.ZERO : value.get(0).getPurchasePrice();
final BigDecimal productCount = value.get(0).getProductCount() == null ? BigDecimal.ZERO : BigDecimal.valueOf(value.get(0).getProductCount());
billProductDetailVo.setTotalAmount(purchasePrice.multiply(productCount));
billProductDetailVo.setBillAttributeListVos(billAttributeListVos);
billSaleDetailVos.add(billProductDetailVo);
}
supplierBillPurchaseVo.setBillSaleDetailVos(billSaleDetailVos);
}
}
}
// 将销售信息存放到对账单中
supplierBillDataVo.setSupplierBillSaleVos(dealingRecordPage);
return supplierBillDataVo;
}
}

41
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillDataVo.java

@ -0,0 +1,41 @@
package cc.hiver.mall.bill.vo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* 对账单信息
* @author 王富康
* @date 2024/6/26
*/
@Data
public class SupplierBillDataVo {
@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 Page<SupplierBillPurchaseVo> supplierBillSaleVos;
}

50
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillPurchaseVo.java

@ -0,0 +1,50 @@
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 SupplierBillPurchaseVo {
@ApiModelProperty(value = "入库单号")
private String purchaseId;
@ApiModelProperty(value = "操作人")
private String createByName;
@ApiModelProperty(value = "日期")
private String createTime;
@ApiModelProperty(value = "订单金额(销售金额)")
private BigDecimal shouldPay;
@ApiModelProperty(value="余额抵扣金额")
private BigDecimal balanceDeductionAmount;
@ApiModelProperty(value = "已收")
private BigDecimal alreadyPay;
@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;
}

26
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillQueryVo.java

@ -0,0 +1,26 @@
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 SupplierBillQueryVo extends HiverBasePageQuery {
@ApiModelProperty(value = "供应商id")
private String supplierId;
@ApiModelProperty(value = "店铺id")
private String shopId;
@ApiModelProperty(value = "开始时间")
private String startDate;
@ApiModelProperty(value = "结束时间")
private String endDate;
}

20
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PurchaseController.java

@ -290,4 +290,24 @@ public class PurchaseController {
return ResultUtil.error("查询失败");
}
}
/**
* 请详细描述方法
* @author 王富康
* @date 2024/7/24
* @param purchasePageQuery
* @return Result
*/
@RequestMapping(value = "/getPurchaseListOfSupplier", method = RequestMethod.POST)
@ApiOperation("获取从某个供应商的拿货入库记录")
public Result getPurchaseListOfSupplier(@RequestBody PurchasePageQuery purchasePageQuery) {
if(StringUtils.isEmpty(purchasePageQuery.getSupplierId())){
return ResultUtil.error("供应商id不能为空!");
}
// shopId从缓存中设置
final String shopId = securityUtil.getShopId();
purchasePageQuery.setShopId(shopId);
final Page<PurchaseVo> purchaseVoList = purchaseService.getPurchaseListOfSupplier(purchasePageQuery);
return ResultUtil.data(purchaseVoList);
}
}

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

@ -1022,6 +1022,12 @@ public class SaleController {
@RequestMapping(value = "/getSupplierBuyProductLog", method = RequestMethod.POST)
@ApiOperation("根据供应商查询商品购买记录")
public Result getSupplierBuyProductLog(@RequestBody SalePageQuery salePageQuery) {
if(StringUtils.isEmpty(salePageQuery.getShopId())){
return ResultUtil.error("店铺id不能为空");
}
if(StringUtils.isEmpty(salePageQuery.getSupplierId())){
return ResultUtil.error("供应商id不能为空");
}
final Page<SupplierBuyProductLogVo> salePage = saleService.getSupplierBuyProductLog(salePageQuery);
return ResultUtil.data(salePage);
}

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

@ -2,6 +2,8 @@ package cc.hiver.mall.dao.mapper;
import cc.hiver.mall.bill.vo.CustomerBillQueryVo;
import cc.hiver.mall.bill.vo.CustomerBillSaleVo;
import cc.hiver.mall.bill.vo.SupplierBillPurchaseVo;
import cc.hiver.mall.bill.vo.SupplierBillQueryVo;
import cc.hiver.mall.entity.DealingsRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -38,4 +40,6 @@ public interface DealingsRecordMapper extends BaseMapper<DealingsRecord> {
void cancelRecord(@Param("saleId") String saleId);
Page<CustomerBillSaleVo> getDealingsRecordPageByUserId(Page<CustomerBillSaleVo> page, @Param("customerBillQueryVo") CustomerBillQueryVo customerBillQueryVo);
Page<SupplierBillPurchaseVo> getDealingsRecordPageBySupplierId(Page<SupplierBillPurchaseVo> page, @Param("supplierBillQueryVo") SupplierBillQueryVo supplierBillQueryVo);
}

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

@ -42,4 +42,6 @@ public interface PurchaseDetailMapper extends BaseMapper<PurchaseDetail> {
void batchUpdatePurchaseList(@Param("purchaseDetails") List<PurchaseDetail> updatePurchaseDetails);
void deleteByPurchaseId(@Param("purchaseId") String purchaseId);
List<PurchaseDetail> getPurchaseDetails(@Param("purchaseIdList") List<String> purchaseIdList);
}

14
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseMapper.java

@ -1,5 +1,7 @@
package cc.hiver.mall.dao.mapper;
import cc.hiver.mall.bill.vo.ArrearsVo;
import cc.hiver.mall.bill.vo.SupplierBillQueryVo;
import cc.hiver.mall.entity.Purchase;
import cc.hiver.mall.entity.PurchaseExample;
import cc.hiver.mall.pojo.dto.DebtSupplier;
@ -49,4 +51,16 @@ public interface PurchaseMapper extends BaseMapper<Purchase> {
void deleteByPurchaseId(@Param("id") String id);
Page<PurchasingCostDetailVo> purchasingCostDetail(Page<PurchasingCostDetailVo> page,@Param("purchasePageQuery") PurchasePageQuery purchasePageQuery);
ArrearsVo getArrearsAndTotalSale(@Param("supplierBillQueryVo") SupplierBillQueryVo supplierBillQueryVo);
/**
* 获取从某个供应商的拿货入库记录(按入库单)
* @author 王富康
* @date 2024/7/24
* @param page
* @param purchasePageQuery
* @return Page<Purchase>
*/
Page<Purchase> getPurchaseListBySupplierId(Page<Purchase> page,@Param("purchasePageQuery") PurchasePageQuery purchasePageQuery);
}

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

@ -75,7 +75,7 @@ public interface SaleMapper extends BaseMapper<Sale> {
List<SupplierBuyProductDetailLogVo> getSupplierBuyProductLogDetailLog(@Param("supplierId") String supplierId, @Param("shopId") String shopId, @Param("productIds") List<String> productIds);
Page<SupplierBuyProductLogVo> getSupplierBuyProductLog(Page<SupplierBuyProductLogVo> page, @Param("supplierId") String supplierId, @Param("shopId") String shopId);
Page<SupplierBuyProductLogVo> getSupplierBuyProductLog(Page<SupplierBuyProductLogVo> page,@Param("salePageQuery") SalePageQuery salePageQuery);
Page<SaleNoWorkerVO> getSaleByCompanyId(Page<SaleNoWorkerVO> page, @Param("salePageQuery") SalePageQuery salePageQuery);

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

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

36
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/controller/DebtController.java

@ -29,10 +29,11 @@ public class DebtController {
/**
* / 根据店铺id查询欠款列表
* @author 王富康
* @date 2024/6/9
*
* @param queryDebtVo 查询vo
* @return Result
* @author 王富康
* @date 2024/6/9
*/
@RequestMapping(value = "/getDebtByShopId", method = RequestMethod.POST)
@ApiOperation("根据店铺id查询欠款列表")
@ -46,10 +47,11 @@ public class DebtController {
/**
* 新增客户欠款回款开单退单修改客户欠款
* @author 王富康
* @date 2024/6/10
*
* @param debt
* @return Result
* @author 王富康
* @date 2024/6/10
*/
@RequestMapping(value = "/saveOrUpdateDebt", method = RequestMethod.POST)
@ApiOperation("新增/修改欠款")
@ -63,10 +65,11 @@ public class DebtController {
/**
* 充值正数是减少欠款负数是追加欠款
* @author 王富康
* @date 2024/6/30
*
* @param debt
* @return Result
* @author 王富康
* @date 2024/6/30
*/
@RequestMapping(value = "/recharge", method = RequestMethod.POST)
@ApiOperation("充值")
@ -77,4 +80,25 @@ public class DebtController {
}
return new ResultUtil<>().setData(saveOrUpdateDebt);
}
/**
* 根据客户/供应商id获取欠款信息
*
* @param shopId
* @param userId
* @return Result
* @author 王富康
* @date 2024/7/23
*/
@RequestMapping(value = "/selectByUserId", method = RequestMethod.POST)
@ApiOperation("根据客户/供应商id获取欠款信息")
public Result selectByUserId(String shopId, String userId) {
final Debt saveOrUpdateDebt = debtService.selectByUserId(shopId, userId);
if (saveOrUpdateDebt == null) {
return new ResultUtil<>().setErrorMsg("查询欠款用户信息失败!");
}
return new ResultUtil<>().setData(saveOrUpdateDebt);
}
}

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

@ -2,6 +2,7 @@ package cc.hiver.mall.debt.service;
import cc.hiver.mall.debt.entity.Debt;
import cc.hiver.mall.debt.vo.QueryDebtVo;
import cc.hiver.mall.entity.Purchase;
import cc.hiver.mall.pojo.dto.SaleQueryDTO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
@ -12,27 +13,30 @@ public interface DebtService extends IService<Debt> {
/**
* 根据店铺id查询欠款列表
* @author 王富康
* @date 2024/6/10
*
* @param queryDebtVo
* @return Page<Debt>
* @author 王富康
* @date 2024/6/10
*/
Page<Debt> getDebtByShopId(QueryDebtVo queryDebtVo);
/**
* 新增客户欠款回款开单退单修改客户欠款
* @author 王富康
* @date 2024/6/10
*
* @param debt
* @return Debt
* @author 王富康
* @date 2024/6/10
*/
Debt saveOrUpdateDebt(Debt debt);
/**
* 开单进行欠款更新
*
* @param saleQueryDTO
* @author 王富康
* @date 2024/6/10
* @param saleQueryDTO
*/
void saleToDebt(SaleQueryDTO saleQueryDTO);
@ -45,20 +49,31 @@ public interface DebtService extends IService<Debt> {
// void returnSaleToDebt(SaleQueryDTO saleQueryDTO);
/**
* 根据客户或者供应商id获取欠款信息
* 入库进行供应商欠款更新
*
* @param purchase
* @author 王富康
* @date 2024/6/22
* @date 2024/7/22
*/
void purchaseToDebt(Purchase purchase);
/**
* 根据客户或者供应商id获取欠款信息
*
* @param userIds
* @return List<Debt>
* @author 王富康
* @date 2024/6/22
*/
List<Debt> getDebtByUserIds(List<String> userIds);
/**
* 根据客户id获取欠款信息
* @author 王富康
* @date 2024/6/26
*
* @param userId
* @return Debt
* @author 王富康
* @date 2024/6/26
*/
Debt selectByUserId(String shopId, String userId);

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

@ -10,6 +10,7 @@ import cc.hiver.mall.debt.service.DebtService;
import cc.hiver.mall.debt.vo.QueryDebtVo;
import cc.hiver.mall.entity.Customer;
import cc.hiver.mall.entity.DealingsRecord;
import cc.hiver.mall.entity.Purchase;
import cc.hiver.mall.entity.Supplier;
import cc.hiver.mall.pojo.dto.SaleQueryDTO;
import cc.hiver.mall.service.SupplierService;
@ -223,6 +224,52 @@ public class DebtServiceImpl extends ServiceImpl<DebtMapper, Debt> implements De
dealingsRecordService.save(dealingsRecord);
}
/**
* 入库进行供应商欠款更新
*
* @param purchase
* @author 王富康
* @date 2024/7/22
*/
@Override
public void purchaseToDebt(Purchase purchase) {
final String shopId = securityUtil.getShopId();
final Debt oldDebt = debtMapper.selectByUserId(shopId, purchase.getSupplierId());
BigDecimal lastDebtAmount = BigDecimal.ZERO;
BigDecimal newDebtAmount;
// 本单欠款
BigDecimal noPay = purchase.getNoPay() == null ? BigDecimal.ZERO : purchase.getNoPay();
// 余额抵扣,需要从欠款中减掉
final BigDecimal balanceDeductionAmount = purchase.getBalanceDeductionAmount() == null ? BigDecimal.ZERO : purchase.getBalanceDeductionAmount();
lastDebtAmount = oldDebt.getAmountOwed() == null ? BigDecimal.ZERO : oldDebt.getAmountOwed();
// 计算欠款
newDebtAmount = oldDebt.getAmountOwed().add(noPay).add(balanceDeductionAmount);
oldDebt.setAmountOwed(newDebtAmount);
debtMapper.updateById(oldDebt);
// 2. 新增欠款记录
final DealingsRecord dealingsRecord = new DealingsRecord();
// 创建人
final User user = securityUtil.getCurrUser();
dealingsRecord.setCreateBy(user.getId());
dealingsRecord.setCreateByName(user.getNickname());
dealingsRecord.setCreateTime(new Date());
dealingsRecord.setSaleId(purchase.getId());
dealingsRecord.setDealingsUserId(purchase.getSupplierId());
dealingsRecord.setDealingsUserName(purchase.getSupplierName());
dealingsRecord.setUserType(DealingsRecordConstant.TYPE[0]);
dealingsRecord.setDealingsWay("入库");
dealingsRecord.setShopId(shopId);
// 上次欠款
dealingsRecord.setLastDebtAmount(lastDebtAmount);
// 最新欠款
dealingsRecord.setBalanceDue(newDebtAmount);
// 本次欠款
dealingsRecord.setAmount(noPay);
dealingsRecord.setDealingsType(DealingsRecordConstant.DEALINGS_TYPE[7]);
dealingsRecordService.save(dealingsRecord);
}
@Override
public List<Debt> getDebtByUserIds(List<String> userIds) {
return debtMapper.getDebtByUserIds(userIds);

3
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Purchase.java

@ -54,6 +54,9 @@ public class Purchase extends HiverBaseEntity {
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "余额抵扣")
private BigDecimal balanceDeductionAmount;
@Transient
@TableField(exist = false)
@ApiModelProperty(value = "起始日期")

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

@ -1,5 +1,6 @@
package cc.hiver.mall.pojo.vo;
import cc.hiver.mall.entity.DealingsRecord;
import cc.hiver.mall.entity.Purchase;
import cc.hiver.mall.entity.PurchaseDetail;
import cc.hiver.mall.entity.Supplier;
@ -22,4 +23,7 @@ public class PurchaseVo {
@ApiModelProperty(value = "采购单子表")
private List<PurchaseDetail> purchaseDetails;
@ApiModelProperty(value = "欠款信息")
private List<DealingsRecord> dealingsRecords;
}

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

@ -2,6 +2,8 @@ package cc.hiver.mall.service.mybatis;
import cc.hiver.mall.bill.vo.CustomerBillQueryVo;
import cc.hiver.mall.bill.vo.CustomerBillSaleVo;
import cc.hiver.mall.bill.vo.SupplierBillPurchaseVo;
import cc.hiver.mall.bill.vo.SupplierBillQueryVo;
import cc.hiver.mall.entity.DealingsRecord;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
@ -42,4 +44,14 @@ public interface DealingsRecordService extends IService<DealingsRecord> {
* @date 2024/7/6
*/
Page<CustomerBillSaleVo> getDealingsRecordPageByUserId(CustomerBillQueryVo customerBillQueryVo);
/**
* 对账单分页获取
*
* @param supplierBillQueryVo
* @return Page<BillDealingsRecordVo>
* @author 王富康
* @date 2024/7/6
*/
Page<SupplierBillPurchaseVo> getDealingsRecordPageBySupplierId(SupplierBillQueryVo supplierBillQueryVo);
}

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

@ -20,4 +20,6 @@ public interface PurchaseDetailService extends IService<PurchaseDetail> {
void batchSavePurchaseList(List<PurchaseDetail> purchaseDetails);
void deleteByPurchaseId(String purchaseId);
List<PurchaseDetail> getPurchaseDetails(List<String> purchaseIdList);
}

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

@ -1,5 +1,7 @@
package cc.hiver.mall.service.mybatis;
import cc.hiver.mall.bill.vo.ArrearsVo;
import cc.hiver.mall.bill.vo.SupplierBillQueryVo;
import cc.hiver.mall.entity.Purchase;
import cc.hiver.mall.pojo.dto.DebtSupplier;
import cc.hiver.mall.pojo.query.PurchasePageQuery;
@ -53,4 +55,15 @@ public interface PurchaseService extends IService<Purchase> {
* @return List<PurchasingCostDetailVo>
*/
Page<PurchasingCostDetailVo> purchasingCostDetail(PurchasePageQuery purchasePageQuery);
ArrearsVo getArrearsAndTotalSale(SupplierBillQueryVo supplierBillQueryVo);
/**
* 获取从某个供应商的拿货入库记录(按入库单)
* @author 王富康
* @date 2024/7/24
* @param purchasePageQuery
* @return Page<PurchaseVo>
*/
Page<PurchaseVo> getPurchaseListOfSupplier(PurchasePageQuery purchasePageQuery);
}

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

@ -13,4 +13,6 @@ public interface StockLogService extends IService<StockLog> {
void batchSaveStockLogList(List<StockLog> stockLogList);
void deleteByPurchaseId(String purchaseId);
List<StockLog> getPurchaseDetails(List<String> purchaseIdList);
}

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

@ -3,6 +3,8 @@ package cc.hiver.mall.serviceimpl.mybatis;
import cc.hiver.core.common.utils.SecurityUtil;
import cc.hiver.mall.bill.vo.CustomerBillQueryVo;
import cc.hiver.mall.bill.vo.CustomerBillSaleVo;
import cc.hiver.mall.bill.vo.SupplierBillPurchaseVo;
import cc.hiver.mall.bill.vo.SupplierBillQueryVo;
import cc.hiver.mall.dao.mapper.DealingsRecordMapper;
import cc.hiver.mall.entity.DealingsRecord;
import cc.hiver.mall.service.mybatis.DealingsRecordService;
@ -64,4 +66,10 @@ public class DealingsRecordServiceImpl extends ServiceImpl<DealingsRecordMapper,
return dealingsRecordMapper.getDealingsRecordPageByUserId(page,customerBillQueryVo);
}
@Override
public Page<SupplierBillPurchaseVo> getDealingsRecordPageBySupplierId(SupplierBillQueryVo supplierBillQueryVo) {
final Page<SupplierBillPurchaseVo> page = new Page<>(supplierBillQueryVo.getPageNum(), supplierBillQueryVo.getPageSize());
return dealingsRecordMapper.getDealingsRecordPageBySupplierId(page,supplierBillQueryVo);
}
}

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

@ -81,4 +81,9 @@ public class PurchaseDetailServiceImpl extends ServiceImpl<PurchaseDetailMapper,
public void deleteByPurchaseId(String purchaseId) {
purchaseDetailMapper.deleteByPurchaseId(purchaseId);
}
@Override
public List<PurchaseDetail> getPurchaseDetails(List<String> purchaseIdList) {
return purchaseDetailMapper.getPurchaseDetails(purchaseIdList);
}
}

121
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java

@ -4,6 +4,8 @@ import cc.hiver.core.common.constant.DealingsRecordConstant;
import cc.hiver.core.common.utils.SecurityUtil;
import cc.hiver.core.common.utils.StringUtils;
import cc.hiver.core.entity.User;
import cc.hiver.mall.bill.vo.ArrearsVo;
import cc.hiver.mall.bill.vo.SupplierBillQueryVo;
import cc.hiver.mall.dao.mapper.PurchaseMapper;
import cc.hiver.mall.entity.*;
import cc.hiver.mall.pojo.dto.DebtSupplier;
@ -161,6 +163,8 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
}
purchaseVo.setPurchaseDetails(purchaseDetails);
// 获取该入库单的欠款更新记录
purchaseVo.setDealingsRecords(dealingsRecordService.getDealingsRecordList(id));
return purchaseVo;
}
@ -487,4 +491,121 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
purchasePageQuery.setShopId(shopId);
return purchaseMapper.purchasingCostDetail(page, purchasePageQuery);
}
@Override
public ArrearsVo getArrearsAndTotalSale(SupplierBillQueryVo supplierBillQueryVo) {
return purchaseMapper.getArrearsAndTotalSale(supplierBillQueryVo);
}
/**
* 获取从某个供应商的拿货入库记录(按入库单)
* @author 王富康
* @date 2024/7/24
* @param purchasePageQuery
* @return Page<PurchaseVo>
*/
@Override
public Page<PurchaseVo> getPurchaseListOfSupplier(PurchasePageQuery purchasePageQuery) {
// 获取采购单主表信息
final Page<Purchase> page = new Page<>(purchasePageQuery.getPageNum(), purchasePageQuery.getPageSize());
final String supplierId = purchasePageQuery.getSupplierId();
//结束时间+1天
if (StringUtils.isNotEmpty(purchasePageQuery.getEndDate())) {
final String endDate = DateUtil.addDay(purchasePageQuery.getEndDate(), 1);
purchasePageQuery.setEndDate(endDate);
}
final Page<Purchase> salePage = purchaseMapper.getPurchaseListBySupplierId(page, purchasePageQuery);
final List<Purchase> records = salePage.getRecords();
final List<String> purchaseIdList = new ArrayList<>();
for (Purchase record : records) {
purchaseIdList.add(record.getId());
}
final Map<String, List<PurchaseDetail>> purchaseDetailMap = new HashMap<>();
if (!purchaseIdList.isEmpty()) {
// 获取采购单明细
final List<PurchaseDetail> byPurchaseIdList = purchaseDetailService.getByPurchaseIdList(purchaseIdList, "");
for (PurchaseDetail purchaseDetail : byPurchaseIdList) {
final String purchaseId = purchaseDetail.getPurchaseId();
if (purchaseDetailMap.containsKey(purchaseId)) {
purchaseDetailMap.get(purchaseId).add(purchaseDetail);
} else {
final List<PurchaseDetail> purchaseDetails = new ArrayList<>();
purchaseDetails.add(purchaseDetail);
purchaseDetailMap.put(purchaseId, purchaseDetails);
}
}
// 获取规格及数量
// 获取规格信息
final List<StockLog> stockLogList = stockLogService.getByPurchaseIds(purchaseIdList, "");
final Map<String, List<StockLog>> stockLogMap = new HashMap<>();
// 封装规格属性
for (StockLog stockLog : stockLogList) {
final String orderId = stockLog.getOrderId();
if (stockLogMap.containsKey(orderId)) {
stockLogMap.get(orderId).add(stockLog);
} else {
final List<StockLog> stockLogs = new ArrayList<>();
stockLogs.add(stockLog);
stockLogMap.put(orderId, stockLogs);
}
}
// 将规格及数量封装到详细表中
for (PurchaseDetail purchaseDetail : byPurchaseIdList) {
final String purchaseId = purchaseDetail.getPurchaseId();
final String productId1 = purchaseDetail.getProductId();
if (stockLogMap.containsKey(purchaseId)) {
int purductCount = 0;
final List<StockLog> stockLogList1 = stockLogMap.get(purchaseId);
for (StockLog stockLog : stockLogList1) {
if (productId1.equals(stockLog.getProductId())) {
purductCount += stockLog.getProductCount();
final List<StockLog> stockLogList11 = purchaseDetail.getStockLogList1();
if (stockLogList11 == null) {
final List<StockLog> stockLogListNew = new ArrayList<>();
stockLogListNew.add(stockLog);
purchaseDetail.setStockLogList1(stockLogListNew);
} else {
purchaseDetail.getStockLogList1().add(stockLog);
}
}
}
// 将采购单明细中的数量放到采购单上
purchaseDetail.setProductCount(purductCount);
}
}
}
// 整合为返回的对象
final Page<PurchaseVo> purchaseVos = new Page<>(purchasePageQuery.getPageNum(), purchasePageQuery.getPageSize());
purchaseVos.setPages(salePage.getPages());
purchaseVos.setTotal(salePage.getTotal());
for (Purchase record : records) {
final String id = record.getId();
final PurchaseVo purchaseVo = new PurchaseVo();
purchaseVo.setPurchase(record);
if (purchaseDetailMap.containsKey(id)) {
final List<PurchaseDetail> purchaseDetails = purchaseDetailMap.get(id);
purchaseVo.setPurchaseDetails(purchaseDetails);
// 这里原本应该返回给count,最开始入库的时候存错了,所以以后就先用totalAmount
purchaseVo.getPurchase().setTotalAmount(BigDecimal.valueOf(purchaseDetails.get(0).getProductCount()));
}
// 获取供应商信息
if (StringUtils.isNotEmpty(supplierId)) {
final Supplier supplier = supplierService.findById(supplierId);
purchaseVo.setSupplier(supplier);
}
final List<PurchaseVo> vosRecords = purchaseVos.getRecords();
if (vosRecords.isEmpty()) {
final List<PurchaseVo> purchaseVoList = new ArrayList<>();
purchaseVoList.add(purchaseVo);
purchaseVos.setRecords(purchaseVoList);
} else {
purchaseVos.getRecords().add(purchaseVo);
}
}
return purchaseVos;
}
}

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

@ -459,10 +459,16 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
public Page<SupplierBuyProductLogVo> getSupplierBuyProductLog(SalePageQuery salePageQuery) {
final String shopId = securityUtil.getShopId();
//结束时间-1天
if (StringUtils.isNotEmpty(salePageQuery.getEndDate())) {
final String endDate = DateUtil.addDay(salePageQuery.getEndDate(), 1);
salePageQuery.setEndDate(endDate);
}
// 先拿到该客户购买的所有商品信息
final Page<SupplierBuyProductLogVo> page = new Page<>(salePageQuery.getPageNum(), salePageQuery.getPageSize());
final String supplierId = salePageQuery.getSupplierId();
final Page<SupplierBuyProductLogVo> salePage = saleMapper.getSupplierBuyProductLog(page, supplierId, shopId);
final Page<SupplierBuyProductLogVo> salePage = saleMapper.getSupplierBuyProductLog(page, salePageQuery);
final List<SupplierBuyProductLogVo> records = salePage.getRecords();
final List<String> productIds = new ArrayList<>();
// 商品id集合

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

@ -35,4 +35,9 @@ public class StockLogServiceImpl extends ServiceImpl<StockLogMapper, StockLog> i
stockLogMapper.deleteByPurchaseId(purchaseId);
}
@Override
public List<StockLog> getPurchaseDetails(List<String> purchaseIdList) {
return stockLogMapper.getPurchaseDetails(purchaseIdList);
}
}

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

@ -10,6 +10,7 @@ import cc.hiver.core.entity.User;
import cc.hiver.mall.common.constant.PurchaseConstant;
import cc.hiver.mall.common.constant.StockConstant;
import cc.hiver.mall.dao.mapper.StockMapper;
import cc.hiver.mall.debt.service.DebtService;
import cc.hiver.mall.entity.*;
import cc.hiver.mall.pojo.query.StockPageQuery;
import cc.hiver.mall.pojo.vo.*;
@ -62,6 +63,9 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
@Autowired
private SaleDetailService saleDetailService;
@Autowired
private DebtService debtService;
@Transactional
@Override
public Result putIn(PurchaseVo purchaseVo) {
@ -518,6 +522,8 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
if (purchaseDetailService.saveOrUpdateBatch(purchaseDetails)) {
// 更新商品信息
productService.saveOrUpdateBatch(updateProductList);
// 异步更新供应商欠款信息机欠款记录
debtService.purchaseToDebt(purchase);
return ResultUtil.success("添加成功");
} else {
return ResultUtil.error("添加入库单商品信息失败");
@ -1074,6 +1080,8 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
if (stockLogService.saveBatch(stockLogAddList)) {
// 更新商品信息
productService.saveOrUpdateBatch(updateProductList);
// 异步更新供应商欠款信息机欠款记录
debtService.purchaseToDebt(purchase);
return ResultUtil.success("添加成功");
} else {
return ResultUtil.error("添加入库单商品规格信息失败");

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

@ -162,4 +162,29 @@
</if>
order by tdr.create_time asc
</select>
<select id="getDealingsRecordPageBySupplierId" resultType="cc.hiver.mall.bill.vo.SupplierBillPurchaseVo">
select
tdr.sale_id as purchase_id,
tdr.create_by_name,
tdr.create_time,
tdr.last_debt_amount,
tdr.amount,
tdr.balance_due,
tdr.dealings_type,
ts.should_pay,
ts.balance_deduction_amount,
ts.already_pay
from
t_dealings_record tdr
left join t_purchase ts on ts.id = tdr.sale_id and ts.shop_id = #{supplierBillQueryVo.shopId}
WHERE
tdr.dealings_user_id = #{supplierBillQueryVo.supplierId}
and tdr.shop_id = #{supplierBillQueryVo.shopId}
and (tdr.sale_id is null or ts.in_storage_status = '1')
<if test='supplierBillQueryVo.startDate !=null and supplierBillQueryVo.endDate !=null'>
and tdr.create_time BETWEEN #{supplierBillQueryVo.startDate} AND #{supplierBillQueryVo.endDate}
</if>
order by tdr.create_time asc
</select>
</mapper>

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

@ -587,7 +587,9 @@
<include refid="Base_Column_List" />
from t_purchase_detail
where del_flag ='0'
<if test='productId != null and productId.trim() neq "" '>
and product_id = #{productId,jdbcType=VARCHAR}
</if>
and purchase_id in
<foreach close=")" collection="purchaseIds" item="listItem" open="(" separator=",">
#{listItem}
@ -629,4 +631,14 @@
<update id="deleteByPurchaseId" parameterType="java.lang.String">
update t_purchase_detail set del_flag = '1' where purchase_id = #{purchaseId,jdbcType=VARCHAR}
</update>
<select id="getPurchaseDetails" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_purchase_detail
where purchase_id in
<foreach close=")" collection="purchaseIdList" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</select>
</mapper>

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

@ -19,6 +19,7 @@
<result column="other_pay" jdbcType="DECIMAL" property="otherPay" />
<result column="in_storage_status" jdbcType="INTEGER" property="inStorageStatus" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="balance_deduction_amount" jdbcType="DECIMAL" property="balanceDeductionAmount" />
</resultMap>
<resultMap id="DebtResultMap" type="cc.hiver.mall.pojo.dto.DebtSupplier">
@ -87,7 +88,7 @@
</sql>
<sql id="Base_Column_List">
id, create_by,create_by_name, create_time, del_flag, update_by, update_time, supplier_id,supplier_name, shop_id,
total_amount, should_pay, already_pay, no_pay,other_pay, in_storage_status,remark
total_amount, should_pay, already_pay, no_pay,other_pay, in_storage_status,remark, balance_deduction_amount
</sql>
<select id="selectByExample" parameterType="cc.hiver.mall.entity.PurchaseExample" resultMap="BaseResultMap">
select
@ -123,13 +124,13 @@
insert into t_purchase (id, create_by, create_by_name, create_time,
del_flag, update_by, update_time,
supplier_id,supplier_name, shop_id, total_amount,
should_pay, already_pay, no_pay,other_pay, in_storage_status,remark
should_pay, already_pay, no_pay,other_pay, in_storage_status,remark, balance_deduction_amount
)
values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createByName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
#{supplierId,jdbcType=VARCHAR},#{supplierName,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR}, #{totalAmount,jdbcType=DECIMAL},
#{shouldPay,jdbcType=DECIMAL}, #{alreadyPay,jdbcType=DECIMAL}, #{noPay,jdbcType=DECIMAL}, #{otherPay,jdbcType=DECIMAL}, #{inStorageStatus,jdbcType=INTEGER},
#{remark,jdbcType=VARCHAR}
#{remark,jdbcType=VARCHAR}, #{balanceDeductionAmount,jdbcType=DECIMAL}
)
</insert>
<insert id="insertSelective" parameterType="cc.hiver.mall.entity.Purchase">
@ -186,6 +187,9 @@
<if test="remark != null">
remark,
</if>
<if test="balanceDeductionAmount != null">
balance_deduction_amount,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -292,6 +296,9 @@
<if test="record.remark != null">
remark = #{record.remark,jdbcType=VARCHAR},
</if>
<if test="record.balanceDeductionAmount != null">
balance_deduction_amount = #{record.balanceDeductionAmount,jdbcType=DECIMAL},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -315,7 +322,8 @@
no_pay = #{record.noPay,jdbcType=DECIMAL},
other_pay = #{record.otherPay,jdbcType=DECIMAL},
in_storage_status = #{record.inStorageStatus,jdbcType=INTEGER},
remark = #{record.remark,jdbcType=VARCHAR}
remark = #{record.remark,jdbcType=VARCHAR},
balance_deduction_amount = #{record.balanceDeductionAmount,jdbcType=DECIMAL}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -371,6 +379,9 @@
<if test="remark != null">
remark = #{remark,jdbcType=INTEGER},
</if>
<if test="balanceDeductionAmount != null">
balance_deduction_amount = #{balanceDeductionAmount,jdbcType=DECIMAL},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -391,7 +402,8 @@
no_pay = #{noPay,jdbcType=DECIMAL},
other_pay = #{otherPay,jdbcType=DECIMAL},
in_storage_status = #{inStorageStatus,jdbcType=INTEGER},
remark = #{remark,jdbcType=INTEGER}
remark = #{remark,jdbcType=INTEGER},
balance_deduction_amount = #{balanceDeductionAmount,jdbcType=DECIMAL}
where id = #{id,jdbcType=VARCHAR}
</update>
@ -422,6 +434,10 @@
<!-- 查询ai列表-->
and in_storage_status in ('2','3','4')
</if>
<!-- 根据供货商查询 -->
<if test="queryParams.supplierId != null and queryParams.supplierId != ''">
and supplier_id = #{queryParams.supplierId}
</if>
<if test="queryParams.searchStr != null and queryParams.searchStr != ''">
and (id in(
select purchase_id from t_purchase_detail
@ -512,4 +528,35 @@
</if>
order by purchase_date desc
</select>
<select id="getArrearsAndTotalSale" resultType="cc.hiver.mall.bill.vo.ArrearsVo">
select
sum(tp.should_pay) as total_sale
from
t_purchase tp
WHERE
tp.del_flag = '0'
and tp.supplier_id = #{supplierBillQueryVo.supplierId}
and tp.shop_id = #{supplierBillQueryVo.shopId}
<!-- 状态为已入库的 -->
and tp.in_storage_status = '1'
<if test='supplierBillQueryVo.startDate !=null and supplierBillQueryVo.endDate !=null'>
and tp.create_time BETWEEN #{supplierBillQueryVo.startDate} AND #{supplierBillQueryVo.endDate}
</if>
order by tp.create_time desc
</select>
<select id="getPurchaseListBySupplierId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_purchase
where del_flag ='0'
and supplier_id = #{purchasePageQuery.supplierId}
and in_storage_status = '1'
<if test='purchasePageQuery.startDate !=null and purchasePageQuery.endDate !=null'>
and create_time BETWEEN #{purchasePageQuery.startDate} AND #{purchasePageQuery.endDate}
</if>
order by create_time desc
</select>
</mapper>

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

@ -950,9 +950,12 @@ trans_company, company_name, product_count, remark, sale_name, company_phone, cr
FROM
t_purchase_detail t
WHERE
t.shop_id = #{shopId}
t.shop_id = #{salePageQuery.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 purchase_id IN ( SELECT id FROM t_purchase WHERE del_flag = 0 and in_storage_status = 1 and supplier_id = #{salePageQuery.supplierId} )
<if test='salePageQuery.startDate !=null and salePageQuery.endDate !=null'>
and t.create_time BETWEEN #{salePageQuery.startDate} AND #{salePageQuery.endDate}
</if>
GROUP BY
product_id, product_name,product_sn
order by product_name desc

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

@ -427,7 +427,9 @@
<include refid="Base_Column_List" />
from t_stock_log
where del_flag ='0'
<if test='productId != null and productId.trim() neq "" '>
and product_id = #{productId,jdbcType=VARCHAR}
</if>
and order_id in
<foreach close=")" collection="purchaseIds" item="listItem" open="(" separator=",">
#{listItem}
@ -456,4 +458,14 @@
update t_stock_log set purchase_price = #{item.purchasePrice} WHERE product_id = #{item.productId} and purchase_price is null
</foreach>
</update>
<select id="getPurchaseDetails" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_stock_log
where order_id in
<foreach close=")" collection="purchaseIdList" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</select>
</mapper>
Loading…
Cancel
Save