| package com.xzx.gc.order.controller; | 
|   | 
| import cn.hutool.core.bean.BeanUtil; | 
| import cn.hutool.core.codec.Base64; | 
| import cn.hutool.core.collection.CollUtil; | 
| import cn.hutool.core.convert.Convert; | 
| import cn.hutool.core.date.DateUtil; | 
| import cn.hutool.core.lang.Validator; | 
| import cn.hutool.core.util.NumberUtil; | 
| import cn.hutool.core.util.StrUtil; | 
| import cn.hutool.json.JSONUtil; | 
| import cn.jpush.api.push.model.audience.Audience; | 
| 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.CommonDto; | 
| import com.xzx.gc.common.dto.SimplePage; | 
| import com.xzx.gc.common.dto.log.OperationAppLog; | 
| import com.xzx.gc.common.exception.RestException; | 
| import com.xzx.gc.common.request.BaseController; | 
| import com.xzx.gc.common.utils.*; | 
| import com.xzx.gc.entity.*; | 
| import com.xzx.gc.model.FileExportDTO; | 
| import com.xzx.gc.model.JsonResult; | 
| import com.xzx.gc.model.admin.*; | 
| 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.UserGatherOrderParam; | 
| import com.xzx.gc.model.user.UserGatherOrderRes; | 
| import com.xzx.gc.model.user.UserGatherOrderSureListParam; | 
| import com.xzx.gc.model.user.UserGatherOrderSureParam; | 
| import com.xzx.gc.order.dto.*; | 
| import com.xzx.gc.order.mapper.*; | 
| import com.xzx.gc.order.service.*; | 
| import com.xzx.gc.util.DoubleUtil; | 
| import io.swagger.annotations.Api; | 
| import io.swagger.annotations.ApiImplicitParam; | 
| import io.swagger.annotations.ApiImplicitParams; | 
| import io.swagger.annotations.ApiOperation; | 
| import lombok.extern.slf4j.Slf4j; | 
| import org.springframework.beans.BeanUtils; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.beans.factory.annotation.Value; | 
| import org.springframework.http.MediaType; | 
| import org.springframework.validation.annotation.Validated; | 
| import org.springframework.web.bind.annotation.*; | 
|   | 
| import javax.servlet.http.HttpServletRequest; | 
| import javax.servlet.http.HttpServletResponse; | 
| import java.io.UnsupportedEncodingException; | 
| import java.math.BigDecimal; | 
| import java.math.RoundingMode; | 
| import java.util.*; | 
| import java.util.stream.Collectors; | 
|   | 
| /** | 
|  * @author:andylei | 
|  * @title | 
|  * @Description | 
|  * @date 2018/11/22/022 | 
|  * @修改历史 | 
|  */ | 
| @Api(tags = "订单管理") | 
| @RestController | 
| @Slf4j | 
| public class OrderController extends BaseController { | 
|   | 
|     @Autowired | 
|     private OrderDetailService orderDetailService; | 
|   | 
|     @Autowired | 
|     private OtherUserService otherUserService; | 
|     @Autowired | 
|     private MqUtil mqUtil; | 
|   | 
|     @Autowired | 
|     private OrderService orderService; | 
|   | 
|     @Autowired | 
|     private OrderClockInMapper orderClockInMapper; | 
|   | 
|     @Autowired | 
|     private AddressMapper addressMapper; | 
|   | 
|     @Autowired | 
|     private OrderMapper orderMapper; | 
|   | 
|     @Autowired | 
|     private ConfigService configService; | 
|   | 
|     @Autowired | 
|     private StorageService storageService; | 
|   | 
|     @Autowired | 
|     private OtherUserMapper otherUserMapper; | 
|   | 
|   | 
|     @Autowired | 
|     private OrderClockInService orderClockInService; | 
|   | 
|   | 
|     @Autowired | 
|     private RuleService ruleService; | 
|   | 
|     @Autowired | 
|     private StoreInfoMapper storeInfoMapper; | 
|   | 
|     @Autowired | 
|     private FenceService fenceService; | 
|   | 
|     @Autowired | 
|     private BusinessUtil businessUtil; | 
|   | 
|     @Autowired | 
|     private PartnerGaodeService partnerGaodeService; | 
|   | 
|     @Autowired | 
|     private AddressService addressService; | 
|   | 
|     @Autowired | 
|     private PartnerFenceService partnerFenceService; | 
|   | 
|     @Autowired | 
|     private JGPushUtil jgPushUtil; | 
|   | 
|     @Autowired | 
|     private UserService userService; | 
|   | 
|     @Autowired | 
|     private AddressLevelService addressLevelService; | 
|   | 
|     @Autowired | 
|     private PartnerFenceMapper partnerFenceMapper; | 
|   | 
|   | 
|     @Value("${jg.appkey}") | 
|     private String JG_APP_KEY; | 
|     @Value("${jg.secret}") | 
|     private String JG_SECRET; | 
|   | 
|     @Autowired | 
|     private CityPartnerService cityPartnerService; | 
|   | 
|     @Autowired | 
|     private UserMapper userMapper; | 
|   | 
|     /** | 
|      * 订单增加 | 
|      * | 
|      * @param orderInfoReq | 
|      */ | 
|     @ApiOperation(value = "下单") | 
|     @PostMapping("/order/add") | 
|     public Result<String> orderAdd(HttpServletRequest request, @Validated @RequestBody OrderInfoReq orderInfoReq) { | 
|   | 
|   | 
|         //截取经纬度为小数点后6位 | 
|         if (StrUtil.isNotBlank(orderInfoReq.getLatitude())) { | 
|             Double aDouble = Convert.toDouble(NumberUtil.roundStr(orderInfoReq.getLatitude(), 6, RoundingMode.DOWN)); | 
|             orderInfoReq.setLatitude(Convert.toStr(aDouble)); | 
|         } | 
|   | 
|         if (StrUtil.isNotBlank(orderInfoReq.getLongitude())) { | 
|             Double aDouble = Convert.toDouble(NumberUtil.roundStr(orderInfoReq.getLongitude(), 6, RoundingMode.DOWN)); | 
|             orderInfoReq.setLongitude(Convert.toStr(aDouble)); | 
|         } | 
|   | 
|         if (StringUtils.isNotBlank(orderInfoReq.getCreateUserName())) { | 
|             if (!StringUtils.isBase64(orderInfoReq.getCreateUserName())) { | 
|                 orderInfoReq.setCreateUserName(Base64.encode(orderInfoReq.getCreateUserName())); | 
|             } | 
|         } | 
|   | 
|         if (OrderEnum.待接单.getValue().equals(orderInfoReq.getOrderStatus())) { | 
|             Validator.validateNotEmpty(orderInfoReq.getAddress(), "详细地址不能为空"); | 
|         } | 
|   | 
|         String reserveTime = orderInfoReq.getReserveTime(); | 
|   | 
|         //正常下单 | 
|         if (orderInfoReq.getStoreId() == null) { | 
|             if (StrUtil.isBlank(reserveTime)) { | 
|                 throw new RestException(-1, "预约时间不能为空"); | 
|             } else { | 
|                 try { | 
|                     DateUtil.parse(reserveTime, "yyyy-MM-dd HH:mm"); | 
|                 } catch (Exception e) { | 
|                     throw new RestException(-1, "预约时间格式不正确"); | 
|                 } | 
|             } | 
|         } else { | 
|             //门店下单 | 
|             StoreInfo storeInfo = storeInfoMapper.selectByPrimaryKey(orderInfoReq.getStoreId()); | 
|             if (storeInfo != null) { | 
|                 if (Constants.DEL_FLAG == Convert.toInt(storeInfo.getDelFlag(), Constants.DEL_FLAG) || Constants.CLOSE.equals(storeInfo.getFlag())) { | 
|                     throw new RestException(-1, "门店已关闭"); | 
|                 } | 
|                 //单位米 | 
|                 double distance = LocationUtils.getDistance(Convert.toDouble(storeInfo.getLatitude()), Convert.toDouble(storeInfo.getLongitude()), Convert.toDouble(orderInfoReq.getLatitude()), Convert.toDouble(orderInfoReq.getLongitude())); | 
|                 if (NumberUtil.compare(distance, Convert.toDouble(5000)) > 0) { | 
|                     throw new RestException(-1, "您当前下单位置超出门店服务范围"); | 
|                 } | 
|             } else { | 
|                 throw new RestException(-1, "门店不存在"); | 
|             } | 
|   | 
|         } | 
|   | 
|   | 
|         orderInfoReq.setVersion(getVersion(request)); | 
|   | 
|         if (orderInfoReq.getType() == 1) { | 
|             //预约时间不对或者是定点下单的情况 | 
|             if ("0000-00-00 00:00".equals(orderInfoReq.getReserveTime()) || ":00".equals(orderInfoReq.getReserveTime())) { | 
|                 orderInfoReq.setReserveTime(DateUtil.format(new Date(), DateUtils.DATE_FORMAT_YMDHM)); | 
|             } | 
|         } | 
|   | 
|         //下单用户手机号码不能在平台存在别的身份 | 
|         String mobile = orderInfoReq.getType() == 0 ? orderInfoReq.getMobilePhone() : orderInfoReq.getRelaPhone(); | 
|         if (!SpringUtil.isDev()) { | 
|             List<OtherUserInfo> byMobileForBidden = otherUserService.findByMobileAndTypeForBidden(mobile, CommonEnum.回收员.getValue()); | 
|             if (CollUtil.isNotEmpty(byMobileForBidden)) { | 
|                 throw new RestException(-1, "您是平台骑手,暂不支持下单操作"); | 
|             } | 
|         } | 
|   | 
|         String orderId = orderService.orderAdd(orderInfoReq); | 
|   | 
|   | 
|         OperationAppLog build = OperationAppLog.builder().appPrograme(getFrontClient(request)).opreateName(mobile) | 
|                 .methodName(Constants.ORDER_MODUL_NAME).operateAction("下单-" + orderId).build(); | 
|         mqUtil.sendApp(build); | 
|   | 
|         return Result.success(); | 
|     } | 
|   | 
|   | 
|     @ApiOperation(value = "重新指派") | 
|     @PostMapping("/order/point") | 
|     public Result<String> point(HttpServletRequest request, @RequestBody OrderPointDto orderPointDto) { | 
|         Result point = orderService.point(orderPointDto); | 
|         if (point.getCode() == 0) { | 
|             String mobilePhone = userService.findOtherByUserId(getUserId(request), 1); | 
|             OperationAppLog build = OperationAppLog.builder().appPrograme(getFrontClient(request)).opreateName(mobilePhone) | 
|                     .methodName(Constants.ORDER_MODUL_NAME).operateAction("重新指派-" + orderPointDto.getOrderId()).build(); | 
|             mqUtil.sendApp(build); | 
|         } | 
|         return point; | 
|     } | 
|   | 
|   | 
|     @ApiOperation(value = "修改订单地址") | 
|     @PostMapping("/order/updateAddress") | 
|     public Result updateAddress(HttpServletRequest request, @RequestBody OrderUpdateAddressDto orderUpdateAddress) { | 
|   | 
|         //截取经纬度为小数点后6位 | 
|         if (StrUtil.isNotBlank(orderUpdateAddress.getLatitude())) { | 
|             Double aDouble = Convert.toDouble(NumberUtil.roundStr(orderUpdateAddress.getLatitude(), 6, RoundingMode.DOWN)); | 
|             orderUpdateAddress.setLatitude(Convert.toStr(aDouble)); | 
|         } | 
|   | 
|         if (StrUtil.isNotBlank(orderUpdateAddress.getLongitude())) { | 
|             Double aDouble = Convert.toDouble(NumberUtil.roundStr(orderUpdateAddress.getLongitude(), 6, RoundingMode.DOWN)); | 
|             orderUpdateAddress.setLongitude(Convert.toStr(aDouble)); | 
|         } | 
|   | 
|   | 
| //        String townId=orderService.getFenceId(orderUpdateAddress.getLongitude(), orderUpdateAddress.getLatitude(),orderUpdateAddress.getAddressId().toString(),orderUpdateAddress.getOrderId(),0); | 
|   | 
|         Long addressId = orderUpdateAddress.getAddressId(); | 
|         AddressInfo byId1 = addressService.findById(addressId.toString()); | 
|         FenceDto fence = fenceService.getFence(byId1.getTownshipId(), false, orderUpdateAddress.getLongitude(), orderUpdateAddress.getLatitude(), true); | 
|         if (StrUtil.isBlank(fence.getFenceId())) { | 
|             throw new RestException(-3, "所选位置暂未开通服务"); | 
|         } | 
|   | 
|         orderUpdateAddress.setTownId(fence.getFenceId()); | 
|         OrderInfo orderInfo = new OrderInfo(); | 
|         BeanUtils.copyProperties(orderUpdateAddress, orderInfo); | 
|         orderService.updateOrderById(orderInfo); | 
|   | 
|         OrderDetailInfo orderDetailInfo = new OrderDetailInfo(); | 
|         BeanUtils.copyProperties(orderUpdateAddress, orderDetailInfo); | 
|         orderDetailService.update(orderDetailInfo); | 
|   | 
|         String mobilePhone = userService.findOtherByUserId(getUserId(request), 1); | 
|         OperationAppLog build = OperationAppLog.builder().appPrograme(getFrontClient(request)).opreateName(mobilePhone) | 
|                 .methodName(Constants.ORDER_MODUL_NAME).operateAction("更新订单地址-" + orderUpdateAddress.getOrderId()).build(); | 
|         mqUtil.sendApp(build); | 
|   | 
|   | 
|         return Result.success(); | 
|     } | 
|   | 
|   | 
|     @ApiOperation(value = "更新订单") | 
|     @PostMapping("/order/update") | 
|     public Result<String> updateOrder(HttpServletRequest request, @RequestBody OrderInfoReq orderInfoReq) { | 
|         Result result = orderService.updateOrder(orderInfoReq); | 
|         if (result.getCode() == 0) { | 
|             String mobilePhone; | 
|             if (StrUtil.isNotBlank(orderInfoReq.getReceiver())) { | 
|                 mobilePhone = userService.findOtherByUserId(getUserId(request), 1); | 
|             } else { | 
|                 mobilePhone = userService.findOtherByUserId(getUserId(request), 0); | 
|             } | 
|             OperationAppLog build = OperationAppLog.builder().appPrograme(getFrontClient(request)).opreateName(mobilePhone) | 
|                     .methodName(Constants.ORDER_MODUL_NAME).operateAction("更新订单-" + orderInfoReq.getOrderId()).build(); | 
|             mqUtil.sendApp(build); | 
|         } | 
|         return result; | 
|     } | 
|   | 
|     @ApiOperation(value = "催单") | 
|     @PostMapping("/order/reminder") | 
|     public Result<String> reminder(HttpServletRequest request, @RequestBody OrderReminderDto orderReminderDto) { | 
|         OrderDetailInfo orderInfo = new OrderDetailInfo(); | 
|         BeanUtil.copyProperties(orderReminderDto, orderInfo); | 
|         orderInfo.setOrderFastFlag(Convert.toShort(0)); | 
|         orderDetailService.update(orderInfo); | 
|         //根据订单ID查找所属合伙运营员 进行推送 | 
|         OrderInfo byId = orderService.findById(orderReminderDto.getOrderId()); | 
|         String townId = byId.getTownId(); | 
|         String partnerIdByFenceId = partnerFenceService.findPartnerIdByFenceId(townId); | 
|         if (StrUtil.isNotBlank(partnerIdByFenceId)) { | 
|             //推送 | 
|             jgPushUtil.pushRemindOrder(partnerIdByFenceId); | 
|         } | 
|   | 
|         String mobilePhone = userService.findOtherByUserId(getUserId(request), 0); | 
|         OperationAppLog build = OperationAppLog.builder().appPrograme(getFrontClient(request)).opreateName(mobilePhone) | 
|                 .methodName(Constants.ORDER_MODUL_NAME).operateAction("催单-" + orderReminderDto.getOrderId()).build(); | 
|         mqUtil.sendApp(build); | 
|         return Result.success(); | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 更新订单取消原因 | 
|      * | 
|      * @param orderInfoReq | 
|      */ | 
|     @ApiOperation(value = "修改订单取消原因") | 
|     @PostMapping("/order/update/cancelreason") | 
|     public Result<String> updateOrderCancelReason(HttpServletRequest request, @RequestBody OrderInfoReq orderInfoReq) { | 
|         LogUtils.setTraceId(LogUtils.TRACE_ORDER_ID, orderInfoReq.getOrderId()); | 
|         orderService.updateOrderCancelReason(orderInfoReq); | 
|   | 
|         String mobilePhone = userService.findOtherByUserId(getUserId(request), 0); | 
|         OperationAppLog build = OperationAppLog.builder().appPrograme(getFrontClient(request)).opreateName(mobilePhone) | 
|                 .methodName(Constants.ORDER_MODUL_NAME).operateAction("更新订单取消原因-" + orderInfoReq.getOrderId()).build(); | 
|         mqUtil.sendApp(build); | 
|         return Result.success(); | 
|     } | 
|   | 
|     @ApiOperation(value = "订单列表查询") | 
|     @PostMapping("/order/list/query") | 
|     public Result<PageInfo<OrderInfoVo>> orderListQuery(HttpServletRequest request, @RequestBody OrderInfoReq orderInfoReq) { | 
|   | 
|         Result<PageInfo<OrderInfoVo>> result = new Result(); | 
|         String userId = getUserId(request); | 
|         if (!CommonEnum.普通用户.getValue().equals(orderInfoReq.getUserType())) { | 
|             OtherUserInfo otherUserInfo = otherUserMapper.selectByPrimaryKey(userId); | 
|             String leaveStartTime = otherUserInfo.getLeaveStartTime(); | 
|             String leaveEndTime = otherUserInfo.getLeaveEndTime(); | 
|             //可能请假 | 
|             if (StrUtil.isNotBlank(leaveStartTime) && OrderEnum.待接单.getValue().equals(orderInfoReq.getOrderStatus())) { | 
|                 if (DateUtil.compare(new Date(), DateUtil.parse(leaveStartTime)) >= 0 && DateUtil.compare(new Date(), DateUtil.parse(leaveEndTime)) <= 0) { | 
|                     return Result.success(new PageInfo<>(new ArrayList<>())); | 
|                 } | 
|             } | 
|   | 
|   | 
|             orderInfoReq.setUserType(otherUserInfo.getUserType()); | 
|             orderInfoReq.setLoginUserPhone(otherUserInfo.getMobilePhone()); | 
|   | 
|             //查询回收员是否绑定门店 | 
|             //如果回收员绑定了门店,则按门店的经纬度 ,否则是动态的传过来的经纬度 | 
| //            Example example=new Example(StoreInfo.class); | 
| //            Example.Criteria criteria = example.createCriteria(); | 
| //            criteria.andEqualTo("userId",otherUserInfo.getUserId()); | 
| //            criteria.andEqualTo("delFlag",Constants.DEL_NOT_FLAG+""); | 
| //            criteria.andEqualTo("flag",Constants.OPEN); | 
| //            List<StoreInfo> select = storeInfoMapper.selectByExample(example); | 
| //            if(CollUtil.isNotEmpty(select)){ | 
| //                  StoreInfo storeInfo1=select.get(0); | 
| //                  orderInfoReq.setLatitude(storeInfo1.getLatitude()); | 
| //                  orderInfoReq.setLongitude(storeInfo1.getLongitude()); | 
| //                  orderInfoReq.setStoreId(storeInfo1.getId()); | 
| //            } | 
|   | 
|   | 
|             //回收员只能看到自己负责的区域的单 | 
|             boolean exclude = false; | 
|             //指定要排除指定骑手的合伙人 | 
|             String configValue = configService.findByCode(SysConfigConstant.EXCLUDE_OTHER_PARTNER).getConfigValue(); | 
|             if (StrUtil.isNotBlank(configValue)) { | 
|                 List<String> partnerIdlist = Arrays.asList(configValue.split(",")); | 
|                 String partnerId = otherUserInfo.getPartnerId(); | 
|                 if (partnerIdlist.contains(partnerId)) { | 
|                     exclude = true; | 
|                 } | 
|             } | 
|   | 
|             // | 
|             if (!exclude) { | 
|                 orderInfoReq.setReceiver(otherUserInfo.getUserId()); | 
|             } | 
|   | 
|             orderInfoReq.setTownId(otherUserInfo.getTownId()); | 
|   | 
|             if (!orderClockInService.notClock(userId)) { | 
|                 ConfigInfoReq configInfoReq = new ConfigInfoReq(); | 
|                 configInfoReq.setConfigTypeCode("CODE_SCAN_RK"); | 
|                 List<ConfigInfoVo> configInfoVos = configService.configInfoQuery(configInfoReq); | 
|                 configValue = configInfoVos.get(0).getConfigValue(); | 
|   | 
|                 if (OrderEnum.未开放入库扫码.getValue().equals(configValue)) { | 
|                     //用户有未进行空车打卡操作 | 
|                     OrderClockIn today = orderClockInMapper.findToday(userId, StrUtil.split(DateUtil.now(), " ")[0]); | 
|                     if (today == null) { | 
|                         result.setCode(-1); | 
|                         result.setMsg("您今日还未进行打卡"); | 
|                         return result; | 
|                     } | 
|                 } | 
|             } | 
|   | 
|             orderInfoReq.setOrderTypeList(CollUtil.newArrayList("1","2")); | 
|         } else { | 
|             orderInfoReq.setUserType(CommonEnum.普通用户.getValue()); | 
|             orderInfoReq.setOrderTypeList(CollUtil.newArrayList("1", "2", "3", "4", "5")); | 
|         } | 
|         PageInfo<OrderInfoVo> pageInfo = orderService.orderListQuery(orderInfoReq); | 
|         result.setData(pageInfo); | 
|         return result; | 
|     } | 
|   | 
|   | 
|     @ApiOperation(value = "管理员订单列表查询") | 
|     @PostMapping("/order/list/queryForAdmin") | 
|     public Result<PageInfo<OrderInfoVo>> queryForAdmin(HttpServletRequest request, @RequestBody OrderInfoReq orderInfoReq) { | 
|         Result<PageInfo<OrderInfoVo>> result = new Result(); | 
|         String userId = getUserId(request); | 
|         OtherUserInfo otherUserInfo = otherUserMapper.selectByPrimaryKey(userId); | 
|   | 
|   | 
|         orderInfoReq.setUserType(otherUserInfo.getUserType()); | 
|         // 所有的角色 | 
|         List<OtherUserInfo> select = otherUserService.findByMobile(otherUserInfo.getMobilePhone()); | 
|         String roleIds = select.stream().map(OtherUserInfo::getRoleIds).collect(Collectors.joining(",")); | 
|         orderInfoReq.setRoleIds(roleIds); | 
|         //所有身份类型 | 
|         List<String> userTypeList = select.stream().map(OtherUserInfo::getUserType).collect(Collectors.toList()); | 
|   | 
|         orderInfoReq.setLoginUserPhone(otherUserInfo.getMobilePhone()); | 
|   | 
|   | 
|         if (userTypeList.contains(CommonEnum.运营员.getValue()) || userTypeList.contains(CommonEnum.骑手组长.getValue())) { | 
|             String partnerId = otherUserInfo.getPartnerId(); | 
|             List<String> collect = partnerFenceService.findFences(partnerId); | 
|             orderInfoReq.setFenceIds(collect); | 
|             orderInfoReq.setPartnerId(partnerId); | 
|         } | 
|   | 
|         PageInfo<OrderInfoVo> pageInfo = orderService.orderListQueryForAdmin(orderInfoReq); | 
|         result.setData(pageInfo); | 
|         return result; | 
|     } | 
|   | 
|   | 
|     @ApiOperation(value = "家电骑手订单列表查询") | 
|     @PostMapping("/order/list/queryForHomeAppliance") | 
|     public Result<PageInfo<OrderInfoVo>> queryForHomeAppliance(HttpServletRequest request, @RequestBody OrderInfoReq orderInfoReq) { | 
|   | 
|         Result<PageInfo<OrderInfoVo>> result = new Result(); | 
|         String userId = getUserId(request); | 
|         OtherUserInfo otherUserInfo = otherUserMapper.selectByPrimaryKey(userId); | 
|         String leaveStartTime = otherUserInfo.getLeaveStartTime(); | 
|         String leaveEndTime = otherUserInfo.getLeaveEndTime(); | 
|         //可能请假 | 
|         if (StrUtil.isNotBlank(leaveStartTime) && OrderEnum.待接单.getValue().equals(orderInfoReq.getOrderStatus())) { | 
|             if (DateUtil.compare(new Date(), DateUtil.parse(leaveStartTime)) >= 0 && DateUtil.compare(new Date(), DateUtil.parse(leaveEndTime)) <= 0) { | 
|                 return Result.success(new PageInfo<>(new ArrayList<>())); | 
|             } | 
|         } | 
|         PageInfo<OrderInfoVo> pageInfo = orderService.queryForHomeAppliance(orderInfoReq, otherUserInfo); | 
|         result.setData(pageInfo); | 
|         return result; | 
|     } | 
|   | 
|     /** | 
|      * 订单列表查询 | 
|      */ | 
|     @ApiOperation(value = "已完成订单列表查询", notes = "extra:rk代表入库员查询,不传则是回收员查询") | 
|     @PostMapping("/order/list/complete/query") | 
|     public Result<PageInfo<OrderStorageInfo>> orderListCompleteQuery(HttpServletRequest request, @RequestBody SimplePage simplePage) { | 
|         Result<PageInfo<OrderStorageInfo>> result = new Result(); | 
|         List<OrderStorageInfo> completeOrder = storageService.findCompleteOrder(simplePage, getUserId(request)); | 
|         PageInfo<OrderStorageInfo> pageInfo = new PageInfo<>(completeOrder); | 
|         int i = storageService.countStorageOrder(getUserId(request)); | 
|         pageInfo.setNavigatePages(i); | 
|         result.setData(pageInfo); | 
|         return result; | 
|     } | 
|   | 
|     /** | 
|      * 入库明细查询 | 
|      * | 
|      * @param | 
|      */ | 
|     @ApiOperation(value = "入库详情", notes = "id:入库Id") | 
|     @PostMapping("/order/storage/complete/detail") | 
|     public Result<StorageDetailBatchDto> orderStorageCompleteDetailQuery(HttpServletRequest request, @RequestBody CommonDto commonDto) { | 
|         String storageId = commonDto.getId(); | 
|         LogUtils.setTraceId(LogUtils.TRACE_ORDER_ID, storageId); | 
|         Result<StorageDetailBatchDto> result = new Result(); | 
|         StorageDetailBatchDto storageDetailBatchDto = storageService.detail(storageId); | 
|         result.setData(storageDetailBatchDto); | 
|         return result; | 
|   | 
|     } | 
|   | 
|   | 
|     @ApiOperation(value = "查看回收订单", notes = "id:入库ID") | 
|     @PostMapping("/order/storage/recyle/detail") | 
|     public Result<List<OrderDetailInfo>> orderRecyleCompleteDetailQuery(HttpServletRequest request, @RequestBody CommonDto commonDto) { | 
|         Result<List<OrderDetailInfo>> result = new Result(); | 
|         String storageId = commonDto.getId(); | 
|         LogUtils.setTraceId(LogUtils.TRACE_ORDER_ID, storageId); | 
|         List<OrderDetailInfo> list = storageService.recyledDetail(storageId); | 
|         result.setData(list); | 
|         return result; | 
|   | 
|     } | 
|   | 
|     @ApiOperation(value = "订单详情") | 
|     @PostMapping("/order/detail/query") | 
|     public Result<List<OrderInfoVo>> orderDetailQuery(HttpServletRequest request, @RequestBody OrderInfoReq orderInfoReq) { | 
|         Result<List<OrderInfoVo>> result = new Result(); | 
|         LogUtils.setTraceId(LogUtils.TRACE_ORDER_ID, orderInfoReq.getOrderId()); | 
|         List<OrderInfoVo> list = orderService.orderDetailQuery(orderInfoReq); | 
|         result.setData(list); | 
|         return result; | 
|     } | 
|   | 
|   | 
|     @ApiOperation(value = "入库列表查询") | 
|     @PostMapping("/order/storage/list") | 
|     public Result<List<OrderStorageVo>> orderStorageListQuery(@RequestBody OrderStorageReq orderStorageReq) { | 
|         Result<List<OrderStorageVo>> result = new Result(); | 
|   | 
|         List<OrderStorageVo> list = orderService.orderStorageListQuery(orderStorageReq); | 
|   | 
|         result.setData(list); | 
|   | 
|         return result; | 
|   | 
|     } | 
|   | 
|     /** | 
|      * 入库明细查询 | 
|      * | 
|      * @param | 
|      */ | 
|     @ApiOperation(value = "入库明细查询") | 
|     @PostMapping("/order/storage/detail") | 
|     public Result<List<OrderStorageVo>> orderStorageDetailQuery(HttpServletRequest request, @RequestBody OrderStorageReq orderStorageReq) { | 
|         Result<List<OrderStorageVo>> result = new Result(); | 
|         List<OrderStorageVo> list = orderService.orderStorageDetailQuery(orderStorageReq); | 
|         result.setData(list); | 
|         return result; | 
|   | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 获取默认预约时间 | 
|      */ | 
|     @ApiOperation(value = "获取默认预约时间", notes = "extra:0代表普通用户 1:平台用户 2集货员") | 
|     @PostMapping("/order/reserveTime") | 
|     public Result<OrderReserveResDto> getReserveTimeNew(HttpServletRequest request, @RequestBody CommonDto commonDto) { | 
|         Result<OrderReserveResDto> result = new Result<>(); | 
|         OrderReserveResDto orderReserveResDto = new OrderReserveResDto(); | 
|         //2集货员 | 
|         if ("2".equals(commonDto.getExtra())) { | 
|             String timeInterval = "0"; | 
|             List<ConfigInfo> orderTime = configService.findByGroup(SysConfigConstant.GATHER_ORDER_TIME); | 
|             for (ConfigInfo configInfo : orderTime) { | 
|                 if (configInfo.getConfigTypeCode().equals(SysConfigConstant.GATHER_INTERVAL_TIME)) { | 
|                     //分钟 | 
|                     timeInterval = configInfo.getConfigValue(); | 
|                 } else if (configInfo.getConfigTypeCode().equals(SysConfigConstant.GATHER_START_TIME)) { | 
|                     orderReserveResDto.setStartTime(configInfo.getConfigValue()); | 
|                 } else if (configInfo.getConfigTypeCode().equals(SysConfigConstant.GATHER_END_TIME)) { | 
|                     orderReserveResDto.setEndTime(configInfo.getConfigValue()); | 
|                 } | 
|             } | 
|             //获取时间间隔后的时间 | 
|             String reserveTime = DateUtil.offsetMinute(new Date(), Convert.toInt(timeInterval)).toString(DateUtils.DATE_FORMAT_YMDHMS); | 
|             orderReserveResDto.setReserveTime(reserveTime); | 
|         } else { | 
|             String partnerId = partnerGaodeService.findPartnerIdByUserId(getUserId(request), Convert.toInt(commonDto.getExtra())); | 
|             RuleDto stepRebate = ruleService.findWeightRebate(getUserId(request), false, partnerId); | 
|             orderReserveResDto.setList(stepRebate.getRebateRules()); | 
|             stepRebate = ruleService.findStepRebate(getUserId(request), false, partnerId); | 
|             orderReserveResDto.setScale(stepRebate.getScale()); | 
|             //预约时间 | 
|             orderService.getReserveTimeNew(orderReserveResDto, partnerId); | 
|         } | 
|         result.setData(orderReserveResDto); | 
|         return result; | 
|     } | 
|   | 
|     /** | 
|      * 获取各状态的订单列表数 | 
|      * | 
|      * @param orderInfoReq | 
|      */ | 
|     @ApiOperation(value = "获取各状态的订单列表数") | 
|     @PostMapping("/order/status/count") | 
|     public Result<OrderStatusCountVo> getReserveTime(HttpServletRequest request, @RequestBody OrderInfoReq orderInfoReq) { | 
|         Result<OrderStatusCountVo> result = new Result<>(); | 
|         OrderStatusCountVo orderStatusCount = orderService.orderListCount(orderInfoReq); | 
|         result.setData(orderStatusCount); | 
|         return result; | 
|     } | 
|   | 
|   | 
|     @ApiOperation(value = "自助下单列表查询") | 
|     @PostMapping("/order/customer/find") | 
|     public Result<PageInfo<OrderCustomDto>> customerFind(HttpServletRequest request, @RequestBody SimplePage simplePage) { | 
|         Result result = new Result(); | 
|         String userId = getUserId(request); | 
|         PageHelper.startPage(simplePage.getPageNo(), simplePage.getPageSize()); | 
|         List<OrderCustomDto> list = orderService.customerFind(userId); | 
|         PageInfo<OrderCustomDto> pageInfo = new PageInfo<>(list); | 
|         result.setData(pageInfo); | 
|         return result; | 
|     } | 
|   | 
|   | 
|     @ApiOperation(value = "根据订单id删除自助下单") | 
|     @PostMapping("/order/customer/delete") | 
|     public Result customerdel(HttpServletRequest request, @RequestBody CommonDto commonDto) { | 
|         String orderId = commonDto.getId(); | 
|         OrderInfo orderInfo = new OrderInfo(); | 
|         orderInfo.setOrderId(orderId); | 
|         orderInfo.setDelFlag(Convert.toShort(Constants.DEL_FLAG)); | 
|         orderMapper.updateByPrimaryKeySelective(orderInfo); | 
|   | 
|         String mobilePhone = userService.findOtherByUserId(getUserId(request), 1); | 
|         OperationAppLog build = OperationAppLog.builder().appPrograme(getFrontClient(request)).opreateName(mobilePhone) | 
|                 .methodName(Constants.ORDER_MODUL_NAME).operateAction("删除自助下单-" + orderId).build(); | 
|         mqUtil.sendApp(build); | 
|   | 
|         return Result.success(); | 
|     } | 
|   | 
|   | 
|     @ApiOperation(value = "根据日期查找回收员的订单") | 
|     @PostMapping("/order/findOrderByTime") | 
|     public Result<List<OrderInfo>> findByTime(HttpServletRequest request, @RequestBody FindOrderByTimeDto findOrderByTimeDto) { | 
|         List<OrderInfo> list = orderMapper.findOrderByTime(findOrderByTimeDto); | 
|         if (CollUtil.isNotEmpty(list)) { | 
|             for (OrderInfo orderInfo : list) { | 
|                 if (StrUtil.isNotBlank(orderInfo.getCompleteTime())) { | 
|                     //格式化hh:mm | 
|                     orderInfo.setCompleteTime(DateUtil.parse(orderInfo.getCompleteTime(), DateUtils.DATE_FORMAT_YMDHMS).toString(DateUtils.DATE_FORMAT_HM)); | 
|                 } | 
|             } | 
|         } | 
|         return Result.success(list); | 
|     } | 
|   | 
|   | 
|     @ApiOperation(value = "订单状态变更") | 
|     @PostMapping("/order/orderRevers") | 
|     public Result orderRevers(HttpServletRequest request, @RequestBody OrderReversDto orderReversDto) { | 
|         orderReversDto.setManageUserId(getUserId(request)); | 
|         orderReversDto.setIsSendMsg(true); | 
|         orderService.orderRevers(orderReversDto); | 
|   | 
|         String mobilePhone = userService.findOtherByUserId(getUserId(request), 1); | 
|         String collect = orderReversDto.getList().stream().map(x -> x.getOrderId()).collect(Collectors.joining(",")); | 
|         OperationAppLog build = OperationAppLog.builder().appPrograme(getFrontClient(request)).opreateName(mobilePhone) | 
|                 .methodName(Constants.ORDER_MODUL_NAME).operateAction("订单状态变更-" + collect).build(); | 
|         mqUtil.sendApp(build); | 
|         return Result.success(); | 
|     } | 
|   | 
|   | 
|     @ApiOperation(value = "订单标记") | 
|     @PostMapping("/order/mark") | 
|     public Result<String> mark(HttpServletRequest request, @RequestBody OrderMarkDTO orderMarkDTO) { | 
|         OrderDetailInfo orderDetailInfo = new OrderDetailInfo(); | 
|         BeanUtil.copyProperties(orderMarkDTO, orderDetailInfo); | 
|         //未读 | 
|         orderDetailInfo.setMarkRead("0"); | 
|         orderDetailService.update(orderDetailInfo); | 
|   | 
|         String mobilePhone = userService.findOtherByUserId(getUserId(request), 1); | 
|         OperationAppLog build = OperationAppLog.builder().appPrograme(getFrontClient(request)).opreateName(mobilePhone) | 
|                 .methodName(Constants.ORDER_MODUL_NAME).operateAction("订单标记-" + orderMarkDTO.getOrderId()).build(); | 
|         mqUtil.sendApp(build); | 
|         return Result.success(); | 
|     } | 
|   | 
|     @ApiOperation(value = "订单后台备注") | 
|     @PostMapping("/admin/front/order/note") | 
|     public Result<String> note(HttpServletRequest request, @RequestBody OrderMarkDTO orderMarkDTO) { | 
|         OrderDetailInfo orderDetailInfo = new OrderDetailInfo(); | 
|         orderDetailInfo.setOrderId(orderMarkDTO.getOrderId()); | 
|         orderDetailInfo.setNote(orderMarkDTO.getMarkCode()); | 
|         orderDetailService.update(orderDetailInfo); | 
|   | 
|         String mobilePhone = userService.findOtherByUserId(getUserId(request), 1); | 
|         OperationAppLog build = OperationAppLog.builder().appPrograme(getFrontClient(request)).opreateName(mobilePhone) | 
|                 .methodName(Constants.ORDER_MODUL_NAME).operateAction("订单后台备注-" + orderMarkDTO.getOrderId()).build(); | 
|         mqUtil.sendApp(build); | 
|         return Result.success(); | 
|     } | 
|   | 
|     @ApiOperation(value = "到家服务支付") | 
|     @PostMapping("/order/homePay") | 
|     public Result<String> homePay(HttpServletRequest request, @RequestBody OrderHomePayDto orderHomePayDto) { | 
|   | 
|         String money = orderHomePayDto.getMoney(); | 
|         if (StrUtil.isBlank(money) || Convert.toBigDecimal(money).compareTo(BigDecimal.ZERO) <= 0) { | 
|             throw new RestException("支付金额不正确"); | 
|         } | 
|         Result<String> result = orderService.homePay(orderHomePayDto.getOrderId(), Convert.toBigDecimal(money)); | 
|         if (result.getCode() == 0) { | 
|             OperationAppLog build = OperationAppLog.builder().appPrograme(getFrontClient(request)).opreateName(result.getData()) | 
|                     .methodName(Constants.ORDER_MODUL_NAME).operateAction("到家服务支付-" + orderHomePayDto.getOrderId()).build(); | 
|             mqUtil.sendApp(build); | 
|         } | 
|   | 
|         return result; | 
|   | 
|     } | 
|   | 
|     /** | 
|      * 查询用户订单 | 
|      * | 
|      * @param orderModel | 
|      * @return | 
|      */ | 
|     @PostMapping("/admin/front/order/queryOrderDataList.do") | 
|     @ApiOperation(value = "订单管理-用户订单", notes = "test: 仅0有正确返回") | 
|     public JsonResult<Map<String, Object>> queryOrderDataList(@RequestBody OrderModel orderModel) { | 
|         Map<String, Object> result = orderService.queryOrderApiList(orderModel); | 
|         return JsonResult.success(result); | 
|     } | 
|   | 
|     /** | 
|      * 根据订单好查询订单详细 | 
|      * | 
|      * @param orderModel | 
|      * @return | 
|      */ | 
|     @PostMapping("/admin/front/order/queryOrderDetailByNo.json") | 
|     @ApiOperation(value = "订单管理-用户订单详情", notes = "test: 仅0有正确返回") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(paramType = "query", name = "page", value = "页码", required = true, dataType = "int"), | 
|             @ApiImplicitParam(paramType = "query", name = "limit", value = "每页条数", required = true, dataType = "int"), | 
|             @ApiImplicitParam(paramType = "query", name = "orderId", value = "订单编号", required = true, dataType = "int") | 
|     }) | 
|     public JsonResult<Map<String, Object>> queryOrderDetailByNo(@RequestBody OrderModel orderModel) { | 
|         Map<String, Object> map = orderService.queryOrderByOrderno(orderModel); | 
|         return JsonResult.success(map); | 
|     } | 
|   | 
|     /** | 
|      * 查询指派员或回收员 | 
|      * | 
|      * @param orderModel | 
|      * @return | 
|      */ | 
|     @PostMapping("/admin/front/order/queryCuserApiByType.json") | 
|     @ApiOperation(value = "订单管理-指派工作人员", notes = "test: 仅0有正确返回") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(paramType = "query", name = "page", value = "页码", required = true, dataType = "int"), | 
|             @ApiImplicitParam(paramType = "query", name = "limit", value = "每页条数", required = true, dataType = "int"), | 
|             @ApiImplicitParam(paramType = "query", name = "orderId", value = "订单编号", required = true, dataType = "int"), | 
|             @ApiImplicitParam(paramType = "query", name = "name", value = "条件", required = true, dataType = "int") | 
|     }) | 
|     public JsonResult<Map<String, Object>> queryCuserApiByType(@RequestBody OrderModel orderModel) { | 
|         orderModel.setUserType("2"); | 
|         Map<String, Object> map = orderService.queryCuserApiByType(orderModel); | 
|         map.put("orderId", orderModel.getOrderId()); | 
|         return JsonResult.success(map); | 
|     } | 
|   | 
|     /** | 
|      * 取消订单 | 
|      * | 
|      * @param orderModel | 
|      * @return | 
|      */ | 
|     @PostMapping("/admin/front/order/updateOrderReserveTime.json") | 
|     @ApiOperation(value = "订单管理-修改预约时间", notes = "test: 仅0有正确返回") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(paramType = "query", name = "orderId", value = "订单编号", required = true, dataType = "int"), | 
|             @ApiImplicitParam(paramType = "query", name = "userId", value = "用户Id", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "reserveDate", value = "预约时间", required = true, dataType = "String") | 
|     }) | 
|     public JsonResult<Map<String, Object>> updateOrderReserveTime(@RequestBody OrderModel orderModel, HttpServletRequest request) { | 
|         Map<String, Object> map = orderService.updateOrderReserveTime(orderModel); | 
|   | 
|         OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request)) | 
|                 .methodName(Constants.ORDER_MODUL_NAME).operateAction("修改预约时间-" + orderModel.getOrderId()).build(); | 
|         mqUtil.sendApp(build); | 
|         return JsonResult.success(map); | 
|     } | 
|   | 
|     /** | 
|      * 取消订单 | 
|      * | 
|      * @param orderModel | 
|      * @return | 
|      */ | 
|     @PostMapping("/admin/front/order/cancelOrderData.json") | 
|     @ApiOperation(value = "订单管理-确定弹窗", notes = "test: 仅0有正确返回") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(paramType = "query", name = "orderId", value = "订单编号", required = true, dataType = "int"), | 
|             @ApiImplicitParam(paramType = "query", name = "userId", value = "用户Id", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "cancelReasonName", value = "订单取消原因", required = true, dataType = "String") | 
|   | 
|     }) | 
|     public JsonResult<Map<String, Object>> cancelOrderData(@RequestBody OrderModel orderModel, HttpServletRequest request) { | 
|         Map<String, Object> map = orderService.cancelOrderData(orderModel); | 
|   | 
|         OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request)) | 
|                 .methodName(Constants.ORDER_MODUL_NAME).operateAction("取消订单-" + orderModel.getOrderId()).build(); | 
|         mqUtil.sendApp(build); | 
|         return JsonResult.success(map); | 
|     } | 
|   | 
|     /** | 
|      * 重新指派 | 
|      * | 
|      * @param orderModel | 
|      * @return | 
|      */ | 
|     @PostMapping("/admin/front/order/updateApirecByOrderId.json") | 
|     @ApiOperation(value = "订单管理-重新指派", notes = "test: 仅0有正确返回") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(paramType = "query", name = "orderId", value = "订单编号", required = true, dataType = "int"), | 
|             @ApiImplicitParam(paramType = "query", name = "userId", value = "用户Id", required = true, dataType = "int"), | 
|     }) | 
|     public JsonResult<Map<String, Object>> updateApirecByOrderId(@RequestBody OrderModel orderModel, HttpServletRequest request) { | 
|         Map<String, Object> map = orderService.updateApirecByOrderId(orderModel); | 
|         if (Integer.parseInt(map.get("code").toString()) == 0) { | 
|   | 
|             OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request)) | 
|                     .methodName(Constants.ORDER_MODUL_NAME).operateAction("重新指派-" + orderModel.getOrderId()).build(); | 
|             mqUtil.sendApp(build); | 
|   | 
|             return JsonResult.success(map); | 
|   | 
|         } else { | 
|             return JsonResult.failMessage(map.get("msg").toString()); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 入库订单 | 
|      * | 
|      * @param orderModel | 
|      * @return | 
|      */ | 
|     @PostMapping("/admin/front/order/queryStorageApiList.do") | 
|     @ApiOperation(value = "订单管理-(待)入库订单", notes = "test: 仅0有正确返回") | 
|     public JsonResult<Map<String, Object>> queryStorageApiList(@RequestBody OrderModel orderModel) { | 
|         Map<String, Object> map = orderService.queryStorageApiList(orderModel); | 
|         return JsonResult.success(map); | 
|     } | 
|   | 
|     /** | 
|      * 入库订单明细 | 
|      * | 
|      * @param orderModel | 
|      * @return | 
|      */ | 
|     @PostMapping("/admin/front/order/queryStorageDetailApiList.json") | 
|     @ApiOperation(value = "订单管理-入库订单明细", notes = "test: 仅0有正确返回") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(paramType = "query", name = "page", value = "页码", required = true, dataType = "int"), | 
|             @ApiImplicitParam(paramType = "query", name = "limit", value = "每页条数", required = true, dataType = "int"), | 
|             @ApiImplicitParam(paramType = "query", name = "orderType", value = "列表类型(0:订单列表 1:品类重量)", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "storageId", value = "入库单号", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "storageStatus", value = "入库类型(0:已入库,1:入库中)", required = true, dataType = "String") | 
|     }) | 
|     public JsonResult<Map<String, Object>> queryStorageDetailApiList(@RequestBody OrderModel orderModel) { | 
|         Map<String, Object> map = orderService.queryStorageDetailApiList(orderModel); | 
|         return JsonResult.success(map); | 
|     } | 
|   | 
|     @PostMapping("/admin/front/order/queryUserInfoByPhone.json") | 
|     @ApiOperation(value = "订单管理-查询有电话下单的用户", notes = "test: 仅0有正确返回") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(paramType = "query", name = "mobilePhone", value = "手机号", required = true, dataType = "String") | 
|     }) | 
|     public JsonResult<List<OrderModel>> queryUserInfoByPhone(@RequestBody OrderModel orderModel) { | 
|         List<OrderModel> result = new ArrayList<>(); | 
|         List<UserModel> userModelList = userService.queryUserByPhoneNormal(orderModel.getMobilePhone(), "3"); | 
|         if (null != userModelList && userModelList.size() > 0) { | 
|             for (UserModel model : userModelList) { | 
|                 OrderModel orderModel1 = new OrderModel(); | 
|                 orderModel1.setUserId(model.getUserId()); | 
|   | 
|                 if (!org.apache.commons.lang3.StringUtils.isEmpty(model.getNickName())) { | 
|                     orderModel1.setNickName(StringUtils.decode(model.getNickName())); | 
|                     UserAddressModel paramUserAddress = new UserAddressModel(); | 
|                     paramUserAddress.setUserId(model.getUserId()); | 
|                     paramUserAddress.setMobilePhone(model.getMobilePhone()); | 
|                     UserAddressModel addressModels = addressMapper.queryUserAddressInfo(model.getUserId(), model.getMobilePhone()); | 
|                     if (null != addressModels) { | 
|                         orderModel1.setProvinceId(addressModels.getProvinceId()); | 
|                         orderModel1.setCityId(addressModels.getCityId()); | 
|                         orderModel1.setTownshipId(addressModels.getTownshipId()); | 
|                         orderModel1.setProvinceName(addressLevelService.queryAreaName("1", addressModels.getProvinceId())); | 
|                         orderModel1.setCityName(addressLevelService.queryAreaName("2", addressModels.getCityId())); | 
|                         orderModel1.setTownshipName(addressLevelService.queryAreaName("3", addressModels.getTownshipId())); | 
|                         orderModel1.setAddressArea(addressModels.getAddressArea()); | 
|                         orderModel1.setDetailAddress(addressModels.getDetailAddress()); | 
|                         orderModel1.setLongitude(addressModels.getLongitude()); | 
|                         orderModel1.setLatitude(addressModels.getLatitude()); | 
|                         orderModel1.setMobilePhone(model.getMobilePhone()); | 
|                         orderModel1.setUserId(model.getUserId()); | 
|                     } | 
|   | 
|                 } | 
|                 result.add(orderModel1); | 
|             } | 
|   | 
|         } | 
|         return JsonResult.success(result); | 
|     } | 
|   | 
|   | 
|     @PostMapping("/admin/front/order/addOrderByPhone.json") | 
|     @ApiOperation(value = "订单管理-添加订单", notes = "test: 仅0有正确返回") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(paramType = "query", name = "mobilePhone", value = "手机号", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "nickName", value = "用户昵称", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "type", value = "回收方式(0:上门回收 1:送货到店)", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "provinceId", value = "省", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "cityId", value = "市", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "townshipId", value = "区", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "addressArea", value = "区域名称", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "detailAddress", value = "详细地址", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "longitude", value = "经度", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "latitude", value = "纬度", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "reserveDay", value = "预约日期", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "reserveDate", value = "预约时间", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "itemIds", value = "物品类型id(多个用逗号隔开)", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "remark", value = "留言备注", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "storeId", value = "门店Id", required = true, dataType = "String") | 
|     }) | 
|     public JsonResult<String> addOrderByPhone(@RequestBody OrderModel orderModel, HttpServletRequest request) { | 
|         //1:电话下单必须为非注册用户 普通 | 
|         if (!DoubleUtil.isMobile(orderModel.getMobilePhone())) { | 
|             return JsonResult.failMessage("用户手机号不正确!"); | 
|         } | 
|         String isNomal = "0"; | 
|         orderModel.setAddressArea(orderModel.getProvinceId() + orderModel.getCityId() + orderModel.getTownshipId() + orderModel.getDetailAddress()); | 
|         String userType = "1"; | 
|         UserModel userModel = userMapper.queryUserByUsertype(orderModel.getMobilePhone(), userType, "0", null, null); | 
|         if (userModel != null) { | 
|             isNomal = "1"; | 
|         } | 
|         List<OtherUserInfo> userModelOther = otherUserService.findByMobileForBidden(orderModel.getMobilePhone()); | 
|         if (null != userModelOther && userModelOther.size() > 0) { | 
|             return JsonResult.failMessage("该用户存在平台身份,暂不支持下单操作"); | 
|         } | 
|         List<OrderModel> orderModelList = orderMapper.queryOrderByPhone(orderModel.getMobilePhone()); | 
|         if (null != orderModelList && orderModelList.size() > 0) { | 
|             return JsonResult.failMessage("该用户有未完成订单,不能重复下单"); | 
|         } | 
|         //必须传入经纬度 | 
|         if (null != orderModel.getLongitude() && !"".equals(orderModel.getLongitude())) { | 
|             log.debug("经纬度==" + orderModel.getLongitude()); | 
|         } else { | 
|             return JsonResult.failMessage("地图指定异常!"); | 
|         } | 
|         if (null != orderModel.getLatitude() && !"".equals(orderModel.getLatitude())) { | 
|             log.debug("经纬度==" + orderModel.getLatitude()); | 
|         } else { | 
|             return JsonResult.failMessage("地图指定异常!"); | 
|         } | 
|         //下单是否超出范围 | 
|         //String townIds = service.queryConfigByTagCodeOne("ORDER_REGION"); | 
|         String partnerId = null; | 
|         List<String> partnerIds = cityPartnerService.queryPartnerByCurrent(); | 
|         if (null != partnerIds && partnerIds.size() > 0) { | 
|             partnerId = partnerIds.get(0); | 
|         } else { | 
|             return JsonResult.failMessage("只有合伙人才能电话下单!"); | 
|         } | 
|         List<String> keys = partnerFenceMapper.queryElectricTownIds(partnerId); | 
|         //预约时间是否大于当前时间 | 
|         String reTime = orderModel.getReserveDay() + " " + orderModel.getReserveDate() + ":00"; | 
|         log.info("传入的订单预约时间为 ====" + reTime); | 
|         String now = cn.hutool.core.date.DateUtil.now(); | 
|   | 
|         if (com.xzx.gc.util.DateUtil.checkBig(reTime, now) >= 2) { | 
|             return JsonResult.failMessage("预约时间不能小于当前时间!"); | 
|         } | 
|         orderModel.setPartnerId(partnerId); | 
|         userModel = userService.insertUserInfo(orderModel, keys, isNomal); | 
|         if (null != userModel) { | 
|             OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request)) | 
|                     .methodName(Constants.ORDER_MODUL_NAME).operateAction("添加订单-" + userModel.getOrderId()).build(); | 
|             mqUtil.sendApp(build); | 
|   | 
|             return JsonResult.success("下单成功!"); | 
|         } else { | 
|             return JsonResult.failMessage("下单失败,订单超出范围!"); | 
|         } | 
|   | 
|     } | 
|   | 
|     @PostMapping("/admin/front/order/queryAdressArea.json") | 
|     @ApiOperation(value = "订单管理-添加订单", notes = "test: 仅0有正确返回") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(paramType = "query", name = "type", value = "查询类型(0:省份,1:对应的城市,2:城市对应的区)", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "level1Id", value = "省Id", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "level2Id", value = "市Id", required = true, dataType = "String") | 
|     }) | 
|     public JsonResult<List<SysAddressLevelModel>> queryAdressArea(@RequestBody SysAddressLevelModel addressLevelModel) { | 
|         if (null != addressLevelModel.getType() && !"".equals(addressLevelModel.getType())) { | 
|             List<SysAddressLevelModel> list = orderService.queryAdressArea(addressLevelModel); | 
|             return JsonResult.success(list); | 
|         } else { | 
|             return JsonResult.failMessage("请传入查询类型"); | 
|         } | 
|     } | 
|   | 
|     @PostMapping("/admin/front/order/queryUserOrderApiList.do") | 
|     @ApiOperation(value = "用户管理-普通用户的订单列表", notes = "test: 仅0有正确返回") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(paramType = "query", name = "page", value = "页码", required = true, dataType = "int"), | 
|             @ApiImplicitParam(paramType = "query", name = "limit", value = "每页条数", required = true, dataType = "int"), | 
|             @ApiImplicitParam(paramType = "query", name = "userId", value = "用户id", required = true, dataType = "String") | 
|     }) | 
|     public JsonResult<Map<String, Object>> queryUserOrderApiList(@RequestBody UserModel userModel) { | 
|         Map<String, Object> map = orderService.queryUserOrderApiList(userModel); | 
|         return JsonResult.success(map); | 
|     } | 
|   | 
|     @ApiOperation(value = "订单导出", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) | 
|     @PostMapping(value = "/admin/front/order/export") | 
|     public void fileExport(@RequestBody FileExportDTO fileExportDTO, HttpServletRequest request, HttpServletResponse response) { | 
|         List<List<String>> rows = new ArrayList<>(); | 
|         Map<String, Object> object = (Map<String, Object>) fileExportDTO.getObject(); | 
|         //标题 | 
|         List<String> header = CollUtil.newArrayList("订单号", "昵称", "手机号", "下单时间", "接单时间", "完成时间", "订单状态"); | 
|         rows.add(header); | 
|   | 
|         //组装数据 | 
|         OrderModel orderModel = BeanUtil.mapToBean(object, OrderModel.class, true); | 
|         Map<String, Object> result = orderService.queryOrderApiList(orderModel); | 
|         List<OrderModel> list = (List<OrderModel>) result.get("data"); | 
|         if (CollUtil.isNotEmpty(list)) { | 
|             for (OrderModel model : list) { | 
|                 List<String> row = CollUtil.newArrayList(model.getOrderId(), StrUtil.isNotBlank(model.getName()) ? model.getName() : model.getNickName(), model.getMobilePhone(), model.getCreateTime(), | 
|                         model.getReceiveTime(), model.getCompleteTime(), BusinessEnum.getOrderDescByCode(model.getOrderStatus())); | 
|                 rows.add(row); | 
|             } | 
|         } | 
|   | 
|         //导出 | 
|         export(rows, response); | 
|   | 
|         OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request)) | 
|                 .methodName(Constants.ORDER_MODUL_NAME).operateAction("订单导出").build(); | 
|         mqUtil.sendApp(build); | 
|   | 
|     } | 
|   | 
|     @PostMapping("/admin/front/order/queryOrderByHsy.json") | 
|     @ApiOperation(value = "查询回收员所有订单", notes = "test: 仅0有正确返回") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(paramType = "query", name = "userId", value = "用户Id", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "dayTime", value = "日期", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "startTime", value = "开始时间", required = true, dataType = "String"), | 
|             @ApiImplicitParam(paramType = "query", name = "endTime", value = "结束时间", required = true, dataType = "String") | 
|     }) | 
|     public JsonResult<List<Map<String, String>>> queryOrderByHsy(@RequestBody XzxCityPartnerModel model) { | 
|         List<Map<String, String>> list = cityPartnerService.queryOrderByHsy(model); | 
|         return JsonResult.success(list); | 
|     } | 
|   | 
|     @PostMapping("/admin/front/order/receiverStatsitic") | 
|     @ApiOperation(value = "骑手订单统计") | 
|     public JsonResult<List<ReceiverStatsiticResDTO>> receiverStatsitic(@RequestBody ReceiverStatsiticDTO receiverStatsiticDTO) { | 
| //        int type = receiverStatsiticDTO.getType(); | 
| //        if(type==1||type==2||type==3){ | 
| //            receiverStatsiticDTO.setPageSize(0); | 
| //        } | 
| //        PageHelper.startPage(receiverStatsiticDTO.getPageNo(),receiverStatsiticDTO.getPageSize()); | 
|   | 
|         if (StrUtil.isNotBlank(receiverStatsiticDTO.getMonth())) { | 
|             receiverStatsiticDTO.setMonth(StringUtils.addZero(Convert.toInt(receiverStatsiticDTO.getMonth()))); | 
|         } | 
|         return orderService.receiverStatsitic(receiverStatsiticDTO); | 
| //        PageInfo<ReceiverStatsiticResDTO> pageInfo=new PageInfo<>(list); | 
|     } | 
|   | 
|     @ApiOperation(value = "集货订单列表查询") | 
|     @PostMapping("/order/gather/list") | 
|     public Result<PageInfo<UserGatherOrderRes>> ordergatherList(HttpServletRequest request, @RequestBody UserGatherOrderParam userGatherOrderParam) { | 
|   | 
|         if (StrUtil.isNotBlank((userGatherOrderParam.getLatitude()))) { | 
|             userGatherOrderParam.setLatitude(NumberUtil.roundStr(userGatherOrderParam.getLatitude(), 6, RoundingMode.DOWN)); | 
|         } | 
|         if (StrUtil.isNotBlank(userGatherOrderParam.getLongitude())) { | 
|             userGatherOrderParam.setLongitude(NumberUtil.roundStr(userGatherOrderParam.getLongitude(), 6, RoundingMode.DOWN)); | 
|         } | 
|         PageHelper.startPage(userGatherOrderParam.getPageNo(), userGatherOrderParam.getPageSize()); | 
|         List<UserGatherOrderRes> list = orderService.ordergatherList(userGatherOrderParam); | 
|         return Result.success(new PageInfo<>(list)); | 
|     } | 
|   | 
|     @ApiOperation(value = "集货确认收货") | 
|     @PostMapping("/order/gather/sure") | 
|     public Result ordergatherSure(HttpServletRequest request, @RequestBody UserGatherOrderSureParam userGatherOrderSureParam) { | 
|         List<UserGatherOrderSureListParam> list = userGatherOrderSureParam.getList(); | 
|         if (CollUtil.isNotEmpty(list)) { | 
|             String userId = userGatherOrderSureParam.getUserId(); | 
|             UserInfo byId = userService.findById(userId); | 
|             String mobilePhone = byId.getMobilePhone(); | 
|             userGatherOrderSureParam.setUserInfo(byId); | 
|             //确认 | 
|             orderService.ordergatherSure(userGatherOrderSureParam); | 
|             OperationAppLog build = OperationAppLog.builder().appPrograme(getFrontClient(request)).opreateName(mobilePhone) | 
|                     .methodName(Constants.ORDER_MODUL_NAME).operateAction("集货确认收货-" + list.stream().map(x -> x.getOrderId()).collect(Collectors.joining(","))).build(); | 
|             mqUtil.sendApp(build); | 
|         } | 
|         return Result.success(); | 
|     } | 
|   | 
|     @ApiOperation(value = "新版订单详情") | 
|     @PostMapping("/order/new/detail") | 
|     public Result<OrderNewDetailResDTO> orderNewDetail(HttpServletRequest request, @RequestBody OrderNewDetailParamDTO orderNewDetailParamDTO) { | 
|         if (StrUtil.isBlank(orderNewDetailParamDTO.getOrderId())) { | 
|             return Result.error("订单不存在"); | 
|         } | 
|         OrderNewDetailResDTO resDTO = orderService.newDetail(orderNewDetailParamDTO); | 
|         return Result.success(resDTO); | 
|     } | 
|   | 
|   | 
|     @ApiOperation(value = "更换骑手申请") | 
|     @PostMapping("/order/changeReceiver") | 
|     public Result<String> changeReceiver(HttpServletRequest request, @RequestBody OrderChangeReceiverDto orderChangeReceiverDto) { | 
|         OrderDetailInfo orderDetailInfo = new OrderDetailInfo(); | 
|         BeanUtil.copyProperties(orderChangeReceiverDto, orderDetailInfo); | 
|         orderDetailInfo.setChangeReceiverFlag(Convert.toShort(1)); | 
|         orderDetailService.update(orderDetailInfo); | 
|         //推送给骑手 | 
|         jgPushUtil.pushOrder(orderDetailInfo.getOrderId(),orderDetailInfo.getReceiver()); | 
|   | 
|         String mobilePhone = userService.findOtherByUserId(getUserId(request), 0); | 
|         OperationAppLog build = OperationAppLog.builder().appPrograme(getFrontClient(request)).opreateName(mobilePhone) | 
|                 .methodName(Constants.ORDER_MODUL_NAME).operateAction("用户更换骑手申请-" + orderChangeReceiverDto.getOrderId()).build(); | 
|         mqUtil.sendApp(build); | 
|         return Result.success(); | 
|     } | 
|   | 
|   | 
|     @ApiOperation(value = "更换骑手审核") | 
|     @PostMapping("/order/changeReceiverAudit") | 
|     public Result<String> changeReceiverAudit(HttpServletRequest request, @RequestBody OrderChangeReceiverAuditDto orderChangeReceiverAuditDto) { | 
|         orderService.changeReceiverAudit(orderChangeReceiverAuditDto); | 
|   | 
|         String mobilePhone = userService.findOtherByUserId(getUserId(request), 0); | 
|         OperationAppLog build = OperationAppLog.builder().appPrograme(getFrontClient(request)).opreateName(mobilePhone) | 
|                 .methodName(Constants.ORDER_MODUL_NAME).operateAction("更换骑手审核-" + orderChangeReceiverAuditDto.getOrderId()).build(); | 
|         mqUtil.sendApp(build); | 
|         return Result.success(); | 
|     } | 
|   | 
|   | 
|   | 
| } |