散户下单接口问题修复

wxpay
LI-CCONG\李聪聪 8 months ago
parent 7dd33b86a1
commit a076727389

@ -50,7 +50,7 @@ public class RecycleOrderController {
Page<RecycleOrder> result = recycleOrderService.queryOrderByPage(recycleOrderQuery);
// 3.订单距离计算
LocationDTO locationDTO = recycleOrderQuery.getLocation();
if (ObjectUtil.isNotEmpty(locationDTO) && locationDTO.isValid()) {
if (ObjectUtil.isNotEmpty(locationDTO)) {
String longitude = locationDTO.getLongitude();
String latitude = locationDTO.getLatitude();
for(RecycleOrder recycleOrder : result.getRecords()) {
@ -79,7 +79,7 @@ public class RecycleOrderController {
public CommonResult<RecycleOrderRespVO> findOrder(@RequestBody RecycleOrderQuery recycleOrderQuery) {
RecycleOrder recycleOrder = recycleOrderService.getOrderById(recycleOrderQuery.getId());
LocationDTO locationDTO = recycleOrderQuery.getLocation();
if (ObjectUtil.isNotEmpty(locationDTO) && locationDTO.isValid()) {
if (ObjectUtil.isNotEmpty(locationDTO)) {
String longitude = locationDTO.getLongitude();
String latitude = locationDTO.getLatitude();
String distance = CommonUtil.getDistance(longitude, latitude, recycleOrder.getLongitude(), recycleOrder.getLatitude());

@ -41,8 +41,8 @@ public class RecycleStationController {
public CommonResult<PageDTO<RecycleStationRespVO>> queryStationByPage(@RequestBody RecycleStationQuery recycleStationQuery) {
LocationDTO locationDTO = recycleStationQuery.getLocation();
log.info("client locationDTO: {}", locationDTO);
if (ObjectUtil.isEmpty(locationDTO) && !locationDTO.isValid()) {
throw new BizIllegalException("授权定位信息未授权 或 定位信息错误");
if (ObjectUtil.isEmpty(locationDTO)) {
throw new BizIllegalException("授权定位信息未授权");
}
Page<RecycleStation> result = recycleStationService.queryStationByPage(recycleStationQuery);
PageDTO<RecycleStationRespVO> recycleStationPageVO = PageDTO.of(result, RecycleStationRespVO.class);
@ -58,8 +58,8 @@ public class RecycleStationController {
// 站点距离计算
LocationDTO locationDTO = recycleStationQuery.getLocation();
log.info("client locationDTO: {}", locationDTO);
if (ObjectUtil.isEmpty(locationDTO) && !locationDTO.isValid()) {
throw new BizIllegalException("授权定位信息未授权 或 定位信息错误");
if (ObjectUtil.isEmpty(locationDTO)) {
throw new BizIllegalException("授权定位信息未授权");
}
return CommonResult.success(recycleStationRespVO);
}

@ -4,27 +4,33 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.regex.Pattern;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
@Data
@ApiModel(description = "当前位置实体")
public class LocationDTO {
private static final String LONGITUDE_REGEX = "/^[\\-\\+]?(0?\\d{1,2}\\.\\d{1,6}|1[0-7]?\\d{1}\\.\\d{1,6}|180\\.0{1,6})$/";
private static final String LONGITUDE_REGEX = "^[\\-\\+]?(0?\\d{1,2}\\.\\d{1,6}|1[0-7]?\\d{1}\\.\\d{1,6}|180\\.0{1,6})$";
private static final String LATITUDE_REGEX = "/^[\\-\\+]?([0-8]?\\d{1}\\.\\d{1,6}|90\\.0{1,6})$/";
private static final String LATITUDE_REGEX = "^[\\-\\+]?([0-8]?\\d{1}\\.\\d{1,6}|90\\.0{1,6})$";
@ApiModelProperty(value = "当前经度", required = true, example = "121.404032")
@NotNull(message = "未知定位")
@Pattern(regexp = LONGITUDE_REGEX, message = "经度格式错误")
private String longitude;
@ApiModelProperty(value = "当前经度", required = true, example = "31.163973")
@ApiModelProperty(value = "当前纬度", required = true, example = "31.163973")
@NotNull(message = "未知定位")
@Pattern(regexp = LATITUDE_REGEX, message = "纬度格式错误")
private String latitude;
// 判断经纬度是否有效
public boolean isValid() {
return Pattern.matches(LONGITUDE_REGEX, longitude) && Pattern.matches(LATITUDE_REGEX, latitude);
}
// // 判断经纬度是否有效
// public boolean isValid() {
// return Pattern.matches(/LONGITUDE_REGEX/, longitude) && Pattern.matches(/LATITUDE_REGEX/, latitude);
// }
}

@ -5,7 +5,6 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
@Data
@ApiModel(description = "小程序认证实体")

@ -1,10 +1,12 @@
package cc.yunxi.domain.vo.recycleorder;
import cc.yunxi.domain.dto.LocationDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.constraints.Future;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@ -29,13 +31,17 @@ public class RecycleOrderCreateVO {
@NotBlank(message = "散户地址不能为空")
private String recycleAddress;
@ApiModelProperty(value = "下单地址经度", required = true, example = "119.643888")
@NotBlank(message = "下单地址经度不能为空")
private Double longitude;
@ApiModelProperty(value = "下单地址纬度", required = true, example = "37.966944")
@NotBlank(message = "下单地址纬度不能为空")
private Double latitude;
// @ApiModelProperty(value = "下单地址经度", required = true, example = "119.643888")
// @NotBlank(message = "下单地址经度不能为空")
// private String longitude;
//
// @ApiModelProperty(value = "下单地址纬度", required = true, example = "37.966944")
// @NotBlank(message = "下单地址纬度不能为空")
// private String latitude;
@ApiModelProperty(value = "当前位置", required = true)
@NotNull(message = "位置定位信息未授权")
@Valid
private LocationDTO locationDTO;
@ApiModelProperty(value = "预约上门时间起", required = true, example = "2024-03-01 15:58:49")
@NotNull(message = "预约上门时间起不能为空")

@ -1,6 +1,7 @@
package cc.yunxi.interceptor;
import cc.yunxi.common.exception.BizIllegalException;
import cc.yunxi.common.exception.UnauthorizedException;
import cc.yunxi.domain.dto.UserDTO;
import cc.yunxi.service.impl.CommonService;
import cc.yunxi.utils.JwtTool;
@ -31,7 +32,7 @@ public class LoginInterceptor implements HandlerInterceptor {
// 2.缓存中读取token信息
boolean existsKey = redisTool.existsKey(CommonService.TOKEN_KEY + token);
if (!existsKey) {
throw new BizIllegalException("token已过期");
throw new UnauthorizedException("token已过期");
}
// 这里userInfo可以来自缓存 todo
// 3.校验token

@ -32,7 +32,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import javax.validation.Valid;
/**
* <p>
@ -94,7 +93,10 @@ public class RecycleOrderServiceImpl extends ServiceImpl<RecycleOrderMapper, Rec
if (ObjectUtil.isEmpty(client)) {
throw new DbException("散户不存在");
}
RecycleOrder recycleOrder = BeanUtils.copyBean(orderCreateVO, RecycleOrder.class);
RecycleOrder recycleOrder = BeanUtils.copyBean(orderCreateVO, RecycleOrder.class, (source, target) -> {
target.setLatitude(source.getLocationDTO().getLatitude());
target.setLongitude(source.getLocationDTO().getLongitude());
});
String idNumber = CommonUtil.getIdNumber(BusinessCodeEnum.ORDER.getCode());
recycleOrder.setClientId(client.getId());
recycleOrder.setClientName(client.getNickName());
@ -111,9 +113,12 @@ public class RecycleOrderServiceImpl extends ServiceImpl<RecycleOrderMapper, Rec
@Override
@Transactional(rollbackFor = Exception.class)
public void updateOrder(RecycleOrderUpdateVO orderUpdateVO) {
// 接单后无法修改地址 todo
validateOrderExists(orderUpdateVO.getId());
RecycleOrder recycleOrder = BeanUtils.copyBean(orderUpdateVO, RecycleOrder.class);
RecycleOrder recycleOrder = this.getOrderById(orderUpdateVO.getId());
// 接单后无法修改订单信息
if (!recycleOrder.getOrderStatus().equals(OrderStatusEnum.PENDING)) {
throw new BizIllegalException("订单处理中,无法修改订单信息");
}
recycleOrder = BeanUtils.copyBean(orderUpdateVO, RecycleOrder.class);
log.info("recycleOrder updateVO: {}", recycleOrder);
this.updateById(recycleOrder);
}

Loading…
Cancel
Save