111
rk
2025-08-27 367281413e2120cb9192a2ec9ecbc49c4331b6af
server/services/src/main/java/com/doumee/service/business/impl/OrdersServiceImpl.java
@@ -33,6 +33,7 @@
import com.wechat.pay.java.service.refund.model.RefundNotification;
import jodd.util.StringUtil;
import lombok.With;
import lombok.extern.slf4j.Slf4j;
import nonapi.io.github.classgraph.json.Id;
import org.apache.poi.sl.image.ImageHeaderEMF;
import org.checkerframework.checker.units.qual.A;
@@ -54,6 +55,7 @@
 * @author 江蹄蹄
 * @date 2025/07/09 12:00
 */
@Slf4j
@Service
public class OrdersServiceImpl implements OrdersService {
@@ -297,6 +299,12 @@
            }
            orders.setWayInfo(JSONObject.toJSONString(orders.getWayInfoDTOList()));
        }else{
            List<Category> categoryList = categoryMapper.selectList(new QueryWrapper<Category>().lambda().eq(Category::getDeleted,Constants.ZERO)
                    .eq(Category::getType,Constants.TWO)
            );
            if(CollectionUtils.isEmpty(categoryList)){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"餐标信息错误");
            }
            //用餐订单
            if(CollectionUtils.isEmpty(orders.getCateringDTOList())){
                throw new BusinessException(ResponseStatus.BAD_REQUEST);
@@ -309,6 +317,19 @@
                        || Objects.isNull(cateringDTO.getNum())
                ){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"用餐标准数据错误");
                }
                //餐标信息
                List<Category> categories = categoryList.stream().filter(i->Constants.equalsInteger(i.getId(),cateringDTO.getId())).collect(Collectors.toList());
                if(CollectionUtils.isEmpty(categories)){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"用餐标准数据错误,请刷新重试");
                }
                Category category = categories.get(Constants.ZERO);
                List<String> priceList = JSONArray.parseArray(category.getDetail(),String.class  );
                if(CollectionUtils.isEmpty(priceList)){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"用餐标准数据错误,请刷新重试");
                }
                if(priceList.stream().filter(i->((Long.valueOf(i)*100)+"").equals((cateringDTO.getPrice()+""))).collect(Collectors.toList()).size()==Constants.ZERO){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"用餐标准数据错误,请刷新重试");
                }
                sumPrice = sumPrice + (cateringDTO.getPrice() * cateringDTO.getNum()) ;
            }
@@ -474,9 +495,9 @@
        );
        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(orderLogList)){
            for (OrderLog orderLog:orderLogList) {
                if(Constants.equalsInteger(orderLog.getOptUserType(),Constants.ZERO)){
                if(Constants.equalsInteger(orderLog.getOptUserType(),Constants.ZERO)&& org.apache.commons.lang3.StringUtils.isNotBlank(orders.getReleaseName())){
                    orderLog.setLogInfo(orderLog.getLogInfo().replace("{userName}",orders.getReleaseName()));
                }else if(Constants.equalsInteger(orderLog.getOptUserType(),Constants.ONE)){
                }else if(Constants.equalsInteger(orderLog.getOptUserType(),Constants.ONE)&& org.apache.commons.lang3.StringUtils.isNotBlank(orders.getAcceptName())){
                    orderLog.setLogInfo(orderLog.getLogInfo().replace("{userName}",orders.getAcceptName()));
                }
            }
@@ -651,15 +672,15 @@
        //查询用户是否有对应身份
        if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){
            if(!Constants.equalsInteger(member.getWorkerIdentity(),Constants.TWO)){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"身份信息异常,请前往个人中心进行身份认证!");
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"您还未注册该服务,请前往个人信息中提交申请。");
            }
        }else if(Constants.equalsInteger(orders.getType(),Constants.ONE)){
            if(!Constants.equalsInteger(member.getDriverIdentity(),Constants.TWO)){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"身份信息异常,请前往个人中心进行身份认证!");
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"您还未注册该服务,请前往个人信息中提交申请。");
            }
        }else{
            if(!Constants.equalsInteger(member.getChefIdentity(),Constants.TWO)){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"身份信息异常,请前往个人中心进行身份认证!");
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"您还未注册该服务,请前往个人信息中提交申请。");
            }
        }
@@ -911,13 +932,13 @@
                .eq(Orders::getReleaseMemberId,member.getId()));
        //查询取消次数
        if(totalCancelTimes<=cancelTimes){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"今日订单主动取消次数已超出"+totalCancelTimes+"次,无法取消订单,如需处理请联系客服");
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"今日订单主动取消次数已超出"+totalCancelTimes+"次,无法取消订单");
        }
        Integer cancelTimeHour = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RELEASE_CANCEL_TIME).getCode());
        Long hours = DateUtil.getBetweenHours(new Date(),orders.getStartDate());
        if(hours < cancelTimeHour){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"距离订单开始时间不足"+cancelTimeHour+"小时,无法取消订单,如需处理请联系客服");
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"距离订单开始时间不足"+cancelTimeHour+"小时,无法取消订单");
        }
        return  "今日还可主动取消"+(totalCancelTimes-cancelTimes)+"次,是否确认取消";
@@ -1761,8 +1782,9 @@
     */
    @Override
    public void autoGrabOrders(){
        log.error("滴滴滴滴");
        String autoConfirmTime = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.AUTO_DISPATCH).getCode();
        List<Orders> ordersList = ordersMapper.selectList(new QueryWrapper<Orders>().lambda()
        List<Orders> ordersList = ordersMapper.selectList(new QueryWrapper<Orders>().lambda().eq(Orders::getDeleted,Constants.ZERO)
                .eq(Orders::getStatus,Constants.ONE).eq(Orders::getCommentStatus,Constants.ZERO)
                .apply(" DATE_ADD(create_time, INTERVAL "+autoConfirmTime+" MINUTE) < now() ")
                .last("limit 100")
@@ -1771,9 +1793,10 @@
            BigDecimal lat = orders.getLat();
            BigDecimal lgt = orders.getLgt();
            //查询范围内的会员
            List<Member> memberList = memberMapper.selectList(new MPJLambdaWrapper<Member>().selectAll(Member.class)
                            .select(" ifnull((select r.level from receive_weight r where r.RECEIVE_MAX > t.RECEIVE_NUM and t.RECEIVE_NUM > r.RECEIVE_MIN limit 1  ),0) " ,Member::getLevel)
                            .select(  " ifnull( (select CONVERT( ST_Distance_Sphere ( POINT ( ii.lgt, ii.lat ), POINT ( "+lgt+", "+lat+" )) /1000,DECIMAL(15,2)) from identity_info ii where ii.AUDIT_STATUS = 2 and type = 0 and ii.member_id = t.ID limit  1 ),0) ",Member::getDistance )
            List<Member> memberList = memberMapper.selectList(new MPJLambdaWrapper<Member>()
                    .selectAll(Member.class)
                            .select(" ifnull((select r.level from receive_weight r where r.RECEIVE_MAX > RECEIVE_NUM and RECEIVE_NUM > r.RECEIVE_MIN limit 1  ),0) " ,Member::getLevel)
                            .select(  " ifnull( (select CONVERT( ST_Distance_Sphere ( POINT ( ii.lgt, ii.lat ), POINT ( "+lgt+", "+lat+" )) /1000,DECIMAL(15,2)) from identity_info ii where ii.AUDIT_STATUS = 2 and type = 0 and ii.member_id = ID limit  1 ),0) ",Member::getDistance )
                    .apply(" id in (" +
                            " select ii.member_id from identity_info ii where ii.AUDIT_STATUS = 2 and type = '"+orders.getType()+"' " +
@@ -1804,7 +1827,7 @@
            );
            //更新接单量
            memberMapper.update(new UpdateWrapper<Member>().lambda().setSql(" publish_num = (ifnull(publish_num,0) + 1 )").eq(Member::getId,member.getId()));
            memberMapper.update(new UpdateWrapper<Member>().lambda().setSql(" RECEIVE_NUM = (ifnull(RECEIVE_NUM,0) + 1 )").eq(Member::getId,member.getId()));
            //创建操作日志
            Constants.OrdersLog ordersLog = Constants.OrdersLog.AUTO;