浏览代码

添加会员商品折扣,修改房费超时收费接口

许智捷 2 年之前
父节点
当前提交
5f568f827e

+ 13 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/BusMemberCardController.java

@@ -308,6 +308,19 @@ public class BusMemberCardController extends JeecgController<BusMemberCard, IBus
 		return Result.OK(busMemberCard);
 	}
 
+	/**
+	 * 通过id查询
+	 *
+	 * @param id
+	 * @return
+	 */
+	//@AutoLog(value = "bus_member_card-通过id查询")
+	@ApiOperation(value="通过会员id找到会员卡等级", notes="bus_member_card-通过id查询")
+	@GetMapping(value = "/getMarkerMemberByCarId")
+	public Result<BusMarketMember> getMarkerMemberByCarId(@RequestParam(name="id",required=true) String id) {
+		return Result.OK(busMemberCardService.getMarkerMemberByCarId(id));
+	}
+
     /**
     * 导出excel
     *

+ 4 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/entity/BusMarketMember.java

@@ -54,6 +54,10 @@ public class BusMarketMember implements Serializable {
 	@Excel(name = "会员折扣值", width = 15)
     @ApiModelProperty(value = "会员折扣值")
     private BigDecimal discount;
+    /**会员折扣值*/
+	@Excel(name = "会员折扣值", width = 15)
+    @ApiModelProperty(value = "会员折扣值")
+    private BigDecimal goodsDiscount;
 	/**关联房价方案*/
 	@Excel(name = "关联房价方案", width = 15)
     @ApiModelProperty(value = "关联房价方案")

+ 3 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/IBusMemberCardService.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.business.service;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.business.dto.UserGroupDto;
 import org.jeecg.modules.business.dto.UserLabelDto;
+import org.jeecg.modules.business.entity.BusMarketMember;
 import org.jeecg.modules.business.entity.BusMemberBalanceLog;
 import org.jeecg.modules.business.entity.BusMemberCard;
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -46,4 +47,6 @@ public interface IBusMemberCardService extends IService<BusMemberCard> {
      * @return
      */
     public BusMemberBalanceLog cardPayFee(BusMemberCard busMemberCard, BigDecimal money, String feeId, String hotelId);
+
+    BusMarketMember getMarkerMemberByCarId(String id);
 }

+ 17 - 2
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/BusMemberCardServiceImpl.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.business.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import org.apache.commons.lang3.ObjectUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.exception.JeecgBootException;
@@ -11,6 +12,7 @@ import org.jeecg.modules.business.dto.UserGroupDto;
 import org.jeecg.modules.business.dto.UserLabelDto;
 import org.jeecg.modules.business.entity.*;
 import org.jeecg.modules.business.mapper.*;
+import org.jeecg.modules.business.service.IBusMarketMemberService;
 import org.jeecg.modules.business.service.IBusMemberCardService;
 import org.jeecg.modules.business.vo.MemberCardStatVo;
 import org.springframework.stereotype.Service;
@@ -34,8 +36,9 @@ public class BusMemberCardServiceImpl extends ServiceImpl<BusMemberCardMapper, B
     private BusMarketMemberGroupMapper busMarketMemberGroupMapper;
     @Resource
     private BusMarketMemberLableMapper busMarketMemberLableMapper;
+
     @Resource
-    private BusMemberCardMapper busMemberCardMapper;
+    private IBusMarketMemberService marketMemberService;
     /**
      * 设置用户分组
      * @param dto
@@ -85,7 +88,7 @@ public class BusMemberCardServiceImpl extends ServiceImpl<BusMemberCardMapper, B
      * @return
      */
     public MemberCardStatVo stat(String hotelId) {
-        return busMemberCardMapper.stat(hotelId);
+        return baseMapper.stat(hotelId);
     }
 
     /**
@@ -123,4 +126,16 @@ public class BusMemberCardServiceImpl extends ServiceImpl<BusMemberCardMapper, B
         return balanceLog;
     }
 
+    @Override
+    public BusMarketMember getMarkerMemberByCarId(String id) {
+        BusMemberCard memberCard = getById(id);
+        if (memberCard == null){
+            throw new JeecgBootException("未找到会员");
+        }
+        BusMarketMember marketMember = marketMemberService.getById(memberCard.getGradeId());
+        if (marketMember == null){
+            throw new JeecgBootException("未找到会员等级");
+        }
+        return marketMember;
+    }
 }

+ 69 - 21
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/BusRoomBookingOrdersServiceImpl.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.business.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateTime;
 import cn.hutool.core.lang.Snowflake;
 import cn.hutool.core.util.BooleanUtil;
 import cn.hutool.core.util.ObjectUtil;
@@ -15,6 +16,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
+import org.checkerframework.checker.units.qual.C;
 import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
@@ -1152,6 +1154,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         return livingOrder.getId();
     }
 
+    /**
+     * 首次超时收费时间
+     */
     public Calendar getRemindTime(BusRoomsLivingOrder livingOrder, CesAllDayPriceRule cesAllDayPriceRule, Integer BookingType){
         Calendar calendar = Calendar.getInstance();
         if (ObjectUtil.equals(BookingType, 1)) {
@@ -1590,6 +1595,10 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             if (ObjectUtil.isEmpty(roomBookingOrder)){
                 return;
             }
+            List<CesRooms> cesRooms = roomsService.list(Wrappers.<CesRooms>lambdaQuery().eq(CesRooms::getLivingOrderId, e.getId()));
+            if (CollUtil.isNotEmpty(cesRooms)){
+                System.out.println(cesRooms.get(0).getName());
+            }
             // 全天房
             if (ObjectUtil.equals(1,roomBookingOrder.getBookingType())){
                 // 如果房间超时是按分钟加收费用
@@ -1617,6 +1626,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
     public void addByMinute(BusRoomsLivingOrder livingOrder, CesAllDayPriceRule cesAllDayPriceRule){
         Date date = new Date();
         Calendar nextCalendar = Calendar.getInstance();
+        Calendar nowCalendar = Calendar.getInstance();
         nextCalendar.setTime(date);
         BusBookingRooms bookingroom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
         if (ObjectUtil.isEmpty(bookingroom)){
@@ -1628,37 +1638,65 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         // 需要支付完整费用时间的最后时间
         Date endTime = getFullFeeTime(date, cesAllDayPriceRule);
         // 当前时间加上超时收费时间
-        nextCalendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
+//        nextCalendar.add(Calendar.MINUTE, cesAllDayPriceRule.getMinute());
+        // 获取今日第一次超时时间
+        nextCalendar = getRemindTime(livingOrder, cesAllDayPriceRule, 1);
+        nextCalendar.set(Calendar.YEAR, nowCalendar.get(Calendar.YEAR));
+        nextCalendar.set(Calendar.MONTH, nowCalendar.get(Calendar.MONTH));
+        nextCalendar.set(Calendar.DATE, nowCalendar.get(Calendar.DATE));
+        // 今日超时分钟
+        Integer overMinutes = Math.round((nowCalendar.getTimeInMillis() - nextCalendar.getTimeInMillis()) / (1000 * 60 ));
+        if (overMinutes < 0){
+            return;
+        }
+        //已经超时的 不足时间
+        Integer minutesDiff = overMinutes % cesAllDayPriceRule.getMinute();
+        // 超出 超时时间 的数量
+        Integer minutesDiffNum = (int) Math.floor(overMinutes / cesAllDayPriceRule.getMinute());
+
+        Integer moreThenMinuteDiffNum = (int) Math.floor(minutesDiff / cesAllDayPriceRule.getMoreThenMinute());
+        // 加上下一次不足时间 >= 超出时间,用超出时间
+        if (minutesDiff + cesAllDayPriceRule.getMoreThenMinute() > cesAllDayPriceRule.getMinute()){
+            Integer newOverTime = cesAllDayPriceRule.getMinute() * (minutesDiffNum + 1);
+            nextCalendar.add(Calendar.MINUTE, newOverTime);
+        }else {
+            nextCalendar.add(Calendar.MINUTE, cesAllDayPriceRule.getMoreThenMinute());
+        }
+
+        log.info("{}今日超时分钟{},超时时间数量{},不足时间数量{}",livingOrder.getId(),overMinutes,minutesDiffNum,moreThenMinuteDiffNum);
+
         // 当前时间加上超时收费时间 < 按全天收费时间的标准
         if (nextCalendar.getTime().compareTo(endTime) < 0){
             // 不满足的情况下,添加超时收费,设置下一次收费时间戳
+            BigDecimal money = cesAllDayPriceRule.getPrice().multiply(BigDecimal.valueOf(minutesDiffNum))
+                    .add(cesAllDayPriceRule.getMoreThenPrice().multiply(BigDecimal.valueOf(moreThenMinuteDiffNum)));
             fee.setDayTime(date);
-            fee.setMoney(fee.getMoney().add(cesAllDayPriceRule.getPrice()));
+            fee.setMoney(money);
             redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
 
             // 如果下一次增加收费时间大于 全天收费时间 设置
         }else {
             // 如果满足全天收费要求,预离时间增加1天
             CesRoomLayout layout = layoutService.getById(bookingroom.getRoomLayoutId());
+
             BusLivingLayoutDayPrice dayPrice = addDayPrice(livingOrder, bookingroom, layout.getMarketPrice());
             fee.setMoney(dayPrice.getPrice());
             fee.setDayTime(date);
-            nextCalendar.setTime(livingOrder.getDueOutTime());
-            nextCalendar.add(Calendar.DAY_OF_YEAR,1);
-            livingOrder.setDueOutTime(nextCalendar.getTime());
-            roomsLivingOrderService.updateById(livingOrder);
-            // 下一次收费时间戳
-            nextCalendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
-            // 添加每日房费
+            // 获取每天超时时间,如果超过预离时间,修改预离时间
+            nextCalendar = getNextCalendar(livingOrder, nowCalendar,cesAllDayPriceRule);
+
         }
         // 移除处理过的时间订单,添加订单下一次超时的时间戳
         redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
         redisTemplate.opsForZSet().add("overTimerOrder",livingOrder.getId(),nextCalendar.getTimeInMillis());
+        // 添加超时房费
         feeService.saveOrUpdate(fee);
     }
 
+
     public void addByDay(BusRoomsLivingOrder livingOrder, CesAllDayPriceRule cesAllDayPriceRule){
         Date date = new Date();
+        Calendar nowCalendar = Calendar.getInstance();
         Calendar nextCalendar = Calendar.getInstance();
         BusBookingRooms bookingroom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
         if (ObjectUtil.isEmpty(bookingroom)) {
@@ -1678,12 +1716,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             // 添加每日房费
             BusLivingLayoutDayPrice dayPrice = addDayPrice(livingOrder, bookingroom, layout.getMarketPrice());
             fee.setMoney(dayPrice.getPrice());
-            nextCalendar.setTime(livingOrder.getDueOutTime());
-            nextCalendar.add(Calendar.DAY_OF_YEAR,1);
-            livingOrder.setDueOutTime(nextCalendar.getTime());
-            roomsLivingOrderService.updateById(livingOrder);
-            // 下一次收费时间戳
-            nextCalendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
+            // 获取每天超时时间,如果超过预离时间,修改预离时间
+            nextCalendar = getNextCalendar(livingOrder, nowCalendar,cesAllDayPriceRule);
         }
         // 移除处理过的时间订单,添加订单下一次超时的时间戳
         redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
@@ -1693,6 +1727,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
 
     public void notAdd(BusRoomsLivingOrder livingOrder, CesAllDayPriceRule cesAllDayPriceRule){
         Date date = new Date();
+        Calendar nowCalendar = Calendar.getInstance();
         Calendar nextCalendar = Calendar.getInstance();
         BusBookingRooms bookingroom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
         if (ObjectUtil.isEmpty(bookingroom)) {
@@ -1708,12 +1743,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             // 添加每日房费
             BusLivingLayoutDayPrice dayPrice = addDayPrice(livingOrder, bookingroom, layout.getMarketPrice());
             fee.setMoney(dayPrice.getPrice());
-            nextCalendar.setTime(livingOrder.getDueOutTime());
-            nextCalendar.add(Calendar.DAY_OF_YEAR,1);
-            livingOrder.setDueOutTime(nextCalendar.getTime());
-            roomsLivingOrderService.updateById(livingOrder);
-            // 下一次收费时间戳
-            nextCalendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
+            // 获取每天超时时间,如果超过预离时间,修改预离时间
+            nextCalendar = getNextCalendar(livingOrder, nowCalendar,cesAllDayPriceRule);
         }
         // 移除处理过的时间订单,添加订单下一次超时的时间戳
         redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
@@ -1769,6 +1800,23 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         return fee;
     }
 
+    private Calendar getNextCalendar(BusRoomsLivingOrder livingOrder, Calendar nowCalendar,CesAllDayPriceRule cesAllDayPriceRule) {
+        Calendar nextCalendar = Calendar.getInstance();
+        nextCalendar.setTime(livingOrder.getDueOutTime());
+        nextCalendar.set(Calendar.YEAR, nowCalendar.get(Calendar.YEAR));
+        nextCalendar.set(Calendar.MONTH, nowCalendar.get(Calendar.MONTH));
+        nextCalendar.set(Calendar.DAY_OF_MONTH, nowCalendar.get(Calendar.YEAR));
+        nextCalendar.add(Calendar.DAY_OF_YEAR,1);
+        // 修改预离时间
+        if(nextCalendar.getTime().compareTo(livingOrder.getDueOutTime()) > 0){
+            livingOrder.setDueOutTime(nextCalendar.getTime());
+            roomsLivingOrderService.updateById(livingOrder);
+        }
+        // 下一次收费时间戳
+        nextCalendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
+        return nextCalendar;
+    }
+
     /**
      * 完整费用时间
      * @return

+ 1 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/BusSchemeLayoutDailyPriceServiceImpl.java

@@ -42,6 +42,7 @@ public class BusSchemeLayoutDailyPriceServiceImpl extends ServiceImpl<BusSchemeL
         if(user.getRelTenantIds() != null && !user.getRelTenantIds().equals("")){
             queryWrapper.eq("tenant_id",user.getRelTenantIds());
         }
+        queryWrapper.eq("scheme_layout_id",schemeLayoutId);
         queryWrapper.eq("del_flag",0);
         List<BusSchemeLayoutDailyPrice> list = list(queryWrapper);
         //获取从今天开始,两个月时间的数据

+ 5 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/Vo/CesGoodsVo.java

@@ -19,4 +19,9 @@ public class CesGoodsVo extends CesGoods {
     private Double number;
 
     private List<KcDepositoryInGoods> kcDepositoryInGoods;
+
+    /**在套餐中包含数量*/
+    private Integer thaliNum;
+    /**套餐中是否必选*/
+    private Integer thaliRequired;
 }

+ 3 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/entity/CesGoods.java

@@ -167,6 +167,9 @@ public class CesGoods extends Model<CesGoods> {
      */
     private Boolean invalid;
 
+    /**
+     * 临时商品
+     */
     private Boolean isTemp;
 
     /**

+ 1 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/service/CesGoodsServiceImpl.java

@@ -273,6 +273,7 @@ private KcGoodsServiceImpl kcGoodsService;
     }
 
 
+    /**商品退货*/
     public void saleReturn(KcDepositoryInGoods depositoryInGoods){
         CesGoods goods = getById(depositoryInGoods.getGoodsId());
         if (goods == null) {