Browse Source

许多家需求优化,BUG修改,等。

cangku
wangfukang 2 years ago
parent
commit
5da027c19b
  1. 8
      hiver-admin/src/main/resources/application.yml
  2. 16
      hiver-admin/test-output/test-report.html
  3. 8
      hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/AuthController.java
  4. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/CustomerBillSaleVo.java
  5. 6
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillPurchaseVo.java
  6. 13
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java
  7. 1
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SupplierControlller.java
  8. 53
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Purchase.java
  9. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/PurchasePageQuery.java
  10. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SaleVO.java
  11. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/SupplierService.java
  12. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/CustomerService.java
  13. 1
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java
  14. 49
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SupplierServiceImpl.java
  15. 8
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java
  16. 10
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java
  17. 35
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java
  18. 12
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java
  19. 25
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java
  20. 7
      hiver-modules/hiver-mall/src/main/resources/mapper/DealingsRecordMapper.xml
  21. 3
      hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml
  22. 14
      hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml
  23. 13
      hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml
  24. 3
      hiver-modules/hiver-mall/src/main/resources/mapper/StockLogMapper.xml

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

@ -25,8 +25,8 @@ spring:
timeout-per-shutdown-phase: 10S
# 数据源
datasource:
url: jdbc:mysql://154.8.162.157:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true
# url: jdbc:mysql://8.140.198.243:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true
# url: jdbc:mysql://154.8.162.157:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true
url: jdbc:mysql://8.140.198.243:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: reddoor
# Jasypt加密 可到common-utils中找到JasyptUtil加解密工具类生成加密结果 格式为ENC(加密结果) 以下解密结果为123456
password: ENC(Zla4U4+yRLPhicvuX2TmiEgxEpzP4dk8BHzFDEtiEhwLQIIaftZrrEUJZce6efoe)
@ -67,8 +67,8 @@ spring:
ddl-auto: update
# Redis 若设有密码自行添加配置password
redis:
host: 154.8.162.157
# host: 8.140.198.243
# host: 154.8.162.157
host: 8.140.198.243
password: reddoor168
# 数据库索引 默认0
database: 1

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

@ -35,7 +35,7 @@
<a href="#"><span class="badge badge-primary">Hiver</span></a>
</li>
<li class="m-r-10">
<a href="#"><span class="badge badge-primary">七月 25, 2024 22:04:43</span></a>
<a href="#"><span class="badge badge-primary">八月 01, 2024 22:09:58</span></a>
</li>
</ul>
</div>
@ -84,7 +84,7 @@
<div class="test-detail">
<span class="meta text-white badge badge-sm"></span>
<p class="name">passTest</p>
<p class="text-sm"><span>22:04:43 下午</span> / <span>0.016 secs</span></p>
<p class="text-sm"><span>22:09:59 下午</span> / <span>0.019 secs</span></p>
</div>
<div class="test-contents d-none">
<div class="detail-head">
@ -92,9 +92,9 @@
<div class="info">
<div class='float-right'><span class='badge badge-default'>#test-id=1</span></div>
<h5 class="test-status text-pass">passTest</h5>
<span class='badge badge-success'>07.25.2024 22:04:43</span>
<span class='badge badge-danger'>07.25.2024 22:04:43</span>
<span class='badge badge-default'>0.016 secs</span>
<span class='badge badge-success'>08.01.2024 22:09:59</span>
<span class='badge badge-danger'>08.01.2024 22:09:59</span>
<span class='badge badge-default'>0.019 secs</span>
</div>
<div class="m-t-10 m-l-5"></div>
</div>
@ -104,7 +104,7 @@
<tbody>
<tr class="event-row">
<td><span class="badge log pass-bg">Pass</span></td>
<td>22:04:43</td>
<td>22:09:59</td>
<td>
Test passed
</td>
@ -128,13 +128,13 @@
<div class="col-md-3">
<div class="card"><div class="card-body">
<p class="m-b-0">Started</p>
<h3>七月 25, 2024 22:04:43</h3>
<h3>八月 01, 2024 22:09:58</h3>
</div></div>
</div>
<div class="col-md-3">
<div class="card"><div class="card-body">
<p class="m-b-0">Ended</p>
<h3>七月 25, 2024 22:04:43</h3>
<h3>八月 01, 2024 22:09:59</h3>
</div></div>
</div>
<div class="col-md-3">

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

@ -442,9 +442,13 @@ public class AuthController {
supplier.setConsigneeName("默认供应商");
supplier.setCreateBy(user.getId());
supplier.setCreateTime(new Date());
supplier.setConsigneeMobile("");
supplier.setConsigneeMobile("13222222222");
supplier.setProvince("暂无");
supplier.setCity("暂无");
supplier.setArea("暂无");
supplier.setAddress("暂无");
supplier.setDelFlag(CommonConstant.DEL_FLAG_FALSE);
supplierService.save(supplier);
supplierService.addSupplier(supplier);
// 启用店铺的时候需要给该店铺新增一个散客的客户;
Customer customer = new Customer();
customer.setCreateBy(user.getId());

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

@ -56,6 +56,9 @@ public class CustomerBillSaleVo {
@ApiModelProperty(value = "交易类型:0:开单;1:退货;2:回款")
private Integer dealingsType;
@ApiModelProperty(value = "删除标识")
private Integer delFlag;
@ApiModelProperty(value = "销售明细")
private List<BillProductDetailVo> billSaleDetailVos;

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

@ -44,6 +44,12 @@ public class SupplierBillPurchaseVo {
@ApiModelProperty(value = "交易类型:0:开单;1:退货;2:回款")
private Integer dealingsType;
@ApiModelProperty(value = "入库时间,20240727重新定义为入库单的创建时间,createTime为前台传递的入库单")
private String purchaseTime;
@ApiModelProperty(value = "删除标识")
private Integer delFlag;
@ApiModelProperty(value = "销售明细")
private List<BillProductDetailVo> billSaleDetailVos;

13
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java

@ -55,11 +55,12 @@ public class CustomerController {
@ApiOperation("新增客户")
@Transactional
public Result save(Customer customer) {
boolean result = true;
result = customerService.addCustomer(customer);
if (result) {
return ResultUtil.success("添加成功");
} else {
try {
final Customer addCustomer = customerService.addCustomer(customer);
// 添加成功,返回客户信息
return new ResultUtil<Customer>().setData(addCustomer);
}catch (Exception e){
log.error("添加客户失败", e);
return ResultUtil.error("添加失败");
}
}
@ -72,7 +73,7 @@ public class CustomerController {
}
final Customer originCustomer = customerService.getById(customer.getId());
// 如果客户id为空,那么就是之前的客户没有填写手机号,没有新增客户登录信息
String userId = originCustomer.getUserId();
final String userId = originCustomer.getUserId();
if(StringUtils.isEmpty(userId)){
if(StringUtils.isNotEmpty(customer.getPhone())){
// 如果维护了客户的手机号,那么就新增用户登录信息

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

@ -91,6 +91,7 @@ public class SupplierControlller {
// 新增供应商欠款
// 客户欠款信息
final BigDecimal noEarn = entity.getNoEarn() == null ? BigDecimal.ZERO : entity.getNoEarn();
supplier.setNoEarn(noEarn);
final Debt debt = new Debt();
debt.setUserId(supplier.getId());
debt.setShopId(shopId);

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

@ -1,14 +1,23 @@
package cc.hiver.mall.entity;
import cc.hiver.core.base.HiverBaseEntity;
import cc.hiver.core.common.constant.CommonConstant;
import cc.hiver.core.common.utils.SnowFlakeUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.Id;
import javax.persistence.Transient;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
@ -16,11 +25,45 @@ import java.util.Date;
@Data
@ApiModel(value = "采购单主表")
@TableName(value = "t_purchase", autoResultMap = true)
public class Purchase extends HiverBaseEntity {
@TableName(value = "t_purchase")
public class Purchase {
private static final long serialVersionUID = 1L;
@Id
@TableId
@ApiModelProperty(value = "唯一标识")
private String id = SnowFlakeUtil.nextId().toString();
@ApiModelProperty(value = "创建者")
@CreatedBy
@TableField(fill = FieldFill.INSERT)
private String createBy;
@ApiModelProperty(value = "更新者")
@LastModifiedBy
@TableField(fill = FieldFill.UPDATE)
private String updateBy;
@LastModifiedDate
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新时间")
@TableField(fill = FieldFill.UPDATE)
private Date updateTime;
@ApiModelProperty(value = "删除标志 默认0")
private Integer delFlag = CommonConstant.STATUS_NORMAL;
/**
* 20240730因为creTime需要保存为前台传递的入库时间这里不适用自动填充
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.DEFAULT)
private Date createTime;
@ApiModelProperty(value = "供应商ID")
private String createByName;
@ -75,8 +118,10 @@ public class Purchase extends HiverBaseEntity {
@Transient
@TableField(exist = false)
@ApiModelProperty(value = "AI识别-实际识别的数量")
private Integer OcrCount;
private Integer ocrCount;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty(value = "入库时间,20240727重新定义为入库单的创建时间,createTime为前台传递的入库单")
private Date purchaseTime;

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

@ -93,4 +93,7 @@ public class PurchasePageQuery extends HiverBasePageQuery {
@ApiModelProperty("是否是Ai列表")
private String isAiList;
@ApiModelProperty("哪个列表")
private String fromWhere;
}

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

@ -11,6 +11,9 @@ import java.io.Serializable;
@ApiModel(value = "销售单主表")
public class SaleVO implements Serializable {
@ApiModelProperty(value = "销售单id")
private String saleId;
@ApiModelProperty(value = "1-全部订单 2-订单列表 3-退货列表")
private String remarkSR;

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

@ -13,4 +13,6 @@ public interface SupplierService extends HiverBaseService<Supplier, String> {
List<Supplier> getbyShopId(String shopId,String searchStr);
void delById(String id);
void addSupplier(Supplier supplier);
}

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

@ -15,7 +15,7 @@ public interface CustomerService extends IService<Customer> {
List<String> findByUserId(String userId);
boolean addCustomer(Customer customer);
Customer addCustomer(Customer customer);
Page<Customer> getCustomerList(CustomerPageQuery customerPageQuery);

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

@ -78,4 +78,5 @@ public interface PurchaseService extends IService<Purchase> {
*/
void cancelPurchase(String id);
boolean insert(Purchase purchase);
}

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

@ -2,11 +2,15 @@ package cc.hiver.mall.serviceimpl;
import cc.hiver.core.base.HiverBaseDao;
import cc.hiver.core.common.constant.CommonConstant;
import cc.hiver.core.common.constant.DealingsRecordConstant;
import cc.hiver.mall.dao.SupplierDao;
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.service.SupplierService;
import cc.hiver.mall.service.mybatis.DealingsRecordService;
import cn.hutool.core.text.CharSequenceUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -18,7 +22,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.criteria.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
@ -34,6 +40,9 @@ public class SupplierServiceImpl implements SupplierService {
@Autowired
private DebtService debtService;
@Autowired
private DealingsRecordService dealingsRecordService;
@Override
public HiverBaseDao<Supplier, String> getRepository() {
return supplierDao;
@ -102,4 +111,44 @@ public class SupplierServiceImpl implements SupplierService {
public void delById(String id) {
supplierDao.delById(id);
}
@Override
public void addSupplier(Supplier supplier) {
supplierDao.save(supplier);
// 客户欠款信息
final BigDecimal amountOwed = BigDecimal.ZERO;
final Debt debt = new Debt();
debt.setCreateBy(supplier.getCreateBy());
debt.setCreateTime(new Date());
debt.setUserId(supplier.getId());
debt.setShopId(supplier.getShopId());
debt.setUserPhone(supplier.getConsigneeMobile());
debt.setUserAdress(supplier.getAddress());
debt.setUserName(supplier.getConsigneeName());
debt.setAmountOwed(amountOwed);
debt.setUserType(DebtConstant.USER_TYPE[1]);
debtService.save(debt);
// 新增交易记录
// 2. 新增欠款记录
final DealingsRecord dealingsRecord = new DealingsRecord();
dealingsRecord.setCreateBy(supplier.getCreateBy());
// dealingsRecord.setCreateByName(supplier);
dealingsRecord.setCreateTime(new Date());
dealingsRecord.setDealingsUserId(supplier.getId());
dealingsRecord.setDealingsUserName(supplier.getConsigneeName());
dealingsRecord.setUserType(DealingsRecordConstant.TYPE[0]);
dealingsRecord.setDealingsWay("新增供应商");
dealingsRecord.setShopId(supplier.getShopId());
// 销售金额
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);
}
}

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

@ -82,8 +82,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
}
@Override
public boolean addCustomer(Customer customer) {
boolean result = false;
public Customer addCustomer(Customer customer) {
// 20240608 更新为新增客户可不填写手机号
if (StringUtils.isNotEmpty(customer.getPhone())) {
// 如果填写了手机号,同时新增客户的登录信息
@ -184,10 +183,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
dealingsRecord.setAmount(amountOwed);
dealingsRecord.setDealingsType(DealingsRecordConstant.DEALINGS_TYPE[3]);
dealingsRecordService.save(dealingsRecord);
if (insert > 0) {
result = true;
}
return result;
return customer;
}
@Override

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

@ -49,13 +49,14 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
final Page<ProductPageVO> page = new Page<>(productPageQuery.getPageNum(), productPageQuery.getPageSize());
final List<ProductPageVO> list = baseMapper.getShareList(page, productPageQuery);
// 获取商品子图
List<String> productIdList = new ArrayList<>();
final List<String> productIdList = new ArrayList<>();
for (ProductPageVO productPageVO : list) {
productIdList.add(productPageVO.getId());
}
if(!productIdList.isEmpty()){
// 获取子图
List<ProductPicture> productPictureByProductIds = productPictureService.getProductPictureByProductIds(productIdList);
Map<String, List<ProductPicture>> productPictureMap = new HashMap<>();
final List<ProductPicture> productPictureByProductIds = productPictureService.getProductPictureByProductIds(productIdList);
final Map<String, List<ProductPicture>> productPictureMap = new HashMap<>();
for (ProductPicture productPictureByProductId : productPictureByProductIds) {
if (productPictureMap.containsKey(productPictureByProductId.getProductId())) {
productPictureMap.get(productPictureByProductId.getProductId()).add(productPictureByProductId);
@ -66,11 +67,12 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
}
}
for (ProductPageVO productPageVO : list) {
String productId = productPageVO.getId();
final String productId = productPageVO.getId();
if (productPictureMap.containsKey(productId)) {
productPageVO.setProductPictures(productPictureMap.get(productId));
}
}
}
page.setRecords(list);
return page;
}

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

@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
@ -162,6 +163,7 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
purchaseDetail.setStockLogList1(stockLogMap.get(productId));
productIdList.add(productId);
}
if(!productIdList.isEmpty()){
// 20240602 将商品的采购价、零售价、批发价回填回来
// 获取商品
final List<Product> productList = productService.getProductList(productIdList);
@ -177,6 +179,7 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
}
}
purchaseVo.setPurchaseDetails(purchaseDetails);
}
// 获取该入库单的欠款更新记录
purchaseVo.setDealingsRecords(dealingsRecordService.getDealingsRecordList(id));
@ -637,8 +640,8 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
public void cancelPurchase(String id) {
// 获取采购单信息
Purchase purchase = purchaseService.getById(id);
List<String> purchaseIdList = new ArrayList<>();
final Purchase purchase = purchaseService.getById(id);
final List<String> purchaseIdList = new ArrayList<>();
purchaseIdList.add(id);
// 3. 商品及库存回退
// 查询商品是有有销售记录并且是不是有且只有这一次入库记录,是的话,直接删除商品及其库存信息,其他的只回退库存即可
@ -714,12 +717,12 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
stockLogService.deleteByPurchaseId(id);
// 5. 计算平均采购价
// 获取该商品的历次入库记录,排除掉本次入库记录 入库的价格*入库数量/入库总数量
Map<String , BigDecimal> productPurchasePriceMap = new HashMap<>();
final Map<String, BigDecimal> productPurchasePriceMap = new HashMap<>();
List<Product> productList = new ArrayList<>();
final List<Product> productList = new ArrayList<>();
for (Map.Entry<String, List<PurchaseDetail>> stringListEntry : purductPurchaseMap.entrySet()) {
final String productId = stringListEntry.getKey();
List<PurchaseDetail> purchaseDetail = stringListEntry.getValue();
final List<PurchaseDetail> purchaseDetail = stringListEntry.getValue();
// 计算该商品的平均采购价 = (当前入库价格*当前入库数量 + 历史入库价格*历史入库数量)/(当前入库数量+历史入库数量)
// 总入库数量
int totalInStorageCount = 0;
@ -727,13 +730,19 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
BigDecimal totalInStoragePrice = BigDecimal.ZERO;
for (PurchaseDetail detail : purchaseDetail) {
totalInStorageCount += detail.getProductCount();
BigDecimal bigDecimalOfProductCount = new BigDecimal(detail.getProductCount());
BigDecimal purchasePrice = detail.getPurchasePrice();
final BigDecimal bigDecimalOfProductCount = new BigDecimal(detail.getProductCount());
final BigDecimal purchasePrice = detail.getPurchasePrice();
totalInStoragePrice = totalInStoragePrice.add(purchasePrice.multiply(bigDecimalOfProductCount));
}
final BigDecimal productContBigDe = BigDecimal.valueOf(totalInStorageCount);
BigDecimal newPurchasePrice = BigDecimal.ZERO;
// 平均采购价为 总入库金额 / 总入库数量
BigDecimal newPurchasePrice = totalInStoragePrice.divide(BigDecimal.valueOf(totalInStorageCount));
Product product = new Product();
if (productContBigDe.compareTo(BigDecimal.ZERO) > 0) {
// 不能整除,数学上是无穷小数,抛出ArithmeticException异常
// 指定计算结果的精度,保留到小数点后几位,以及舍入模式
newPurchasePrice = totalInStoragePrice.divide(productContBigDe, 4, RoundingMode.HALF_UP);
}
final Product product = new Product();
product.setId(productId);
product.setPurchasePrice(newPurchasePrice);
productList.add(product);
@ -779,6 +788,7 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
dealingsRecord.setAmount(noPay);
dealingsRecord.setDealingsType(DealingsRecordConstant.DEALINGS_TYPE[6]);
dealingsRecord.setUserType(DealingsRecordConstant.TYPE[0]);
dealingsRecord.setSaleId(id);
dealingsRecordService.save(dealingsRecord);
}
// 作废当前订单的欠款记录
@ -788,4 +798,11 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
// 2. 将订单详情设置为删除状态
purchaseDetailService.deleteByPurchaseId(id);
}
@Override
public boolean insert(Purchase purchase) {
// log.debug("保存前的入库时间==="+DateUtil.COMMON_FULL.getDateText(purchase.getCreateTime())+"===="+DateUtil.COMMON_FULL.getDateText(purchase.getPurchaseTime()));
final int insert = purchaseMapper.insert(purchase);
return insert > 0;
}
}

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

@ -954,6 +954,7 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
// 创建人
final User user = securityUtil.getCurrUser();
final DealingsRecord dealingsRecord = new DealingsRecord();
dealingsRecord.setSaleId(id);
dealingsRecord.setCreateBy(user.getId());
dealingsRecord.setCreateByName(user.getNickname());
dealingsRecord.setCreateTime(new Date());
@ -1068,6 +1069,17 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa
@Override
public void temporarySaveSale(SaleQueryDTO saleQueryDTO) {
// 先删除之前的信息
// 删除主表数据
final boolean result = saleService.deleteById(saleQueryDTO.getOldSaleId());
if (result) {
// 删除子表数据
saleDetailService.deleteBySaleId(saleQueryDTO.getOldSaleId());
// 删除退货单的信息
returnSaleService.deleteBySaleId(saleQueryDTO.getOldSaleId());
// 删除退货单的详细信息
returnDetailService.deleteBySaleId(saleQueryDTO.getOldSaleId());
}
try {
// 设置店铺id为缓存中的内容
// shopId从缓存中设置

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

@ -707,15 +707,18 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
purchase.setCreateByName(user.getNickname());
purchase.setShopId(shopId);
// 入库时间,约定前台肯定传
final Date purchaseTime = purchase.getPurchaseTime();
Date purchaseTime = purchase.getPurchaseTime();
log.debug("入库时间前台传的是==="+DateUtil.COMMON_FULL.getDateText(purchaseTime));
if(purchaseTime == null){
// 如果前台没有传入库时间,就存当前时间,这里应该不会进入
purchase.setPurchaseTime(new Date());
}else{
// 前台传的是不带时分秒的,如果是今天,那么使用当前时间,否则使用前台传的时间
log.debug("是否是同一天==="+DateUtil.COMMON_FULL.getDateText(purchaseTime)+"===="+DateUtil.COMMON_FULL.getDateText(new Date())+"====="+DateUtil.isSameDay(new Date(),purchaseTime));
if(DateUtil.isSameDay(new Date(),purchaseTime)){
purchase.setCreateTime(new Date());
purchase.setPurchaseTime(new Date());
purchaseTime = new Date();
}else{
// 因为现在对账单或者是列表排序等都是根据creTime去排序和展示的,所以这里createTime 为入库时间,前台传,PurchaseTime为入库单创建时间
purchase.setCreateTime(purchaseTime);
@ -725,9 +728,12 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
// 语音入库没有入库id
String purchaseId = purchase.getId();
boolean insertFlag = true;
if (StringUtils.isEmpty(purchaseId)){
purchaseId = SnowFlakeUtil.nextId().toString();
purchase.setId(purchaseId);
}else{
insertFlag = false;
}
// 先根据入库单id 删除详情及库存履历表信息
@ -952,6 +958,8 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
// 更新商品的批发价和零售价
product.setPrice(purchaseDetail.getPrice());
product.setWholesalePrice(purchaseDetail.getWholesalePrice());
// 更新商品的图片
product.setProductPicture(purchaseDetail.getProductPicture());
updateProductList.add(product);
// 先计算平均采购价、再更新库存数,否则会有问题。
@ -1111,13 +1119,24 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
saleDetailService.putInUpdatePurchasePrice(purchaseDetails);
//3.登记采购单主表和采购单明细表
if (purchaseService.saveOrUpdate(purchase)) {
// log.debug("保存前的入库时间==="+DateUtil.COMMON_FULL.getDateText(purchase.getCreateTime())+"===="+DateUtil.COMMON_FULL.getDateText(purchase.getPurchaseTime()));
final boolean saveOrUpdateFlag;
if(insertFlag){
saveOrUpdateFlag = purchaseService.insert(purchase);
// 不知道为什么保存不上creTime,这里再更新下两个时间
purchase.setCreateTime(purchaseTime);
purchase.setPurchaseTime(new Date());
purchaseService.updateById(purchase);
}else{
saveOrUpdateFlag = purchaseService.updateById(purchase);
}
if (saveOrUpdateFlag) {
// 保存之后将采购单的id 放到明细表中取
if (purchaseDetailService.saveBatch(purchaseDetails)) {
if (stockLogService.saveBatch(stockLogAddList)) {
// 更新商品信息
productService.saveOrUpdateBatch(updateProductList);
// 异步更新供应商欠款信息机欠款记录
// 更新供应商欠款信息机欠款记录
debtService.purchaseToDebt(purchase);
return ResultUtil.success("添加成功");
} else {

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

@ -134,6 +134,7 @@
tdr.amount,
tdr.balance_due,
tdr.dealings_type,
tdr.del_flag,
ts.total_amount,
ts.debt_deduction_amount,
ts.sale_deduction_amount,
@ -143,7 +144,7 @@
trs.return_sale_total_amount
from
t_dealings_record tdr
left join t_sale ts on ts.id = tdr.sale_id and ts.shop_id = #{customerBillQueryVo.shopId} and ts.status not in ( '2', '6', '7' )
left join t_sale ts on ts.id = tdr.sale_id and ts.shop_id = #{customerBillQueryVo.shopId} and ts.status not in ('6', '7' )
left join (
select
n.sale_id,
@ -172,9 +173,11 @@
tdr.amount,
tdr.balance_due,
tdr.dealings_type,
tdr.del_flag,
ts.should_pay,
ts.balance_deduction_amount,
ts.already_pay
ts.already_pay,
ts.create_time as purchase_time
from
t_dealings_record tdr
left join t_purchase ts on ts.id = tdr.sale_id and ts.shop_id = #{supplierBillQueryVo.shopId}

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

@ -577,8 +577,7 @@
select
<include refid="Base_Column_List" />
from t_purchase_detail
where del_flag ='0'
and purchase_id = #{id,jdbcType=VARCHAR}
where purchase_id = #{id,jdbcType=VARCHAR}
order by create_time desc
</select>

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

@ -438,11 +438,17 @@
select
<include refid="Base_Column_List"/>
from t_purchase
where del_flag = '0'
and shop_id = #{queryParams.shopId}
where shop_id = #{queryParams.shopId}
<if test="queryParams.startDate != null and queryParams.startDate != '' and queryParams.endDate != null and queryParams.endDate != ''">
and create_time BETWEEN #{queryParams.startDate} AND #{queryParams.endDate}
and purchase_time BETWEEN #{queryParams.startDate} AND #{queryParams.endDate}
</if>
<if test='queryParams.fromWhere!=null and queryParams.fromWhere.trim() neq ""'>
<if test='queryParams.fromWhere == "0"'>
and del_flag = '0'
</if>
</if>
<if test="queryParams.isAiList != null and queryParams.isAiList != ''">
<!-- 查询ai列表-->
and in_storage_status in ('2','3','4')
@ -464,7 +470,7 @@
or supplier_name like concat('%',#{queryParams.searchStr},'%')
)
</if>
order by create_time desc
order by purchase_time desc
</select>
<select id="getPurchaseListByProductId" resultMap="BaseResultMap">
select

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

@ -830,7 +830,7 @@ trans_company, company_name, product_count, remark, sale_name, company_phone, cr
left join (
select n.sale_id,sum(n.total_amount) as return_sale_total_amount ,sum(n.product_count) as return_sale_product_count from t_sale m left join t_return_sale n on m.id = n.sale_id group by n.sale_id
) trs on ts.id = trs.sale_id
left join t_dealings_record tdr ON ts.id = tdr.sale_id
left join (select sale_id,last_debt_amount from t_dealings_record where dealings_type = '0') tdr ON ts.id = tdr.sale_id
<where>
and ts.shop_id = #{saleVO.shopId}
<if test='saleVO.payStatus!=null'>
@ -880,7 +880,9 @@ trans_company, company_name, product_count, remark, sale_name, company_phone, cr
and ts.create_time BETWEEN #{saleVO.startTime} AND #{saleVO.endTime}
</if>
<if test='saleVO.searchStr!=null'>
and (ts.user_name like concat('%',#{saleVO.searchStr},'%') or ts.create_by_name like concat('%',#{saleVO.searchStr},'%'))
and (ts.user_name like concat('%',#{saleVO.searchStr},'%')
or ts.create_by_name like concat('%',#{saleVO.searchStr},'%')
or ts.id like concat('%',#{saleVO.searchStr},'%'))
</if>
</where>
order by ts.create_time desc
@ -952,10 +954,11 @@ trans_company, company_name, product_count, remark, sale_name, company_phone, cr
WHERE
t.shop_id = #{salePageQuery.shopId}
and t.del_flag != 1
AND purchase_id IN ( SELECT id FROM t_purchase WHERE del_flag = 0 and in_storage_status = 1 and supplier_id = #{salePageQuery.supplierId} )
AND purchase_id IN ( SELECT id FROM t_purchase WHERE del_flag = 0 and in_storage_status = 1 and supplier_id = #{salePageQuery.supplierId}
<if test='salePageQuery.startDate !=null and salePageQuery.endDate !=null'>
and t.create_time BETWEEN #{salePageQuery.startDate} AND #{salePageQuery.endDate}
and create_time BETWEEN #{salePageQuery.startDate} AND #{salePageQuery.endDate}
</if>
)
GROUP BY
product_id, product_name,product_sn
order by product_name desc
@ -1071,7 +1074,7 @@ GROUP BY
ts.user_id = #{customerBillQueryVo.customerId}
and ts.shop_id = #{customerBillQueryVo.shopId}
<!--订单状态不为:2:已作废;分享页提交订单:6:待配货;挂单页提交订单:7:挂单-->
and ts.status not in ( '2', '6', '7' )
and ts.status not in ('6', '7' )
<if test='customerBillQueryVo.startDate !=null and customerBillQueryVo.endDate !=null'>
and ts.create_time BETWEEN #{customerBillQueryVo.startDate} AND #{customerBillQueryVo.endDate}
</if>

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

@ -418,8 +418,7 @@
select
<include refid="Base_Column_List" />
from t_stock_log
where del_flag='0'
and order_id = #{id,jdbcType=VARCHAR}
where order_id = #{id,jdbcType=VARCHAR}
</select>
<select id="getByPurchaseIds" resultMap="BaseResultMap">

Loading…
Cancel
Save