Browse Source

统计页开发

cangku
wangfukang 2 years ago
parent
commit
b7bd409b7d
  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. 7
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/controller/BillController.java
  5. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/CustomerBillQueryVo.java
  6. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/LogiticsCompanyController.java
  7. 23
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PurchaseController.java
  8. 4
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ReturnCommissionController.java
  9. 62
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ReturnSaleController.java
  10. 60
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SaleController.java
  11. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java
  12. 58
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SupplierControlller.java
  13. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseMapper.java
  14. 13
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ReturnDetailMapper.java
  15. 38
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ReturnSaleMapper.java
  16. 22
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java
  17. 17
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/controller/DebtController.java
  18. 5
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/DebtService.java
  19. 91
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/impl/DebtServiceImpl.java
  20. 38
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/deductlog/service/impl/DeductLogServiceImpl.java
  21. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/ReturnDetail.java
  22. 10
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Supplier.java
  23. 6
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/invitelog/service/impl/InviteLogServiceImpl.java
  24. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/PurchasePageQuery.java
  25. 15
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/ReturnSalePageQuery.java
  26. 12
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/SalePageQuery.java
  27. 5
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/SupplierQueryCriteria.java
  28. 28
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/CustomerSaleDetailVo.java
  29. 41
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/PurchasingCostDetailVo.java
  30. 5
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ReturnSaleVo.java
  31. 39
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ReturnTotalAmountDetailVo.java
  32. 42
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/TotalAlreadyEarnDetailDayVo.java
  33. 39
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/TotalAmountDetailVo.java
  34. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/purchaseocr/service/impl/PurchaseOcrPictureServiceImpl.java
  35. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/SupplierService.java
  36. 10
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java
  37. 12
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ReturnDetailService.java
  38. 32
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ReturnSaleService.java
  39. 28
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleService.java
  40. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesAndDetailsServiceImpl.java
  41. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesCalculateServiceImpl.java
  42. 60
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SupplierServiceImpl.java
  43. 61
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java
  44. 31
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductCategoryServiceImpl.java
  45. 10
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java
  46. 19
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ReturnDetailServiceImpl.java
  47. 168
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ReturnSaleServiceImpl.java
  48. 80
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java
  49. 49
      hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml
  50. 42
      hiver-modules/hiver-mall/src/main/resources/mapper/ReturnDetailMapper.xml
  51. 101
      hiver-modules/hiver-mall/src/main/resources/mapper/ReturnSaleMapper.xml
  52. 120
      hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml

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

@ -317,11 +317,16 @@ ignored:
- /hiver/app/stock/productCount - /hiver/app/stock/productCount
# 选择物流公司 # 选择物流公司
- /hiver/app/logitics/chooseCompany - /hiver/app/logitics/chooseCompany
# 下游客户查询商品购买记录 # 根据客户id分页获取销售历史(按商品)
- /hiver/app/sale/getCustomerBuyProductLog - /hiver/app/sale/getCustomerBuyProductLog
# 客户对账单
- /hiver/app/bill/getCustomerBill
# 根据客户id分页获取退货历史
- /hiver/app/return/getReturnSaleListByUserId
# 根据客户id分页获取销售历史(按销售单)
- /hiver/app/sale/listPages
# # 临时增加 # # 临时增加
- /hiver/app/bill/getCustomerBill
# 限流及黑名单不拦截的路径 # 限流及黑名单不拦截的路径
limitUrls: limitUrls:
- /**/*.js - /**/*.js

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

@ -35,7 +35,7 @@
<a href="#"><span class="badge badge-primary">Hiver</span></a> <a href="#"><span class="badge badge-primary">Hiver</span></a>
</li> </li>
<li class="m-r-10"> <li class="m-r-10">
<a href="#"><span class="badge badge-primary">六月 28, 2024 09:09:27</span></a> <a href="#"><span class="badge badge-primary">七月 01, 2024 00:15:38</span></a>
</li> </li>
</ul> </ul>
</div> </div>
@ -84,7 +84,7 @@
<div class="test-detail"> <div class="test-detail">
<span class="meta text-white badge badge-sm"></span> <span class="meta text-white badge badge-sm"></span>
<p class="name">passTest</p> <p class="name">passTest</p>
<p class="text-sm"><span>09:09:28 上午</span> / <span>0.019 secs</span></p> <p class="text-sm"><span>00:15:38 上午</span> / <span>0.018 secs</span></p>
</div> </div>
<div class="test-contents d-none"> <div class="test-contents d-none">
<div class="detail-head"> <div class="detail-head">
@ -92,9 +92,9 @@
<div class="info"> <div class="info">
<div class='float-right'><span class='badge badge-default'>#test-id=1</span></div> <div class='float-right'><span class='badge badge-default'>#test-id=1</span></div>
<h5 class="test-status text-pass">passTest</h5> <h5 class="test-status text-pass">passTest</h5>
<span class='badge badge-success'>06.28.2024 09:09:28</span> <span class='badge badge-success'>07.01.2024 00:15:38</span>
<span class='badge badge-danger'>06.28.2024 09:09:28</span> <span class='badge badge-danger'>07.01.2024 00:15:38</span>
<span class='badge badge-default'>0.019 secs</span> <span class='badge badge-default'>0.018 secs</span>
</div> </div>
<div class="m-t-10 m-l-5"></div> <div class="m-t-10 m-l-5"></div>
</div> </div>
@ -104,7 +104,7 @@
<tbody> <tbody>
<tr class="event-row"> <tr class="event-row">
<td><span class="badge log pass-bg">Pass</span></td> <td><span class="badge log pass-bg">Pass</span></td>
<td>9:09:28</td> <td>0:15:38</td>
<td> <td>
Test passed Test passed
</td> </td>
@ -128,13 +128,13 @@
<div class="col-md-3"> <div class="col-md-3">
<div class="card"><div class="card-body"> <div class="card"><div class="card-body">
<p class="m-b-0">Started</p> <p class="m-b-0">Started</p>
<h3>六月 28, 2024 09:09:27</h3> <h3>七月 01, 2024 00:15:38</h3>
</div></div> </div></div>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<div class="card"><div class="card-body"> <div class="card"><div class="card-body">
<p class="m-b-0">Ended</p> <p class="m-b-0">Ended</p>
<h3>六月 28, 2024 09:09:28</h3> <h3>七月 01, 2024 00:15:38</h3>
</div></div> </div></div>
</div> </div>
<div class="col-md-3"> <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}; Integer[] TYPE = {0, 1};
/** /**
* 交易类型0:开单1退货2回款 * 交易类型0:开单1退货(应该是没用到)2回款3新增客户/供应商欠款4充值5追加欠款;6:撤销订单;
*/ */
Integer[] DEALINGS_TYPE = {0, 1, 2}; Integer[] DEALINGS_TYPE = {0, 1, 2, 3, 4, 5, 6};
} }

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

@ -8,6 +8,7 @@ import cc.hiver.mall.bill.vo.CustomerBillQueryVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -40,6 +41,12 @@ public class BillController {
@PostMapping("/getCustomerBill") @PostMapping("/getCustomerBill")
@ApiOperation("获取客户对账单") @ApiOperation("获取客户对账单")
public Result getCustomerBill(@RequestBody CustomerBillQueryVo customerBillQueryVo) { public Result getCustomerBill(@RequestBody CustomerBillQueryVo customerBillQueryVo) {
if(StringUtils.isEmpty(customerBillQueryVo.getCustomerId())){
return ResultUtil.error("客户id不能为空");
}
if(StringUtils.isEmpty(customerBillQueryVo.getShopId())){
return ResultUtil.error("店铺id不能为空");
}
try { try {
final CustomerBillDataVo customerBill = billService.getCustomerBill(customerBillQueryVo); final CustomerBillDataVo customerBill = billService.getCustomerBill(customerBillQueryVo);
return new ResultUtil<>().setData(customerBill); return new ResultUtil<>().setData(customerBill);

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

@ -15,6 +15,9 @@ public class CustomerBillQueryVo extends HiverBasePageQuery {
@ApiModelProperty(value = "客户id") @ApiModelProperty(value = "客户id")
private String customerId; private String customerId;
@ApiModelProperty(value = "店铺id")
private String shopId;
@ApiModelProperty(value = "开始时间") @ApiModelProperty(value = "开始时间")
private String startDate; private String startDate;

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/LogiticsCompanyController.java

@ -148,7 +148,7 @@ public class LogiticsCompanyController {
rechargeService.save(recharge); rechargeService.save(recharge);
final LogiticsCompany oldLogiticsCompany = companyService.findById(company.getId()); final LogiticsCompany oldLogiticsCompany = companyService.findById(company.getId());
final BigDecimal oldCompanyDepoBal = oldLogiticsCompany.getDepoBal() == null ? BigDecimal.valueOf(0) : oldLogiticsCompany.getDepoBal(); final BigDecimal oldCompanyDepoBal = oldLogiticsCompany.getDepoBal() == null ? BigDecimal.ZERO : oldLogiticsCompany.getDepoBal();
company.setDepoBal(oldCompanyDepoBal.add(company.getDepoNum())); company.setDepoBal(oldCompanyDepoBal.add(company.getDepoNum()));
company.setDepoNum(new BigDecimal(0)); company.setDepoNum(new BigDecimal(0));
} }

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

@ -11,6 +11,7 @@ import cc.hiver.mall.entity.PurchaseDetail;
import cc.hiver.mall.pojo.dto.DebtSupplier; import cc.hiver.mall.pojo.dto.DebtSupplier;
import cc.hiver.mall.pojo.query.PurchasePageQuery; import cc.hiver.mall.pojo.query.PurchasePageQuery;
import cc.hiver.mall.pojo.vo.PurchaseVo; import cc.hiver.mall.pojo.vo.PurchaseVo;
import cc.hiver.mall.pojo.vo.PurchasingCostDetailVo;
import cc.hiver.mall.service.mybatis.PurchaseDetailService; import cc.hiver.mall.service.mybatis.PurchaseDetailService;
import cc.hiver.mall.service.mybatis.PurchaseService; import cc.hiver.mall.service.mybatis.PurchaseService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -21,10 +22,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
@ -275,4 +273,21 @@ public class PurchaseController {
final PurchaseVo purchaseVo = purchaseService.getPurchaseAllDataOfAi(id); final PurchaseVo purchaseVo = purchaseService.getPurchaseAllDataOfAi(id);
return new ResultUtil<PurchaseVo>().setData(purchaseVo); return new ResultUtil<PurchaseVo>().setData(purchaseVo);
} }
/**
* 进货金额可查明细
* @author 王富康
* @date 2024/6/29
* @param purchasePageQuery
* @return Result
*/
@PostMapping("/purchasingCostDetail")
public Result purchasingCostDetail(@RequestBody PurchasePageQuery purchasePageQuery) {
try {
final Page<PurchasingCostDetailVo> purchasingCostDetail = purchaseService.purchasingCostDetail(purchasePageQuery);
return new ResultUtil<>().setData(purchasingCostDetail);
} catch (Exception e) {
log.info(e.getMessage(),e);
return ResultUtil.error("查询失败");
}
}
} }

4
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ReturnCommissionController.java

@ -103,7 +103,7 @@ public class ReturnCommissionController {
if(returnCommission.getCommission() == null ){ if(returnCommission.getCommission() == null ){
return ResultUtil.error("提现金额不能为空!"); return ResultUtil.error("提现金额不能为空!");
} }
if(returnCommission.getCommission().compareTo(BigDecimal.valueOf(0)) == 0){ if(returnCommission.getCommission().compareTo(BigDecimal.ZERO) == 0){
return ResultUtil.error("提现金额不能为0!"); return ResultUtil.error("提现金额不能为0!");
} }
if(StringUtils.isEmpty(returnCommission.getAliName())){ if(StringUtils.isEmpty(returnCommission.getAliName())){
@ -116,7 +116,7 @@ public class ReturnCommissionController {
boolean result = false; boolean result = false;
String aliResult = ""; String aliResult = "";
final Shop shop = shopService.findById(shopId); final Shop shop = shopService.findById(shopId);
if(shop.getYearFee() == null || shop.getYearFee().compareTo(BigDecimal.valueOf(0)) == 0){ if(shop.getYearFee() == null || shop.getYearFee().compareTo(BigDecimal.ZERO) == 0){
return ResultUtil.error("店铺处于试用期,不能提现!"); return ResultUtil.error("店铺处于试用期,不能提现!");
} }
//支付宝户名(姓名) //支付宝户名(姓名)

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

@ -16,10 +16,7 @@ import cc.hiver.mall.pojo.dto.SaleDetailDTO;
import cc.hiver.mall.pojo.dto.SaleDetailQueryDTO; import cc.hiver.mall.pojo.dto.SaleDetailQueryDTO;
import cc.hiver.mall.pojo.dto.SaleReturnDTO; import cc.hiver.mall.pojo.dto.SaleReturnDTO;
import cc.hiver.mall.pojo.query.ReturnSalePageQuery; import cc.hiver.mall.pojo.query.ReturnSalePageQuery;
import cc.hiver.mall.pojo.vo.ReturnSaleVo; import cc.hiver.mall.pojo.vo.*;
import cc.hiver.mall.pojo.vo.SaleComVO;
import cc.hiver.mall.pojo.vo.SaleQueryVO;
import cc.hiver.mall.pojo.vo.SaleReturnVO;
import cc.hiver.mall.service.*; import cc.hiver.mall.service.*;
import cc.hiver.mall.service.mybatis.*; import cc.hiver.mall.service.mybatis.*;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
@ -465,11 +462,64 @@ public class ReturnSaleController {
return new ResultUtil<IPage<ReturnSaleVo>>().setData(result); return new ResultUtil<IPage<ReturnSaleVo>>().setData(result);
} }
/**
* 根据商品id分页获取退货历史
*
* @param returnSalePageQuery
* @return Result
* @author 王富康
* @date 2024/6/29
*/
@RequestMapping(value = "/getReturnSaleListByProductId", method = RequestMethod.POST) @RequestMapping(value = "/getReturnSaleListByProductId", method = RequestMethod.POST)
@ApiOperation("根据商品id分页获取退货历史") @ApiOperation("根据商品id分页获取退货历史")
public Result getReturnSaleListByProductId(ReturnSalePageQuery returnSalePageQuery) { public Result getReturnSaleListByProductId(@RequestBody ReturnSalePageQuery returnSalePageQuery) {
if(StringUtils.isEmpty(returnSalePageQuery.getProductId())){
return ResultUtil.error("商品id不能为空");
}
// 分页获取销售单历史
final Page<ReturnSaleVo> salePage = returnSaleService.getReturnSaleListByProductId(returnSalePageQuery);
return ResultUtil.data(salePage);
}
/**
* 根据客户id分页获取退货历史
*
* @param returnSalePageQuery
* @return Result
* @author 王富康
* @date 2024/6/29
*/
@RequestMapping(value = "/getReturnSaleListByUserId", method = RequestMethod.POST)
@ApiOperation("根据客户id分页获取退货历史")
public Result getReturnSaleListByUserId(@RequestBody ReturnSalePageQuery returnSalePageQuery) {
if(StringUtils.isEmpty(returnSalePageQuery.getUserId())){
return ResultUtil.error("客户id不能为空");
}
if(StringUtils.isEmpty(returnSalePageQuery.getShopId())){
return ResultUtil.error("店铺id不能为空");
}
// 分页获取销售单历史 // 分页获取销售单历史
final Page<SaleReturnDTO> salePage = returnSaleService.getReturnSaleListByProductId(returnSalePageQuery); final Page<ReturnSaleVo> salePage = returnSaleService.getReturnSaleListByUserId(returnSalePageQuery);
return ResultUtil.data(salePage); return ResultUtil.data(salePage);
} }
/**
* 退货金额明细
*
* @param returnSalePageQuery
* @return Result
* @author 王富康
* @date 2024/6/29
*/
@PostMapping("/returnTotalAmountDetail")
public Result returnTotalAmountDetail(@RequestBody ReturnSalePageQuery returnSalePageQuery) {
try {
final Page<ReturnTotalAmountDetailVo> returnTotalAmountDetail = returnSaleService.returnTotalAmountDetail(returnSalePageQuery);
return new ResultUtil<>().setData(returnTotalAmountDetail);
} catch (Exception e) {
log.info(e.getMessage(), e);
return ResultUtil.error("查询失败");
}
}
} }

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

@ -226,7 +226,7 @@ public class SaleController {
final BigDecimal debtDeductionAmount = saleQueryDTO.getSale().getDebtDeductionAmount(); final BigDecimal debtDeductionAmount = saleQueryDTO.getSale().getDebtDeductionAmount();
// 余额抵扣金额 // 余额抵扣金额
final BigDecimal balanceDeductionAmount = saleQueryDTO.getSale().getBalanceDeductionAmount(); final BigDecimal balanceDeductionAmount = saleQueryDTO.getSale().getBalanceDeductionAmount();
if (noEarn.compareTo(BigDecimal.valueOf(0)) != 0 || debtDeductionAmount.compareTo(BigDecimal.valueOf(0)) != 0 || balanceDeductionAmount.compareTo(BigDecimal.valueOf(0)) != 0) { if (noEarn.compareTo(BigDecimal.ZERO) != 0 || debtDeductionAmount.compareTo(BigDecimal.ZERO) != 0 || balanceDeductionAmount.compareTo(BigDecimal.ZERO) != 0) {
debtService.saleToDebt(saleQueryDTO); debtService.saleToDebt(saleQueryDTO);
} }
return new ResultUtil<>().setData(sale.getId(), "下单成功"); return new ResultUtil<>().setData(sale.getId(), "下单成功");
@ -979,6 +979,9 @@ public class SaleController {
@RequestMapping(value = "/getCustomerBuyProductLog", method = RequestMethod.POST) @RequestMapping(value = "/getCustomerBuyProductLog", method = RequestMethod.POST)
@ApiOperation("下游客户查询商品购买记录") @ApiOperation("下游客户查询商品购买记录")
public Result getCustomerBuyProductLog(@RequestBody SalePageQuery salePageQuery) { public Result getCustomerBuyProductLog(@RequestBody SalePageQuery salePageQuery) {
if(StringUtils.isEmpty(salePageQuery.getShopId())){
return ResultUtil.error("店铺id不能为空");
}
final Page<CustomerBuyProductLogVo> salePage = saleService.getCustomerBuyProductLog(salePageQuery); final Page<CustomerBuyProductLogVo> salePage = saleService.getCustomerBuyProductLog(salePageQuery);
return ResultUtil.data(salePage); return ResultUtil.data(salePage);
} }
@ -1099,4 +1102,59 @@ public class SaleController {
return ResultUtil.error("撤销失败!"); return ResultUtil.error("撤销失败!");
} }
} }
/**
* 点击销售金额查询销售明细
*
* @param salePageQuery
* @return Result
* @author 王富康
* @date 2024/6/29
*/
@PostMapping("/totalAmountDetail")
public Result totalAmountDetail(@RequestBody SalePageQuery salePageQuery) {
try {
final Page<TotalAmountDetailVo> totalAmountDetail = saleService.totalAmountDetail(salePageQuery);
return new ResultUtil<>().setData(totalAmountDetail);
} catch (Exception e) {
log.info(e.getMessage(),e);
return ResultUtil.error("查询失败");
}
}
/**
* 实收金额明细
* @author 王富康
* @date 2024/6/29
* @param salePageQuery
* @return Result
*/
@PostMapping("/totalAlreadyEarnDetail")
public Result totalAlreadyEarnDetail(@RequestBody SalePageQuery salePageQuery) {
try {
final Page<TotalAlreadyEarnDetailDayVo> totalAlreadyEarnDetail = saleService.totalAlreadyEarnDetail(salePageQuery);
return new ResultUtil<>().setData(totalAlreadyEarnDetail);
} catch (Exception e) {
log.info(e.getMessage(),e);
return ResultUtil.error("查询失败");
}
}
/**
* 客户拿货统计
* @author 王富康
* @date 2024/6/29
* @param salePageQuery
* @return Result
*/
@PostMapping("/customerSaleDetail")
public Result customerSaleDetail(@RequestBody SalePageQuery salePageQuery) {
try {
final Page<CustomerSaleDetailVo> customerSaleDetail = saleService.customerSaleDetail(salePageQuery);
return new ResultUtil<>().setData(customerSaleDetail);
} catch (Exception e) {
log.info(e.getMessage(),e);
return ResultUtil.error("查询失败");
}
}
} }

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

@ -171,7 +171,7 @@ public class ShopController {
} }
// 设置返佣 // 设置返佣
if (shop.getYearFee() != null && shop.getYearFee().compareTo(BigDecimal.valueOf(0)) > 0) { if (shop.getYearFee() != null && shop.getYearFee().compareTo(BigDecimal.ZERO) > 0) {
inviteLogService.updateInviteLogIsOpen(shop.getId()); inviteLogService.updateInviteLogIsOpen(shop.getId());
} }
return ResultUtil.success("编辑成功"); return ResultUtil.success("编辑成功");

58
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SupplierControlller.java

@ -1,14 +1,20 @@
package cc.hiver.mall.controller; package cc.hiver.mall.controller;
import cc.hiver.core.common.constant.CommonConstant; import cc.hiver.core.common.constant.CommonConstant;
import cc.hiver.core.common.constant.DealingsRecordConstant;
import cc.hiver.core.common.utils.PageUtil; import cc.hiver.core.common.utils.PageUtil;
import cc.hiver.core.common.utils.ResultUtil; import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.utils.SecurityUtil; import cc.hiver.core.common.utils.SecurityUtil;
import cc.hiver.core.common.vo.PageVo; import cc.hiver.core.common.vo.PageVo;
import cc.hiver.core.common.vo.Result; import cc.hiver.core.common.vo.Result;
import cc.hiver.core.entity.User;
import cc.hiver.mall.debt.constant.DebtConstant;
import cc.hiver.mall.debt.entity.Debt;
import cc.hiver.mall.debt.service.DebtService;
import cc.hiver.mall.entity.DealingsRecord;
import cc.hiver.mall.entity.Supplier; import cc.hiver.mall.entity.Supplier;
import cc.hiver.mall.pojo.query.SupplierQueryCriteria;
import cc.hiver.mall.service.SupplierService; import cc.hiver.mall.service.SupplierService;
import cc.hiver.mall.service.mybatis.DealingsRecordService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -17,6 +23,8 @@ import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
@Slf4j @Slf4j
@ -31,13 +39,19 @@ public class SupplierControlller {
@Autowired @Autowired
private SecurityUtil securityUtil; private SecurityUtil securityUtil;
@Autowired
private DebtService debtService;
@Autowired
private DealingsRecordService dealingsRecordService;
@RequestMapping(value = "/getByCondition", method = RequestMethod.POST) @RequestMapping(value = "/getByCondition", method = RequestMethod.POST)
@ApiOperation(value = "根据条件获得分页") @ApiOperation(value = "根据条件获得分页")
public Result<Page<Supplier>> queryAll(SupplierQueryCriteria criteria, PageVo pageVo) { public Result<Page<Supplier>> queryAll(Supplier supplierOfquery, PageVo pageVo) {
// 从缓存中拿到店铺id // 从缓存中拿到店铺id
final String shopId = securityUtil.getShopId(); final String shopId = securityUtil.getShopId();
criteria.setShopId(shopId); supplierOfquery.setShopId(shopId);
Page<Supplier> users = supplierService.queryAll(criteria, PageUtil.initPage(pageVo)); Page<Supplier> users = supplierService.queryAll(supplierOfquery, PageUtil.initPage(pageVo));
return new ResultUtil<Page<Supplier>>().setData(users); return new ResultUtil<Page<Supplier>>().setData(users);
} }
@ -70,8 +84,40 @@ public class SupplierControlller {
final String shopId = securityUtil.getShopId(); final String shopId = securityUtil.getShopId();
entity.setShopId(shopId); entity.setShopId(shopId);
entity.setDelFlag(CommonConstant.DEL_FLAG_FALSE); entity.setDelFlag(CommonConstant.DEL_FLAG_FALSE);
Supplier address = supplierService.save(entity); Supplier supplier = supplierService.save(entity);
return new ResultUtil<Supplier>().setData(address); // 新增供应商欠款
// 客户欠款信息
final BigDecimal noEarn = entity.getNoEarn() == null ? BigDecimal.ZERO : entity.getNoEarn();
final Debt debt = new Debt();
debt.setUserId(supplier.getId());
debt.setUserName(supplier.getConsigneeName());
debt.setAmountOwed(noEarn);
debt.setUserType(DebtConstant.USER_TYPE[1]);
debtService.save(debt);
// 新增交易记录
// 2. 新增欠款记录
final User user = securityUtil.getCurrUser();
final DealingsRecord dealingsRecord = new DealingsRecord();
dealingsRecord.setCreateBy(user.getId());
dealingsRecord.setCreateByName(user.getNickname());
dealingsRecord.setCreateTime(new Date());
dealingsRecord.setDealingsUserId(supplier.getId());
dealingsRecord.setDealingsUserName(supplier.getConsigneeName());
dealingsRecord.setUserType(DealingsRecordConstant.TYPE[1]);
dealingsRecord.setDealingsWay("新增供应商欠款");
dealingsRecord.setShopId(shopId);
// 销售金额
dealingsRecord.setSaleAmount(BigDecimal.ZERO);
// 退货金额
dealingsRecord.setReturnAmount(BigDecimal.ZERO);
// 上次欠款
dealingsRecord.setLastDebtAmount(BigDecimal.ZERO);
// 最新欠款
dealingsRecord.setBalanceDue(noEarn);
dealingsRecord.setAmount(noEarn);
dealingsRecord.setDealingsType(DealingsRecordConstant.DEALINGS_TYPE[3]);
dealingsRecordService.save(dealingsRecord);
return new ResultUtil<Supplier>().setData(supplier);
} }
@RequestMapping(value = "/edit", method = RequestMethod.POST) @RequestMapping(value = "/edit", method = RequestMethod.POST)

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

@ -4,6 +4,7 @@ import cc.hiver.mall.entity.Purchase;
import cc.hiver.mall.entity.PurchaseExample; import cc.hiver.mall.entity.PurchaseExample;
import cc.hiver.mall.pojo.dto.DebtSupplier; import cc.hiver.mall.pojo.dto.DebtSupplier;
import cc.hiver.mall.pojo.query.PurchasePageQuery; import cc.hiver.mall.pojo.query.PurchasePageQuery;
import cc.hiver.mall.pojo.vo.PurchasingCostDetailVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -46,4 +47,6 @@ public interface PurchaseMapper extends BaseMapper<Purchase> {
void updateInStorageStatus(@Param("id")String id,@Param("inStorageStatus") int inStorageStatus); void updateInStorageStatus(@Param("id")String id,@Param("inStorageStatus") int inStorageStatus);
void deleteByPurchaseId(@Param("id") String id); void deleteByPurchaseId(@Param("id") String id);
Page<PurchasingCostDetailVo> purchasingCostDetail(Page<PurchasingCostDetailVo> page,@Param("purchasePageQuery") PurchasePageQuery purchasePageQuery);
} }

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

@ -2,6 +2,7 @@ package cc.hiver.mall.dao.mapper;
import cc.hiver.mall.entity.ReturnDetail; import cc.hiver.mall.entity.ReturnDetail;
import cc.hiver.mall.entity.ReturnDetailExample; import cc.hiver.mall.entity.ReturnDetailExample;
import cc.hiver.mall.pojo.query.ReturnSalePageQuery;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -33,4 +34,16 @@ public interface ReturnDetailMapper extends BaseMapper<ReturnDetail> {
int updateByPrimaryKey(ReturnDetail record); int updateByPrimaryKey(ReturnDetail record);
List<ReturnDetail> getReturnDetails(@Param("saleIdList") List<String> saleIdList); List<ReturnDetail> getReturnDetails(@Param("saleIdList") List<String> saleIdList);
/**
* 根据商品id分页获取退货历史
*
* @param returnSalePageQuery
* @return List<ReturnDetail>
* @author 王富康
* @date 2024/6/29
*/
List<ReturnDetail> getReturnDetailsByProductId(@Param("returnSalePageQuery") ReturnSalePageQuery returnSalePageQuery);
List<ReturnDetail> getReturnDetailsByReturnId(@Param("returnSaleIdList") List<String> returnSaleIdList);
} }

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

@ -4,8 +4,9 @@ import cc.hiver.mall.bill.vo.ArrearsVo;
import cc.hiver.mall.bill.vo.CustomerBillQueryVo; import cc.hiver.mall.bill.vo.CustomerBillQueryVo;
import cc.hiver.mall.entity.ReturnSale; import cc.hiver.mall.entity.ReturnSale;
import cc.hiver.mall.entity.ReturnSaleExample; import cc.hiver.mall.entity.ReturnSaleExample;
import cc.hiver.mall.pojo.dto.SaleReturnDTO; import cc.hiver.mall.pojo.query.ReturnSalePageQuery;
import cc.hiver.mall.pojo.vo.ReturnSaleVo; import cc.hiver.mall.pojo.vo.ReturnSaleVo;
import cc.hiver.mall.pojo.vo.ReturnTotalAmountDetailVo;
import cc.hiver.mall.pojo.vo.SaleAllVO; import cc.hiver.mall.pojo.vo.SaleAllVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -13,6 +14,7 @@ import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
@Repository @Repository
public interface ReturnSaleMapper extends BaseMapper<ReturnSale> { public interface ReturnSaleMapper extends BaseMapper<ReturnSale> {
long countByExample(ReturnSaleExample example); long countByExample(ReturnSaleExample example);
@ -43,9 +45,39 @@ public interface ReturnSaleMapper extends BaseMapper<ReturnSale> {
ReturnSale getBySaleId(String id); ReturnSale getBySaleId(String id);
List<ReturnSaleVo> getReturnSaleList(Page<ReturnSaleVo> page,@Param("queryParams") ReturnSaleVo returnSaleVo); List<ReturnSaleVo> getReturnSaleList(Page<ReturnSaleVo> page, @Param("queryParams") ReturnSaleVo returnSaleVo);
ArrearsVo getTotalReturn(@Param("customerBillQueryVo") CustomerBillQueryVo customerBillQueryVo); ArrearsVo getTotalReturn(@Param("customerBillQueryVo") CustomerBillQueryVo customerBillQueryVo);
Page<SaleReturnDTO> getReturnSaleListByProductId(Page<SaleReturnDTO> page,@Param("productId") String productId); /**
* 根据商品id分页获取退货历史
*
* @param page
* @return Page<ReturnSaleVo>
* @author 王富康
* @date 2024/6/29
*/
Page<ReturnSaleVo> getReturnSaleListByProductId(Page<ReturnSaleVo> page, @Param("returnSalePageQuery") ReturnSalePageQuery returnSalePageQuery);
/**
* 退货金额明细
*
* @param page
* @param returnSalePageQuery
* @return Page<returnTotalAmountDetailVo>
* @author 王富康
* @date 2024/6/29
*/
Page<ReturnTotalAmountDetailVo> returnTotalAmountDetail(Page<ReturnTotalAmountDetailVo> page, @Param("returnSalePageQuery") ReturnSalePageQuery returnSalePageQuery);
/**
* 根据客户id分页获取退货历史
*
* @param page
* @param returnSalePageQuery
* @return Page<ReturnSaleVo>
* @author 王富康
* @date 2024/6/30
*/
Page<ReturnSaleVo> getReturnSaleListByUserId(Page<ReturnSaleVo> page, @Param("returnSalePageQuery") ReturnSalePageQuery returnSalePageQuery);
} }

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

@ -91,4 +91,26 @@ public interface SaleMapper extends BaseMapper<Sale> {
Page<CustomerBillSaleVo> getCustomerBill(Page<CustomerBillSaleVo> page,@Param("customerBillQueryVo") CustomerBillQueryVo customerBillQueryVo); Page<CustomerBillSaleVo> getCustomerBill(Page<CustomerBillSaleVo> page,@Param("customerBillQueryVo") CustomerBillQueryVo customerBillQueryVo);
ArrearsVo getArrearsAndTotalSale( @Param("customerBillQueryVo") CustomerBillQueryVo customerBillQueryVo); ArrearsVo getArrearsAndTotalSale( @Param("customerBillQueryVo") CustomerBillQueryVo customerBillQueryVo);
Page<TotalAmountDetailVo> totalAmountDetail(Page<TotalAmountDetailVo> page, @Param("salePageQuery") SalePageQuery salePageQuery);
/**
* 实收金额明细
* @author 王富康
* @date 2024/6/29
* @param page
* @param salePageQuery
* @return List<TotalAlreadyEarnDetailDayVo>
*/
Page<TotalAlreadyEarnDetailDayVo> totalAlreadyEarnDetail(Page<TotalAlreadyEarnDetailDayVo> page,@Param("salePageQuery") SalePageQuery salePageQuery);
/**
* 客户拿货统计
* @author 王富康
* @date 2024/6/29
* @param page
* @param salePageQuery
* @return Page<CustomerSaleDetailVo>
*/
Page<CustomerSaleDetailVo> customerSaleDetail(Page<CustomerSaleDetailVo> page,@Param("salePageQuery") SalePageQuery salePageQuery);
} }

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

@ -60,4 +60,21 @@ public class DebtController {
} }
return new ResultUtil<>().setData(saveOrUpdateDebt); return new ResultUtil<>().setData(saveOrUpdateDebt);
} }
/**
* 充值正数是减少欠款负数是追加欠款
* @author 王富康
* @date 2024/6/30
* @param debt
* @return Result
*/
@RequestMapping(value = "/recharge", method = RequestMethod.POST)
@ApiOperation("充值")
public Result recharge(@RequestBody Debt debt) {
final Debt saveOrUpdateDebt = debtService.recharge(debt);
if(saveOrUpdateDebt == null){
return new ResultUtil<>().setErrorMsg("查询欠款用户信息失败!");
}
return new ResultUtil<>().setData(saveOrUpdateDebt);
}
} }

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

@ -4,10 +4,11 @@ import cc.hiver.mall.debt.entity.Debt;
import cc.hiver.mall.debt.vo.QueryDebtVo; import cc.hiver.mall.debt.vo.QueryDebtVo;
import cc.hiver.mall.pojo.dto.SaleQueryDTO; import cc.hiver.mall.pojo.dto.SaleQueryDTO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List; import java.util.List;
public interface DebtService { public interface DebtService extends IService<Debt> {
/** /**
* 根据店铺id查询欠款列表 * 根据店铺id查询欠款列表
@ -60,4 +61,6 @@ public interface DebtService {
* @return Debt * @return Debt
*/ */
Debt selectByUserId(String userId); Debt selectByUserId(String userId);
Debt recharge(Debt debt);
} }

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

@ -77,10 +77,10 @@ public class DebtServiceImpl extends ServiceImpl<DebtMapper, Debt> implements De
String userType = debt.getUserType(); String userType = debt.getUserType();
String dealingsUserId = ""; String dealingsUserId = "";
String dealingsUserName = ""; String dealingsUserName = "";
if(DebtConstant.USER_TYPE[0].equals(userType)){ if (DebtConstant.USER_TYPE[0].equals(userType)) {
//客户欠款 //客户欠款
final Customer customer = customerService.getById(userId); final Customer customer = customerService.getById(userId);
if(customer == null){ if (customer == null) {
return null; return null;
} }
dealingsUserId = customer.getId(); dealingsUserId = customer.getId();
@ -89,10 +89,10 @@ public class DebtServiceImpl extends ServiceImpl<DebtMapper, Debt> implements De
debt.setUserName(customer.getName()); debt.setUserName(customer.getName());
debt.setUserPhone(customer.getPhone()); debt.setUserPhone(customer.getPhone());
debt.setUserAdress(customer.getAddress()); debt.setUserAdress(customer.getAddress());
}else{ } else {
// 供应商信息 // 供应商信息
final Supplier supplier = supplierService.findById(userId); final Supplier supplier = supplierService.findById(userId);
if(supplier == null){ if (supplier == null) {
return null; return null;
} }
dealingsUserId = supplier.getId(); dealingsUserId = supplier.getId();
@ -105,8 +105,8 @@ public class DebtServiceImpl extends ServiceImpl<DebtMapper, Debt> implements De
final Debt oldDebt = debtMapper.selectByUserId(shopId, userId); final Debt oldDebt = debtMapper.selectByUserId(shopId, userId);
String dealingsWay = ""; String dealingsWay = "";
BigDecimal lastDebtAmount = BigDecimal.valueOf(0); BigDecimal lastDebtAmount = BigDecimal.ZERO;
BigDecimal newDebtAmount = BigDecimal.valueOf(0); BigDecimal newDebtAmount = BigDecimal.ZERO;
if (oldDebt == null) { if (oldDebt == null) {
dealingsWay = "新增欠款"; dealingsWay = "新增欠款";
// 新增 // 新增
@ -114,7 +114,7 @@ public class DebtServiceImpl extends ServiceImpl<DebtMapper, Debt> implements De
newDebtAmount = debt.getAmountOwed(); newDebtAmount = debt.getAmountOwed();
} else { } else {
dealingsWay = "回款"; dealingsWay = "回款";
lastDebtAmount = oldDebt.getAmountOwed(); lastDebtAmount = oldDebt.getAmountOwed() == null ? BigDecimal.ZERO : oldDebt.getAmountOwed();
// 计算欠款 // 计算欠款
newDebtAmount = oldDebt.getAmountOwed().subtract(debt.getAmountOwed()); newDebtAmount = oldDebt.getAmountOwed().subtract(debt.getAmountOwed());
oldDebt.setAmountOwed(newDebtAmount); oldDebt.setAmountOwed(newDebtAmount);
@ -165,26 +165,26 @@ public class DebtServiceImpl extends ServiceImpl<DebtMapper, Debt> implements De
debt.setUserPhone(customer.getPhone()); debt.setUserPhone(customer.getPhone());
debt.setUserAdress(customer.getAddress()); debt.setUserAdress(customer.getAddress());
// 本单欠款 // 本单欠款
BigDecimal noEarn = saleQueryDTO.getSale().getNoEarn() == null ? BigDecimal.valueOf(0) : saleQueryDTO.getSale().getNoEarn(); BigDecimal noEarn = saleQueryDTO.getSale().getNoEarn() == null ? BigDecimal.ZERO : saleQueryDTO.getSale().getNoEarn();
debt.setAmountOwed(noEarn); debt.setAmountOwed(noEarn);
debt.setUserType(DebtConstant.USER_TYPE[0]); debt.setUserType(DebtConstant.USER_TYPE[0]);
final String shopId = securityUtil.getShopId(); final String shopId = securityUtil.getShopId();
debt.setShopId(shopId); debt.setShopId(shopId);
final String userId = saleQueryDTO.getSale().getUserId(); final String userId = saleQueryDTO.getSale().getUserId();
final Debt oldDebt = debtMapper.selectByUserId(shopId, userId); final Debt oldDebt = debtMapper.selectByUserId(shopId, userId);
BigDecimal lastDebtAmount = BigDecimal.valueOf(0); BigDecimal lastDebtAmount = BigDecimal.ZERO;
BigDecimal newDebtAmount; BigDecimal newDebtAmount;
// 欠款抵扣,需要单独从欠款中减掉 // 欠款抵扣,需要单独从欠款中减掉
final BigDecimal debtDeductionAmount = saleQueryDTO.getSale().getDebtDeductionAmount() == null ? BigDecimal.valueOf(0) : saleQueryDTO.getSale().getDebtDeductionAmount(); final BigDecimal debtDeductionAmount = saleQueryDTO.getSale().getDebtDeductionAmount() == null ? BigDecimal.ZERO : saleQueryDTO.getSale().getDebtDeductionAmount();
// 余额抵扣,需要从欠款中减掉 // 余额抵扣,需要从欠款中减掉
final BigDecimal balanceDeductionAmount = saleQueryDTO.getSale().getBalanceDeductionAmount() == null ? BigDecimal.valueOf(0) : saleQueryDTO.getSale().getBalanceDeductionAmount(); final BigDecimal balanceDeductionAmount = saleQueryDTO.getSale().getBalanceDeductionAmount() == null ? BigDecimal.ZERO : saleQueryDTO.getSale().getBalanceDeductionAmount();
if (oldDebt == null) { if (oldDebt == null) {
// 新增 // 新增
debtMapper.insert(debt); debtMapper.insert(debt);
newDebtAmount = debt.getAmountOwed(); newDebtAmount = debt.getAmountOwed();
} else { } else {
lastDebtAmount = oldDebt.getAmountOwed(); lastDebtAmount = oldDebt.getAmountOwed() == null ? BigDecimal.ZERO : oldDebt.getAmountOwed();
// 计算欠款 // 计算欠款
newDebtAmount = oldDebt.getAmountOwed().add(debt.getAmountOwed()).subtract(debtDeductionAmount).add(balanceDeductionAmount); newDebtAmount = oldDebt.getAmountOwed().add(debt.getAmountOwed()).subtract(debtDeductionAmount).add(balanceDeductionAmount);
oldDebt.setAmountOwed(newDebtAmount); oldDebt.setAmountOwed(newDebtAmount);
@ -202,17 +202,17 @@ public class DebtServiceImpl extends ServiceImpl<DebtMapper, Debt> implements De
dealingsRecord.setDealingsWay("开单"); dealingsRecord.setDealingsWay("开单");
dealingsRecord.setShopId(shopId); dealingsRecord.setShopId(shopId);
// 销售金额 // 销售金额
if(!saleQueryDTO.getSaleDetailList().isEmpty()){ if (!saleQueryDTO.getSaleDetailList().isEmpty()) {
dealingsRecord.setSaleAmount(saleQueryDTO.getSale().getTotalAmount()); dealingsRecord.setSaleAmount(saleQueryDTO.getSale().getTotalAmount());
}else{ } else {
dealingsRecord.setSaleAmount(BigDecimal.valueOf(0)); dealingsRecord.setSaleAmount(BigDecimal.ZERO);
} }
// 退货金额 // 退货金额
if(saleQueryDTO.getSaleReturnDTO() != null){ if (saleQueryDTO.getSaleReturnDTO() != null) {
dealingsRecord.setReturnAmount(saleQueryDTO.getSaleReturnDTO().getReturnSale().getTotalAmount()); dealingsRecord.setReturnAmount(saleQueryDTO.getSaleReturnDTO().getReturnSale().getTotalAmount());
}else{ } else {
dealingsRecord.setReturnAmount(BigDecimal.valueOf(0)); dealingsRecord.setReturnAmount(BigDecimal.ZERO);
} }
// 上次欠款 // 上次欠款
dealingsRecord.setLastDebtAmount(lastDebtAmount); dealingsRecord.setLastDebtAmount(lastDebtAmount);
@ -227,7 +227,58 @@ public class DebtServiceImpl extends ServiceImpl<DebtMapper, Debt> implements De
public List<Debt> getDebtByUserIds(List<String> userIds) { public List<Debt> getDebtByUserIds(List<String> userIds) {
return debtMapper.getDebtByUserIds(userIds); return debtMapper.getDebtByUserIds(userIds);
} }
public Debt selectByUserId(String userId){
return debtMapper.selectByUserId(securityUtil.getShopId(),userId); public Debt selectByUserId(String userId) {
return debtMapper.selectByUserId(securityUtil.getShopId(), userId);
}
@Override
public Debt recharge(Debt debt) {
final String shopId = securityUtil.getShopId();
debt.setShopId(shopId);
final String userId = debt.getUserId();
final User user = securityUtil.getCurrUser();
Integer dealingsType = DealingsRecordConstant.DEALINGS_TYPE[4];
String dealingsWay = "";
if (debt.getAmountOwed().compareTo(BigDecimal.ZERO) > 0) {
dealingsWay = "充值";
dealingsType = DealingsRecordConstant.DEALINGS_TYPE[4];
} else {
dealingsWay = "追加欠款";
dealingsType = DealingsRecordConstant.DEALINGS_TYPE[5];
}
final Debt oldDebt = debtMapper.selectByUserId(shopId, userId);
BigDecimal lastDebtAmount = BigDecimal.ZERO;
BigDecimal newDebtAmount = BigDecimal.ZERO;
lastDebtAmount = oldDebt.getAmountOwed() == null ? BigDecimal.ZERO : oldDebt.getAmountOwed();
// 计算欠款
newDebtAmount = oldDebt.getAmountOwed().subtract(debt.getAmountOwed());
oldDebt.setAmountOwed(newDebtAmount);
debtMapper.updateById(oldDebt);
// 2. 新增欠款记录
// 创建人
final DealingsRecord dealingsRecord = new DealingsRecord();
dealingsRecord.setCreateBy(user.getId());
dealingsRecord.setCreateByName(user.getNickname());
dealingsRecord.setCreateTime(new Date());
dealingsRecord.setDealingsUserId(oldDebt.getUserId());
dealingsRecord.setDealingsUserName(oldDebt.getUserName());
dealingsRecord.setDealingsWay(dealingsWay);
dealingsRecord.setShopId(shopId);
// 上次欠款
dealingsRecord.setLastDebtAmount(lastDebtAmount);
// 最新欠款
dealingsRecord.setBalanceDue(newDebtAmount);
// 金额
dealingsRecord.setAmount(debt.getAmountOwed());
// 充值
dealingsRecord.setDealingsType(dealingsType);
dealingsRecord.setUserType(DealingsRecordConstant.TYPE[1]);
dealingsRecordService.save(dealingsRecord);
return debt;
} }
} }

38
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/deductlog/service/impl/DeductLogServiceImpl.java

@ -111,26 +111,26 @@ public class DeductLogServiceImpl extends ServiceImpl<DeductLogMapper, DeductLog
public void updateRebateAmount(String workId, String transCompanyId, String shopId, String saleId,String transportType) { public void updateRebateAmount(String workId, String transCompanyId, String shopId, String saleId,String transportType) {
// 如果只选物流,就不需要拉包工返佣 // 如果只选物流,就不需要拉包工返佣
BigDecimal workerRebateAmount = BigDecimal.valueOf(0); BigDecimal workerRebateAmount = BigDecimal.ZERO;
BigDecimal workerFixedAmount = BigDecimal.valueOf(0); BigDecimal workerFixedAmount = BigDecimal.ZERO;
BigDecimal workerBefDepoBal = BigDecimal.valueOf(0); BigDecimal workerBefDepoBal = BigDecimal.ZERO;
BigDecimal workerAfterDepoBal = BigDecimal.valueOf(0); BigDecimal workerAfterDepoBal = BigDecimal.ZERO;
Worker worker = null; Worker worker = null;
// 20240427 拼包transport_type=3,不用更新拉包工余额 // 20240427 拼包transport_type=3,不用更新拉包工余额
if (StringUtils.isNotEmpty(workId) && !SaleConstant.TRANSPORT_TYPE[3].equals(transportType)) { if (StringUtils.isNotEmpty(workId) && !SaleConstant.TRANSPORT_TYPE[3].equals(transportType)) {
// 获取拉包工信息 // 获取拉包工信息
worker = workerService.findById(workId); worker = workerService.findById(workId);
// 配送人员扣减固定金额 // 配送人员扣减固定金额
workerFixedAmount = worker.getFixedAmount() == null ? BigDecimal.valueOf(0) : worker.getFixedAmount(); workerFixedAmount = worker.getFixedAmount() == null ? BigDecimal.ZERO : worker.getFixedAmount();
// 配送人员押金余额(拉包工扣减前押金余额) // 配送人员押金余额(拉包工扣减前押金余额)
workerBefDepoBal = worker.getDepoBal() == null ? BigDecimal.valueOf(0) : worker.getDepoBal(); workerBefDepoBal = worker.getDepoBal() == null ? BigDecimal.ZERO : worker.getDepoBal();
// 配送人员返佣金额 // 配送人员返佣金额
workerRebateAmount = worker.getRebateAmount() == null ? BigDecimal.valueOf(0) : worker.getRebateAmount(); workerRebateAmount = worker.getRebateAmount() == null ? BigDecimal.ZERO : worker.getRebateAmount();
// 拉包工扣减后押金余额 // 拉包工扣减后押金余额
workerAfterDepoBal = workerBefDepoBal.subtract(workerFixedAmount); workerAfterDepoBal = workerBefDepoBal.subtract(workerFixedAmount);
worker.setDepoBal(workerAfterDepoBal); worker.setDepoBal(workerAfterDepoBal);
// 更新拉包工押金余额 // 更新拉包工押金余额
if(workerFixedAmount.compareTo(BigDecimal.valueOf(0))>0){ if(workerFixedAmount.compareTo(BigDecimal.ZERO)>0){
// 固定扣减金额大于0,才去更新,否则,没变化不用更新 // 固定扣减金额大于0,才去更新,否则,没变化不用更新
workerService.update(worker); workerService.update(worker);
} }
@ -138,10 +138,10 @@ public class DeductLogServiceImpl extends ServiceImpl<DeductLogMapper, DeductLog
} }
// 获取物流公司信息 // 获取物流公司信息
BigDecimal companyRebateAmount = BigDecimal.valueOf(0); BigDecimal companyRebateAmount = BigDecimal.ZERO;
BigDecimal companyFixedAmount = BigDecimal.valueOf(0); BigDecimal companyFixedAmount = BigDecimal.ZERO;
BigDecimal companyDepoBal = BigDecimal.valueOf(0); BigDecimal companyDepoBal = BigDecimal.ZERO;
BigDecimal companyAfterDepoBal = BigDecimal.valueOf(0); BigDecimal companyAfterDepoBal = BigDecimal.ZERO;
String companyName = ""; String companyName = "";
LogiticsCompany logiticsCompany = null; LogiticsCompany logiticsCompany = null;
// 拼单不会有物流公司信息, // 拼单不会有物流公司信息,
@ -149,26 +149,26 @@ public class DeductLogServiceImpl extends ServiceImpl<DeductLogMapper, DeductLog
logiticsCompany = companyService.findById(transCompanyId); logiticsCompany = companyService.findById(transCompanyId);
if (logiticsCompany != null) { if (logiticsCompany != null) {
companyName = logiticsCompany.getCompanyName(); companyName = logiticsCompany.getCompanyName();
companyRebateAmount = logiticsCompany.getRebateAmount() == null ? BigDecimal.valueOf(0) : logiticsCompany.getRebateAmount(); companyRebateAmount = logiticsCompany.getRebateAmount() == null ? BigDecimal.ZERO : logiticsCompany.getRebateAmount();
companyFixedAmount = logiticsCompany.getFixedAmount() == null ? BigDecimal.valueOf(0) : logiticsCompany.getFixedAmount(); companyFixedAmount = logiticsCompany.getFixedAmount() == null ? BigDecimal.ZERO : logiticsCompany.getFixedAmount();
companyDepoBal = logiticsCompany.getDepoBal() == null ? BigDecimal.valueOf(0) : logiticsCompany.getDepoBal(); companyDepoBal = logiticsCompany.getDepoBal() == null ? BigDecimal.ZERO : logiticsCompany.getDepoBal();
// 物流公司扣减后押金余额 // 物流公司扣减后押金余额
companyAfterDepoBal = companyDepoBal.subtract(companyFixedAmount); companyAfterDepoBal = companyDepoBal.subtract(companyFixedAmount);
logiticsCompany.setDepoBal(companyAfterDepoBal); logiticsCompany.setDepoBal(companyAfterDepoBal);
// 更新物流公司押金余额 // 更新物流公司押金余额
if(companyFixedAmount.compareTo(BigDecimal.valueOf(0))>0){ if(companyFixedAmount.compareTo(BigDecimal.ZERO)>0){
companyService.update(logiticsCompany); companyService.update(logiticsCompany);
} }
} }
} }
// 如果拉包工的返佣金额或者物流公司的返佣金额任意之一大于0,才去更新,店铺返佣金额,及更新记录 // 如果拉包工的返佣金额或者物流公司的返佣金额任意之一大于0,才去更新,店铺返佣金额,及更新记录
if(companyRebateAmount.compareTo(BigDecimal.valueOf(0))>0 ||workerRebateAmount.compareTo(BigDecimal.valueOf(0))>0){ if(companyRebateAmount.compareTo(BigDecimal.ZERO)>0 ||workerRebateAmount.compareTo(BigDecimal.ZERO)>0){
// 获取店铺信息 // 获取店铺信息
final Shop shop = shopService.findById(shopId); final Shop shop = shopService.findById(shopId);
final String shopName = shop.getShopName(); final String shopName = shop.getShopName();
// 返佣金额 // 返佣金额
final BigDecimal shopBefRebateAmount = shop.getRebateAmount() == null ? BigDecimal.valueOf(0) : shop.getRebateAmount(); final BigDecimal shopBefRebateAmount = shop.getRebateAmount() == null ? BigDecimal.ZERO : shop.getRebateAmount();
// 本次返佣金额 // 本次返佣金额
final BigDecimal shopRebateAmount = companyRebateAmount.add(workerRebateAmount); final BigDecimal shopRebateAmount = companyRebateAmount.add(workerRebateAmount);
// 返佣后金额 // 返佣后金额
@ -204,7 +204,7 @@ public class DeductLogServiceImpl extends ServiceImpl<DeductLogMapper, DeductLog
deductLog.setShopBefRebateAmount(shopBefRebateAmount); deductLog.setShopBefRebateAmount(shopBefRebateAmount);
deductLog.setShopAfterRebateAmount(shopAfterRebateAmount); deductLog.setShopAfterRebateAmount(shopAfterRebateAmount);
deductLog.setShopRebateAmount(shopRebateAmount); deductLog.setShopRebateAmount(shopRebateAmount);
if (shopBefRebateAmount.compareTo(BigDecimal.valueOf(0)) > 0) { if (shopBefRebateAmount.compareTo(BigDecimal.ZERO) > 0) {
// 返佣金额大于0的时候再保存返佣记录 // 返佣金额大于0的时候再保存返佣记录
saveDeductLog(deductLog); saveDeductLog(deductLog);
} }

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

@ -17,6 +17,8 @@ public class ReturnDetail implements Serializable {
private String createBy; private String createBy;
private String createByName;
private Date createTime; private Date createTime;
private Integer delFlag; private Integer delFlag;

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

@ -11,6 +11,8 @@ import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient;
import java.math.BigDecimal;
@Data @Data
@Entity @Entity
@ -43,8 +45,14 @@ public class Supplier extends HiverBaseEntity {
@ApiModelProperty(value = "供应商联系方式") @ApiModelProperty(value = "供应商联系方式")
private String consigneeMobile; private String consigneeMobile;
@Transient
@TableField(exist = false) @TableField(exist = false)
@ApiModelProperty(value = "欠款") @ApiModelProperty(value = "欠款")
private String noEarn; private BigDecimal noEarn;
@Transient
@TableField(exist = false)
@ApiModelProperty(value = "搜索关键字")
private String searchStr;
} }

6
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/invitelog/service/impl/InviteLogServiceImpl.java

@ -50,8 +50,8 @@ public class InviteLogServiceImpl extends ServiceImpl<InviteLogMapper, InviteLog
final String inviteShopId = inviteLog.getInviteShopId(); final String inviteShopId = inviteLog.getInviteShopId();
final Shop shop = shopService.findById(inviteShopId); final Shop shop = shopService.findById(inviteShopId);
inviteLog.setInviteShopName(shop.getShopName()); inviteLog.setInviteShopName(shop.getShopName());
inviteLog.setShopBefRebateAmount(BigDecimal.valueOf(0)); inviteLog.setShopBefRebateAmount(BigDecimal.ZERO);
inviteLog.setShopAfterRebateAmount(BigDecimal.valueOf(0)); inviteLog.setShopAfterRebateAmount(BigDecimal.ZERO);
inviteLog.setIsOpen(InviteLogConstant.IS_OPEN[0]); inviteLog.setIsOpen(InviteLogConstant.IS_OPEN[0]);
inviteLogMapper.insert(inviteLog); inviteLogMapper.insert(inviteLog);
} else { } else {
@ -71,7 +71,7 @@ public class InviteLogServiceImpl extends ServiceImpl<InviteLogMapper, InviteLog
// 获取店铺信息 // 获取店铺信息
final Shop shop = shopService.findById(inviteLog.getInviteShopId()); final Shop shop = shopService.findById(inviteLog.getInviteShopId());
// 返佣金额 // 返佣金额
final BigDecimal shopBefRebateAmount = shop.getRebateAmount() == null ? BigDecimal.valueOf(0) : shop.getRebateAmount(); final BigDecimal shopBefRebateAmount = shop.getRebateAmount() == null ? BigDecimal.ZERO : shop.getRebateAmount();
// 返佣后金额(目前写死的50) // 返佣后金额(目前写死的50)
final BigDecimal shopAfterRebateAmount = shopBefRebateAmount.add(BigDecimal.valueOf(50)); final BigDecimal shopAfterRebateAmount = shopBefRebateAmount.add(BigDecimal.valueOf(50));
// 更新返佣金额 // 更新返佣金额

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/PurchasePageQuery.java

@ -39,6 +39,8 @@ public class PurchasePageQuery extends HiverBasePageQuery {
private String createBy; private String createBy;
private String createByName;
private Date createTime; private Date createTime;
private Integer delFlag; private Integer delFlag;

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

@ -30,6 +30,21 @@ import lombok.Data;
@Data @Data
public class ReturnSalePageQuery extends HiverBasePageQuery { public class ReturnSalePageQuery extends HiverBasePageQuery {
@ApiModelProperty("店铺id")
private String shopId;
@ApiModelProperty("操作人")
private String createBy;
@ApiModelProperty("操作人名称")
private String createByName;
@ApiModelProperty("客户id")
private String userId;
@ApiModelProperty("客户名称")
private String userName;
@ApiModelProperty("商品ID") @ApiModelProperty("商品ID")
private String productId; private String productId;

12
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/SalePageQuery.java

@ -30,12 +30,24 @@ import lombok.Data;
@Data @Data
public class SalePageQuery extends HiverBasePageQuery { public class SalePageQuery extends HiverBasePageQuery {
@ApiModelProperty("店铺id")
private String shopId;
@ApiModelProperty("商品ID") @ApiModelProperty("商品ID")
private String productId; private String productId;
@ApiModelProperty("操作人id")
private String createBy;
@ApiModelProperty("操作人姓名")
private String createByName;
@ApiModelProperty("客户id") @ApiModelProperty("客户id")
private String userId; private String userId;
@ApiModelProperty("客户id")
private String userName;
@ApiModelProperty("供应商id") @ApiModelProperty("供应商id")
private String supplierId; private String supplierId;

5
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/SupplierQueryCriteria.java

@ -1,21 +1,16 @@
package cc.hiver.mall.pojo.query; package cc.hiver.mall.pojo.query;
import cc.hiver.core.common.annotation.Query;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
public class SupplierQueryCriteria implements Serializable { public class SupplierQueryCriteria implements Serializable {
@Query
private String id; private String id;
@Query
private String shopId; private String shopId;
@Query
private int delFlag; private int delFlag;
@Query(blurry = "consigneeName,consigneeMobile")
private String searchStr; private String searchStr;
} }

28
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/CustomerSaleDetailVo.java

@ -0,0 +1,28 @@
package cc.hiver.mall.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class CustomerSaleDetailVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = " 客户id")
private String userId;
@ApiModelProperty(value = " 客户名称")
private String userName;
@ApiModelProperty(value = " 拿货数量")
private String productCount;
@ApiModelProperty(value = " 拿货总金额")
private String realAmount;
@ApiModelProperty(value = " 成本")
private String totalCost;
@ApiModelProperty(value = " 利润")
private String profit;
}

41
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/PurchasingCostDetailVo.java

@ -0,0 +1,41 @@
package cc.hiver.mall.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class PurchasingCostDetailVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = " 操作人")
private String createBy;
@ApiModelProperty(value = " 操作人")
private String createByName;
@ApiModelProperty(value = " 入库单id")
private String purchaseId;
@ApiModelProperty(value = " 供应商id")
private String supplierId;
@ApiModelProperty(value = " 供应商名称")
private String supplierName;
@ApiModelProperty(value = " 入库日期")
private String purchaseDate;
@ApiModelProperty(value = "总成本")
private BigDecimal totalCost;
@ApiModelProperty(value = "商品款数")
private BigDecimal productNum;
@ApiModelProperty(value = "商品数量")
private BigDecimal productCount;
}

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

@ -1,6 +1,7 @@
package cc.hiver.mall.pojo.vo; package cc.hiver.mall.pojo.vo;
import cc.hiver.core.base.HiverBasePageQuery; import cc.hiver.core.base.HiverBasePageQuery;
import cc.hiver.mall.pojo.dto.ReturnSaleDetailDTO;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -9,6 +10,7 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List;
@Data @Data
@ApiModel(value = "退货单主表") @ApiModel(value = "退货单主表")
@ -107,5 +109,8 @@ public class ReturnSaleVo extends HiverBasePageQuery implements Serializable {
@ApiModelProperty(value = "累计欠款") @ApiModelProperty(value = "累计欠款")
private String balanceDue; private String balanceDue;
@ApiModelProperty(value = "退款订单明细")
private List<ReturnSaleDetailDTO> returnSaleDetailList;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

39
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ReturnTotalAmountDetailVo.java

@ -0,0 +1,39 @@
package cc.hiver.mall.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class ReturnTotalAmountDetailVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = " 操作人")
private String createBy;
@ApiModelProperty(value = " 操作人")
private String createByName;
@ApiModelProperty(value = " 退货单id")
private String returnSaleId;
@ApiModelProperty(value = " 客户id")
private String userId;
@ApiModelProperty(value = " 客户名称")
private String userName;
@ApiModelProperty(value = " 退货单日期")
private String returnSaleDate;
@ApiModelProperty(value = " 退货单金额")
private BigDecimal totalAmount;
@ApiModelProperty(value = "数量")
private Integer productCount;
@ApiModelProperty(value = "总成本")
private BigDecimal totalCost;
}

42
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/TotalAlreadyEarnDetailDayVo.java

@ -0,0 +1,42 @@
package cc.hiver.mall.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 请详细描述方法
* @author 王富康
* @date 2024/6/29
*/
@Data
public class TotalAlreadyEarnDetailDayVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = " 日期")
private String paymentDay;
@ApiModelProperty(value = " 现金支付金额")
private String xianjin;
@ApiModelProperty(value = " 微信支付金额")
private String weixin;
@ApiModelProperty(value = " 支付宝支付金额")
private String zhifubao;
@ApiModelProperty(value = " 银行转账支付金额")
private String yihangzhuanzhang;
@ApiModelProperty(value = " 收款码支付金额")
private String shouhuanma;
@ApiModelProperty(value = " 预留支付方式1")
private String yuliuOne;
@ApiModelProperty(value = " 预留支付方式2")
private String yuliuTwo;
@ApiModelProperty(value = " 预留支付方式3")
private String yuliuThree;
}

39
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/TotalAmountDetailVo.java

@ -0,0 +1,39 @@
package cc.hiver.mall.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class TotalAmountDetailVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = " 操作人")
private String createBy;
@ApiModelProperty(value = " 操作人")
private String createByName;
@ApiModelProperty(value = " 销售单id")
private String saleId;
@ApiModelProperty(value = " 客户id")
private String userId;
@ApiModelProperty(value = " 客户名称")
private String userName;
@ApiModelProperty(value = " 销售单日期")
private String saleDate;
@ApiModelProperty(value = " 销售单金额")
private BigDecimal totalAmount;
@ApiModelProperty(value = "利润")
private BigDecimal profit;
@ApiModelProperty(value = "总成本")
private BigDecimal totalCost;
}

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

@ -220,7 +220,7 @@ public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService
productSn = CommonUtil.getProductSn(productSn); productSn = CommonUtil.getProductSn(productSn);
final String productName = object.getString("productName"); final String productName = object.getString("productName");
final String priceStr = object.getString("price"); final String priceStr = object.getString("price");
BigDecimal price = BigDecimal.valueOf(0); BigDecimal price = BigDecimal.ZERO;
// 使用正则表达式提取数字部分 // 使用正则表达式提取数字部分
final Pattern pattern = Pattern.compile("-?\\d+(\\.\\d+)?"); final Pattern pattern = Pattern.compile("-?\\d+(\\.\\d+)?");
final Matcher matcher = pattern.matcher(priceStr); final Matcher matcher = pattern.matcher(priceStr);

3
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/SupplierService.java

@ -2,14 +2,13 @@ package cc.hiver.mall.service;
import cc.hiver.core.base.HiverBaseService; import cc.hiver.core.base.HiverBaseService;
import cc.hiver.mall.entity.Supplier; import cc.hiver.mall.entity.Supplier;
import cc.hiver.mall.pojo.query.SupplierQueryCriteria;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.util.List; import java.util.List;
public interface SupplierService extends HiverBaseService<Supplier, String> { public interface SupplierService extends HiverBaseService<Supplier, String> {
Page<Supplier> queryAll(SupplierQueryCriteria criteria, Pageable pageable); Page<Supplier> queryAll(Supplier supplierOfquery, Pageable pageable);
List<Supplier> getbyShopId(String shopId,String searchStr); List<Supplier> getbyShopId(String shopId,String searchStr);

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

@ -4,6 +4,7 @@ import cc.hiver.mall.entity.Purchase;
import cc.hiver.mall.pojo.dto.DebtSupplier; import cc.hiver.mall.pojo.dto.DebtSupplier;
import cc.hiver.mall.pojo.query.PurchasePageQuery; import cc.hiver.mall.pojo.query.PurchasePageQuery;
import cc.hiver.mall.pojo.vo.PurchaseVo; import cc.hiver.mall.pojo.vo.PurchaseVo;
import cc.hiver.mall.pojo.vo.PurchasingCostDetailVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
@ -43,4 +44,13 @@ public interface PurchaseService extends IService<Purchase> {
void updateInStorageStatus(String id,int inStorageStatus); void updateInStorageStatus(String id,int inStorageStatus);
void deleteById(String id); void deleteById(String id);
/**
* 进货金额可查明细
* @author 王富康
* @date 2024/6/29
* @param purchasePageQuery
* @return List<PurchasingCostDetailVo>
*/
Page<PurchasingCostDetailVo> purchasingCostDetail(PurchasePageQuery purchasePageQuery);
} }

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

@ -1,6 +1,7 @@
package cc.hiver.mall.service.mybatis; package cc.hiver.mall.service.mybatis;
import cc.hiver.mall.entity.ReturnDetail; import cc.hiver.mall.entity.ReturnDetail;
import cc.hiver.mall.pojo.query.ReturnSalePageQuery;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
@ -12,5 +13,16 @@ public interface ReturnDetailService extends IService<ReturnDetail> {
public List<String> selectByCondition1(QueryWrapper queryWrapper); public List<String> selectByCondition1(QueryWrapper queryWrapper);
List<ReturnDetail> getReturnDetails(List<String> saleIdList); List<ReturnDetail> getReturnDetails(List<String> saleIdList);
List<ReturnDetail> getReturnDetailsByReturnId(List<String> returnSaleIdList);
/**
* 根据商品id分页获取退货历史
*
* @param returnSalePageQuery
* @return List<ReturnDetail>
* @author 王富康
* @date 2024/6/29
*/
List<ReturnDetail> getReturnDetailsByProductId(ReturnSalePageQuery returnSalePageQuery);
} }

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

@ -3,9 +3,9 @@ package cc.hiver.mall.service.mybatis;
import cc.hiver.mall.bill.vo.ArrearsVo; import cc.hiver.mall.bill.vo.ArrearsVo;
import cc.hiver.mall.bill.vo.CustomerBillQueryVo; import cc.hiver.mall.bill.vo.CustomerBillQueryVo;
import cc.hiver.mall.entity.ReturnSale; import cc.hiver.mall.entity.ReturnSale;
import cc.hiver.mall.pojo.dto.SaleReturnDTO;
import cc.hiver.mall.pojo.query.ReturnSalePageQuery; import cc.hiver.mall.pojo.query.ReturnSalePageQuery;
import cc.hiver.mall.pojo.vo.ReturnSaleVo; import cc.hiver.mall.pojo.vo.ReturnSaleVo;
import cc.hiver.mall.pojo.vo.ReturnTotalAmountDetailVo;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
@ -19,5 +19,33 @@ public interface ReturnSaleService extends IService<ReturnSale> {
ArrearsVo getTotalReturn(CustomerBillQueryVo customerBillQueryVo); ArrearsVo getTotalReturn(CustomerBillQueryVo customerBillQueryVo);
Page<SaleReturnDTO> getReturnSaleListByProductId(ReturnSalePageQuery returnSalePageQuery); /**
* 根据商品id分页获取退货历史
*
* @param returnSalePageQuery
* @return Page<ReturnSaleVo>
* @author 王富康
* @date 2024/6/29
*/
Page<ReturnSaleVo> getReturnSaleListByProductId(ReturnSalePageQuery returnSalePageQuery);
/**
* 退货金额明细
*
* @param returnSalePageQuery
* @return Page<returnTotalAmountDetailVo>
* @author 王富康
* @date 2024/6/29
*/
Page<ReturnTotalAmountDetailVo> returnTotalAmountDetail(ReturnSalePageQuery returnSalePageQuery);
/**
* 根据客户id分页获取退货历史
*
* @param returnSalePageQuery
* @return Page<ReturnSaleVo>
* @author 王富康
* @date 2024/6/30
*/
Page<ReturnSaleVo> getReturnSaleListByUserId(ReturnSalePageQuery returnSalePageQuery);
} }

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

@ -88,4 +88,32 @@ public interface SaleService extends IService<Sale> {
Page<CustomerBillSaleVo> getCustomerBill(CustomerBillQueryVo customerBillQueryVo); Page<CustomerBillSaleVo> getCustomerBill(CustomerBillQueryVo customerBillQueryVo);
ArrearsVo getArrearsAndTotalSale(CustomerBillQueryVo customerBillQueryVo); ArrearsVo getArrearsAndTotalSale(CustomerBillQueryVo customerBillQueryVo);
/**
* 点击销售金额查询销售明细
*
* @param salePageQuery
* @return List<TotalAmountDetailVo>
* @author 王富康
* @date 2024/6/29
*/
Page<TotalAmountDetailVo> totalAmountDetail(SalePageQuery salePageQuery);
/**
* 实收金额明细
* @author 王富康
* @date 2024/6/29
* @param salePageQuery
* @return List<TotalAlreadyEarnDetailDayVo>
*/
Page<TotalAlreadyEarnDetailDayVo> totalAlreadyEarnDetail(SalePageQuery salePageQuery);
/**
* 客户拿货统计
* @author 王富康
* @date 2024/6/29
* @param salePageQuery
* @return Page<CustomerSaleDetailVo>
*/
Page<CustomerSaleDetailVo> customerSaleDetail(SalePageQuery salePageQuery);
} }

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

@ -389,6 +389,8 @@ public class SalesAndDetailsServiceImpl implements SalesAndDetailsService {
BeanUtils.copyBeanProp(returnDetail,returnSaleDetailDTO); BeanUtils.copyBeanProp(returnDetail,returnSaleDetailDTO);
returnDetail.setCreateTime(returnSale.getCreateTime()); returnDetail.setCreateTime(returnSale.getCreateTime());
returnDetail.setCreateBy(returnSale.getCreateBy()); returnDetail.setCreateBy(returnSale.getCreateBy());
returnDetail.setDelFlag(CommonConstant.DEL_FLAG_FALSE);
returnDetail.setCreateByName(user.getNickname());
saleDetailList2.add(returnDetail); saleDetailList2.add(returnDetail);
} }
} }

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

@ -136,7 +136,7 @@ public class SalesCalculateServiceImpl implements SalesCalculateService {
BigDecimal totalPurchasePrice = new BigDecimal("0.0"); BigDecimal totalPurchasePrice = new BigDecimal("0.0");
final List<SaleDetail> list = saleDetailService.listOfShopAll(shopId,startTime,endTime); final List<SaleDetail> list = saleDetailService.listOfShopAll(shopId,startTime,endTime);
for (SaleDetail saleDetail : list) { for (SaleDetail saleDetail : list) {
final BigDecimal purchasePrice = saleDetail.getPurchasePrice() == null ? BigDecimal.valueOf(0) :saleDetail.getPurchasePrice(); final BigDecimal purchasePrice = saleDetail.getPurchasePrice() == null ? BigDecimal.ZERO :saleDetail.getPurchasePrice();
final int productCount = saleDetail.getProductCount() == null ? 0 : saleDetail.getProductCount(); final int productCount = saleDetail.getProductCount() == null ? 0 : saleDetail.getProductCount();
totalPurchasePrice = totalPurchasePrice.add(purchasePrice.multiply(new BigDecimal(productCount))); totalPurchasePrice = totalPurchasePrice.add(purchasePrice.multiply(new BigDecimal(productCount)));
} }

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

@ -2,20 +2,22 @@ package cc.hiver.mall.serviceimpl;
import cc.hiver.core.base.HiverBaseDao; import cc.hiver.core.base.HiverBaseDao;
import cc.hiver.core.common.constant.CommonConstant; import cc.hiver.core.common.constant.CommonConstant;
import cc.hiver.core.common.utils.QueryHelp;
import cc.hiver.mall.dao.SupplierDao; import cc.hiver.mall.dao.SupplierDao;
import cc.hiver.mall.debt.entity.Debt; import cc.hiver.mall.debt.entity.Debt;
import cc.hiver.mall.debt.service.DebtService; import cc.hiver.mall.debt.service.DebtService;
import cc.hiver.mall.entity.Supplier; import cc.hiver.mall.entity.Supplier;
import cc.hiver.mall.pojo.query.SupplierQueryCriteria;
import cc.hiver.mall.service.SupplierService; import cc.hiver.mall.service.SupplierService;
import cn.hutool.core.text.CharSequenceUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.persistence.criteria.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -38,10 +40,33 @@ public class SupplierServiceImpl implements SupplierService {
} }
@Override @Override
public Page<Supplier> queryAll(SupplierQueryCriteria criteria, Pageable pageable) { public Page<Supplier> queryAll(Supplier supplierOfquery, Pageable pageable) {
// 添加未删除标记 // 添加未删除标记
criteria.setDelFlag(CommonConstant.DEL_FLAG_FALSE); supplierOfquery.setDelFlag(CommonConstant.DEL_FLAG_FALSE);
final Page<Supplier> list = supplierDao.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable); final Page<Supplier> list = supplierDao.findAll(new Specification<Supplier>() {
@Nullable
@Override
public Predicate toPredicate(Root<Supplier> root, CriteriaQuery<?> cq, CriteriaBuilder cb) {
final Path<String> shopIdField = root.get("shopId");
final Path<String> delFlagField = root.get("delFlag");
final Path<String> consigneeNameField = root.get("consigneeName");
final Path<String> consigneeMobileField = root.get("consigneeMobile");
final List<Predicate> list = new ArrayList<>();
list.add(cb.equal(shopIdField, supplierOfquery.getShopId()));
list.add(cb.equal(delFlagField, supplierOfquery.getDelFlag()));
if (CharSequenceUtil.isNotBlank(supplierOfquery.getSearchStr())) {
Predicate p = cb.or(cb.like(consigneeNameField, "%" + supplierOfquery.getSearchStr() + "%"));
p = cb.or(p, cb.like(consigneeMobileField, "%" + supplierOfquery.getSearchStr() + "%"));
list.add(p);
}
final Predicate[] arr = new Predicate[list.size()];
cq.where(list.toArray(arr));
return null;
}
}, pageable);
// 添加欠款信息 // 添加欠款信息
// 获取供应商的id // 获取供应商的id
final List<String> idList = new ArrayList<>(); final List<String> idList = new ArrayList<>();
@ -51,17 +76,20 @@ public class SupplierServiceImpl implements SupplierService {
// 添加到id列表中 // 添加到id列表中
idList.add(id); idList.add(id);
}); });
// 获取供应商的欠款信息 if(!idList.isEmpty()){
final List<Debt> debtByUserIds = debtService.getDebtByUserIds(idList); // 获取供应商的欠款信息
// 变为map,key为userid, final List<Debt> debtByUserIds = debtService.getDebtByUserIds(idList);
final Map<String, Debt> debtMap = debtByUserIds.stream().collect(Collectors.toMap(Debt::getUserId, Function.identity())); // 变为map,key为userid,
list.forEach(supplier -> { final Map<String, Debt> debtMap = debtByUserIds.stream().collect(Collectors.toMap(Debt::getUserId, Function.identity()));
final String id = supplier.getId(); list.forEach(supplier -> {
final Debt debt = debtMap.get(id); final String id = supplier.getId();
if (debt != null) { final Debt debt = debtMap.get(id);
supplier.setNoEarn(debt.getAmountOwed().toString()); if (debt != null) {
} supplier.setNoEarn(debt.getAmountOwed());
}); }
});
}
return list; return list;
} }

61
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java

@ -1,6 +1,7 @@
package cc.hiver.mall.serviceimpl.mybatis; package cc.hiver.mall.serviceimpl.mybatis;
import cc.hiver.core.common.constant.CommonConstant; import cc.hiver.core.common.constant.CommonConstant;
import cc.hiver.core.common.constant.DealingsRecordConstant;
import cc.hiver.core.common.constant.UserConstant; import cc.hiver.core.common.constant.UserConstant;
import cc.hiver.core.common.utils.PageUtil; import cc.hiver.core.common.utils.PageUtil;
import cc.hiver.core.common.utils.SecurityUtil; import cc.hiver.core.common.utils.SecurityUtil;
@ -17,9 +18,11 @@ import cc.hiver.mall.debt.constant.DebtConstant;
import cc.hiver.mall.debt.entity.Debt; import cc.hiver.mall.debt.entity.Debt;
import cc.hiver.mall.debt.service.DebtService; import cc.hiver.mall.debt.service.DebtService;
import cc.hiver.mall.entity.Customer; import cc.hiver.mall.entity.Customer;
import cc.hiver.mall.entity.DealingsRecord;
import cc.hiver.mall.pojo.dto.DebtCustomer; import cc.hiver.mall.pojo.dto.DebtCustomer;
import cc.hiver.mall.pojo.query.CustomerPageQuery; import cc.hiver.mall.pojo.query.CustomerPageQuery;
import cc.hiver.mall.service.mybatis.CustomerService; import cc.hiver.mall.service.mybatis.CustomerService;
import cc.hiver.mall.service.mybatis.DealingsRecordService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -28,6 +31,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
@Service @Service
@ -51,6 +55,9 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
@Autowired @Autowired
private DebtService debtService; private DebtService debtService;
@Autowired
private DealingsRecordService dealingsRecordService;
@Override @Override
public Page<DebtCustomer> debt(CustomerPageQuery customerPageQuery) { public Page<DebtCustomer> debt(CustomerPageQuery customerPageQuery) {
final Page<DebtCustomer> page = new Page<>(customerPageQuery.getPageNum(), customerPageQuery.getPageSize()); final Page<DebtCustomer> page = new Page<>(customerPageQuery.getPageNum(), customerPageQuery.getPageSize());
@ -120,27 +127,51 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
userRole.setUserId(saveUser.getId()); userRole.setUserId(saveUser.getId());
userRoleService.save(userRole); userRoleService.save(userRole);
} }
// shopId从缓存中设置
final String shopId = securityUtil.getShopId();
// 这里是后台管理系统启用时增加散客增加的这个操作 // 这里是后台管理系统启用时增加散客增加的这个操作
if(StringUtils.isEmpty(customer.getShopId())){ if (StringUtils.isEmpty(customer.getShopId())) {
// 如果没有传shopId,那么就去缓存中拿 // 如果没有传shopId,那么就去缓存中拿
// shopId从缓存中设置
final String shopId = securityUtil.getShopId();
customer.setShopId(shopId); customer.setShopId(shopId);
} }
customer.setDelFlag(CommonConstant.DEL_FLAG_FALSE); customer.setDelFlag(CommonConstant.DEL_FLAG_FALSE);
final int insert = customerMapper.insert(customer); final int insert = customerMapper.insert(customer);
BigDecimal amountOwed = customer.getAmountOwed();
if(amountOwed != null){
// 新增客户欠款及记录
Debt debt = new Debt();
debt.setUserId(customer.getId());
debt.setAmountOwed(amountOwed);
debt.setUserType(DebtConstant.USER_TYPE[0]);
debtService.saveOrUpdateDebt(debt);
}
if(insert>0){ // 客户欠款信息
final BigDecimal amountOwed = customer.getAmountOwed() == null ? BigDecimal.ZERO : customer.getAmountOwed();
final Debt debt = new Debt();
debt.setUserId(customer.getId());
debt.setShopId(shopId);
debt.setUserPhone(customer.getPhone());
debt.setUserAdress(customer.getAddress());
debt.setUserName(customer.getName());
debt.setAmountOwed(amountOwed);
debt.setUserType(DebtConstant.USER_TYPE[0]);
debtService.save(debt);
// 新增交易记录
// 2. 新增欠款记录
final User user = securityUtil.getCurrUser();
final DealingsRecord dealingsRecord = new DealingsRecord();
dealingsRecord.setCreateBy(user.getId());
dealingsRecord.setCreateByName(user.getNickname());
dealingsRecord.setCreateTime(new Date());
dealingsRecord.setDealingsUserId(customer.getUserId());
dealingsRecord.setDealingsUserName(customer.getUserName());
dealingsRecord.setUserType(DealingsRecordConstant.TYPE[1]);
dealingsRecord.setDealingsWay("开单");
dealingsRecord.setShopId(shopId);
// 销售金额
dealingsRecord.setSaleAmount(BigDecimal.ZERO);
// 退货金额
dealingsRecord.setReturnAmount(BigDecimal.ZERO);
// 上次欠款
dealingsRecord.setLastDebtAmount(BigDecimal.ZERO);
// 最新欠款
dealingsRecord.setBalanceDue(amountOwed);
dealingsRecord.setAmount(amountOwed);
dealingsRecord.setDealingsType(DealingsRecordConstant.DEALINGS_TYPE[3]);
dealingsRecordService.save(dealingsRecord);
if (insert > 0) {
result = true; result = true;
} }
return result; return result;
@ -154,7 +185,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
customerPageQuery.setShopId(shopId); customerPageQuery.setShopId(shopId);
customerPageQuery.setDelFlag(delFlag); customerPageQuery.setDelFlag(delFlag);
final Page<Customer> page = new Page<>(customerPageQuery.getPageNum(), customerPageQuery.getPageSize()); final Page<Customer> page = new Page<>(customerPageQuery.getPageNum(), customerPageQuery.getPageSize());
return customerMapper.getCustomerList(page,customerPageQuery); return customerMapper.getCustomerList(page, customerPageQuery);
} }
@Override @Override

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

@ -411,11 +411,24 @@ public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMappe
final String attributeName = productAttributeOfAddVo.getAttributeName(); final String attributeName = productAttributeOfAddVo.getAttributeName();
stockAttributeNameList.add(attributeName); stockAttributeNameList.add(attributeName);
} }
// 记录本次新增的规格,防止重复添加
final List<String> addAttributeNameList = new ArrayList<>();
final CopyOnWriteArrayList<ProductAttributeOfAddVo> attributeOfAddVos = newProductCategoryVo.getProductAttributeOfAddVos(); final CopyOnWriteArrayList<ProductAttributeOfAddVo> attributeOfAddVos = newProductCategoryVo.getProductAttributeOfAddVos();
for (ProductAttributeOfAddVo attributeOfAddVo : attributeOfAddVos) { for (ProductAttributeOfAddVo attributeOfAddVo : attributeOfAddVos) {
final String attributeName = attributeOfAddVo.getAttributeName(); final String attributeName = attributeOfAddVo.getAttributeName();
final CopyOnWriteArrayList<ProductAttributeValueVo> attributeValueVoList = attributeOfAddVo.getProductAttributeValueVoList(); final CopyOnWriteArrayList<ProductAttributeValueVo> attributeValueVoList = attributeOfAddVo.getProductAttributeValueVoList();
// 拿到旧的规格
ProductAttributeOfAddVo oldProductAttributeOfAddVo = new ProductAttributeOfAddVo();
for (ProductAttributeOfAddVo productAttributeOfAddVo : productAttributeOfAddVos) {
if (productAttributeOfAddVo.getAttributeName().equals(attributeName)) {
oldProductAttributeOfAddVo = productAttributeOfAddVo;
}
}
final List<ProductAttributeValueVo> productAttributeValueVoList = oldProductAttributeOfAddVo.getProductAttributeValueVoList();
final List<String> stockAttributeValueList = new ArrayList<>();
for (ProductAttributeValueVo productAttributeValueVo : productAttributeValueVoList) {
stockAttributeValueList.add(productAttributeValueVo.getValue());
}
// 首先判断是否需要新增规格 // 首先判断是否需要新增规格
if (!stockAttributeNameList.contains(attributeName)) { if (!stockAttributeNameList.contains(attributeName)) {
final ProductAttribute productAttribute = new ProductAttribute(); final ProductAttribute productAttribute = new ProductAttribute();
@ -434,27 +447,17 @@ public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMappe
} }
} else { } else {
// 包含规格,那么就只需要新增属性即可 // 包含规格,那么就只需要新增属性即可
// 拿到旧的规格
ProductAttributeOfAddVo oldProductAttributeOfAddVo = new ProductAttributeOfAddVo();
for (ProductAttributeOfAddVo productAttributeOfAddVo : productAttributeOfAddVos) {
if (productAttributeOfAddVo.getAttributeName().equals(attributeName)) {
oldProductAttributeOfAddVo = productAttributeOfAddVo;
}
}
final List<ProductAttributeValueVo> productAttributeValueVoList = oldProductAttributeOfAddVo.getProductAttributeValueVoList();
final List<String> stockAttributeValueList = new ArrayList<>();
for (ProductAttributeValueVo productAttributeValueVo : productAttributeValueVoList) {
stockAttributeValueList.add(productAttributeValueVo.getValue());
}
// 判断旧的值中是否包含新的值,如果不包含就新增 // 判断旧的值中是否包含新的值,如果不包含就新增
for (ProductAttributeValueVo productAttributeValueVo : attributeValueVoList) { for (ProductAttributeValueVo productAttributeValueVo : attributeValueVoList) {
final String value = productAttributeValueVo.getValue(); final String value = productAttributeValueVo.getValue();
if (!stockAttributeValueList.contains(value)) { if (!stockAttributeValueList.contains(value) && !addAttributeNameList.contains(value)) {
final ProductAttributeValue productAttributeValue = new ProductAttributeValue(); final ProductAttributeValue productAttributeValue = new ProductAttributeValue();
productAttributeValue.setCreateTime(new Date()); productAttributeValue.setCreateTime(new Date());
productAttributeValue.setAttributeId(oldProductAttributeOfAddVo.getAttributeId()); productAttributeValue.setAttributeId(oldProductAttributeOfAddVo.getAttributeId());
productAttributeValue.setValue(value); productAttributeValue.setValue(value);
addProductAttributeValues.add(productAttributeValue); addProductAttributeValues.add(productAttributeValue);
// 入库选两款商品同样的颜色,会重复新增,这里王判重的list中添加一下
addAttributeNameList.add(value);
} }
} }
} }

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

@ -10,6 +10,7 @@ import cc.hiver.mall.pojo.dto.DebtSupplier;
import cc.hiver.mall.pojo.query.PurchasePageQuery; import cc.hiver.mall.pojo.query.PurchasePageQuery;
import cc.hiver.mall.pojo.vo.ProductCategoryVo; import cc.hiver.mall.pojo.vo.ProductCategoryVo;
import cc.hiver.mall.pojo.vo.PurchaseVo; import cc.hiver.mall.pojo.vo.PurchaseVo;
import cc.hiver.mall.pojo.vo.PurchasingCostDetailVo;
import cc.hiver.mall.purchaseocr.entity.PurchaseOcrPicture; import cc.hiver.mall.purchaseocr.entity.PurchaseOcrPicture;
import cc.hiver.mall.purchaseocr.service.PurchaseOcrPictureService; import cc.hiver.mall.purchaseocr.service.PurchaseOcrPictureService;
import cc.hiver.mall.purchaseocr.vo.PurchaseOcrCountVo; import cc.hiver.mall.purchaseocr.vo.PurchaseOcrCountVo;
@ -475,4 +476,13 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
public void deleteById(String id) { public void deleteById(String id) {
purchaseMapper.deleteByPurchaseId(id); purchaseMapper.deleteByPurchaseId(id);
} }
@Override
public Page<PurchasingCostDetailVo> purchasingCostDetail(PurchasePageQuery purchasePageQuery) {
final Page<PurchasingCostDetailVo> page = new Page<>(purchasePageQuery.getPageNum(), purchasePageQuery.getPageSize());
// shopId从缓存中设置
final String shopId = securityUtil.getShopId();
purchasePageQuery.setShopId(shopId);
return purchaseMapper.purchasingCostDetail(page, purchasePageQuery);
}
} }

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

@ -2,6 +2,7 @@ package cc.hiver.mall.serviceimpl.mybatis;
import cc.hiver.mall.dao.mapper.ReturnDetailMapper; import cc.hiver.mall.dao.mapper.ReturnDetailMapper;
import cc.hiver.mall.entity.ReturnDetail; import cc.hiver.mall.entity.ReturnDetail;
import cc.hiver.mall.pojo.query.ReturnSalePageQuery;
import cc.hiver.mall.service.mybatis.ReturnDetailService; import cc.hiver.mall.service.mybatis.ReturnDetailService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -27,4 +28,22 @@ public class ReturnDetailServiceImpl extends ServiceImpl<ReturnDetailMapper, Ret
public List<ReturnDetail> getReturnDetails(List<String> saleIdList) { public List<ReturnDetail> getReturnDetails(List<String> saleIdList) {
return returnDetailMapper.getReturnDetails(saleIdList); return returnDetailMapper.getReturnDetails(saleIdList);
} }
@Override
public List<ReturnDetail> getReturnDetailsByReturnId(List<String> returnSaleIdList) {
return returnDetailMapper.getReturnDetailsByReturnId(returnSaleIdList);
}
/**
* 根据商品id分页获取退货历史
*
* @param returnSalePageQuery
* @return List<ReturnDetail>
* @author 王富康
* @date 2024/6/29
*/
@Override
public List<ReturnDetail> getReturnDetailsByProductId(ReturnSalePageQuery returnSalePageQuery) {
return returnDetailMapper.getReturnDetailsByProductId(returnSalePageQuery);
}
} }

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

@ -1,12 +1,17 @@
package cc.hiver.mall.serviceimpl.mybatis; package cc.hiver.mall.serviceimpl.mybatis;
import cc.hiver.core.common.utils.SecurityUtil;
import cc.hiver.mall.bill.vo.ArrearsVo; import cc.hiver.mall.bill.vo.ArrearsVo;
import cc.hiver.mall.bill.vo.CustomerBillQueryVo; import cc.hiver.mall.bill.vo.CustomerBillQueryVo;
import cc.hiver.mall.dao.mapper.ReturnSaleMapper; import cc.hiver.mall.dao.mapper.ReturnSaleMapper;
import cc.hiver.mall.entity.ReturnDetail;
import cc.hiver.mall.entity.ReturnSale; import cc.hiver.mall.entity.ReturnSale;
import cc.hiver.mall.pojo.dto.SaleReturnDTO; import cc.hiver.mall.pojo.dto.ReturnSaleDetailDTO;
import cc.hiver.mall.pojo.dto.SaleDetailQueryDTO;
import cc.hiver.mall.pojo.query.ReturnSalePageQuery; import cc.hiver.mall.pojo.query.ReturnSalePageQuery;
import cc.hiver.mall.pojo.vo.ReturnSaleVo; import cc.hiver.mall.pojo.vo.ReturnSaleVo;
import cc.hiver.mall.pojo.vo.ReturnTotalAmountDetailVo;
import cc.hiver.mall.service.mybatis.ReturnDetailService;
import cc.hiver.mall.service.mybatis.ReturnSaleService; import cc.hiver.mall.service.mybatis.ReturnSaleService;
import cc.hiver.mall.utils.DateUtil; import cc.hiver.mall.utils.DateUtil;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@ -16,7 +21,10 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
@Service @Service
public class ReturnSaleServiceImpl extends ServiceImpl<ReturnSaleMapper, ReturnSale> implements ReturnSaleService { public class ReturnSaleServiceImpl extends ServiceImpl<ReturnSaleMapper, ReturnSale> implements ReturnSaleService {
@ -24,6 +32,12 @@ public class ReturnSaleServiceImpl extends ServiceImpl<ReturnSaleMapper, ReturnS
@Autowired @Autowired
private ReturnSaleMapper returnSaleMapper; private ReturnSaleMapper returnSaleMapper;
@Autowired
private ReturnDetailService returnDetailService;
@Autowired
private SecurityUtil securityUtil;
@Override @Override
public ReturnSale getBySaleId(String id) { public ReturnSale getBySaleId(String id) {
return returnSaleMapper.getBySaleId(id); return returnSaleMapper.getBySaleId(id);
@ -32,7 +46,7 @@ public class ReturnSaleServiceImpl extends ServiceImpl<ReturnSaleMapper, ReturnS
@Override @Override
public IPage<ReturnSaleVo> getReturnSaleList(ReturnSaleVo returnSaleVo) { public IPage<ReturnSaleVo> getReturnSaleList(ReturnSaleVo returnSaleVo) {
final Page<ReturnSaleVo> page = new Page<>(returnSaleVo.getPageNum(), returnSaleVo.getPageSize()); final Page<ReturnSaleVo> page = new Page<>(returnSaleVo.getPageNum(), returnSaleVo.getPageSize());
if(StringUtils.isNotEmpty(returnSaleVo.getEndTime())){ if (StringUtils.isNotEmpty(returnSaleVo.getEndTime())) {
// 日期加一天 // 日期加一天
returnSaleVo.setEndTime(DateUtil.addDay(returnSaleVo.getEndTime(), 1)); returnSaleVo.setEndTime(DateUtil.addDay(returnSaleVo.getEndTime(), 1));
} }
@ -46,13 +60,153 @@ public class ReturnSaleServiceImpl extends ServiceImpl<ReturnSaleMapper, ReturnS
return returnSaleMapper.getTotalReturn(customerBillQueryVo); return returnSaleMapper.getTotalReturn(customerBillQueryVo);
} }
/**
* 根据商品id分页获取退货历史
*
* @param returnSalePageQuery
* @return Page<ReturnSaleVo>
* @author 王富康
* @date 2024/6/29
*/
@Override @Override
public Page<SaleReturnDTO> getReturnSaleListByProductId(ReturnSalePageQuery returnSalePageQuery) { public Page<ReturnSaleVo> getReturnSaleListByProductId(ReturnSalePageQuery returnSalePageQuery) {
if (StringUtils.isNotEmpty(returnSalePageQuery.getEndDate())) {
returnSalePageQuery.setEndDate(DateUtil.addDay(returnSalePageQuery.getEndDate(), 1));
}
final Page<ReturnSaleVo> page = new Page<>(returnSalePageQuery.getPageNum(), returnSalePageQuery.getPageSize());
final Page<ReturnSaleVo> returnSalePage = returnSaleMapper.getReturnSaleListByProductId(page, returnSalePageQuery);
final List<ReturnSaleVo> returnSaleList = returnSalePage.getRecords();
// 根据商品id获取退货详细信息
// 获取退货单明细
final List<ReturnDetail> returnDetails = returnDetailService.getReturnDetailsByProductId(returnSalePageQuery);
// 将returnDetails 放到以return_sale_id 为key ReturnDetail为value的map中去
final Map<String, List<ReturnDetail>> returnSaleMap = new HashMap<>();
for (ReturnDetail returnDetail : returnDetails) {
final String returnSaleId = returnDetail.getReturnSaleId();
if (returnSaleMap.containsKey(returnSaleId)) {
final List<ReturnDetail> returnDetailList = returnSaleMap.get(returnSaleId);
returnDetailList.add(returnDetail);
returnSaleMap.put(returnSaleId, returnDetailList);
} else {
final List<ReturnDetail> returnDetailList = new ArrayList<>();
returnDetailList.add(returnDetail);
returnSaleMap.put(returnSaleId, returnDetailList);
}
}
// 将详细信息封装到返回结果中去
for (ReturnSaleVo returnSaleVo : returnSaleList) {
final String id = returnSaleVo.getId();
// 从returnSaleMap获取,并封装
if (returnSaleMap.containsKey(id)) {
// 这是是根据退商品id查询的,所以肯定是同一件商品,并且在同一个订单中采购价等也是一样
// 所以商品信息循环覆盖即可,每一个详情相当于一种规格
final List<ReturnSaleDetailDTO> returnSaleDetailList = new ArrayList<>();
final ReturnSaleDetailDTO returnSaleDetailDTO = new ReturnSaleDetailDTO();
final List<ReturnDetail> returnDetailList = returnSaleMap.get(id);
final List<SaleDetailQueryDTO> stockLogList1 = new ArrayList<>();
for (ReturnDetail returnDetail : returnDetailList) {
returnSaleDetailDTO.setProductId(returnDetail.getProductId());
returnSaleDetailDTO.setProductName(returnDetail.getProductName());
returnSaleDetailDTO.setProductCount(returnDetail.getProductCount());
returnSaleDetailDTO.setRealPrice(returnDetail.getRealPrice());
// 详细规格
final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO();
saleDetailQueryDTO.setAttributeList(returnDetail.getAttributeList());
saleDetailQueryDTO.setProductCount(returnDetail.getProductCount());
stockLogList1.add(saleDetailQueryDTO);
}
returnSaleDetailDTO.setStockLogList1(stockLogList1);
returnSaleDetailList.add(returnSaleDetailDTO);
returnSaleVo.setReturnSaleDetailList(returnSaleDetailList);
}
}
return returnSalePage;
}
final Page<SaleReturnDTO> page = new Page<>(returnSalePageQuery.getPageNum(), returnSalePageQuery.getPageSize()); /**
final Page<SaleReturnDTO> salePage = returnSaleMapper.getReturnSaleListByProductId(page, returnSalePageQuery.getProductId()); * 退货金额明细
final List<SaleReturnDTO> saleList = salePage.getRecords(); *
* @param returnSalePageQuery
* @return Page<returnTotalAmountDetailVo>
* @author 王富康
* @date 2024/6/29
*/
@Override
public Page<ReturnTotalAmountDetailVo> returnTotalAmountDetail(ReturnSalePageQuery returnSalePageQuery) {
final Page<ReturnTotalAmountDetailVo> page = new Page<>(returnSalePageQuery.getPageNum(), returnSalePageQuery.getPageSize());
// shopId从缓存中设置
final String shopId = securityUtil.getShopId();
returnSalePageQuery.setShopId(shopId);
return returnSaleMapper.returnTotalAmountDetail(page, returnSalePageQuery);
}
/**
* 根据客户id分页获取退货历史
*
* @param returnSalePageQuery
* @return Page<ReturnSaleVo>
* @author 王富康
* @date 2024/6/30
*/
@Override
public Page<ReturnSaleVo> getReturnSaleListByUserId(ReturnSalePageQuery returnSalePageQuery) {
if (StringUtils.isNotEmpty(returnSalePageQuery.getEndDate())) {
returnSalePageQuery.setEndDate(DateUtil.addDay(returnSalePageQuery.getEndDate(), 1));
}
final Page<ReturnSaleVo> page = new Page<>(returnSalePageQuery.getPageNum(), returnSalePageQuery.getPageSize());
final Page<ReturnSaleVo> returnSalePage = returnSaleMapper.getReturnSaleListByUserId(page, returnSalePageQuery);
final List<ReturnSaleVo> returnSaleList = returnSalePage.getRecords();
// 根据商品id获取退货详细信息
List<String> returnSaleIdList = new ArrayList<>();
for (ReturnSaleVo returnSaleVo : returnSaleList) {
returnSaleIdList.add(returnSaleVo.getId());
}
if(!returnSaleIdList.isEmpty()){
// 获取退货单明细
final List<ReturnDetail> returnDetails = returnDetailService.getReturnDetailsByReturnId(returnSaleIdList);
// 将returnDetails 放到以return_sale_id 为key ReturnDetail为value的map中去
final Map<String, List<ReturnDetail>> returnSaleMap = new HashMap<>();
for (ReturnDetail returnDetail : returnDetails) {
final String returnSaleId = returnDetail.getReturnSaleId();
if (returnSaleMap.containsKey(returnSaleId)) {
final List<ReturnDetail> returnDetailList = returnSaleMap.get(returnSaleId);
returnDetailList.add(returnDetail);
returnSaleMap.put(returnSaleId, returnDetailList);
} else {
final List<ReturnDetail> returnDetailList = new ArrayList<>();
returnDetailList.add(returnDetail);
returnSaleMap.put(returnSaleId, returnDetailList);
}
}
// 将详细信息封装到返回结果中去
for (ReturnSaleVo returnSaleVo : returnSaleList) {
final String id = returnSaleVo.getId();
// 从returnSaleMap获取,并封装
if (returnSaleMap.containsKey(id)) {
// 这是是根据退商品id查询的,所以肯定是同一件商品,并且在同一个订单中采购价等也是一样
// 所以商品信息循环覆盖即可,每一个详情相当于一种规格
final List<ReturnSaleDetailDTO> returnSaleDetailList = new ArrayList<>();
final ReturnSaleDetailDTO returnSaleDetailDTO = new ReturnSaleDetailDTO();
final List<ReturnDetail> returnDetailList = returnSaleMap.get(id);
final List<SaleDetailQueryDTO> stockLogList1 = new ArrayList<>();
for (ReturnDetail returnDetail : returnDetailList) {
returnSaleDetailDTO.setProductId(returnDetail.getProductId());
returnSaleDetailDTO.setProductName(returnDetail.getProductName());
returnSaleDetailDTO.setProductCount(returnDetail.getProductCount());
returnSaleDetailDTO.setRealPrice(returnDetail.getRealPrice());
// 详细规格
final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO();
saleDetailQueryDTO.setAttributeList(returnDetail.getAttributeList());
saleDetailQueryDTO.setProductCount(returnDetail.getProductCount());
stockLogList1.add(saleDetailQueryDTO);
}
returnSaleDetailDTO.setStockLogList1(stockLogList1);
returnSaleDetailList.add(returnSaleDetailDTO);
returnSaleVo.setReturnSaleDetailList(returnSaleDetailList);
}
}
}
return null; return returnSalePage;
} }
} }

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

@ -366,11 +366,10 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
@Override @Override
public Page<CustomerBuyProductLogVo> getCustomerBuyProductLog(SalePageQuery salePageQuery) { public Page<CustomerBuyProductLogVo> getCustomerBuyProductLog(SalePageQuery salePageQuery) {
final String shopId = securityUtil.getShopId();
// 先拿到该客户购买的所有商品信息 // 先拿到该客户购买的所有商品信息
final Page<CustomerBuyProductLogVo> page = new Page<>(salePageQuery.getPageNum(), salePageQuery.getPageSize()); final Page<CustomerBuyProductLogVo> page = new Page<>(salePageQuery.getPageNum(), salePageQuery.getPageSize());
final String userId = salePageQuery.getUserId(); final String userId = salePageQuery.getUserId();
final Page<CustomerBuyProductLogVo> salePage = saleMapper.getCustomerBuyProductLog(page, userId, shopId); final Page<CustomerBuyProductLogVo> salePage = saleMapper.getCustomerBuyProductLog(page, userId, salePageQuery.getShopId());
final List<CustomerBuyProductLogVo> records = salePage.getRecords(); final List<CustomerBuyProductLogVo> records = salePage.getRecords();
final List<String> productIds = new ArrayList<>(); final List<String> productIds = new ArrayList<>();
// 商品id集合 // 商品id集合
@ -385,7 +384,7 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
} }
if (!productIds.isEmpty()) { if (!productIds.isEmpty()) {
// 获取商品各规格售卖的数量 // 获取商品各规格售卖的数量
final List<CustomerBuyProductDetailLogVo> customerBuyProductDetailLogVos = saleMapper.getCustomerBuyProductLogDetailLog(userId, shopId, productIds); final List<CustomerBuyProductDetailLogVo> customerBuyProductDetailLogVos = saleMapper.getCustomerBuyProductLogDetailLog(userId, salePageQuery.getShopId(), productIds);
// 进行数据封装Map<商品id,Map<销售单id,商品明细>> // 进行数据封装Map<商品id,Map<销售单id,商品明细>>
final Map<String, Map<String, List<CustomerBuyProductDetailLogVo>>> allMap = new HashMap<>(); final Map<String, Map<String, List<CustomerBuyProductDetailLogVo>>> allMap = new HashMap<>();
@ -914,19 +913,41 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
// 根据订单获取交易记录 // 根据订单获取交易记录
final String userId = sale.getUserId(); final String userId = sale.getUserId();
final Debt oldDebt = debtService.selectByUserId(userId); final Debt oldDebt = debtService.selectByUserId(userId);
if(oldDebt != null){ if (oldDebt != null) {
final BigDecimal newDebtAmount; final BigDecimal newDebtAmount;
final BigDecimal lastDebtAmount = oldDebt.getAmountOwed();
// 欠款抵扣,需要单独从欠款中减掉 // 欠款抵扣,需要单独从欠款中减掉
final BigDecimal debtDeductionAmount = sale.getDebtDeductionAmount() == null ? BigDecimal.valueOf(0) : sale.getDebtDeductionAmount(); final BigDecimal debtDeductionAmount = sale.getDebtDeductionAmount() == null ? BigDecimal.ZERO : sale.getDebtDeductionAmount();
// 余额抵扣,需要从欠款中减掉 // 余额抵扣,需要从欠款中减掉
final BigDecimal balanceDeductionAmount = sale.getBalanceDeductionAmount() == null ? BigDecimal.valueOf(0) : sale.getBalanceDeductionAmount(); final BigDecimal balanceDeductionAmount = sale.getBalanceDeductionAmount() == null ? BigDecimal.ZERO : sale.getBalanceDeductionAmount();
// 本单欠款 // 本单欠款
final BigDecimal noEarn = sale.getNoEarn() == null ? BigDecimal.valueOf(0) : sale.getNoEarn(); final BigDecimal noEarn = sale.getNoEarn() == null ? BigDecimal.ZERO : sale.getNoEarn();
// 计算欠款 // 计算欠款
final BigDecimal amount = debtDeductionAmount.subtract(noEarn).subtract(balanceDeductionAmount);
newDebtAmount = oldDebt.getAmountOwed().subtract(noEarn).add(debtDeductionAmount).subtract(balanceDeductionAmount); newDebtAmount = oldDebt.getAmountOwed().subtract(noEarn).add(debtDeductionAmount).subtract(balanceDeductionAmount);
oldDebt.setAmountOwed(newDebtAmount); oldDebt.setAmountOwed(newDebtAmount);
debtService.saveOrUpdateDebt(oldDebt); debtService.updateById(oldDebt);
// 2. 新增欠款记录
// 创建人
final User user = securityUtil.getCurrUser();
final DealingsRecord dealingsRecord = new DealingsRecord();
dealingsRecord.setCreateBy(user.getId());
dealingsRecord.setCreateByName(user.getNickname());
dealingsRecord.setCreateTime(new Date());
dealingsRecord.setDealingsUserId(sale.getUserId());
dealingsRecord.setDealingsUserName(sale.getUserName());
dealingsRecord.setDealingsWay("订单撤销");
dealingsRecord.setShopId(sale.getShopId());
// 上次欠款
dealingsRecord.setLastDebtAmount(lastDebtAmount);
// 最新欠款
dealingsRecord.setBalanceDue(newDebtAmount);
// 金额
dealingsRecord.setAmount(amount);
dealingsRecord.setDealingsType(DealingsRecordConstant.DEALINGS_TYPE[6]);
dealingsRecord.setUserType(DealingsRecordConstant.TYPE[1]);
dealingsRecordService.save(dealingsRecord);
} }
// 作废当前订单的欠款记录 // 作废当前订单的欠款记录
dealingsRecordService.cancelRecord(id); dealingsRecordService.cancelRecord(id);
@ -949,6 +970,47 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
return saleMapper.getArrearsAndTotalSale(customerBillQueryVo); return saleMapper.getArrearsAndTotalSale(customerBillQueryVo);
} }
@Override
public Page<TotalAmountDetailVo> totalAmountDetail(SalePageQuery salePageQuery) {
final Page<TotalAmountDetailVo> page = new Page<>(salePageQuery.getPageNum(), salePageQuery.getPageSize());
// shopId从缓存中设置
final String shopId = securityUtil.getShopId();
salePageQuery.setShopId(shopId);
return saleMapper.totalAmountDetail(page, salePageQuery);
}
/**
* 实收金额明细
* @author 王富康
* @date 2024/6/29
* @param salePageQuery
* @return List<TotalAlreadyEarnDetailDayVo>
*/
@Override
public Page<TotalAlreadyEarnDetailDayVo> totalAlreadyEarnDetail(SalePageQuery salePageQuery) {
final Page<TotalAlreadyEarnDetailDayVo> page = new Page<>(salePageQuery.getPageNum(), salePageQuery.getPageSize());
// shopId从缓存中设置
final String shopId = securityUtil.getShopId();
salePageQuery.setShopId(shopId);
return saleMapper.totalAlreadyEarnDetail(page, salePageQuery);
}
/**
* 客户拿货统计
* @author 王富康
* @date 2024/6/29
* @param salePageQuery
* @return Page<CustomerSaleDetailVo>
*/
@Override
public Page<CustomerSaleDetailVo> customerSaleDetail(SalePageQuery salePageQuery) {
final Page<CustomerSaleDetailVo> page = new Page<>(salePageQuery.getPageNum(), salePageQuery.getPageSize());
// shopId从缓存中设置
final String shopId = securityUtil.getShopId();
salePageQuery.setShopId(shopId);
return saleMapper.customerSaleDetail(page, salePageQuery);
}
/** /**
* 使用正则表达式替换输入字符串中连续的字符为相应数量的X字符 * 使用正则表达式替换输入字符串中连续的字符为相应数量的X字符
* *

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

@ -396,13 +396,17 @@
</update> </update>
<select id="selectDebtByShopId" resultMap="DebtResultMap"> <select id="selectDebtByShopId" resultMap="DebtResultMap">
select a.supplier_id,a.supplier_name,sum(a.no_pay) no_pay SELECT
from t_purchase a tc.id as supplier_id,
where del_flag = '0' tc.consignee_name,
and no_pay > 0 td.amount_owed as no_pay
and shop_id = #{queryParams.shopId} FROM
group by a.supplier_id,a.supplier_name t_supplier tc
order by no_pay desc LEFT JOIN t_debt td ON tc.id = td.user_id
WHERE
tc.del_flag = '0'
and tc.shop_id = #{queryParams.shopId}
order by no_earn desc
</select> </select>
<select id="getPurchaseList" parameterType="cc.hiver.mall.pojo.query.PurchasePageQuery" resultMap="BaseResultMap"> <select id="getPurchaseList" parameterType="cc.hiver.mall.pojo.query.PurchasePageQuery" resultMap="BaseResultMap">
@ -466,4 +470,35 @@
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
<select id="purchasingCostDetail" resultType="cc.hiver.mall.pojo.vo.PurchasingCostDetailVo">
select
tp.id as purchase_id,
tp.create_by,
tp.create_by_name,
tp.supplier_id,
tp.supplier_name,
tp.create_time as purchase_date,
cb.total_cost,
cb.product_count,
cb.product_num
from
t_purchase tp
left join
(select purchase_id, sum(price) as total_cost,count(product_id) as product_num,sum(product_count) as product_count from t_purchase_detail tpd where shop_id = #{purchasePageQuery.shopId} group by tpd.purchase_id) cb
on tp.id = cb.purchase_id
WHERE
del_flag ='0'
and in_storage_status = '1'
and shop_id = #{purchasePageQuery.shopId}
<if test='purchasePageQuery.createByName !=null and purchasePageQuery.createByName !=""'>
and create_by_name like concat('%',#{purchasePageQuery.createByName},'%')
</if>
<if test='purchasePageQuery.supplierName !=null and purchasePageQuery.supplierName !=""'>
and supplier_name like concat('%',#{purchasePageQuery.supplierName},'%')
</if>
<if test='purchasePageQuery.startDate !=null and purchasePageQuery.endDate !=null'>
and create_time BETWEEN #{purchasePageQuery.startDate} AND #{purchasePageQuery.endDate}
</if>
order by purchase_date desc
</select>
</mapper> </mapper>

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

@ -4,6 +4,7 @@
<resultMap id="BaseResultMap" type="cc.hiver.mall.entity.ReturnDetail"> <resultMap id="BaseResultMap" type="cc.hiver.mall.entity.ReturnDetail">
<id column="id" jdbcType="VARCHAR" property="id" /> <id column="id" jdbcType="VARCHAR" property="id" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" /> <result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_by_name" jdbcType="VARCHAR" property="createByName" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="del_flag" jdbcType="INTEGER" property="delFlag" /> <result column="del_flag" jdbcType="INTEGER" property="delFlag" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" /> <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
@ -85,7 +86,7 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, create_by, create_time, del_flag, update_by, update_time, sale_id, product_id, id, create_by, create_by_name, create_time, del_flag, update_by, update_time, sale_id, product_id,
product_name, unit, shop_id, category_id, attribute_list, price, purchase_price, product_name, unit, shop_id, category_id, attribute_list, price, purchase_price,
wholesale_price, product_count, discount, discount_amount, real_price, return_sale_id, wholesale_price, product_count, discount, discount_amount, real_price, return_sale_id,
product_picture, product_sn product_picture, product_sn
@ -121,14 +122,14 @@
</if> </if>
</delete> </delete>
<insert id="insert" parameterType="cc.hiver.mall.entity.ReturnDetail"> <insert id="insert" parameterType="cc.hiver.mall.entity.ReturnDetail">
insert into t_return_detail (id, create_by, create_time, insert into t_return_detail (id, create_by,create_by_name, create_time,
del_flag, update_by, update_time, del_flag, update_by, update_time,
sale_id, product_id, product_name, sale_id, product_id, product_name,
unit, shop_id, category_id, unit, shop_id, category_id,
attribute_list, price, purchase_price, attribute_list, price, purchase_price,
wholesale_price, product_count, discount, wholesale_price, product_count, discount,
discount_amount, real_price,return_sale_id,product_picture,product_sn) discount_amount, real_price,return_sale_id,product_picture,product_sn)
values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR},#{createByName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
#{saleId,jdbcType=VARCHAR}, #{productId,jdbcType=VARCHAR}, #{productName,jdbcType=VARCHAR}, #{saleId,jdbcType=VARCHAR}, #{productId,jdbcType=VARCHAR}, #{productName,jdbcType=VARCHAR},
#{unit,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR}, #{categoryId,jdbcType=VARCHAR}, #{unit,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR}, #{categoryId,jdbcType=VARCHAR},
@ -145,6 +146,9 @@
</if> </if>
<if test="createBy != null"> <if test="createBy != null">
create_by, create_by,
</if>
<if test="createByName != null">
create_by_name,
</if> </if>
<if test="createTime != null"> <if test="createTime != null">
create_time, create_time,
@ -216,6 +220,9 @@
</if> </if>
<if test="createBy != null"> <if test="createBy != null">
#{createBy,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR},
</if>
<if test="createByName != null">
#{createByName,jdbcType=VARCHAR},
</if> </if>
<if test="createTime != null"> <if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP},
@ -296,6 +303,9 @@
</if> </if>
<if test="record.createBy != null"> <if test="record.createBy != null">
create_by = #{record.createBy,jdbcType=VARCHAR}, create_by = #{record.createBy,jdbcType=VARCHAR},
</if>
<if test="record.createByName != null">
create_by_name = #{record.createByName,jdbcType=VARCHAR},
</if> </if>
<if test="record.createTime != null"> <if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP}, create_time = #{record.createTime,jdbcType=TIMESTAMP},
@ -369,6 +379,7 @@
update t_return_detail update t_return_detail
set id = #{record.id,jdbcType=VARCHAR}, set id = #{record.id,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=VARCHAR}, create_by = #{record.createBy,jdbcType=VARCHAR},
create_by_name = #{record.createByName,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP}, create_time = #{record.createTime,jdbcType=TIMESTAMP},
del_flag = #{record.delFlag,jdbcType=INTEGER}, del_flag = #{record.delFlag,jdbcType=INTEGER},
update_by = #{record.updateBy,jdbcType=VARCHAR}, update_by = #{record.updateBy,jdbcType=VARCHAR},
@ -399,6 +410,9 @@
<set> <set>
<if test="createBy != null"> <if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR}, create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="createByName != null">
create_by_name = #{createByName,jdbcType=VARCHAR},
</if> </if>
<if test="createTime != null"> <if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP}, create_time = #{createTime,jdbcType=TIMESTAMP},
@ -469,6 +483,7 @@
<update id="updateByPrimaryKey" parameterType="cc.hiver.mall.entity.ReturnDetail"> <update id="updateByPrimaryKey" parameterType="cc.hiver.mall.entity.ReturnDetail">
update t_return_detail update t_return_detail
set create_by = #{createBy,jdbcType=VARCHAR}, set create_by = #{createBy,jdbcType=VARCHAR},
create_by_name = #{createByName,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP}, create_time = #{createTime,jdbcType=TIMESTAMP},
del_flag = #{delFlag,jdbcType=INTEGER}, del_flag = #{delFlag,jdbcType=INTEGER},
update_by = #{updateBy,jdbcType=VARCHAR}, update_by = #{updateBy,jdbcType=VARCHAR},
@ -502,4 +517,25 @@
#{listItem} #{listItem}
</foreach> </foreach>
</select> </select>
<select id="getReturnDetailsByProductId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_return_detail
where del_flag='0'
and product_id = #{returnSalePageQuery.productId}
<if test='returnSalePageQuery.startDate !=null and returnSalePageQuery.endDate !=null'>
and ts.create_time BETWEEN #{returnSalePageQuery.startDate} AND #{returnSalePageQuery.endDate}
</if>
</select>
<select id="getReturnDetailsByReturnId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_return_detail
where sale_id in
<foreach close=")" collection="returnSaleIdList" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</select>
</mapper> </mapper>

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

@ -582,7 +582,9 @@
from from
t_return_sale ts t_return_sale ts
WHERE WHERE
ts.user_id = #{customerBillQueryVo.customerId} ts.del_flag = '0'
and ts.user_id = #{customerBillQueryVo.customerId}
and ts.shop_id = #{customerBillQueryVo.shopId}
<!--订单状态不为:02:退货已作废--> <!--订单状态不为:02:退货已作废-->
and ts.status not in ( '02' ) and ts.status not in ( '02' )
<if test='customerBillQueryVo.startDate !=null and customerBillQueryVo.endDate !=null'> <if test='customerBillQueryVo.startDate !=null and customerBillQueryVo.endDate !=null'>
@ -591,32 +593,83 @@
order by ts.create_time asc order by ts.create_time asc
</select> </select>
<select id="getReturnSaleListByProductId" resultMap="BaseResultMap"> <select id="getReturnSaleListByProductId" resultType="cc.hiver.mall.pojo.vo.ReturnSaleVo">
select select
ts.id,ts.create_by,ts.create_by_name,ts.create_time,ts.del_flag,ts.update_by,ts.update_by_name,ts.update_time,ts.user_id,ts.user_name, id, trs.sale_id, trs.create_by, trs.create_time, trs.del_flag, trs.update_by, trs.update_time, trs.user_id,user_name, trs.shop_id,
ts.shop_id,ts.shop_name,ts.total_amount,ts.discount,ts.discount_amount,ts.real_amount,ts.debt_deduction_amount,ts.sale_deduction_amount,ts.balance_deduction_amount ,ts.already_earn,ts.no_earn,ts.pay_status, total_amount, trs.discount, trs.discount_amount, trs.real_amount, trs.already_earn, trs.no_earn, trs.pay_status,
ts.pay_type,ts.status,ts.other_expense,ts.transport_type,ts.share_address,ts.receive_address,ts.province,ts.city,ts.area, status, trs.transport_type, trs.share_address, trs.receive_address, trs.province, trs.city, trs.area, trs.trans_company,
ts.trans_company,ts.company_name,ts.product_count,ts.remark,ts.sale_name,ts.company_phone,ts.create_by_phone,ts.mode_of_service, trans_company_name, trs.product_count
ts.ai_flag,ts.ai_result,ts.ai_not_recognition,
ss.return_sale_product_count,ss.return_sale_amount
from from
t_sale ts t_return_sale trs
left join (
select
sale_id,
sum( trs.product_count ) as return_sale_product_count,
sum( trs.total_amount ) as return_sale_amount
from
t_return_sale trs
where
trs.sale_id in ( select sale_id from t_sale_detail where product_id = #{productId} )
group by
trs.sale_id
) ss on ts.id = ss.sale_id
where where
ts.id in ( select sale_id from t_sale_detail where product_id = #{productId} ) del_flag ='0'
and ts.status not in ( '2', '6', '7' ) and trs.id in ( select trd.return_sale_id from t_return_detail trd where trd.product_id = #{returnSalePageQuery.productId} )
and trs.status not in ('02')
<if test='returnSalePageQuery.startDate !=null and returnSalePageQuery.endDate !=null'>
and ts.create_time BETWEEN #{returnSalePageQuery.startDate} AND #{returnSalePageQuery.endDate}
</if>
order by
trs.create_time desc
</select>
<select id="returnTotalAmountDetail" resultType="cc.hiver.mall.pojo.vo.ReturnTotalAmountDetailVo">
select
id as return_sale_id,
create_by,
create_by_name,
user_id,
user_name,
create_time as return_sale_date,
product_count,
total_amount,
cb.total_cost
from
t_return_sale trs
left join
(select trd.return_sale_id,trd.sale_id, IFNULL(sum(trd.purchase_price * trd.product_count),0.00) as total_cost from t_return_detail trd where trd.shop_id = #{returnSalePageQuery.shopId} group by trd.sale_id,trd.return_sale_id) cb
on trs.id = cb.return_sale_id
WHERE
trs.del_flag ='0'
<!--订单状态不为:2:已作废;分享页提交订单:6:待配货;挂单页提交订单:7:挂单-->
and trs.shop_id = #{returnSalePageQuery.shopId}
and trs.status not in ( '02' )
<if test='returnSalePageQuery.createByName !=null and returnSalePageQuery.createByName !=""'>
and trs.create_by_name like concat('%',#{returnSalePageQuery.createByName},'%')
</if>
<!--按客户查询-->
<if test='returnSalePageQuery.createBy !=null and returnSalePageQuery.createBy !=""'>
and trs.create_by = #{returnSalePageQuery.createBy}
</if>
<!--按商品查询-->
<if test='returnSalePageQuery.productId !=null and returnSalePageQuery.productId !=""'>
and trs.product_id = #{returnSalePageQuery.productId}
</if>
<if test='returnSalePageQuery.userName !=null and returnSalePageQuery.userName !=""'>
and trs.user_name like concat('%',#{returnSalePageQuery.userName},'%')
</if>
<if test='returnSalePageQuery.startDate !=null and returnSalePageQuery.endDate !=null'>
and trs.create_time BETWEEN #{returnSalePageQuery.startDate} AND #{returnSalePageQuery.endDate}
</if>
order by trs.create_time desc
</select>
<select id="getReturnSaleListByUserId" resultType="cc.hiver.mall.pojo.vo.ReturnSaleVo">
select
trs.id, trs.sale_id, trs.create_by, trs.create_time, trs.del_flag, trs.update_by, trs.update_time, trs.user_id,user_name, trs.shop_id,
trs.total_amount, trs.discount, trs.discount_amount, trs.real_amount, trs.already_earn, trs.no_earn, trs.pay_status,
trs.status, trs.transport_type, trs.share_address, trs.receive_address, trs.province, trs.city, trs.area, trs.trans_company,
trs.trans_company_name, trs.product_count
from
t_return_sale trs
where
trs.del_flag ='0'
and trs.shop_id = #{returnSalePageQuery.shopId}
and trs.user_id = #{returnSalePageQuery.userId}
and trs.status not in ('02')
<if test='returnSalePageQuery.startDate !=null and returnSalePageQuery.endDate !=null'>
and trs.create_time BETWEEN #{returnSalePageQuery.startDate} AND #{returnSalePageQuery.endDate}
</if>
order by order by
ts.create_time desc trs.create_time desc
</select> </select>
</mapper> </mapper>

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

@ -1030,9 +1030,10 @@ trans_company, company_name, product_count, remark, sale_name, company_phone, cr
group by group by
n.sale_id n.sale_id
) trs on ts.id = trs.sale_id ) trs on ts.id = trs.sale_id
left join t_dealings_record tdr on ts.id = tdr.sale_id left join t_dealings_record tdr on ts.id = tdr.sale_id and tdr.shop_id = #{customerBillQueryVo.shopId}
WHERE WHERE
ts.user_id = #{customerBillQueryVo.customerId} ts.user_id = #{customerBillQueryVo.customerId}
and ts.shop_id = #{customerBillQueryVo.shopId}
<!--订单状态不为:2:已作废;分享页提交订单:6:待配货;挂单页提交订单:7:挂单--> <!--订单状态不为:2:已作废;分享页提交订单:6:待配货;挂单页提交订单:7:挂单-->
and ts.status not in ( '2', '6', '7' ) and ts.status not in ( '2', '6', '7' )
<if test='customerBillQueryVo.startDate !=null and customerBillQueryVo.endDate !=null'> <if test='customerBillQueryVo.startDate !=null and customerBillQueryVo.endDate !=null'>
@ -1048,12 +1049,125 @@ trans_company, company_name, product_count, remark, sale_name, company_phone, cr
from from
t_sale ts t_sale ts
WHERE WHERE
ts.user_id = #{customerBillQueryVo.customerId} ts.del_flag = '0'
and ts.user_id = #{customerBillQueryVo.customerId}
and ts.shop_id = #{customerBillQueryVo.shopId}
<!--订单状态不为:2:已作废;分享页提交订单:6:待配货;挂单页提交订单:7:挂单--> <!--订单状态不为:2:已作废;分享页提交订单:6:待配货;挂单页提交订单:7:挂单-->
and ts.status not in ( '2', '6', '7' ) and ts.status not in ( '2', '6', '7' )
<if test='customerBillQueryVo.startDate !=null and customerBillQueryVo.endDate !=null'> <if test='customerBillQueryVo.startDate !=null and customerBillQueryVo.endDate !=null'>
and ts.create_time BETWEEN #{customerBillQueryVo.startDate} AND #{customerBillQueryVo.endDate} and ts.create_time BETWEEN #{customerBillQueryVo.startDate} AND #{customerBillQueryVo.endDate}
</if> </if>
order by ts.create_time asc order by ts.create_time desc
</select>
<select id="totalAmountDetail" resultType="cc.hiver.mall.pojo.vo.TotalAmountDetailVo">
select
id as sale_id,
create_by,
create_by_name,
user_id,
user_name,
create_time as sale_date,
total_amount,
cb.total_cost,
total_amount -cb.total_cost as profit
from
t_sale ts
left join
(select tsd.sale_id, IFNULL(sum(tsd.purchase_price * tsd.product_count),0.00) as total_cost from t_sale_detail tsd where tsd.shop_id = #{salePageQuery.shopId} group by tsd.sale_id) cb
on ts.id = cb.sale_id
WHERE
ts.del_flag ='0'
<!--订单状态不为:2:已作废;分享页提交订单:6:待配货;挂单页提交订单:7:挂单-->
and ts.shop_id = #{salePageQuery.shopId}
and ts.status not in ( '2', '6', '7' )
<if test='salePageQuery.createByName !=null and salePageQuery.createByName !=""'>
and ts.create_by_name like concat('%',#{salePageQuery.createByName},'%')
</if>
<!--按客户查询-->
<if test='salePageQuery.createBy !=null and salePageQuery.createBy !=""'>
and ts.create_by = #{salePageQuery.createBy}
</if>
<!--按商品查询-->
<if test='salePageQuery.productId !=null and salePageQuery.productId !=""'>
and ts.product_id = #{salePageQuery.productId}
</if>
<if test='salePageQuery.userName !=null and salePageQuery.userName !=""'>
and ts.user_name like concat('%',#{salePageQuery.userName},'%')
</if>
<if test='salePageQuery.startDate !=null and salePageQuery.endDate !=null'>
and ts.create_time BETWEEN #{salePageQuery.startDate} AND #{salePageQuery.endDate}
</if>
order by ts.create_time desc
</select>
<select id="totalAlreadyEarnDetail" resultType="cc.hiver.mall.pojo.vo.TotalAlreadyEarnDetailDayVo">
select
date(create_time) as payment_day,
sum(case when pay_type = '0' then real_amount else 0 end) as xianjin,
sum(case when pay_type = '1' then real_amount else 0 end) as weixin,
sum(case when pay_type = '2' then real_amount else 0 end) as zhifubao,
sum(case when pay_type = '3' then real_amount else 0 end) as yihangzhuanzhang,
sum(case when pay_type = '4' then real_amount else 0 end) as shouhuanma,
sum(case when pay_type = '5' then real_amount else 0 end) as yuliu_one,
sum(case when pay_type = '6' then real_amount else 0 end) as yuliu_two,
sum(case when pay_type = '7' then real_amount else 0 end) as yuliu_three
from
t_sale
WHERE
del_flag ='0'
<!--订单状态不为:2:已作废;分享页提交订单:6:待配货;挂单页提交订单:7:挂单-->
and shop_id = #{salePageQuery.shopId}
and status not in ( '2', '6', '7' )
<if test='salePageQuery.createByName !=null and salePageQuery.createByName !=""'>
and create_by_name like concat('%',#{salePageQuery.createByName},'%')
</if>
<if test='salePageQuery.userName !=null and salePageQuery.userName !=""'>
and user_name like concat('%',#{salePageQuery.userName},'%')
</if>
<if test='salePageQuery.startDate !=null and salePageQuery.endDate !=null'>
and create_time BETWEEN #{salePageQuery.startDate} AND #{salePageQuery.endDate}
</if>
group by payment_day
order by payment_day desc
</select>
<select id="customerSaleDetail" resultType="cc.hiver.mall.pojo.vo.CustomerSaleDetailVo">
SELECT
ts.user_id,
ts.user_name,
sum(ts.product_count) as product_count,
sum(ts.real_amount) as real_amount,
sum(cb.total_cost) as total_cost,
sum(ts.real_amount - cb.total_cost) as profit
FROM
t_sale ts
left join
(select tsd.sale_id, IFNULL(sum(tsd.purchase_price * tsd.product_count),0.00) as total_cost from t_sale_detail tsd where tsd.shop_id = #{salePageQuery.shopId} group by tsd.sale_id) cb
on ts.id = cb.sale_id
WHERE
ts.del_flag ='0'
<!--订单状态不为:2:已作废;分享页提交订单:6:待配货;挂单页提交订单:7:挂单-->
and ts.shop_id = #{salePageQuery.shopId}
and ts.status not in ( '2', '6', '7' )
<if test='salePageQuery.createByName !=null and salePageQuery.createByName !=""'>
and ts.create_by_name like concat('%',#{salePageQuery.createByName},'%')
</if>
<!--按客户查询-->
<if test='salePageQuery.createBy !=null and salePageQuery.createBy !=""'>
and ts.create_by = #{salePageQuery.createBy}
</if>
<!--按商品查询-->
<if test='salePageQuery.productId !=null and salePageQuery.productId !=""'>
and ts.product_id = #{salePageQuery.productId}
</if>
<if test='salePageQuery.userName !=null and salePageQuery.userName !=""'>
and ts.user_name like concat('%',#{salePageQuery.userName},'%')
</if>
<if test='salePageQuery.startDate !=null and salePageQuery.endDate !=null'>
and ts.create_time BETWEEN #{salePageQuery.startDate} AND #{salePageQuery.endDate}
</if>
group by user_id,user_name
order by real_amount desc
</select> </select>
</mapper> </mapper>
Loading…
Cancel
Save