package com.iamberry.wechat.handles.admin;

import java.io.IOException;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.iamberry.wechat.core.entity.ProbationOrderUtil;
import com.iamberry.wechat.core.entity.admin.ShopSystemRule;
import com.iamberry.wechat.core.entity.order.MessageDto;
import com.iamberry.wechat.core.entity.order.OrderActionDto;
import com.iamberry.wechat.core.entity.order.ProbationOrder;
import com.iamberry.wechat.face.order.AdminOrderService;
import com.iamberry.wechat.face.order.AdminProbationOrderService;
import com.iamberry.wechat.tools.DateTimeUtil;
import com.iamberry.wechat.tools.ResultInfo;
import com.iamberry.wechat.sendMsg.SendMessageUtil;

@Controller
@RequestMapping("/admin/probationOrder")
public class AdminProbationOrderHandler {

	@Autowired
	private AdminProbationOrderService adminProbationOrderService;
	
	@Autowired
	private AdminOrderService adminOrderService;
	
	@Autowired
	private ProbationOrderUtil probationOrderUtil;
	
	@Autowired
	private SendMessageUtil sendMessageUtil;
	
	/**
	 * 后台进入订单列表功能
	 * @param request
	 * @param pageSize
	 * @param pageNO
	 * @return ModelAndView
	 * @throws Exception
	 */
	@RequestMapping("/selectProbationList")
	public ModelAndView selectProbationList(HttpServletRequest request,
			@RequestParam(value= "pageSize",defaultValue= "20" ,required=false) Integer pageSize, 
			@RequestParam(value = "pageNO", defaultValue = "1",required=false) Integer pageNO) throws Exception {
		ModelAndView mv = new ModelAndView("admin/order/probationOrderList");
		ProbationOrder probationOrder = new ProbationOrder();
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		String orderStatus = request.getParameter("orderStatus");
		
		String text = request.getParameter("text");
		String beginDate = request.getParameter("beginDate");
		String endDate = request.getParameter("endDate");
		
		StringBuilder url = new StringBuilder("/admin/probationOrder/selectProbationList?orderStatus=" + orderStatus);
		
		if (text != null && !"".equals(text)) {
			probationOrder.setProbationOrderid(text);
			url.append("&text=" + text);
			mv.addObject("selectInput", text);
		}
		if (beginDate != null && !"".equals(beginDate)) {
			probationOrder.setBeginDate(format.parse(beginDate));
			url.append("&beginDate=" + beginDate);
			mv.addObject("beginDate", beginDate);
		}
		if (endDate != null && !"".equals(endDate)) {
			probationOrder.setEndDate(format.parse(endDate));
			url.append("&endDate=" + endDate);
			mv.addObject("endDate", endDate);
		}
		
		if (orderStatus == null || "".equals(orderStatus)) {
			orderStatus = "staySendOrder";
		}
		// 订单状态，数字标识
		int status = -1;
		if (!orderStatus.equals("allOrder")) {
			status = probationOrderUtil.getOrderStatusByStr(orderStatus);
		}
		probationOrder.setProbationStatus(status);
		probationOrder.getPage().setPageSize(pageSize);
		probationOrder.getPage().setPageNumber(pageNO);
		probationOrder.getPage().initRecordBegin();
		List<ProbationOrder> orderList = adminProbationOrderService.selectProbationList(probationOrder);
		// 订单是否按照状态查询的, 用于页面
		if (status == -1) {
			mv.addObject("orderListIsStatus", false);
			for (ProbationOrder probationOrders : orderList) {
				// 用户昵称编码
				if (probationOrders.getUserNickName() != null && !probationOrders.getUserNickName().isEmpty()) {
					probationOrders.setUserNickName(URLDecoder.decode(probationOrders.getUserNickName(), "UTF-8"));
				}
				// 获取用户的操作权限
				probationOrders.setOperations(probationOrderUtil.orderOperationByStatus(
						probationOrders.getProbationStatus(), probationOrders.getProbationOrderid()));
				probationOrders.setOrderLinkStatus(probationOrderUtil.orderStatusToString(probationOrders.getProbationStatus()));
			}
		} else {
			mv.addObject("orderListIsStatus", true);
			for (ProbationOrder probationOrders : orderList) {
				// 用户昵称编码
				if (probationOrders.getUserNickName() != null && !probationOrders.getUserNickName().isEmpty()) {
					probationOrders.setUserNickName(URLDecoder.decode(probationOrders.getUserNickName(), "UTF-8"));
				}
				// 获取用户的操作权限
				probationOrders.setOperations(probationOrderUtil.orderOperationByStatus(
						probationOrders.getProbationStatus(), probationOrders.getProbationOrderid()));
			}
		}
		url.append("&pageSize=" + pageSize + "&pageNO=");
		mv.addObject("orderList", orderList);
		mv.addObject("pageNO", pageNO);
		mv.addObject("orderStatus", status);// 订单状态
		mv.addObject("url", url.toString());
		mv.addObject("pageSize", adminProbationOrderService.selectProbationCount(probationOrder));
		mv.addObject("orderStatusStr", probationOrderUtil.orderStatusIntToOrderStatusString(status));// 订单状态描述（用于选中订单头）
		mv.addObject("orderLinkStatus", probationOrderUtil.orderStatusToString(status));// 订单状态描述，中文（显示给用户看）
		mv.addObject("statusUrl", "/admin/probationOrder/selectProbationList?bid=&sid=");
		return mv;
	}
	
	/**
	 * 订单详细信息
	 * @param request
	 * @param orderId
	 * @return ModelAndView
	 * @throws Exception
	 */
	@RequestMapping("/getProbationOrderByOrderId/{probationOrderId}")
	public ModelAndView getProbationOrderByOrderId(HttpServletRequest request,
			@PathVariable("probationOrderId") String probationOrderId) throws Exception{
		ModelAndView mv = new ModelAndView("admin/order/probationOrderInfo");
		if (null != probationOrderId && !"".equals(probationOrderId)) {
			ProbationOrder probationOrder = new ProbationOrder();
			probationOrder.setProbationOrderid(probationOrderId);
			ProbationOrder pOrder = adminProbationOrderService.getProbationOrderByOrderId(probationOrder);
				// 用户昵称编码
				if (pOrder.getUserNickName() != null && !pOrder.getUserNickName().isEmpty()) {
					pOrder.setUserNickName(URLDecoder.decode(pOrder.getUserNickName(), "UTF-8"));
				}
				// 获取用户的操作权限
				pOrder.setOperations(probationOrderUtil.orderOperationByStatus(
						pOrder.getProbationStatus(), pOrder.getProbationOrderid()));
				pOrder.setOrderLinkStatus(probationOrderUtil.orderStatusToString(pOrder.getProbationStatus()));
			mv.addObject("pOrder",pOrder);
		}
		return mv;
	}
	
	/**
	 * 操作订单
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("/{action}/{probationOrderid}")
	public synchronized ModelAndView actionOrder(
			@PathVariable("action") String action,
			@PathVariable("probationOrderid") String probationOrderid,
			OrderActionDto actionDto
			) throws Exception {
		ModelAndView mv = new ModelAndView("admin/msg/msg");
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		ProbationOrder probationOrder = new ProbationOrder();
		probationOrder.setProbationOrderid(probationOrderid);
		// 判断当前的订单，是否支持希望进行的操作
		ProbationOrder currentProbationOrder = adminProbationOrderService.getProbationOrderByOrderId(probationOrder);
		Integer orderStatus = currentProbationOrder.getProbationStatus();
		probationOrder.setProbationOldStatus(orderStatus);
		if (!probationOrderUtil.orderStatusIntToOrderStatusString(orderStatus).equals(actionDto.getOrderStatus())) {
			mv.addObject("msgObj", new MessageDto(false, "对不起，操作有误", "对不起，您刚才的操作流程有误，请按照系统流程操作！"));
			return mv;
		}
		switch (orderStatus) {
			case 0: // 取消的订单，不支持任何修改订单状态的操作
				
				mv.addObject("msgObj", new MessageDto(false, "对不起，操作有误", "对不起，您刚才的操作流程有误，取消的订单不能操作!"));
				return mv;
			case 1: // 待派送（管理员存在操作权限：取消订单，如果取消订单，订单状态修改为0，派送中：将物品派送出去）
				
				if (probationOrderUtil.getOrderActin()[0].equals(action)) {// 判断当前请求操作是否相符, 否则提示不成功
					if (!probationOrderUtil.orderStatusIntToOrderStatusString(0).equals(actionDto.getToOrderStatus())) {// 判断请求修改的订单状态是否相符，否则提示不成功
						mv.addObject("msgObj", new MessageDto(false, "对不起，操作有误", "对不起，您刚才的操作流程有误，请按照系统流程操作！"));
						return mv;
					}
					probationOrder.setProbationStatus(probationOrderUtil.getOrderStatusByStr(actionDto.getToOrderStatus()));
					// 执行修改操作
					if (adminProbationOrderService.updateProbationOrderStatus(probationOrder)) {
						mv.addObject("msgObj", new MessageDto(true, "取消订单成功", "恭喜您！订单：" + probationOrderid + "取消成功，本订单将不能操作!"));
						//推送关闭信息
						try {
							sendMessageUtil.probationShutDown(ResultInfo.PROBATION_FIRST, probationOrderid,"0元","未支付", ResultInfo.PROBATION_REMARK, currentProbationOrder.getProbationOpenid(), ResultInfo.TRY_ORDER_DETAIL+"?orderId="+probationOrderid);
						} catch (Exception e) {
							System.out.println("试用订单关闭，消息提示失败！");
						}
						return mv;
					} else {
						mv.addObject("msgObj", new MessageDto(false, "对不起，取消订单失败", "对不起，取消订单失败，请稍后重试！"));
						return mv;
					}
				} else if (probationOrderUtil.getOrderActin()[2].equals(action)) {// 判断当前请求操作是否相符, 否则提示不成功
					if (!probationOrderUtil.orderStatusIntToOrderStatusString(2).equals(actionDto.getToOrderStatus())) {// 判断请求修改的订单状态是否相符，否则提示不成功
						mv.addObject("msgObj", new MessageDto(false, "对不起，操作有误", "对不起，您刚才的操作流程有误，请按照系统流程操作！"));
						return mv;
					}
					probationOrder.setProbationStatus(probationOrderUtil.getOrderStatusByStr(actionDto.getToOrderStatus()));
					// 执行修改操作
					if (adminProbationOrderService.updateProbationOrderStatus(probationOrder)) {
						//1
						mv.addObject("msgObj", new MessageDto(true, "订单已确认派送", "恭喜您！订单：" + probationOrderid + "已确认派送，状态为派送中!"));
						return mv;
					} else {
						mv.addObject("msgObj", new MessageDto(false, "对不起，派送订单失败", "对不起，派送订单失败，请稍后重试！"));
						return mv;
					}
				}
				
			case 2: // 派送中（管理员的操作为：关闭订单，试用开始待支付）
				
				if (probationOrderUtil.getOrderActin()[0].equals(action)) {// 判断当前请求操作是否相符, 否则提示不成功
					if (!probationOrderUtil.orderStatusIntToOrderStatusString(0).equals(actionDto.getToOrderStatus())) {// 判断请求修改的订单状态是否相符，否则提示不成功
						mv.addObject("msgObj", new MessageDto(false, "对不起，操作有误", "对不起，您刚才的操作流程有误，请按照系统流程操作！"));
						return mv;
					}
					probationOrder.setProbationStatus(probationOrderUtil.getOrderStatusByStr(actionDto.getToOrderStatus()));
					// 执行修改操作
					if (adminProbationOrderService.updateProbationOrderStatus(probationOrder)) {
						mv.addObject("msgObj", new MessageDto(true, "取消订单成功", "恭喜您！订单：" + probationOrderid + "取消成功，本订单将不能操作!"));
						//推送关闭信息
						try {
							sendMessageUtil.probationShutDown(ResultInfo.PROBATION_FIRST, probationOrderid,"0元","未支付", ResultInfo.PROBATION_REMARK, currentProbationOrder.getProbationOpenid(), ResultInfo.TRY_ORDER_DETAIL+"?orderId="+probationOrderid);
						} catch (Exception e) {
							System.out.println("试用订单关闭，消息提示失败！");
						}
						return mv;
					} else {
						mv.addObject("msgObj", new MessageDto(false, "对不起，取消订单失败", "对不起，取消订单失败，请稍后重试！"));
						return mv;
					}
				} else if (probationOrderUtil.getOrderActin()[4].equals(action)) {// 判断当前请求操作是否相符, 否则提示不成功
					if (!probationOrderUtil.orderStatusIntToOrderStatusString(3).equals(actionDto.getToOrderStatus())) {// 判断请求修改的订单状态是否相符，否则提示不成功
						mv.addObject("msgObj", new MessageDto(false, "对不起，操作有误", "对不起，您刚才的操作流程有误，请按照系统流程操作！"));
						return mv;
					}
					probationOrder.setProbationStatus(probationOrderUtil.getOrderStatusByStr(actionDto.getToOrderStatus()));
					// 执行修改操作
					ShopSystemRule shopSystemRule = adminOrderService.getReluByRid(221);
					Calendar calendar = Calendar.getInstance();
					calendar.setTime(new Date());
					calendar.add(calendar.DATE,shopSystemRule.getRuleNum().intValue());//把日期往后增加一天.整数往后推,负数往前移动
					Date pauseEndDate = calendar.getTime();
					probationOrder.setProbationEndTime(pauseEndDate);
					String message = ResultInfo.PROBATION_FIRST_MSG;
					String msg = ResultInfo.PROBATION_END_MSG;
					String startTime = DateTimeUtil.format(new Date());
					if(currentProbationOrder.getProbationStartTime() != null){
						startTime = DateTimeUtil.format(currentProbationOrder.getProbationStartTime());
					}
					if (adminProbationOrderService.updateSendDate(probationOrder)) {
						try {
							//推送消息
							sendMessageUtil.probationApplyNotice(
									message, 
									currentProbationOrder.getProbationProductName(),
									startTime, 
									msg,
									currentProbationOrder.getProbationOpenid(),
									ResultInfo.TRY_ORDER_DETAIL + "?orderId=" + currentProbationOrder.getProbationOrderid());
							
						} catch (Exception e) {
							System.out.println("开始试用推送消息发送失败！");
						}
						
						mv.addObject("msgObj", new MessageDto(true, "订单派送成功", "恭喜您！订单：" + probationOrderid + "订单派送成功，请确认订单是否收到!"));
						return mv;
					} else {
						mv.addObject("msgObj", new MessageDto(false, "对不起，派送订单失败", "对不起，派送订单失败，请稍后重试！"));
						return mv;
					}
				}
			case 3: // 待支付（管理员可以操作：关闭订单，暂停计时）
				
				if (probationOrderUtil.getOrderActin()[0].equals(action)) {// 判断当前请求操作是否相符, 否则提示不成功
					if (!probationOrderUtil.orderStatusIntToOrderStatusString(0).equals(actionDto.getToOrderStatus())) {// 判断请求修改的订单状态是否相符，否则提示不成功
						mv.addObject("msgObj", new MessageDto(false, "对不起，操作有误", "对不起，您刚才的操作流程有误，请按照系统流程操作！"));
						return mv;
					}
					probationOrder.setProbationStatus(probationOrderUtil.getOrderStatusByStr(actionDto.getToOrderStatus()));
					// 执行修改操作
					if (adminProbationOrderService.updateProbationOrderStatus(probationOrder)) {
						mv.addObject("msgObj", new MessageDto(true, "取消订单成功", "恭喜您！订单：" + probationOrderid + "取消成功，本订单将不能操作!"));
						//推送关闭信息
						try {
							sendMessageUtil.probationShutDown(ResultInfo.PROBATION_FIRST, probationOrderid,"0元","未支付", ResultInfo.PROBATION_REMARK, currentProbationOrder.getProbationOpenid(), ResultInfo.TRY_ORDER_DETAIL+"?orderId="+probationOrderid);
						} catch (Exception e) {
							System.out.println("试用订单关闭，消息提示失败！");
						}
						return mv;
					} else {
						mv.addObject("msgObj", new MessageDto(false, "对不起，取消订单失败", "对不起，取消订单失败，请稍后重试！"));
						return mv;
					}
				} else if (probationOrderUtil.getOrderActin()[5].equals(action)) {// 判断当前请求操作是否相符, 否则提示不成功
					if (!probationOrderUtil.orderStatusIntToOrderStatusString(4).equals(actionDto.getToOrderStatus())) {// 判断请求修改的订单状态是否相符，否则提示不成功
						mv.addObject("msgObj", new MessageDto(false, "对不起，操作有误", "对不起，您刚才的操作流程有误，请按照系统流程操作！"));
						return mv;
					}
					probationOrder.setProbationStatus(probationOrderUtil.getOrderStatusByStr(actionDto.getToOrderStatus()));
					// 执行修改操作
					if (adminProbationOrderService.updatePauseStartTime(probationOrder)) {
						mv.addObject("msgObj", new MessageDto(true, "订单暂停成功", "恭喜您！订单：" + probationOrderid + "订单暂停成功，请确认订单试用倒计时是否显示!"));
						return mv;
					} else {
						mv.addObject("msgObj", new MessageDto(false, "对不起，订单暂停失败", "对不起，订单暂停失败，请稍后重试！"));
						return mv;
					}
				}
				
			case 4: // 试用暂停（管理员可以操作：可以取消暂停，订单到待支付状态）
				
				if (!probationOrderUtil.getOrderActin()[4].equals(action)) {// 判断当前请求操作是否相符, 否则提示不成功
					mv.addObject("msgObj", new MessageDto(false, "对不起，操作有误", "对不起，您刚才的操作流程有误，请按照系统流程操作！"));
					return mv;
				}
				if (!probationOrderUtil.orderStatusIntToOrderStatusString(3).equals(actionDto.getToOrderStatus())) {// 判断请求修改的订单状态是否相符，否则提示不成功
					mv.addObject("msgObj", new MessageDto(false, "对不起，操作有误", "对不起，您刚才的操作流程有误，请按照系统流程操作！"));
					return mv;
				}
				probationOrder.setProbationStatus(probationOrderUtil.getOrderStatusByStr(actionDto.getToOrderStatus()));
				// 执行修改操作
				//计算开始时间与结束时间的时间差，毫秒为单位
				String timeLength =  DateTimeUtil.getDistanceTime2(currentProbationOrder.getProbationPauseStartTime(),new Date());
				if (timeLength != null && !"".equals(timeLength)) {
					probationOrder.setProbationPauseTotalLength(Long.parseLong(timeLength));
				}
				Date endTime = dateDiff(currentProbationOrder.getProbationPauseStartTime(),new Date(),currentProbationOrder.getProbationEndTime());
				probationOrder.setProbationEndTime(endTime);
				if (adminProbationOrderService.updatePauseEndTime(probationOrder)) {
					mv.addObject("msgObj", new MessageDto(true, "订单派送成功", "恭喜您！订单：" + probationOrderid + "订单派送成功，请确认订单是否收到!"));
					return mv;
				} else {
					mv.addObject("msgObj", new MessageDto(false, "对不起，派送订单失败", "对不起，派送订单失败，请稍后重试！"));
					return mv;
				}
			case 5: // 支付完成（管理员不具有权限）
				
				mv.addObject("msgObj", new MessageDto(false, "对不起，操作有误", "对不起，您刚才的操作流程有误，已发货的订单不能操作!"));
				return mv;
			default: // 报错
				
				mv.addObject("msgObj", new MessageDto(false, "对不起，操作有误", "对不起，您刚才的操作流程有误!"));
				return mv;
		}
	}
	
	/**
	 * 将时间顺延方法
	 * @param startTime	开始时间
	 * @param endTime 	结束时间
	 * @param format		时间类型
	 * @param date			要顺延的开始时间
	 * @throws Exception 
	 */
	public Date dateDiff(Date startDate, Date endDate, Date date) throws Exception{
		//按照传入的格式生成一个simpledateformate对象
//		String startTime = "2016-11-01 12:12:12";
//		String endTime = "2016-11-17 13:13:13";
//		Date date = new Date();
		SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String startTime = sd.format(startDate);
		String endTime = sd.format(endDate);
		int nd = 1000*24*60*60;//一天的毫秒数
		int nh = 1000*60*60;//一小时的毫秒数
		int nm = 1000*60;//一分钟的毫秒数
		int ns = 1000;//一秒钟的毫秒数long diff;try {
		//获得两个时间的毫秒时间差异
		int diff = (int)(sd.parse(endTime).getTime() - sd.parse(startTime).getTime());
		int day = diff/nd;//计算差多少天
		int hour = diff%nd/nh;//计算差多少小时
		int min = diff%nd%nh/nm;//计算差多少分钟
		int sec = diff%nd%nh%nm/ns;//计算差多少秒//输出结果
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.add(Calendar.DATE , day);						//延迟天
		calendar.add(Calendar.HOUR_OF_DAY, hour);		//延迟小时
		calendar.add(Calendar.MINUTE, min);					//延迟分
		calendar.add(Calendar.SECOND , sec);					//延迟秒
		return calendar.getTime();
	}
	
	/**
	 * 订单备注
	 * @param actionDTO
	 * @throws IOException 
	 */
	@RequestMapping(value="/remark/{id}",produces = {"application/json;charset=UTF-8"})
	@ResponseBody
	public String orderRemark(OrderActionDto actionDto, @PathVariable("id") String probationOrderid, HttpServletResponse response) throws IOException {
		// 订单备注
		if (actionDto.getRemarkColor() == null) {
			actionDto.setRemarkColor(1);
		}
		if (actionDto.getRemark() == null || actionDto.getRemark().isEmpty()) {
			return "{\"status\":\"false\",\"info\":\"备注信息不能为空!\"}";
		}
		if (actionDto.getRemark().length() > 100) {
			return "{\"status\":\"false\",\"info\":\"备注信息不能超过100个字符!\"}";
		}
		ProbationOrder probationOrder = new ProbationOrder();
		probationOrder.setProbationOrderid(probationOrderid);
		probationOrder.setProbationAdminRemark(actionDto.getRemark());
		probationOrder.setProbationColorType(actionDto.getRemarkColor());
		// update到数据库
		if (adminProbationOrderService.updateAdminRemark(probationOrder)) {
			return "{\"status\":true,\"info\":\"备注成功!\"}";
		} else {
			return "{\"status\":\"false\",\"info\":\"备注失败，请稍后重试!\"}";
		}
	}
	
	/**
	 * 录入派送员信息
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping(value="/addCourierInfo/{id}",produces = {"application/json;charset=UTF-8"})
	public String addCourierInfo(OrderActionDto actionDto, @PathVariable("id") String probationOrderid, HttpServletResponse response) throws Exception {
		if (actionDto.getProbationSendName() == null || actionDto.getProbationSendName().isEmpty()) {
			return "{\"status\":\"false\",\"info\":\"派送员姓名不能为空!\"}";
		}
		if (actionDto.getProbationSendTel() == null || actionDto.getProbationSendTel().isEmpty()) {
			return "{\"status\":\"false\",\"info\":\"派送员电话号码不能为空!\"}";
		}
		ProbationOrder probationOrder = new ProbationOrder();
		probationOrder.setProbationOrderid(probationOrderid);
		probationOrder.setProbationSendName(actionDto.getProbationSendName());
		probationOrder.setProbationSendTel(actionDto.getProbationSendTel());
		probationOrder.setProbationPostFirm("02");
		probationOrder.setProbationPostNum("00000000");
		if (adminProbationOrderService.updateSendName(probationOrder)) {
			return "{\"status\":\"true\",\"info\":\"添加派送员信息成功!\"}";
		} else {
			return "{\"status\":\"false\",\"info\":\"添加派送员信息失败，请稍后重试!\"}";
		}
	}
	
	/**
	 * 延时
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping(value="/delayOrder/{id}",produces = {"application/json;charset=UTF-8"})
	public String delayOrder(OrderActionDto actionDto, @PathVariable("id") String probationOrderid, HttpServletResponse response) throws Exception {
		if (actionDto.getProbationEndTime() == null) {
			return "{\"status\":\"false\",\"info\":\"延时时间不能为空!\"}";
		}
		ProbationOrder probationOrder = new ProbationOrder();
		probationOrder.setProbationOrderid(probationOrderid);
		probationOrder.setProbationEndTime(actionDto.getProbationEndTime());
		if (adminProbationOrderService.updateProbationEndTime(probationOrder)) {
			return "{\"status\":true,\"info\":\"延时成功!\"}";
		} else {
			return "{\"status\":\"false\",\"info\":\"延时失败，请稍后重试!\"}";
		}
	}
}
