From 5da027c19bdffc50b2e9c02ab3ebb959b92ee5ef Mon Sep 17 00:00:00 2001
From: wangfukang <15630117759@163.com>
Date: Fri, 2 Aug 2024 09:30:36 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AE=B8=E5=A4=9A=E5=AE=B6=E9=9C=80=E6=B1=82?=
=?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=8CBUG=E4=BF=AE=E6=94=B9=EF=BC=8C?=
=?UTF-8?q?=E7=AD=89=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/main/resources/application.yml | 8 +--
hiver-admin/test-output/test-report.html | 16 ++---
.../controller/manage/AuthController.java | 8 ++-
.../mall/bill/vo/CustomerBillSaleVo.java | 3 +
.../mall/bill/vo/SupplierBillPurchaseVo.java | 6 ++
.../mall/controller/CustomerController.java | 13 ++--
.../mall/controller/SupplierControlller.java | 1 +
.../java/cc/hiver/mall/entity/Purchase.java | 59 +++++++++++++--
.../mall/pojo/query/PurchasePageQuery.java | 3 +
.../java/cc/hiver/mall/pojo/vo/SaleVO.java | 3 +
.../hiver/mall/service/SupplierService.java | 2 +
.../mall/service/mybatis/CustomerService.java | 2 +-
.../mall/service/mybatis/PurchaseService.java | 1 +
.../mall/serviceimpl/SupplierServiceImpl.java | 49 +++++++++++++
.../mybatis/CustomerServiceImpl.java | 8 +--
.../mybatis/ProductServiceImpl.java | 34 ++++-----
.../mybatis/PurchaseServiceImpl.java | 71 ++++++++++++-------
.../serviceimpl/mybatis/SaleServiceImpl.java | 12 ++++
.../serviceimpl/mybatis/StockServiceImpl.java | 25 ++++++-
.../resources/mapper/DealingsRecordMapper.xml | 7 +-
.../resources/mapper/PurchaseDetailMapper.xml | 3 +-
.../main/resources/mapper/PurchaseMapper.xml | 18 +++--
.../src/main/resources/mapper/SaleMapper.xml | 17 +++--
.../main/resources/mapper/StockLogMapper.xml | 3 +-
24 files changed, 273 insertions(+), 99 deletions(-)
diff --git a/hiver-admin/src/main/resources/application.yml b/hiver-admin/src/main/resources/application.yml
index b423c524..dde87d6f 100644
--- a/hiver-admin/src/main/resources/application.yml
+++ b/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
diff --git a/hiver-admin/test-output/test-report.html b/hiver-admin/test-output/test-report.html
index 528db096..e157bf0b 100644
--- a/hiver-admin/test-output/test-report.html
+++ b/hiver-admin/test-output/test-report.html
@@ -35,7 +35,7 @@
Hiver
- 25, 2024 22:04:43
+ 01, 2024 22:09:58
@@ -84,7 +84,7 @@
passTest
-
22:04:43 / 0.016 secs
+
22:09:59 / 0.019 secs
@@ -92,9 +92,9 @@
#test-id=1
passTest
-
07.25.2024 22:04:43
-
07.25.2024 22:04:43
-
0.016 secs
+
08.01.2024 22:09:59
+
08.01.2024 22:09:59
+
0.019 secs
@@ -104,7 +104,7 @@
| Pass |
- 22:04:43 |
+ 22:09:59 |
Test passed
|
@@ -128,13 +128,13 @@
Started
-
25, 2024 22:04:43
+
01, 2024 22:09:58
Ended
-
25, 2024 22:04:43
+
01, 2024 22:09:59
diff --git a/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/AuthController.java b/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/AuthController.java
index 31ecdd0f..209b9c3b 100644
--- a/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/AuthController.java
+++ b/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());
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/CustomerBillSaleVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/CustomerBillSaleVo.java
index d9d33431..88edf545 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/CustomerBillSaleVo.java
+++ b/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
billSaleDetailVos;
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillPurchaseVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillPurchaseVo.java
index e316ba4d..1aadba49 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillPurchaseVo.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillPurchaseVo.java
@@ -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 billSaleDetailVos;
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java
index 413a9555..deb3f9fa 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java
+++ b/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().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())){
// 如果维护了客户的手机号,那么就新增用户登录信息
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SupplierControlller.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SupplierControlller.java
index ba3873a2..f225a49a 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SupplierControlller.java
+++ b/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);
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Purchase.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Purchase.java
index c0be507b..938d30e5 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Purchase.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Purchase.java
@@ -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;
@@ -85,13 +130,13 @@ public class Purchase extends HiverBaseEntity {
}
public void setStartDate(String startDate) {
- if(!StrUtil.isNotEmpty(startDate)){
+ if (!StrUtil.isNotEmpty(startDate)) {
this.startDate = null;
return;
}
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
try {
- this.startDate = formatter.parse(startDate+" 00:00:00");
+ this.startDate = formatter.parse(startDate + " 00:00:00");
} catch (Exception e) {
e.printStackTrace();
}
@@ -102,7 +147,7 @@ public class Purchase extends HiverBaseEntity {
}
public void setEndDate(String endDate) {
- if(!StrUtil.isNotEmpty(endDate)){
+ if (!StrUtil.isNotEmpty(endDate)) {
this.endDate = null;
return;
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/PurchasePageQuery.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/PurchasePageQuery.java
index da682a19..87db7f66 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/PurchasePageQuery.java
+++ b/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;
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SaleVO.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SaleVO.java
index 995ebb8d..49e9a095 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SaleVO.java
+++ b/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;
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/SupplierService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/SupplierService.java
index ead1077e..c9716dcc 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/SupplierService.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/SupplierService.java
@@ -13,4 +13,6 @@ public interface SupplierService extends HiverBaseService {
List getbyShopId(String shopId,String searchStr);
void delById(String id);
+
+ void addSupplier(Supplier supplier);
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/CustomerService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/CustomerService.java
index bf8b3aaf..64e24c26 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/CustomerService.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/CustomerService.java
@@ -15,7 +15,7 @@ public interface CustomerService extends IService {
List findByUserId(String userId);
- boolean addCustomer(Customer customer);
+ Customer addCustomer(Customer customer);
Page getCustomerList(CustomerPageQuery customerPageQuery);
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java
index 62cad720..b4d80bc6 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java
@@ -78,4 +78,5 @@ public interface PurchaseService extends IService {
*/
void cancelPurchase(String id);
+ boolean insert(Purchase purchase);
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SupplierServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SupplierServiceImpl.java
index 7b5dfede..5d1494ae 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SupplierServiceImpl.java
+++ b/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 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);
+ }
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java
index 751a748d..f1369481 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java
@@ -82,8 +82,7 @@ public class CustomerServiceImpl extends ServiceImpl 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 i
dealingsRecord.setAmount(amountOwed);
dealingsRecord.setDealingsType(DealingsRecordConstant.DEALINGS_TYPE[3]);
dealingsRecordService.save(dealingsRecord);
- if (insert > 0) {
- result = true;
- }
- return result;
+ return customer;
}
@Override
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java
index 60cff8e7..2987612c 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java
@@ -49,26 +49,28 @@ public class ProductServiceImpl extends ServiceImpl impl
final Page page = new Page<>(productPageQuery.getPageNum(), productPageQuery.getPageSize());
final List list = baseMapper.getShareList(page, productPageQuery);
// 获取商品子图
- List productIdList = new ArrayList<>();
+ final List productIdList = new ArrayList<>();
for (ProductPageVO productPageVO : list) {
productIdList.add(productPageVO.getId());
}
- // 获取子图
- List productPictureByProductIds = productPictureService.getProductPictureByProductIds(productIdList);
- Map> productPictureMap = new HashMap<>();
- for (ProductPicture productPictureByProductId : productPictureByProductIds) {
- if (productPictureMap.containsKey(productPictureByProductId.getProductId())) {
- productPictureMap.get(productPictureByProductId.getProductId()).add(productPictureByProductId);
- } else {
- final List productPictureList = new ArrayList<>();
- productPictureList.add(productPictureByProductId);
- productPictureMap.put(productPictureByProductId.getProductId(), productPictureList);
+ if(!productIdList.isEmpty()){
+ // 获取子图
+ final List productPictureByProductIds = productPictureService.getProductPictureByProductIds(productIdList);
+ final Map> productPictureMap = new HashMap<>();
+ for (ProductPicture productPictureByProductId : productPictureByProductIds) {
+ if (productPictureMap.containsKey(productPictureByProductId.getProductId())) {
+ productPictureMap.get(productPictureByProductId.getProductId()).add(productPictureByProductId);
+ } else {
+ final List productPictureList = new ArrayList<>();
+ productPictureList.add(productPictureByProductId);
+ productPictureMap.put(productPictureByProductId.getProductId(), productPictureList);
+ }
}
- }
- for (ProductPageVO productPageVO : list) {
- String productId = productPageVO.getId();
- if (productPictureMap.containsKey(productId)) {
- productPageVO.setProductPictures(productPictureMap.get(productId));
+ for (ProductPageVO productPageVO : list) {
+ final String productId = productPageVO.getId();
+ if (productPictureMap.containsKey(productId)) {
+ productPageVO.setProductPictures(productPictureMap.get(productId));
+ }
}
}
page.setRecords(list);
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java
index 832ee079..1c615b2e 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java
@@ -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,21 +163,23 @@ public class PurchaseServiceImpl extends ServiceImpl i
purchaseDetail.setStockLogList1(stockLogMap.get(productId));
productIdList.add(productId);
}
- // 20240602 将商品的采购价、零售价、批发价回填回来
- // 获取商品
- final List productList = productService.getProductList(productIdList);
- // 将商品封装为map,key为商品id,value为商品信息
- final Map productMap = productList.stream().collect(Collectors.toMap(Product::getId, product -> product));
- for (PurchaseDetail purchaseDetail : purchaseDetails) {
- final String productId = purchaseDetail.getProductId();
- if (productMap.containsKey(productId)) {
- final Product product = productMap.get(productId);
- purchaseDetail.setPrice(product.getPrice());
- purchaseDetail.setWholesalePrice(product.getWholesalePrice());
- purchaseDetail.setPurchasePrice(product.getPurchasePrice());
+ if(!productIdList.isEmpty()){
+ // 20240602 将商品的采购价、零售价、批发价回填回来
+ // 获取商品
+ final List productList = productService.getProductList(productIdList);
+ // 将商品封装为map,key为商品id,value为商品信息
+ final Map productMap = productList.stream().collect(Collectors.toMap(Product::getId, product -> product));
+ for (PurchaseDetail purchaseDetail : purchaseDetails) {
+ final String productId = purchaseDetail.getProductId();
+ if (productMap.containsKey(productId)) {
+ final Product product = productMap.get(productId);
+ purchaseDetail.setPrice(product.getPrice());
+ purchaseDetail.setWholesalePrice(product.getWholesalePrice());
+ purchaseDetail.setPurchasePrice(product.getPurchasePrice());
+ }
}
+ purchaseVo.setPurchaseDetails(purchaseDetails);
}
- purchaseVo.setPurchaseDetails(purchaseDetails);
// 获取该入库单的欠款更新记录
purchaseVo.setDealingsRecords(dealingsRecordService.getDealingsRecordList(id));
@@ -637,8 +640,8 @@ public class PurchaseServiceImpl extends ServiceImpl i
public void cancelPurchase(String id) {
// 获取采购单信息
- Purchase purchase = purchaseService.getById(id);
- List purchaseIdList = new ArrayList<>();
+ final Purchase purchase = purchaseService.getById(id);
+ final List purchaseIdList = new ArrayList<>();
purchaseIdList.add(id);
// 3. 商品及库存回退
// 查询商品是有有销售记录并且是不是有且只有这一次入库记录,是的话,直接删除商品及其库存信息,其他的只回退库存即可
@@ -689,22 +692,22 @@ public class PurchaseServiceImpl extends ServiceImpl i
needDeleteProductId.add(productId);
// 库存删除
needDeleteStockProductId.add(productId);
- }else{
+ } else {
// 商品保留,库存扣减
needReduceStockProductId.add(productId);
}
}
// 执行删除商品
- if(StringUtils.isNotEmpty(needDeleteProductId.toString())){
+ if (StringUtils.isNotEmpty(needDeleteProductId.toString())) {
productService.batchDeleteProduct(needDeleteProductId.toString());
}
// 执行删除库存
- if(StringUtils.isNotEmpty(needReduceStockProductId.toString())){
+ if (StringUtils.isNotEmpty(needReduceStockProductId.toString())) {
stockService.batchDeleteStockByProductIds(needDeleteStockProductId.toString());
}
// 执行扣减库存
- if(StringUtils.isNotEmpty(needReduceStockProductId.toString())){
+ if (StringUtils.isNotEmpty(needReduceStockProductId.toString())) {
// 获取当前入库单各商品的规格及数量信息
final List stockLogList = stockLogService.getByProductIds(id, needReduceStockProductId.toString());
// 根据入库记录减掉库存数
@@ -714,12 +717,12 @@ public class PurchaseServiceImpl extends ServiceImpl i
stockLogService.deleteByPurchaseId(id);
// 5. 计算平均采购价
// 获取该商品的历次入库记录,排除掉本次入库记录 入库的价格*入库数量/入库总数量
- Map productPurchasePriceMap = new HashMap<>();
+ final Map productPurchasePriceMap = new HashMap<>();
- List productList = new ArrayList<>();
+ final List productList = new ArrayList<>();
for (Map.Entry> stringListEntry : purductPurchaseMap.entrySet()) {
final String productId = stringListEntry.getKey();
- List purchaseDetail = stringListEntry.getValue();
+ final List purchaseDetail = stringListEntry.getValue();
// 计算该商品的平均采购价 = (当前入库价格*当前入库数量 + 历史入库价格*历史入库数量)/(当前入库数量+历史入库数量)
// 总入库数量
int totalInStorageCount = 0;
@@ -727,20 +730,26 @@ public class PurchaseServiceImpl extends ServiceImpl 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);
}
// 执行更新平均采购价
- if(!productList.isEmpty()){
+ if (!productList.isEmpty()) {
productService.batchUpdatePurchasePrice(productList);
}
// 6. 欠款回退
@@ -779,6 +788,7 @@ public class PurchaseServiceImpl extends ServiceImpl 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 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;
+ }
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java
index b30096d8..7fda31de 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleServiceImpl.java
@@ -954,6 +954,7 @@ public class SaleServiceImpl extends ServiceImpl 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 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从缓存中设置
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java
index 1af0fa5d..0dd583f7 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java
@@ -707,15 +707,18 @@ public class StockServiceImpl extends ServiceImpl 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 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 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 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 {
diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/DealingsRecordMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/DealingsRecordMapper.xml
index d6ad51ee..8d9085ba 100644
--- a/hiver-modules/hiver-mall/src/main/resources/mapper/DealingsRecordMapper.xml
+++ b/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}
diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml
index ab83258c..d4119787 100644
--- a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml
+++ b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseDetailMapper.xml
@@ -577,8 +577,7 @@
select
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
diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml
index 16f143c8..e923e16d 100644
--- a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml
+++ b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml
@@ -438,14 +438,20 @@
select
from t_purchase
- where del_flag = '0'
- and shop_id = #{queryParams.shopId}
+ where shop_id = #{queryParams.shopId}
- and create_time BETWEEN #{queryParams.startDate} AND #{queryParams.endDate}
+ and purchase_time BETWEEN #{queryParams.startDate} AND #{queryParams.endDate}
+
+
+ and del_flag = '0'
+
+
+
+
-
- and in_storage_status in ('2','3','4')
+
+ and in_storage_status in ('2','3','4')
@@ -464,7 +470,7 @@
or supplier_name like concat('%',#{queryParams.searchStr},'%')
)
- order by create_time desc
+ order by purchase_time desc