xiaoyong931011
2023-03-17 1386a8657ec42cd3baf6bde8b1506f52c910f0e1
zq-erp/src/main/java/com/matrix/system/hive/service/imp/ShoppingGoodsServiceImpl.java
@@ -1,6 +1,7 @@
package com.matrix.system.hive.service.imp;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.exception.GlobleException;
import com.matrix.core.pojo.PaginationVO;
@@ -455,31 +456,41 @@
            return DateUtil.stringToDate("2099-12-31", DateUtil.DATE_FORMAT_DD);
        }
        if (type == 2 && buyDate == null) {
            throw new GlobleException("购买日期不能为空");
        }
//        if (type == 2 && buyDate == null) {
//            throw new GlobleException("购买日期不能为空");
//        }
        Date target = null;
        Date buyValidDate = null;
        Date buyValidDate = DateUtil.stringToDate("2099-12-31", DateUtil.DATE_FORMAT_DD);;
        if (type == 1) {
            buyValidDate = DateUtil.calDate(shoppingGoods.getBuyDateNum(), shoppingGoods.getBuyDateUnit());
            if (shoppingGoods.getBuyDateNum() != null && StrUtil.isNotBlank(shoppingGoods.getBuyDateUnit())) {
                buyValidDate = DateUtil.calDate(shoppingGoods.getBuyDateNum(), shoppingGoods.getBuyDateUnit());
            }
        } else {
            buyValidDate = buyDate;
        }
        Date useValidDate = DateUtil.stringToDate("2099-12-31", DateUtil.DATE_FORMAT_DD);
        if (type == 2) {
            useValidDate = DateUtil.calDate(shoppingGoods.getUseDateNum(), shoppingGoods.getUseDateUnit());
            if (shoppingGoods.getUseDateNum() != null && StrUtil.isNotBlank(shoppingGoods.getUseDateUnit())) {
                useValidDate = DateUtil.calDate(shoppingGoods.getUseDateNum(), shoppingGoods.getUseDateUnit());
            }
        }
        if (buyValidDate.after(useValidDate)) {
            target = useValidDate;
        } else {
            target = buyValidDate;
        if (buyValidDate != null) {
            if (buyValidDate.after(useValidDate)) {
                target = useValidDate;
            } else {
                target = buyValidDate;
            }
        }
        if (shoppingGoods.getInvalidTime() != null) {
            if (target.after(shoppingGoods.getInvalidTime())) {
            if (target != null) {
                if (target.after(shoppingGoods.getInvalidTime())) {
                    target = shoppingGoods.getInvalidTime();
                }
            } else {
                target = shoppingGoods.getInvalidTime();
            }
        }