package com.zm.order.tool.server.controller;

import com.zm.order.tool.server.manager.RedisManager;
import com.zm.order.tool.server.model.DataCorrectionRequest;
import com.zm.order.tool.server.model.Order;
import com.zm.order.tool.server.model.OrderPayDetails;
import com.zm.order.tool.server.model.OrderPush;
import com.zm.order.tool.server.request.EsAmountLevelDownRequest;
import com.zm.order.tool.server.request.ListOrderRequest;
import com.zm.order.tool.server.request.OrderDataReviseRequest;
import com.zm.order.tool.server.service.*;
import com.zm.util.dto.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * 订单脚本
 * @author NianChang
 * @ClassName ScriptController
 * @date 2021/02/20 9:48 上午
 */
@Api(value = "迁移脚本", tags = "迁移脚本")
@RestController
@SuppressWarnings("all")
@RequestMapping("/qapi/order/script")
public class OrderScriptController {

    private static final Logger logger = LoggerFactory.getLogger(OrderScriptController.class);

    @Autowired
    private RedisManager redisManager;

    @Autowired
    private OrderScriptService scriptService;

    @Autowired
    private CyService cyService;

    @Autowired
    private DataService dataService;

    @ApiOperation("数据迁移-勿动")
    @RequestMapping(value = "/transfer/data", method = RequestMethod.POST)
    public Result transferOrderData(@RequestBody OrderDataReviseRequest request) {
        logger.info("transferOrderData start!");
        Result result = new Result<>();
        try {
            result = scriptService.transferOrderData(request);
        } catch (Exception e) {
            logger.error("OrderScriptController[transferOrderData]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("订单数据同步")
    @RequestMapping(value = "/sync/order/data", method = RequestMethod.POST)
    public Result syncOrderData(@RequestBody OrderDataReviseRequest request) {
        Result result = new Result<>();
        try {
            result = scriptService.syncOrderData(request);
        } catch (Exception e) {
            logger.error("TemporaryController[syncOrderData]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("批量数据同步ES")
    @RequestMapping(value = "/sync/order/data/list", method = RequestMethod.POST)
    public Result syncOrderDataList(@RequestBody OrderDataReviseRequest request) {
        Result result = new Result<>();
        try {
            result = scriptService.syncOrderDataList(request);
        } catch (Exception e) {
            logger.error("TemporaryController[syncOrderDataList]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("设置redis_key")
    @RequestMapping(value = "/set/redis/key", method = RequestMethod.POST)
    public Result setRedisKey(@RequestBody EsAmountLevelDownRequest request) {
        Result result = new Result();
        try {
            if (Objects.equals(request.getType(), 0)) {
                redisManager.set(request.getKey(), "0");
            } else if (Objects.equals(request.getType(), 1)) {
                redisManager.set(request.getKey(), "1");
            } else if (Objects.equals(request.getType(), 2)) {
                redisManager.delete(request.getKey());
            } else {
                result.setMessage("type错误");
                return result;
            }
            result.setStatus(true);
        } catch (Throwable e) {
            logger.error("set cache failed, key:{}, cause by:{}", e);
        }
        return result;
    }

    @ApiOperation("订单消息补推")
    @RequestMapping(value = "/message/push", method = RequestMethod.POST)
    public Result messagePush(@RequestBody OrderPush orderPush) {
        Result result = new Result();
        try {
            result = scriptService.orderMessagePush(orderPush);
        } catch (Throwable e) {
            logger.error("TemporaryController[messagePush]failed,request:{},cause by: {}", orderPush, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("退款单消息补推")
    @RequestMapping(value = "/message/push/refund", method = RequestMethod.POST)
    public Result messagePushRefund(@RequestBody OrderPush orderPush) {
        Result result = new Result();
        try {
            result = scriptService.messagePushRefund(orderPush);
        } catch (Throwable e) {
            logger.error("TemporaryController[messagePushRefund]failed,request:{},cause by: {}", orderPush, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("批量订单消息补推")
    @RequestMapping(value = "/message/push/list", method = RequestMethod.POST)
    public Result messagePushList(@RequestBody OrderPush orderPush) {
        Result result = new Result();
        try {
            result = scriptService.orderMessagePushList(orderPush);
        } catch (Throwable e) {
            logger.error("TemporaryController[messagePushList]failed,request:{},cause by: {}", orderPush, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("订单数据订正")
    @RequestMapping(value = "/data/Correction", method = RequestMethod.POST)
    public Result dataCorrection(@RequestBody DataCorrectionRequest request) {
        Result result = new Result();
        try {
            result = scriptService.orderDataCorrection(request);
        } catch (Throwable e) {
            logger.error("TemporaryController[dataCorrection]failed,request:{},cause by:{}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("指定商家同步ES")
    @RequestMapping(value = "/sync/es", method = RequestMethod.POST)
    public Result syncES(@RequestBody DataCorrectionRequest request) {
        logger.info("syncES start!");
        Result result = new Result();
        try {
            result = scriptService.syncEs();
        } catch (Throwable e) {
            logger.error("TemporaryController[syncES]failed,request:{},cause by:{}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("订单取消消息补推")
    @RequestMapping(value = "/message/cancel/push", method = RequestMethod.POST)
    public Result messageCancelPush(@RequestBody OrderPush orderPush) {
        logger.info("[messageCancelPush]before!");
        Result result = new Result();
        try {
            result = scriptService.orderMessageCanCelPush();
        } catch (Throwable e) {
            logger.error("TemporaryController[messageCancelPush]failed,request:{},cause by: {}", orderPush, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("餐饮2.0积分商城订单商品itemType订正")
    @RequestMapping(value = "/catering/itemType/1/3", method = RequestMethod.POST)
    public Result cateringItemTypeUpdate(@RequestBody OrderDataReviseRequest request) {
        logger.info("cateringItemTypeUpdate start!");
        Result result = new Result<>();
        try {
            result = scriptService.updateItemType();
        } catch (Exception e) {
            logger.error("TemporaryController[updatePaymentInfo]failed，cause by: {}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("更新订单支付明细")
    @RequestMapping(value = "/sync/order/pay/details", method = RequestMethod.POST)
    public Result insertOrderPayDetails(@RequestBody OrderDataReviseRequest request) {
        Result result = new Result<>();
        try {
            result = scriptService.insertOrderPayDetails(request);
        } catch (Exception e) {
            logger.error("TemporaryController[syncOrderData]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("删除ES数据")
    @RequestMapping(value = "/delete/es/order", method = RequestMethod.POST)
    public Result deleteOrder(@RequestBody OrderDataReviseRequest request) {
        Result result = new Result<>();
        try {
            result = scriptService.deleteOrder(request);
        } catch (Exception e) {
            logger.error("TemporaryController[syncOrderData]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("删除多人点餐无效数据")
    @RequestMapping(value = "/delete/multi/user/order", method = RequestMethod.POST)
    public Result deleteMultiOrder(@RequestBody OrderDataReviseRequest request) {
        Result result = new Result<>();
        try {
            result = scriptService.deleteMultiOrder();
        } catch (Exception e) {
            logger.error("TemporaryController[deleteMultiOrder]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("订单优惠表主键冲突检查对比")
    @RequestMapping(value = "/catering/discount/check", method = RequestMethod.POST)
    public Result orderDiscountIdCheck(@RequestBody OrderDataReviseRequest request) {
        logger.info("orderDiscountIdCheck start!");
        Result result = new Result<>();
        try {
            result = scriptService.orderDiscountIdCheck();
        } catch (Exception e) {
            logger.error("TemporaryController[updatePaymentInfo]failed，cause by: {}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("订单批量修改isDeleted")
    @RequestMapping(value = "/update/deleted", method = RequestMethod.POST)
    public Result updateOrderDeleted(@RequestBody OrderDataReviseRequest request) {
        Result result = new Result<>();
        try {
            result = scriptService.updateOrderDeleted(request);
        } catch (Exception e) {
            logger.error("TemporaryController[syncOrderData]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("订单批量删除")
    @RequestMapping(value = "/update/delete", method = RequestMethod.POST)
    public Result updateOrderDelete(@RequestBody OrderDataReviseRequest request) {
        Result result = new Result<>();
        try {
            result = scriptService.updateOrderDelete();
        } catch (Exception e) {
            logger.error("TemporaryController[syncOrderData]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("修复现金支付订单金额问题")
    @RequestMapping(value = "/update/amount", method = RequestMethod.POST)
    public Result updateAmount(@RequestBody OrderDataReviseRequest request) {
        Result result = new Result<>();
        try {
            result = scriptService.updateAmount();
        } catch (Exception e) {
            logger.error("TemporaryController[updateAmount]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("早安巴黎当日订单同步ES")
    @RequestMapping(value = "/current/order/sync/es", method = RequestMethod.POST)
    public Result currentOrderSyncES(@RequestBody DataCorrectionRequest request) {
        logger.info("currentOrderSyncES start!");
        Result result = new Result();
        try {
            result = scriptService.currentOrderSyncEs();
        } catch (Throwable e) {
            logger.error("TemporaryController[syncES]failed,request:{},cause by:{}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("刷历史退款单支付明细")
    @RequestMapping(value = "/refund/pay/detail", method = RequestMethod.POST)
    public Result refundPayDetail(@RequestBody OrderDataReviseRequest request) {
        Result result = new Result<>();
        try {
            result = scriptService.refundPayDetail();
        } catch (Exception e) {
            logger.error("TemporaryController[refundPayDetail]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("ID撞车现场")
    @RequestMapping(value = "/repeat/id", method = RequestMethod.POST)
    public Result repeatID(@RequestBody OrderDataReviseRequest request) {
        logger.info("repeatID start!");
        Result result = new Result<>();
        try {
            result = dataService.repeatID();
        } catch (Exception e) {
            logger.error("TemporaryController[repeatID]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("ID撞车现场save")
    @RequestMapping(value = "/repeat/id/save", method = RequestMethod.POST)
    public Result repeatIDSave(@RequestBody OrderDataReviseRequest request) {
        logger.info("repeatID start!");
        Result result = new Result<>();
        try {
            result = dataService.repeatIDSave();
        } catch (Exception e) {
            logger.error("TemporaryController[repeatID]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("查询撞车订单")
    @RequestMapping(value = "/repeat/id/save1", method = RequestMethod.POST)
    public Result repeatIDSave1(@RequestBody OrderDataReviseRequest request) {
        logger.info("repeatID start!");
        Result result = new Result<>();
        try {
            result = dataService.queryOrder1();
        } catch (Exception e) {
            logger.error("TemporaryController[repeatID]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("修复撞车订单")
    @RequestMapping(value = "/repeat/id/update", method = RequestMethod.POST)
    public Result repeatIdUpdate(@RequestBody OrderDataReviseRequest request) {
        logger.info("repeatIdUpdate start!");
        Result result = new Result<>();
        try {
            result = dataService.resetId();
        } catch (Exception e) {
            logger.error("TemporaryController[repeatID]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("查询ES中撞车主键订单")
    @RequestMapping(value = "/query/repeat/id", method = RequestMethod.POST)
    public Result queryRepeatId(@RequestBody OrderDataReviseRequest request) {
        logger.info("queryRepeatId start!");
        Result result = new Result<>();
        try {
            result = dataService.queryRepeatId();
        } catch (Exception e) {
            logger.error("TemporaryController[queryRepeatId]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("订单路由校验")
    @RequestMapping(value = "/routing/check", method = RequestMethod.POST)
    public Result routingCheck(@RequestBody OrderDataReviseRequest request) {
        logger.info("routingCheck start!");
        Result result = new Result<>();
        try {
            result = dataService.routingCheck();
        } catch (Exception e) {
            logger.error("TemporaryController[routingCheck]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("设置订单路由")
    @RequestMapping(value = "/routing/set", method = RequestMethod.POST)
    public Result setRouting(@RequestBody OrderDataReviseRequest request) {
        logger.info("setRouting start!");
        Result result = new Result<>();
        try {
            result = dataService.setRouting(request.getMaxLoop());
        } catch (Exception e) {
            logger.error("TemporaryController[setRouting]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("测试事物")
    @RequestMapping(value = "/test", method = RequestMethod.POST)
    public Result test(@RequestBody Order order) {
        logger.info("setRouting start!");
        Result result = new Result<>();
        try {
            result = dataService.test(order);
        } catch (Exception e) {
            logger.error("TemporaryController[setRouting]failed,request:{},cause by: {}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("补偿订单索引")
    @RequestMapping(value = "/insert/index", method = RequestMethod.POST)
    public Result insertIndex(@RequestBody Order order) {
        logger.info("insertIndex start!");
        Result result = new Result<>();
        try {
            result = dataService.insertIndex(order);
        } catch (Exception e) {
            logger.error("TemporaryController[insertIndex]failed,request:{},cause by: {}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    /**
     * --------------------------------------------start routing--------------------------------------------------------
     */
    @Autowired
    private OrderRoutingService routeService;

    @ApiOperation("订单重新路由-批量拉取历史订单")
    @RequestMapping(value = "/routing/order", method = RequestMethod.POST)
    public Result routingOrder(@RequestBody Order order) {
        logger.info("routingOrder start!");
        try {
            routeService.routing();
        } catch (Exception e) {
            logger.error("TemporaryController[routingOrder]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @Autowired
    private ItemRoutingService itemRouteService;

    @ApiOperation("商品重新路由-批量拉取历史订单")
    @RequestMapping(value = "/routing/item", method = RequestMethod.POST)
    public Result routingItem(@RequestBody Order order) {
        logger.info("routingItem start!");
        try {
            itemRouteService.routing();
        } catch (Exception e) {
            logger.error("TemporaryController[routingItem]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @Autowired
    private DiscountRoutingService discountRouteService;

    @ApiOperation("优惠重新路由-批量拉取历史订单")
    @RequestMapping(value = "/routing/discount", method = RequestMethod.POST)
    public Result routingDiscount(@RequestBody Order order) {
        logger.info("routingDiscount start!");
        try {
            discountRouteService.routing();
        } catch (Exception e) {
            logger.error("TemporaryController[routingDiscount]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @Autowired
    private PayDetailsRoutingService pdrService;

    @ApiOperation("支付明细重新路由-批量拉取历史订单")
    @RequestMapping(value = "/routing/pay/detail", method = RequestMethod.POST)
    public Result routingPayDetail(@RequestBody Order order) {
        logger.info("routingPayDetail start!");
        try {
            pdrService.routing();
        } catch (Exception e) {
            logger.error("TemporaryController[routingPayDetail]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @Autowired
    private OrderAddrRoutingService addrRouteService;

    @ApiOperation("地址重新路由-批量拉取历史订单")
    @RequestMapping(value = "/routing/addr", method = RequestMethod.POST)
    public Result routingAddr(@RequestBody Order order) {
        logger.info("routingAddr start!");
        try {
            addrRouteService.routing();
        } catch (Exception e) {
            logger.error("TemporaryController[routingAddr]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @Autowired
    private BatchingRoutingService batchingRouteService;

    @ApiOperation("加料重新路由-批量拉取历史订单")
    @RequestMapping(value = "/routing/batching", method = RequestMethod.POST)
    public Result routingBatching(@RequestBody Order order) {
        logger.info("routingBatching start!");
        try {
            batchingRouteService.routing();
        } catch (Exception e) {
            logger.error("TemporaryController[routingBatching]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @Autowired
    private OrderExtendsRoutingService oerSerivce;

    @ApiOperation("扩展信息重新路由-批量拉取历史订单")
    @RequestMapping(value = "/routing/extend", method = RequestMethod.POST)
    public Result routingExtend(@RequestBody Order order) {
        logger.info("routingExtend start!");
        try {
            oerSerivce.routing();
        } catch (Exception e) {
            logger.error("TemporaryController[routingExtend]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @Autowired
    private SelfTakeRoutingService srtService;

    @ApiOperation("自提信息重新路由-批量拉取历史订单")
    @RequestMapping(value = "/routing/self/take", method = RequestMethod.POST)
    public Result routingSelfTake(@RequestBody Order order) {
        logger.info("routingSelfTake start!");
        try {
            srtService.routing();
        } catch (Exception e) {
            logger.error("TemporaryController[routingSelfTake]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    /**
     * --------------------------------------------end routing----------------------------------------------------------
     */

    /**
     * --------------------------------------------start check----------------------------------------------------------
     */

    @ApiOperation("订单信息check")
    @RequestMapping(value = "/check/order", method = RequestMethod.POST)
    public Result checkOrder(@RequestBody Order order) {
        logger.info("checkOrder start!");
        try {
            routeService.check();
        } catch (Exception e) {
            logger.error("TemporaryController[checkOrder]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("商品信息check")
    @RequestMapping(value = "/check/item", method = RequestMethod.POST)
    public Result checkItem(@RequestBody Order order) {
        logger.info("checkItem start!");
        try {
            itemRouteService.check();
        } catch (Exception e) {
            logger.error("TemporaryController[checkItem]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("优惠信息check")
    @RequestMapping(value = "/check/discount", method = RequestMethod.POST)
    public Result checkDiscount(@RequestBody Order order) {
        logger.info("checkDiscount start!");
        try {
            discountRouteService.check();
        } catch (Exception e) {
            logger.error("TemporaryController[checkDiscount]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("支付信息check")
    @RequestMapping(value = "/check/pay/detail", method = RequestMethod.POST)
    public Result checkPayDetail(@RequestBody Order order) {
        logger.info("checkPayDetail start!");
        try {
            pdrService.check();
        } catch (Exception e) {
            logger.error("TemporaryController[checkPayDetail]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("加料信息check")
    @RequestMapping(value = "/check/batching", method = RequestMethod.POST)
    public Result checkBatching(@RequestBody Order order) {
        logger.info("checkBatching start!");
        try {
            batchingRouteService.check();
        } catch (Exception e) {
            logger.error("TemporaryController[checkBatching]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("地址信息check")
    @RequestMapping(value = "/check/addr", method = RequestMethod.POST)
    public Result checkAddr(@RequestBody Order order) {
        logger.info("checkAddr start!");
        try {
            addrRouteService.check();
        } catch (Exception e) {
            logger.error("TemporaryController[checkAddr]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("扩展信息check")
    @RequestMapping(value = "/check/extends", method = RequestMethod.POST)
    public Result checkExtends(@RequestBody Order order) {
        logger.info("checkExtends start!");
        try {
            oerSerivce.check();
        } catch (Exception e) {
            logger.error("TemporaryController[checkExtends]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("自提信息check")
    @RequestMapping(value = "/check/self/take", method = RequestMethod.POST)
    public Result checkSelfTake(@RequestBody Order order) {
        logger.info("checkSelfTake start!");
        try {
            srtService.check();
        } catch (Exception e) {
            logger.error("TemporaryController[checkSelfTake]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    /**
     * --------------------------------------------end check------------------------------------------------------------
     */

    /**
     * --------------------------------------------start update---------------------------------------------------------
     */

    @ApiOperation("订单信息更新")
    @RequestMapping(value = "/update/order", method = RequestMethod.POST)
    public Result updateOrder(@RequestBody Order order) {
        logger.info("updateOrder start!");
        try {
            routeService.updateData();
        } catch (Exception e) {
            logger.error("TemporaryController[updateOrder]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("商品信息更新")
    @RequestMapping(value = "/update/item", method = RequestMethod.POST)
    public Result updateItem(@RequestBody Order order) {
        logger.info("updateItem start!");
        try {
            itemRouteService.updateData();
        } catch (Exception e) {
            logger.error("TemporaryController[updateItem]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("优惠信息更新")
    @RequestMapping(value = "/update/discount", method = RequestMethod.POST)
    public Result updateDiscount(@RequestBody Order order) {
        logger.info("updateDiscount start!");
        try {
            discountRouteService.updateData();
        } catch (Exception e) {
            logger.error("TemporaryController[updateDiscount]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("支付信息更新")
    @RequestMapping(value = "/update/pay/details", method = RequestMethod.POST)
    public Result updatePayDetails(@RequestBody Order order) {
        logger.info("updatePayDetails start!");
        try {
            pdrService.updateData();
        } catch (Exception e) {
            logger.error("TemporaryController[updatePayDetails]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("加料信息更新")
    @RequestMapping(value = "/update/batching", method = RequestMethod.POST)
    public Result updateBatching(@RequestBody Order order) {
        logger.info("updateBatching start!");
        try {
            batchingRouteService.updateData();
        } catch (Exception e) {
            logger.error("TemporaryController[updateBatching]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("地址信息更新")
    @RequestMapping(value = "/update/addr", method = RequestMethod.POST)
    public Result updateAddr(@RequestBody Order order) {
        logger.info("updateAddr start!");
        try {
            addrRouteService.updateData();
        } catch (Exception e) {
            logger.error("TemporaryController[updateAddr]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("扩展信息更新")
    @RequestMapping(value = "/update/extend", method = RequestMethod.POST)
    public Result updateExtend(@RequestBody Order order) {
        logger.info("updateExtend start!");
        try {
            oerSerivce.updateData();
        } catch (Exception e) {
            logger.error("TemporaryController[updateExtend]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("自提信息更新")
    @RequestMapping(value = "/update/self/take", method = RequestMethod.POST)
    public Result updateSelfTake(@RequestBody Order order) {
        logger.info("updateSelfTake start!");
        try {
            srtService.updateData();
        } catch (Exception e) {
            logger.error("TemporaryController[updateSelfTake]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    /**
     * --------------------------------------------end update-----------------------------------------------------------
     */

    /**
     * --------------------------------------------start count----------------------------------------------------------
     */
    @ApiOperation("新节点数据统计")
    @RequestMapping(value = "/count", method = RequestMethod.POST)
    public Result count(@RequestBody ListOrderRequest query) {
        logger.info("count start!");
        try {
            routeService.count(query);
        } catch (Exception e) {
            logger.error("TemporaryController[count]failed,request:{},cause by: {}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    /**
     * --------------------------------------------end count----------------------------------------------------------
     */

    /**
     * --------------------------------------------start checkByOne-----------------------------------------------------
     */
    @ApiOperation("订单-校验一天的数据")
    @RequestMapping(value = "/order/check/one", method = RequestMethod.POST)
    public Result orderCheckOne() {
        logger.info("orderCheckOne start!");
        try {
            routeService.checkByOne();
        } catch (Exception e) {
            logger.error("TemporaryController[count]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("商品-校验一天的数据")
    @RequestMapping(value = "/item/check/one", method = RequestMethod.POST)
    public Result itemCheckOne() {
        logger.info("itemCheckOne start!");
        try {
            itemRouteService.checkByOne();
        } catch (Exception e) {
            logger.error("TemporaryController[itemCheckOne]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("优惠-校验一天的数据")
    @RequestMapping(value = "/discount/check/one", method = RequestMethod.POST)
    public Result discountCheckOne() {
        logger.info("discountCheckOne start!");
        try {
            discountRouteService.checkByOne();
        } catch (Exception e) {
            logger.error("TemporaryController[discountCheckOne]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("支付-校验一天的数据")
    @RequestMapping(value = "/pay/check/one", method = RequestMethod.POST)
    public Result payCheckOne() {
        logger.info("payCheckOne start!");
        try {
            pdrService.checkByOne();
        } catch (Exception e) {
            logger.error("TemporaryController[payCheckOne]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("加料-校验一天的数据")
    @RequestMapping(value = "/batching/check/one", method = RequestMethod.POST)
    public Result batchingCheckOne() {
        logger.info("batchingCheckOne start!");
        try {
            batchingRouteService.checkByOne();
        } catch (Exception e) {
            logger.error("TemporaryController[batchingCheckOne]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("地址-校验一天的数据")
    @RequestMapping(value = "/address/check/one", method = RequestMethod.POST)
    public Result addressCheckOne() {
        logger.info("addressCheckOne start!");
        try {
            addrRouteService.checkByOne();
        } catch (Exception e) {
            logger.error("TemporaryController[addressCheckOne]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("自提-校验一天的数据")
    @RequestMapping(value = "/take/check/one", method = RequestMethod.POST)
    public Result takeCheckOne() {
        logger.info("takeCheckOne start!");
        try {
            srtService.checkByOne();
        } catch (Exception e) {
            logger.error("TemporaryController[takeCheckOne]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("扩展-校验一天的数据")
    @RequestMapping(value = "/extend/check/one", method = RequestMethod.POST)
    public Result extendCheckOne() {
        logger.info("extendCheckOne start!");
        try {
            oerSerivce.checkByOne();
        } catch (Exception e) {
            logger.error("TemporaryController[extendCheckOne]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }
    /**
     * --------------------------------------------end checkByOne-----------------------------------------------------
     */


    @ApiOperation("指定单号正餐订单迁移")
    @RequestMapping(value = "/dinner/order/appoint-transfer", method = RequestMethod.POST)
    public Result appointOrderTransfer() {
        logger.info("appointOrderTransfer start!");
        try {
            scriptService.appointOrderTransfer();
        } catch (Exception e) {
            logger.error("TemporaryController[appointOrderTransfer]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("修改订单门店id")
    @RequestMapping(value = "/update-store-id", method = RequestMethod.POST)
    public Result updateStoreId() {
        logger.info("updateStoreId start!");
        try {
            scriptService.updateStoreId();
        } catch (Exception e) {
            logger.error("TemporaryController[updateStoreId]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("补偿评价数据")
    @RequestMapping(value = "/repair-comment", method = RequestMethod.POST)
    public Result repairComment() {
        logger.info("repairComment start!");
        try {
            scriptService.repairComment();
        } catch (Exception e) {
            logger.error("TemporaryController[repairComment]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("美团来源订单处理")
    @RequestMapping(value = "/mt-order", method = RequestMethod.POST)
    public Result mtOrder() {
        logger.info("mtOrder start!");
        try {
            scriptService.mtSourceOrder();
        } catch (Exception e) {
            logger.error("TemporaryController[mtOrder]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("补偿指定数据到美团库")
    @RequestMapping(value = "/mt-order-repair", method = RequestMethod.POST)
    public Result mtOrderRepair() {
        logger.info("mtOrderRepair start!");
        try {
            scriptService.mtOrderRepair();
        } catch (Exception e) {
            logger.error("TemporaryController[mtOrderRepair]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("修改订单状态为完成（50）")
    @RequestMapping(value = "/update-complete-status", method = RequestMethod.POST)
    public Result updateCompleteStatus() {
        logger.info("updateCompleteStatus start!");
        try {
            scriptService.pullData();
        } catch (Exception e) {
            logger.error("TemporaryController[pullData]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("新增支付明细")
    @RequestMapping(value = "/insert-pay", method = RequestMethod.POST)
    public Result insertPay(@RequestBody OrderPayDetails payDetails) {
        logger.info("insertPay start!");
        try {
            scriptService.insertPay(payDetails);
        } catch (Exception e) {
            logger.error("TemporaryController[updateStoreId]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("指定数据新增支付明细")
    @RequestMapping(value = "/appoint/insert-pay", method = RequestMethod.POST)
    public Result appointInsertPay() {
        logger.info("appointInsertPay start!");
        try {
            scriptService.appointInsertPay();
        } catch (Exception e) {
            logger.error("TemporaryController[updateStoreId]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("预拉取数据到临时表")
    @RequestMapping(value = "/pre/pull-data", method = RequestMethod.POST)
    public Result pullData() {
        logger.info("pullData start!");
        try {
            scriptService.pullData();
        } catch (Exception e) {
            logger.error("TemporaryController[pullData]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("预拉取数据到临时表餐饮")
    @RequestMapping(value = "/pre/pull-data/catering", method = RequestMethod.POST)
    public Result pullDataCatering() {
        logger.info("pullData start!");
        try {
            scriptService.pullDataCatering();
        } catch (Exception e) {
            logger.error("TemporaryController[pullData]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("餐饮积分商城迁移")
    @RequestMapping(value = "/pre/pull-data/catering/do", method = RequestMethod.POST)
    public Result jifenOrderCatering() {
        logger.info("pullData start!");
        try {
            scriptService.jifenOrderCatering();
        } catch (Exception e) {
            logger.error("TemporaryController[pullData]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("预拉取数据到临时表烘焙")
    @RequestMapping(value = "/pre/pull-data/baking/es", method = RequestMethod.POST)
    public Result pullDataBakingEs() {
        logger.info("pullDataBakingEs start!");
        try {
            scriptService.pullDataBakingEs();
        } catch (Exception e) {
            logger.error("TemporaryController[pullData]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("预拉取数据到临时表烘焙")
    @RequestMapping(value = "/pre/pull-data/baking", method = RequestMethod.POST)
    public Result pullDataBaking() {
        logger.info("pullData start!");
        try {
            scriptService.pullDataBaking();
        } catch (Exception e) {
            logger.error("TemporaryController[pullData]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("标准化商家-预拉取数据到临时表烘焙")
    @RequestMapping(value = "/pre/pull-data/baking/std", method = RequestMethod.POST)
    public Result pullDataBakingStd() {
        logger.info("pullData start!");
        try {
            scriptService.pullDataBakingStd();
        } catch (Exception e) {
            logger.error("TemporaryController[pullData]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }
    @ApiOperation("标准化商家-预拉取数据到临时表烘焙")
    @RequestMapping(value = "/pre/pull-data/baking/std/do", method = RequestMethod.POST)
    public Result bakingStdDoTransfer() {
        logger.info("pullData start!");
        try {
            scriptService.bakingStdDoTransfer();
        } catch (Exception e) {
            logger.error("TemporaryController[pullData]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("临时表烘焙积分商城数据迁移")
    @RequestMapping(value = "/pre/do/jifen/baking", method = RequestMethod.POST)
    public Result doJfenBaking() {
        logger.info("doJfenBaking start!");
        try {
            scriptService.doBakingJiFenTransfer();
        } catch (Exception e) {
            logger.error("TemporaryController[doJfenBaking]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("餐饮积分商城订单迁移")
    @RequestMapping(value = "/dinner/order/transfer", method = RequestMethod.POST)
    public Result orderTransfer() {
        logger.info("dinnerOrder start!");
        try {
            scriptService.dinnerOrder();
        } catch (Exception e) {
            logger.error("TemporaryController[orderTransfer]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("修复主键重复订单")
    @RequestMapping(value = "/order/repair", method = RequestMethod.POST)
    public Result orderRepair() {
        logger.info("orderRepair start!");
        try {
            scriptService.orderRepair();
        } catch (Exception e) {
            logger.error("TemporaryController[orderRepair]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }

    @ApiOperation("查询已经支付订单")
    @RequestMapping(value = "/order/payed", method = RequestMethod.POST)
    public Result orderPayed() {
        logger.info("orderPayed start!");
        try {
            scriptService.orderPayed();
        } catch (Exception e) {
            logger.error("TemporaryController[orderPayed]failed! cause by:{}", e);
            return Result.failureData(e.getMessage());
        }
        return Result.successNullData();
    }
}
