| package com.xzx.gc.order.service; | 
|   | 
| import cn.hutool.core.bean.BeanUtil; | 
| import cn.hutool.core.codec.Base64; | 
| import cn.hutool.core.collection.CollUtil; | 
| import cn.hutool.core.comparator.PropertyComparator; | 
| import cn.hutool.core.convert.Convert; | 
| import cn.hutool.core.date.DateTime; | 
| import cn.hutool.core.date.DateUnit; | 
| import cn.hutool.core.date.DateUtil; | 
| import cn.hutool.core.lang.Dict; | 
| import cn.hutool.core.map.MapUtil; | 
| import cn.hutool.core.text.StrBuilder; | 
| import cn.hutool.core.util.NumberUtil; | 
| import cn.hutool.core.util.StrUtil; | 
| import cn.hutool.json.JSONUtil; | 
| import com.github.pagehelper.PageHelper; | 
| import com.github.pagehelper.PageInfo; | 
| import com.xzx.gc.common.Result; | 
| import com.xzx.gc.common.constant.*; | 
| import com.xzx.gc.common.dto.gdmap.CommonTraceDto; | 
| import com.xzx.gc.common.dto.gdmap.GdReverseGEODto; | 
| import com.xzx.gc.common.dto.log.OrderOperationInfo; | 
| import com.xzx.gc.common.exception.RestException; | 
| import com.xzx.gc.common.utils.*; | 
| import com.xzx.gc.common.utils.ali.SmsUtil; | 
| import com.xzx.gc.common.utils.gdmap.GdMapUtil; | 
| import com.xzx.gc.common.utils.gdmap.GdTraceUtil; | 
| import com.xzx.gc.entity.*; | 
| import com.xzx.gc.model.JsonResult; | 
| import com.xzx.gc.model.SmsDto; | 
| import com.xzx.gc.model.admin.OrderModel; | 
| import com.xzx.gc.model.admin.OrderOperationLogModel; | 
| import com.xzx.gc.model.admin.SysAddressLevelModel; | 
| import com.xzx.gc.model.admin.UserModel; | 
| import com.xzx.gc.model.comon.account.AllAcountParamDto; | 
| import com.xzx.gc.model.order.*; | 
| import com.xzx.gc.model.system.ConfigInfoReq; | 
| import com.xzx.gc.model.system.ConfigInfoVo; | 
| import com.xzx.gc.model.user.*; | 
| import com.xzx.gc.order.dto.*; | 
| import com.xzx.gc.order.mapper.*; | 
| import com.xzx.gc.service.AccountContext; | 
| import com.xzx.gc.util.DoubleUtil; | 
| import lombok.extern.slf4j.Slf4j; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.context.annotation.Lazy; | 
| import org.springframework.core.env.Environment; | 
| import org.springframework.core.env.Profiles; | 
| import org.springframework.scheduling.annotation.Async; | 
| import org.springframework.scheduling.annotation.Scheduled; | 
| import org.springframework.stereotype.Service; | 
| import org.springframework.transaction.annotation.Transactional; | 
| import org.springframework.util.CollectionUtils; | 
| import tk.mybatis.mapper.entity.Example; | 
|   | 
| import java.math.BigDecimal; | 
| import java.util.*; | 
| import java.util.stream.Collectors; | 
|   | 
| @Service | 
| @Transactional | 
| @Slf4j | 
| public class OrderService { | 
|   | 
|     @Autowired | 
|     private CommissionsService commissionsService; | 
|   | 
|     @Autowired | 
|     private OrderMapper orderMapper; | 
|   | 
|     @Autowired | 
|     private JGPushUtil jgPushUtil; | 
|   | 
|   | 
|     @Autowired | 
|     private AddressService addressService; | 
|   | 
|     @Autowired | 
|     private FenceService fenceService; | 
|   | 
|     @Autowired | 
|     private OrderItemService orderItemService; | 
|   | 
|     @Autowired | 
|     private AddressLevelService addressLevelService; | 
|   | 
|     @Autowired | 
|     private PayInfoService payInfoService; | 
|   | 
|     @Autowired | 
|     private OrderComplaintService orderComplaintService; | 
|   | 
|     @Autowired | 
|     private AccountLogMapper accountLogMapper; | 
|   | 
|     @Autowired | 
|     private PartnerTraceService partnerTraceService; | 
|   | 
|     @Autowired | 
|     private PartnerFenceService partnerFenceService; | 
|   | 
|     @Autowired | 
|     private PayInfoMapper payInfoMapper; | 
|   | 
|   | 
|     @Autowired | 
|     private OtherUserService otherUserService; | 
|   | 
|     @Autowired | 
|     private OrderDetailMapper orderDetailMapper; | 
|   | 
|     @Autowired | 
|     private AccountMapper accountMapper; | 
|   | 
|   | 
|     @Autowired | 
|     private SysMessageMapper sysMessageMapper; | 
|   | 
|   | 
|     @Autowired | 
|     private RedisUtil redisUtil; | 
|   | 
|     @Autowired | 
|     private OtherUserMapper otherUserMapper; | 
|   | 
|     @Autowired | 
|     private OrderAppraiseInfoService orderAppraiseInfoService; | 
|   | 
|     @Autowired | 
|     private ConfigService configService; | 
|   | 
|     @Autowired | 
|     private UserTargetInfoMapper userTargetInfoMapper; | 
|   | 
|     @Autowired | 
|     private javax.servlet.http.HttpServletRequest request; | 
|   | 
|     @Autowired | 
|     private UserMapper userMapper; | 
|   | 
|   | 
|     @Autowired | 
|     private UserService userService; | 
|   | 
|   | 
|     @Autowired | 
|     private AddressMapper addressMapper; | 
|   | 
|   | 
|     @Autowired | 
|     private StairRebateService stairRebateService; | 
|   | 
|     @Autowired | 
|     private IdUtils idUtils; | 
|   | 
|     @Autowired | 
|     private BusinessUtil businessUtil; | 
|   | 
|     @Autowired | 
|     private ConfigMapper configMapper; | 
|   | 
|     @Autowired | 
|     private Environment environment; | 
|   | 
|     @Autowired | 
|     private CityPartnerService cityPartnerService; | 
|   | 
|   | 
|     @Autowired | 
|     private ReceiveClockMapper receiveClockMapper; | 
|   | 
|     @Autowired | 
|     private SysStorageService sysStorageService; | 
|   | 
|   | 
|     @Autowired | 
|     private ShareRebateService shareRebateService; | 
|   | 
|     @Autowired | 
|     private WeightRebateService weightRebateService; | 
|   | 
|     @Autowired | 
|     private PartnerAccountLogService partnerAccountLogService; | 
|   | 
|     @Autowired | 
|     private PartnerAccountService partnerAccountService; | 
|   | 
|   | 
|     @Autowired | 
|     private AccountLogService accountLogService; | 
|   | 
|     @Autowired | 
|     @Lazy | 
|     private RuleService ruleService; | 
|   | 
|     @Autowired | 
|     private OrderDetailService orderDetailService; | 
|   | 
|   | 
|     @Autowired | 
|     private AccountService accountService; | 
|   | 
|     @Autowired | 
|     private SysEnvironmentalInfoService sysEnvironmentalInfoService; | 
|   | 
|     @Autowired | 
|     private OrderStorageService orderStorageService; | 
|   | 
|     @Autowired | 
|     private PartnerConfigService partnerConfigService; | 
|   | 
|     @Autowired | 
|     private HomeServiceInfoService homeServiceInfoService; | 
|   | 
|     @Autowired | 
|     private UserScrapStoreMapper userScrapStoreMapper; | 
|   | 
|     @Autowired | 
|     private PlatformAccountInfoService platformAccountInfoService; | 
|   | 
|     @Autowired | 
|     private AccountScoreLogMapper accountScoreLogMapper; | 
|     @Autowired | 
|     private PlatformAccountLogService platformAccountLogService; | 
|   | 
|     @Autowired | 
|     private OrderHomeApplianceService orderHomeApplianceService; | 
|   | 
|   | 
|   | 
|     public OrderReserveResDto getReserveTimeNew(OrderReserveResDto orderReserveResDto, String partnerId) { | 
|         List<PartnerConfig> orderTime = partnerConfigService.findValueByPartnerAndGroup(partnerId, SysConfigConstant.ORDER_TIME, true); | 
|         String timeInterval = "0"; | 
|         if (!CollectionUtils.isEmpty(orderTime)) { | 
|             for (PartnerConfig configInfo : orderTime) { | 
|                 if (configInfo.getConfigCode().equals(SysConfigConstant.INTERVAL_TIME)) { | 
|                     //小时 | 
|                     timeInterval = configInfo.getConfigValue(); | 
|                 } else if (configInfo.getConfigCode().equals(SysConfigConstant.START_TIME)) { | 
|                     orderReserveResDto.setStartTime(configInfo.getConfigValue()); | 
|                 } else if (configInfo.getConfigCode().equals(SysConfigConstant.END_TIME)) { | 
|                     orderReserveResDto.setEndTime(configInfo.getConfigValue()); | 
|                 } | 
|             } | 
|             //获取时间间隔后的时间 | 
|             String reserveTime = DateUtil.offsetHour(new Date(), Convert.toInt(timeInterval,0)).toString(DateUtils.DATE_FORMAT_YMDHMS); | 
|             orderReserveResDto.setReserveTime(reserveTime); | 
|         } | 
|         return orderReserveResDto; | 
|     } | 
|   | 
|   | 
|     public int findOrderCountByCreateUserId(String createUserId) { | 
|         Example example = new Example(OrderInfo.class); | 
|         example.createCriteria().andEqualTo("createUserId", createUserId) | 
|                 .andEqualTo("orderType", OrderEnum.回收.getValue()).andEqualTo("orderStatus", OrderEnum.待接单.getValue()); | 
|         return orderMapper.selectCountByExample(example); | 
|     } | 
|   | 
|     public int findGatherOrderCountByCreateUserId(String createUserId) { | 
|         Example example = new Example(OrderInfo.class); | 
|         example.createCriteria().andEqualTo("createUserId", createUserId) | 
|                 .andEqualTo("orderType", OrderEnum.集货.getValue()) | 
|                 .andIn("orderStatus",CollUtil.newArrayList( OrderEnum.待接单.getValue(),OrderEnum.完成.getValue())) | 
|                 .andCondition("DATE_FORMAT(create_time,'%Y-%m-%d')=DATE_FORMAT(now(),'%Y-%m-%d')"); | 
|         return orderMapper.selectCountByExample(example); | 
|     } | 
|   | 
|   | 
|     public String orderAdd(OrderInfoReq orderInfoReq) { | 
|         /********************自助下单**********************/ | 
|         int type = orderInfoReq.getType(); | 
|         if (type == 1) { | 
|             //            orderInfoReq.setStoreId(Constants.DEFAULT_STORE_ID); | 
|             selfHelpOrder(orderInfoReq); | 
|         } | 
|         /*********************自助下单END****************************/ | 
|   | 
|   | 
|         //查询订单所属区域或围栏信息 | 
|         //回收员 | 
|         OtherUserInfo receiverInfo = null; | 
|         UserInfo userInfo = new UserInfo(); | 
|         String receiver = orderInfoReq.getReceiver(); | 
|         //订单类型 | 
|         String orderType = orderInfoReq.getOrderType(); | 
|         //地址ID | 
|         String addressId = orderInfoReq.getAddressId(); | 
|         String partnerId = null; | 
|         if (StrUtil.isNotBlank(receiver)) { | 
|   | 
|             if (OrderEnum.集货.getValue().equals(orderType)) { | 
|                 userInfo = userService.findById(receiver); | 
|                 if(userInfo.getDelFlag().equals(Constants.DEL_FLAG)||userInfo.getIsProhibit().booleanValue()==Boolean.TRUE.booleanValue()){ | 
|                     throw new RestException( "请重新选择集货员"); | 
|                 } | 
|             } else { | 
|                 receiverInfo = otherUserService.findById(receiver); | 
|   | 
|                 String leaveStartTime = receiverInfo.getLeaveStartTime(); | 
|                 String leaveEndTime = receiverInfo.getLeaveEndTime(); | 
|                 //可能请假 | 
|                 if (StrUtil.isNotBlank(leaveStartTime)) { | 
|                     if (DateUtil.compare(new Date(), DateUtil.parse(leaveStartTime)) >= 0 && DateUtil.compare(new Date(), DateUtil.parse(leaveEndTime)) <= 0) { | 
|                         throw new RestException( "请重新选择骑手"); | 
|                     } | 
|                 } | 
|   | 
|                 if(receiverInfo.getDelFlag().equals(Constants.DEL_FLAG)||receiverInfo.getIsProhibit().booleanValue()==Boolean.TRUE.booleanValue()){ | 
|                     throw new RestException( "请重新选择骑手"); | 
|                 } | 
|                 partnerId = receiverInfo.getPartnerId(); | 
|             } | 
|         } | 
|         AddressInfo addressInfo = addressService.findById(addressId); | 
|         boolean checkFence = !OrderEnum.家电回收.getValue().equals(orderType)&&StrUtil.isBlank(receiver) && StrUtil.isNotBlank(orderInfoReq.getLatitude()) && StrUtil.isNotBlank(orderInfoReq.getLongitude()) && (orderInfoReq.getStoreId() == null || Convert.toLong(Constants.DEFAULT_ID).equals(orderInfoReq.getStoreId())); | 
|         if (checkFence) { | 
|             boolean checkReceiver = orderInfoReq.getType() == 1 ? true : false; | 
|             FenceDto fence = fenceService.getFence(addressInfo.getTownshipId(), checkReceiver, orderInfoReq.getLongitude(), orderInfoReq.getLatitude(), true); | 
|             if (StrUtil.isBlank(fence.getFenceId())) { | 
|                 throw new RestException(-3, "所选位置暂未开通服务"); | 
|             } | 
|             orderInfoReq.setTownId(fence.getFenceId()); | 
|             partnerId = fence.getPartnerId(); | 
|         } | 
|   | 
|         if(OrderEnum.家电回收.getValue().equals(orderType)){ | 
|             //市ID | 
|             String townId=addressInfo.getCityId(); | 
|             boolean b = existExcludeCityId(townId); | 
|             if(b){ | 
|                 throw new RestException(-3, "所选位置暂未开通服务"); | 
|             } | 
|             orderInfoReq.setTownId(townId); | 
|         } | 
|   | 
|   | 
|         //更新用户的合伙人ID | 
|         if (partnerId != null) { | 
|             userService.updatePartnerId(orderInfoReq.getCreateUserId(), partnerId); | 
|         } | 
|   | 
|         //订单预约时间判断 | 
|         String orderReserveTime = orderInfoReq.getReserveTime(); | 
|         orderReserveTime = StrUtil.isNotBlank(orderReserveTime) ? orderReserveTime + ":00" : orderReserveTime; | 
|         orderInfoReq.setReserveTime(orderReserveTime); | 
|   | 
|   | 
|         if (OrderEnum.集货.getValue().equals(orderType)) { | 
|             //集货每天只能完成一个单 | 
|             if (findGatherOrderCountByCreateUserId(orderInfoReq.getCreateUserId()) > 0 && !SpringUtil.isDev()) { | 
|                 throw new RestException(-4, " 每天只能下一个极速订单"); | 
|             } | 
|         }else { | 
|             //只能下一个单 在其他未完成或取消前 | 
|             if (findOrderCountByCreateUserId(orderInfoReq.getCreateUserId()) > 0 && !SpringUtil.isDev()) { | 
|                 throw new RestException(-1, " 您有未完成订单,不能重复下单"); | 
|             } | 
|         } | 
|   | 
|   | 
|         String orderId = idUtils.generate("DD", 1); | 
|         orderInfoReq.setOrderId(orderId); | 
|         //订单创建时间 | 
|         orderInfoReq.setCreateTime(DateUtil.now()); | 
|   | 
|         String createType = type == 1 ? OrderEnum.自助下单.getValue() : OrderEnum.正常下单.getValue(); | 
|         orderInfoReq.setCreateType(Convert.toShort(createType)); | 
|         //插入订单基本信息 | 
|         orderInfoReq.setDelFlag(Convert.toShort(Constants.DEL_NOT_FLAG)); | 
|   | 
|         orderInfoReq.setAddress(addressInfo.getDetailAddress()); | 
|         orderInfoReq.setAddressArea(addressInfo.getAddressArea()); | 
|         orderInfoReq.setUnitName(addressInfo.getUnitName()); | 
|         orderInfoReq.setHouseNumber(addressInfo.getHouseNumber()); | 
|         orderInfoReq.setHouseName(addressInfo.getHouseName()); | 
|         orderMapper.orderInfoAdd(orderInfoReq); | 
|         //插入订单详情 | 
|         if (receiverInfo != null) { | 
|             orderInfoReq.setReceiverName(receiverInfo.getName()); | 
|             orderInfoReq.setReceiverPhone(receiverInfo.getMobilePhone()); | 
|         } else if (userInfo != null) { | 
|             orderInfoReq.setReceiverName(userInfo.getName()); | 
|             orderInfoReq.setReceiverPhone(userInfo.getMobilePhone()); | 
|         } | 
|         //家电信息 | 
|         OrderHomeAppliance orderHomeAppliance = orderInfoReq.getOrderHomeAppliance(); | 
|         if(orderHomeAppliance !=null){ | 
|             orderHomeAppliance.setOrderId(orderId); | 
|             orderHomeApplianceService.add(orderHomeAppliance); | 
|             orderInfoReq.setHomeApplianceId(orderHomeAppliance.getId()); | 
|         } | 
|         orderMapper.orderDetailAdd(orderInfoReq); | 
|         //插入订单物品信息 | 
|         List<OrderItemReq> orderItemList = orderInfoReq.getOrderItemList(); | 
|         if (CollUtil.isNotEmpty(orderItemList)) { | 
|             for (OrderItemReq orderItem : orderItemList) { | 
|                 orderItem.setOrderId(orderId); | 
|                 orderMapper.orderItemAdd(orderItem); | 
|             } | 
|         } | 
|   | 
|         if (type == 0&&StrUtil.isBlank(receiver)) { | 
|             redisUtil.set(RedisKeyConstant.ORDER_CANCEL + orderId, "0"); | 
|         } | 
|   | 
|         String tag=Constants.GRAB_ORDER_TAG; | 
|         if(OrderEnum.家电回收.getValue().equals(orderType)){ | 
|             tag=Constants.GRAB_ORDER_HOME_TAG; | 
|         } | 
|   | 
|         if (type == 0 && StrUtil.isNotBlank(orderInfoReq.getTownId())) { | 
|             //推送 | 
|             jgPushUtil.pushNewOrder(tag,orderInfoReq.getTownId()); | 
| //            otherUserService.sendHomeSms(); | 
|         } | 
|   | 
|         //自助下单自动变为服务中的订单 | 
|         if (type == 1) { | 
|             OrderInfoReq orderInfoReq1 = new OrderInfoReq(); | 
|             orderInfoReq1.setVersion(request.getHeader(Constants.VERSION_TEXT)); | 
|             orderInfoReq1.setReceiver(request.getHeader("userId")); | 
|             OtherUserInfo otherUserInfo = otherUserMapper.selectByPrimaryKey(orderInfoReq1.getReceiver()); | 
|             orderInfoReq1.setReceiverPhone(otherUserInfo.getMobilePhone()); | 
|             orderInfoReq1.setReceiverName(otherUserInfo.getName()); | 
|             orderInfoReq1.setMobilePhone(orderInfoReq.getMobilePhone()); | 
|             orderInfoReq1.setOrderId(orderId); | 
|             orderInfoReq1.setOrderStatus(OrderEnum.服务中.getValue()); | 
|             orderInfoReq1.setType(1); | 
|             log.trace("自助下单自动接单中"); | 
|             updateOrder(orderInfoReq1); | 
|         } | 
|         return orderId; | 
|     } | 
|   | 
|     /** | 
|      * 自助下单流程 | 
|      * | 
|      * @param orderInfoReq | 
|      */ | 
|     private void selfHelpOrder(OrderInfoReq orderInfoReq) { | 
|         //关联默认门店 | 
|         String relaPhone = orderInfoReq.getRelaPhone(); | 
|         String relaName = orderInfoReq.getRelaName(); | 
|         String redisVerifyCode = redisUtil.get(Constants.REDIS_USER_KEY + "code:" + relaPhone); | 
|   | 
|         if (!SpringUtil.isDev()) { | 
|             if (org.apache.commons.lang3.StringUtils.isBlank(redisVerifyCode)) { | 
|                 //验证码已经超过有效期2分钟 | 
|                 throw new RestException(-1, "验证码已经失效,有效期两分钟"); | 
|             } | 
|             if (!redisVerifyCode.equals(orderInfoReq.getVerifyCode())) { | 
|                 //验证码错误 | 
|                 throw new RestException(-1, "验证码错误"); | 
|             } | 
|         } | 
|   | 
|         //判断用户是不是注册用户 | 
|         UserInfo userInfo1 = userService.findByMobile(relaPhone); | 
|   | 
|         String yh; | 
|         if (userInfo1 != null) { | 
|             if (Convert.toShort(CommonEnum.正常注册用户.getValue()).equals(userInfo1.getRegistType())) { | 
|                 throw new RestException(-1, "您已是注册用户,请自行下单"); | 
|             } else { | 
|                 yh = userInfo1.getUserId(); | 
|             } | 
|         } else { | 
|             //新建一个非注册用户 | 
|             yh = idUtils.generate("YH", 3); | 
|             UserInfo userInfo2 = new UserInfo(); | 
|             userInfo2.setUserId(yh); | 
|             userInfo2.setMobilePhone(relaPhone); | 
|             userInfo2.setName(relaName); | 
|             userInfo2.setNickName(relaName); | 
|             userInfo2.setRegistTime(DateUtil.now()); | 
|             userInfo2.setDelFlag(Constants.DEL_NOT_FLAG); | 
|             userInfo2.setRegistType(Convert.toShort(CommonEnum.非注册用户.getValue())); | 
|             userInfo2.setUserType(CommonEnum.普通用户.getValue()); | 
|             userMapper.insertSelective(userInfo2); | 
|   | 
|             //增加一个默认账户 | 
|             AccountInfo accountInfo = new AccountInfo(); | 
|             accountInfo.setAccountId(idUtils.generate("ZH", 4)); | 
|             accountInfo.setAccountName(relaPhone); | 
|             accountInfo.setUserId(yh); | 
|             accountInfo.setFreezeMoney("0"); | 
|             accountInfo.setWithdrawMoney("0"); | 
|             accountInfo.setMoney("0"); | 
|             accountInfo.setDelFlag(0); | 
|             accountInfo.setIsProhibit("0"); | 
|             accountInfo.setErrorTimes(0); | 
|             accountInfo.setCreateTime(DateUtil.now()); | 
|             accountInfo.setUpdateTime(DateUtil.now()); | 
|             accountMapper.insertSelective(accountInfo); | 
|         } | 
|   | 
|         String addressId; | 
|         if (StrUtil.isBlank(orderInfoReq.getAddressId())) { | 
|             //新建一个地址表 | 
|             AddressInfo addressInfo2 = new AddressInfo(); | 
|             addressInfo2.setFlag(UserEnum.非默认地址.getValue()); | 
|             Example example = new Example(AddressInfo.class); | 
|             example.createCriteria().andEqualTo("userId", yh); | 
|             addressMapper.updateByExampleSelective(addressInfo2, example); | 
|             AddressInfo addressInfo = new AddressInfo(); | 
|             addressInfo.setMobilePhone(relaPhone); | 
|             addressInfo.setUserId(yh); | 
|             addressInfo.setAddressArea(orderInfoReq.getAddressArea()); | 
|             addressInfo.setDetailAddress(orderInfoReq.getAddress()); | 
|             addressInfo.setLongitude(orderInfoReq.getLongitude()); | 
|             addressInfo.setLatitude(orderInfoReq.getLatitude()); | 
|             addressInfo.setFlag(UserEnum.默认地址.getValue()); | 
|             addressInfo.setRelaName(relaName); | 
|             addressInfo.setRelaPhone(relaPhone); | 
|             addressInfo.setDelFlag(Convert.toStr(Constants.DEL_NOT_FLAG)); | 
|             AddressReq addressReq = new AddressReq(); | 
|             addressReq.setProvinceName(orderInfoReq.getProvinceName()); | 
|             addressReq.setTownshipName(businessUtil.changeArea(orderInfoReq.getTownshipName())); | 
|             addressReq.setCityName(orderInfoReq.getCityName()); | 
|             List<AddressVo> addressLevelList = addressMapper.queryAreaIdByName(addressReq); | 
|             if (addressLevelList != null && addressLevelList.size() > 0) { | 
|                 String provinceId = addressLevelList.get(0).getProvinceId(); | 
|                 String cityId = addressLevelList.get(0).getCityId(); | 
|                 String townshipId = addressLevelList.get(0).getTownshipId(); | 
|                 addressInfo.setProvinceId(provinceId); | 
|                 addressInfo.setCityId(cityId); | 
|                 addressInfo.setTownshipId(townshipId); | 
|             } | 
|             addressInfo.setCreateTime(DateUtil.now()); | 
|             addressMapper.insertSelective(addressInfo); | 
|             addressId = Convert.toStr(addressInfo.getAddressId()); | 
|         } else { | 
|             addressId = orderInfoReq.getAddressId(); | 
|         } | 
|         orderInfoReq.setAddressId(addressId); | 
|         orderInfoReq.setCreateUserId(yh); | 
|         orderInfoReq.setCreateUserName(relaName); | 
|         orderInfoReq.setMobilePhone(relaPhone); | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 根据订单状态 | 
|      * | 
|      * @param orderStatus | 
|      * @return | 
|      */ | 
|     public List<OrderInfo> findByOrderStatus(String orderStatus) { | 
|         OrderInfo orderInfo = new OrderInfo(); | 
|         orderInfo.setOrderStatus(orderStatus); | 
|         List<OrderInfo> select = orderMapper.select(orderInfo); | 
|         return select; | 
|     } | 
|   | 
|     public List<OrderCustomDto> findByAddressId(String addressId) { | 
|         List<OrderCustomDto> select = orderMapper.findByAddressId(addressId); | 
|         return select; | 
|     } | 
|   | 
|     public List<OrderCustomDto> findWithLonNull() { | 
|         List<OrderCustomDto> select = orderMapper.findWithLonNull(); | 
|         return select; | 
|     } | 
|   | 
|     /** | 
|      * 查询回收员接单的数目 | 
|      * | 
|      * @param receiver | 
|      * @return | 
|      */ | 
|     public int findReceiveOrderNum(String receiver) { | 
|         OrderInfo orderInfo = new OrderInfo(); | 
|         orderInfo.setReceiver(receiver); | 
|         orderInfo.setOrderStatus(OrderEnum.服务中.getValue()); | 
|         return orderMapper.selectCount(orderInfo); | 
|     } | 
|   | 
|   | 
|     public PageInfo<OrderInfoVo> orderListQuery(OrderInfoReq orderInfoReq) { | 
|   | 
|         /** | 
|          * 待接单状态 只对回收员生效 | 
|          * ORDER_VIEW_TOTAL >0 则表示只能看ORDER_VIEW_TOTAL个单   0则无限制 | 
|          */ | 
|   | 
|         //可查看订单数目 | 
|         int pageSize = orderInfoReq.getPageSize(); | 
|         String userId = request.getHeader("userId"); | 
|   | 
|         if (CommonEnum.回收员.getValue().equals(orderInfoReq.getUserType()) && OrderEnum.待接单.getValue().equals(orderInfoReq.getOrderStatus())) { | 
|   | 
|   | 
|                 String partnerId = otherUserService.findById(userId).getPartnerId(); | 
|                 int orderViewNum = Convert.toInt(partnerConfigService.findValueByPartnerAndCode(partnerId, SysConfigConstant.ORDER_VIEW_TOTAL, true)); | 
|   | 
|                 if (orderViewNum > 0) { | 
|                     //查看回收员当前正在服务中的数目 | 
|                     int receiveOrderNum = findReceiveOrderNum(userId); | 
|                     pageSize = orderViewNum - receiveOrderNum; | 
|   | 
|                     if (pageSize <= 0) { | 
|                         return new PageInfo<>(new ArrayList<>()); | 
|                     } | 
|                 } | 
|         } | 
|   | 
|   | 
|         PageHelper.startPage(orderInfoReq.getPageNo(), pageSize); | 
|         List<OrderInfoVo> orderList = orderMapper.orderListQuery(orderInfoReq); | 
|   | 
|   | 
|         if (CollUtil.isNotEmpty(orderList)) { | 
|             for (OrderInfoVo orderInfo : orderList) { | 
|                  getOrderOtherInfo(orderInfo,orderInfoReq); | 
|             } | 
|   | 
|         } | 
|         PageInfo<OrderInfoVo> result = new PageInfo<>(orderList != null ? orderList : new ArrayList<>()); | 
|         return result; | 
|     } | 
|   | 
|   | 
|     public PageInfo<OrderInfoVo> orderListQueryForAdmin(OrderInfoReq orderInfoReq) { | 
|         orderInfoReq.setOrderTypeList(CollUtil.newArrayList("1", "2", "3", "4")); | 
|         PageHelper.startPage(orderInfoReq.getPageNo(), orderInfoReq.getPageSize()); | 
|         List<OrderInfoVo> orderList = orderMapper.orderListQueryForAdmin(orderInfoReq); | 
|         if (CollUtil.isNotEmpty(orderList)) { | 
|             for (OrderInfoVo orderInfo : orderList) { | 
|                 getOrderOtherInfo(orderInfo,orderInfoReq); | 
|             } | 
|         } | 
|         PageInfo<OrderInfoVo> result = new PageInfo<>(orderList != null ? orderList : new ArrayList<>()); | 
|         return result; | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 获取订单其他信息 | 
|      * @param orderInfo | 
|      * @param orderInfoReq | 
|      */ | 
|     private void getOrderOtherInfo(OrderInfoVo orderInfo,OrderInfoReq orderInfoReq){ | 
|         String orderId = orderInfo.getOrderId(); | 
|         String receiver = orderInfo.getReceiver(); | 
|         String addressId = orderInfo.getAddressId(); | 
|         Long homeApplianceId = orderInfo.getHomeApplianceId(); | 
|         String createUserId = orderInfo.getCreateUserId(); | 
|         Map<String, Object> map = getPartnerIdByReceiveOrFence(receiver, orderInfo.getTownId(),addressId); | 
|         String partnerId= (String) map.get("partnerId"); | 
|         String townId= (String) map.get("townId"); | 
|         OtherUserInfo otherUserInfo= (OtherUserInfo) map.get("otherUserInfo"); | 
|   | 
|         orderInfo.setOrderTimeOut(getOrderTimeOut(partnerId) + ""); | 
|   | 
|         if (StrUtil.isNotBlank(orderInfo.getCancelReason())) { | 
|             orderInfo.setCancelReasonName(orderInfo.getCancelReason()); | 
|         } | 
|   | 
|         if (OrderEnum.自助下单.getValue().equals(Convert.toStr(orderInfo.getType(), "1"))) { | 
|             orderInfo.setType(Convert.toShort(1)); | 
|             //将自助下单的-1门店 | 
| //                    orderInfo.setStoreId(null); | 
|         } else { | 
|             orderInfo.setType(Convert.toShort(0)); | 
|         } | 
|   | 
|   | 
|         //地址信息 回收站预约的单没地址ID | 
|         AddressInfo addressInfo; | 
|         if(StrUtil.isNotBlank(addressId)) { | 
|             addressInfo = addressMapper.selectByPrimaryKey(addressId); | 
|             orderInfo.setProvinceId(addressInfo.getProvinceId()); | 
|             orderInfo.setTownshipId(addressInfo.getTownshipId()); | 
|             orderInfo.setCityId(addressInfo.getCityId()); | 
|             AddressLevelInfo addressLevelInfo = addressLevelService.find(addressInfo.getProvinceId(), addressInfo.getCityId(), addressInfo.getTownshipId()); | 
|             if (addressLevelInfo != null) { | 
|                 orderInfo.setProvinceName(addressLevelInfo.getLevel1Name()); | 
|                 orderInfo.setCityName(addressLevelInfo.getLevel2Name()); | 
|                 orderInfo.setTownshipName(addressLevelInfo.getLevel3Name()); | 
|             } | 
|         } | 
|   | 
|         //预约时间 | 
|         String reserveTime = orderInfo.getReserveTime(); | 
|   | 
|   | 
|         Short orderFastFlag = orderInfo.getOrderFastFlag(); | 
|   | 
|         //先判断orderFastFlag是否已催单 ,催单则显示而且置灰 ,未催单则判断orderFastShow是否展示 | 
|         if (StrUtil.isNotBlank(reserveTime)&&orderFastFlag == null && DateUtil.compare(new Date(), DateUtil.parseDateTime(reserveTime)) > 0) { | 
|             orderInfo.setOrderFastShow(Convert.toShort(0)); | 
|         } | 
|   | 
|         if (StrUtil.isNotBlank(reserveTime)) { | 
|             orderInfo.setReserveTime(DateUtil.format(DateUtil.parse(reserveTime, DateUtils.DATE_FORMAT_YMDHMS), DateUtils.DATE_FORMAT_MDHMS)); | 
|             orderInfo.setReserveTimeForYear(reserveTime); | 
|         } | 
|   | 
|         //围栏名称 | 
|         if (StrUtil.isNotBlank(orderInfo.getTownId())) { | 
|             Fence fence = fenceService.queryById(Convert.toInt(orderInfo.getTownId())); | 
|             if (fence != null) { | 
|                 orderInfo.setFenceName(fence.getFenceName()); | 
|             } | 
|         } | 
|   | 
|         //服务中的骑手信息 | 
|         if (otherUserInfo!=null) { | 
|             orderInfo.setReceiverName(otherUserInfo.getName()); | 
|             orderInfo.setReceiverPhone(otherUserInfo.getMobilePhone()); | 
|             //查询星级等信息 | 
|             OrderAppraiseInfo starInfo = orderAppraiseInfoService.findStarInfo(receiver,createUserId); | 
|             orderInfo.setCompleteOrderNum(starInfo.getCompleteOrderNum()); | 
|             orderInfo.setStar(starInfo.getStar()); | 
|             //排队人数 | 
|             orderInfo.setQueueNum(starInfo.getQueueNum()); | 
|         } | 
|   | 
|         //回收员查看价格区域ID | 
|         orderInfo.setReceiverAreaId(townId); | 
|   | 
|         //处理骑手乱码 | 
|         orderInfo.setReceiverName(StringUtils.decode(orderInfo.getReceiverName())); | 
|   | 
|   | 
|         //评价信息 | 
|         OrderAppraiseInfo orderAppraiseInfo1 = orderAppraiseInfoService.findByOrderId(orderId); | 
|         if (orderAppraiseInfo1 != null) { | 
|             orderInfo.setAppraiseFlag(true); | 
|             orderInfo.setAppraiseId(orderAppraiseInfo1.getId()); | 
|             String star = orderAppraiseInfo1.getStar(); | 
|             if (StrUtil.isNotBlank(star)) { | 
|                 ConfigInfoReq configInfoReq = new ConfigInfoReq(); | 
|                 configInfoReq.setConfigTypeCode("APPRAISE_TAG" + star + "_AttITUDE"); | 
|                 List<ConfigInfoVo> configInfoVos = configService.configInfoQuery(configInfoReq); | 
|                 String configTypeName = configInfoVos.get(0).getConfigTypeName(); | 
|                 orderInfo.setAppraise(configTypeName); | 
|             } | 
|   | 
|         } else { | 
|             orderInfo.setAppraiseFlag(false); | 
|         } | 
|   | 
|   | 
|         //订单物品查询 | 
|         List<OrderItemVo> orderItemList = orderItemService.findByOrderId(orderId,townId); | 
|         //新任务和待服务状态下过滤没有选择重量的物品 | 
|         if (!OrderEnum.待接单.getValue().equals(orderInfoReq.getOrderStatus()) && !OrderEnum.服务中.getValue().equals(orderInfoReq.getOrderStatus()) && CollUtil.isNotEmpty(orderItemList)) { | 
|             orderItemList = orderItemList.stream().filter(x -> (x.getWeight() != null && Convert.toBigDecimal(x.getWeight()).compareTo(BigDecimal.ZERO) != 0) || (x.getAmount() != null && Convert.toBigDecimal(x.getAmount()).compareTo(BigDecimal.ZERO) != 0)).collect(Collectors.toList()); | 
|         } | 
|         orderInfo.setOrderItemList(orderItemList); | 
|   | 
|         //用户是否是首次下单 | 
|         orderInfo.setOrderFirstFlag(isFirstOrder(createUserId) == true ? 0 : 1); | 
|   | 
|         //家电下单的家电信息 | 
|         if(homeApplianceId!=null) { | 
|             OrderHomeAppliance byOrderId = orderHomeApplianceService.findById(homeApplianceId); | 
|             orderInfo.setOrderHomeAppliance(byOrderId); | 
|         } | 
|   | 
|         //下单用户的登录手机号码 | 
|         UserInfo byId = userService.findById(createUserId); | 
|         if(byId!=null) { | 
|             orderInfo.setLoginPhone(byId.getMobilePhone()); | 
|         } | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 根据围栏或回收员查找合伙人ID | 
|      * @param receiver | 
|      * @param fenceId | 
|      * @return | 
|      */ | 
|     private Map<String,Object> getPartnerIdByReceiveOrFence(String receiver,String fenceId,String addressId){ | 
|         Map<String,Object> map=new HashMap<>(); | 
|         String partnerId=""; | 
|         String townId=""; | 
|         if (StrUtil.isNotBlank(receiver)) { | 
|             OtherUserInfo otherUserInfo = otherUserMapper.selectByPrimaryKey(receiver); | 
|             if(otherUserInfo!=null){ | 
|                 map.put("otherUserInfo",otherUserInfo); | 
|                 partnerId=otherUserInfo.getPartnerId(); | 
|                 townId=otherUserInfo.getTownshipId().toString(); | 
|             } | 
|         }else { | 
|             if (StrUtil.isNotBlank(fenceId)) { | 
|                 partnerId = partnerFenceService.findPartnerIdByFenceId(fenceId); | 
|                 townId = fenceService.findTownId(addressId, fenceId); | 
|             } | 
|         } | 
|   | 
|         map.put("partnerId",partnerId); | 
|         map.put("townId",townId); | 
|   | 
|         return map; | 
|     } | 
|   | 
|     /** | 
|      * 用户是否是首次下单 | 
|      * | 
|      * @param createUserId | 
|      * @return | 
|      */ | 
|     public boolean isFirstOrder(String createUserId) { | 
|         Example example = new Example(OrderInfo.class); | 
|         Example.Criteria criteria = example.createCriteria(); | 
|         criteria.andEqualTo("createUserId", createUserId); | 
|         criteria.andIn("orderStatus", CollUtil.newArrayList(OrderEnum.完成.getValue(), OrderEnum.待入库.getValue(), OrderEnum.入库中.getValue())); | 
|         return orderMapper.selectCountByExample(example) > 0 ? false : true; | 
|     } | 
|   | 
|     /** | 
|      * 订单详情 | 
|      * | 
|      * @param orderInfoReq | 
|      * @return | 
|      */ | 
|     public List<OrderInfoVo> orderDetailQuery(OrderInfoReq orderInfoReq) { | 
|         List<OrderInfoVo> orderDetail = orderMapper.orderDetailQuery(orderInfoReq); | 
|         String orderId = orderInfoReq.getOrderId(); | 
|         if (CollUtil.isNotEmpty(orderDetail)) { | 
|             String receiver = orderDetail.get(0).getReceiver(); | 
|             String orderType = orderDetail.get(0).getOrderType(); | 
|             String orderStatus = orderDetail.get(0).getOrderStatus(); | 
|             String createUserId = orderDetail.get(0).getCreateUserId(); | 
|             Long homeApplianceId = orderDetail.get(0).getHomeApplianceId(); | 
|   | 
|             //下单用户登录号码 | 
|             UserInfo byId1 = userService.findById(createUserId); | 
|             if(byId1!=null){ | 
|                 orderDetail.get(0).setLoginPhone(byId1.getMobilePhone()); | 
|             } | 
|   | 
|             Map<String, Object> map = getPartnerIdByReceiveOrFence(receiver, orderDetail.get(0).getTownId(),orderDetail.get(0).getAddressId()); | 
|             String partnerId= (String) map.get("partnerId"); | 
|             String townId= (String) map.get("townId"); | 
|             OtherUserInfo otherUserInfo= (OtherUserInfo) map.get("otherUserInfo"); | 
|   | 
|             orderDetail.get(0).setOrderTimeOut(getOrderTimeOut(partnerId) + ""); | 
|   | 
|             //评分 | 
|             OrderAppraiseInfo starInfo = orderAppraiseInfoService.findStarInfo(receiver,createUserId); | 
|             orderDetail.get(0).setOrderAppraiseInfo(starInfo); | 
|   | 
|             //评价信息 | 
|             OrderAppraiseInfo orderAppraiseInfo1 = orderAppraiseInfoService.findByOrderId(orderId); | 
|             if (orderAppraiseInfo1 != null) { | 
|                 orderDetail.get(0).setAppraiseFlag(true); | 
|                 orderDetail.get(0).setAppraiseId(orderAppraiseInfo1.getId()); | 
|             } | 
|   | 
|             //头像 | 
|             if (otherUserInfo != null) { | 
|                 orderDetail.get(0).setReceiverPhoto(otherUserInfo.getAvatar()); | 
|             } | 
|   | 
|             //地址信息 | 
|             String addressId = orderDetail.get(0).getAddressId(); | 
|             AddressInfo addressInfo = addressMapper.selectByPrimaryKey(addressId); | 
|             orderDetail.get(0).setProvinceId(addressInfo.getProvinceId()); | 
|             orderDetail.get(0).setTownshipId(addressInfo.getTownshipId()); | 
|             orderDetail.get(0).setCityId(addressInfo.getCityId()); | 
|             AddressLevelInfo addressLevelInfo = addressLevelService.find(addressInfo.getProvinceId(), addressInfo.getCityId(), addressInfo.getTownshipId()); | 
|             if (addressLevelInfo != null) { | 
|                 orderDetail.get(0).setProvinceName(addressLevelInfo.getLevel1Name()); | 
|                 orderDetail.get(0).setCityName(addressLevelInfo.getLevel2Name()); | 
|                 orderDetail.get(0).setTownshipName(addressLevelInfo.getLevel3Name()); | 
|             } | 
|   | 
|   | 
|             //投诉信息 | 
|             List<ComplaintFindResDto> orderComplaints = orderComplaintService.detail(orderId); | 
|             if (CollUtil.isNotEmpty(orderComplaints)) { | 
|                 Integer afterSaleFlag = orderComplaints.get(0).getAfterSaleFlag(); | 
|                 if (afterSaleFlag != null && afterSaleFlag != 0) { | 
|                     orderDetail.get(0).setComplaintFlag(Convert.toInt(OrderEnum.投诉已处理.getValue())); | 
|                 } else { | 
|                     orderDetail.get(0).setComplaintFlag(Convert.toInt(OrderEnum.投诉未处理.getValue())); | 
|                 } | 
|   | 
|                 //多次投诉 | 
|                 orderDetail.get(0).setComplaintFirstFlag(1); | 
|             } else { | 
|                 //第一次投诉 | 
|                 orderDetail.get(0).setComplaintFirstFlag(0); | 
|             } | 
|   | 
|   | 
|             //上门服务信息 | 
|             if (OrderEnum.到家服务.getValue().equals(orderType)) { | 
|                 String homeServiceIds = orderDetail.get(0).getHomeServiceId(); | 
|                 if (StrUtil.isNotBlank(homeServiceIds)) { | 
|                     StrBuilder strBuilder = StrBuilder.create(); | 
|                     String[] split = homeServiceIds.split(","); | 
|                     for (String homeServiceId : split) { | 
|                         HomeServiceInfo father = homeServiceInfoService.findFather(Convert.toLong(homeServiceId)); | 
|                         strBuilder.append(father.getParentName() + " " + father.getName() + ","); | 
|                     } | 
|                     orderDetail.get(0).setServiceName(StringUtils.removeLast(strBuilder, ",")); | 
|                 } else { | 
|                     HomeServiceInfo byId = homeServiceInfoService.findById(Constants.TOP_ID); | 
|                     orderDetail.get(0).setServiceName(byId.getName()); | 
|                 } | 
|             } | 
|   | 
|   | 
|             //订单物品查询 | 
|             List<OrderItemVo> orderItemList = orderItemService.findByOrderId(orderId,townId); | 
|             orderDetail.get(0).setOrderItemList(orderItemList); | 
|             PayInfo payInfo = payInfoMapper.selectByOrderIdAndUserId(orderId, orderInfoReq.getCreateUserId(), PayEnum.环保金收入.getValue()); | 
|             if (payInfo != null) { | 
|                 //环保金 | 
|                 orderDetail.get(0).setPayType("-1"); | 
|                 String createTime = payInfo.getCreateTime(); | 
|                 orderDetail.get(0).setPayTime(createTime); | 
|             } else { | 
|                 //现金 | 
|                 orderDetail.get(0).setPayType("-2"); | 
|             } | 
|   | 
|             if (OrderEnum.入库中.getValue().equals(orderStatus) || OrderEnum.待入库.getValue().equals(orderStatus) || OrderEnum.完成.getValue().equals(orderStatus)) { | 
|                 PayInfo byOrderAndUserAndType = payInfoService.findByOrderAndUserAndType(orderInfoReq.getCreateUserId(), orderId, PayEnum.按重量返利.getValue()); | 
|                 if (byOrderAndUserAndType != null) { | 
|                     orderDetail.get(0).setScaleMoney(businessUtil.changeMoney(byOrderAndUserAndType.getMoney())); | 
|                     orderDetail.get(0).setRuleType(OrderEnum.重量返利支出.getValue()); | 
|                 } else { | 
|                     PartnerAccountLog byTypeAndFlow = partnerAccountLogService.findByTypeAndFlow(OrderEnum.阶梯返利.getValue(), orderId); | 
|                     if (byTypeAndFlow != null) { | 
|                         orderDetail.get(0).setScaleMoney(businessUtil.changeMoney(byTypeAndFlow.getMoney())); | 
|                         orderDetail.get(0).setRuleId(Convert.toInt(byTypeAndFlow.getRuleId())); | 
|                         orderDetail.get(0).setRuleType(OrderEnum.阶梯返利.getValue()); | 
|                     } | 
|                 } | 
|             } else { | 
|                 if(partnerId!=null) { | 
|                     //重量返利 | 
|                     RuleDto stepRebate = ruleService.findWeightRebate(orderInfoReq.getCreateUserId(), true, partnerId); | 
|                     if (stepRebate.getRuleId() != null) { | 
|                         orderDetail.get(0).setList(stepRebate.getRebateRules()); | 
|                         orderDetail.get(0).setProductType(stepRebate.getProductType()); | 
|                         orderDetail.get(0).setRuleType(OrderEnum.重量返利支出.getValue()); | 
|                     } else { | 
|                         stepRebate = ruleService.findStepRebate(orderInfoReq.getCreateUserId(), true, partnerId); | 
|                         //阶梯返利比率 | 
|                         String scale = stepRebate.getScale(); | 
|                         if (!UserEnum.无返利.getValue().equals(scale)) { | 
|                             orderDetail.get(0).setScale(scale); | 
|                             orderDetail.get(0).setRuleId(Convert.toInt(stepRebate.getRuleId())); | 
|                             orderDetail.get(0).setRuleType(OrderEnum.阶梯返利.getValue()); | 
|                         } | 
|                     } | 
|                 } | 
|             } | 
|   | 
|             //家电下单的家电信息 | 
|             if(homeApplianceId!=null) { | 
|                 OrderHomeAppliance byOrderId = orderHomeApplianceService.findById(homeApplianceId); | 
|                 orderDetail.get(0).setOrderHomeAppliance(byOrderId); | 
|             } | 
|   | 
|         } | 
|         return orderDetail; | 
|     } | 
|   | 
|     /** | 
|      * 自助下单 短信发送 | 
|      */ | 
|     private void sendSms(OrderInfoReq orderInfoReq) { | 
|         List<OrderItemReq> orderItemList = orderInfoReq.getOrderItemList(); | 
|         BigDecimal weight = Constants.WEIGHT_INIT; | 
|         if (CollUtil.isNotEmpty(orderItemList)) { | 
|             for (OrderItemReq orderItemReq : orderItemList) { | 
|                 List<OrderItemReq> list = orderItemReq.getList(); | 
|                 if (CollUtil.isNotEmpty(list)) { | 
|                     double sum = list.stream().mapToDouble(x -> Convert.toDouble(x.getWeight(), Convert.toDouble(Constants.WEIGHT_INIT))).sum(); | 
|                     weight = NumberUtil.add(weight, Convert.toBigDecimal(sum)); | 
|                 } | 
|             } | 
|         } | 
|         Map<String, String> map = new HashMap(); | 
|         map.put("other_number", Convert.toStr(weight, "0")); | 
|         map.put("amount", orderInfoReq.getMoney()); | 
|   | 
|         if (businessUtil.getVersion(request.getHeader("version")).compareTo(Convert.toDouble(CommonEnum.版本号1点5点11.getValue())) >= 0) { | 
|             BigDecimal stepMulForPartner2 = orderInfoReq.getStepMulForPartner() == null ? BigDecimal.ZERO : orderInfoReq.getStepMulForPartner(); | 
|             BigDecimal stepMulForReceiver2 = orderInfoReq.getStepMulForReceiver() == null ? BigDecimal.ZERO : orderInfoReq.getStepMulForReceiver(); | 
|             BigDecimal stepMul = NumberUtil.add(stepMulForPartner2, stepMulForReceiver2); | 
|             map.put("others", Convert.toStr(stepMul, "0")); | 
|         } else { | 
|             BigDecimal stepMul = orderInfoReq.getStepMul(); | 
|             map.put("others", Convert.toStr(stepMul, "0")); | 
|         } | 
|         String content = StrUtil.format("回收员帮您下的订单已完成,回收重量{other_number}kg,金额{amount}元,返利{others}元", map); | 
|         SmsUtil.sendPoint(orderInfoReq.getMobilePhone(), content); | 
|     } | 
|   | 
|     public Result updateOrder(OrderInfoReq orderInfoReq) { | 
|         String orderId = orderInfoReq.getOrderId(); | 
|         if (StringUtils.isNotBlank(orderInfoReq.getReceiverName()) && !StringUtils.isBase64(orderInfoReq.getReceiverName())) { | 
|             orderInfoReq.setReceiverName(Base64.encode(orderInfoReq.getReceiverName())); | 
|         } | 
|   | 
|         //订单类型 1为回收,2为到家服务 3:集货单 4:废品店下单 5家电回收 | 
|         String orderType = orderInfoReq.getOrderType(); | 
|   | 
|         //可最大接单数目 | 
|         if (StrUtil.isNotBlank(orderInfoReq.getReceiver())) { | 
|             int configValueSetMaxOrderNum = maxOrderNum(orderInfoReq.getReceiver()); | 
|             orderInfoReq.setMaxOrderNum(configValueSetMaxOrderNum); | 
|         } | 
|   | 
|         orderInfoReq.setVersion(request.getHeader(Constants.VERSION_TEXT)); | 
|         String money = orderInfoReq.getMoney(); | 
|   | 
|         if (StrUtil.isNotBlank(money)) { | 
|             orderInfoReq.setMoney(businessUtil.changeMoney(money)); | 
|         } | 
|         Dict dict = null; | 
|         //入库 | 
|         boolean lock = false; | 
|         String lockKey=RedisKeyConstant.ORDER_DRK + orderId; | 
|         //抢单 | 
|         boolean lockRob=false; | 
|         String lockRobKey=RedisKeyConstant.ORDER_ROB+orderId; | 
|         String traceIds=null; | 
|         try { | 
|             String operateTime = DateUtil.now(); | 
|             //接单 | 
|             if (OrderEnum.服务中.getValue().equals(orderInfoReq.getOrderStatus())) { | 
|                 List<OrderInfoVo> orderDetail = orderMapper.orderDetailQuery(orderInfoReq); | 
|                 orderInfoReq.setOrderDetail(orderDetail); | 
|   | 
|   | 
|                 String orderStatus = orderDetail.get(0).getOrderStatus(); | 
|   | 
|                 //判断订单是否是处于待接单状态 | 
|                 if (OrderEnum.取消.getValue().equals(orderStatus)) { | 
|                     throw new RestException("订单已被取消"); | 
|                 } | 
|   | 
|                 // 查询是否超单  自助下单不限制 | 
|                 if (orderInfoReq.getType() == 0) { | 
|                     exceedOrderRedis(orderInfoReq); | 
|                 } | 
|   | 
|                 if(redisUtil.setnxex(lockRobKey,"0",300)){ | 
|                     lockRob=true; | 
|                     //接单 | 
|                     dict = receiverOrder(orderInfoReq, operateTime,orderDetail); | 
|   | 
|                     //正常下单 接单需要创建一条轨迹 | 
|                     if (orderInfoReq.getType() == 0 && OrderEnum.回收.getValue().equals(orderType)) { | 
|                         PartnerTrace byUserIdAndType = partnerTraceService.findByUserIdAndType(orderInfoReq.getReceiver(), null); | 
|                         if (byUserIdAndType != null) { | 
|                             String key = byUserIdAndType.getPartnerKey(); | 
|                             String sid = byUserIdAndType.getPartnerServiceId(); | 
|                             String tid = byUserIdAndType.getOtherUserInfo().getTerminalId(); | 
|                             Result trace = GdTraceUtil.createTrace(key, sid, tid); | 
|                             if (trace.getCode() == 0) { | 
|                                 orderInfoReq.setTraceId(trace.getData().toString()); | 
|                             } | 
|                         } | 
|                     } | 
|   | 
|                     upOrder(orderInfoReq); | 
|   | 
|                     if (OrderEnum.回收.getValue().equals(orderType)) { | 
|                         //查询所有服务中的轨迹ID返回 | 
|                         List<OrderInfo> detailByReceiverAndStatus = findDetailByReceiverAndStatus(orderInfoReq.getReceiver(), OrderEnum.服务中.getValue()); | 
|                         StrBuilder strBuilder = StrBuilder.create(); | 
|                         if (CollUtil.isNotEmpty(detailByReceiverAndStatus)) { | 
|                             for (OrderInfo byReceiverAndStatus : detailByReceiverAndStatus) { | 
|                                 if (StrUtil.isNotBlank(byReceiverAndStatus.getTraceId())) { | 
|                                     strBuilder.append(byReceiverAndStatus.getTraceId() + ","); | 
|                                 } | 
|                             } | 
|                         } | 
|                         if (strBuilder.length() > 0) { | 
|                             String s = strBuilder.toString(); | 
|                             String s1 = StrUtil.removeSuffix(s, ","); | 
|                             return Result.success(s1); | 
|                         } | 
|                     } | 
|                 }else { | 
|                     throw new RestException("该订单已被抢单,请刷新页面查看其他订单"); | 
|                 } | 
|             } else if (OrderEnum.取消.getValue().equals(orderInfoReq.getOrderStatus())) { | 
|                 dict = cancelOrder(orderInfoReq); | 
|                 orderInfoReq.setCancelTime(operateTime); | 
|                 upOrder(orderInfoReq); | 
|                 redisUtil.del(RedisKeyConstant.ORDER_CANCEL+ orderId); | 
|             } else if (OrderEnum.待入库.getValue().equals(orderInfoReq.getOrderStatus())) { | 
|                 if (redisUtil.setnx(lockKey, "0")) { | 
|                     lock = true; | 
|                     orderInfoReq.setCompleteTime(operateTime); | 
|                     //家电回收是外部骑手 | 
|                     if(!OrderEnum.家电回收.getValue().equals(orderType)) { | 
|                         ConfigInfo configInfo = new ConfigInfo(); | 
|                         configInfo.setConfigTypeCode("PAY_METHOD"); | 
|                         ConfigInfo configInfo1 = configMapper.selectOne(configInfo); | 
|                         if (configInfo1 != null) { | 
|                             String configValue = configInfo1.getConfigValue(); | 
|                             if (PayEnum.环保金支付.getValue().equals(configValue)) { | 
|                                 if (PayEnum.现金支出.getValue().equals(orderInfoReq.getPayType())) { | 
|                                     throw new RestException(-1, "支付方式不正确"); | 
|                                 } | 
|                             } else if (PayEnum.现金支付.getValue().equals(configValue)) { | 
|                                 if (PayEnum.环保金支出.getValue().equals(orderInfoReq.getPayType())) { | 
|                                     throw new RestException(-1, "支付方式不正确"); | 
|                                 } | 
|                             } | 
|                         } | 
|                     } | 
|                     //回收员已确认订单待入库 | 
|                     checkOrder(orderInfoReq); | 
|                     //操作账户 | 
|                     dict = sureOrder(orderInfoReq, operateTime); | 
|                     //更新订单状态 | 
|                     upOrder(orderInfoReq); | 
|   | 
|                     //如果是家电回收 直接订单状态变成已完成 | 
|                     if(OrderEnum.家电回收.getValue().equals(orderType)){ | 
|                         //订单状态变更 | 
|                         OrderReversDto orderReversDto=new OrderReversDto(); | 
|                         orderReversDto.setManageUserId(orderInfoReq.getReceiver()); | 
|                         orderReversDto.setNewStatus(OrderEnum.完成.getValue()); | 
|                         orderReversDto.setIsSendMsg(false); | 
|                         List<OrderDto> list=CollUtil.newArrayList(); | 
|                         OrderDto orderDto=new OrderDto(); | 
|                         orderDto.setOrderId(orderId); | 
|                         orderDto.setReceiverId(orderInfoReq.getReceiver()); | 
|                         list.add(orderDto); | 
|                         orderReversDto.setList(list); | 
|                         orderRevers(orderReversDto); | 
|                     } | 
|   | 
|   | 
|                     //自助下单短信发送 | 
|                     if (orderInfoReq.getType() == 1) { | 
|                         String createUserPhone = dict.getStr("createUserPhone"); | 
|                         if (StrUtil.isNotBlank(createUserPhone)) { | 
|                             orderInfoReq.setMobilePhone(createUserPhone); | 
|                             sendSms(orderInfoReq); | 
|                         } | 
|                     } else if (orderInfoReq.getType() == 0) { | 
|                         traceIds = getTrace(orderInfoReq); | 
|                     } | 
|   | 
|                 } | 
|             } | 
|         } catch (RestException e) { | 
|             //还原订单redis操作 | 
|             restoreOrderRedis(orderInfoReq, dict); | 
|             ExceptionUtils.err(e.getMsg(), e); | 
|         } catch (Exception e) { | 
|             //还原订单redis操作 | 
|             restoreOrderRedis(orderInfoReq, dict); | 
|             ExceptionUtils.err("订单更新失败", e); | 
|         } finally { | 
|             if (lock) { | 
|                 redisUtil.del(lockKey); | 
|             } | 
|             if (lockRob) { | 
|                 redisUtil.del(lockRobKey); | 
|             } | 
|         } | 
|   | 
|         return Result.success(traceIds); | 
|     } | 
|   | 
|     /** | 
|      * 获取回收元轨迹 | 
|      * @param orderInfoReq | 
|      * @return | 
|      */ | 
|     private String getTrace(OrderInfoReq orderInfoReq) { | 
|         String traceIds=null; | 
|         PartnerTrace byUserIdAndType = partnerTraceService.findByUserIdAndType(orderInfoReq.getReceiver(), null); | 
|         if (byUserIdAndType != null) { | 
|             String key = byUserIdAndType.getPartnerKey(); | 
|             String sid = byUserIdAndType.getPartnerServiceId(); | 
|             String tid = byUserIdAndType.getOtherUserInfo().getTerminalId(); | 
|   | 
|             //删除所有回收员服务中的订单的轨迹且重新创建轨迹 重新创建轨迹 | 
|             List<OrderInfo> detailByReceiverAndStatus = findDetailByReceiverAndStatus(orderInfoReq.getReceiver(), OrderEnum.服务中.getValue()); | 
|             StrBuilder strBuilder = StrBuilder.create(); | 
|             if (CollUtil.isNotEmpty(detailByReceiverAndStatus)) { | 
|                 for (OrderInfo byReceiverAndStatus : detailByReceiverAndStatus) { | 
|                     String traceId = byReceiverAndStatus.getTraceId(); | 
|                     if (StrUtil.isNotBlank(traceId)) { | 
|                         CommonTraceDto commonTraceDto = new CommonTraceDto(); | 
|                         commonTraceDto.setKey(key); | 
|                         commonTraceDto.setSid(sid); | 
|                         commonTraceDto.setTid(tid); | 
|                         commonTraceDto.setTrid(traceId); | 
|                         GdTraceUtil.deleteTrace(commonTraceDto); | 
|                         Result trace = GdTraceUtil.createTrace(key, sid, tid); | 
|                         if (trace.getCode() == 0) { | 
|                             String s = trace.getData().toString(); | 
|                             strBuilder.append(s + ","); | 
|                             //更新轨迹ID | 
|                             OrderInfo orderInfo = new OrderInfo(); | 
|                             orderInfo.setOrderId(byReceiverAndStatus.getOrderId()); | 
|                             orderInfo.setTraceId(s); | 
|                             orderMapper.updateByPrimaryKeySelective(orderInfo); | 
|                         } | 
|                     } | 
|                 } | 
|             } | 
|             if (strBuilder.length() > 0) { | 
|                 String s = strBuilder.toString(); | 
|                 String s1 = StrUtil.removeSuffix(s, ","); | 
|                 traceIds=s1; | 
|             } | 
|         } | 
|         return traceIds; | 
|     } | 
|   | 
|     public int updateOrderById(OrderInfo orderInfo) { | 
|         orderMapper.updateByPrimaryKeySelective(orderInfo); | 
|         return 0; | 
|     } | 
|   | 
|     public int updateOrderAll(OrderInfo orderInfo) { | 
|         orderMapper.updateByPrimaryKey(orderInfo); | 
|         return 0; | 
|     } | 
|   | 
|     private void upOrder(OrderInfoReq orderInfoReq) { | 
|         //更新订单 | 
|         orderMapper.updateOrderInfo(orderInfoReq); | 
|         //更新物品详情 | 
|         List<OrderItemReq> resList = getOrderWeight(orderInfoReq); | 
|   | 
|         //含返利金额 | 
|         if (OrderEnum.待入库.getValue().equals(orderInfoReq.getOrderStatus())) { | 
|             int type = orderInfoReq.getType(); | 
|             BigDecimal allMoney = Convert.toBigDecimal(orderInfoReq.getMoney()); | 
|             BigDecimal stepMulForReceiver = orderInfoReq.getStepMulForReceiver(); | 
|             BigDecimal stepMulForPartner = orderInfoReq.getStepMulForPartner(); | 
|             if (stepMulForReceiver != null) { | 
|                 allMoney = NumberUtil.sub(allMoney, stepMulForReceiver); | 
|             } | 
|   | 
|             //自助下单 | 
|             if (type == 1) { | 
|                 if (stepMulForPartner != null) { | 
|                     allMoney = NumberUtil.sub(allMoney, stepMulForPartner); | 
|                 } | 
|             } | 
|             orderInfoReq.setMoney(Convert.toStr(allMoney)); | 
|         } | 
|         orderMapper.updateOrderDetailInfo(orderInfoReq); | 
|         //更新物品orderitemInfo信息  如果不存在则增加,否则更新 | 
|         updateOrderItem(orderInfoReq, resList); | 
|     } | 
|   | 
|     /** | 
|      * 计算物品总重量和总数量 | 
|      * | 
|      * @param orderInfoReq | 
|      * @return | 
|      */ | 
|     private List<OrderItemReq> getOrderWeight(OrderInfoReq orderInfoReq) { | 
|         BigDecimal weight = new BigDecimal("0"); | 
|         BigDecimal amount = new BigDecimal("0"); | 
|         List<OrderItemReq> resList = new ArrayList<>(); | 
|         if (!CollectionUtils.isEmpty(orderInfoReq.getOrderItemList())) { | 
|             for (OrderItemReq orderItemReq : orderInfoReq.getOrderItemList()) { | 
|                 List<OrderItemReq> list = orderItemReq.getList(); | 
|                 if (!CollectionUtils.isEmpty(list)) { | 
|                     resList.addAll(list); | 
|                 } | 
|             } | 
|         } | 
|         if (!CollectionUtils.isEmpty(resList)) { | 
|             for (OrderItemReq orderItemReq : resList) { | 
|                 if (StringUtils.isNotBlank(orderItemReq.getWeight()) && Convert.toBigDecimal(orderItemReq.getWeight()).compareTo(BigDecimal.ZERO) != 0) { | 
|                     weight = NumberUtil.add(weight, new BigDecimal(orderItemReq.getWeight())); | 
|                 } | 
|                 if (StringUtils.isNotBlank(orderItemReq.getAmount()) && Convert.toBigDecimal(orderItemReq.getAmount()).compareTo(BigDecimal.ZERO) != 0) { | 
|                     amount = NumberUtil.add(amount, new BigDecimal(orderItemReq.getAmount())); | 
|                 } | 
|   | 
|                 //回收员设定价格覆盖平台价格 | 
|                 String userPrice = orderItemReq.getUserPrice(); | 
|                 if(StrUtil.isNotBlank(userPrice)){ | 
|                     orderItemReq.setPrice(userPrice); | 
|                 } | 
|             } | 
|         } | 
|         orderInfoReq.setWeight(Convert.toStr(weight)); | 
|         orderInfoReq.setAmount(Convert.toStr(amount)); | 
|         return resList; | 
|     } | 
|   | 
|     private void updateOrderItem(OrderInfoReq orderInfoReq, List<OrderItemReq> resList) { | 
|         if (!CollectionUtils.isEmpty(resList)) { | 
|             for (OrderItemReq orderItem : resList) { | 
|                 //从请求对象中获取订单id | 
|                 orderItem.setOrderId(orderInfoReq.getOrderId()); | 
|                 boolean flag = orderItemService.isExist(orderItem.getOrderId(), orderItem.getItemType()); | 
|                 if (flag) { | 
|                     orderMapper.orderItemUpdate(orderItem); | 
|                 } else { | 
|                     orderMapper.orderItemAdd(orderItem); | 
|                 } | 
|             } | 
|         } | 
|     } | 
|   | 
|   | 
|     private void restoreOrderRedis(OrderInfoReq orderInfoReq, Dict dict) { | 
|         if (dict != null) { | 
|             if (dict.get("receiverOrder") != null) { | 
|                 redisUtil.set(Constants.REDIS_ORDER_KEY + "status:" + orderInfoReq.getOrderId(), "0"); | 
|             } | 
|         } | 
|     } | 
|   | 
|     private Dict receiverOrder(OrderInfoReq orderInfoReq, String operateTime,  List<OrderInfoVo> orderDetail) { | 
|         // 接单开始 | 
|         Dict dict = Dict.create(); | 
|   | 
|         if (StringUtils.isNotBlank(orderInfoReq.getReceiver())) { | 
|             orderInfoReq.setReceiveTime(operateTime); | 
|         } | 
|   | 
|         //插入消息记录(接单消息) | 
|         String createTime = DateUtils.getCurDateTime(); | 
|         String receiver = orderDetail.get(0).getReceiver(); | 
|   | 
|         if (orderInfoReq.getType() == 0&&StrUtil.isBlank(receiver)) { | 
|             Boolean s = redisUtil.exists(RedisKeyConstant.ORDER_CANCEL + orderInfoReq.getOrderId()); | 
|             if (s) { | 
|                 redisUtil.del(RedisKeyConstant.ORDER_CANCEL + orderInfoReq.getOrderId()); | 
|                 dict.set("receiverOrder", true); | 
|             } else { | 
|                 throw new RestException("该订单已被抢单,请刷新页面查看其他订单"); | 
|             } | 
|         } | 
|   | 
|   | 
|         String createUserId = orderDetail.get(0).getCreateUserId(); | 
|         //回收员接收的消息 | 
|         SysMessage sysMessage = new SysMessage(); | 
|         sysMessage.setCreateTime(createTime); | 
|         sysMessage.setCreateUserId(orderInfoReq.getReceiver()); | 
|         sysMessage.setFlag(SysEnum.未读.getValue()); | 
|         sysMessage.setMessage("您已接单" + orderInfoReq.getOrderId() + ",请准时到达现场"); | 
|         sysMessage.setMessageSubTypeName("订单接单"); | 
|         sysMessage.setMessageType("1"); | 
|         sysMessage.setUserId(orderInfoReq.getReceiver()); | 
|         sysMessageMapper.insert(sysMessage); | 
|   | 
|         //普通用户接收的消息 | 
|         if (orderInfoReq.getType() == 0) { | 
|             SysMessage sysMessage2 = new SysMessage(); | 
|             sysMessage2.setCreateTime(createTime); | 
|             sysMessage2.setCreateUserId(orderInfoReq.getReceiver()); | 
|             sysMessage2.setFlag(SysEnum.未读.getValue()); | 
|             sysMessage2.setMessage("您的订单" + orderInfoReq.getOrderId() + "已经接单"); | 
|             sysMessage2.setMessageSubTypeName("订单接单"); | 
|             sysMessage2.setMessageType("1"); | 
|             sysMessage2.setUserId(createUserId); | 
|             sysMessageMapper.insert(sysMessage2); | 
|         } | 
|   | 
|         return dict; | 
|     } | 
|   | 
|     private void exceedOrderRedis(OrderInfoReq orderInfoReq) { | 
|         int orderNum = findReceiveOrderNum(orderInfoReq.getReceiver()); | 
|         if (orderNum >= orderInfoReq.getMaxOrderNum()) { | 
|             // 超单 | 
|             throw new RestException( "服务中订单不能超过" + orderInfoReq.getMaxOrderNum() + "个,请先完成订单"); | 
|         } | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 回收员接单完成 | 
|      * | 
|      * @param orderInfoReq | 
|      * @param now | 
|      * @return | 
|      */ | 
|     private Dict sureOrder(OrderInfoReq orderInfoReq, String now) { | 
|         Dict dict = Dict.create(); | 
|         String orderId = orderInfoReq.getOrderId(); | 
|         String receiverId = orderInfoReq.getReceiver(); | 
|         Map receiverMap = new HashMap(); | 
|         OtherUserInfo otherUserInfo = otherUserMapper.selectByPrimaryKey(receiverId); | 
|         //1:外部骑手 | 
|         Short originType = otherUserInfo.getOriginType(); | 
|         String partnerId = otherUserInfo.getPartnerId(); | 
|         receiverMap.put("userId", orderInfoReq.getReceiver()); | 
|         Map createUserMap = new HashMap(); | 
|         String createUserId = orderInfoReq.getCreateUserId(); | 
|         createUserMap.put("userId", createUserId); | 
|         //环保金支付 | 
|         String recerverAccountId = null; | 
|         String createUserAccountId = null; | 
|   | 
|         List<AccountVo> receiverAccount = accountMapper.queryMyMoney(receiverMap); | 
|         if (CollUtil.isEmpty(receiverAccount)) { | 
|             throw new RestException("账户被禁用"); | 
|         } | 
|         String receiverLimit = receiverAccount.get(0).getOverdraftLimit(); | 
|         String receiverMoney = receiverAccount.get(0).getMoney(); | 
|         recerverAccountId = receiverAccount.get(0).getAccountId(); | 
|   | 
|         List<AccountVo> createUserAccount = accountMapper.queryMyMoney(createUserMap); | 
|         if (CollUtil.isEmpty(createUserAccount)) { | 
|             throw new RestException("用户账户被禁用"); | 
|         } | 
|         createUserAccountId = createUserAccount.get(0).getAccountId(); | 
|         String createUserMobile = createUserAccount.get(0).getAccountName(); | 
|         dict.set("createUserPhone", createUserMobile); | 
|         String createUserMoney = createUserAccount.get(0).getMoney(); | 
|         //阶梯提成 | 
|         BigDecimal stepMul = orderInfoReq.getStepMul(); | 
|         BigDecimal stepMulForReceiver = businessUtil.changeMul(orderInfoReq.getStepMulForReceiver()); | 
|         BigDecimal stepMulForPartner = businessUtil.changeMul(orderInfoReq.getStepMulForPartner()); | 
|   | 
|         PartnerAccount byPartnerId; | 
|   | 
|   | 
|         //除去返利后的真实订单金额 | 
|         BigDecimal realMoney = Convert.toBigDecimal(orderInfoReq.getMoney()); | 
|   | 
|             if (orderInfoReq.getType() == 0) { | 
|                 realMoney = NumberUtil.sub(realMoney, stepMulForReceiver); | 
|             } else if (orderInfoReq.getType() == 1) { | 
|                 realMoney = NumberUtil.sub(realMoney, stepMulForReceiver, stepMulForPartner); | 
|             } | 
|   | 
|             if(originType==null||originType.intValue()==0) { | 
|                 //判断合伙人的账户的钱是否够 | 
|                 if (stepMulForPartner != null) { | 
|                     byPartnerId = partnerAccountService.findByPartnerId(partnerId); | 
|                     if (byPartnerId != null) { | 
|                         String hbb = byPartnerId.getHbb(); | 
|                         if (Convert.toBigDecimal(hbb, BigDecimal.ZERO).compareTo(stepMulForPartner) < 0) { | 
|                             throw new RestException(-1, "合伙人账户余额不足,支付失败"); | 
|                         } | 
|                     } else { | 
|                         throw new RestException(-1, "合伙人账户不存在"); | 
|                     } | 
|                 } | 
|             } | 
|   | 
|   | 
|             //环保必支付 | 
|         if (!PayEnum.现金支出.getValue().equals(orderInfoReq.getPayType())) { | 
|   | 
|             Map<String, Object> payMap = new HashMap(); | 
|   | 
|             //回收员 | 
|             String otherPayOrderId = idUtils.generate("ZF", 0); | 
|             payMap.put("payOrderId", otherPayOrderId); | 
|             payMap.put("orderId", orderInfoReq.getOrderId()); | 
|             payMap.put("createUserId", orderInfoReq.getReceiver()); | 
|             payMap.put("money", realMoney.toString()); | 
|             payMap.put("accountId", recerverAccountId); | 
|             //环保金 | 
|             if (!PayEnum.现金支出.getValue().equals(orderInfoReq.getPayType())) { | 
|                 payMap.put("payType", PayEnum.环保金支出.getValue()); | 
|             } else { | 
|                 payMap.put("payType", PayEnum.现金支出.getValue()); | 
|             } | 
|             payMap.put("status", PayEnum.已支付.getValue());//2表示已支付 | 
|             payMap.put("createTime", now); | 
|             payInfoMapper.payInfoAdd(payMap); | 
|   | 
|             BigDecimal otherOldMoney = Convert.toBigDecimal(receiverMoney); | 
|             BigDecimal oldMoney = null; | 
|             int otherMoneyType = 0; | 
|             //正常下单 | 
|             if (orderInfoReq.getType() == 0) { | 
|                 Map map = new HashMap<>(); | 
|                 String money = orderInfoReq.getMoney(); | 
|                 BigDecimal moneyDecimal = NumberUtil.toBigDecimal(money); | 
|                 //回收员支出 | 
|                 //回收员扣透支额度,如果小于0,则再扣环保金  5  1    4 | 
|                 //环保金加额度小于支付金额,则提示金额不够 | 
|                 BigDecimal receiverLimitDecimal = NumberUtil.toBigDecimal(receiverLimit); | 
|                 BigDecimal receiverMoneyDecimal = NumberUtil.toBigDecimal(receiverMoney); | 
|   | 
|   | 
|                 if (NumberUtil.isLess(NumberUtil.add(receiverLimitDecimal, receiverMoneyDecimal), moneyDecimal)) { | 
|                     //支付金额不足 | 
|                     throw new RestException(-1, "支付金额不足"); | 
|                 } else if (NumberUtil.isLessOrEqual(moneyDecimal, receiverLimitDecimal)) { | 
|                     //支付金额小于等于支付额度  优先扣除支付额度 | 
|                     map.put("userId", orderInfoReq.getReceiver()); | 
|                     map.put("money", Convert.toBigDecimal("-" + money)); | 
|                     log.info("支付金额小于支付额度:{}", JSONUtil.formatJsonStr(JSONUtil.toJsonStr(map))); | 
|                     accountMapper.updateLimitByOrder(map); | 
|                 } else if (NumberUtil.isGreater(moneyDecimal, receiverLimitDecimal)) { | 
|                     //支付金额大于支付额度 也是优先扣除额度变为0  剩下的用余额扣除 | 
|                     BigDecimal actualMoney = NumberUtil.sub(moneyDecimal, receiverLimitDecimal); | 
|                     map.clear(); | 
|                     map.put("userId", orderInfoReq.getReceiver()); | 
|                     map.put("money", Convert.toBigDecimal("-" + actualMoney)); | 
|                     map.put("limit", BigDecimal.ZERO); | 
|                     log.info("支付金额大于支付额度:{}", JSONUtil.formatJsonStr(JSONUtil.toJsonStr(map))); | 
|                     accountMapper.updateMoneyAndLimit(map); | 
|                 } | 
|   | 
|                 /** | 
|                  * 操作回收员的账户日志 | 
|                  */ | 
|                 AccountLog accountLog = new AccountLog(); | 
|                 accountLog.setAccountId(recerverAccountId); | 
|                 accountLog.setCreateUserId(orderInfoReq.getReceiver()); | 
|                 accountLog.setChannelType(Convert.toShort(CommonEnum.回收操作.getValue())); | 
|                 accountLog.setOrderId(otherPayOrderId); | 
|                 if (NumberUtil.isLessOrEqual(realMoney, receiverLimitDecimal)) { | 
|                     accountLog.setOldLimit(receiverLimit); | 
|                     accountLog.setNewLimit(Convert.toStr(NumberUtil.sub(Convert.toBigDecimal(accountLog.getOldLimit()), realMoney))); | 
|                     otherOldMoney = Convert.toBigDecimal(accountLog.getNewLimit()); | 
|                     otherMoneyType = 1; | 
|                 } else if (NumberUtil.isGreater(realMoney, receiverLimitDecimal)) { | 
|                     BigDecimal actualMoney = NumberUtil.sub(realMoney, receiverLimitDecimal); | 
|                     accountLog.setOldLimit(receiverLimit); | 
|                     accountLog.setNewLimit(Convert.toStr(Constants.MONEY_INIT)); | 
|                     accountLog.setOldMoney(receiverMoney); | 
|                     accountLog.setNewMoney(businessUtil.changeMoney(NumberUtil.sub(Convert.toBigDecimal(accountLog.getOldMoney()), actualMoney))); | 
|                     otherOldMoney = Convert.toBigDecimal(accountLog.getNewMoney()); | 
|                     otherMoneyType = 2; | 
|                 } | 
|                 accountLogService.add(accountLog); | 
|   | 
|                 //普通用户环保金增加 | 
|                 map.clear(); | 
|                 map.put("userId", createUserId); | 
|   | 
|                 //含所有返利的总支付金额 | 
|                 BigDecimal allMoney = moneyDecimal; | 
|                 if (stepMulForPartner != null) { | 
|                     allMoney = NumberUtil.add(moneyDecimal, stepMulForPartner); | 
|                 } | 
|                 map.put("money", allMoney); | 
|                 accountMapper.updateMyMoneyByOrder(map); | 
|   | 
|                 String payOrderId = idUtils.generate("ZF", 0); | 
|                 payMap.clear(); | 
|                 payMap.put("payOrderId", payOrderId); | 
|                 payMap.put("orderId", orderInfoReq.getOrderId()); | 
|                 payMap.put("createUserId", createUserId); | 
|                 payMap.put("money", realMoney.toString()); | 
|                 payMap.put("accountId", createUserAccountId); | 
|                 if (!PayEnum.现金支出.getValue().equals(orderInfoReq.getPayType())) { | 
|                     //环保金支付 | 
|                     payMap.put("payType", PayEnum.环保金收入.getValue()); | 
|                 } else { | 
|                     payMap.put("payType", PayEnum.现金收入.getValue()); | 
|                 } | 
|                 payMap.put("status", PayEnum.已支付.getValue()); | 
|                 payMap.put("createTime", now); | 
|                 payInfoMapper.payInfoAdd(payMap); | 
|   | 
|                 AccountLog accountLog2 = new AccountLog(); | 
|                 accountLog2.setAccountId(createUserAccountId); | 
|                 accountLog2.setCreateUserId(createUserId); | 
|                 accountLog2.setChannelType(Convert.toShort(CommonEnum.回收操作.getValue())); | 
|                 accountLog2.setOldMoney(createUserMoney); | 
|                 oldMoney = NumberUtil.add(Convert.toBigDecimal(createUserMoney), realMoney); | 
|                 accountLog2.setNewMoney(Convert.toStr(oldMoney)); | 
|                 accountLog2.setOrderId(payOrderId); | 
|                 accountLogService.add(accountLog2); | 
|             } | 
|   | 
|   | 
|             //只有内部骑手才有返利 | 
|             if(originType==null||originType.intValue()==0) { | 
|                 /** | 
|                  * 阶梯返利 | 
|                  */ | 
|                 AllAcountParamDto allAcountParamDto = AllAcountParamDto.builder().type(4).flowNo(orderId).orderType(orderInfoReq.getType()).oldMoney(oldMoney). | 
|                         otherOldMoney(otherOldMoney). | 
|                         otherUserId(receiverId).otherAccountId(recerverAccountId).ruleId(orderInfoReq.getRuleId()) | 
|                         .money(stepMul).userId(createUserId).accountId(createUserAccountId).partnerId(partnerId).build(); | 
|                 new AccountContext(stairRebateService).account(allAcountParamDto); | 
|   | 
|   | 
|                 /** | 
|                  * 重量返利支出 | 
|                  * oldmoney 用户增加了回收订单金额的金额 | 
|                  * otherOldMoney 回收员扣除了回收订单后的金额 | 
|                  * otherMoney  回收员返利 | 
|                  * money 合伙人返利 | 
|                  * | 
|                  */ | 
|                 allAcountParamDto = AllAcountParamDto.builder().type(3).flowNo(orderId).orderType(orderInfoReq.getType()).oldMoney(oldMoney). | 
|                         otherUserId(receiverId).otherAccountId(recerverAccountId).otherMoney(stepMulForReceiver).otherOldMoney(businessUtil.changeMul(receiverMoney)).ruleId(orderInfoReq.getRuleId()) | 
|                         .money(stepMulForPartner).userId(createUserId).accountId(createUserAccountId).partnerId(partnerId).otherOldMoney(otherOldMoney).otherMoneyType(otherMoneyType).build(); | 
|                 new AccountContext(weightRebateService).account(allAcountParamDto); | 
|   | 
|   | 
|                 /** | 
|                  * 分享返利 | 
|                  */ | 
|                 allAcountParamDto = AllAcountParamDto.builder().type(2).flowNo(orderId).money(realMoney).mobile(createUserMobile).partnerId(partnerId) | 
|                         .otherUserId(createUserId).ruleId(orderInfoReq.getRuleId()).build(); | 
|                 new AccountContext(shareRebateService).account(allAcountParamDto); | 
|             } | 
|         } | 
|   | 
|   | 
|         //修改目标客户的状态 | 
|         UserTargetInfo userTargetInfo = new UserTargetInfo(); | 
|         userTargetInfo.setRegsterType(Convert.toInt(UserEnum.已成交.getValue())); | 
|         Example example2 = new Example(UserTargetInfo.class); | 
|         example2.createCriteria().andEqualTo("mobile", createUserMobile); | 
|         userTargetInfoMapper.updateByExampleSelective(userTargetInfo, example2); | 
|   | 
|         if(originType==null||originType.intValue()==0) { | 
|             //提佣 | 
|             AllAcountParamDto allAcountParamDto = AllAcountParamDto.builder().type(0).flowNo(orderId).userId(createUserId).money(realMoney).partnerId(partnerId).build(); | 
|             new AccountContext(commissionsService).account(allAcountParamDto); | 
|         } | 
|   | 
|         /***********消息相关************/ | 
|         SysMessage sysMessage = new SysMessage(); | 
|         if (orderInfoReq.getType() == 0) { | 
|             sysMessage.setCreateTime(now); | 
|             sysMessage.setCreateUserId(orderInfoReq.getReceiver()); | 
|             sysMessage.setFlag(SysEnum.未读.getValue()); | 
|             if (PayEnum.现金支出.getValue().equals(orderInfoReq.getPayType())) { | 
|                 sysMessage.setMessage("订单" + orderInfoReq.getOrderId() + "完成"); | 
|             } else { | 
|                 sysMessage.setMessage("订单" + orderInfoReq.getOrderId() + "完成,您收到环保金" + orderInfoReq.getMoney() + "元"); | 
|             } | 
|             sysMessage.setMessageSubTypeName("赚取"); | 
|             sysMessage.setMessageType(SysEnum.充值.getValue()); | 
|             sysMessage.setUserId(createUserId); | 
|             sysMessageMapper.insert(sysMessage); | 
|         } | 
|   | 
|         sysMessage.setCreateTime(now); | 
|         sysMessage.setCreateUserId(orderInfoReq.getReceiver()); | 
|         sysMessage.setFlag(SysEnum.未读.getValue()); | 
|         if (PayEnum.现金支出.getValue().equals(orderInfoReq.getPayType())) { | 
|             sysMessage.setMessage("订单" + orderInfoReq.getOrderId() + "完成,您支出现金" + orderInfoReq.getMoney() + "元"); | 
|         } else { | 
|             sysMessage.setMessage("订单" + orderInfoReq.getOrderId() + "完成,您支出环保金" + orderInfoReq.getMoney() + "元"); | 
|   | 
|         } | 
|         sysMessage.setMessageSubTypeName("支出"); | 
|         sysMessage.setMessageType(SysEnum.充值.getValue()); | 
|         sysMessage.setUserId(orderInfoReq.getReceiver()); | 
|         sysMessageMapper.insert(sysMessage); | 
|   | 
|   | 
|         return dict; | 
|     } | 
|   | 
|   | 
|     public int updateOrderCancelReason(OrderInfoReq orderInfoReq) { | 
|   | 
|         try { | 
|             //更新订单取消原因 | 
|             orderMapper.updateOrderCancelReason(orderInfoReq); | 
|   | 
|             //插入操作记录 | 
|             OrderOperationInfo operationInfo = new OrderOperationInfo(); | 
|             operationInfo.setOrderId(orderInfoReq.getOrderId()); | 
|             operationInfo.setOperateContent("更新订单取消原因"); | 
|             //获取操作时间 | 
|             operationInfo.setOperateTime(DateUtil.now()); | 
|             //6为已取消 | 
|             operationInfo.setOrderStatus(OrderEnum.取消.getValue()); | 
|             if (StringUtils.isNotBlank(orderInfoReq.getCancelUserId())) { | 
|                 operationInfo.setOperateUserId(orderInfoReq.getCancelUserId()); | 
|             } | 
|         } catch (Exception e) { | 
|             ExceptionUtils.err("订单取消原因更新失败", e); | 
|         } | 
|         return 0; | 
|     } | 
|   | 
|     private Dict cancelOrder(OrderInfoReq orderInfoReq) { | 
|         Dict dict = Dict.create(); | 
|         String createTime = DateUtils.getCurDateTime(); | 
|         List<OrderInfoVo> orderDetail = orderMapper.orderDetailQuery(orderInfoReq); | 
|   | 
|   | 
|         String createUserId = orderDetail.get(0).getCreateUserId(); | 
|         //回收员接收的消息(如果普通用户与取消人是同一个人,则不需要重复发消息) | 
|         SysMessage sysMessage = new SysMessage(); | 
|   | 
|         //回收员取消的 | 
|         if (StringUtils.isNotBlank(orderInfoReq.getCancelUserId()) && !orderInfoReq.getCancelUserId().equals(createUserId)) { | 
|             sysMessage.setCreateTime(createTime); | 
|             sysMessage.setCreateUserId(orderInfoReq.getCancelUserId()); | 
|             sysMessage.setFlag(SysEnum.未读.getValue()); | 
|             sysMessage.setMessage("订单" + orderInfoReq.getOrderId() + "已经取消"); | 
|             sysMessage.setMessageSubTypeName("取消订单"); | 
|             sysMessage.setMessageType("1"); | 
|             sysMessage.setUserId(orderInfoReq.getCancelUserId()); | 
|             sysMessageMapper.insert(sysMessage); | 
|         } else { | 
|             //用户取消订单前判断订单是否是待接单 | 
|             if (!OrderEnum.待接单.getValue().equals(orderDetail.get(0).getOrderStatus())) { | 
|                 throw new RestException(-1, "当前订单不可取消"); | 
|             } | 
|         } | 
|   | 
|         if (orderInfoReq.getType() == 0) { | 
|             //普通用户接收的消息 | 
|             SysMessage sysMessage2 = new SysMessage(); | 
|             sysMessage2.setCreateTime(createTime); | 
|             sysMessage2.setCreateUserId(orderInfoReq.getCancelUserId()); | 
|             sysMessage2.setFlag(SysEnum.未读.getValue()); //0为新消息 | 
|             sysMessage2.setMessage("您的订单" + orderInfoReq.getOrderId() + "已经取消"); | 
|             sysMessage2.setMessageSubTypeName("取消订单"); | 
|             sysMessage2.setMessageType("1"); | 
|             sysMessage2.setUserId(createUserId); | 
|             sysMessageMapper.insert(sysMessage2); | 
|         } | 
|   | 
|         return dict; | 
|     } | 
|   | 
|   | 
|     private void checkOrder(OrderInfoReq orderInfoReq) { | 
|         OrderInfo orderInfo = new OrderInfo(); | 
|         orderInfo.setOrderId(orderInfoReq.getOrderId()); | 
|         OrderInfo select = orderMapper.selectOne(orderInfo); | 
|         if (select.getOrderStatus().equals(orderInfoReq.getOrderStatus())) { | 
|             throw new RestException(-1, "订单已操作"); | 
|         } else { | 
|             orderInfoReq.setTraceId(select.getTraceId()); | 
|         } | 
|   | 
|     } | 
|   | 
|   | 
|     /** | 
|      * @param orderInfoReq | 
|      * @param receiverAccount 回收员账户 | 
|      * @param accountVo       入库员账户 | 
|      * @return | 
|      */ | 
|     public void storageAccount(OrderInfoReq orderInfoReq, AccountVo receiverAccount, AccountVo accountVo, int usertype, String partnerId) { | 
|         String now = DateUtil.now(); | 
|         String storageId = orderInfoReq.getStorageId(); | 
|         if (accountVo != null) { | 
|             BigDecimal limit = Convert.toBigDecimal(accountVo.getOverdraftLimit(), Constants.MONEY_INIT); | 
|             BigDecimal moneyDecimal = Convert.toBigDecimal(orderInfoReq.getStorageMoney()); | 
|             BigDecimal moneyDB = Convert.toBigDecimal(accountVo.getMoney(), Constants.MONEY_INIT); | 
|             String userId = accountVo.getUserId(); | 
|   | 
|             //入库员 | 
|             String otherPayOrderId = idUtils.generate("ZF", 0); | 
|             Map storageMap = new HashMap(); | 
|             storageMap.put("userId", orderInfoReq.getStorageUserId()); | 
|             List<AccountVo> storageAccount = accountMapper.queryMyMoney(storageMap); | 
|             String storageAccountId = storageAccount.get(0).getAccountId(); | 
|   | 
|             //明细 | 
|             Map payMap = new HashMap(); | 
|             payMap.put("payOrderId", otherPayOrderId); | 
|             payMap.put("orderId", storageId); | 
|             payMap.put("createUserId", orderInfoReq.getStorageUserId()); | 
|             payMap.put("money", orderInfoReq.getStorageMoney()); | 
|             payMap.put("accountId", storageAccountId); | 
|             if (!PayEnum.现金支出.getValue().equals(orderInfoReq.getPayType())) { | 
|                 payMap.put("payType", PayEnum.环保金支出.getValue()); | 
|             } else { | 
|                 payMap.put("payType", PayEnum.现金支出.getValue()); | 
|             } | 
|             payMap.put("status", PayEnum.已支付.getValue()); | 
|             payMap.put("createTime", now); | 
|             payInfoMapper.payInfoAdd(payMap); | 
|   | 
|   | 
|             AccountLog accountLog2 = new AccountLog(); | 
|             accountLog2.setCreateTime(now); | 
|             accountLog2.setAccountId(accountVo.getAccountId()); | 
|             accountLog2.setCreateUserId(userId); | 
|             accountLog2.setChannelType(Convert.toShort(CommonEnum.入库操作.getValue())); | 
|             accountLog2.setOrderId(otherPayOrderId); | 
|   | 
|             if (usertype == 1) { | 
|                 //入库员 | 
|                 //扣除仓管员的额度 | 
|                 AccountInfo accountInfo = new AccountInfo(); | 
|                 accountInfo.setAccountId(accountVo.getAccountId()); | 
|                 accountInfo.setOverdraftLimit(Convert.toStr(NumberUtil.sub(limit, moneyDecimal))); | 
|                 accountLog2.setOldLimit(limit.toString()); | 
|                 accountLog2.setNewLimit(accountInfo.getOverdraftLimit()); | 
|                 accountLogMapper.insertSelective(accountLog2); | 
|                 accountMapper.updateByPrimaryKeySelective(accountInfo); | 
|             } else if (usertype == 2) { | 
|                 Map map = new HashMap<>(); | 
|                 map.put("userId", userId); | 
|                 if (NumberUtil.isLessOrEqual(moneyDecimal, limit)) {//支付金额小于等于支付额度  优先扣除支付额度 | 
|                     map.put("money", Convert.toBigDecimal("-" + orderInfoReq.getStorageMoney())); | 
|                     log.info("打包员支付金额小于支付额度:{}", JSONUtil.formatJsonStr(JSONUtil.toJsonStr(map))); | 
|                     accountLog2.setOldLimit(limit.toString()); | 
|                     accountLog2.setNewLimit(Convert.toStr(NumberUtil.sub(limit, moneyDecimal))); | 
|                     accountMapper.updateLimitByOrder(map); | 
|                 } else if (NumberUtil.isGreater(moneyDecimal, limit)) {   //支付金额大于支付额度 也是优先扣除额度变为0  剩下的用余额扣除 | 
|                     BigDecimal actualMoney = NumberUtil.sub(moneyDecimal, limit); | 
|                     map.put("money", Convert.toBigDecimal("-" + actualMoney)); | 
|                     map.put("limit", BigDecimal.ZERO); | 
|                     log.info("打包员支付金额大于支付额度:{}", JSONUtil.formatJsonStr(JSONUtil.toJsonStr(map))); | 
|                     accountLog2.setOldLimit(limit.toString()); | 
|                     accountLog2.setNewLimit(Convert.toStr(Constants.MONEY_INIT)); | 
|                     accountLog2.setOldMoney(moneyDB.toString()); | 
|                     accountLog2.setNewMoney(Convert.toStr(NumberUtil.sub(moneyDB, actualMoney))); | 
|                     accountMapper.updateMoneyAndLimit(map); | 
|                 } | 
|                 accountLogMapper.insertSelective(accountLog2); | 
|             } | 
|         } | 
|   | 
|         //环保金支出 | 
|         if (PayEnum.环保金支出.getValue().equals(orderInfoReq.getPayType())) { | 
|   | 
|             String money = orderInfoReq.getStorageMoney(); | 
|   | 
|             //只有打包站入库才有提成 | 
|             if (usertype == 2) { | 
|                 //根据订单计算出回收员所有纸类的订单金额  其他分类由回收员自己回收 | 
| //                BigDecimal paperMoney = orderItemService.findMoneyByOrderIdsAndItemType(Constants.TIANXIN_CODE,orderInfoReq.getOrderId(), Constants.PAPER_ITEM_TYPE,paperBasic); | 
|                 money = businessUtil.changeMoney(orderInfoReq.getPaperMoney()); | 
|                 //要给平台用于提成结算的金额 | 
|                 BigDecimal platMoney = NumberUtil.sub(Convert.toBigDecimal(orderInfoReq.getStorageMoney()), Convert.toBigDecimal(money)); | 
|   | 
|                 if (platMoney.compareTo(BigDecimal.ZERO) < 0) { | 
|                     throw new RestException("入库失败"); | 
|                 } | 
|   | 
|                 if (platMoney.compareTo(BigDecimal.ZERO) > 0) { | 
|                     PartnerAccountLog partnerAccountLog = new PartnerAccountLog(); | 
|                     partnerAccountLog.setPartnerId(partnerId); | 
|                     partnerAccountLog.setFlowNo(orderInfoReq.getStorageId()); | 
|                     partnerAccountLog.setType(OrderEnum.结算提成.getValue()); | 
|                     partnerAccountLog.setMoney(platMoney.toString()); | 
|                     partnerAccountLogService.add(partnerAccountLog); | 
|                     partnerAccountService.updateAddMoneyByPartnerId(partnerId, platMoney); | 
|                 } | 
|             } | 
|             accountService.addAccount(receiverAccount, CommonEnum.入库操作.getValue(), orderInfoReq.getStorageId(), money); | 
|             orderInfoReq.setReceiveMoney(money); | 
|         } | 
|     } | 
|   | 
|   | 
|     public void storageMessage(OrderInfoReq orderInfoReq, String curDateTime) { | 
|         //回收员 | 
|         SysMessage sysMessage = new SysMessage(); | 
|         sysMessage.setCreateTime(curDateTime); | 
|         sysMessage.setCreateUserId(orderInfoReq.getStorageUserId()); | 
|         sysMessage.setFlag(SysEnum.未读.getValue()); | 
|         if (PayEnum.现金支出.getValue().equals(orderInfoReq.getPayType())) { | 
|             sysMessage.setMessage("订单" + orderInfoReq.getOrderId() + "入库完成,您收到环保金" + orderInfoReq.getReceiveMoney() + "元"); | 
|             sysMessage.setMessageSubTypeName("现金收入"); | 
|         } else { | 
|             sysMessage.setMessage("订单" + orderInfoReq.getOrderId() + "入库完成"); | 
|             sysMessage.setMessageSubTypeName("赚取"); | 
|         } | 
|         //充值提现根据文字匹配 不根据类型 | 
|         sysMessage.setMessageType(SysEnum.充值.getValue()); | 
|         sysMessage.setUserId(orderInfoReq.getReceiver()); | 
|         sysMessageMapper.insert(sysMessage); | 
|   | 
|         //入库员 | 
|         sysMessage.setCreateTime(curDateTime); | 
|         sysMessage.setCreateUserId(orderInfoReq.getStorageUserId()); | 
|         sysMessage.setFlag(SysEnum.未读.getValue()); | 
|         if (PayEnum.现金支出.getValue().equals(orderInfoReq.getPayType())) { | 
|             sysMessage.setMessage("订单" + orderInfoReq.getOrderId() + "入库完成"); | 
|             sysMessage.setMessageSubTypeName("现金支出"); | 
|         } else { | 
|             sysMessage.setMessage("订单" + orderInfoReq.getOrderId() + "入库完成,您支出额度" + orderInfoReq.getStorageMoney() + "元"); | 
|             sysMessage.setMessageSubTypeName("支出"); | 
|         } | 
|   | 
|         sysMessage.setMessageType(SysEnum.充值.getValue()); | 
|         sysMessage.setUserId(orderInfoReq.getStorageUserId()); | 
|         sysMessageMapper.insert(sysMessage); | 
|     } | 
|   | 
|   | 
|     public List<OrderStorageVo> orderStorageListQuery(OrderStorageReq orderStorageReq) { | 
|         if (orderStorageReq.getStorageStatus() == null) { | 
|             orderStorageReq.setStorageStatus(Convert.toShort(0)); | 
|         } | 
|         List<OrderStorageVo> orderStorageList = orderMapper.orderStorageListQuery(orderStorageReq); | 
|         return orderStorageList; | 
|     } | 
|   | 
|     public List<OrderStorageVo> orderStorageDetailQuery(OrderStorageReq orderStorageReq) { | 
|         if (orderStorageReq.getStorageStatus() == null) { | 
|             orderStorageReq.setStorageStatus(Convert.toShort(0)); | 
|         } | 
|         List<OrderStorageVo> orderStorageDetail = orderMapper.orderStorageListQuery(orderStorageReq); | 
|         if (CollUtil.isNotEmpty(orderStorageDetail)) { | 
|   | 
|             Integer sysStorageId = orderStorageDetail.get(0).getSysStorageId(); | 
|             Integer sysStorageType = orderStorageDetail.get(0).getSysStorageType(); | 
|             if (OrderEnum.仓库.getValue().equals(sysStorageType)) { | 
|                 orderStorageReq.setType(0); | 
|                 SysStorage byId = sysStorageService.findById(sysStorageId); | 
|                 orderStorageReq.setTownId(byId.getArea()); | 
|             } else if (OrderEnum.打包站.getValue().equals(sysStorageType)) { | 
|                 orderStorageReq.setType(1); | 
|                 orderStorageReq.setTownId(sysStorageId.toString()); | 
|             } | 
|             //入库明细查询 | 
|             orderStorageReq.setFlag("1"); | 
|             List<OrderItemVo> storageItemList = orderMapper.orderStorageDetailQuery(orderStorageReq); | 
|             //回收明细查询 | 
|             orderStorageReq.setFlag("2"); | 
|             List<OrderItemVo> recycleItemList = orderMapper.orderStorageDetailQuery(orderStorageReq); | 
|   | 
|   | 
|             orderStorageDetail.get(0).setStorageItemList(storageItemList); | 
|             orderStorageDetail.get(0).setRecycleItemList(recycleItemList); | 
|         } | 
|   | 
|         return orderStorageDetail; | 
|     } | 
|   | 
|     public OrderStatusCountVo orderListCount(OrderInfoReq orderInfoReq) { | 
|         String userType = orderInfoReq.getUserType(); | 
|         List<Map<String, Object>> result = null; | 
|   | 
|   | 
|         OrderStatusCountVo vo = null; | 
|         if (CommonEnum.普通用户.getValue().equals(userType)) {   // 普通用户 | 
|             result = orderMapper.statNormalUserOrder(orderInfoReq); | 
|             if (CollUtil.isNotEmpty(result)) { | 
|                 vo = changeBean(result, userType); | 
|             } else { | 
|                 vo = new OrderStatusCountVo(); | 
|             } | 
|         } else if (CommonEnum.回收员.getValue().equals(userType)) { // 员工用户 | 
|             result = orderMapper.statStaffUserOrder(orderInfoReq); | 
|             if (CollUtil.isNotEmpty(result)) { | 
|                 vo = changeBean(result, userType); | 
|             } else { | 
|                 vo = new OrderStatusCountVo(); | 
|             } | 
|         } | 
|         return vo; | 
|     } | 
|   | 
|     public List<OrderCustomDto> customerFind(String userId) { | 
|         return orderMapper.customerFind(userId); | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 根据围栏获取订单超时配置 | 
|      * | 
|      * @return | 
|      */ | 
|     public long getOrderTimeOut(String partnerId) { | 
|         if(StrUtil.isNotBlank(partnerId)) { | 
|             return Convert.toLong(partnerConfigService.findValueByPartnerAndCode(partnerId, SysConfigConstant.ORDERTIMEOUT, true)); | 
|         } | 
|         return 0; | 
|     } | 
|   | 
|     @Scheduled(cron = "${order.cancle.cron}") | 
|     @Async | 
|     public void cancelOrderTimeOut() { | 
|         log.trace("********定时执行超时订单任务开始【每1小时执行1次】*********"); | 
|         if (!SpringUtil.isCloud()) { | 
|             OrderInfo orderInfo = new OrderInfo(); | 
|             orderInfo.setOrderStatus(OrderEnum.待接单.getValue()); | 
|             orderInfo.setOrderType(OrderEnum.回收.getValue()); | 
|             List<OrderInfo> select = orderMapper.select(orderInfo); | 
|   | 
|             if (!CollectionUtils.isEmpty(select)) { | 
|                 for (OrderInfo info : select) { | 
|                     //订单超时时间 | 
|                     Long addressId = orderDetailService.findById(info.getOrderId()).getAddressId(); | 
|                     Map<String, Object> map = getPartnerIdByReceiveOrFence(info.getReceiver(), info.getTownId(),addressId.toString()); | 
|                     String partnerId= (String) map.get("partnerId"); | 
|                     long configValue = getOrderTimeOut(partnerId); | 
|                     //如果当前时间>=预约时间往后推configValue小时则取消订单 | 
|                     String reserveTime = info.getReserveTime(); | 
|                     DateTime parse = DateUtil.parse(reserveTime, DateUtils.DATE_FORMAT_YMDHMS); | 
|                     DateTime dateTime; | 
|                     if (SpringUtil.isDevOrTestOrCheck()) { | 
|                         dateTime = DateUtil.offsetSecond(parse, Convert.toInt(configValue)); | 
|                     } else { | 
|                         dateTime = DateUtil.offsetHour(parse, Convert.toInt(configValue)); | 
|                     } | 
|                     if (DateUtil.compare(new Date(), dateTime) >= 0) { | 
| //                        log.info("合伙人:{},配置超时时间为:{},当前运行环境为:{},当前时间:{},预约时间:{}",partnerId,configValue,SpringUtil.getActiveProfile(),DateUtil.now(),reserveTime); | 
|                         info.setOrderStatus(OrderEnum.取消.getValue()); | 
|                         //更新订单状态 | 
|                         orderMapper.updateByPrimaryKeySelective(info); | 
|                         //插入操作记录 | 
|                         OrderOperationInfo operationInfo = new OrderOperationInfo(); | 
|                         operationInfo.setOrderId(info.getOrderId()); | 
|                         operationInfo.setOperateContent("更新订单取消原因"); | 
|                         operationInfo.setOperateTime(DateUtil.now()); | 
|                         operationInfo.setOrderStatus(OrderEnum.取消.getValue()); | 
|                         operationInfo.setOperateUserId(info.getCreateUserId()); | 
|   | 
|                         //普通用户接收的消息 | 
|                         SysMessage sysMessage = new SysMessage(); | 
|                         sysMessage.setCreateTime(DateUtil.now()); | 
|                         sysMessage.setCreateUserId(info.getCreateUserId()); | 
|                         sysMessage.setFlag(SysEnum.未读.getValue()); | 
|                         sysMessage.setMessage("您的订单" + info.getOrderId() + "因为超时已经取消"); | 
|                         sysMessage.setMessageSubTypeName("取消订单"); | 
|                         sysMessage.setMessageType("1"); | 
|                         sysMessage.setUserId(info.getCreateUserId()); | 
|                         sysMessageMapper.insert(sysMessage); | 
|   | 
|                         //发送短信 | 
|                         if (environment.acceptsProfiles(Profiles.of("prod"))) { | 
|                             log.debug("开始发送定时取消订单短信"); | 
|                             try { | 
|                                 Map mapSms = new HashMap(); | 
|                                 mapSms.put("date", info.getCreateTime()); | 
|                                 String templateCode = Constants.ORDER_SMS_CANCLE_ZT_TEMPLATE; | 
|                                 UserInfo byId = userService.findById(info.getCreateUserId()); | 
|                                 if (byId != null) { | 
|                                     String phoneNum = byId.getMobilePhone(); | 
|                                     SmsUtil.send(phoneNum, mapSms, templateCode, CommonEnum.助通短信.getValue()); | 
|                                 } | 
|                             } catch (Exception e) { | 
|                                 log.error("自动取消订单短信发送失败", e); | 
|                             } | 
|                         } | 
|                         redisUtil.del(Constants.REDIS_ORDER_KEY + "status:" + info.getOrderId()); | 
|                         log.info("********因为超时已取消订单号【{}】*********", info.getOrderId()); | 
|                     } | 
|                 } | 
|             } | 
|         } | 
|   | 
|         log.trace("********定时执行超时订单任务结束【每1小时执行1次】*********"); | 
|     } | 
|   | 
|     private OrderStatusCountVo changeBean(List<Map<String, Object>> list, String userType) { | 
|         OrderStatusCountVo vo = new OrderStatusCountVo(); | 
|         for (Map m : list) { | 
|             String num = m.get("orderNum") == null ? "0" : m.get("orderNum").toString(); | 
|             if ("djdCount".equals(m.get("orderStatus"))) { | 
|                 vo.setDjdCount(num); | 
|             } else if ("fwzCount".equals(m.get("orderStatus"))) { | 
|                 vo.setFwzCount(num); | 
|             } else if ("dqrCount".equals(m.get("orderStatus"))) { | 
|                 vo.setDqrCount(num); | 
|             } else if ("drkCount".equals(m.get("orderStatus"))) { | 
|                 vo.setDrkCount(num); | 
|             } else if ("wcCount".equals(m.get("orderStatus"))) { | 
|                 vo.setWcCount(num); | 
|             } else if ("cancelCount".equals(m.get("orderStatus"))) { | 
|                 vo.setCancelCount(num); | 
|             } else if ("recyleingCount".equals(m.get("orderStatus"))) { | 
|                 vo.setRecyleingCount(num); | 
|             } | 
|         } | 
|   | 
|   | 
|         int total = 0; | 
|         if (CommonEnum.普通用户.getValue().equals(userType)) { | 
|             vo.setWcCount(String.valueOf(Integer.parseInt(vo.getDrkCount() != null && !"".equals(vo.getDrkCount()) ? vo.getDrkCount() : "0") | 
|                     + Integer.parseInt(vo.getWcCount() != null && !"".equals(vo.getWcCount()) ? vo.getWcCount() : "0") + Integer.parseInt(vo.getRecyleingCount() != null && !"".equals(vo.getRecyleingCount()) ? vo.getRecyleingCount() : "0"))); | 
|   | 
|             total = Integer.parseInt((vo.getDjdCount() == null || "".equals(vo.getDjdCount())) ? "0" : vo.getDjdCount()) | 
|                     + Integer.parseInt((vo.getFwzCount() == null || "".equals(vo.getFwzCount())) ? "0" : vo.getFwzCount()) | 
|                     + Integer.parseInt((vo.getWcCount() == null || "".equals(vo.getWcCount())) ? "0" : vo.getWcCount()) | 
|                     + Integer.parseInt((vo.getCancelCount() == null || "".equals(vo.getCancelCount())) ? "0" : vo.getCancelCount()); | 
|         } else if (CommonEnum.回收员.getValue().equals(userType)) { | 
|             vo.setDrkCount(String.valueOf(Integer.parseInt(vo.getDrkCount() != null && !"".equals(vo.getDrkCount()) ? vo.getDrkCount() : "0") | 
|                     + Integer.parseInt(vo.getRecyleingCount() != null && !"".equals(vo.getRecyleingCount()) ? vo.getRecyleingCount() : "0"))); | 
|   | 
|             total = | 
|                     Integer.parseInt((vo.getFwzCount() == null || "".equals(vo.getFwzCount())) ? "0" : vo.getFwzCount()) | 
|                             + Integer.parseInt((vo.getDrkCount() == null || "".equals(vo.getDrkCount())) ? "0" : vo.getDrkCount()) | 
|                             + Integer.parseInt((vo.getWcCount() == null || "".equals(vo.getWcCount())) ? "0" : vo.getWcCount()) | 
|                             + Integer.parseInt((vo.getCancelCount() == null || "".equals(vo.getCancelCount())) ? "0" : vo.getCancelCount()); | 
|         } | 
|         vo.setSumCount(total + ""); | 
|         return vo; | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 用户下单总重量 包括家电类的 | 
|      * | 
|      * @param userId | 
|      * @return | 
|      */ | 
|     public BigDecimal findSumWeight(String userId, RedPaperRule one) { | 
|         BigDecimal sumWeight = orderMapper.findSumWeight(userId); | 
|         if (sumWeight == null) { | 
|             sumWeight = BigDecimal.ZERO; | 
|         } | 
|   | 
|         List<String> childItemTypeByType = sysEnvironmentalInfoService.findChildItemTypeByType(Constants.TIANXIN_CODE, Constants.HOUSE_HOLD_ITEM_TYPE); | 
|         List<OrderItemInfo> houseHold = orderItemService.findByUserIdAndTypesWithComplete(userId, childItemTypeByType); | 
|         //家电折算成30kg/每个 | 
|         int amountNum = 0; | 
|         if (CollUtil.isNotEmpty(houseHold)) { | 
|             for (OrderItemInfo orderItemInfo : houseHold) { | 
|                 String amount = orderItemInfo.getAmount(); | 
|                 if (StrUtil.isNotBlank(amount)) { | 
|                     amountNum = amountNum + Convert.toInt(amount, 0); | 
|                 } | 
|             } | 
|         } | 
|         String conversionPerUnit = one.getConversionPerUnit(); | 
|         if (StrUtil.isBlank(conversionPerUnit)) { | 
|             conversionPerUnit = "0"; | 
|         } | 
|         BigDecimal i = NumberUtil.mul(Convert.toBigDecimal(amountNum), Convert.toBigDecimal(conversionPerUnit)); | 
|         sumWeight = NumberUtil.add(sumWeight, i); | 
|         return sumWeight; | 
|     } | 
|   | 
|   | 
|     public OrderInfo findById(String orderId) { | 
|         return orderMapper.selectByPrimaryKey(orderId); | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 根据回收员查询某个状态的单 | 
|      * | 
|      * @param receiver | 
|      * @param orderStatus 状态 | 
|      * @return | 
|      */ | 
|     public List<OrderInfo> findDetailByReceiverAndStatus(String receiver, String orderStatus) { | 
|         List<OrderInfo> list1 = orderMapper.findDetailByReceiverAndStatus(receiver, orderStatus); | 
|         return list1; | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 最大接单数 | 
|      * | 
|      * @return | 
|      */ | 
|     public int maxOrderNum(String receiverId) { | 
|         String num; | 
|         OtherUserInfo byId = otherUserService.findById(receiverId); | 
|         //外部骑手 | 
|         if(byId.getOriginType()!=null&&byId.getOriginType().intValue()==1){ | 
|             num=configService.findByCode(SysConfigConstant.OUTER_ORDERTOTAL).getConfigValue(); | 
|         }else { | 
|             //内部骑手 | 
|             String partnerId = byId.getPartnerId(); | 
|             num = partnerConfigService.findValueByPartnerAndCode(partnerId, SysConfigConstant.ORDERTOTAL, true); | 
|         } | 
|         return Convert.toInt(num); | 
|     } | 
|   | 
|     /** | 
|      * 重新指派 | 
|      * | 
|      * @param orderPointDto | 
|      */ | 
|     public Result point(OrderPointDto orderPointDto) { | 
|         //新的回收员id | 
|         String userId = orderPointDto.getUserId(); | 
|   | 
|         int maxOrderNum = maxOrderNum(userId); | 
|   | 
|         String oldUserId = orderPointDto.getOldUserId(); | 
|   | 
|         String orderId = orderPointDto.getOrderId(); | 
|   | 
|         String orderUserId = orderPointDto.getOrderUserId(); | 
|   | 
|         String now = DateUtil.now(); | 
|   | 
|         String operUserId = request.getHeader("userId"); | 
|   | 
|         int orderNum = findReceiveOrderNum(userId); | 
|         //判断指派的回收员是否超过接单数 | 
|         if (orderNum >= maxOrderNum) { | 
|             return Result.error(-1, "指派的回收员已经达到最大接单数:" + maxOrderNum); | 
|         } | 
|   | 
|         OrderInfo orderInfo = orderMapper.selectByPrimaryKey(orderId); | 
|         OtherUserInfo otherUserInfo = otherUserMapper.selectByPrimaryKey(userId); | 
|         OrderDetailInfo orderDetailInfo = orderDetailMapper.selectByPrimaryKey(orderId); | 
|         String traceId = null; | 
|         //轨迹操作 | 
|         if (businessUtil.getVersion(request.getHeader("version")).compareTo(Convert.toDouble(CommonEnum.版本号1点5点2.getValue())) >= 0) { | 
|             //派单 在当前终端下新生成一条轨迹 | 
|             if (StrUtil.isBlank(oldUserId)) { | 
|                 PartnerTrace byUserIdAndType = partnerTraceService.findByUserIdAndType(userId, null); | 
|                 if (byUserIdAndType != null) { | 
|                     String key = byUserIdAndType.getPartnerKey(); | 
|                     String sid = byUserIdAndType.getPartnerServiceId(); | 
|                     String tid = byUserIdAndType.getOtherUserInfo().getTerminalId(); | 
|                     Result trace = GdTraceUtil.createTrace(key, sid, tid); | 
|                     if (trace.getCode() == 0) { | 
|                         traceId = trace.getData().toString(); | 
|                     } | 
|                 } | 
|             } else { | 
|                 PartnerTrace byUserIdAndType = partnerTraceService.findByUserIdAndType(oldUserId, null); | 
|                 if (byUserIdAndType != null) { | 
|                     String key = byUserIdAndType.getPartnerKey(); | 
|                     String sid = byUserIdAndType.getPartnerServiceId(); | 
|                     String tid = byUserIdAndType.getOtherUserInfo().getTerminalId(); | 
|   | 
|                     //重新指派  删除原终端下这条轨迹 在新的回收员终端下生成这条轨迹 | 
|                     CommonTraceDto commonTraceDto = new CommonTraceDto(); | 
|                     commonTraceDto.setKey(key); | 
|                     commonTraceDto.setSid(sid); | 
|                     commonTraceDto.setTid(tid); | 
|                     commonTraceDto.setTrid(orderInfo.getTraceId()); | 
|                     GdTraceUtil.deleteTrace(commonTraceDto); | 
|   | 
|                     Result trace = GdTraceUtil.createTrace(key, sid, otherUserInfo.getTerminalId()); | 
|                     if (trace.getCode() == 0) { | 
|                         traceId = trace.getData().toString(); | 
|                     } | 
|   | 
|                 } | 
|             } | 
|         } | 
|   | 
|   | 
|         //派单  ,指派将进行正常的接单操作 ,重新指派需要将订单的回收员信息及接单时间变更 | 
|         if (StrUtil.isBlank(oldUserId)) { | 
|             //指派 | 
|             orderInfo.setOrderStatus(OrderEnum.服务中.getValue()); | 
|             orderInfo.setReceiver(userId); | 
|             orderInfo.setTraceId(traceId); | 
|             orderMapper.updateByPrimaryKeySelective(orderInfo); | 
|   | 
|   | 
|             orderDetailInfo.setReceiveTime(now); | 
|             if (otherUserInfo != null) { | 
|                 orderDetailInfo.setReceiverName(otherUserInfo.getName()); | 
|                 orderDetailInfo.setReceiverPhone(otherUserInfo.getMobilePhone()); | 
|             } | 
|             orderDetailMapper.updateByPrimaryKeySelective(orderDetailInfo); | 
|         } else { | 
|             //重新指派 | 
|             orderInfo.setReceiver(userId); | 
|             orderInfo.setTraceId(traceId); | 
|             orderMapper.updateByPrimaryKeySelective(orderInfo); | 
|   | 
|             orderDetailInfo.setReceiveTime(now); | 
|             if (otherUserInfo != null) { | 
|                 orderDetailInfo.setReceiverName(otherUserInfo.getName()); | 
|                 orderDetailInfo.setReceiverPhone(otherUserInfo.getMobilePhone()); | 
|             } | 
|             orderDetailMapper.updateByPrimaryKeySelective(orderDetailInfo); | 
|         } | 
|   | 
|   | 
|         //发送消息给新回收员 重新指派同时也会发送消息给老回收员  如果是指派将发消息给用户 | 
|         SysMessage sysMessage = new SysMessage(); | 
|         sysMessage.setCreateTime(now); | 
|         sysMessage.setCreateUserId(operUserId); | 
|         sysMessage.setFlag(SysEnum.未读.getValue()); | 
|         sysMessage.setMessage("您已被系统派单" + orderId + ",请准时到达现场"); | 
|         sysMessage.setMessageSubTypeName("订单接单"); | 
|         sysMessage.setMessageType("1"); | 
|         sysMessage.setUserId(userId); | 
|         sysMessageMapper.insert(sysMessage); | 
|   | 
|         //重新指派 | 
|         if (StrUtil.isNotBlank(oldUserId)) { | 
|             sysMessage = new SysMessage(); | 
|             sysMessage.setCreateTime(now); | 
|             sysMessage.setCreateUserId(operUserId); | 
|             sysMessage.setFlag(SysEnum.未读.getValue()); | 
|             sysMessage.setMessage("您的订单" + orderId + "已被系统重新指派"); | 
|             sysMessage.setMessageSubTypeName("订单接单"); | 
|             sysMessage.setMessageType("1"); | 
|             sysMessage.setUserId(oldUserId); | 
|             sysMessageMapper.insert(sysMessage); | 
|         } else { | 
|             SysMessage sysMessage2 = new SysMessage(); | 
|             sysMessage2.setCreateTime(now); | 
|             sysMessage2.setCreateUserId(operUserId); | 
|             sysMessage2.setFlag(SysEnum.未读.getValue()); | 
|             sysMessage2.setMessage("您的订单" + orderId + "已经接单"); | 
|             sysMessage2.setMessageSubTypeName("订单接单"); | 
|             sysMessage2.setMessageType("1"); | 
|             sysMessage2.setUserId(orderUserId); | 
|             sysMessageMapper.insert(sysMessage2); | 
|         } | 
|   | 
|         //发送订单操作队列  指派只发送一条新回收员记录 重新指派将发送新老回收员各一条 | 
|         if (StrUtil.isNotBlank(oldUserId)) { | 
|   | 
|             OrderOperationInfo operationInfo = new OrderOperationInfo(); | 
|             operationInfo.setOrderId(orderId); | 
|             operationInfo.setOperateContent("取消重新指派"); | 
|             //获取操作时间 | 
|             operationInfo.setOperateTime(now); | 
|             operationInfo.setOrderStatus(OrderEnum.取消.getValue()); | 
|             operationInfo.setOperateUserId(oldUserId); | 
| //            mqUtil.send(MqConstants.ORDER_OPERATION_LOG_QUEUE, operationInfo); | 
|   | 
|   | 
|             operationInfo = new OrderOperationInfo(); | 
|             operationInfo.setOrderId(orderId); | 
|             operationInfo.setOperateContent("重新指派"); | 
|             //获取操作时间 | 
|             operationInfo.setOperateTime(now); | 
|             operationInfo.setOrderStatus(OrderEnum.服务中.getValue()); | 
|             operationInfo.setOperateUserId(userId); | 
| //            mqUtil.send(MqConstants.ORDER_OPERATION_LOG_QUEUE, operationInfo); | 
|         } else { | 
|             OrderOperationInfo operationInfo = new OrderOperationInfo(); | 
|             operationInfo.setOrderId(orderId); | 
|             operationInfo.setOperateContent("指派订单"); | 
|             //获取操作时间 | 
|             operationInfo.setOperateTime(now); | 
|             operationInfo.setOrderStatus(OrderEnum.服务中.getValue()); | 
|             operationInfo.setOperateUserId(userId); | 
| //            mqUtil.send(MqConstants.ORDER_OPERATION_LOG_QUEUE, operationInfo); | 
|         } | 
|   | 
|         redisUtil.del(Constants.REDIS_ORDER_KEY + "status:" + orderId); | 
|   | 
|   | 
|         if (businessUtil.getVersion(request.getHeader("version")).compareTo(Convert.toDouble(CommonEnum.版本号1点5点2.getValue())) >= 0) { | 
|   | 
|             if (StrUtil.isBlank(oldUserId)) { | 
|                 //派单 | 
|                 pushTrace(userId); | 
|             } else { | 
|                 //重新派单 | 
|                 pushTrace(userId); | 
|                 pushTrace(oldUserId); | 
|             } | 
|   | 
|         } | 
|   | 
|   | 
|         return Result.success(null); | 
|     } | 
|   | 
|     /** | 
|      * 根据用户推送轨迹 | 
|      * | 
|      * @param userId | 
|      */ | 
|     private void pushTrace(String userId) { | 
|         List<OrderInfo> detailByReceiverAndStatus = findDetailByReceiverAndStatus(userId, OrderEnum.服务中.getValue()); | 
|         StrBuilder strBuilder = StrBuilder.create(); | 
|         if (CollUtil.isNotEmpty(detailByReceiverAndStatus)) { | 
|             for (OrderInfo byReceiverAndStatus : detailByReceiverAndStatus) { | 
|                 strBuilder.append(byReceiverAndStatus.getTraceId() + ","); | 
|             } | 
|         } | 
|         if (strBuilder.length() > 0) { | 
|             String s = strBuilder.toString(); | 
|             String s1 = StrUtil.removeSuffix(s, ","); | 
|             //极光推送 | 
|             jgPushUtil.pushTrace(s1, userId); | 
|         } else { | 
|             //极光推送 | 
|             jgPushUtil.pushTrace("", userId); | 
|         } | 
|     } | 
|   | 
|     public List<ReceiveClock> findWorkOrder() { | 
|         return orderMapper.findWorkOrder(); | 
|     } | 
|   | 
|   | 
|     @Scheduled(cron = "${order.clock.cron}") | 
|     @Async | 
|     public void syncClock() { | 
|         log.trace("********定时同步回收员打卡时间【晚上11点执行】*********"); | 
|         if (!SpringUtil.isCloud()) { | 
|             //查询回收员每天第一次接单完成时间和最后1次接单完成时间 | 
|             List<ReceiveClock> workOrder = findWorkOrder(); | 
|             if (CollUtil.isNotEmpty(workOrder)) | 
|                 receiveClockMapper.insertList(workOrder); | 
|         } | 
|         log.trace("********定时同步回收员打卡时间【晚上11点执行】完毕*********"); | 
|     } | 
|   | 
|     @Scheduled(cron = "${order.partnerBalance.cron}") | 
|     @Async | 
|     public void syncMoney() { | 
|   | 
|         log.trace("********定时查询合伙人账户余额 【中午12点执行】*********"); | 
|         if (environment.acceptsProfiles(Profiles.of("prod"))) { | 
|             List<PartnerAccount> byType = partnerAccountService.findByType(CommonEnum.合伙人.getValue()); | 
|             for (PartnerAccount partnerAccount : byType) { | 
|                 String partnerId = partnerAccount.getPartnerId(); | 
|                 CityPartner byId = cityPartnerService.findById(Convert.toInt(partnerId)); | 
|                 //合伙人手机号 | 
|                 String mobilePhone = byId.getMobilePhone(); | 
|                 //合伙人余额 | 
|                 String hbb = businessUtil.changeMoney(partnerAccount.getHbb()); | 
|                 String money1 = Convert.toStr(Constants.MIN_PARTNER_MONEY); | 
|                 String money2 = Convert.toStr(Constants.MAX_PARTNER_MONEY); | 
|   | 
|                 BigDecimal bigDecimal1 = new BigDecimal(money1); | 
|                 BigDecimal bigDecimal2 = new BigDecimal(money2); | 
|   | 
|                 //当前时间格式化 | 
|                 Date now = new Date(); | 
|                 String key = Constants.REDIS_COMMON_KEY + "sms:partnerBalance"; | 
|                 List<String> hget = redisUtil.lrange(key, 0, -1); | 
|                 //短信2000之内隔天发送一次短信。低于1000,每天都发一次短信 | 
|                 if (bigDecimal1.compareTo(Convert.toBigDecimal(hbb)) > 0) { | 
|                     if (CollUtil.isEmpty(hget)) { | 
|                         //1档代表是1000以下 2是5000以下1000以上 | 
|                         sendSms(hbb, money1, mobilePhone, "1", now, partnerId, key); | 
|                     } else { | 
|                         List<SmsDto> smsDto = new ArrayList<>(); | 
|                         for (String s : hget) { | 
|                             smsDto.add(JSONUtil.toBean(s, SmsDto.class)); | 
|                         } | 
|                         //判断 | 
|                         long count = smsDto.stream().filter(x -> DateUtil.isSameDay(now, x.getDate()) && partnerId.equals(x.getId()) && "1".equals(x.getExtra())).count(); | 
|   | 
|                         //当天没发送过短信就发送 | 
|                         if (count == 0) { | 
|                             sendSms(hbb, money1, mobilePhone, "1", now, partnerId, key); | 
|                         } | 
|                     } | 
|                 } else if (bigDecimal2.compareTo(Convert.toBigDecimal(hbb)) > 0) { | 
|                     if (CollUtil.isEmpty(hget)) { | 
|                         //1档代表是1000以下 2是5000以下1000以上 | 
|                         sendSms(hbb, money2, mobilePhone, "2", now, partnerId, key); | 
|                     } else { | 
|                         List<SmsDto> smsDto = new ArrayList<>(); | 
|                         for (String s : hget) { | 
|                             smsDto.add(JSONUtil.toBean(s, SmsDto.class)); | 
|                         } | 
|                         long count1 = smsDto.stream().filter(x -> partnerId.equals(x.getId()) && "2".equals(x.getExtra())).count(); | 
|                         if (count1 == 0) { | 
|                             sendSms(hbb, money2, mobilePhone, "2", now, partnerId, key); | 
|                         } else { | 
|                             //判断 | 
|                             long count = smsDto.stream().filter(x -> DateUtil.betweenDay(x.getDate(), now, true) == 2 && partnerId.equals(x.getId()) && "2".equals(x.getExtra())).count(); | 
|                             if (count == 1) { | 
|                                 sendSms(hbb, money2, mobilePhone, "2", now, partnerId, key); | 
|                             } | 
|                         } | 
|                     } | 
|                 } else { | 
|                     continue; | 
|                 } | 
|   | 
|             } | 
|         } | 
|         log.trace("********定时查询合伙人账户余额【中午12点执行】完毕*********"); | 
|     } | 
|   | 
|   | 
|     private void sendSms(String money, String fix, String mobile, String extra, Date now, String partnerId, String key) { | 
|         Map<String, Object> map = MapUtil.newHashMap(); | 
|         map.put("time", DateUtil.format(now, DateUtils.CHINESE_DATE_FORMAT_MDHM)); | 
|         map.put("money", money); | 
|         map.put("fix", fix); | 
|         String content = StrUtil.format("尊敬的客户,截至{time},您的账户余额为:{money}元,已不足{fix},请及时充值,以免影响您的业务和正常交易", map); | 
|         int i = SmsUtil.sendPoint(mobile, content); | 
|         if (i == 0) { | 
|             SmsDto smsDto = new SmsDto(); | 
|             smsDto.setDate(now); | 
|             smsDto.setExtra(extra); | 
|             smsDto.setMobile(mobile); | 
|             smsDto.setId(partnerId); | 
|             redisUtil.rpush(key, JSONUtil.toJsonStr(smsDto)); | 
|         } | 
|     } | 
|   | 
|   | 
|     /** | 
|      * @param userId | 
|      * @param time | 
|      * @param type | 
|      * @return | 
|      */ | 
|     public int findByCreateTime(String userId, String time, int type) { | 
|         Example example = new Example(OrderInfo.class); | 
|         Example.Criteria criteria = example.createCriteria(); | 
|         criteria.andEqualTo("createUserId", userId); | 
|         List<String> list = new ArrayList<>(); | 
|         list.add(OrderEnum.待入库.getValue()); | 
|         list.add(OrderEnum.入库中.getValue()); | 
|         list.add(OrderEnum.完成.getValue()); | 
|         criteria.andIn("orderStatus", list); | 
|         //上线时间 | 
|         if (0 == type) { | 
|             criteria.andGreaterThan("createTime", time); | 
|         } else if (1 == type) { | 
|             criteria.andLessThan("createTime", time); | 
|         } | 
|         int i = orderMapper.selectCountByExample(example); | 
|         return i; | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 根据订单好查询订单详细 | 
|      * | 
|      * @param orderModel | 
|      * @return | 
|      */ | 
|     public Map<String, Object> queryOrderByOrderno(OrderModel orderModel) { | 
|         String orderNo = orderModel.getOrderId(); | 
|         int page = orderModel.getPage(); | 
|         int limit = orderModel.getLimit(); | 
|         Map<String, Object> result = new HashMap<>(); | 
|         PageHelper.startPage(page, limit); | 
|         List<Map<String, Object>> list = orderMapper.queryOrderPageByOrderno(orderNo); | 
|         PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(list); | 
|         //修改被客户投诉的订单标记 | 
|         //int num =  orderComplaintService.queryByOrderNoCount(orderNo); | 
|         //if(num>0){ | 
|         List<String> partnerIds = cityPartnerService.queryPartnerByCurrent(); | 
|         if (null != partnerIds && partnerIds.size() > 0) { | 
|             orderMapper.updateOrderDetailByNo(orderNo); | 
|   | 
|         } | 
|         //} | 
|         String address = "无配送地址"; | 
|         String addressArea = ""; | 
|         String remark = ""; | 
|         String reserveTime = ""; | 
|         if (null != list && list.size() > 0) { | 
|             Map<String, Object> pmap = list.get(0); | 
|             if (null != pmap.get("address")) { | 
|                 address = pmap.get("address").toString(); | 
|             } | 
|             if (null != pmap.get("addressArea")) { | 
|                 addressArea = pmap.get("addressArea").toString(); | 
|             } | 
|             if (null != pmap.get("reserveTime")) { | 
|                 reserveTime = pmap.get("reserveTime").toString(); | 
|             } | 
|             if (null != pmap.get("remark")) { | 
|                 remark = pmap.get("remark").toString(); | 
|             } | 
|             if (null != pmap.get("title")) { | 
|             } else { | 
|                 list = new ArrayList<>(); | 
|             } | 
|         } | 
|   | 
|         result.put("count", pageInfo.getTotal()); | 
|         result.put("code", 0); | 
|         result.put("data", list); | 
|         result.put("address", address); | 
|         result.put("addressArea", addressArea); | 
|         result.put("remark", remark); | 
|         result.put("reserveTime", reserveTime); | 
|   | 
|         return result; | 
|     } | 
|   | 
|   | 
|     public Map<String, Object> queryOrderApiList(OrderModel orderModel) { | 
|         String startTime = orderModel.getStartTime(); | 
|         String endTime = orderModel.getEndTime(); | 
|         if (null != startTime && !"".equals(startTime)) { | 
|             startTime = startTime + " 00:00:00"; | 
|         } | 
|         if (null != endTime && !"".equals(endTime)) { | 
|             endTime = endTime + " 23:59:59"; | 
|         } | 
|         orderModel.setStartTime(startTime); | 
|         orderModel.setEndTime(endTime); | 
|         OrderModel newOrderModel = new OrderModel(); | 
|         newOrderModel.setOrderStatus(orderModel.getOrderStatus()); | 
|         newOrderModel.setStartTime(startTime); | 
|         newOrderModel.setName(orderModel.getName()); | 
|         newOrderModel.setEndTime(endTime); | 
|         newOrderModel.setOrderType(orderModel.getOrderType()); | 
|         newOrderModel.setCreateType(orderModel.getCreateType()); | 
|         newOrderModel.setOrderId(orderModel.getOrderId()); | 
|         newOrderModel.setOrderType(orderModel.getOrderType()); | 
|         List<String> partnerIds = new ArrayList<>(); | 
|         if (null != orderModel.getPartnerId() && !"".equals(orderModel.getPartnerId())) { | 
|             newOrderModel.setPartnerId(orderModel.getPartnerId()); | 
|             partnerIds.add(orderModel.getPartnerId()); | 
|             newOrderModel.setPartnerIds(partnerIds); | 
|   | 
|         } else { | 
|             partnerIds = cityPartnerService.queryPartnerByCurrent(); | 
|             newOrderModel.setPartnerIds(partnerIds); | 
|             if(CollUtil.isNotEmpty(partnerIds)) { | 
|                 newOrderModel.setPartnerId(partnerIds.get(0)); | 
|             } | 
|         } | 
|   | 
|         //筛选条件 | 
|         if (StrUtil.isNotBlank(orderModel.getNickName())) { | 
|             newOrderModel.setMobilePhone(orderModel.getNickName()); | 
|             newOrderModel.setNickName(Base64.encode(orderModel.getNickName())); | 
|         } | 
|         List<OrderModel> maps; | 
|         if(CollUtil.isNotEmpty(partnerIds)) { | 
|             List<String> townIds = orderMapper.queryTownIdsByPartnerIds(partnerIds); | 
|             if (CollUtil.isNotEmpty(townIds)) { | 
|                 newOrderModel.setTownIds(townIds); | 
|             } | 
|         } | 
|         PageHelper.startPage(orderModel.getPage(), orderModel.getLimit()); | 
|         maps = orderMapper.queryOrderApiList(newOrderModel); | 
|         PageInfo pageInfo = new PageInfo(maps); | 
|   | 
|         for (OrderModel model : maps) { | 
|             //查询订单区域属于哪个合伙人 | 
|             String townId = orderMapper.queryOrderByPartnerId(model.getOrderId()); | 
|             //是否被投诉 | 
|             int num = orderComplaintService.queryByOrderNoCount(model.getOrderId()); | 
|             if (num > 0) { | 
|                 model.setIsComplaint(num + ""); | 
|   | 
|             } else { | 
|                 model.setIsComplaint("0"); | 
|             } | 
|             //查询code码对应的标记说明 | 
|             String markCode = model.getMarkCode(); | 
|             String markCodeStr = ""; | 
|             if (null != markCode && !"".equals(markCode)) { | 
|                 markCodeStr = configService.findByCode(markCode).getConfigValue(); | 
|   | 
|             } | 
|             model.setMarkCodeStr(markCodeStr); | 
|             String partnerId = fenceService.queryPartnerIdByTownId(townId); | 
|             CityPartner partner = new CityPartner(); | 
|             if (null != partnerId && !"".equals(partnerId)) { | 
|                 model.setPartnerId(partnerId); | 
|                 partner = cityPartnerService.queryPartnerById(Long.parseLong(partnerId)); | 
|   | 
|             } | 
|             if (null != partner) { | 
|                 model.setPartnerName(partner.getPartnerName()); | 
|   | 
|             } | 
|             if (null != model.getOrderMoney() && !"".equals(model.getOrderMoney())) { | 
|                 model.setOrderMoney(DoubleUtil.roundTwo(model.getOrderMoney())); | 
|             } | 
|             if (null != model.getOrderWeight() && !"".equals(model.getOrderWeight())) { | 
|                 model.setOrderWeight(DoubleUtil.roundThree(model.getOrderWeight())); | 
|   | 
|             } | 
|             if (!org.apache.commons.lang3.StringUtils.isEmpty(model.getNickName())) { | 
|                 if (StringUtils.isBase64(model.getNickName())) { | 
|                     model.setNickName(Base64.decodeStr(model.getNickName())); | 
|   | 
|                 } | 
|             } | 
|   | 
|             //上门服务信息 | 
|             String orderType = model.getOrderType(); | 
|             if (OrderEnum.到家服务.getValue().equals(orderType)) { | 
|                 String homeServiceIds = model.getHomeServiceId(); | 
|                 if (StrUtil.isNotBlank(homeServiceIds)) { | 
|                     StrBuilder strBuilder = StrBuilder.create(); | 
|                     String[] split = homeServiceIds.split(","); | 
|                     for (String homeServiceId : split) { | 
|                         HomeServiceInfo father = homeServiceInfoService.findFather(Convert.toLong(homeServiceId)); | 
|                         strBuilder.append(father.getParentName() + " " + father.getName() + ","); | 
|                     } | 
|                     model.setServiceName(StringUtils.removeLast(strBuilder, ",")); | 
|                 } else { | 
|                     HomeServiceInfo byId = homeServiceInfoService.findById(Constants.TOP_ID); | 
|                     model.setServiceName(byId.getName()); | 
|                 } | 
|             } | 
|         } | 
|         int count = Convert.toInt(pageInfo.getTotal()); | 
|         Map<String, Object> map = new HashMap<>(); | 
|         map.put("data", maps); | 
|         map.put("count", count); | 
|         map.put("code", 0); | 
|         return map; | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 根据用户类型查询用户列表 | 
|      * | 
|      * @param orderModel | 
|      */ | 
|     public Map<String, Object> queryCuserApiByType(OrderModel orderModel) { | 
|         String userType = orderModel.getUserType(); | 
|         String nickName = orderModel.getNickName(); | 
|         if (!org.apache.commons.lang3.StringUtils.isEmpty(nickName)) { | 
|             nickName = new String(org.apache.commons.codec.binary.Base64.encodeBase64(nickName.getBytes())); | 
|         } | 
|         List<String> partnerIds = cityPartnerService.queryPartnerByCurrent(); | 
|         String partnerId = ""; | 
|         if (null != partnerIds && partnerIds.size() > 0) { | 
|             partnerId = partnerIds.get(0); | 
|         } | 
|         String phone = orderModel.getMobilePhone(); | 
|         PageHelper.startPage(orderModel.getPage(), orderModel.getLimit()); | 
|         List<Map<String, Object>> maps = otherUserMapper.queryCuserByTypeList(userType, nickName, phone, partnerId); | 
|         PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(maps); | 
|         for (Map<String, Object> m : maps) { | 
|             m.put("partnerId", m.get("partner_id")); | 
|             m.put("userId", m.get("user_id")); | 
|             List<Map<String, Object>> scount = orderMapper.queryStatusByCuserId(m.get("user_id").toString()); | 
|             int unFinishOrder = 0; | 
|             int finishOrder = 0; | 
|             //m.put("unFinishOrder",) | 
|             for (Map<String, Object> mx : scount) { | 
|                 if (mx.get("orderStatus").toString().equals("5")) { | 
|                     finishOrder = Integer.parseInt(mx.get("count").toString()); | 
|                 } else if (mx.get("orderStatus").toString().equals("2")) { | 
|                     unFinishOrder = unFinishOrder + Integer.parseInt(mx.get("count").toString()); | 
|                 } else if (mx.get("orderStatus").toString().equals("3")) { | 
|                     unFinishOrder = unFinishOrder + Integer.parseInt(mx.get("count").toString()); | 
|                 } | 
|             } | 
|             m.put("unFinishOrder", unFinishOrder); | 
|             m.put("finishOrder", finishOrder); | 
|         } | 
|   | 
|         Map<String, Object> m = new HashMap<>(); | 
|         m.put("data", maps); | 
|         m.put("count", pageInfo.getTotal()); | 
|         m.put("code", 0); | 
|         return m; | 
|     } | 
|   | 
|     public Map<String, Object> cancelOrderData(OrderModel orderModel) { | 
|         Map<String, Object> result = new HashMap<>(); | 
|         String orderId = orderModel.getOrderId(); | 
|         String cancelReasonName = orderModel.getCancelReasonName(); | 
|         int num = orderMapper.updateOrderStatus1(orderId, "6"); | 
|         if (num > 0) { | 
|             //修改取消原因 | 
|             orderMapper.updateOrderDetailReData(orderId, cancelReasonName); | 
|             String receiver = orderMapper.queryOrderByOrderId(orderId); | 
|   | 
|             String msg = "您的订单" + orderId + "已经取消"; | 
|             String msg1 = "订单" + orderId + "已经取消"; | 
|             String userId = orderMapper.queryUserIdByOrderId(orderId); | 
|             sysMessageMapper.insertMessage(msg, userId, "", "1", "取消订单", DateUtil.now()); | 
|             if (null != receiver && !"".equals(receiver)) { | 
|                 sysMessageMapper.insertMessage(msg1, receiver, "", "1", "取消订单", DateUtil.now()); | 
|             } | 
|             redisUtil.del(RedisKeyConstant.ORDER_CANCEL + orderId); | 
|             result.put("code", 0); | 
|             result.put("orderId", orderId); | 
|         } else { | 
|             result.put("code", -1); | 
|             result.put("orderId", orderId); | 
|   | 
|         } | 
|   | 
|         return result; | 
|     } | 
|   | 
|     public Map<String, Object> queryStorageApiList(OrderModel orderModel) { | 
|         List<String> partnerIds = new ArrayList<>(); | 
|         if (null != orderModel.getPartnerId() && !"".equals(orderModel.getPartnerId())) { | 
|             partnerIds.add(orderModel.getPartnerId()); | 
|         } else { | 
|             partnerIds = cityPartnerService.queryPartnerByCurrent(); | 
|         } | 
|         Map<String, Object> map = new HashMap<>(); | 
|         String startTime = orderModel.getStartTime(); | 
|         String endTime = orderModel.getEndTime(); | 
|         if (null != startTime && !"".equals(startTime)) { | 
|             orderModel.setStartTime(startTime + " 00:00:00"); | 
|         } | 
|         if (null != endTime && !"".equals(endTime)) { | 
|             orderModel.setEndTime(endTime + " 23:59:59"); | 
|         } | 
|         orderModel.setPartnerIds(partnerIds); | 
|         if (null != partnerIds && partnerIds.size() > 0) { | 
|             //查询下面所有的打包站 | 
|             List<String> packageIds = cityPartnerService.queryPackageIdList(partnerIds.get(0)); | 
|             packageIds.add(partnerIds.get(0)); | 
|             orderModel.setPartnerIds(packageIds); | 
|         } | 
|         PageHelper.startPage(Convert.toInt(orderModel.getPage()), Convert.toInt(orderModel.getLimit())); | 
|         List<Map<String, Object>> list = orderMapper.queryStorageApiList(orderModel); | 
|         UserModel otherUser = new UserModel(); | 
|         for (Map<String, Object> pmap : list) { | 
|             String storageWeight = "0"; | 
|             String orderWeight = "0"; | 
|             String storageMoney = "0"; | 
|             String orderMoney = "0"; | 
|             String storageTime = ""; | 
|             if (null != pmap.get("storageWeight")) { | 
|                 storageWeight = pmap.get("storageWeight").toString(); | 
|             } | 
|             if (null != pmap.get("recycleWeight")) { | 
|                 orderWeight = pmap.get("recycleWeight").toString(); | 
|             } | 
|             if (null != pmap.get("storageMoney")) { | 
|                 storageMoney = pmap.get("storageMoney").toString(); | 
|             } | 
|             if (null != pmap.get("recycleMoney")) { | 
|                 orderMoney = pmap.get("recycleMoney").toString(); | 
|             } | 
|             if (null != pmap.get("storageTime")) { | 
|                 storageTime = pmap.get("storageTime").toString(); | 
|             } else { | 
|                 storageTime = "-"; | 
|             } | 
|             if (null != pmap.get("sysStorageName")) { | 
|                 String sysstoragename = pmap.get("sysStorageName").toString(); | 
|                 pmap.put("sysstoragename", sysstoragename); | 
|   | 
|             } | 
|   | 
|             pmap.put("storageweight", DoubleUtil.roundThree(storageWeight)); | 
|             pmap.put("recycleweight", DoubleUtil.roundThree(orderWeight)); | 
|             pmap.put("storagemoney", DoubleUtil.roundTwo(storageMoney)); | 
|             pmap.put("recyclemoney", DoubleUtil.roundTwo(orderMoney)); | 
|             pmap.put("storagetime", storageTime); | 
|   | 
|             if (null != pmap.get("receiverName")) { | 
|                 pmap.put("receivername", pmap.get("receiverName").toString()); | 
|             } else { | 
|                 if (null != pmap.get("receiver")) { | 
|                     otherUser = otherUserMapper.queryUserOtherById(pmap.get("receiver").toString()); | 
|                     pmap.put("receivername", otherUser.getName()); | 
|                     pmap.put("receiverName", otherUser.getName()); | 
|                 } | 
|   | 
|             } | 
|             if (null != pmap.get("storageName")) { | 
|                 pmap.put("storagename", pmap.get("storageName").toString()); | 
|             } else { | 
|                 pmap.put("storagename", "--"); | 
|             } | 
|   | 
|             pmap.put("storageid", pmap.get("storageId").toString()); | 
|             if (null != pmap.get("receiverPhone")) { | 
|                 pmap.put("receiverphone", pmap.get("receiverPhone").toString()); | 
|             } else { | 
|                 pmap.put("receiverphone", otherUser.getMobilePhone()); | 
|                 pmap.put("receiverPhone", otherUser.getMobilePhone()); | 
|   | 
|             } | 
|             //pmap.put("sysstoragename",pmap.get("sysStorageName").toString()); | 
|   | 
|             BigDecimal weightError1 = new BigDecimal(storageWeight).subtract(new BigDecimal(orderWeight)); | 
|             BigDecimal moneyError1 = new BigDecimal(storageMoney).subtract(new BigDecimal(orderMoney)); | 
|             pmap.put("weightError", DoubleUtil.roundThree(weightError1.toString()));//重量误差 | 
|             pmap.put("moneyError", DoubleUtil.roundTwo(moneyError1.toString()));//重量误差 | 
|   | 
|             if (null != pmap.get("vehicleId")) { | 
|                 String vehicleId = pmap.get("vehicleId").toString(); | 
|                 BigDecimal batchError = new BigDecimal("0"); | 
|                 String batchWeight = pmap.get("batchWeight").toString(); | 
|                 String emptyWeight = pmap.get("emptyWeight").toString(); | 
|                 batchError = new BigDecimal(batchWeight).subtract(new BigDecimal(emptyWeight)); | 
|                 System.out.println("vehicleId===" + vehicleId); | 
|                 pmap.put("emptyWeight", DoubleUtil.roundThree(emptyWeight)); //空车 | 
|                 pmap.put("batchWeight", DoubleUtil.roundThree(batchWeight));//载重 | 
|                 pmap.put("batchError", DoubleUtil.roundThree(batchError.toString()));//核算 | 
|                 // | 
|             } else { | 
|                 pmap.put("emptyWeight", "0"); //空车 | 
|                 pmap.put("batchWeight", "0");//载重 | 
|                 pmap.put("batchError", "0");//核算 | 
|   | 
|             } | 
|         } | 
|         PageInfo pageInfo = new PageInfo(list); | 
|         map.put("data", list); | 
|         map.put("code", 0); | 
|         map.put("count", pageInfo.getTotal()); | 
|         return map; | 
|     } | 
|   | 
|   | 
|     public Map<String, Object> queryStorageDetailApiList(OrderModel orderModel) { | 
|         Map<String, Object> map = new HashMap<>(); | 
|         List<Map<String, Object>> queryStorageDetailApiList = new ArrayList<>(); | 
|         int count = 0; | 
|         String storageId = orderModel.getStorageId(); | 
|         String orderIds = orderMapper.queryOrderIdsByStorageId(storageId); | 
|         String[] orderids = orderIds.split(","); | 
|         List<String> orderIdList = new ArrayList<>(); | 
|         for (String orderId : orderids) { | 
|             orderIdList.add(orderId); | 
|         } | 
|         if (orderIdList.size() > 0) { | 
|   | 
|             PageHelper.startPage(Convert.toInt(orderModel.getPage()), Convert.toInt(orderModel.getLimit())); | 
|             if (null != orderModel.getOrderType()) { | 
|                 if (orderModel.getOrderType().equals("1")) { | 
|                     queryStorageDetailApiList = orderMapper.queryStroageDetailPageByOrderno(orderIdList, storageId); | 
|                 } else { | 
|                     queryStorageDetailApiList = orderMapper.queryStorageDetailApiList(orderIdList); | 
|                 } | 
|             } else { | 
|                 queryStorageDetailApiList = orderMapper.queryStorageDetailApiList(orderIdList); | 
|             } | 
|             PageInfo pageInfo = new PageInfo(queryStorageDetailApiList); | 
|             count = Convert.toInt(pageInfo.getTotal()); | 
|         } | 
|         for (Map<String, Object> obj : queryStorageDetailApiList) { | 
|             String ordermoney = "0"; | 
|             String orderweight = "0"; | 
|             String moneyerror = "0"; | 
|             String weighterror = "0"; | 
|             if (null != obj.get("recyclemoney") && !"".equals(obj.get("recyclemoney"))) { | 
|                 obj.put("recyclemoney", DoubleUtil.roundTwo(obj.get("recyclemoney").toString())); | 
|                 moneyerror = new BigDecimal(obj.get("recyclemoney").toString()).subtract(new BigDecimal(obj.get("storagemoney").toString())).toString(); | 
|                 obj.put("moneyerror", DoubleUtil.roundTwo(moneyerror)); | 
|                 obj.put("storagemoney", DoubleUtil.roundTwo(obj.get("storagemoney").toString())); | 
|                 ordermoney = DoubleUtil.roundTwo(obj.get("recyclemoney").toString()); | 
|   | 
|             } | 
|             if (null != obj.get("recycleweight") && !"".equals(obj.get("recycleweight"))) { | 
|                 obj.put("recycleweight", DoubleUtil.roundThree(obj.get("recycleweight").toString())); | 
|                 weighterror = new BigDecimal(obj.get("recycleweight").toString()).subtract(new BigDecimal(obj.get("storageweight").toString())).toString(); | 
|                 obj.put("weighterror", DoubleUtil.roundThree(weighterror)); | 
|                 obj.put("storageweight", DoubleUtil.roundThree(obj.get("storageweight").toString())); | 
|                 orderweight = DoubleUtil.roundThree(obj.get("recycleweight").toString()); | 
|   | 
|             } | 
|             if (null != obj.get("ordermoney") && !"".equals(obj.get("ordermoney"))) { | 
|                 ordermoney = obj.get("ordermoney").toString(); | 
|             } | 
|             if (null != obj.get("orderweight") && !"".equals(obj.get("orderweight"))) { | 
|                 orderweight = obj.get("orderweight").toString(); | 
|             } | 
|             obj.put("ordermoney", DoubleUtil.roundTwo(ordermoney)); | 
|             obj.put("orderweight", DoubleUtil.roundThree(orderweight)); | 
|         } | 
|         map.put("count", count); | 
|         map.put("code", 0); | 
|         map.put("data", queryStorageDetailApiList); | 
|         return map; | 
|     } | 
|   | 
|     public Map<String, Object> updateApirecByOrderId(OrderModel orderModel) { | 
|         //判断接单数量 修改回收员接单数+1 | 
|         Map<String, Object> map = new HashMap<>(); | 
|         String userId = orderModel.getUserId(); | 
|         String orderId = orderModel.getOrderId(); | 
|         String receiver = orderMapper.queryOrderByOrderId(orderId); | 
|         String oldTrid = ""; | 
|         String newTrid = ""; | 
|         String obj = orderMapper.queryOrderReNum(orderModel.getUserId()); | 
|         if (null != obj) { | 
|             int objNum = Integer.parseInt(obj); | 
|             int configNum = maxOrderNum(userId); | 
|             objNum = objNum + 1; | 
|             if (objNum > configNum) { | 
|                 map.put("code", -1); | 
|                 map.put("orderId", orderModel.getOrderId()); | 
|                 map.put("msg", "回收员超过自身可接单数量!"); | 
|                 return map; | 
|             } | 
|         } | 
|   | 
|         int num = 0; | 
|         UserModel userModel = otherUserMapper.queryUserOtherById(orderModel.getUserId()); | 
|         String partnerId = userModel.getPartnerId(); | 
|         CityPartner partner = cityPartnerService.queryById(partnerId); | 
|         String key = partner.getPartnerKey(); | 
|         String tid = userModel.getTerminalId(); | 
|         String sid = cityPartnerService.querySidByPid(partner.getId() + "", "1"); | 
|         if (null != key && !"".equals(key)) { | 
|             Result trace = GdTraceUtil.createTrace(key, sid, tid); | 
|             if (trace.getCode() == 0) { | 
|                 String trid = trace.getData().toString(); | 
|                 num = orderMapper.updateApirecByOrderId(orderId, userId, trid); | 
|                 newTrid = trid; | 
|             } | 
|   | 
|             UserModel apirecUserModel = otherUserMapper.queryUserOtherApiById(userId, "2"); | 
|             orderMapper.updateApirecDetailByOrderId(orderId, apirecUserModel.getMobilePhone(), apirecUserModel.getName()); | 
|   | 
|   | 
|             //发消息队列订单操作 | 
|             sendOperationLog(orderModel); | 
|             //发消息给回收员1 | 
|             String message = "指派订单" + orderId + "给您,请准时到达现场"; | 
|             sysMessageMapper.insertMessage(message, userId, "", "1", "指派订单", DateUtil.now()); | 
|             if (null != receiver && !"".equals(receiver)) { | 
|                 UserModel uu = otherUserMapper.queryUserOtherById(receiver); | 
|                 oldTrid = uu.getTerminalId(); | 
|                 String message1 = "订单" + orderId + "已更换骑手"; | 
|                 sysMessageMapper.insertMessage(message1, receiver, "", "1", "订单变更", DateUtil.now()); | 
|   | 
|             } | 
|             //极光推送 | 
|             jgPushUtil.pushTrace(newTrid, userId); | 
|             if (null != receiver && !"".equals(receiver)) { | 
|                 jgPushUtil.pushTrace(oldTrid, receiver); | 
|             } | 
|   | 
|   | 
|             if (num > 0) { | 
|                 map.put("code", 0); | 
|                 map.put("orderId", orderId); | 
|             } else { | 
|                 map.put("code", -1); | 
|                 map.put("orderId", orderId); | 
|   | 
|             } | 
|             return map; | 
|         } else { | 
|             return null; | 
|         } | 
|   | 
|     } | 
|   | 
|     private void sendOperationLog(OrderModel orderModel) { | 
|         OrderOperationLogModel operationLogModel = new OrderOperationLogModel(); | 
|         operationLogModel.setOrderId(orderModel.getOrderId()); | 
|         operationLogModel.setOperateContent("后台指派回收员"); | 
|         operationLogModel.setOrderStatus("2"); | 
|         operationLogModel.setOrderSecondStatus("1"); | 
|         operationLogModel.setOperateTime(DateUtil.now()); | 
|         operationLogModel.setOperateUserId(orderModel.getUserId()); | 
|         redisUtil.remove("xzx:order:status:" + orderModel.getOrderId()); | 
|     } | 
|   | 
|     public List<SysAddressLevelModel> queryAdressArea(SysAddressLevelModel addressLevelModel) { | 
|         if (addressLevelModel.getType().equals("0")) { | 
|             return orderMapper.queryProvince(); | 
|         } else if (addressLevelModel.getType().equals("1")) { | 
|             return orderMapper.queryCityByProvinceId(addressLevelModel.getLevel1Id()); | 
|         } else if (addressLevelModel.getType().equals("2")) { | 
|             return orderMapper.queryTownShipByCityId(addressLevelModel.getLevel2Id()); | 
|         } else { | 
|             return null; | 
|         } | 
|     } | 
|   | 
|   | 
|   | 
|     /** | 
|      * 订单状态变更 | 
|      * | 
|      * @param orderReversDto | 
|      */ | 
|     public void orderRevers(OrderReversDto orderReversDto) { | 
|         String newStatus = orderReversDto.getNewStatus(); | 
|         String oldStatus = orderReversDto.getOldStatus(); | 
|         String manageUserId = orderReversDto.getManageUserId(); | 
|         List<OrderDto> list = orderReversDto.getList(); | 
|   | 
|         //待入库-》完成 | 
|         if (OrderEnum.完成.getValue().equals(newStatus)) { | 
|             //新增入库数据和入库详情数据 不需要处理 | 
|   | 
|             //发送消息给回收员/ | 
|   | 
|             //按回收员分组 | 
|             List<List<OrderDto>> receiverId1 = CollUtil.groupByField(list, "receiverId"); | 
|   | 
|             OtherUserInfo byId = otherUserService.findById(manageUserId); | 
|             for (List<OrderDto> orderDtos : receiverId1) { | 
|   | 
|                 for (OrderDto orderDto : orderDtos) { | 
|                     String orderId = orderDto.getOrderId(); | 
|                     OrderInfo orderInfo = new OrderInfo(); | 
|                     orderInfo.setOrderId(orderId); | 
|                     orderInfo.setOrderStatus(newStatus); | 
|                     orderMapper.updateByPrimaryKeySelective(orderInfo); | 
|                 } | 
|   | 
|                 String receiverId = orderDtos.get(0).getReceiverId(); | 
|                 //多个订单合并成一个入库单 | 
|                 String collect = orderDtos.stream().map(x -> x.getOrderId()).collect(Collectors.joining(",")); | 
|                 //获取回收的总重量和金额 | 
|                 OrderStatistic orderStatistic = findSumWeightAndMoney(CollUtil.toList(collect.split(","))); | 
|                 OrderStorageInfo orderStorageInfo = new OrderStorageInfo(); | 
|                 orderStorageInfo.setStorageId(idUtils.generate("RK", 2)); | 
|                 orderStorageInfo.setStorageStatus(Convert.toShort(OrderEnum.已入库.getValue())); | 
|                 orderStorageInfo.setOrderId(collect); | 
|                 orderStorageInfo.setStorageUserName(byId.getName()); | 
|                 orderStorageInfo.setStorageUserPhone(byId.getMobilePhone()); | 
|                 orderStorageInfo.setStorageTime(DateUtil.now()); | 
|                 orderStorageInfo.setReceiver(receiverId); | 
|                 orderStorageInfo.setStorageMoney(BigDecimal.ZERO); | 
|                 orderStorageInfo.setRecycleWeight(businessUtil.changeWeight(orderStatistic.getSumWeight())); | 
|                 orderStorageInfo.setRecycleMoney(businessUtil.changeMul(orderStatistic.getSumMoney())); | 
|                 orderStorageService.add(orderStorageInfo); | 
|   | 
|                 if(orderReversDto.getIsSendMsg()) { | 
|                     //发送消息 | 
|                     SysMessage sysMessage = new SysMessage(); | 
|                     sysMessage.setCreateTime(DateUtil.now()); | 
|                     sysMessage.setCreateUserId(manageUserId); | 
|                     sysMessage.setFlag(SysEnum.未读.getValue()); | 
|                     sysMessage.setMessage("订单" + collect + "入库完成"); | 
|                     sysMessage.setMessageSubTypeName("现金收入"); | 
|                     //充值提现根据文字匹配 不根据类型 | 
|                     sysMessage.setMessageType(SysEnum.充值.getValue()); | 
|                     sysMessage.setUserId(receiverId); | 
|                     sysMessageMapper.insert(sysMessage); | 
|                 } | 
|             } | 
|   | 
|   | 
|         }else if(Constants.DEFAULT_ID.equals(newStatus)){ | 
|             //退回任务大厅  将状态改动为待接单。同时redis的抢单 | 
|             for (OrderDto orderDto : list) { | 
|                 String orderId = orderDto.getOrderId(); | 
|                 String receiverId = orderDto.getReceiverId(); | 
|                 OrderInfo byId = findById(orderId); | 
|                 String traceId=byId.getTraceId(); | 
|                 byId.setOrderStatus(OrderEnum.待接单.getValue()); | 
| //                byId.setReceiver(null); | 
|                 byId.setTraceId(null); | 
|                 orderMapper.updateByPrimaryKey(byId); | 
|                 OrderDetailInfo byId1 = orderDetailService.findById(orderId); | 
|                 byId1.setReceiveTime(null); | 
| //                byId1.setReceiverName(null); | 
| //                byId1.setReceiverPhone(null); | 
|                 orderDetailService.updateAllById(byId1); | 
|   | 
|   | 
|                 //删除轨迹 | 
|                 if(OrderEnum.服务中.getValue().equals(oldStatus)&&StrUtil.isNotBlank(traceId)){ | 
|                     PartnerTrace byUserIdAndType = partnerTraceService.findByUserIdAndType(receiverId, null); | 
|                     if(byUserIdAndType!=null){ | 
|                         String key = byUserIdAndType.getPartnerKey(); | 
|                         String sid = byUserIdAndType.getPartnerServiceId(); | 
|                         String tid = byUserIdAndType.getOtherUserInfo().getTerminalId(); | 
|                         CommonTraceDto commonTraceDto = new CommonTraceDto(); | 
|                         commonTraceDto.setKey(key); | 
|                         commonTraceDto.setSid(sid); | 
|                         commonTraceDto.setTid(tid); | 
|                         commonTraceDto.setTrid(traceId); | 
|                         GdTraceUtil.deleteTrace(commonTraceDto); | 
|                     } | 
|                 } | 
|   | 
|                 //重新设置redis键 | 
|                 redisUtil.set(RedisKeyConstant.ORDER_CANCEL + orderId, "0"); | 
|             } | 
|   | 
|         } | 
|     } | 
|   | 
|   | 
|   | 
|     public Map<String, Object> updateOrderReserveTime(OrderModel orderModel) { | 
|         Map<String, Object> result = new HashMap<>(); | 
|         String orderId = orderModel.getOrderId(); | 
|         String reserveDate = orderModel.getReserveDate(); | 
|         orderMapper.updateOrderInfoReserveTime(orderId, reserveDate); | 
|         int num = orderMapper.updateOrderReserveTime(orderId, reserveDate); | 
|         if (num > 0) { | 
|             String msg = "您预约的订单" + orderId + "已经由系统更改时间为:" + reserveDate; | 
|             String userId = orderMapper.queryUserIdByOrderId(orderId); | 
|             sysMessageMapper.insertMessage(msg, userId, "", "4", "修改订单预约时间", DateUtil.now()); | 
|             result.put("code", 0); | 
|             result.put("orderId", orderId); | 
|         } else { | 
|             result.put("code", -1); | 
|             result.put("orderId", orderId); | 
|   | 
|         } | 
|         redisUtil.set(RedisKeyConstant.ORDER_CANCEL + orderModel.getOrderId(), "0"); | 
|   | 
|         return result; | 
|     } | 
|   | 
|     public String queryMoneyByOrderId(String orderId) { | 
|         return orderMapper.queryMoneyByOrderId(orderId); | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 到家服务支付 | 
|      * | 
|      * @param orderId | 
|      * @param payMoney | 
|      */ | 
|     public Result<String> homePay(String orderId, BigDecimal payMoney) { | 
|         String key = RedisKeyConstant.ORDER_PAY + orderId; | 
|         if (redisUtil.setnx(key, "0")) { | 
|             try { | 
|                 payMoney = businessUtil.changeMul(payMoney); | 
|                 OrderInfo byId = findById(orderId); | 
|                 String createUserId = byId.getCreateUserId(); | 
|                 String receiver = byId.getReceiver(); | 
|                 AccountInfo byUserId = accountService.findByUserId(createUserId); | 
|                 AccountInfo receiveAccount = accountService.findByUserId(receiver); | 
|                 if (byUserId == null) { | 
|                     return Result.error("用户账户异常"); | 
|                 } | 
|   | 
|                 if (receiveAccount == null) { | 
|                     return Result.error("回收员账户异常"); | 
|                 } | 
|   | 
|                 BigDecimal money = Convert.toBigDecimal(byUserId.getMoney(), Constants.MONEY_INIT); | 
|   | 
|                 if (payMoney.compareTo(money) > 0) { | 
|                     return Result.error(-3, "账户余额不足"); | 
|                 } | 
|   | 
|                 //更新订单 | 
|                 OrderInfo orderInfo = new OrderInfo(); | 
|                 orderInfo.setOrderId(orderId); | 
|                 orderInfo.setOrderStatus(OrderEnum.完成.getValue()); | 
|                 updateOrderById(orderInfo); | 
|   | 
|                 //更新订单详情的金额 | 
|                 OrderDetailInfo orderDetailInfo = new OrderDetailInfo(); | 
|                 orderDetailInfo.setOrderId(orderId); | 
|                 orderDetailInfo.setMoney(businessUtil.changeMoney(payMoney)); | 
|                 orderDetailInfo.setCompleteTime(DateUtil.now()); | 
|                 orderDetailService.update(orderDetailInfo); | 
|   | 
|                 //添加入库记录 | 
|                 OrderStorageInfo orderStorageInfo = new OrderStorageInfo(); | 
|                 orderStorageInfo.setStorageId(idUtils.generate("RK", 2)); | 
|                 orderStorageInfo.setStorageStatus(Convert.toShort(OrderEnum.已入库.getValue())); | 
|                 orderStorageInfo.setOrderId(orderId); | 
| //                orderStorageInfo.setStorageUserName(""); | 
| //                orderStorageInfo.setStorageUserPhone(""); | 
|                 orderStorageInfo.setStorageTime(DateUtil.now()); | 
|                 orderStorageInfo.setReceiver(receiver); | 
|                 orderStorageInfo.setStorageMoney(BigDecimal.ZERO); | 
| //                orderStorageInfo.setRecycleWeight(businessUtil.changeWeight(orderStatistic.getSumWeight())); | 
|                 orderStorageInfo.setRecycleMoney(businessUtil.changeMul(payMoney)); | 
|                 orderStorageService.add(orderStorageInfo); | 
|   | 
|   | 
|                 /*******************用户**************************/ | 
|                 //环保金变动通知 | 
|                 Map<String, Object> payMap = new HashMap<>(); | 
|                 String otherPayOrderId = idUtils.generate("ZF", 0); | 
|                 payMap.put("payOrderId", otherPayOrderId); | 
|                 payMap.put("orderId", orderId); | 
|                 payMap.put("createUserId", createUserId); | 
|                 payMap.put("money", payMoney.toString()); | 
|                 payMap.put("accountId", byUserId.getAccountId()); | 
|                 payMap.put("payType", PayEnum.环保金支出.getValue()); | 
|                 payMap.put("status", PayEnum.已支付.getValue()); | 
|                 payMap.put("createTime", DateUtil.now()); | 
|                 payInfoMapper.payInfoAdd(payMap); | 
|   | 
|                 //添加账户变更日志 | 
|                 AccountLog accountLog = new AccountLog(); | 
|                 accountLog.setAccountId(byUserId.getAccountId()); | 
|                 accountLog.setCreateUserId(createUserId); | 
|                 accountLog.setChannelType(Convert.toShort(CommonEnum.回收操作.getValue())); | 
|                 accountLog.setOrderId(otherPayOrderId); | 
|                 accountLog.setOldMoney(businessUtil.changeMoney(money)); | 
|                 accountLog.setNewMoney(businessUtil.changeMoney(NumberUtil.sub(Convert.toBigDecimal(accountLog.getOldMoney()), payMoney))); | 
|                 accountLogService.add(accountLog); | 
|   | 
|                 //更新账户余额 | 
|                 accountService.updateMoneyByUserId(createUserId, Convert.toBigDecimal("-" + payMoney.toString())); | 
|   | 
|   | 
|                 /*******************回收员**************************/ | 
|                 //环保金变动通知 | 
|                 payMap = new HashMap<>(); | 
|                 otherPayOrderId = idUtils.generate("ZF", 0); | 
|                 payMap.put("payOrderId", otherPayOrderId); | 
|                 payMap.put("orderId", orderId); | 
|                 payMap.put("createUserId", receiver); | 
|                 payMap.put("money", payMoney.toString()); | 
|                 payMap.put("accountId", receiveAccount.getAccountId()); | 
|                 payMap.put("payType", PayEnum.环保金收入.getValue()); | 
|                 payMap.put("status", PayEnum.已支付.getValue()); | 
|                 payMap.put("createTime", DateUtil.now()); | 
|                 payInfoMapper.payInfoAdd(payMap); | 
|   | 
|                 //添加账户变更日志 | 
|                 accountLog = new AccountLog(); | 
|                 accountLog.setAccountId(receiveAccount.getAccountId()); | 
|                 accountLog.setCreateUserId(receiver); | 
|                 accountLog.setChannelType(Convert.toShort(CommonEnum.回收操作.getValue())); | 
|                 accountLog.setOrderId(otherPayOrderId); | 
|                 accountLog.setOldMoney(businessUtil.changeMoney(receiveAccount.getMoney())); | 
|                 accountLog.setNewMoney(businessUtil.changeMoney(NumberUtil.add(Convert.toBigDecimal(accountLog.getOldMoney()), payMoney))); | 
|                 accountLogService.add(accountLog); | 
|   | 
|                 //更新账户余额 | 
|                 accountService.updateMoneyByUserId(receiver, Convert.toBigDecimal(payMoney.toString())); | 
|                 return Result.success(byUserId.getAccountName()); | 
|             } catch (Exception e) { | 
|                 ExceptionUtils.err("支付失败", e); | 
|             } finally { | 
|                 redisUtil.del(key); | 
|             } | 
|             return Result.error("支付失败"); | 
|         } else { | 
|             return Result.error("支付中,请稍候"); | 
|         } | 
|   | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 获取统计的回收金额和重量 | 
|      * | 
|      * @return | 
|      */ | 
|     public OrderStatistic findSumWeightAndMoney(List<String> orderIds) { | 
|         return orderMapper.findSumWeightAndMoney(orderIds); | 
|     } | 
|   | 
|     public Map<String, Object> queryUserOrderApiList(UserModel userModel) { | 
|         Map<String, Object> m = new HashMap<>(); | 
|         int page = userModel.getPage(); | 
|         int limit = userModel.getLimit(); | 
|         PageHelper.startPage(page, limit); | 
|         List<OrderModel> userOrderList = orderMapper.queryUserOrderApiList(userModel.getUserId()); | 
|         PageInfo<OrderModel> pageInfo = new PageInfo<>(userOrderList); | 
|         m.put("count", pageInfo.getTotal()); | 
|         m.put("data", userOrderList); | 
|         m.put("code", 0); | 
|         return m; | 
|     } | 
|   | 
|     public JsonResult receiverStatsitic(ReceiverStatsiticDTO receiverStatsiticDTO) { | 
|         JsonResult jsonResult = JsonResult.success(); | 
|         int type = receiverStatsiticDTO.getType(); | 
|         List<ReceiverStatsiticResDTO> receiverStatsiticResDTOS = orderMapper.receiverStatsitic(receiverStatsiticDTO); | 
|         List<ReceiverStatsiticResDTO> list; | 
|         if (type == 2) { | 
|             //按月 | 
|             Map<String, List<ReceiverStatsiticResDTO>> collect = receiverStatsiticResDTOS.stream().collect(Collectors.groupingBy(x -> x.getName() + "," + (DateUtil.month(DateUtil.parse(x.getTime())) + 1))); | 
|             list = receiverStatsiticAggregation(collect); | 
|             CollUtil.sort(list, new PropertyComparator<>("time")); | 
|         } else if (type == 3) { | 
|             //按周 | 
|             Map<String, List<ReceiverStatsiticResDTO>> collect = receiverStatsiticResDTOS.stream().collect(Collectors.groupingBy(x -> x.getName() + "," + DateUtil.weekOfMonth(DateUtil.parse(x.getTime())))); | 
|             list = receiverStatsiticAggregation(collect); | 
|             CollUtil.sort(list, new PropertyComparator<>("time")); | 
|         } else { | 
|             //按名字和时间分组 | 
|             Map<String, List<ReceiverStatsiticResDTO>> collect = receiverStatsiticResDTOS.stream().collect(Collectors.groupingBy(x -> x.getName() + "," + x.getTime())); | 
|             list = receiverStatsiticAggregation(collect); | 
|             CollUtil.sort(list, new PropertyComparator<>("time").reversed()); | 
|         } | 
|   | 
|         jsonResult.setCount(list.size() + ""); | 
|         //假分页 | 
|         list = CollUtil.page(receiverStatsiticDTO.getPageNo() - 1, receiverStatsiticDTO.getPageSize(), list); | 
|         jsonResult.setData(list); | 
|         return jsonResult; | 
|     } | 
|   | 
|     private List<ReceiverStatsiticResDTO> receiverStatsiticAggregation(Map<String, List<ReceiverStatsiticResDTO>> collect) { | 
|         List<ReceiverStatsiticResDTO> list = new ArrayList<>(); | 
|         for (String s : collect.keySet()) { | 
|             List<ReceiverStatsiticResDTO> paramList = collect.get(s); | 
|             ReceiverStatsiticResDTO dto = new ReceiverStatsiticResDTO(); | 
|             dto.setName(s.split(",")[0]); | 
|             dto.setTime(s.split(",")[1]); | 
|             dto.setCompleteNum(paramList.stream().filter(x -> x.getOrderStatus().equals(OrderEnum.完成.getValue()) || x.getOrderStatus().equals(OrderEnum.待入库.getValue()) || x.getOrderStatus().equals(OrderEnum.入库中.getValue())).count()); | 
|             dto.setComplaintNum(paramList.stream().filter(x -> x.getComplaintId() != null).count()); | 
|             dto.setDelayNum(paramList.stream().filter(x -> StrUtil.isNotBlank(x.getReceiveTime()) && DateUtil.parse(x.getReceiveTime(), DateUtils.DATE_FORMAT_YMDHMS).after(DateUtil.parse(x.getReserveTime(), DateUtils.DATE_FORMAT_YMDHMS))).count()); | 
|             dto.setDelayThreeHourNum(paramList.stream().filter(x -> StrUtil.isNotBlank(x.getCompleteTime()) && DateUtil.between(DateUtil.parse(x.getReserveTime(), DateUtils.DATE_FORMAT_YMDHMS), DateUtil.parse(x.getCompleteTime(), DateUtils.DATE_FORMAT_YMDHMS), DateUnit.HOUR) >= 3).count()); | 
|             dto.setWeight(businessUtil.changeWeight(Convert.toStr(paramList.stream().filter(x -> StrUtil.isNotBlank(x.getWeight())).mapToDouble(x -> Convert.toDouble(x.getWeight())).sum()))); | 
|             list.add(dto); | 
|         } | 
|         return list; | 
|     } | 
|   | 
|     public List<UserGatherOrderRes> ordergatherList(UserGatherOrderParam userGatherOrderParam) { | 
|         List<UserGatherOrderRes> orderList = orderMapper.ordergatherList(userGatherOrderParam); | 
|         for (UserGatherOrderRes userGatherOrderRes : orderList) { | 
|             String fliterType = userGatherOrderParam.getFliterType(); | 
|             String createTime = userGatherOrderRes.getCreateTime(); | 
|             String completeTime = userGatherOrderRes.getCompleteTime(); | 
|             //今日 | 
|             if ("1".equals(fliterType)) { | 
|                 userGatherOrderRes.setCreateTime(DateUtil.format(DateUtil.parseDateTime(createTime), DateUtils.DATE_FORMAT_HM)); | 
|                 if (StrUtil.isNotBlank(completeTime)) { | 
|                     userGatherOrderRes.setCompleteTime(DateUtil.format(DateUtil.parseDateTime(completeTime), DateUtils.DATE_FORMAT_HM)); | 
|                 } | 
|             } | 
|             if (StrUtil.isBlank(userGatherOrderRes.getDetailAddress())) { | 
|                 userGatherOrderRes.setDetailAddress(userGatherOrderRes.getAddress()); | 
|             } | 
|         } | 
|         return orderList; | 
|     } | 
|   | 
|     public void ordergatherSure(UserGatherOrderSureParam userGatherOrderSureParam) { | 
|         List<UserGatherOrderSureListParam> list = userGatherOrderSureParam.getList(); | 
|   | 
|         String key = RedisKeyConstant.GATHER_PAY + userGatherOrderSureParam.getUserId(); | 
|         if (redisUtil.setnx(key, "0")) { | 
|             try { | 
|                 for (UserGatherOrderSureListParam dto : list) { | 
|   | 
|                     String userId = dto.getCreateUserId(); | 
|                     String orderId = dto.getOrderId(); | 
|                     OrderInfo byId = findById(orderId); | 
|                     if (OrderEnum.待接单.getValue().equals(byId.getOrderStatus())) { | 
|                         //更新订单相关 | 
|                         OrderInfo orderInfo = new OrderInfo(); | 
|                         BeanUtil.copyProperties(dto, orderInfo); | 
|                         orderInfo.setOrderStatus(OrderEnum.完成.getValue()); | 
|                         orderInfo.setReceiver(userGatherOrderSureParam.getUserId()); | 
|                         updateOrderById(orderInfo); | 
|   | 
|                         OrderDetailInfo orderDetailInfo = new OrderDetailInfo(); | 
|                         orderDetailInfo.setOrderId(orderId); | 
|                         orderDetailInfo.setReceiverName(userGatherOrderSureParam.getUserInfo().getName()); | 
|                         orderDetailInfo.setReceiverPhone(userGatherOrderSureParam.getUserInfo().getMobilePhone()); | 
|                         orderDetailInfo.setCompleteTime(DateUtil.now()); | 
|                         orderDetailService.update(orderDetailInfo); | 
|   | 
|                         if(OrderEnum.已收取.getValue().equals(dto.getOrderSecondStatus())){ | 
|                             //支付集货 | 
|                             List<ConfigInfo> configInfoList = configService.findByGroup(SysConfigConstant.SCORE_HBB_GATHER_ORDER_GROUP); | 
|                             String payType = userGatherOrderSureParam.getPayType(); | 
|   | 
|                             if (PayEnum.环保金支付.getValue().equals(payType)) { | 
|                                 String configValue = configInfoList.stream().filter(x -> x.getConfigTypeCode().equals(SysConfigConstant.HHB_GATHER_ORDER)).collect(Collectors.toList()).get(0).getConfigValue(); | 
|                                 //平台要减去环保比 | 
|                                 String oldHbb = Constants.MONEY_INIT.toString(); | 
|                                 PlatformAccountInfo hbbKey = platformAccountInfoService.findByKey(Constants.PLAT_HBB_KEY); | 
|                                 if (hbbKey != null) { | 
|                                     oldHbb = hbbKey.getFieldValue(); | 
|                                 } | 
|                                 PlatformAccountLog platformAccountLog = new PlatformAccountLog(); | 
|                                 platformAccountLog.setCreateUserId(userId); | 
|                                 platformAccountLog.setType(Convert.toInt(CommonEnum.平台集货.getValue())); | 
|                                 platformAccountLog.setOldHbb(Convert.toBigDecimal(oldHbb)); | 
|                                 platformAccountLog.setHbb(Convert.toBigDecimal("-" + configValue)); | 
|                                 platformAccountLog.setNewHbb(NumberUtil.add(platformAccountLog.getOldHbb(), platformAccountLog.getHbb())); | 
|                                 platformAccountLog.setFlowNo(orderId); | 
|                                 platformAccountLogService.add(platformAccountLog); | 
|                                 //更新平台的环保比 | 
|                                 platformAccountInfoService.updateHbb("-" + configValue); | 
|                                 //记录用户账户日志表 | 
|                                 AccountInfo byUserId = accountService.findByUserId(userId); | 
|                                 if (byUserId != null) { | 
|   | 
|                                     //环保明细 | 
|                                     Map<String, Object> payMap = new HashMap<>(); | 
|                                     String otherPayOrderId = idUtils.generate("ZF", 0); | 
|                                     payMap.put("payOrderId", otherPayOrderId); | 
|                                     payMap.put("orderId", orderId); | 
|                                     payMap.put("createUserId", userId); | 
|                                     payMap.put("money", configValue); | 
|                                     payMap.put("accountId", byUserId.getAccountId()); | 
|                                     payMap.put("payType", PayEnum.环保金收入.getValue()); | 
|                                     payMap.put("status", PayEnum.已审核.getValue()); | 
|                                     payMap.put("createTime", DateUtil.now()); | 
|                                     payInfoMapper.payInfoAdd(payMap); | 
|   | 
|   | 
|                                     String collectScore = byUserId.getMoney(); | 
|                                     if (StrUtil.isBlank(collectScore)) collectScore = "0"; | 
|                                     AccountLog accountScoreLog = new AccountLog(); | 
|                                     accountScoreLog.setAccountId(byUserId.getAccountId()); | 
|                                     accountScoreLog.setOldMoney(collectScore); | 
|                                     accountScoreLog.setNewMoney(NumberUtil.add(Convert.toBigDecimal(accountScoreLog.getOldMoney()), Convert.toBigDecimal(collectScore)).toString()); | 
|                                     accountScoreLog.setCreateUserId(userId); | 
|                                     accountScoreLog.setChannelType(Convert.toShort(CommonEnum.回收操作.getValue())); | 
|                                     accountScoreLog.setOrderId(otherPayOrderId); | 
|                                     accountLogService.add(accountScoreLog); | 
|                                     //更新用户环保比 | 
|                                     accountService.updateMoneyByUserId(userId, Convert.toBigDecimal(configValue)); | 
|                                 } | 
|                             } else if (PayEnum.积分支付.getValue().equals(payType)) { | 
|                                 String configValue = configInfoList.stream().filter(x -> x.getConfigTypeCode().equals(SysConfigConstant.SCORE_GATHER_ORDER)).collect(Collectors.toList()).get(0).getConfigValue(); | 
|                                 //平台要减去积分 | 
|                                 platformAccountInfoService.updateScore("-" + configValue); | 
|   | 
|                                 //记录用户积分日志表 | 
|                                 AccountInfo byUserId = accountService.findByUserId(userId); | 
|                                 if (byUserId != null) { | 
|   | 
|                                     //环保明细 | 
|                                     Map<String, Object> payMap = new HashMap<>(); | 
|                                     String otherPayOrderId = idUtils.generate("ZF", 0); | 
|                                     payMap.put("payOrderId", otherPayOrderId); | 
|                                     payMap.put("orderId", orderId); | 
|                                     payMap.put("createUserId", userId); | 
|                                     payMap.put("money", configValue); | 
|                                     payMap.put("accountId", byUserId.getAccountId()); | 
|                                     payMap.put("payType", PayEnum.积分收入.getValue()); | 
|                                     payMap.put("status", PayEnum.已审核.getValue()); | 
|                                     payMap.put("createTime", DateUtil.now()); | 
|                                     payInfoMapper.payInfoAdd(payMap); | 
|   | 
|   | 
|                                     String collectScore = byUserId.getCollectScore(); | 
|                                     if (StrUtil.isBlank(collectScore)) collectScore = "0"; | 
|                                     AccountScoreLog accountScoreLog = new AccountScoreLog(); | 
|                                     accountScoreLog.setAccountId(byUserId.getAccountId()); | 
|                                     accountScoreLog.setOldScore(collectScore); | 
|                                     accountScoreLog.setManageScore(configValue); | 
|                                     accountScoreLog.setNewScore(NumberUtil.add(Convert.toBigDecimal(accountScoreLog.getOldScore()), Convert.toBigDecimal(accountScoreLog.getManageScore())).toString()); | 
|                                     accountScoreLog.setCreateUserId(userId); | 
|                                     accountScoreLog.setCreateTime(DateUtil.now()); | 
|                                     accountScoreLog.setChannelType(Convert.toShort(OrderEnum.集货积分类型.getValue())); | 
|                                     accountScoreLog.setOrderId(orderId); | 
|                                     accountScoreLog.setPayId(otherPayOrderId); | 
|                                     accountScoreLog.setRoleType(Convert.toShort(CommonEnum.普通用户.getValue())); | 
|                                     //最新的平台积分 | 
|                                     PlatformAccountInfo collectScore1 = platformAccountInfoService.findByKey("collectScore"); | 
|                                     accountScoreLog.setNewPlatScore(collectScore1.getFieldValue()); | 
|                                     accountScoreLogMapper.insertSelective(accountScoreLog); | 
|                                     //更新用户积分 | 
|                                     accountService.updateScoreByUserId(userId, Convert.toBigDecimal(configValue)); | 
|                                 } | 
|                             } | 
|                         } | 
|   | 
|                     } | 
|                 } | 
|             } catch (Exception e) { | 
|                 ExceptionUtils.err("确认收货失败", e); | 
|             } finally { | 
|                 redisUtil.del(key); | 
|             } | 
|         } else { | 
|             throw new RestException("确认收货中,请稍候再试"); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 新版订单详情 | 
|      * | 
|      * @param orderNewDetailParamDTO | 
|      * @return | 
|      */ | 
|     public OrderNewDetailResDTO newDetail(OrderNewDetailParamDTO orderNewDetailParamDTO) { | 
|         OrderNewDetailResDTO resDTO = new OrderNewDetailResDTO(); | 
|         String orderId = orderNewDetailParamDTO.getOrderId(); | 
|   | 
|         //DB | 
|         OrderInfo order = findById(orderId); | 
|         OrderDetailInfo orderDetail = orderDetailService.findById(orderId); | 
|         Map<String, Object> map = getPartnerIdByReceiveOrFence(order.getReceiver(), order.getTownId(),orderDetail.getAddressId()+""); | 
|         String townId= (String) map.get("townId"); | 
|         List<OrderItemVo> orderItemList = orderItemService.findByOrderId(orderId,townId); | 
|         orderItemList = orderItemList.stream().filter(x -> (x.getWeight() != null && Convert.toBigDecimal(x.getWeight()).compareTo(BigDecimal.ZERO) != 0) || (x.getAmount() != null && Convert.toBigDecimal(x.getAmount()).compareTo(BigDecimal.ZERO) != 0)).collect(Collectors.toList()); | 
|   | 
|   | 
|         String receiver = order.getReceiver(); | 
|         String orderType = order.getOrderType(); | 
|         OtherUserInfo otherUserInfo = new OtherUserInfo(); | 
|         if (OrderEnum.集货.getValue().equals(orderType)) { | 
|             UserInfo userInfo = userService.findById(receiver); | 
|             BeanUtil.copyProperties(userInfo, otherUserInfo); | 
|         } else if (OrderEnum.废品站.getValue().equals(orderType)) { | 
|             UserScrapStore userScrapStore = userScrapStoreMapper.selectByPrimaryKey(order.getScrapId()); | 
|             List<OrderAppraiseInfo> orderAppraiseInfos = orderAppraiseInfoService.findByReceiver(order.getScrapId()); | 
|             //满意度 | 
|             if (CollUtil.isNotEmpty(orderAppraiseInfos)) { | 
|                 double sum = orderAppraiseInfos.stream().mapToDouble(x -> Convert.toDouble(x.getStar(), Convert.toDouble(Constants.SCORE_MAX))).sum(); | 
|                 userScrapStore.setSatisfaction(Convert.toInt(sum / (orderAppraiseInfos.size() * Constants.SCORE_MAX) * 100)); | 
|             } | 
|             resDTO.setScrapInfo(userScrapStore); | 
|         } else { | 
|             otherUserInfo = otherUserService.findById(receiver); | 
|         } | 
|   | 
|         //下单所属区域 | 
|         String townShipId; | 
|         if(otherUserInfo==null){ | 
|             townShipId = fenceService.findTownId(orderDetail.getAddressId().toString(), order.getTownId()); | 
|         }else { | 
|             townShipId=otherUserInfo.getTownshipId().toString(); | 
|         } | 
|   | 
|   | 
|         SysEnvironmentalInfo sysEnvironmentalInfo = null; | 
|         //平台废纸报价 | 
|         if (OrderEnum.回收.getValue().equals(orderType) || OrderEnum.到家服务.getValue().equals(orderType)) { | 
|             sysEnvironmentalInfo = sysEnvironmentalInfoService.findByItemTypeAndAreaNotDel(Constants.PAPER_WASTE_ITEM_TYPE, Convert.toInt(townShipId,Convert.toInt(Constants.TIANXIN_CODE))); | 
|         } | 
|   | 
|         //回收员或集货员信息 | 
|         if (!OrderEnum.废品站.getValue().equals(orderType)) { | 
|             UserRecommendListResDTO receiverInfo=new UserRecommendListResDTO(); | 
|             if(otherUserInfo!=null) { | 
|                 receiverInfo = otherUserService.getHeadInfo(otherUserInfo, order.getLongitude(), order.getLatitude(), order.getCreateUserId(), sysEnvironmentalInfo); | 
|             } | 
|             if (OrderEnum.集货.getValue().equals(orderType)) { | 
|                 receiverInfo.setType("1"); | 
|             } | 
|             resDTO.setReceiverInfo(receiverInfo); | 
|         } | 
|   | 
|   | 
|         //订单投诉信息 | 
|         Integer complaintFirstFlag=0; | 
|         List<ComplaintFindResDto> orderComplaints = orderComplaintService.detail(orderId); | 
|         if (CollUtil.isNotEmpty(orderComplaints)) { | 
|             //多次投诉 | 
|             complaintFirstFlag=1; | 
|         } | 
|   | 
|   | 
|         //订单信息 | 
|         OrderSimpleDTO orderInfo = new OrderSimpleDTO(); | 
|         orderInfo.setOrderId(order.getOrderId()); | 
|         orderInfo.setCreateTime(order.getCreateTime()); | 
|         orderInfo.setMoney(businessUtil.changeMoney(orderDetail.getMoney())); | 
|         orderInfo.setOrderItemInfoList(orderItemList); | 
|         orderInfo.setLatitude(order.getLatitude()); | 
|         orderInfo.setLongitude(order.getLongitude()); | 
|         orderInfo.setOrderStatus(order.getOrderStatus()); | 
|         orderInfo.setComplaintFirstFlag(complaintFirstFlag); | 
|         orderInfo.setReceiveTime(orderDetail.getReceiveTime()); | 
|         orderInfo.setChangeReceiverFlag(orderDetail.getChangeReceiverFlag()); | 
|   | 
|         //家电下单的家电信息 | 
|         if(orderDetail.getHomeApplianceId()!=null) { | 
|             OrderHomeAppliance byOrderId = orderHomeApplianceService.findById(orderDetail.getHomeApplianceId()); | 
|             orderInfo.setOrderHomeAppliance(byOrderId); | 
|         } | 
|   | 
|         resDTO.setOrderInfo(orderInfo); | 
|   | 
|         //下单用户信息 | 
|         UserSimpleDTO userInfo = new UserSimpleDTO(); | 
|         userInfo.setAddressComplete(order.getAddressArea() + order.getAddress()); | 
|         if (CollUtil.isNotEmpty(orderItemList)) { | 
|             userInfo.setItemNames(orderItemList.stream().map(x -> x.getItemTypeName()).collect(Collectors.joining(","))); | 
|         } | 
|         userInfo.setOrderType(order.getOrderType()); | 
|         userInfo.setRelaName(order.getRelaName()); | 
|         userInfo.setRelaPhone(order.getRelaPhone()); | 
|         userInfo.setRemark(orderDetail.getRemark()); | 
|         userInfo.setReserveTime(orderDetail.getReserveTime()); | 
|         resDTO.setUserInfo(userInfo); | 
|   | 
|         //设置地址信息 | 
|         AddressInfo addressInfo=new AddressInfo(); | 
|         BeanUtil.copyProperties(order,addressInfo); | 
|         addressInfo.setAddressId(orderDetail.getAddressId()); | 
|         GdReverseGEODto gdReverseGEODto = new GdReverseGEODto(); | 
|         gdReverseGEODto.setLocation(order.getLongitude()+","+order.getLatitude()); | 
|         Result areaInfo = GdMapUtil.getAreaInfo(gdReverseGEODto, 0); | 
|         if(areaInfo.getCode()==0) { | 
|             AddressInfo data = (AddressInfo) areaInfo.getData(); | 
|             addressInfo.setTownshipName(businessUtil.changeArea(data.getTownshipName())); | 
|             addressInfo.setProvinceName(data.getProvinceName()); | 
|             addressInfo.setCityName(data.getCityName()); | 
|         } | 
|         resDTO.setAddressInfo(addressInfo); | 
|   | 
|         return resDTO; | 
|     } | 
|   | 
|     public PageInfo<OrderInfoVo> queryForHomeAppliance(OrderInfoReq orderInfoReq,OtherUserInfo otherUserInfo) { | 
|         PageInfo<OrderInfoVo> result=new PageInfo<>(); | 
|         boolean b = existExcludeCityId(otherUserInfo.getCityId().toString()); | 
|         if(b){ | 
|             return  result; | 
|         } | 
|         //可查看订单数目 | 
|         int pageSize = orderInfoReq.getPageSize(); | 
|   | 
|         if (CommonEnum.回收员.getValue().equals(orderInfoReq.getUserType()) && OrderEnum.待接单.getValue().equals(orderInfoReq.getOrderStatus())) { | 
|   | 
|             int orderViewNum = Convert.toInt(configService.findByCode(SysConfigConstant.OUTER_ORDER_VIEW_TOTAL).getConfigValue()); | 
|             if (orderViewNum > 0) { | 
|                 //查看回收员当前正在服务中的数目 | 
|                 int receiveOrderNum = findReceiveOrderNum(otherUserInfo.getUserId()); | 
|                 pageSize = orderViewNum - receiveOrderNum; | 
|   | 
|                 if (pageSize <= 0) { | 
|                     return result; | 
|                 } | 
|             } | 
|         } | 
|   | 
|   | 
|         PageHelper.startPage(orderInfoReq.getPageNo(), pageSize); | 
|         orderInfoReq.setTownId(otherUserInfo.getCityId()+""); | 
|         orderInfoReq.setReceiver(otherUserInfo.getUserId()); | 
|   | 
|   | 
|         List<OrderInfoVo> orderList = orderMapper.queryForHomeAppliance(orderInfoReq); | 
|   | 
|         if (CollUtil.isNotEmpty(orderList)) { | 
|             for (OrderInfoVo orderInfo : orderList) { | 
|                 getOrderOtherInfo(orderInfo,orderInfoReq); | 
|             } | 
|         } | 
|         result = new PageInfo<>(orderList != null ? orderList : new ArrayList<>()); | 
|         return result; | 
|   | 
|     } | 
|   | 
| //    public void homeApplianceUpdate(OrderInfoReq orderInfoReq) { | 
| // | 
| //        String key=RedisKeyConstant.HOME_APPLIANCE+orderInfoReq.getOrderId(); | 
| //        String now=DateUtil.now(); | 
| //        try { | 
| //            if(redisService.setnx(key,"0")){ | 
| //                orderInfoReq.setCompleteTime(now); | 
| //                String createUserId = orderInfoReq.getCreateUserId(); | 
| //                UserInfo byId = userService.findById(createUserId); | 
| //                //修改目标客户的状态 | 
| //                UserTargetInfo userTargetInfo = new UserTargetInfo(); | 
| //                userTargetInfo.setRegsterType(Convert.toInt(UserEnum.已成交.getValue())); | 
| //                Example example2 = new Example(UserTargetInfo.class); | 
| //                example2.createCriteria().andEqualTo("mobile", byId.getMobilePhone()); | 
| //                userTargetInfoMapper.updateByExampleSelective(userTargetInfo, example2); | 
| // | 
| //                //下单用户 | 
| //                SysMessage sysMessage = new SysMessage(); | 
| //                sysMessage.setCreateTime(now); | 
| //                sysMessage.setCreateUserId(orderInfoReq.getReceiver()); | 
| //                sysMessage.setFlag(SysEnum.未读.getValue()); | 
| //                if (PayEnum.现金支出.getValue().equals(orderInfoReq.getPayType())) { | 
| //                    sysMessage.setMessage("订单" + orderInfoReq.getOrderId() + "完成"); | 
| //                } else { | 
| //                    sysMessage.setMessage("订单" + orderInfoReq.getOrderId() + "完成,您收到环保金" + orderInfoReq.getMoney() + "元"); | 
| //                } | 
| //                sysMessage.setMessageSubTypeName("赚取"); | 
| //                sysMessage.setMessageType(SysEnum.充值.getValue()); | 
| //                sysMessage.setUserId(createUserId); | 
| //                sysMessageMapper.insert(sysMessage); | 
| // | 
| //                //更新订单 | 
| //                orderMapper.updateOrderInfo(orderInfoReq); | 
| //                //更新物品详情 | 
| //                List<OrderItemReq> resList = getOrderWeight(orderInfoReq); | 
| //                orderMapper.updateOrderDetailInfo(orderInfoReq); | 
| //                //更新物品orderitemInfo信息  如果不存在则增加,否则更新 | 
| //                updateOrderItem(orderInfoReq, resList); | 
| // | 
| //                //订单状态变更 | 
| //                OrderReversDto orderReversDto=new OrderReversDto(); | 
| //                orderReversDto.setManageUserId(orderInfoReq.getReceiver()); | 
| //                orderReversDto.setNewStatus(OrderEnum.完成.getValue()); | 
| //                List<OrderDto> list=CollUtil.newArrayList(); | 
| //                OrderDto orderDto=new OrderDto(); | 
| //                orderDto.setOrderId(orderInfoReq.getOrderId()); | 
| //                orderDto.setReceiverId(orderInfoReq.getReceiver()); | 
| //                list.add(orderDto); | 
| //                orderReversDto.setList(list); | 
| //                orderRevers(orderReversDto); | 
| //            } | 
| //        }catch (RestException e){ | 
| //            ExceptionUtils.err(e.getMsg(),e); | 
| //        }catch (Exception e){ | 
| //            ExceptionUtils.err("确认订单失败",e); | 
| //        }finally { | 
| //            redisService.del(key); | 
| //        } | 
| // | 
| //    } | 
|   | 
|     /** | 
|      * 当前市是否属于排除的市 | 
|      * @param cityId | 
|      * @return | 
|      */ | 
|     public boolean existExcludeCityId(String cityId){ | 
|         //不能在配置的那几个区域内 | 
|         String configValue = configService.findByCode(SysConfigConstant.EXCLUDE_HOME_TOWNID).getConfigValue(); | 
|         List<String> townIds=Arrays.asList(configValue.split(",")); | 
|         if(CollUtil.isNotEmpty(townIds)&&townIds.contains(cityId)){ | 
|             return true; | 
|         } | 
|         return  false; | 
|     } | 
|   | 
|     public void changeReceiverAudit(OrderChangeReceiverAuditDto orderChangeReceiverAuditDto) { | 
|         OrderDetailInfo orderDetailInfo = orderDetailService.findById(orderChangeReceiverAuditDto.getOrderId()); | 
|         if(orderChangeReceiverAuditDto.getFlag()) { | 
|             //同意 | 
|             orderDetailInfo.setChangeReceiverFlag(Convert.toShort(2)); | 
|   | 
|             OrderInfo orderInfo=findById(orderDetailInfo.getOrderId()); | 
|             orderInfo.setOrderStatus(OrderEnum.待接单.getValue()); | 
|             orderInfo.setReceiver(null); | 
|             updateOrderAll(orderInfo); | 
|             redisUtil.set(RedisKeyConstant.ORDER_CANCEL+orderDetailInfo.getOrderId(),"0"); | 
|         }else{ | 
|             orderDetailInfo.setChangeReceiverFlag(null); | 
|         } | 
|         orderDetailService.updateAllById(orderDetailInfo); | 
|     } | 
| } |