xin
2025-09-04 ea26c842829ef69be20ef86d6a546f45c6c5a258
Merge branch 'pxb' into xin
9 files modified
100 ■■■■ changed files
oying-system/src/main/java/com/oying/modules/rider/domain/dto/RiderIncomeDetailQueryCriteria.java 3 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/rider/domain/vo/OrderDeliveryPhotosVo.java 12 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/rider/mapper/RiderDeliveryPhotosMapper.java 2 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/rider/rest/WxRiderController.java 21 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/rider/service/RiderDeliveryPhotosService.java 2 ●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/rider/service/impl/RiderDeliveryPhotosServiceImpl.java 33 ●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/rider/service/impl/RiderOrderRecordServiceImpl.java 19 ●●●● patch | view | raw | blame | history
oying-system/src/main/resources/mapper/rider/RiderDeliveryPhotosMapper.xml 5 ●●●●● patch | view | raw | blame | history
oying-system/src/main/resources/mapper/rider/RiderIncomeDetailMapper.xml 3 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/rider/domain/dto/RiderIncomeDetailQueryCriteria.java
@@ -21,6 +21,9 @@
    @ApiModelProperty(value = "骑手名字")
    private String riderName;
    @ApiModelProperty(value = "骑手ID")
    private String riderId;
    @ApiModelProperty(value = "骑手手机号")
    private String riderPhone;
oying-system/src/main/java/com/oying/modules/rider/domain/vo/OrderDeliveryPhotosVo.java
@@ -3,6 +3,7 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.web.multipart.MultipartFile;
import java.io.Serializable;
@@ -25,13 +26,16 @@
    @ApiModelProperty(value = "拍照纬度")
    private String userLatitude;
    @ApiModelProperty(value = "图片地址")
    private String photoUrl;
    @ApiModelProperty(value = "描述")
    private String description;
    @ApiModelProperty(value = "照片存储ID")
    @ApiModelProperty(value = "图片地址(前端不用传值)")
    private String photoUrl;
    @ApiModelProperty(value = "桶文件ID(前端不用传值)")
    private Long uploadId;
    @ApiModelProperty(value = "图片文件")
    private transient MultipartFile photoFile;
}
oying-system/src/main/java/com/oying/modules/rider/mapper/RiderDeliveryPhotosMapper.java
@@ -19,4 +19,6 @@
    IPage<RiderDeliveryPhotos> findAll(@Param("criteria") RiderDeliveryPhotosQueryCriteria criteria, Page<Object> page);
    List<RiderDeliveryPhotos> findAll(@Param("criteria") RiderDeliveryPhotosQueryCriteria criteria);
    RiderDeliveryPhotos getRiderDeliveryPhotosByOrderNum(@Param("orderNum") String orderNum);
}
oying-system/src/main/java/com/oying/modules/rider/rest/WxRiderController.java
@@ -1,6 +1,8 @@
package com.oying.modules.rider.rest;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.oying.domain.BucketStorage;
import com.oying.exception.BadRequestException;
import com.oying.modules.rider.domain.*;
import com.oying.modules.rider.domain.dto.RiderIncomeDetailQueryCriteria;
import com.oying.modules.rider.domain.dto.RiderOrderRecordQueryCriteria;
@@ -9,6 +11,8 @@
import com.oying.modules.rider.domain.vo.OrderRiderOperationVo;
import com.oying.modules.rider.service.*;
import com.oying.modules.rider.utils.Constants;
import com.oying.service.BucketStorageService;
import com.oying.utils.FileUtil;
import com.oying.utils.PageResult;
import com.oying.utils.R;
import com.oying.utils.StringUtils;
@@ -18,6 +22,7 @@
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
@@ -101,7 +106,7 @@
    public ResponseEntity<?> riderGrabOrder(@PathVariable String orderNum) {
        // 订单号不能为空
        if (StringUtils.isBlank(orderNum)) {
            return ResponseEntity.ok(R.fail(Constants.HTTP_CODE_FAIL, "订单号不能为空"));
            throw new BadRequestException("订单号不能为空");
        }
        R result = riderOrderRecordService.riderGrabOrder(orderNum);
        return ResponseEntity.ok(result);
@@ -113,7 +118,7 @@
    public ResponseEntity<?> riderCancelOrder(@PathVariable String orderNum) {
        // 订单号不能为空
        if (StringUtils.isBlank(orderNum)) {
            return ResponseEntity.ok(R.fail(Constants.HTTP_CODE_FAIL, "订单号不能为空"));
            throw new BadRequestException("订单号不能为空");
        }
        R result = riderOrderRecordService.riderCancelOrder(orderNum);
        return ResponseEntity.ok(R.success(result));
@@ -125,7 +130,7 @@
    public ResponseEntity<?> riderCompleteOrder(@PathVariable String orderNum) {
        // 订单号不能为空
        if (StringUtils.isBlank(orderNum)) {
            return ResponseEntity.ok(R.fail(Constants.HTTP_CODE_FAIL, "订单号不能为空"));
            throw new BadRequestException("订单号不能为空");
        }
        R result = riderOrderRecordService.riderCompleteOrder(orderNum);
        return ResponseEntity.ok(R.success(result));
@@ -137,21 +142,21 @@
    public ResponseEntity<?> riderOperationOrder(@RequestBody OrderRiderOperationVo orderRiderOperationVo) {
        // 订单号不能为空
        if (StringUtils.isBlank(orderRiderOperationVo.getOrderNum())) {
            return ResponseEntity.ok(R.fail(Constants.HTTP_CODE_FAIL, "订单号不能为空"));
            throw new BadRequestException("订单号不能为空");
        }
        R result = riderOrderRecordService.riderOperationOrder(orderRiderOperationVo);
        return ResponseEntity.ok(R.success(result));
    }
    @PostMapping("riderDeliveryPhotos")
    @ApiOperation("骑手上传图片记录")
    @ApiOperation("骑手上传图片")
    // @PreAuthorize("@el.check('riderOrderRecord:list')")
    public ResponseEntity<?> riderDeliveryPhotos(@RequestBody OrderDeliveryPhotosVo orderDeliveryPhotosVo) {
    public ResponseEntity<?> riderDeliveryPhotos(OrderDeliveryPhotosVo orderDeliveryPhotosVo) {
        // 订单号不能为空
        if (StringUtils.isBlank(orderDeliveryPhotosVo.getOrderNum())) {
            return ResponseEntity.ok(R.fail(Constants.HTTP_CODE_FAIL, "订单号不能为空"));
            throw new BadRequestException("订单号不能为空");
        }
        Boolean result = riderDeliveryPhotosService.riderDeliveryPhotos(orderDeliveryPhotosVo);
        RiderDeliveryPhotos result = riderDeliveryPhotosService.riderDeliveryPhotos(orderDeliveryPhotosVo);
        return ResponseEntity.ok(R.success(result));
    }
oying-system/src/main/java/com/oying/modules/rider/service/RiderDeliveryPhotosService.java
@@ -64,5 +64,5 @@
     * @param orderDeliveryPhotosVo
     * @throws IOException /
     */
    Boolean riderDeliveryPhotos(OrderDeliveryPhotosVo orderDeliveryPhotosVo);
    RiderDeliveryPhotos riderDeliveryPhotos(OrderDeliveryPhotosVo orderDeliveryPhotosVo);
}
oying-system/src/main/java/com/oying/modules/rider/service/impl/RiderDeliveryPhotosServiceImpl.java
@@ -1,10 +1,13 @@
package com.oying.modules.rider.service.impl;
import com.oying.domain.BucketStorage;
import com.oying.exception.BadRequestException;
import com.oying.modules.rider.domain.RiderDeliveryPhotos;
import com.oying.modules.rider.domain.vo.OrderDeliveryPhotosVo;
import com.oying.modules.rider.utils.Constants;
import com.oying.modules.sh.domain.vo.OrderResponse;
import com.oying.modules.sh.service.OrderService;
import com.oying.service.BucketStorageService;
import com.oying.utils.FileUtil;
import lombok.RequiredArgsConstructor;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -24,6 +27,7 @@
import java.util.LinkedHashMap;
import com.oying.utils.PageResult;
import org.springframework.web.multipart.MultipartFile;
/**
 * @author pxb
@@ -36,6 +40,8 @@
    private final RiderDeliveryPhotosMapper riderDeliveryPhotosMapper;
    private final OrderService orderService;
    private final BucketStorageService bucketStorageService;
    @Override
    public PageResult<RiderDeliveryPhotos> queryAll(RiderDeliveryPhotosQueryCriteria criteria, Page<Object> page) {
@@ -96,9 +102,24 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean riderDeliveryPhotos(OrderDeliveryPhotosVo orderDeliveryPhotosVo) {
    public RiderDeliveryPhotos riderDeliveryPhotos(OrderDeliveryPhotosVo orderDeliveryPhotosVo) {
        // 限制只上传一张图
        RiderDeliveryPhotos riderDeliveryPhotosIsHave = riderDeliveryPhotosMapper.getRiderDeliveryPhotosByOrderNum(orderDeliveryPhotosVo.getOrderNum());
        if(riderDeliveryPhotosIsHave != null) {
            throw new BadRequestException("只能上传一张图片,图片已上传");
        }
        OrderResponse orderResponse = orderService.getByOrderNum(orderDeliveryPhotosVo.getOrderNum());
        if (orderResponse != null) {
            // 图片信息不能为空
            MultipartFile file = orderDeliveryPhotosVo.getPhotoFile();
            // 判断文件是否为图片
            String suffix = FileUtil.getExtensionName(file.getOriginalFilename());
            FileUtil.checkSize(5, file.getSize());
            if (!FileUtil.IMAGE.equals(FileUtil.getFileType(suffix))) {
                throw new BadRequestException("只能上传图片");
            }
            // 上传照片
            BucketStorage bucketStorage = bucketStorageService.create(null, file);
            // 封装数据
            RiderDeliveryPhotos riderDeliveryPhotos = new RiderDeliveryPhotos();
            riderDeliveryPhotos.setOrderId(orderResponse.getOrder().getOrderId());
@@ -106,16 +127,18 @@
            riderDeliveryPhotos.setRiderId(orderResponse.getOrder().getRiderId());
            riderDeliveryPhotos.setRiderName(orderResponse.getOrder().getRiderName());
            riderDeliveryPhotos.setRiderPhone(orderResponse.getOrder().getRiderPhone());
            riderDeliveryPhotos.setPhotoUrl(orderDeliveryPhotosVo.getPhotoUrl());
            riderDeliveryPhotos.setUploadId(orderDeliveryPhotosVo.getUploadId());
            riderDeliveryPhotos.setPhotoUrl(bucketStorage.getPath());
            riderDeliveryPhotos.setUploadId(bucketStorage.getBucketId());
            riderDeliveryPhotos.setLatitude(orderDeliveryPhotosVo.getUserLatitude());
            riderDeliveryPhotos.setLongitude(orderDeliveryPhotosVo.getUserLongitude());
            riderDeliveryPhotos.setDescription(orderDeliveryPhotosVo.getDescription());
            riderDeliveryPhotos.setIsValid(Constants.IS_VALID_YES);
            riderDeliveryPhotos.setUserPhone(orderResponse.getOrder().getUsername());
            riderDeliveryPhotos.setUserId(orderResponse.getOrder().getUserId());
            return this.save(riderDeliveryPhotos);
            riderDeliveryPhotosMapper.insert(riderDeliveryPhotos);
            return riderDeliveryPhotos;
        } else {
            throw new BadRequestException("订单不存在!");
        }
        return false;
    }
}
oying-system/src/main/java/com/oying/modules/rider/service/impl/RiderOrderRecordServiceImpl.java
@@ -161,7 +161,7 @@
        // 查询骑手信息
        RiderInfo riderInfo = riderInfoService.getRiderSourceInfo(riderId);
        if (riderInfo == null || riderInfo.getEnabled().equals(Constants.SOURCE_ENABLED_DFF)) {
            return R.fail(400, "骑手信息不存在或已过期");
            throw new BadRequestException("骑手信息不存在或已过期");
        }
        // 唯一标识当前线程/客户端
        String clientId = UUID.randomUUID().toString();
@@ -171,27 +171,27 @@
            // 获取分布式锁,设置超时时间10秒
            boolean isLocked = redisUtils.setIfAbsent(lockKey, clientId, 10);
            if (!isLocked) {
                return R.fail(400, "订单已经被其他骑手接单,请稍后重试");
                throw new BadRequestException("订单已经被其他骑手接单,请稍后重试");
            }
            // 查询当前订单 检查订单是否已经被其他骑手抢到或取消 直接返回
            OrderResponse orderResponse = orderService.getByOrderNum(orderNum);
            if (orderResponse == null || orderResponse.getOrder() == null) {
                return R.fail(400, "订单信息不存在,请稍后重试");
                throw new BadRequestException("订单信息不存在,请稍后重试");
            }
            int orderStatus = orderResponse.getOrder().getOrderStatus();
            // 2商家已接单 4商家已备货 这两个状态可以接单
            if (orderStatus != 2 && orderStatus != 4) {
                return R.fail(400, "订单已经被其他骑手接单或取消,请稍后重试");
            // 2商家已接单 3商家已备货 这两个状态可以接单
            if (orderStatus != 2 && orderStatus != 3) {
                throw new BadRequestException("订单已经被其他骑手接单或取消,请稍后重试");
            }
            // 商家备货状态 查看是否存在骑手信息
            if (orderStatus == 4 && orderResponse.getOrder().getRiderId() != null) {
                return R.fail(400, "订单已经被其他骑手接单,请稍后重试");
                throw new BadRequestException("订单已经被其他骑手接单,请稍后重试");
            }
            // 订单没有被接单或取消的情况下,进行接单操作
            // 1.新增骑手接单记录
            addRiderOrderRecord(riderInfo, orderResponse);
            // 2.新增订单接单流程信息 骑手接单流程新增
            orderService.operationLog(orderResponse, OrderStatusEnum.THREE, riderInfo.getCardName());
            orderService.operationLog(orderResponse, OrderStatusEnum.FOUR, riderInfo.getCardName());
            // 返回成功信息
            return R.success(orderResponse, "接单成功");
        } catch (Exception e) {
@@ -289,7 +289,8 @@
        RiderDeliveryPhotos riderDeliveryPhotos = riderDeliveryPhotosService.getOne(
                new QueryWrapper<RiderDeliveryPhotos>().eq(RiderDeliveryPhotos.COL_ORDER_NUM, orderNum));
        if (riderDeliveryPhotos == null) {
            return R.fail(400, "请上传送达照片");
            // 送达照片数据为空,抛出异常
            throw new BadRequestException("请上传送达照片");
        }
        // 当前订单信息
        OrderResponse orderResponse = orderService.getByOrderNum(orderNum);
oying-system/src/main/resources/mapper/rider/RiderDeliveryPhotosMapper.xml
@@ -61,4 +61,9 @@
        </where>
        order by photo_id desc
    </select>
    <select id="getRiderDeliveryPhotosByOrderNum" resultMap="BaseResultMap">
     select
        <include refid="Base_Column_List"/>
        from qs_rider_delivery_photos where order_num = #{orderNum}
</select>
</mapper>
oying-system/src/main/resources/mapper/rider/RiderIncomeDetailMapper.xml
@@ -31,6 +31,9 @@
        <include refid="Base_Column_List"/>
        from qs_rider_income_detail
        <where>
            <if test="criteria.riderId != null">
                and rider_id = #{criteria.riderId}
            </if>
            <if test="criteria.riderName != null">
                and rider_name = #{criteria.riderName}
            </if>