| | |
| | | import com.matrix.core.constance.MatrixConstance; |
| | | import com.matrix.core.exception.GlobleException; |
| | | import com.matrix.core.pojo.PaginationVO; |
| | | import com.matrix.core.tools.DateUtil; |
| | | import com.matrix.core.tools.StringUtils; |
| | | import com.matrix.core.tools.WebUtil; |
| | | import com.matrix.system.common.bean.SysUsers; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.awt.event.WindowStateListener; |
| | | import java.time.LocalDate; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | |
| | | shoppingGoods.setCreateTime(new Date()); |
| | | setPublicAttr(shoppingGoods); |
| | | |
| | | setShoppingGoodsInvalidTime(shoppingGoods); |
| | | |
| | | if (shoppingGoods.getReferencePice() == null) { |
| | | //赠送金额 |
| | | shoppingGoods.setReferencePice(0D); |
| | |
| | | |
| | | |
| | | return i; |
| | | } |
| | | |
| | | private void setShoppingGoodsInvalidTime(ShoppingGoods shoppingGoods) { |
| | | // 若未设置购买有效期和消耗有效期,则默认永久有效 |
| | | // if (shoppingGoods.getBuyDateNum() == null && shoppingGoods.getUseDateNum() == null) { |
| | | // shoppingGoods.setInvalidTime(DateUtil.stringToDate("9999-12-31", DateUtil.DATE_FORMAT_DD)); |
| | | // } else { |
| | | // // 计算失效日期,判断购买有效期和消耗有效期哪个先失效,则为失效日期 |
| | | // Date buyValidDate = DateUtil.calDate(shoppingGoods.getBuyDateNum(), shoppingGoods.getBuyDateUnit()); |
| | | // Date useValidDate = DateUtil.calDate(shoppingGoods.getUseDateNum(), shoppingGoods.getUseDateUnit()); |
| | | // if (buyValidDate.after(useValidDate)) { |
| | | // shoppingGoods.setInvalidTime(useValidDate); |
| | | // } else { |
| | | // shoppingGoods.setInvalidTime(buyValidDate); |
| | | // } |
| | | // shoppingGoods.setBuyValid(shoppingGoods.getBuyDateNum() + shoppingGoods.getBuyDateUnit()); |
| | | // shoppingGoods.setUseValid(shoppingGoods.getUseDateNum() + shoppingGoods.getUseDateUnit()); |
| | | // } |
| | | |
| | | if (shoppingGoods.getBuyDateNum() != null && StringUtils.isNotBlank(shoppingGoods.getBuyDateUnit())) { |
| | | shoppingGoods.setBuyValid(shoppingGoods.getBuyDateNum() + shoppingGoods.getBuyDateUnit()); |
| | | } else { |
| | | shoppingGoods.setBuyValid(null); |
| | | } |
| | | |
| | | if (shoppingGoods.getUseDateNum() != null && StringUtils.isNotBlank(shoppingGoods.getUseDateUnit())) { |
| | | shoppingGoods.setUseValid(shoppingGoods.getUseDateNum() + shoppingGoods.getUseDateUnit()); |
| | | } else { |
| | | shoppingGoods.setUseValid(null); |
| | | } |
| | | } |
| | | |
| | | private void setGoodsAssembles(ShoppingGoods shoppingGoods) { |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | setShoppingGoodsInvalidTime(shoppingGoods); |
| | | |
| | | return shoppingGoodsDao.update(shoppingGoods); |
| | | |