From abad4b2840dd17124f29593ebc808dd5d900920d Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Thu, 24 Dec 2020 16:17:09 +0800
Subject: [PATCH] fix achieve for order
---
zq-erp/src/main/java/com/matrix/system/hive/service/imp/ShoppingGoodsServiceImpl.java | 25 ++++++++++++++++++++-----
1 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/ShoppingGoodsServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/ShoppingGoodsServiceImpl.java
index 1966a30..d415e72 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/ShoppingGoodsServiceImpl.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/ShoppingGoodsServiceImpl.java
@@ -99,7 +99,7 @@
shoppingGoods.setReferencePice(0D);
}
// 验证套餐卡卡必须填写最大使用次数
- if (Dictionary.FLAG_YES_Y.equals(shoppingGoods.getIsCourse())) {
+ if (Dictionary.FLAG_YES_Y.equals(shoppingGoods.getIsCourse()) && Dictionary.FLAG_NO_N.equals(shoppingGoods.getIsInfinite())) {
if (shoppingGoods.getCarUseCount() == null) {
shoppingGoods.setCarUseCount(0);
}
@@ -428,16 +428,31 @@
*
* @param shoppingGoods
* @param type 1 - 购买时 2 - 消耗时
+ * @param buyDate 购买日期, 当计算消耗日期时,不能为空
* @return
*/
@Override
- public Date calInvalidTime(ShoppingGoods shoppingGoods, @NotNull Integer type) {
+ public Date calInvalidTime(ShoppingGoods shoppingGoods, @NotNull Integer type, Date buyDate) {
if (StringUtils.isBlank(shoppingGoods.getBuyValid()) && StringUtils.isBlank(shoppingGoods.getUseValid()) && shoppingGoods.getInvalidTime() == null) {
- return null;
+ return DateUtil.stringToDate("9999-12-31", DateUtil.DATE_FORMAT_DD);
}
+
+ if (type == 2 && buyDate == null) {
+ throw new GlobleException("购买日期不能为空");
+ }
+
Date target = null;
- Date buyValidDate = DateUtil.calDate(shoppingGoods.getBuyDateNum(), shoppingGoods.getBuyDateUnit());
- Date useValidDate = DateUtil.calDate(shoppingGoods.getUseDateNum(), shoppingGoods.getUseDateUnit());
+ Date buyValidDate = null;
+ if (type == 1) {
+ buyValidDate = DateUtil.calDate(shoppingGoods.getBuyDateNum(), shoppingGoods.getBuyDateUnit());
+ } else {
+ buyValidDate = buyDate;
+ }
+
+ Date useValidDate = DateUtil.stringToDate("9999-12-31", DateUtil.DATE_FORMAT_DD);
+ if (type == 2) {
+ useValidDate = DateUtil.calDate(shoppingGoods.getUseDateNum(), shoppingGoods.getUseDateUnit());
+ }
if (buyValidDate.after(useValidDate)) {
target = useValidDate;
--
Gitblit v1.9.1