|  |  |  | 
|---|
|  |  |  | package com.doumee.service.business.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONArray; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
|---|
|  |  |  | import com.doumee.config.wx.WxMiniConfig; | 
|---|
|  |  |  | import com.doumee.config.wx.WxMiniUtilService; | 
|---|
|  |  |  | import com.doumee.core.constants.Constants; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | import com.doumee.core.model.LoginUserInfo; | 
|---|
|  |  |  | import com.doumee.core.model.PageData; | 
|---|
|  |  |  | import com.doumee.core.model.PageWrap; | 
|---|
|  |  |  | import com.doumee.core.utils.DateUtil; | 
|---|
|  |  |  | import com.doumee.core.utils.GeoUtils; | 
|---|
|  |  |  | import com.doumee.core.utils.Utils; | 
|---|
|  |  |  | import com.doumee.dao.business.OrdersMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Orders; | 
|---|
|  |  |  | import com.doumee.dao.business.*; | 
|---|
|  |  |  | import com.doumee.dao.business.model.*; | 
|---|
|  |  |  | import com.doumee.dao.dto.*; | 
|---|
|  |  |  | import com.doumee.service.business.OrdersService; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.github.yulichang.wrapper.MPJLambdaWrapper; | 
|---|
|  |  |  | import com.wechat.pay.java.service.partnerpayments.jsapi.model.Amount; | 
|---|
|  |  |  | import com.wechat.pay.java.service.partnerpayments.jsapi.model.Payer; | 
|---|
|  |  |  | import com.wechat.pay.java.service.partnerpayments.jsapi.model.PrepayRequest; | 
|---|
|  |  |  | import com.wechat.pay.java.service.partnerpayments.jsapi.model.PrepayWithRequestPaymentResponse; | 
|---|
|  |  |  | import jodd.util.StringUtil; | 
|---|
|  |  |  | import nonapi.io.github.classgraph.json.Id; | 
|---|
|  |  |  | import org.apache.poi.sl.image.ImageHeaderEMF; | 
|---|
|  |  |  | import org.checkerframework.checker.units.qual.A; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.data.redis.core.RedisTemplate; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  | import org.springframework.util.CollectionUtils; | 
|---|
|  |  |  | import org.springframework.util.StringUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.math.BigDecimal; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Objects; | 
|---|
|  |  |  | import java.util.UUID; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 订单信息记录Service实现 | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrdersMapper ordersMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemDictDataBiz systemDictDataBiz; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CategoryMapper categoryMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MultifileMapper multifileMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrderLogMapper orderLogMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MemberMapper memberMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MemberRevenueMapper memberRevenueMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private IdentityInfoMapper identityInfoMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WxMiniUtilService wxMiniUtilService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Integer create(Orders orders) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) | 
|---|
|  |  |  | public Object create(Orders orders) { | 
|---|
|  |  |  | Object objects = null; | 
|---|
|  |  |  | this.initVerification(orders); | 
|---|
|  |  |  | orders.setCreateTime(new Date()); | 
|---|
|  |  |  | orders.setPayStatus(Constants.ZERO); | 
|---|
|  |  |  | //订单编号 | 
|---|
|  |  |  | orders.setCode(this.getNextCode(orders.getType())); | 
|---|
|  |  |  | Category category = categoryMapper.selectOne(new QueryWrapper<Category>().lambda() | 
|---|
|  |  |  | .eq(Category::getDeleted,Constants.ZERO).eq(Category::getType,Constants.THREE) | 
|---|
|  |  |  | .eq(Category::getName,orders.getType()) | 
|---|
|  |  |  | .last("limit 1") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(Objects.isNull(category)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"参数配置错误,请联系管理员"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //用餐订单 | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getType(),Constants.TWO)){ | 
|---|
|  |  |  | orders.setStatus(Constants.ZERO); | 
|---|
|  |  |  | //唤起支付业务 | 
|---|
|  |  |  | objects = this.getWxPayResponse(orders,orders.getMember().getOpenid()); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | orders.setStatus(Constants.ONE); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ordersMapper.insert(orders); | 
|---|
|  |  |  | return orders.getId(); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(orders.getMultifileList())){ | 
|---|
|  |  |  | List<Multifile> multifileList = orders.getMultifileList(); | 
|---|
|  |  |  | for (Multifile multifile:multifileList) { | 
|---|
|  |  |  | if(Objects.isNull(multifile) | 
|---|
|  |  |  | || Objects.isNull(multifile.getObjType()) | 
|---|
|  |  |  | || StringUtils.isEmpty(multifile.getFileurl()) | 
|---|
|  |  |  | || StringUtils.isEmpty(multifile.getName())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"附件信息错误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | multifile.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | multifile.setCreateDate(new Date()); | 
|---|
|  |  |  | multifile.setObjId(orders.getId()); | 
|---|
|  |  |  | multifile.setObjType(Constants.ONE); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | multifileMapper.insert(multifileList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //更新用户发单量 | 
|---|
|  |  |  | memberMapper.update(new UpdateWrapper<Member>().lambda().set(Member::getReceiveNum," (receive_num + 1 )").eq(Member::getId,orders.getMember().getId())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //创建操作日志 | 
|---|
|  |  |  | Constants.OrdersLog ordersLog = Constants.OrdersLog.UPLOAD; | 
|---|
|  |  |  | String orderTypeInfo = "用工单"; | 
|---|
|  |  |  | if(!Constants.equalsInteger(orders.getType(),Constants.ZERO)){ | 
|---|
|  |  |  | orderTypeInfo =   Constants.equalsInteger(orders.getType(),Constants.ONE)?"用车单":"送餐单"; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getWorkType(),Constants.ZERO)){ | 
|---|
|  |  |  | orderTypeInfo = orderTypeInfo + "-采摘工"; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | orderTypeInfo = orderTypeInfo + (Constants.equalsInteger(orders.getWorkType(),Constants.ONE)?"-分拣工":"-包装工"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String logInfo = ordersLog.getInfo() | 
|---|
|  |  |  | .replace("{param}",orderTypeInfo); | 
|---|
|  |  |  | this.saveOrderLog(orders,ordersLog, | 
|---|
|  |  |  | logInfo,orders.getReleaseMemberId(),null); | 
|---|
|  |  |  | return objects; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private Object getWxPayResponse(Orders orders,String openid){ | 
|---|
|  |  |  | Object response = null; | 
|---|
|  |  |  | //调起支付 | 
|---|
|  |  |  | PrepayRequest request = new PrepayRequest(); | 
|---|
|  |  |  | request.setAttach("createOrder"); | 
|---|
|  |  |  | request.setDescription("近快订单支付"); | 
|---|
|  |  |  | request.setSpMchid(WxMiniConfig.wxProperties.getMchId()); | 
|---|
|  |  |  | request.setSpAppid(WxMiniConfig.wxProperties.getAppId()); | 
|---|
|  |  |  | request.setSubMchid(WxMiniConfig.wxProperties.getSubMchId()); | 
|---|
|  |  |  | request.setSubAppid(WxMiniConfig.wxProperties.getSubAppId()); | 
|---|
|  |  |  | Payer payer = new Payer(); | 
|---|
|  |  |  | payer.setSubOpenid(openid); | 
|---|
|  |  |  | request.setPayer(payer); | 
|---|
|  |  |  | request.setOutTradeNo(orders.getCode()); | 
|---|
|  |  |  | request.setNotifyUrl(WxMiniConfig.wxProperties.getNotifyUrl());//这个回调url必须是https开头的 | 
|---|
|  |  |  | Amount amount = new Amount(); | 
|---|
|  |  |  | amount.setTotal(orders.getEstimatedAccount().intValue()); | 
|---|
|  |  |  | request.setAmount(amount); | 
|---|
|  |  |  | //        PrepayResponse res = WxMiniConfig.wxPayService.prepay(request); | 
|---|
|  |  |  | // 跟之前下单示例一样,填充预下单参数 | 
|---|
|  |  |  | PrepayWithRequestPaymentResponse resParam =  WxMiniConfig.jsapiExtService.prepayWithRequestPayment(request,WxMiniConfig.wxProperties.getSubAppId()); | 
|---|
|  |  |  | response =resParam; | 
|---|
|  |  |  | return response; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 日志信息 | 
|---|
|  |  |  | * @param orders 订单信息 | 
|---|
|  |  |  | * @param ordersLog 订单支持分类 | 
|---|
|  |  |  | * @param logInfo 日志内容 | 
|---|
|  |  |  | * @param memberId 移动端操作人 | 
|---|
|  |  |  | * @param userId 系统操作人 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public void saveOrderLog(Orders orders,Constants.OrdersLog ordersLog,String logInfo,Integer memberId,Integer userId){ | 
|---|
|  |  |  | OrderLog orderLog = new OrderLog(); | 
|---|
|  |  |  | orderLog.setCreateTime(orders.getUpdateTime()); | 
|---|
|  |  |  | orderLog.setDeleted(Constants.ZERO); | 
|---|
|  |  |  | orderLog.setOrderId(orders.getId()); | 
|---|
|  |  |  | orderLog.setTitle(ordersLog.getName()); | 
|---|
|  |  |  | orderLog.setLogInfo(logInfo); | 
|---|
|  |  |  | orderLog.setObjType(ordersLog.getKey()); | 
|---|
|  |  |  | orderLog.setOrderStatus(orders.getStatus()); | 
|---|
|  |  |  | orderLog.setMemberId(memberId); | 
|---|
|  |  |  | orderLog.setCreateUser(userId); | 
|---|
|  |  |  | orderLog.setOptUserType(ordersLog.getUserType()); | 
|---|
|  |  |  | orderLogMapper.insert(orderLog); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | || Objects.isNull(orders.getLat()) | 
|---|
|  |  |  | || Objects.isNull(orders.getLgt()) | 
|---|
|  |  |  | || Objects.isNull(orders.getCategoryId()) | 
|---|
|  |  |  | || Objects.isNull(orders.getTotalDays()) | 
|---|
|  |  |  | || (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Objects.isNull(orders.getWorkType())) | 
|---|
|  |  |  | || Objects.isNull(orders.getPriceNum1()) | 
|---|
|  |  |  | || (!( Constants.equalsInteger(orders.getType(),Constants.ZERO) | 
|---|
|  |  |  | && Constants.equalsInteger(orders.getWorkType(),Constants.TWO) ) && Objects.isNull(orders.getPrice()) ) | 
|---|
|  |  |  | || ( Constants.equalsInteger(orders.getType(),Constants.ONE) && Objects.isNull(orders.getTransportTypeId()) ) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | || Objects.isNull(orders.getEstimatedAccount()) | 
|---|
|  |  |  | || Objects.isNull(orders.getPrice()) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getType(),Constants.ONE)){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if((Constants.equalsInteger(orders.getType(),Constants.ZERO) && Constants.equalsInteger(orders.getWorkType(),Constants.ZERO )) | 
|---|
|  |  |  | || (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Constants.equalsInteger(orders.getWorkType(),Constants.TWO) | 
|---|
|  |  |  | &&Constants.equalsInteger(orders.getCarType(),Constants.TWO)) | 
|---|
|  |  |  | || Constants.equalsInteger(orders.getType(),Constants.ONE) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | orders.setPriceNum2(Constants.ONE); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(Objects.isNull(orders.getPriceNum2())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getWorkType(),Constants.TWO) | 
|---|
|  |  |  | && Objects.isNull(orders.getCarType())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else if(Constants.equalsInteger(orders.getType(),Constants.ONE)){ | 
|---|
|  |  |  | if(Objects.isNull(orders.getTransportTypeId()) | 
|---|
|  |  |  | || Objects.isNull(orders.getCarType()) | 
|---|
|  |  |  | || Objects.isNull(orders.getTransportNum()) | 
|---|
|  |  |  | || StringUtils.isEmpty(orders.getTransportUnit()) | 
|---|
|  |  |  | || StringUtils.isEmpty(orders.getLocationEnd()) | 
|---|
|  |  |  | || Objects.isNull(orders.getLatEnd()) | 
|---|
|  |  |  | || Objects.isNull(orders.getLgtEnd()) | 
|---|
|  |  |  | || CollectionUtils.isEmpty(orders.getWayInfoDTOList()) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (WayInfoDTO wayInfoDTO:orders.getWayInfoDTOList()) { | 
|---|
|  |  |  | if(Objects.isNull(wayInfoDTO) | 
|---|
|  |  |  | ||StringUtils.isEmpty(wayInfoDTO.getLocation()) | 
|---|
|  |  |  | ||StringUtils.isEmpty(wayInfoDTO.getProvince()) | 
|---|
|  |  |  | ||StringUtils.isEmpty(wayInfoDTO.getCity()) | 
|---|
|  |  |  | ||StringUtils.isEmpty(wayInfoDTO.getArea()) | 
|---|
|  |  |  | ||Objects.isNull(wayInfoDTO.getLat()) | 
|---|
|  |  |  | ||Objects.isNull(wayInfoDTO.getLgt()) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orders.setWayInfo(JSONObject.toJSONString(orders.getWayInfoDTOList())); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //用餐订单 | 
|---|
|  |  |  | if(CollectionUtils.isEmpty(orders.getCateringDTOList())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Long sumPrice = 0L; | 
|---|
|  |  |  | for (CateringDTO cateringDTO:orders.getCateringDTOList()) { | 
|---|
|  |  |  | if(Objects.isNull(cateringDTO) | 
|---|
|  |  |  | || StringUtils.isEmpty(cateringDTO.getName()) | 
|---|
|  |  |  | || Objects.isNull(cateringDTO.getPrice()) | 
|---|
|  |  |  | || Objects.isNull(cateringDTO.getNum()) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"用餐标准数据错误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | sumPrice = sumPrice + (cateringDTO.getPrice() * cateringDTO.getNum()) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!sumPrice.equals(orders.getPrice())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"单价计算错误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orders.setWayInfo(JSONObject.toJSONString(orders.getCateringDTOList())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!orders.getEstimatedAccount().equals(this.getTotal(orders))){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"金额计算错误!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public void updateById(Orders orders) { | 
|---|
|  |  |  | if(Objects.isNull(orders) | 
|---|
|  |  |  | || Objects.isNull(orders.getId())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Orders model = ordersMapper.selectById(orders.getId()); | 
|---|
|  |  |  | if(Constants.equalsInteger(model.getType(),Constants.TWO)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"此类订单无法进行修改"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!Constants.equalsInteger(model.getStatus(),Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | this.initVerification(orders); | 
|---|
|  |  |  | orders.setUpdateTime(new Date()); | 
|---|
|  |  |  | Category category = categoryMapper.selectOne(new QueryWrapper<Category>().lambda() | 
|---|
|  |  |  | .eq(Category::getDeleted,Constants.ZERO).eq(Category::getType,Constants.THREE) | 
|---|
|  |  |  | .eq(Category::getName,orders.getType()) | 
|---|
|  |  |  | .last("limit 1") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(Objects.isNull(category)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"参数配置错误,请联系管理员"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | multifileMapper.update(new UpdateWrapper<Multifile>().lambda().set(Multifile::getIsdeleted,Constants.ONE).eq(Multifile::getObjType,Constants.ONE) | 
|---|
|  |  |  | .eq(Multifile::getObjId,orders.getId())); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(orders.getMultifileList())){ | 
|---|
|  |  |  | List<Multifile> multifileList = orders.getMultifileList(); | 
|---|
|  |  |  | for (Multifile multifile:multifileList) { | 
|---|
|  |  |  | if(Objects.isNull(multifile) | 
|---|
|  |  |  | || Objects.isNull(multifile.getObjType()) | 
|---|
|  |  |  | || StringUtils.isEmpty(multifile.getFileurl()) | 
|---|
|  |  |  | || StringUtils.isEmpty(multifile.getName())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"附件信息错误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | multifile.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | multifile.setCreateDate(new Date()); | 
|---|
|  |  |  | multifile.setObjId(orders.getId()); | 
|---|
|  |  |  | multifile.setObjType(Constants.ONE); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | multifileMapper.insert(multifileList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ordersMapper.updateById(orders); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Orders findById(Integer id) { | 
|---|
|  |  |  | return ordersMapper.selectById(id); | 
|---|
|  |  |  | Orders orders = ordersMapper.selectJoinOne(Orders.class,new MPJLambdaWrapper<Orders>() | 
|---|
|  |  |  | .selectAll(Orders.class) | 
|---|
|  |  |  | .select(" m1.name " , Orders::getReleaseName) | 
|---|
|  |  |  | .select(" m1.telephone " , Orders::getReleasePhone) | 
|---|
|  |  |  | .select(" case when i.AUTH_TYPE = 0 then i.LINK_NAME else i.COMPANY_NAME end " , Orders::getAcceptName) | 
|---|
|  |  |  | .select(" i.TELEPHONE " , Orders::getAcceptPhone) | 
|---|
|  |  |  | .select("c1.name",Orders::getCategoryName) | 
|---|
|  |  |  | .select("c2.name",Orders::getTransportTypeName) | 
|---|
|  |  |  | .leftJoin(" category c1 on t.category_id = c1.id  ") | 
|---|
|  |  |  | .leftJoin(" category c2 on t.TRANSPORT_TYPE_ID = c2.id  ") | 
|---|
|  |  |  | .leftJoin("member m1 on t.RELEASE_MEMBER_ID = m1.id ") | 
|---|
|  |  |  | .leftJoin("member m2 on t.ACCEPT_MEMBER_ID = m2.id ") | 
|---|
|  |  |  | .leftJoin("identity_info i on m2.id = i.MEMBER_ID and i.TYPE = t.type and i.AUDIT_STATUS = 2  ") | 
|---|
|  |  |  | .eq(Orders::getDeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Orders::getId,id) | 
|---|
|  |  |  | .orderByDesc(Orders::getId)); | 
|---|
|  |  |  | if(Objects.isNull(orders)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //附件信息 | 
|---|
|  |  |  | List<Multifile> multifileList = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda().eq(Multifile::getObjId,orders.getId()) | 
|---|
|  |  |  | .eq(Multifile::getIsdeleted,Constants.ZERO).eq(Multifile::getObjType,Constants.ONE).orderByAsc(Multifile::getId)); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ | 
|---|
|  |  |  | String path  = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RESOURCE_PATH).getCode() | 
|---|
|  |  |  | +systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.ORDERS_FILES).getCode(); | 
|---|
|  |  |  | for (Multifile multifile:multifileList) { | 
|---|
|  |  |  | multifile.setFileurlFull(path + multifile.getFileurl()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orders.setMultifileList(multifileList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //订单流转记录 | 
|---|
|  |  |  | List<OrderLog> orderLogList = orderLogMapper.selectList(new QueryWrapper<OrderLog>().lambda() | 
|---|
|  |  |  | .eq(OrderLog::getDeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(OrderLog::getOrderId,orders.getId()) | 
|---|
|  |  |  | .orderByAsc(OrderLog::getCreateTime) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(orderLogList)){ | 
|---|
|  |  |  | for (OrderLog orderLog:orderLogList) { | 
|---|
|  |  |  | if(Constants.equalsInteger(orderLog.getOptUserType(),Constants.ZERO)){ | 
|---|
|  |  |  | orderLog.setLogInfo(orderLog.getLogInfo().replace("{userName}",orders.getReleaseName())); | 
|---|
|  |  |  | }else if(Constants.equalsInteger(orderLog.getOptUserType(),Constants.ONE)){ | 
|---|
|  |  |  | orderLog.setLogInfo(orderLog.getLogInfo().replace("{userName}",orders.getAcceptName())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orders.setOrderLogList(orderLogList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return orders; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public PageData<Orders> findPage(PageWrap<Orders> pageWrap) { | 
|---|
|  |  |  | IPage<Orders> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); | 
|---|
|  |  |  | QueryWrapper<Orders> queryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | MPJLambdaWrapper<Orders> queryWrapper = new MPJLambdaWrapper<Orders>(); | 
|---|
|  |  |  | Utils.MP.blankToNull(pageWrap.getModel()); | 
|---|
|  |  |  | if (pageWrap.getModel().getId() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getId, pageWrap.getModel().getId()); | 
|---|
|  |  |  | Orders model  = pageWrap.getModel(); | 
|---|
|  |  |  | queryWrapper.selectAll(Orders.class) | 
|---|
|  |  |  | .select(" m1.name " , Orders::getReleaseName) | 
|---|
|  |  |  | .select(" m1.telephone " , Orders::getReleasePhone) | 
|---|
|  |  |  | .select(" case when i.AUTH_TYPE = 0 then i.LINK_NAME else i.COMPANY_NAME end " , Orders::getAcceptName) | 
|---|
|  |  |  | .select(" i.TELEPHONE " , Orders::getAcceptPhone) | 
|---|
|  |  |  | .select("c1.name",Orders::getCategoryName) | 
|---|
|  |  |  | .select("c2.name",Orders::getTransportTypeName) | 
|---|
|  |  |  | .leftJoin(" category c1 on t.category_id = c1.id  ") | 
|---|
|  |  |  | .leftJoin(" category c2 on t.TRANSPORT_TYPE_ID = c2.id  ") | 
|---|
|  |  |  | .leftJoin("member m1 on t.RELEASE_MEMBER_ID = m1.id ") | 
|---|
|  |  |  | .leftJoin("member m2 on t.ACCEPT_MEMBER_ID = m2.id ") | 
|---|
|  |  |  | .leftJoin("identity_info i on m2.id = i.MEMBER_ID and i.TYPE = t.type and i.AUDIT_STATUS = 2  ") | 
|---|
|  |  |  | .eq(Orders::getDeleted,Constants.ZERO) | 
|---|
|  |  |  | .orderByDesc(Orders::getId) | 
|---|
|  |  |  | ; | 
|---|
|  |  |  | queryWrapper.ge(Objects.nonNull(model.getCreateTimeStart()),Orders::getCreateTime, Utils.Date.getStart(model.getCreateTimeStart())); | 
|---|
|  |  |  | queryWrapper.le(Objects.nonNull(model.getCreateTimeEnd()),Orders::getCreateTime, Utils.Date.getEnd(model.getCreateTimeEnd())); | 
|---|
|  |  |  | queryWrapper.ge(Objects.nonNull(model.getAcceptTimeStart()),Orders::getAcceptTime, Utils.Date.getStart(model.getAcceptTimeStart())); | 
|---|
|  |  |  | queryWrapper.le(Objects.nonNull(model.getAcceptTimeEnd()),Orders::getAcceptTime, Utils.Date.getEnd(model.getAcceptTimeEnd())); | 
|---|
|  |  |  | queryWrapper.ge(Objects.nonNull(model.getDoneTimeStart()),Orders::getFinishTime, Utils.Date.getStart(model.getDoneTimeStart())); | 
|---|
|  |  |  | queryWrapper.le(Objects.nonNull(model.getDoneTimeEnd()),Orders::getFinishTime, Utils.Date.getEnd(model.getDoneTimeEnd())); | 
|---|
|  |  |  | queryWrapper.like(org.apache.commons.lang3.StringUtils.isNotBlank(model.getCode()),Orders::getCode, model.getCode()); | 
|---|
|  |  |  | queryWrapper.eq(Objects.nonNull(model.getType()),Orders::getType, model.getType()); | 
|---|
|  |  |  | queryWrapper.eq(Objects.nonNull(model.getStatus()),Orders::getStatus, model.getStatus()); | 
|---|
|  |  |  | queryWrapper.eq(Objects.nonNull(model.getAcceptType()),Orders::getAcceptType, model.getAcceptType()); | 
|---|
|  |  |  | queryWrapper.like(org.apache.commons.lang3.StringUtils.isNotBlank(model.getReleaseName()),"m1.name", model.getReleaseName()); | 
|---|
|  |  |  | queryWrapper.apply(org.apache.commons.lang3.StringUtils.isNotBlank(model.getAcceptName())," i.LINK_NAME like '%"+model.getAcceptName()+"%' or i.company_name like '%"+model.getAcceptName()+"%' "); | 
|---|
|  |  |  | IPage<Orders> iPage = ordersMapper.selectJoinPage(page,Orders.class,queryWrapper); | 
|---|
|  |  |  | for (Orders orders:iPage.getRecords()) { | 
|---|
|  |  |  | this.getOrderContent(orders); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getDeleted() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getDeleted, pageWrap.getModel().getDeleted()); | 
|---|
|  |  |  | return PageData.from(iPage); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void getOrderContent(Orders orders){ | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ | 
|---|
|  |  |  | orders.setOrderContent(Constants.workType.getName(orders.getWorkType()) +" | " + orders.getCategoryName()); | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getWorkType(),Constants.ZERO)){ | 
|---|
|  |  |  | orders.setOrderContent(orders.getOrderContent()+" | " +orders.getPriceNum1()+"斤"); | 
|---|
|  |  |  | }else if(Constants.equalsInteger(orders.getWorkType(),Constants.ONE)){ | 
|---|
|  |  |  | orders.setOrderContent(orders.getOrderContent()+" | " +orders.getPriceNum2()+"人"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getCarType(),Constants.ZERO)||Constants.equalsInteger(orders.getCarType(),Constants.ONE)){ | 
|---|
|  |  |  | orders.setOrderContent(orders.getOrderContent()+" | " +orders.getPriceNum2()+"人"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | orders.setOrderContent(orders.getOrderContent()+" | " +orders.getPriceNum1()+"斤"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else if(Constants.equalsInteger(orders.getType(),Constants.ONE)){ | 
|---|
|  |  |  | orders.setOrderContent(  orders.getCategoryName() + " | " + orders.getTransportTypeName() +" | " + orders.getTransportNum() +"斤"); | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getCarType(),Constants.ZERO)){ | 
|---|
|  |  |  | orders.setOrderContent(orders.getOrderContent()+" | 用车" +orders.getPriceNum2()+"天"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | orders.setOrderContent(orders.getOrderContent()+" | 用车" +orders.getPriceNum2()+"次"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | if(org.apache.commons.lang3.StringUtils.isNotBlank(orders.getWayInfo())){ | 
|---|
|  |  |  | List<CateringDTO> cateringDTOList = JSONArray.parseArray(orders.getWayInfo(),CateringDTO.class); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(cateringDTOList)){ | 
|---|
|  |  |  | for (CateringDTO cateringDTO:cateringDTOList) { | 
|---|
|  |  |  | if(StringUtils.isEmpty(orders.getOrderContent())){ | 
|---|
|  |  |  | orders.setOrderContent(cateringDTO.getName()+cateringDTO.getPrice()+" 需"+cateringDTO.getNum()+"份"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | orders.setOrderContent(orders.getOrderContent()+" | "+cateringDTO.getName()+cateringDTO.getPrice()+" 需"+cateringDTO.getNum()+"份"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCreateUser() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getCreateUser, pageWrap.getModel().getCreateUser()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public long count(Orders orders) { | 
|---|
|  |  |  | QueryWrapper<Orders> wrapper = new QueryWrapper<>(orders); | 
|---|
|  |  |  | return ordersMapper.selectCount(wrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 手动接单 | 
|---|
|  |  |  | * @param orderId | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public void accept(Integer orderId,Member member){ | 
|---|
|  |  |  | Orders orders = ordersMapper.selectById(orderId); | 
|---|
|  |  |  | if(Objects.isNull(orders)||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCreateTime() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().ge(Orders::getCreateTime, Utils.Date.getStart(pageWrap.getModel().getCreateTime())); | 
|---|
|  |  |  | queryWrapper.lambda().le(Orders::getCreateTime, Utils.Date.getEnd(pageWrap.getModel().getCreateTime())); | 
|---|
|  |  |  | if(!Constants.equalsInteger(orders.getStatus(),Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getUpdateUser() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getUpdateUser, pageWrap.getModel().getUpdateUser()); | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getReleaseMemberId(),member.getId())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"您自己的订单无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getUpdateTime() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().ge(Orders::getUpdateTime, Utils.Date.getStart(pageWrap.getModel().getUpdateTime())); | 
|---|
|  |  |  | queryWrapper.lambda().le(Orders::getUpdateTime, Utils.Date.getEnd(pageWrap.getModel().getUpdateTime())); | 
|---|
|  |  |  | //查询用户是否有对应身份 | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ | 
|---|
|  |  |  | if(!Constants.equalsInteger(member.getWorkerIdentity(),Constants.TWO)){ | 
|---|
|  |  |  | 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(),"身份信息异常,请联系管理员"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | if(!Constants.equalsInteger(member.getChefIdentity(),Constants.TWO)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"身份信息异常,请联系管理员"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getRemark() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getRemark, pageWrap.getModel().getRemark()); | 
|---|
|  |  |  | orders.setUpdateTime(new Date()); | 
|---|
|  |  |  | orders.setAcceptType(Constants.ZERO); | 
|---|
|  |  |  | orders.setAcceptTime(new Date()); | 
|---|
|  |  |  | orders.setAcceptMemberId(member.getId()); | 
|---|
|  |  |  | orders.setStatus(Constants.TWO); | 
|---|
|  |  |  | ordersMapper.updateById(orders); | 
|---|
|  |  |  | //更新接单量 | 
|---|
|  |  |  | memberMapper.update(new UpdateWrapper<Member>().lambda().set(Member::getPublishNum," (publish_num + 1 )").eq(Member::getId,member.getId())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //创建操作日志 | 
|---|
|  |  |  | Constants.OrdersLog ordersLog = Constants.OrdersLog.RECEIVE; | 
|---|
|  |  |  | this.saveOrderLog(orders,ordersLog, | 
|---|
|  |  |  | ordersLog.getInfo(),member.getId(),null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //TODO 微信公众号提醒 已接单提醒 | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 开始作业 | 
|---|
|  |  |  | * @param orderId | 
|---|
|  |  |  | * @param member | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public void begin(Integer orderId,Member member){ | 
|---|
|  |  |  | Orders orders = ordersMapper.selectById(orderId); | 
|---|
|  |  |  | if(Objects.isNull(orders)||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getReleaseMemberId() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getReleaseMemberId, pageWrap.getModel().getReleaseMemberId()); | 
|---|
|  |  |  | if(!Constants.equalsInteger(orders.getStatus(),Constants.TWO)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getType() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getType, pageWrap.getModel().getType()); | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getReleaseMemberId(),member.getId())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getStartDate() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().ge(Orders::getStartDate, Utils.Date.getStart(pageWrap.getModel().getStartDate())); | 
|---|
|  |  |  | queryWrapper.lambda().le(Orders::getStartDate, Utils.Date.getEnd(pageWrap.getModel().getStartDate())); | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getIsUpdate(),Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单修改待确认,无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getEndDate() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().ge(Orders::getEndDate, Utils.Date.getStart(pageWrap.getModel().getEndDate())); | 
|---|
|  |  |  | queryWrapper.lambda().le(Orders::getEndDate, Utils.Date.getEnd(pageWrap.getModel().getEndDate())); | 
|---|
|  |  |  | orders.setUpdateTime(new Date()); | 
|---|
|  |  |  | orders.setStatus(Constants.THREE); | 
|---|
|  |  |  | orders.setWorkStartTime(new Date()); | 
|---|
|  |  |  | ordersMapper.updateById(orders); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //创建操作日志 | 
|---|
|  |  |  | Constants.OrdersLog ordersLog = Constants.OrdersLog.BEGIN; | 
|---|
|  |  |  | this.saveOrderLog(orders,ordersLog, | 
|---|
|  |  |  | ordersLog.getInfo(),member.getId(),null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 发单方修改订单 - 已接单状态 | 
|---|
|  |  |  | * @param updOrderDataDTO | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public void updOrderData(UpdOrderDataDTO updOrderDataDTO){ | 
|---|
|  |  |  | if(Objects.isNull(updOrderDataDTO) | 
|---|
|  |  |  | || Objects.isNull(updOrderDataDTO.getOrderId()) | 
|---|
|  |  |  | || Objects.isNull(updOrderDataDTO.getStartDate()) | 
|---|
|  |  |  | || Objects.isNull(updOrderDataDTO.getEndDate()) | 
|---|
|  |  |  | || Objects.isNull(updOrderDataDTO.getTotalDays())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getLocation() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getLocation, pageWrap.getModel().getLocation()); | 
|---|
|  |  |  | Orders orders = ordersMapper.selectById(updOrderDataDTO.getOrderId()); | 
|---|
|  |  |  | if(Objects.isNull(orders)||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getLocationRemark() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getLocationRemark, pageWrap.getModel().getLocationRemark()); | 
|---|
|  |  |  | if(!Constants.equalsInteger(orders.getStatus(),Constants.TWO)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getLat() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getLat, pageWrap.getModel().getLat()); | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getReleaseMemberId(),updOrderDataDTO.getMember().getId())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getProvince() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getProvince, pageWrap.getModel().getProvince()); | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getIsUpdate(),Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单已修改,待接单方确认,无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCity() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getCity, pageWrap.getModel().getCity()); | 
|---|
|  |  |  | orders.setStartDate(updOrderDataDTO.getStartDate()); | 
|---|
|  |  |  | orders.setEndDate(updOrderDataDTO.getEndDate()); | 
|---|
|  |  |  | orders.setTotalDays(updOrderDataDTO.getTotalDays()); | 
|---|
|  |  |  | //用车类型 | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getType(),Constants.ONE)){ | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getCarType(),Constants.ZERO)) { | 
|---|
|  |  |  | orders.setPriceNum1(updOrderDataDTO.getTotalDays()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getWorkType(),Constants.ONE)||(Constants.equalsInteger(orders.getWorkType(),Constants.TWO)&&Constants.equalsInteger(orders.getCarType(),Constants.ZERO))){ | 
|---|
|  |  |  | orders.setPriceNum1(updOrderDataDTO.getTotalDays()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | orders.setPriceNum1(updOrderDataDTO.getTotalDays()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getArea() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getArea, pageWrap.getModel().getArea()); | 
|---|
|  |  |  | Long total = this.getTotal(orders); | 
|---|
|  |  |  | ordersMapper.update(new UpdateWrapper<Orders>().lambda() | 
|---|
|  |  |  | .set(Orders::getStartDate,updOrderDataDTO.getStartDate()) | 
|---|
|  |  |  | .set(Orders::getEndDate,updOrderDataDTO.getEndDate()) | 
|---|
|  |  |  | .set(Orders::getTotalDays,updOrderDataDTO.getTotalDays()) | 
|---|
|  |  |  | .set(Orders::getIsUpdate,Constants.ONE) | 
|---|
|  |  |  | .set(Orders::getUpdateTime,"now()") | 
|---|
|  |  |  | .set(Orders::getEstimatedAccount,total) | 
|---|
|  |  |  | .eq(Orders::getId,orders.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | //创建操作日志 | 
|---|
|  |  |  | Constants.OrdersLog ordersLog = Constants.OrdersLog.UPD_ORDER; | 
|---|
|  |  |  | this.saveOrderLog(orders,ordersLog, | 
|---|
|  |  |  | ordersLog.getInfo(),updOrderDataDTO.getMember().getId(),null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //TODO 通知接单人 订单发生变更 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Long getTotal(Orders orders){ | 
|---|
|  |  |  | if( | 
|---|
|  |  |  | (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Constants.equalsInteger(orders.getWorkType(),Constants.ZERO )) || | 
|---|
|  |  |  | (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Constants.equalsInteger(orders.getWorkType(),Constants.TWO) | 
|---|
|  |  |  | &&Constants.equalsInteger(orders.getCarType(),Constants.TWO)) | 
|---|
|  |  |  | || Constants.equalsInteger(orders.getType(),Constants.ONE) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | orders.setPriceNum2(Constants.ONE); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getLgt() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getLgt, pageWrap.getModel().getLgt()); | 
|---|
|  |  |  | return orders.getPrice() * orders.getPriceNum1() * orders.getPriceNum2(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 接单方处理订单修改 | 
|---|
|  |  |  | * @param confirmUpdOrderDTO | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public void confirmUpd(ConfirmUpdOrderDTO confirmUpdOrderDTO){ | 
|---|
|  |  |  | if(Objects.isNull(confirmUpdOrderDTO) | 
|---|
|  |  |  | || Objects.isNull(confirmUpdOrderDTO.getOrderId()) | 
|---|
|  |  |  | || Objects.isNull(confirmUpdOrderDTO.getStatus()) | 
|---|
|  |  |  | || !(Constants.equalsInteger(confirmUpdOrderDTO.getStatus(),Constants.ONE)|| | 
|---|
|  |  |  | Constants.equalsInteger(confirmUpdOrderDTO.getStatus(),Constants.ZERO)) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCategoryId() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getCategoryId, pageWrap.getModel().getCategoryId()); | 
|---|
|  |  |  | Orders orders = ordersMapper.selectById(confirmUpdOrderDTO.getOrderId()); | 
|---|
|  |  |  | if(Objects.isNull(orders)||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getWorkType() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getWorkType, pageWrap.getModel().getWorkType()); | 
|---|
|  |  |  | if(!Constants.equalsInteger(orders.getStatus(),Constants.TWO)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getPriceNum1() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getPriceNum1, pageWrap.getModel().getPriceNum1()); | 
|---|
|  |  |  | if(!Constants.equalsInteger(orders.getIsUpdate(),Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单修改状态已流转,无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getPriceNum2() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getPriceNum2, pageWrap.getModel().getPriceNum2()); | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getAcceptMemberId(),confirmUpdOrderDTO.getMember().getId())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getSupplement() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getSupplement, pageWrap.getModel().getSupplement()); | 
|---|
|  |  |  | if( Constants.equalsInteger(confirmUpdOrderDTO.getStatus(),Constants.ONE)){ | 
|---|
|  |  |  | ordersMapper.update(new UpdateWrapper<Orders>().lambda() | 
|---|
|  |  |  | .set(Orders::getIsUpdate,Constants.TWO) | 
|---|
|  |  |  | .set(Orders::getUpdateTime,"now()") | 
|---|
|  |  |  | .eq(Orders::getId,orders.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | //记录同意修改的日志 | 
|---|
|  |  |  | Constants.OrdersLog ordersLog = Constants.OrdersLog.UPD_AGREE; | 
|---|
|  |  |  | this.saveOrderLog(orders,ordersLog, | 
|---|
|  |  |  | ordersLog.getInfo(),confirmUpdOrderDTO.getMember().getId(),null); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | ordersMapper.update(new UpdateWrapper<Orders>().lambda() | 
|---|
|  |  |  | .set(Orders::getIsUpdate,Constants.TWO) | 
|---|
|  |  |  | .set(Orders::getUpdateTime,"now()") | 
|---|
|  |  |  | .set(Orders::getStatus,Constants.ONE) | 
|---|
|  |  |  | .set(Orders::getAcceptMemberId,null) | 
|---|
|  |  |  | .set(Orders::getAcceptType,null) | 
|---|
|  |  |  | .eq(Orders::getId,orders.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | memberMapper.update(new UpdateWrapper<Member>().lambda().set(Member::getReceiveNum,"receive_num - 1").eq(Member::getId,confirmUpdOrderDTO.getMember().getId())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //记录不同意修改的日志 | 
|---|
|  |  |  | Constants.OrdersLog ordersLog = Constants.OrdersLog.UPD_DISAGREE; | 
|---|
|  |  |  | this.saveOrderLog(orders,ordersLog, | 
|---|
|  |  |  | ordersLog.getInfo(),confirmUpdOrderDTO.getMember().getId(),null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //TODO 发送不同意变更通知 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getPrice() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getPrice, pageWrap.getModel().getPrice()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 发单方取消订单 | 
|---|
|  |  |  | * @param orderId | 
|---|
|  |  |  | * @param member | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public void releaseCancelOrder(Integer orderId,Member member){ | 
|---|
|  |  |  | Orders orders = ordersMapper.selectById(orderId); | 
|---|
|  |  |  | if(Objects.isNull(orders)||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getEstimatedAccount() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getEstimatedAccount, pageWrap.getModel().getEstimatedAccount()); | 
|---|
|  |  |  | if(!(Constants.equalsInteger(orders.getStatus(),Constants.ONE) | 
|---|
|  |  |  | ||Constants.equalsInteger(orders.getStatus(),Constants.ZERO) | 
|---|
|  |  |  | || Constants.equalsInteger(orders.getStatus(),Constants.TWO))){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行取消"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getPayAccount() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getPayAccount, pageWrap.getModel().getPayAccount()); | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getReleaseMemberId(),member.getId())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getPriceRemark() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getPriceRemark, pageWrap.getModel().getPriceRemark()); | 
|---|
|  |  |  | //待支付用餐订单/待接单订单进行取消 | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getStatus(),Constants.ONE) | 
|---|
|  |  |  | ||Constants.equalsInteger(orders.getStatus(),Constants.ZERO)){ | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getType(),Constants.TWO)&&Constants.equalsInteger(orders.getStatus(),Constants.ONE)){ | 
|---|
|  |  |  | //退款业务 | 
|---|
|  |  |  | WithdrawalOrders  withdrawalOrders = new WithdrawalOrders(); | 
|---|
|  |  |  | withdrawalOrders.setCreateTime(new Date()); | 
|---|
|  |  |  | withdrawalOrders.setMemberId(orders.getReleaseMemberId()); | 
|---|
|  |  |  | withdrawalOrders.setAmount(orders.getPayAccount()); | 
|---|
|  |  |  | withdrawalOrders.setWxExternalNo("refund_"+orders.getCode()); | 
|---|
|  |  |  | withdrawalOrders.setStatus(Constants.ONE); | 
|---|
|  |  |  | withdrawalOrders.setDoneTime(new Date()); | 
|---|
|  |  |  | withdrawalOrders.setType(Constants.ONE); | 
|---|
|  |  |  | withdrawalOrders.setObjId(orders.getId()); | 
|---|
|  |  |  | wxMiniUtilService.wxRefund(withdrawalOrders,orders); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ordersMapper.update(new UpdateWrapper<Orders>().lambda() | 
|---|
|  |  |  | .set(Orders::getStatus,99) | 
|---|
|  |  |  | .set(Orders::getUpdateTime,"now()") | 
|---|
|  |  |  | .set(Orders::getCancelTime,"now()") | 
|---|
|  |  |  | .set(Orders::getCancelType,Constants.ZERO) | 
|---|
|  |  |  | .eq(Orders::getId,orders.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //判断是否可修改 已取消次数 与 时间限制 | 
|---|
|  |  |  | Integer totalCancelTimes = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RELEASE_CANCEL_TIMES).getCode()); | 
|---|
|  |  |  | Long cancelTimes = ordersMapper.selectCount(new QueryWrapper<Orders>().lambda() | 
|---|
|  |  |  | .apply(" DATE(cancel_time) = DATE(NOW()) ") | 
|---|
|  |  |  | .eq(Orders::getStatus,99) | 
|---|
|  |  |  | .eq(Orders::getReleaseMemberId,orders.getReleaseMemberId())); | 
|---|
|  |  |  | //查询取消次数 | 
|---|
|  |  |  | if(totalCancelTimes<=cancelTimes){ | 
|---|
|  |  |  | 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+"小时,无法取消订单,如需处理请联系客服"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getType(),Constants.TWO)){ | 
|---|
|  |  |  | //退款业务 | 
|---|
|  |  |  | WithdrawalOrders  withdrawalOrders = new WithdrawalOrders(); | 
|---|
|  |  |  | withdrawalOrders.setCreateTime(new Date()); | 
|---|
|  |  |  | withdrawalOrders.setMemberId(orders.getReleaseMemberId()); | 
|---|
|  |  |  | withdrawalOrders.setAmount(orders.getPayAccount()); | 
|---|
|  |  |  | withdrawalOrders.setWxExternalNo("refund_"+orders.getCode()); | 
|---|
|  |  |  | withdrawalOrders.setStatus(Constants.ONE); | 
|---|
|  |  |  | withdrawalOrders.setDoneTime(new Date()); | 
|---|
|  |  |  | withdrawalOrders.setType(Constants.ONE); | 
|---|
|  |  |  | withdrawalOrders.setObjId(orders.getId()); | 
|---|
|  |  |  | wxMiniUtilService.wxRefund(withdrawalOrders,orders); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ordersMapper.update(new UpdateWrapper<Orders>().lambda() | 
|---|
|  |  |  | .set(Orders::getStatus,99) | 
|---|
|  |  |  | .set(Orders::getUpdateTime,"now()") | 
|---|
|  |  |  | .set(Orders::getCancelTime,"now()") | 
|---|
|  |  |  | .set(Orders::getCancelType,Constants.ONE) | 
|---|
|  |  |  | .eq(Orders::getId,orders.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | //TODO 发单方取消订单通知接单方 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //减少接单量 | 
|---|
|  |  |  | memberMapper.update(new UpdateWrapper<Member>().lambda().set(Member::getReceiveNum,"receive_num - 1").eq(Member::getId,orders.getAcceptMemberId())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCarType() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getCarType, pageWrap.getModel().getCarType()); | 
|---|
|  |  |  | //减少发单量 | 
|---|
|  |  |  | memberMapper.update(new UpdateWrapper<Member>().lambda().set(Member::getPublishNum,"publish_num - 1").eq(Member::getId,orders.getReleaseMemberId())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //日志存储 | 
|---|
|  |  |  | Constants.OrdersLog ordersLog = Constants.OrdersLog.RELEASE_CANCEL; | 
|---|
|  |  |  | this.saveOrderLog(orders,ordersLog, | 
|---|
|  |  |  | ordersLog.getInfo(),member.getId(),null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 接单方取消接单 | 
|---|
|  |  |  | * @param orderId | 
|---|
|  |  |  | * @param member | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public void receiveCancelOrder(Integer orderId,Member member){ | 
|---|
|  |  |  | Orders orders = ordersMapper.selectById(orderId); | 
|---|
|  |  |  | if(Objects.isNull(orders)||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getTransportTypeId() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getTransportTypeId, pageWrap.getModel().getTransportTypeId()); | 
|---|
|  |  |  | if(!Constants.equalsInteger(orders.getStatus(),Constants.TWO)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行取消"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getTransportNum() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getTransportNum, pageWrap.getModel().getTransportNum()); | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getAcceptMemberId(),member.getId())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getTransportUnit() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getTransportUnit, pageWrap.getModel().getTransportUnit()); | 
|---|
|  |  |  | //判断是否可修改 已取消次数 与 时间限制 | 
|---|
|  |  |  | Integer totalCancelTimes = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RECEIVE_CANCEL_TIMES).getCode()); | 
|---|
|  |  |  | Long cancelTimes = orderLogMapper.selectCount(new QueryWrapper<OrderLog>().lambda() | 
|---|
|  |  |  | .apply(" DATE(create_time) = DATE(NOW()) ") | 
|---|
|  |  |  | .eq(OrderLog::getObjType,Constants.OrdersLog.CANCEL.getKey()) | 
|---|
|  |  |  | .eq(OrderLog::getMemberId,member.getId())); | 
|---|
|  |  |  | //查询取消次数 | 
|---|
|  |  |  | if(totalCancelTimes<=cancelTimes){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"今日订单主动取消次数已超出"+totalCancelTimes+"次,无法取消订单,如需处理请联系客服"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getLocationEnd() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getLocationEnd, pageWrap.getModel().getLocationEnd()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Integer cancelTimeHour = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RECEIVE_CANCEL_TIME).getCode()); | 
|---|
|  |  |  | Long hours = DateUtil.getBetweenHours(new Date(),orders.getStartDate()); | 
|---|
|  |  |  | if(hours < cancelTimeHour){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"距离订单开始时间不足"+cancelTimeHour+"小时,无法取消订单,如需处理请联系客服"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getLatEnd() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getLatEnd, pageWrap.getModel().getLatEnd()); | 
|---|
|  |  |  | ordersMapper.update(new UpdateWrapper<Orders>().lambda() | 
|---|
|  |  |  | .set(Orders::getUpdateTime,"now()") | 
|---|
|  |  |  | .set(Orders::getStatus,Constants.ONE) | 
|---|
|  |  |  | .set(Orders::getAcceptMemberId,null) | 
|---|
|  |  |  | .set(Orders::getAcceptType,null) | 
|---|
|  |  |  | .eq(Orders::getId,orders.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //减少接单量 | 
|---|
|  |  |  | memberMapper.update(new UpdateWrapper<Member>().lambda().set(Member::getReceiveNum,"receive_num - 1").eq(Member::getId,orders.getAcceptMemberId())); | 
|---|
|  |  |  | //日志存储 | 
|---|
|  |  |  | Constants.OrdersLog ordersLog = Constants.OrdersLog.CANCEL; | 
|---|
|  |  |  | this.saveOrderLog(orders,ordersLog, | 
|---|
|  |  |  | ordersLog.getInfo(),member.getId(),null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //TODO 接单方取消订单通知 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 完成订单 | 
|---|
|  |  |  | * @param doneOrderDTO | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public Object doneOrder(DoneOrderDTO doneOrderDTO){ | 
|---|
|  |  |  | if(Objects.isNull(doneOrderDTO)||Objects.isNull(doneOrderDTO.getOrderId())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getLgtEnd() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getLgtEnd, pageWrap.getModel().getLgtEnd()); | 
|---|
|  |  |  | Orders orders = ordersMapper.selectById(doneOrderDTO.getOrderId()); | 
|---|
|  |  |  | if(!Constants.equalsInteger(orders.getType(),Constants.TWO)&&Objects.isNull(doneOrderDTO.getAmount())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getWayInfo() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getWayInfo, pageWrap.getModel().getWayInfo()); | 
|---|
|  |  |  | if(Objects.isNull(orders)||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCode() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getCode, pageWrap.getModel().getCode()); | 
|---|
|  |  |  | if(!Constants.equalsInteger(orders.getStatus(),Constants.THREE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行取消"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getStatus() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getStatus, pageWrap.getModel().getStatus()); | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getReleaseMemberId(),doneOrderDTO.getMember().getId())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getAcceptTime() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().ge(Orders::getAcceptTime, Utils.Date.getStart(pageWrap.getModel().getAcceptTime())); | 
|---|
|  |  |  | queryWrapper.lambda().le(Orders::getAcceptTime, Utils.Date.getEnd(pageWrap.getModel().getAcceptTime())); | 
|---|
|  |  |  | Object object = null; | 
|---|
|  |  |  | //用餐订单 | 
|---|
|  |  |  | if(!Constants.equalsInteger(orders.getType(),Constants.TWO)){ | 
|---|
|  |  |  | orders.setPayAccount(doneOrderDTO.getAmount()); | 
|---|
|  |  |  | //提成金额 | 
|---|
|  |  |  | Long tcje = Long.valueOf(new BigDecimal(orders.getPayAccount().toString()).multiply(orders.getPlatformRata()).intValue()); | 
|---|
|  |  |  | orders.setReceiveAccount(orders.getPayAccount() - tcje); | 
|---|
|  |  |  | ordersMapper.updateById(orders); | 
|---|
|  |  |  | //唤起支付业务 | 
|---|
|  |  |  | object = this.getWxPayResponse(orders,orders.getMember().getOpenid()); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | orders.setStatus(Constants.FOUR); | 
|---|
|  |  |  | //日志存储 | 
|---|
|  |  |  | Constants.OrdersLog ordersLog = Constants.OrdersLog.DONE; | 
|---|
|  |  |  | this.saveOrderLog(orders,ordersLog, | 
|---|
|  |  |  | ordersLog.getInfo(),doneOrderDTO.getMember().getId(),null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getAcceptMemberId() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getAcceptMemberId, pageWrap.getModel().getAcceptMemberId()); | 
|---|
|  |  |  | return object; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public void platformCancel(Integer orderId, LoginUserInfo loginUserInfo){ | 
|---|
|  |  |  | Orders orders = ordersMapper.selectById(orderId); | 
|---|
|  |  |  | if(Objects.isNull(orders)||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getAcceptType() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getAcceptType, pageWrap.getModel().getAcceptType()); | 
|---|
|  |  |  | if(!(Constants.equalsInteger(orders.getStatus(),Constants.ONE)||Constants.equalsInteger(orders.getStatus(),Constants.TWO) | 
|---|
|  |  |  | ||Constants.equalsInteger(orders.getStatus(),Constants.THREE))){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行取消"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getWorkStartTime() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().ge(Orders::getWorkStartTime, Utils.Date.getStart(pageWrap.getModel().getWorkStartTime())); | 
|---|
|  |  |  | queryWrapper.lambda().le(Orders::getWorkStartTime, Utils.Date.getEnd(pageWrap.getModel().getWorkStartTime())); | 
|---|
|  |  |  | //如果已支付 则需要进行退款 | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getPayStatus(),Constants.ONE)){ | 
|---|
|  |  |  | WithdrawalOrders  withdrawalOrders = new WithdrawalOrders(); | 
|---|
|  |  |  | withdrawalOrders.setCreateTime(new Date()); | 
|---|
|  |  |  | withdrawalOrders.setMemberId(orders.getReleaseMemberId()); | 
|---|
|  |  |  | withdrawalOrders.setAmount(orders.getPayAccount()); | 
|---|
|  |  |  | withdrawalOrders.setWxExternalNo("refund_"+orders.getCode()); | 
|---|
|  |  |  | withdrawalOrders.setStatus(Constants.ONE); | 
|---|
|  |  |  | withdrawalOrders.setDoneTime(new Date()); | 
|---|
|  |  |  | withdrawalOrders.setType(Constants.ONE); | 
|---|
|  |  |  | withdrawalOrders.setObjId(orders.getId()); | 
|---|
|  |  |  | wxMiniUtilService.wxRefund(withdrawalOrders,orders); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getFinishTime() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().ge(Orders::getFinishTime, Utils.Date.getStart(pageWrap.getModel().getFinishTime())); | 
|---|
|  |  |  | queryWrapper.lambda().le(Orders::getFinishTime, Utils.Date.getEnd(pageWrap.getModel().getFinishTime())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //减少发单量 | 
|---|
|  |  |  | memberMapper.update(new UpdateWrapper<Member>().lambda().set(Member::getPublishNum,"publish_num - 1").eq(Member::getId,orders.getReleaseMemberId())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getStatus(),Constants.TWO)||Constants.equalsInteger(orders.getStatus(),Constants.THREE)){ | 
|---|
|  |  |  | //减少接单量 | 
|---|
|  |  |  | memberMapper.update(new UpdateWrapper<Member>().lambda().set(Member::getReceiveNum,"receive_num - 1").eq(Member::getId,orders.getAcceptMemberId())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getPlatformRata() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getPlatformRata, pageWrap.getModel().getPlatformRata()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ordersMapper.update(new UpdateWrapper<Orders>().lambda() | 
|---|
|  |  |  | .set(Orders::getStatus,99) | 
|---|
|  |  |  | .set(Orders::getUpdateTime,"now()") | 
|---|
|  |  |  | .set(Orders::getCancelTime,"now()") | 
|---|
|  |  |  | .set(Orders::getCancelType,Constants.TWO) | 
|---|
|  |  |  | .eq(Orders::getId,orders.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //日志存储 | 
|---|
|  |  |  | Constants.OrdersLog ordersLog = Constants.OrdersLog.SYSTEM_CANCEL; | 
|---|
|  |  |  | this.saveOrderLog(orders,ordersLog, | 
|---|
|  |  |  | ordersLog.getInfo(),null,loginUserInfo.getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void comment(CommentDTO commentDTO){ | 
|---|
|  |  |  | if(Objects.isNull(commentDTO) | 
|---|
|  |  |  | || Objects.isNull(commentDTO.getOrderId()) | 
|---|
|  |  |  | || Objects.isNull(commentDTO.getLevel()) | 
|---|
|  |  |  | || commentDTO.getLevel()<1 || commentDTO.getLevel() > 5 ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getWxExternalNo() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getWxExternalNo, pageWrap.getModel().getWxExternalNo()); | 
|---|
|  |  |  | Orders orders = ordersMapper.selectById(commentDTO.getOrderId()); | 
|---|
|  |  |  | if(Objects.isNull(orders) | 
|---|
|  |  |  | ||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCommentStatus() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getCommentStatus, pageWrap.getModel().getCommentStatus()); | 
|---|
|  |  |  | if(!Constants.equalsInteger(orders.getStatus(),Constants.FOUR)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行评价"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCommentInfo() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getCommentInfo, pageWrap.getModel().getCommentInfo()); | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getCommentStatus(),Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单已评价!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCommentLevel() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getCommentLevel, pageWrap.getModel().getCommentLevel()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ordersMapper.update(new UpdateWrapper<Orders>().lambda() | 
|---|
|  |  |  | .set(Orders::getCommentStatus,Constants.ONE) | 
|---|
|  |  |  | .set(Orders::getUpdateTime,"now()") | 
|---|
|  |  |  | .set(Orders::getCommentTime,"now()") | 
|---|
|  |  |  | .set(Orders::getCommentLevel,commentDTO.getLevel()) | 
|---|
|  |  |  | .set(Orders::getCommentType,Constants.ZERO) | 
|---|
|  |  |  | .eq(Orders::getId,orders.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | memberMapper.update(new UpdateWrapper<Member>().lambda() | 
|---|
|  |  |  | .set(Member::getScore," ( total_score +" + commentDTO.getLevel() + " ) / (score_order_num + 1 )") | 
|---|
|  |  |  | .set(Member::getTotalScore," total_score +" + commentDTO.getLevel()) | 
|---|
|  |  |  | .set(Member::getScoreOrderNum," score_order_num + 1 " ).eq(Member::getId,orders.getAcceptMemberId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //日志存储 | 
|---|
|  |  |  | Constants.OrdersLog ordersLog = Constants.OrdersLog.COMMENT; | 
|---|
|  |  |  | this.saveOrderLog(orders,ordersLog, | 
|---|
|  |  |  | ordersLog.getInfo(),orders.getAcceptMemberId(),null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 支付回调 | 
|---|
|  |  |  | * @param preOrderId | 
|---|
|  |  |  | * @param paymentNo | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public String payNotify(String preOrderId,String paymentNo){ | 
|---|
|  |  |  | Orders orders = ordersMapper.selectOne(new QueryWrapper<Orders>().lambda().eq(Orders::getCode,preOrderId).last("limit 1")); | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getType(),Constants.TWO)){ | 
|---|
|  |  |  | //用餐订单  如果已经流转到已支付  则直接返回 | 
|---|
|  |  |  | if(!Constants.equalsInteger(orders.getStatus(),Constants.ZERO)){ | 
|---|
|  |  |  | return  ("处理成功!"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //处理支付完成逻辑 | 
|---|
|  |  |  | ordersMapper.update(new UpdateWrapper<Orders>().lambda() | 
|---|
|  |  |  | .set(Orders::getUpdateTime,"now()") | 
|---|
|  |  |  | .set(Orders::getStatus,Constants.ONE) | 
|---|
|  |  |  | .set(Orders::getPayStatus,Constants.ONE) | 
|---|
|  |  |  | .set(Orders::getWxExternalNo,paymentNo) | 
|---|
|  |  |  | .eq(Orders::getId,orders.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //存储日志 | 
|---|
|  |  |  | Constants.OrdersLog ordersLog = Constants.OrdersLog.PAY; | 
|---|
|  |  |  | this.saveOrderLog(orders,ordersLog, | 
|---|
|  |  |  | ordersLog.getInfo(),orders.getReleaseMemberId(),null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //非用餐类订单 | 
|---|
|  |  |  | if(!Constants.equalsInteger(orders.getStatus(),Constants.THREE)){ | 
|---|
|  |  |  | return  ("处理成功!"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //处理支付完成逻辑 | 
|---|
|  |  |  | ordersMapper.update(new UpdateWrapper<Orders>().lambda() | 
|---|
|  |  |  | .set(Orders::getUpdateTime,"now()") | 
|---|
|  |  |  | .set(Orders::getStatus,Constants.FOUR) | 
|---|
|  |  |  | .set(Orders::getPayStatus,Constants.ONE) | 
|---|
|  |  |  | .set(Orders::getWxExternalNo,paymentNo) | 
|---|
|  |  |  | .set(Orders::getFinishTime,"now()") | 
|---|
|  |  |  | .eq(Orders::getId,orders.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Member member = memberMapper.selectById(orders.getAcceptMemberId()); | 
|---|
|  |  |  | //存储流水记录 | 
|---|
|  |  |  | MemberRevenue memberRevenue = new MemberRevenue(); | 
|---|
|  |  |  | memberRevenue.setCreateTime(new Date()); | 
|---|
|  |  |  | memberRevenue.setMemberId(orders.getAcceptMemberId()); | 
|---|
|  |  |  | memberRevenue.setType(orders.getType()); | 
|---|
|  |  |  | memberRevenue.setOptType(Constants.ONE); | 
|---|
|  |  |  | memberRevenue.setBeforeAmount(member.getAmount()); | 
|---|
|  |  |  | memberRevenue.setAmount(orders.getReceiveAccount()); | 
|---|
|  |  |  | memberRevenue.setAfterAmount(member.getAmount() + orders.getReceiveAccount()); | 
|---|
|  |  |  | memberRevenue.setObjId(orders.getId()); | 
|---|
|  |  |  | memberRevenue.setObjType(Constants.ZERO); | 
|---|
|  |  |  | memberRevenue.setStatus(Constants.ZERO); | 
|---|
|  |  |  | memberRevenueMapper.insert(memberRevenue); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //更新接单用户的余额与历史总金额 | 
|---|
|  |  |  | memberMapper.update(new UpdateWrapper<Member>().lambda() | 
|---|
|  |  |  | .set(Member::getAmount,"amount + " + orders.getReceiveAccount() ) | 
|---|
|  |  |  | .set(Member::getTotalAmount,"amount + " + orders.getReceiveAccount() ) | 
|---|
|  |  |  | .eq(Member::getId,member.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //存储日志 | 
|---|
|  |  |  | Constants.OrdersLog ordersLog = Constants.OrdersLog.PAY; | 
|---|
|  |  |  | this.saveOrderLog(orders,ordersLog, | 
|---|
|  |  |  | ordersLog.getInfo(),orders.getReleaseMemberId(),null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //TODO 通知接单方 款项已到账 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCommentTime() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().ge(Orders::getCommentTime, Utils.Date.getStart(pageWrap.getModel().getCommentTime())); | 
|---|
|  |  |  | queryWrapper.lambda().le(Orders::getCommentTime, Utils.Date.getEnd(pageWrap.getModel().getCommentTime())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCommentType() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getCommentType, pageWrap.getModel().getCommentType()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCancelTime() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().ge(Orders::getCancelTime, Utils.Date.getStart(pageWrap.getModel().getCancelTime())); | 
|---|
|  |  |  | queryWrapper.lambda().le(Orders::getCancelTime, Utils.Date.getEnd(pageWrap.getModel().getCancelTime())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getIsUpdate() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(Orders::getIsUpdate, pageWrap.getModel().getIsUpdate()); | 
|---|
|  |  |  | return  ("处理成功!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public PageData<Orders> findPageForMini(PageWrap<Orders> pageWrap) { | 
|---|
|  |  |  | IPage<Orders> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); | 
|---|
|  |  |  | MPJLambdaWrapper<Orders> queryWrapper = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  | Utils.MP.blankToNull(pageWrap.getModel()); | 
|---|
|  |  |  | Orders model = pageWrap.getModel(); | 
|---|
|  |  |  | queryWrapper.selectAll(Orders.class) | 
|---|
|  |  |  | .select("c1.name",Orders::getCategoryName) | 
|---|
|  |  |  | .select("c2.name",Orders::getTransportTypeName) | 
|---|
|  |  |  | .leftJoin(" category c1 on t.category_id = c1.id  ") | 
|---|
|  |  |  | .leftJoin(" category c2 on t.TRANSPORT_TYPE_ID = c2.id  "); | 
|---|
|  |  |  | if(Objects.nonNull(model.getQueryMyOrderType())){ | 
|---|
|  |  |  | if(Constants.equalsInteger(model.getQueryMyOrderType(),Constants.ZERO)){ | 
|---|
|  |  |  | //发单方 我的订单 | 
|---|
|  |  |  | queryWrapper.eq(Orders::getReleaseMemberId,model.getMember().getId()); | 
|---|
|  |  |  | }else if(Constants.equalsInteger(model.getQueryMyOrderType(),Constants.ONE)){ | 
|---|
|  |  |  | //接单方 我的订单 | 
|---|
|  |  |  | queryWrapper.eq(Orders::getAcceptMemberId,model.getMember().getId()); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //接单大厅 | 
|---|
|  |  |  | queryWrapper.and(i-> | 
|---|
|  |  |  | i.eq(Constants.equalsInteger(model.getMember().getWorkerIdentity(),Constants.TWO),Orders::getType,Constants.ZERO) | 
|---|
|  |  |  | .or() | 
|---|
|  |  |  | .eq(Constants.equalsInteger(model.getMember().getDriverIdentity(),Constants.TWO),Orders::getType,Constants.ONE) | 
|---|
|  |  |  | .or() | 
|---|
|  |  |  | .eq(Constants.equalsInteger(model.getMember().getChefIdentity(),Constants.TWO),Orders::getType,Constants.TWO) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | queryWrapper.eq(Orders::getStatus,Constants.ONE); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for(PageWrap.SortData sortData: pageWrap.getSorts()) { | 
|---|
|  |  |  | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { | 
|---|
|  |  |  | 
|---|
|  |  |  | queryWrapper.orderByAsc(sortData.getProperty()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return PageData.from(ordersMapper.selectPage(page, queryWrapper)); | 
|---|
|  |  |  | IPage<Orders> iPage = ordersMapper.selectJoinPage(page,Orders.class,queryWrapper); | 
|---|
|  |  |  | if(Objects.nonNull(model.getQueryMyOrderType())&&Constants.equalsInteger(model.getQueryMyOrderType(),Constants.TWO)){ | 
|---|
|  |  |  | if(Constants.equalsInteger(model.getMember().getUseIdentity(),Constants.ONE)){ | 
|---|
|  |  |  | model.getMember().setWorkerIdentityModel( | 
|---|
|  |  |  | identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() | 
|---|
|  |  |  | .eq(IdentityInfo::getMemberId,model.getMember().getId()) | 
|---|
|  |  |  | .eq(IdentityInfo::getType,Constants.ZERO) | 
|---|
|  |  |  | .eq(IdentityInfo::getAuditStatus,Constants.TWO) | 
|---|
|  |  |  | .last("limit 1") | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | model.getMember().setDriverIdentityModel( | 
|---|
|  |  |  | identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() | 
|---|
|  |  |  | .eq(IdentityInfo::getMemberId,model.getMember().getId()) | 
|---|
|  |  |  | .eq(IdentityInfo::getType,Constants.ONE) | 
|---|
|  |  |  | .eq(IdentityInfo::getAuditStatus,Constants.TWO) | 
|---|
|  |  |  | .last("limit 1") | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | model.getMember().setChefIdentityModel( | 
|---|
|  |  |  | identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() | 
|---|
|  |  |  | .eq(IdentityInfo::getMemberId,model.getMember().getId()) | 
|---|
|  |  |  | .eq(IdentityInfo::getType,Constants.TWO) | 
|---|
|  |  |  | .eq(IdentityInfo::getAuditStatus,Constants.TWO) | 
|---|
|  |  |  | .last("limit 1") | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (Orders orders:iPage.getRecords()) { | 
|---|
|  |  |  | this.getDistance(model.getMember(),orders); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return PageData.from(iPage); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public long count(Orders orders) { | 
|---|
|  |  |  | QueryWrapper<Orders> wrapper = new QueryWrapper<>(orders); | 
|---|
|  |  |  | return ordersMapper.selectCount(wrapper); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //定位距离 | 
|---|
|  |  |  | public void getDistance(Member member,Orders orders){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ | 
|---|
|  |  |  | if(Objects.nonNull(member.getWorkerIdentityModel())&&Objects.nonNull(member.getWorkerIdentityModel().getLgt()) | 
|---|
|  |  |  | &&Objects.nonNull(member.getWorkerIdentityModel().getLat())){ | 
|---|
|  |  |  | orders.setDistance( | 
|---|
|  |  |  | GeoUtils.haversineDistance( | 
|---|
|  |  |  | orders.getLgt().doubleValue(),orders.getLat().doubleValue(), | 
|---|
|  |  |  | member.getWorkerIdentityModel().getLgt().doubleValue(), | 
|---|
|  |  |  | member.getWorkerIdentityModel().getLat().doubleValue() | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }else if(Constants.equalsInteger(orders.getType(),Constants.ONE)){ | 
|---|
|  |  |  | if(Objects.nonNull(member.getDriverIdentityModel())&&Objects.nonNull(member.getDriverIdentityModel().getLgt()) | 
|---|
|  |  |  | &&Objects.nonNull(member.getDriverIdentityModel().getLat())) { | 
|---|
|  |  |  | orders.setDistance( | 
|---|
|  |  |  | GeoUtils.haversineDistance( | 
|---|
|  |  |  | orders.getLgt().doubleValue(), orders.getLat().doubleValue(), | 
|---|
|  |  |  | member.getDriverIdentityModel().getLgt().doubleValue(), | 
|---|
|  |  |  | member.getDriverIdentityModel().getLat().doubleValue() | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | if(Objects.nonNull(member.getChefIdentityModel())&&Objects.nonNull(member.getChefIdentityModel().getLgt()) | 
|---|
|  |  |  | &&Objects.nonNull(member.getChefIdentityModel().getLat())) { | 
|---|
|  |  |  | orders.setDistance( | 
|---|
|  |  |  | GeoUtils.haversineDistance( | 
|---|
|  |  |  | orders.getLgt().doubleValue(),orders.getLat().doubleValue(), | 
|---|
|  |  |  | member.getChefIdentityModel().getLgt().doubleValue(), | 
|---|
|  |  |  | member.getChefIdentityModel().getLat().doubleValue() | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Orders getDetail(Integer id,Integer userType) { | 
|---|
|  |  |  | Orders orders = ordersMapper.selectJoinOne(Orders.class,new MPJLambdaWrapper<Orders>() | 
|---|
|  |  |  | .selectAll(Orders.class) | 
|---|
|  |  |  | .select("c1.name",Orders::getCategoryName) | 
|---|
|  |  |  | .select("c2.name",Orders::getTransportTypeName) | 
|---|
|  |  |  | .leftJoin(" category c1 on t.category_id = c1.id  ") | 
|---|
|  |  |  | .leftJoin(" category c2 on t.TRANSPORT_TYPE_ID = c2.id  ") | 
|---|
|  |  |  | .eq(Orders::getId,id) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(Objects.isNull(orders)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Objects.nonNull(userType)){ | 
|---|
|  |  |  | Member member = memberMapper.selectById( | 
|---|
|  |  |  | Constants.equalsInteger(userType,Constants.ZERO)?orders.getReleaseMemberId():orders.getAcceptMemberId() | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(Objects.nonNull(member)){ | 
|---|
|  |  |  | if(org.apache.commons.lang3.StringUtils.isNotBlank(member.getCoverImage())){ | 
|---|
|  |  |  | //头像信息 | 
|---|
|  |  |  | String path  = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RESOURCE_PATH).getCode() | 
|---|
|  |  |  | +systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.MEMBER_FILES).getCode(); | 
|---|
|  |  |  | member.setFullCoverImage(path + member.getCoverImage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orders.setMember(member); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Multifile> multifileList = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda().eq(Multifile::getObjId,orders.getId()) | 
|---|
|  |  |  | .eq(Multifile::getIsdeleted,Constants.ZERO).eq(Multifile::getObjType,Constants.ONE).orderByAsc(Multifile::getId)); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ | 
|---|
|  |  |  | String path  = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RESOURCE_PATH).getCode() | 
|---|
|  |  |  | +systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.ORDERS_FILES).getCode(); | 
|---|
|  |  |  | for (Multifile multifile:multifileList) { | 
|---|
|  |  |  | multifile.setFileurlFull(path + multifile.getFileurl()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orders.setMultifileList(multifileList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return orders; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public synchronized String  getNextCode(Integer type){ | 
|---|
|  |  |  | //        String prefix = "YG"; | 
|---|
|  |  |  | //        if(!Constants.equalsInteger(type,Constants.ZERO)){ | 
|---|
|  |  |  | //            prefix = (Constants.equalsInteger(type,Constants.ONE)?"YC-":"SC-"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        prefix =  DateUtil.getDate(new Date(),"yyyyMMdd") +"-"; | 
|---|
|  |  |  | //        Integer countNum  = RedisUtil.getObject(redisTemplate, Constants.RedisKeys.ORDER_CODE, Integer.class); | 
|---|
|  |  |  | //        countNum = Constants.formatIntegerNum(countNum)+1; | 
|---|
|  |  |  | //        //更新缓存 | 
|---|
|  |  |  | //        RedisUtil.addObject(redisTemplate,Constants.RedisKeys.ORDER_CODE,countNum); | 
|---|
|  |  |  | //        String nextIndex =Integer.toString( countNum ); | 
|---|
|  |  |  | //        return prefix + org.apache.commons.lang3.StringUtils.leftPad(nextIndex,3,"0"); | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|