modify add order and servier order invalid time
| | |
| | | |
| | | import com.matrix.core.pojo.PaginationVO; |
| | | import com.matrix.system.hive.bean.SysBeauticianState; |
| | | import com.matrix.system.hive.bean.SysProjUse; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.Date; |
| | |
| | | |
| | | public int summaryItemDetailTotal(Map<String,Object> obj); |
| | | |
| | | List<SysBeauticianState> selectByProjUse(@Param("list") List<SysProjUse> list, @Param("state") String state); |
| | | |
| | | List<SysBeauticianState> selectBeauticianStateByPuseIdAndNoStatus(@Param("puseId") Long puseId, @Param("state") String state); |
| | | |
| | | } |
| | |
| | | |
| | | public ShoppingGoods findByCode(String goodsCode); |
| | | |
| | | Date calInvalidTime(ShoppingGoods shoppingGoods, Integer type); |
| | | Date calInvalidTime(ShoppingGoods shoppingGoods, Integer type, Date buyDate); |
| | | } |
| | |
| | | * |
| | | * @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; |
| | | } |
| | | |
| | | 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; |
| | |
| | | import com.matrix.system.hive.pojo.ShoppingCarItemsVo; |
| | | import com.matrix.system.hive.service.AchieveNewService; |
| | | import com.matrix.system.hive.service.CodeService; |
| | | import com.matrix.system.hive.service.ShoppingGoodsService; |
| | | import com.matrix.system.hive.service.SysOrderService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | @Autowired |
| | | private WarehouseDao warehouseDao; |
| | | |
| | | @Autowired |
| | | private ShoppingGoodsService shoppingGoodsService; |
| | | |
| | | @Override |
| | | public int add(SysOrder sysOrder) { |
| | |
| | | } else { |
| | | taocanProjUse.setSource(Dictionary.TAOCAN_SOURCE_ZS); |
| | | } |
| | | // TODO 设置失效时间 |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.set(2200, 1, 1); |
| | | taocanProjUse.setFailTime(cal.getTime()); |
| | | // 失效时间 |
| | | Date invalidTime = shoppingGoodsService.calInvalidTime(taocanShoppingGoods, 1, null); |
| | | taocanProjUse.setFailTime(invalidTime); |
| | | sysProjUseDao.insert(taocanProjUse); |
| | | //计划次数 |
| | | int surplusCount=0; |
| | |
| | | puse.setSource(Dictionary.TAOCAN_SOURCE_ZS); |
| | | } |
| | | // 设置失效时间 |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.set(2300, 1, 1); |
| | | puse.setFailTime(cal.getTime()); |
| | | Date invalidTime = shoppingGoodsService.calInvalidTime(sysOrderItem.getShoppingGoods(), 1, null); |
| | | puse.setFailTime(invalidTime); |
| | | sysProjUseDao.insert(puse); |
| | | } |
| | | |
| | |
| | | private SysOrderService sysOrderService; |
| | | @Autowired |
| | | WarehouseDao warehouseDao; |
| | | @Resource |
| | | private ShoppingGoodsService shoppingGoodsService; |
| | | |
| | | /** |
| | | * 新增服务单 jyy |
| | |
| | | sysProjServices.setServiceNo(codeService.getServiceOrderCode()); |
| | | Double hkPrice = 0.0; |
| | | int i = sysProjServicesDao.insert(sysProjServices); |
| | | |
| | | // 计算项目总时长 |
| | | int totalTime = 0; |
| | | //处理订单明细 |
| | |
| | | //本次消费金额 |
| | | Double bcxfje = MoneyUtil.mul(sysProjUse.getPrice(), Double.valueOf(sysBeauticianState.getCount())); |
| | | upProjUse.setBalance(MoneyUtil.sub(sysProjUse.getBalance(), bcxfje)); |
| | | |
| | | // 判断是否第一次使用该项目, 若是则根据商品消耗有效期更新到期时间 |
| | | List<SysBeauticianState> sysBeauticianStates = beauticianStateDao.selectBeauticianStateByPuseIdAndNoStatus(sysBeauticianState.getPuseId(), Dictionary.SERVICE_STATU_YYQX); |
| | | if (CollectionUtils.isEmpty(sysBeauticianStates)) { |
| | | Date useInvalidTime = shoppingGoodsService.calInvalidTime(sysProjInfo, 2, sysProjUse.getFailTime()); |
| | | upProjUse.setFailTime(useInvalidTime); |
| | | } |
| | | |
| | | //更新余次信息 |
| | | sysProjUseDao.updateSurplusCount(upProjUse); |
| | | //如果项目是套餐 中项目则判断套餐是否失效 |
| | |
| | | taocan.setSurplusCount(tcSurplusCount); |
| | | } |
| | | } |
| | | |
| | | // 根据套餐内所有项目查询该套餐是否第一次使用,若第一次使用则更新该套餐有效期 |
| | | List<SysBeauticianState> taocanHas = beauticianStateDao.selectByProjUse(taocanProjUses, Dictionary.SERVICE_STATU_YYQX); |
| | | if (CollectionUtils.isEmpty(taocanHas)) { |
| | | Date useInvalidTime = shoppingGoodsService.calInvalidTime(sysProjInfo, 2, sysProjUse.getFailTime()); |
| | | taocan.setFailTime(useInvalidTime); |
| | | } |
| | | sysProjUseDao.updateSurplusCount(taocan); |
| | | } |
| | | |
| | |
| | | SERVICES_ID, |
| | | EXC_TIME, |
| | | extract, |
| | | a.puse_id, |
| | | a.count, |
| | | a.proj_id |
| | | puse_id, |
| | | count, |
| | | proj_id |
| | | </sql> |
| | | <sql id="from"> |
| | | from sys_beautician_state |
| | |
| | | group by c.id,f.id) t |
| | | </select> |
| | | |
| | | <select id="selectByProjUse" resultMap="SysBeauticianStateMap"> |
| | | select * from sys_beautician_state |
| | | where state!=#{state} puse_id in |
| | | <foreach collection="list" index="index" item="item" open="(" |
| | | separator="," close=")"> |
| | | #{item.id} |
| | | </foreach> |
| | | </select> |
| | | |
| | | <select id="selectBeauticianStateByPuseIdAndNoStatus" resultMap="SysBeauticianStateMap"> |
| | | select * from sys_beautician_state |
| | | where puse_id=#{puseId} ans state!=#{state} |
| | | </select> |
| | | </mapper> |
| | |
| | | <if test="deductionNum != null "> |
| | | deductionNum = #{deductionNum}, |
| | | </if> |
| | | <if test="failTime != null "> |
| | | fail_time = #{failTime}, |
| | | </if> |
| | | |
| | | </set> |
| | | WHERE ID = #{id} |