Ver código fonte

增加查询可入住酒店列表

gqx 2 anos atrás
pai
commit
96bd6984ff

+ 30 - 28
jeecg-mall-api/src/main/java/org/jeecg/modules/bus/controller/HotelController.java

@@ -24,6 +24,7 @@ import org.jeecg.common.util.TokenUtils;
 import org.jeecg.config.ApiVersion;
 import org.jeecg.config.ApiVersionConstant;
 import org.jeecg.modules.business.entity.BusHotel;
+import org.jeecg.modules.business.entity.BusMarketCouponsCashUsed;
 import org.jeecg.modules.business.service.IBusHotelService;
 import org.jeecg.modules.business.util.MapUtil;
 import org.jeecg.modules.rooms.entity.CesRoomLayout;
@@ -81,39 +82,40 @@ public class HotelController extends  WebConfig {
         return Result.OK(list);
     }
 
+    /**
+     * 可入住酒店列表
+     * @param pageNo
+     * @param pageSize
+     * @param sort 0推荐排序 1 距离优先 2低价优先 3评分优先 4评论数优先
+     * @param keyWord 搜索关键字
+     * @param req
+     * @return
+     */
     @ApiOperation(value="可入住酒店列表", notes="可入住酒店列表")
     @GetMapping(value = "/can-use-hotel-list")
     @ApiLogin
     @ApiVersion(group = ApiVersionConstant.FAP_MALLAPI101)
-    public Result<List<BusHotel>> getCanUseHotelList(BusHotel busHotel, HttpServletRequest req) {
-        LambdaQueryWrapper<BusHotel> queryWrapper = QueryGenerator.initQueryWrapper(busHotel, req.getParameterMap()).lambda();
-        if (StringUtils.isNotBlank(busHotel.getKeyWord())) {
-            queryWrapper.and(t -> {
-                t.like(BusHotel::getAddress, busHotel.getKeyWord());
-                t.or().like(BusHotel::getName, busHotel.getKeyWord());
-                t.or().like(BusHotel::getIntroduction, busHotel.getKeyWord());
-            });
-        }
+    public Result<IPage<BusHotel>> getCanUseHotelList( @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                     @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                     @RequestParam(name = "sort", defaultValue = "0") Integer sort,
+                                                      @RequestParam(name = "keyWord", defaultValue = "") String keyWord,
+                                                     HttpServletRequest req) {
+        Page<BusHotel> page = new Page<BusHotel>(pageNo, pageSize);
         String tenantId = TenantContextHolder.getTenantId();
-        if (StringUtils.isNotBlank(tenantId)) {
-            queryWrapper.eq(BusHotel::getTenantId, tenantId);
-        }
-        queryWrapper.eq(BusHotel::getStatus, 1);
-        queryWrapper.eq(BusHotel::getCheckStatus, 1);
-        queryWrapper.eq(BusHotel::getDelFlag, 0);
-        List<BusHotel> list = busHotelService.list(queryWrapper);
-        list.forEach(t -> {
-            LambdaQueryWrapper<CesRoomLayout> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-            lambdaQueryWrapper.eq(CesRoomLayout::getHotelId, t.getId());
-            lambdaQueryWrapper.orderByAsc(CesRoomLayout::getMarketPrice).last("limit 1");
-            CesRoomLayout cesRoomLayout = cesRoomLayoutService.getOne(lambdaQueryWrapper);
-            if (cesRoomLayout != null) {
-                t.setMinPrice(cesRoomLayout.getMarketPrice());
-            }
-            if (ObjectUtils.isNotEmpty(busHotel.getLat()) && ObjectUtils.isNotEmpty(busHotel.getLng())) {
+        IPage<BusHotel> pageList = busHotelService.pageList(page, tenantId, keyWord, sort);
+        return Result.OK(pageList);
+    }
 
-            }
-        });
-        return Result.OK(list);
+    /**
+     * 通过id查询酒店详情
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value="通过id查询酒店详情", notes="通过id查询酒店详情")
+    @GetMapping(value = "/queryById")
+    public Result<BusHotel> queryById(@RequestParam(name="id",required=true) String id) {
+        BusHotel busHotel = busHotelService.getById(id);
+        return Result.OK(busHotel);
     }
 }

+ 31 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/BusHotelMapper.java

@@ -1,10 +1,15 @@
 package org.jeecg.modules.business.mapper;
 
+import java.util.HashMap;
 import java.util.List;
 
+import cn.hutool.core.date.DateTime;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Param;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Select;
 import org.jeecg.modules.business.entity.BusHotel;
+import org.jeecg.modules.business.entity.BusRoomPayType;
 
 /**
  * @Description: bus_hotel
@@ -14,4 +19,30 @@ import org.jeecg.modules.business.entity.BusHotel;
  */
 public interface BusHotelMapper extends BaseMapper<BusHotel> {
 
+    /**
+     * 可入住酒店列表
+     * @param page
+     * @param tenantId 租户id
+     * @param keyWord 关键字
+     * @param sort 0推荐排序 1 距离优先 2低价优先 3评分优先 4评论数优先
+     * @return
+     */
+    @Select("<script>SELECT h.*, ROUND(6378.138*2*ASIN(SQRT(power(SIN((28.205783*PI()/180-(h.lat)*PI()/180)/2),2)+COS(28.205783*PI()/180)*COS((h.lat)*PI()/180)*power(SIN((112.986861*PI()/180-(h.lng)*PI()/180)/2),2)))*1000,2)  AS distance,ifnull(c.commentNum,0) as commentNum,ifnull(c.score,0) as score,ifnull(market_price,0) as market_price FROM bus_hotel_info h\n" +
+            "left join (select hotel_id,count(0) as commentNum,AVG(score) as score from ces_order_comment where comment_type=1 group by hotel_id) c\n" +
+            "on c.hotel_id=h.id\n" +
+            "left join (select hotel_id,min(market_price) as market_price from ces_room_layout where invalid=0 group by hotel_id) l\n" +
+            "on l.hotel_id=h.id\n" +
+            "where h.del_flag=0 and h.`status`=1 and h.check_status=1\n" +
+            "<if test='tenantId != null and tenantId !=\"\"'> and h.tenant_id = '${tenantId}' </if>" +
+            "<if test='keyWord != null and keyWord !=\"\"'> and (h.address LIKE concat(concat('%',#{keyWord}),'%') or h.name LIKE concat(concat('%',#{keyWord}),'%')) </if>" +
+            "<if test='sort != null and sort ==0'> order by h.create_time desc </if>" +
+            "<if test='sort != null and sort ==1'> order by distance asc </if>" +
+            "<if test='sort != null and sort ==2'> order by market_price asc </if>" +
+            "<if test='sort != null and sort ==3'> order by score desc </if>" +
+            "<if test='sort != null and sort ==4'> order by commentNum desc </if>" +
+            "</script>")
+    public List<BusHotel> pageList(Page<BusHotel> page,@Param("tenantId") String tenantId, @Param("keyWord") String keyWord, @Param("sort") Integer sort);
+
 }
+
+

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

@@ -1,5 +1,6 @@
 package org.jeecg.modules.business.service;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.business.entity.BusHotel;
@@ -24,4 +25,14 @@ public interface IBusHotelService extends IService<BusHotel> {
      * @param busHotel 酒店
      */
     public Result<?>  editHotelInfo(BusHotel busHotel);
+
+    /**
+     * 可入住酒店列表
+     * @param page
+     * @param tenantId
+     * @param keyWord
+     * @param sort 0推荐排序 1 距离优先 2低价优先 3评分优先 4评论数优先
+     * @return
+     */
+    public Page<BusHotel> pageList(Page<BusHotel> page, String tenantId, String keyWord, Integer sort);
 }

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

@@ -1,10 +1,13 @@
 package org.jeecg.modules.business.service.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.date.DateTime;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.ibatis.annotations.Param;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.constant.CacheConstant;
 import org.jeecg.common.system.util.JwtUtil;
@@ -13,6 +16,7 @@ import org.jeecg.common.util.PasswordUtil;
 import org.jeecg.common.util.TokenUtils;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.business.entity.BusHotel;
+import org.jeecg.modules.business.entity.BusRoomPayType;
 import org.jeecg.modules.business.mapper.BusHotelMapper;
 import org.jeecg.modules.business.service.IBusHotelService;
 import org.jeecg.modules.system.entity.SysUser;
@@ -23,8 +27,10 @@ import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
+import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 
 /**
@@ -35,7 +41,7 @@ import java.util.List;
  */
 @Service
 public class BusHotelServiceImpl extends ServiceImpl<BusHotelMapper, BusHotel> implements IBusHotelService {
-    @Autowired
+    @Resource
     private BusHotelMapper busHotelMapper;
 
     @Override
@@ -86,4 +92,15 @@ public class BusHotelServiceImpl extends ServiceImpl<BusHotelMapper, BusHotel> i
         return Result.ok("信息编辑成功!");
     }
 
+    /**
+     * 可入住酒店列表
+     * @param page
+     * @param tenantId
+     * @param keyWord
+     * @param sort 0推荐排序 1 距离优先 2低价优先 3评分优先 4评论数优先
+     * @return
+     */
+    public Page<BusHotel> pageList(Page<BusHotel> page, String tenantId, String keyWord, Integer sort) {
+        return page.setRecords(this.busHotelMapper.pageList(page, tenantId, keyWord, sort));
+    }
 }

+ 2 - 2
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/finance/mapper/SummaryMapper.java

@@ -712,7 +712,7 @@ public interface SummaryMapper extends BaseMapper<PosOrderGoodsPayment> {
             "on b.room_id=room.id\n" +
             "where 1=1\n" +
             "<if test='hotelId != null and hotelId !=\"\"'> and b.hotel_id = '${hotelId}' </if>" +
-            "and b.fee_type=2 and b.preferential_status=2 and p.subject_type=5\n" +
+            "and b.fee_type=2 and b.preferential_status=2 and b.subject_type=5\n" +
             "and b.custorer_order_remark='结账退款'\n" +
             "and datediff(b.create_time,now())=0</script>")
     public List<HashMap<String, Object>> dayExpendOrderFeeList(@Param("hotelId") String hotelId);
@@ -728,7 +728,7 @@ public interface SummaryMapper extends BaseMapper<PosOrderGoodsPayment> {
             "left join ces_rooms room\n" +
             "on b.room_id=room.id\n" +
             "where 1=1\n" +
-            "and b.fee_type=2 and b.preferential_status=2 and p.subject_type=5\n" +
+            "and b.fee_type=2 and b.preferential_status=2 and b.subject_type=5\n" +
             "and b.custorer_order_remark='结账退款'\n" +
             "and datediff(b.create_time,now())=0\n" +
             "<if test='payType != null and payType !=\"\"'> and b.pay_type = '${payType}' </if>" +