| | |
| | | case 106: |
| | | order.setGetoffTime(new Date()); |
| | | if(ToolUtil.isEmpty(order.getEndAddress())){ |
| | | |
| | | String endAddress = processOperationsWarpper.getEndAddress(); |
| | | endAddress = endAddress.replaceAll("& #40;", "("); |
| | | endAddress = endAddress.replaceAll("& #41;", ")"); |
| | | processOperationsWarpper.setEndAddress(endAddress); |
| | | |
| | | order.setEndAddress(processOperationsWarpper.getEndAddress()); |
| | | order.setEndLng(processOperationsWarpper.getEndLng()); |
| | | order.setEndLat(processOperationsWarpper.getEndLat()); |
| | |
| | | @Override |
| | | public ResultUtil setOrderEndAddress(Integer uid, OrderEndAddressWarpper orderEndAddressWarpper) throws Exception { |
| | | Order order = this.selectById(orderEndAddressWarpper.getOrderId()); |
| | | |
| | | String endAddress = orderEndAddressWarpper.getEndAddress(); |
| | | endAddress = endAddress.replaceAll("& #40;", "("); |
| | | endAddress = endAddress.replaceAll("& #41;", ")"); |
| | | orderEndAddressWarpper.setEndAddress(endAddress); |
| | | |
| | | order.setEndLat(orderEndAddressWarpper.getEndLat()); |
| | | order.setEndLng(orderEndAddressWarpper.getEndLng()); |
| | | order.setEndAddress(orderEndAddressWarpper.getEndAddress()); |
| | |
| | | */ |
| | | @Override |
| | | public ResultUtil setOrderStatus(Integer uid, Long orderId, Integer payType, Integer state) throws Exception { |
| | | if(108 == state){ |
| | | String value = redisUtil.getValue("repeat_" + orderId); |
| | | if(ToolUtil.isEmpty(value)){ |
| | | redisUtil.setStrValue("repeat_" + orderId, System.currentTimeMillis() + "", 600);//10分钟 |
| | | try { |
| | | boolean lock = redisUtil.lock(orderId + "",5); |
| | | if(!lock){ |
| | | int num1 = 1; |
| | | while (num1 <= 10){ |
| | | Thread.sleep(3000);//等待3秒 |
| | | lock = redisUtil.lock(orderId + "",5); |
| | | if(lock){ |
| | | break; |
| | | }else{ |
| | | Long s = System.currentTimeMillis() - Long.valueOf(value); |
| | | if(s.compareTo(60000L) < 0){//1分钟 |
| | | return ResultUtil.error("数据处理中"); |
| | | num1++; |
| | | } |
| | | redisUtil.setStrValue("repeat_" + orderId, System.currentTimeMillis() + "", 600);//10分钟 |
| | | } |
| | | } |
| | | if(!lock){ |
| | | redisUtil.unlock(orderId + ""); |
| | | return ResultUtil.error("请稍后重试"); |
| | | } |
| | | |
| | | List<Integer> s = Arrays.asList(107, 108); |
| | | if(!s.contains(state)){ |
| | | return ResultUtil.error("操作失败,请刷新订单"); |
| | | } |
| | | Order order = this.selectById(orderId); |
| | | if(order.getState().compareTo(state) == 0){ |
| | | return ResultUtil.error("不能重复操作"); |
| | | if(state == 107 && order.getState() != 106){ |
| | | redisUtil.unlock(orderId + ""); |
| | | return ResultUtil.error("操作失败,请刷新数据"); |
| | | } |
| | | if(state == 108 && order.getState() != 107){ |
| | | redisUtil.unlock(orderId + ""); |
| | | return ResultUtil.error("操作失败,请刷新数据"); |
| | | } |
| | | |
| | | order.setState(state); |
| | | |
| | | if(payType == 2 && state == 107){ |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | this.updateById(order); |
| | | |
| | |
| | | } |
| | | }, 60000); |
| | | } |
| | | redisUtil.unlock(orderId + ""); |
| | | return ResultUtil.success(); |
| | | }catch (Exception e){ |
| | | redisUtil.unlock(orderId + ""); |
| | | e.printStackTrace(); |
| | | return ResultUtil.error("系统异常"); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | List<Order> orders = this.selectList(new EntityWrapper<Order>().eq("state", 107).eq("status", 1) |
| | | .eq("payType", 3).last(" and UNIX_TIMESTAMP(getoffTime) + 600 <= UNIX_TIMESTAMP(now())")); |
| | | for (Order order : orders) { |
| | | Long orderId = order.getId(); |
| | | try { |
| | | boolean lock = redisUtil.lock(orderId + "",5); |
| | | if(!lock){ |
| | | int num1 = 1; |
| | | while (num1 <= 10){ |
| | | Thread.sleep(3000);//等待3秒 |
| | | lock = redisUtil.lock(orderId + "",5); |
| | | if(lock){ |
| | | break; |
| | | }else{ |
| | | num1++; |
| | | } |
| | | } |
| | | } |
| | | if(!lock){ |
| | | redisUtil.unlock(orderId + ""); |
| | | continue; |
| | | } |
| | | completeCollection_(order); |
| | | }catch (Exception e){ |
| | | redisUtil.unlock(orderId + ""); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | |
| | | public void completeCollection_(Order order) { |
| | | public void completeCollection_(Order order) throws Exception{ |
| | | order.setState(108); |
| | | order.setPayTime(new Date()); |
| | | if(null != order.getCouponId()){ |
| | |
| | | } |
| | | |
| | | this.updateById(order); |
| | | |
| | | try { |
| | | saveRevenue(order); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |