diff --git a/hiver-core/src/main/java/cc/hiver/core/common/constant/DealingsRecordConstant.java b/hiver-core/src/main/java/cc/hiver/core/common/constant/DealingsRecordConstant.java
index e6fd2343..7f609dcd 100644
--- a/hiver-core/src/main/java/cc/hiver/core/common/constant/DealingsRecordConstant.java
+++ b/hiver-core/src/main/java/cc/hiver/core/common/constant/DealingsRecordConstant.java
@@ -13,8 +13,8 @@ public interface DealingsRecordConstant {
Integer[] TYPE = {0, 1};
/**
- * 交易类型:0:开单;1:退货(应该是没用到);2:回款,3:新增客户/供应商欠款,4:充值;5:追加欠款;6:撤销订单;
+ * 交易类型: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};
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/controller/BillController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/controller/BillController.java
index 89d33d9d..793b14e0 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/controller/BillController.java
+++ b/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("获取供应商对账单异常");
+ }
+ }
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/service/BillService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/service/BillService.java
index dc19ba52..b830112e 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/service/BillService.java
+++ b/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);
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/service/impl/BillServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/service/impl/BillServiceImpl.java
index 19caa411..2af5580e 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/service/impl/BillServiceImpl.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/service/impl/BillServiceImpl.java
@@ -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
dealingRecordPage = dealingsRecordService.getDealingsRecordPageBySupplierId(supplierBillQueryVo);
+ final List records = dealingRecordPage.getRecords();
+
+ // 获取saleId,去查询销售单的商品明细,及退货单的商品明细
+ final List 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 purchaseDetails = purchaseDetailService.getPurchaseDetails(purchaseIdList);
+ // 将销售明细封装到销售单对象中
+ final Map> purchaseDetailMap = new HashMap<>();
+ for (PurchaseDetail purchaseDetail : purchaseDetails) {
+ final String purchaseId = purchaseDetail.getPurchaseId();
+ if (purchaseDetailMap.containsKey(purchaseId)) {
+ final List purchaseDetailList = purchaseDetailMap.get(purchaseId);
+ purchaseDetailList.add(purchaseDetail);
+ } else {
+ final List purchaseDetailArrayList = new ArrayList<>();
+ purchaseDetailArrayList.add(purchaseDetail);
+ purchaseDetailMap.put(purchaseId, purchaseDetailArrayList);
+ }
+ }
+ // 获取入库单规格明细
+ final List stockLogList = stockLogService.getPurchaseDetails(purchaseIdList);
+ final Map> stockLogMap = new HashMap<>();
+ for (StockLog stockLog : stockLogList) {
+ final String detailId = stockLog.getDetailId();
+ if (stockLogMap.containsKey(detailId)) {
+ final List stockLogListOfMap = stockLogMap.get(detailId);
+ stockLogListOfMap.add(stockLog);
+ } else {
+ final List stockLogListOfMap = new ArrayList<>();
+ stockLogListOfMap.add(stockLog);
+ stockLogMap.put(detailId, stockLogListOfMap);
+ }
+ }
+
+ // 开始封装数据
+ for (SupplierBillPurchaseVo supplierBillPurchaseVo : records) {
+ final String purchaseId = supplierBillPurchaseVo.getPurchaseId();
+ // 封装销售单信息
+ final List purchaseDetailList = purchaseDetailMap.get(purchaseId);
+ // 根据商品id分类
+ final Map> purchaseDetailMapOfSale = new HashMap<>();
+ if (purchaseDetailList != null && !purchaseDetailList.isEmpty()) {
+ for (PurchaseDetail purchaseDetail : purchaseDetailList) {
+ final String productId = purchaseDetail.getProductId();
+ if (purchaseDetailMapOfSale.containsKey(productId)) {
+ final List purchaseDetailsOfMap = purchaseDetailMapOfSale.get(productId);
+ purchaseDetailsOfMap.add(purchaseDetail);
+ } else {
+ final List purchaseDetailArrayList = new ArrayList<>();
+ purchaseDetailArrayList.add(purchaseDetail);
+ purchaseDetailMapOfSale.put(productId, purchaseDetailArrayList);
+ }
+ }
+ final List billSaleDetailVos = new ArrayList<>();
+ for (Map.Entry> stringListEntry : purchaseDetailMapOfSale.entrySet()) {
+ final List value = stringListEntry.getValue();
+ final BillProductDetailVo billProductDetailVo = new BillProductDetailVo();
+ // 同一款商品,不同规格,商品信息值几钱取第一个
+ billProductDetailVo.setProductSn(value.get(0).getProductSn());
+ billProductDetailVo.setProductName(value.get(0).getProductName());
+ final List billAttributeListVos = new ArrayList<>();
+ final List stockLogList1 = stockLogMap.get(value.get(0).getId());
+ if (stockLogList1 != null && !stockLogList1.isEmpty()) {
+ for (StockLog stockLog : stockLogList1) {
+ final BillAttributeListVo billAttributeListVo = new BillAttributeListVo();
+ billAttributeListVo.setAttributeList(stockLog.getAttributeList());
+ billAttributeListVo.setProductCount(stockLog.getProductCount());
+ billAttributeListVos.add(billAttributeListVo);
+ }
+ }
+ billProductDetailVo.setProductCount(value.get(0).getProductCount());
+ final BigDecimal purchasePrice = value.get(0).getPurchasePrice() == null ? BigDecimal.ZERO : value.get(0).getPurchasePrice();
+ final BigDecimal productCount = value.get(0).getProductCount() == null ? BigDecimal.ZERO : BigDecimal.valueOf(value.get(0).getProductCount());
+ billProductDetailVo.setTotalAmount(purchasePrice.multiply(productCount));
+ billProductDetailVo.setBillAttributeListVos(billAttributeListVos);
+ billSaleDetailVos.add(billProductDetailVo);
+ }
+ supplierBillPurchaseVo.setBillSaleDetailVos(billSaleDetailVos);
+ }
+ }
+ }
+ // 将销售信息存放到对账单中
+ supplierBillDataVo.setSupplierBillSaleVos(dealingRecordPage);
+ return supplierBillDataVo;
+ }
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillDataVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillDataVo.java
new file mode 100644
index 00000000..33134b72
--- /dev/null
+++ b/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 supplierBillSaleVos;
+
+}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillPurchaseVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillPurchaseVo.java
new file mode 100644
index 00000000..e316ba4d
--- /dev/null
+++ b/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 billSaleDetailVos;
+
+}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillQueryVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillQueryVo.java
new file mode 100644
index 00000000..39f899b8
--- /dev/null
+++ b/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;
+}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PurchaseController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PurchaseController.java
index 4bc74fac..c0634d46 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PurchaseController.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PurchaseController.java
@@ -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 purchaseVoList = purchaseService.getPurchaseListOfSupplier(purchasePageQuery);
+ return ResultUtil.data(purchaseVoList);
+ }
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SaleController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SaleController.java
index 81a14efc..5a8c3bef 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SaleController.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SaleController.java
@@ -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 salePage = saleService.getSupplierBuyProductLog(salePageQuery);
return ResultUtil.data(salePage);
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/DealingsRecordMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/DealingsRecordMapper.java
index 124f6ca6..a54737c6 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/DealingsRecordMapper.java
+++ b/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 {
void cancelRecord(@Param("saleId") String saleId);
Page getDealingsRecordPageByUserId(Page page, @Param("customerBillQueryVo") CustomerBillQueryVo customerBillQueryVo);
+
+ Page getDealingsRecordPageBySupplierId(Page page, @Param("supplierBillQueryVo") SupplierBillQueryVo supplierBillQueryVo);
}
\ No newline at end of file
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseDetailMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseDetailMapper.java
index 4be076e7..bda47ec2 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseDetailMapper.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseDetailMapper.java
@@ -42,4 +42,6 @@ public interface PurchaseDetailMapper extends BaseMapper {
void batchUpdatePurchaseList(@Param("purchaseDetails") List updatePurchaseDetails);
void deleteByPurchaseId(@Param("purchaseId") String purchaseId);
+
+ List getPurchaseDetails(@Param("purchaseIdList") List purchaseIdList);
}
\ No newline at end of file
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseMapper.java
index 5eed1d5c..8981fc7d 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseMapper.java
+++ b/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 {
void deleteByPurchaseId(@Param("id") String id);
Page purchasingCostDetail(Page page,@Param("purchasePageQuery") PurchasePageQuery purchasePageQuery);
+
+ ArrearsVo getArrearsAndTotalSale(@Param("supplierBillQueryVo") SupplierBillQueryVo supplierBillQueryVo);
+
+ /**
+ * 获取从某个供应商的拿货入库记录(按入库单)
+ * @author 王富康
+ * @date 2024/7/24
+ * @param page
+ * @param purchasePageQuery
+ * @return Page
+ */
+ Page getPurchaseListBySupplierId(Page page,@Param("purchasePageQuery") PurchasePageQuery purchasePageQuery);
}
\ No newline at end of file
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java
index bb6bd021..daf79645 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java
@@ -75,7 +75,7 @@ public interface SaleMapper extends BaseMapper {
List getSupplierBuyProductLogDetailLog(@Param("supplierId") String supplierId, @Param("shopId") String shopId, @Param("productIds") List productIds);
- Page getSupplierBuyProductLog(Page page, @Param("supplierId") String supplierId, @Param("shopId") String shopId);
+ Page getSupplierBuyProductLog(Page page,@Param("salePageQuery") SalePageQuery salePageQuery);
Page getSaleByCompanyId(Page page, @Param("salePageQuery") SalePageQuery salePageQuery);
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockLogMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockLogMapper.java
index a5de97ad..f05858a0 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockLogMapper.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockLogMapper.java
@@ -41,4 +41,6 @@ public interface StockLogMapper extends BaseMapper {
void deleteByPurchaseId(String purchaseId);
void putInUpdatePurchasePrice(@Param("purchaseDetails") List purchaseDetails);
+
+ List getPurchaseDetails(@Param("purchaseIdList") List purchaseIdList);
}
\ No newline at end of file
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/controller/DebtController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/controller/DebtController.java
index 7916cbe9..e7977218 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/controller/DebtController.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/controller/DebtController.java
@@ -29,10 +29,11 @@ public class DebtController {
/**
* / 根据店铺id查询欠款列表
+ *
+ * @param queryDebtVo 查询vo
+ * @return Result
* @author 王富康
* @date 2024/6/9
- * @param queryDebtVo 查询vo
- * @return Result
*/
@RequestMapping(value = "/getDebtByShopId", method = RequestMethod.POST)
@ApiOperation("根据店铺id查询欠款列表")
@@ -46,16 +47,17 @@ public class DebtController {
/**
* 新增客户欠款、回款、开单、退单修改客户欠款
- * @author 王富康
- * @date 2024/6/10
+ *
* @param debt
* @return Result
+ * @author 王富康
+ * @date 2024/6/10
*/
@RequestMapping(value = "/saveOrUpdateDebt", method = RequestMethod.POST)
@ApiOperation("新增/修改欠款")
public Result saveOrUpdateDebt(@RequestBody Debt debt) {
final Debt saveOrUpdateDebt = debtService.saveOrUpdateDebt(debt);
- if(saveOrUpdateDebt == null){
+ if (saveOrUpdateDebt == null) {
return new ResultUtil<>().setErrorMsg("查询欠款用户信息失败!");
}
return new ResultUtil<>().setData(saveOrUpdateDebt);
@@ -63,18 +65,40 @@ public class DebtController {
/**
* 充值;正数是减少欠款,负数是追加欠款
- * @author 王富康
- * @date 2024/6/30
+ *
* @param debt
* @return Result
+ * @author 王富康
+ * @date 2024/6/30
*/
@RequestMapping(value = "/recharge", method = RequestMethod.POST)
@ApiOperation("充值")
public Result recharge(@RequestBody Debt debt) {
final Debt saveOrUpdateDebt = debtService.recharge(debt);
- if(saveOrUpdateDebt == null){
+ if (saveOrUpdateDebt == null) {
return new ResultUtil<>().setErrorMsg("查询欠款用户信息失败!");
}
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);
+ }
+
+
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/DebtService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/DebtService.java
index 4c4c28cd..a8c48a78 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/DebtService.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/DebtService.java
@@ -2,37 +2,41 @@ 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;
import java.util.List;
-public interface DebtService extends IService {
+public interface DebtService extends IService {
/**
* 根据店铺id查询欠款列表
- * @author 王富康
- * @date 2024/6/10
+ *
* @param queryDebtVo
* @return Page
+ * @author 王富康
+ * @date 2024/6/10
*/
Page 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,22 +49,33 @@ public interface DebtService extends IService {
// 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
+ * @author 王富康
+ * @date 2024/6/22
*/
List getDebtByUserIds(List userIds);
/**
* 根据客户id获取欠款信息
- * @author 王富康
- * @date 2024/6/26
+ *
* @param userId
* @return Debt
+ * @author 王富康
+ * @date 2024/6/26
*/
- Debt selectByUserId(String shopId,String userId);
+ Debt selectByUserId(String shopId, String userId);
Debt recharge(Debt debt);
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/impl/DebtServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/impl/DebtServiceImpl.java
index 1eac465a..ad84c1e3 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/impl/DebtServiceImpl.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/impl/DebtServiceImpl.java
@@ -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 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 getDebtByUserIds(List userIds) {
return debtMapper.getDebtByUserIds(userIds);
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Purchase.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Purchase.java
index b5065d80..f7c747b9 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Purchase.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Purchase.java
@@ -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 = "起始日期")
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/PurchaseVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/PurchaseVo.java
index e4544017..734530de 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/PurchaseVo.java
+++ b/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 purchaseDetails;
+ @ApiModelProperty(value = "欠款信息")
+ private List dealingsRecords;
+
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/DealingsRecordService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/DealingsRecordService.java
index 5be8321a..9e8a2e6e 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/DealingsRecordService.java
+++ b/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 {
* @date 2024/7/6
*/
Page getDealingsRecordPageByUserId(CustomerBillQueryVo customerBillQueryVo);
+
+ /**
+ * 对账单分页获取
+ *
+ * @param supplierBillQueryVo
+ * @return Page
+ * @author 王富康
+ * @date 2024/7/6
+ */
+ Page getDealingsRecordPageBySupplierId(SupplierBillQueryVo supplierBillQueryVo);
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseDetailService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseDetailService.java
index 1572f2d3..8268a692 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseDetailService.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseDetailService.java
@@ -20,4 +20,6 @@ public interface PurchaseDetailService extends IService {
void batchSavePurchaseList(List purchaseDetails);
void deleteByPurchaseId(String purchaseId);
+
+ List getPurchaseDetails(List purchaseIdList);
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java
index 3105642f..b0fa54e3 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java
@@ -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 {
* @return List
*/
Page purchasingCostDetail(PurchasePageQuery purchasePageQuery);
+
+ ArrearsVo getArrearsAndTotalSale(SupplierBillQueryVo supplierBillQueryVo);
+
+ /**
+ * 获取从某个供应商的拿货入库记录(按入库单)
+ * @author 王富康
+ * @date 2024/7/24
+ * @param purchasePageQuery
+ * @return Page
+ */
+ Page getPurchaseListOfSupplier(PurchasePageQuery purchasePageQuery);
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockLogService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockLogService.java
index ad92c469..6b210680 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockLogService.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockLogService.java
@@ -13,4 +13,6 @@ public interface StockLogService extends IService {
void batchSaveStockLogList(List stockLogList);
void deleteByPurchaseId(String purchaseId);
+
+ List getPurchaseDetails(List purchaseIdList);
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/DealingsRecordServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/DealingsRecordServiceImpl.java
index 6ed65235..7361b933 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/DealingsRecordServiceImpl.java
+++ b/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 getDealingsRecordPageBySupplierId(SupplierBillQueryVo supplierBillQueryVo) {
+ final Page page = new Page<>(supplierBillQueryVo.getPageNum(), supplierBillQueryVo.getPageSize());
+ return dealingsRecordMapper.getDealingsRecordPageBySupplierId(page,supplierBillQueryVo);
+ }
+
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseDetailServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseDetailServiceImpl.java
index 92702807..990f84ad 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseDetailServiceImpl.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseDetailServiceImpl.java
@@ -81,4 +81,9 @@ public class PurchaseDetailServiceImpl extends ServiceImpl getPurchaseDetails(List purchaseIdList) {
+ return purchaseDetailMapper.getPurchaseDetails(purchaseIdList);
+ }
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java
index 477ec2e0..738cef77 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java
@@ -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 i
}
purchaseVo.setPurchaseDetails(purchaseDetails);
+ // 获取该入库单的欠款更新记录
+ purchaseVo.setDealingsRecords(dealingsRecordService.getDealingsRecordList(id));
return purchaseVo;
}
@@ -487,4 +491,121 @@ public class PurchaseServiceImpl extends ServiceImpl 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
+ */
+ @Override
+ public Page getPurchaseListOfSupplier(PurchasePageQuery purchasePageQuery) {
+ // 获取采购单主表信息
+ final Page 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 salePage = purchaseMapper.getPurchaseListBySupplierId(page, purchasePageQuery);
+ final List records = salePage.getRecords();
+ final List purchaseIdList = new ArrayList<>();
+ for (Purchase record : records) {
+ purchaseIdList.add(record.getId());
+ }
+ final Map> purchaseDetailMap = new HashMap<>();
+ if (!purchaseIdList.isEmpty()) {
+ // 获取采购单明细
+ final List 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 purchaseDetails = new ArrayList<>();
+ purchaseDetails.add(purchaseDetail);
+ purchaseDetailMap.put(purchaseId, purchaseDetails);
+ }
+ }
+
+ // 获取规格及数量
+ // 获取规格信息
+ final List stockLogList = stockLogService.getByPurchaseIds(purchaseIdList, "");
+ final Map> stockLogMap = new HashMap<>();
+ // 封装规格属性
+ for (StockLog stockLog : stockLogList) {
+ final String orderId = stockLog.getOrderId();
+ if (stockLogMap.containsKey(orderId)) {
+ stockLogMap.get(orderId).add(stockLog);
+ } else {
+ final List 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 stockLogList1 = stockLogMap.get(purchaseId);
+ for (StockLog stockLog : stockLogList1) {
+ if (productId1.equals(stockLog.getProductId())) {
+ purductCount += stockLog.getProductCount();
+ final List stockLogList11 = purchaseDetail.getStockLogList1();
+ if (stockLogList11 == null) {
+ final List stockLogListNew = new ArrayList<>();
+ stockLogListNew.add(stockLog);
+ purchaseDetail.setStockLogList1(stockLogListNew);
+ } else {
+ purchaseDetail.getStockLogList1().add(stockLog);
+ }
+ }
+ }
+ // 将采购单明细中的数量放到采购单上
+ purchaseDetail.setProductCount(purductCount);
+ }
+ }
+ }
+
+ // 整合为返回的对象
+ final Page 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 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 vosRecords = purchaseVos.getRecords();
+ if (vosRecords.isEmpty()) {
+ final List purchaseVoList = new ArrayList<>();
+ purchaseVoList.add(purchaseVo);
+ purchaseVos.setRecords(purchaseVoList);
+ } else {
+ purchaseVos.getRecords().add(purchaseVo);
+ }
+
+ }
+ return purchaseVos;
+ }
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java
index 87ebde65..31c86040 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java
@@ -459,10 +459,16 @@ public class SaleServiceImpl extends ServiceImpl implements Sa
public Page 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 page = new Page<>(salePageQuery.getPageNum(), salePageQuery.getPageSize());
final String supplierId = salePageQuery.getSupplierId();
- final Page salePage = saleMapper.getSupplierBuyProductLog(page, supplierId, shopId);
+ final Page salePage = saleMapper.getSupplierBuyProductLog(page, salePageQuery);
final List records = salePage.getRecords();
final List productIds = new ArrayList<>();
// 商品id集合
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockLogServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockLogServiceImpl.java
index fa66ed69..5cf181b1 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockLogServiceImpl.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockLogServiceImpl.java
@@ -35,4 +35,9 @@ public class StockLogServiceImpl extends ServiceImpl i
stockLogMapper.deleteByPurchaseId(purchaseId);
}
+ @Override
+ public List getPurchaseDetails(List purchaseIdList) {
+ return stockLogMapper.getPurchaseDetails(purchaseIdList);
+ }
+
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java
index 4785cdb8..552beeba 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java
@@ -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 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 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 implements
if (stockLogService.saveBatch(stockLogAddList)) {
// 更新商品信息
productService.saveOrUpdateBatch(updateProductList);
+ // 异步更新供应商欠款信息机欠款记录
+ debtService.purchaseToDebt(purchase);
return ResultUtil.success("添加成功");
} else {
return ResultUtil.error("添加入库单商品规格信息失败");
diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/DealingsRecordMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/DealingsRecordMapper.xml
index bc94c6d0..d6ad51ee 100644
--- a/hiver-modules/hiver-mall/src/main/resources/mapper/DealingsRecordMapper.xml
+++ b/hiver-modules/hiver-mall/src/main/resources/mapper/DealingsRecordMapper.xml
@@ -162,4 +162,29 @@
order by tdr.create_time asc
+
+
\ No newline at end of file
diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml
index 17671baa..4ba9c6eb 100644
--- a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml
+++ b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml
@@ -587,8 +587,10 @@
from t_purchase_detail
where del_flag ='0'
- and product_id = #{productId,jdbcType=VARCHAR}
- and purchase_id in
+
+ and product_id = #{productId,jdbcType=VARCHAR}
+
+ and purchase_id in
#{listItem}
@@ -629,4 +631,14 @@
update t_purchase_detail set del_flag = '1' where purchase_id = #{purchaseId,jdbcType=VARCHAR}
+
+
\ No newline at end of file
diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml
index aca1acce..3aae2652 100644
--- a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml
+++ b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml
@@ -19,6 +19,7 @@
+
@@ -87,7 +88,7 @@
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
+
+
+
+
+
\ No newline at end of file
diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml
index 5b7d2beb..2aef7eeb 100644
--- a/hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml
+++ b/hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml
@@ -950,10 +950,13 @@ 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} )
- GROUP BY
+ AND purchase_id IN ( SELECT id FROM t_purchase WHERE del_flag = 0 and in_storage_status = 1 and supplier_id = #{salePageQuery.supplierId} )
+
+ and t.create_time BETWEEN #{salePageQuery.startDate} AND #{salePageQuery.endDate}
+
+GROUP BY
product_id, product_name,product_sn
order by product_name desc
diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/StockLogMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/StockLogMapper.xml
index 41688f96..0bcbc52a 100644
--- a/hiver-modules/hiver-mall/src/main/resources/mapper/StockLogMapper.xml
+++ b/hiver-modules/hiver-mall/src/main/resources/mapper/StockLogMapper.xml
@@ -427,7 +427,9 @@
from t_stock_log
where del_flag ='0'
- and product_id = #{productId,jdbcType=VARCHAR}
+
+ and product_id = #{productId,jdbcType=VARCHAR}
+
and order_id in
#{listItem}
@@ -456,4 +458,14 @@
update t_stock_log set purchase_price = #{item.purchasePrice} WHERE product_id = #{item.productId} and purchase_price is null
+
+
\ No newline at end of file