|
|
@ -2,6 +2,7 @@ package com.ruoyi.applet.contoller; |
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.cyl.h5.pojo.vo.H5OrderVO; |
|
|
|
import com.cyl.h5.service.H5OrderService; |
|
|
|
import com.cyl.h5.service.H5PetCareService; |
|
|
@ -23,6 +24,7 @@ import com.ruoyi.applet.service.IMallOrderService; |
|
|
|
import com.ruoyi.common.core.controller.BaseController; |
|
|
|
import com.ruoyi.common.core.domain.AjaxResult; |
|
|
|
import com.ruoyi.common.core.page.TableDataInfo; |
|
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
|
import com.ruoyi.common.utils.uuid.IdUtils; |
|
|
|
import com.ruoyi.model.domain.*; |
|
|
|
import com.ruoyi.model.service.*; |
|
|
@ -36,6 +38,7 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
@ -83,10 +86,16 @@ public class ApiAppletOrderController extends BaseController { |
|
|
|
@Autowired |
|
|
|
private OmsOrderServiceMapper omsOrderServiceMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IAppletAddressService appletAddressService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IAppletOutDateService appletOutDateService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IAppletOrderDateFrequencyService appletOrderDateFrequencyService; |
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("接单大厅列表-带分页") |
|
|
|
@GetMapping("/list") |
|
|
|
public AjaxResult outDateList(AppletOrder appletOrder){ |
|
|
@ -111,9 +120,95 @@ public class ApiAppletOrderController extends BaseController { |
|
|
|
List<AppletOrderItem> itemList = null; |
|
|
|
if(appletOrder.getType().equals("0")){ |
|
|
|
|
|
|
|
// TODO 这里需要加上伴宠师等级的筛选 |
|
|
|
//查询当前伴宠师地址 |
|
|
|
List<AppletAddress> addressList = appletAddressService.lambdaQuery() |
|
|
|
.eq(AppletAddress::getUserId, appUsers.getUserId()) |
|
|
|
.list(); |
|
|
|
|
|
|
|
//没有接单地址,无法接单 |
|
|
|
if (addressList.size() == 0){ |
|
|
|
return AjaxResult.error("补全接单地址,开始接单"); |
|
|
|
} |
|
|
|
|
|
|
|
boolean addressBoolean = false; |
|
|
|
|
|
|
|
list = appletOrderService.selectAppletOrderListLikeUserIdJson(appletOrder); |
|
|
|
for (AppletAddress appletAddress : addressList) { |
|
|
|
if (StringUtils.isNotEmpty(appletAddress.getLatitude()) && |
|
|
|
StringUtils.isNotEmpty(appletAddress.getLongitude()) && |
|
|
|
StringUtils.isNotEmpty(appletAddress.getRangeNo()) && |
|
|
|
"true".equals(appletAddress.getStatus())){ |
|
|
|
addressBoolean = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
list = appletOrderService.lambdaQuery() |
|
|
|
.eq(AppletOrder::getStatus, 0) |
|
|
|
.eq(AppletOrder::getType, appletOrder.getType()) |
|
|
|
.eq(AppletOrder::getCompanionLevel, appUsers.getUserBcsRole()) |
|
|
|
.like(appletOrder.getUserIdJson() != null, AppletOrder::getUserIdJson, appletOrder.getUserIdJson()) |
|
|
|
.and(addressList.size() > 0 && addressBoolean, q -> { |
|
|
|
for (AppletAddress appletAddress : addressList) { |
|
|
|
// |
|
|
|
if (StringUtils.isNotEmpty(appletAddress.getLatitude()) && |
|
|
|
StringUtils.isNotEmpty(appletAddress.getLongitude()) && |
|
|
|
StringUtils.isNotEmpty(appletAddress.getRangeNo()) && |
|
|
|
"true".equals(appletAddress.getStatus())){ |
|
|
|
//计算地址范围 getRangeNo getLatitude getLongitude |
|
|
|
BigDecimal latitude = new BigDecimal(appletAddress.getLatitude()); |
|
|
|
BigDecimal longitude = new BigDecimal(appletAddress.getLongitude()); |
|
|
|
BigDecimal range = new BigDecimal(appletAddress.getRangeNo());//公里数 |
|
|
|
|
|
|
|
// 将公里数转换为经纬度范围 |
|
|
|
// 1度纬度约等于111公里 |
|
|
|
// 1度经度约等于111*cos(纬度)公里 |
|
|
|
BigDecimal latRange = range.divide(new BigDecimal("111"), 6, RoundingMode.HALF_UP); |
|
|
|
BigDecimal lngRange = range.divide(new BigDecimal("111").multiply(new BigDecimal(Math.cos(latitude.doubleValue() * Math.PI / 180))), 6, RoundingMode.HALF_UP); |
|
|
|
|
|
|
|
// 计算经纬度范围 |
|
|
|
BigDecimal latMin = latitude.subtract(latRange); |
|
|
|
BigDecimal latMax = latitude.add(latRange); |
|
|
|
BigDecimal lngMin = longitude.subtract(lngRange); |
|
|
|
BigDecimal lngMax = longitude.add(lngRange); |
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
|
|
|
|
//查询当前地址不接单的日期 |
|
|
|
List<String> dates = appletOutDateService |
|
|
|
.lambdaQuery() |
|
|
|
.select(AppletOutDate::getDate) |
|
|
|
.eq(AppletOutDate::getAddressId, appletAddress.getId()) |
|
|
|
.list().stream() |
|
|
|
.map(n -> { |
|
|
|
return sdf.format(n.getDate()); |
|
|
|
}) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
q.or(w -> { |
|
|
|
if(dates.size() > 0){ |
|
|
|
//根据当前日期从serviceList中查询不符合条件的订单id |
|
|
|
List<Long> orderIds = omsOrderServiceMapper.selectList( |
|
|
|
Wrappers.<OmsOrderService>lambdaQuery() |
|
|
|
.select(OmsOrderService::getOrderId) |
|
|
|
.groupBy(OmsOrderService::getOrderId) |
|
|
|
.in(OmsOrderService::getServiceDate, dates)) |
|
|
|
.stream().map(n -> n.getOrderId()).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if (orderIds.size() > 0){ |
|
|
|
w.notIn(AppletOrder::getOrderId, orderIds); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
w.between(AppletOrder::getLatitude, latMin, latMax) |
|
|
|
.between(AppletOrder::getLongitude, lngMin, lngMax); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
.list(); |
|
|
|
|
|
|
|
// list = appletOrderService.selectAppletOrderListLikeUserIdJson(appletOrder); |
|
|
|
for (AppletOrder order : list) { |
|
|
|
H5OrderVO h5OrderVO = h5OrderService.orderDetail(order.getOrderId()); |
|
|
|
// 得到服务信息 |
|
|
@ -230,8 +325,6 @@ public class ApiAppletOrderController extends BaseController { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//接单大厅 - 根据订单标识查询订单详情的接口 |
|
|
|
@ApiOperation("接单大厅 - 根据订单标识查询订单详情的接口") |
|
|
|
@GetMapping("/getByOrderId") |
|
|
|