Commit 28dfeabc by YG8999

门店添加订单预定时间

parent b43788c3
......@@ -78,4 +78,19 @@ public class SStoreVo extends BaseEntity
@ApiModelProperty(name = "美团点评店铺id")
private String openShopUuid;
/**
* 当天最后预定订单时间
*/
private Long orderTime;
/**
* 0-无,1-分钟,2-小时
*/
private Integer orderTimeType;
/**
* 当天最后预定订单类型
*/
private Integer orderType;
}
......@@ -68,4 +68,6 @@ public interface SOrderMapper extends BaseMapper<SOrder>
SOrder getInfoByEntity(SOrder orderParam);
List<SOrder> selectSOrderByMaxTime(SOrder order);
List<SOrder> selectSOrderByStoreIdAndMaxTime(SOrder order);
}
......@@ -213,4 +213,6 @@ public interface ISOrderService extends IService<SOrder>
List<SOrderVo> exportList(SOrder sOrder);
List<SOrder> selectSOrderByMaxTime(SOrder orderQuery);
List<SOrder> selectSOrderByStoreIdAndMaxTime(SOrder orderQuery);
}
......@@ -700,6 +700,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
return baseMapper.selectSOrderByMaxTime(orderQuery);
}
@Override
public List<SOrder> selectSOrderByStoreIdAndMaxTime(SOrder orderQuery) {
return baseMapper.selectSOrderByStoreIdAndMaxTime(orderQuery);
}
/**
* 新增订单
*
......
package share.system.service.impl;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
......@@ -28,6 +30,7 @@ import share.system.request.SStoreRequest;
import share.system.service.*;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
......@@ -301,6 +304,13 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
private List<SStoreVo> convertDosToVosSortByDst(List<SStore> storeList, SStoreRequest request) {
List<SStoreVo> voList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(storeList)) {
// 查询每一个房间最后一条预定订单下单时间
Date now = DateUtil.date();
SOrder orderQuery = new SOrder();
orderQuery.setCreateTime(DateUtil.offsetHour(now, -3));
List<SOrder> orderList = orderService.selectSOrderByStoreIdAndMaxTime(orderQuery);
Map<Long, SOrder> orderMap = Optional.ofNullable(orderList).orElse(new ArrayList<>()).stream().collect(Collectors.toMap(SOrder::getStoreId, Function.identity()));
Double nowLng = Double.parseDouble(request.getNowLongitude());
Double nowLat = Double.parseDouble(request.getNowLatitude());
SpatialContext geo = SpatialContext.GEO;
......@@ -310,6 +320,23 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
SStoreVo vo = new SStoreVo();
BeanUtils.copyProperties(o, vo);
vo.setDistance(distance + "");
// 计算当天预定最后预定时间
SOrder order = orderMap.get(vo.getId());
if (order != null) {
long betweenMinute = DateUtil.between(order.getCreateTime(), now, DateUnit.MINUTE);
if (betweenMinute < 60) {
vo.setOrderTimeType(1);
vo.setOrderTime(betweenMinute);
} else {
long betweenHour = DateUtil.between(order.getCreateTime(), now, DateUnit.HOUR);
vo.setOrderTimeType(2);
vo.setOrderTime(betweenHour);
}
vo.setOrderType(order.getOrderType());
} else {
vo.setOrderTimeType(0);
vo.setOrderTime(0L);
}
voList.add(vo);
});
return voList.stream().sorted(Comparator.comparing(storeVo -> Double.parseDouble(storeVo.getDistance()))).collect(Collectors.toList());
......@@ -326,9 +353,33 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
private List<SStoreVo> convertDosToVos(List<SStore> storeList) {
List<SStoreVo> voList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(storeList)) {
// 查询每一个房间最后一条预定订单下单时间
Date now = DateUtil.date();
SOrder orderQuery = new SOrder();
orderQuery.setCreateTime(DateUtil.offsetHour(now, -3));
List<SOrder> orderList = orderService.selectSOrderByStoreIdAndMaxTime(orderQuery);
Map<Long, SOrder> orderMap = Optional.ofNullable(orderList).orElse(new ArrayList<>()).stream().collect(Collectors.toMap(SOrder::getStoreId, Function.identity()));
storeList.stream().forEach(o -> {
SStoreVo vo = new SStoreVo();
BeanUtils.copyProperties(o, vo);
// 计算当天预定最后预定时间
SOrder order = orderMap.get(vo.getId());
if (order != null) {
long betweenMinute = DateUtil.between(order.getCreateTime(), now, DateUnit.MINUTE);
if (betweenMinute < 60) {
vo.setOrderTimeType(1);
vo.setOrderTime(betweenMinute);
} else {
long betweenHour = DateUtil.between(order.getCreateTime(), now, DateUnit.HOUR);
vo.setOrderTimeType(2);
vo.setOrderTime(betweenHour);
}
vo.setOrderType(order.getOrderType());
} else {
vo.setOrderTimeType(0);
vo.setOrderTime(0L);
}
voList.add(vo);
});
}
......
......@@ -200,6 +200,50 @@
and DATE_FORMAT(create_time, '%Y-%m-%d') = DATE_FORMAT(#{createTime}, '%Y-%m-%d')
group by room_id) t on t.id = s.id;
</select>
<select id="selectSOrderByStoreIdAndMaxTime" parameterType="SOrder" resultMap="SOrderResult">
select s.id,
s.order_no,
s.out_trade_no,
s.historical_order_no,
s.order_type,
s.pay_type,
s.pay_status,
s.store_id,
s.room_id,
s.consumer_id,
s.consumer_name,
s.consumer_phone,
s.pack_id,
s.pack_price,
s.coupon_id,
s.coupon_price,
s.total_price,
s.pay_price,
s.pay_time,
s.time_long,
s.pre_start_date,
s.pre_end_date,
s.start_date,
s.end_date,
s.status,
s.refund_status,
s.refund_reason,
s.refund_reason_time,
s.refund_price,
s.is_delete,
s.create_by,
s.create_time,
s.update_by,
s.update_time,
s.arrival_time,
s.remark
from s_order s inner join (
select store_id, max(create_time) as create_time, max(id) as id from s_order
where
pay_status = 1 and is_delete = 0 and refund_status = 0
and create_time >= #{createTime}
group by store_id) t on t.id = s.id
</select>
<insert id="insertSOrder" parameterType="SOrder" useGeneratedKeys="true" keyProperty="id">
insert into s_order
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment