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

import com.github.dozermapper.core.Mapper;
import com.google.common.base.Throwables;
import com.zm.order.tool.server.builder.AdminBuilder;
import com.zm.order.tool.server.dto.OrderSyncAmountEsDTO;
import com.zm.order.tool.server.helper.AdminHelper;
import com.zm.order.tool.server.manager.InnerApiManager;
import com.zm.order.tool.server.model.DataCorrectionRequest;
import com.zm.order.tool.server.request.*;
import com.zm.order.tool.server.service.*;
import com.zm.order.tool.server.service.impl.AdminOrderServiceImpl;
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.util.Assert;
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.List;

/**
 * @Author 陈标
 * @Date 2020/3/13 13:28
 */
@SuppressWarnings("all")
@Api(value = "临时任务", tags = "对外接口")
@RestController
@RequestMapping("/qapi/order/temporary")
public class TemporaryController {

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

    @Autowired
    private AdminOrderServiceImpl adminOrderServiceImpl;
    @Autowired
    private AdminBuilder adminBuilder;
    @Autowired
    private InnerApiManager innerApiManager;
    @Autowired
    private AdminHelper helper;

    @Autowired
    private TemporaryService temporaryService;

    @Autowired
    private Mapper mapper;
    @Autowired
    private DataService dataService;
    @Autowired
    private OrderSyncService orderSyncService;
    @Autowired
    private BakingService bakingService;

    @ApiOperation("通用第三方接口")
    @RequestMapping(value = "/task", method = RequestMethod.POST)
    public Result temporary(@RequestBody TemporaryTaskRequest request) {
        logger.info("任务开始,请求参数{}", request.toString());
        Result result = new Result<>();
        try {
           /* ExceptionInfo exceptionInfo = helper.checkTemporaryRequest(request);
            if (ExceptionConstants.OK != exceptionInfo) {
                result.setException(exceptionInfo);
                return result;
            }
            if (CollectionUtils.isEmpty(request.getHeaders())) {
                Map<String, String> headers = new HashMap<>(16);
                headers.put("bizType", "1");
                request.setHeaders(headers);
            }
            if (CollectionUtils.isEmpty(request.getBodyMap())) {
                Map<String, Object> bodyMap = new HashMap<>(16);
                bodyMap.put("pageNo", 1);
                bodyMap.put("pageSize", 10);
                bodyMap.put("sellerId", 15550);
                request.setBodyMap(bodyMap);
            }
            InnerApiSignature innerApiSignature = innerApiManager.getInnerApiSignature(request.getAppName());
            InnerApiRequest innerApiRequest = innerApiManager.buildRequest(innerApiSignature, request.getUrl(), request.getBodyMap(), request.getHeaders(), innerApiSignature.getAppKey(), HttpUtils.MethodEnum.POST);
            result = innerApiManager.call(innerApiRequest);*/
            return result;
        } catch (Throwable throwable) {
            logger.error("TemporaryController[temporary] failed, request:{}, cause by:{}",
                    request.toString(), Throwables.getStackTraceAsString(throwable));
        }
        logger.info("任务结束,返回参数", request);
        return result;
    }


    @ApiOperation("自动完成消息补偿")
    @RequestMapping(value = "/compensate", method = RequestMethod.POST)
    public Result compensate(@RequestBody TemporaryTaskRequest request) {
        logger.info("任务开始,请求参数{}", request.toString());
        Result result = new Result<>();
        try {
            result = temporaryService.compensate();
        } catch (Throwable throwable) {
            logger.error("TemporaryController[temporary] failed, request:{}, cause by:{}",
                    request.toString(), Throwables.getStackTraceAsString(throwable));
        }
        logger.info("任务结束,返回参数", request);
        return result;
    }


    @ApiOperation("订单同步统计索引-勿动")
    @RequestMapping(value = "/order/sync/amount/es", method = RequestMethod.POST)
    public Result orderSyncAmountEs(@RequestBody OrderSyncAmountEsRequest request) {
        Result result = new Result<>();
        try {
            result = temporaryService.syncAmountIndex(mapper.map(request, OrderSyncAmountEsDTO.class));
        } catch (Exception e) {
            logger.error("TemporaryController[orderSyncAmountEs]failed,request:{}, cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;

    }

    @ApiOperation("订单重新路由ES索引")
    @RequestMapping(value = "/order/sync/es", method = RequestMethod.POST)
    public Result orderSyncEs(@RequestBody OrderSyncEsRequest request) {
        logger.info("order routing Es index start!");
        Result result = new Result<>();
        try {
            result = temporaryService.syncIndex(request);
        } catch (Exception e) {
            logger.error("TemporaryController[orderSyncEs]failed,request:{}, cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;

    }


    @ApiOperation("订单自动评论事件补推")
    @RequestMapping(value = "/send/event", method = RequestMethod.POST)
    public Result sendEvent(@RequestBody OrderSyncAmountEsRequest request) {
        logger.info("order sendEvent start!");
        Result result = new Result<>();
        try {
            result = temporaryService.sendEvent();
        } catch (Exception e) {
            logger.error("TemporaryController[sendEvent]failed,request:{}, cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;

    }

    @ApiOperation("退款单处理时间订正")
    @RequestMapping(value = "/refund/data", method = RequestMethod.POST)
    public Result refundData(@RequestBody RefundDataReviseRequest request) {
        logger.info("refund data start!");
        Result result = new Result<>();
        try {
            result = temporaryService.refundDataRevise(request);
        } catch (Exception e) {
            logger.error("TemporaryController[refundData]failed,request:{}, cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;

    }

    @ApiOperation("数据迁移后-订单数据订正")
    @RequestMapping(value = "/order/data", method = RequestMethod.POST)
    public Result orderData(@RequestBody OrderDataReviseRequest request) {
        logger.info("order data start!");
        Result result = new Result<>();
        try {
            result = temporaryService.orderDataRevise(request);
        } catch (Exception e) {
            logger.error("TemporaryController[orderData]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;

    }

    @ApiOperation("订正李先生异常数据")
    @RequestMapping(value = "/order/adjust/data", method = RequestMethod.POST)
    public Result orderAdjustData(@RequestBody OrderDataReviseRequest request) {
        logger.info("order adjust data start!");
        Result result = new Result<>();
        try {
            result = temporaryService.orderAdjustDataRevise(request);
        } catch (Exception e) {
            logger.error("TemporaryController[orderAdjustData]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;

    }

    @ApiOperation("指定订正李先生异常数据")
    @RequestMapping(value = "/erp/error", method = RequestMethod.POST)
    public Result erpErrpr(@RequestBody OrderDataReviseRequest request) {
        logger.info("order adjust data start!");
        Result result = new Result<>();
        try {
            result = temporaryService.erpErrorData(request);
        } catch (Exception e) {
            logger.error("TemporaryController[erpErrorData]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 deleteEsOrder(@RequestBody OrderDataReviseRequest request) {
        logger.info("delete Es Order start!");
        Result result = new Result<>();
        try {
            result = temporaryService.deleteEsOrder();
        } catch (Exception e) {
            logger.error("TemporaryController[deleteEsOrder]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;

    }

    @ApiOperation("订单支付明细迁移")
    @RequestMapping(value = "/order/pay/type", method = RequestMethod.POST)
    public Result orderPayType(@RequestBody OrderDataReviseRequest request) {
        logger.info("orderPayType start!");
        Result result = new Result<>();
        try {
            result = temporaryService.orderPayType(request);
        } catch (Exception e) {
            logger.error("TemporaryController[orderPayType]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;

    }

    @ApiOperation("订单退款明细迁移")
    @RequestMapping(value = "/order/refund/type", method = RequestMethod.POST)
    public Result orderRefundType(@RequestBody OrderDataReviseRequest request) {
        logger.info("orderRefundType start!");
        Result result = new Result<>();
        try {
            result = temporaryService.orderRefundType(request);
        } catch (Exception e) {
            logger.error("TemporaryController[orderPayType]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;

    }

    @ApiOperation("数据订正-订单商品goods_id")
    @RequestMapping(value = "/order/item/goodsId", method = RequestMethod.POST)
    public Result orderItemGoodsId(@RequestBody OrderDataReviseRequest request) {
        logger.info("orderItemGoodsId start!");
        Result result = new Result<>();
        try {
            result = temporaryService.orderItemGoodsId();
        } catch (Exception e) {
            logger.error("TemporaryController[orderPayType]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;

    }

    @ApiOperation("删除指定商家订单（测试订单）")
    @RequestMapping(value = "/delete-order-by-seller", method = RequestMethod.POST)
    public Result deleteOrderBySellerId(@RequestBody OrderDataReviseRequest request) {
        logger.info("deleteOrder start!");
        Result result = new Result<>();
        try {
            result = temporaryService.deleteOrder(request);
        } catch (Exception e) {
            logger.error("TemporaryController[deleteOrder]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;

    }

    @ApiOperation("删除指定商家退款单（测试订单）")
    @RequestMapping(value = "/delete-refund-by-seller", method = RequestMethod.POST)
    public Result deleteRefundBySellerId(@RequestBody OrderDataReviseRequest request) {
        logger.info("deleteRefundBySellerId start!");
        Result result = new Result<>();
        try {
            result = temporaryService.deleteRefund(request);
        } catch (Exception e) {
            logger.error("TemporaryController[deleteRefundBySellerId]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;

    }

    @ApiOperation("更新退款单payType字段")
    @RequestMapping(value = "/update/refund/payType", method = RequestMethod.POST)
    public Result updateRefundPayType(@RequestBody OrderDataReviseRequest request) {
        logger.info("updateRefundPayType start!");
        Result result = new Result<>();
        try {
            result = temporaryService.updateRefundPayType(request);
        } catch (Exception e) {
            logger.error("TemporaryController[orderPayType]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("更新退款单completedAt字段")
    @RequestMapping(value = "/update/refund/dealAt", method = RequestMethod.POST)
    public Result updateRefundDealAt(@RequestBody OrderDataReviseRequest request) {
        logger.info("updateRefundDealAt start!");
        Result result = new Result<>();
        try {
            result = temporaryService.updateRefundDealAt(request);
        } catch (Exception e) {
            logger.error("TemporaryController[orderPayType]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("更新pay_info字段")
    @RequestMapping(value = "/update/payInfo", method = RequestMethod.POST)
    public Result updatePayInfo(@RequestBody OrderDataReviseRequest request) {
        logger.info("updatePayInfo start!");
        Result result = new Result<>();
        try {
            result = temporaryService.updatePayInfo(request);
        } catch (Exception e) {
            logger.error("TemporaryController[orderPayType]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("订单更新状态")
    @RequestMapping(value = "/update/itemInfo", method = RequestMethod.POST)
    public Result updateItemInfo(@RequestBody OrderDataReviseRequest request) {
        logger.info("updateItemInfo start!");
        Result result = new Result<>();
        try {
            result = temporaryService.updateOrderStatus(request);
        } catch (Exception e) {
            logger.error("TemporaryController[updateItemInfo]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("订单更新商品价格")
    @RequestMapping(value = "/update/item/price", method = RequestMethod.POST)
    public Result updateItemPrice(@RequestBody OrderDataReviseRequest request) {
        logger.info("updateItemPrice start!");
        Result result = new Result<>();
        try {
            result = temporaryService.updateItemPrice(request);
        } catch (Exception e) {
            logger.error("TemporaryController[updateItemPrice]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("更新订单优惠商家ID")
    @RequestMapping(value = "/update/sellerId", method = RequestMethod.POST)
    public Result updateSellerId(@RequestBody OrderDataReviseRequest request) {
        logger.info("updateSellerId start!");
        Result result = new Result<>();
        try {
            result = temporaryService.updateSellerId(request);
        } catch (Exception e) {
            logger.error("TemporaryController[updateSellerId]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("更新退款商品商家ID")
    @RequestMapping(value = "/update/refundItem/sellerId", method = RequestMethod.POST)
    public Result updateRefundItemSellerId(@RequestBody OrderDataReviseRequest request) {
        logger.info("updateRefundItemSellerId start!");
        Result result = new Result<>();
        try {
            result = temporaryService.updateRefundItemSellerId(request);
        } catch (Exception e) {
            logger.error("TemporaryController[updateRefundItemSellerId]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("更新订单状态")
    @RequestMapping(value = "/update/order/status", method = RequestMethod.POST)
    public Result updateOrderStatus() {
        logger.info("updateOrderStatus start!");
        Result result = new Result<>();
        try {
            result = temporaryService.updateOrderStatus();
        } catch (Exception e) {
            logger.error("TemporaryController[updateOrderStatus]failed，cause by: {}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("更新paymentInfo")
    @RequestMapping(value = "/update/paymentInfo", method = RequestMethod.POST)
    public Result updatePaymentInfo(@RequestBody OrderDataReviseRequest request) {
        logger.info("updatePaymentInfo start!");
        Result result = new Result<>();
        try {
            result = temporaryService.updatePaymentInfo(request);
        } catch (Exception e) {
            logger.error("TemporaryController[updatePaymentInfo]failed，cause by: {}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("餐饮2.0订单和商品数据迁移")
    @RequestMapping(value = "/catering/transfer", method = RequestMethod.POST)
    public Result cateringTransfer(@RequestBody OrderDataReviseRequest request) {
        logger.info("cateringTransfer start!");
        Result result = new Result<>();
        try {
            result = temporaryService.cateringTransfer(request);
        } catch (Exception e) {
            logger.error("TemporaryController[updatePaymentInfo]failed，cause by: {0}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("餐饮2.0退款单数据迁移")
    @RequestMapping(value = "/catering/refund/transfer", method = RequestMethod.POST)
    public Result cateringRefundTransfer(@RequestBody OrderDataReviseRequest request) {
        logger.info("cateringRefundTransfer start!");
        Result result = new Result<>();
        try {
            result = temporaryService.cateringRefundTransfer(request);
        } catch (Exception e) {
            logger.error("TemporaryController[cateringRefundTransfer]failed，cause by: {0}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("餐饮2.0订单和商品数据迁移回滚")
    @RequestMapping(value = "/catering/transfer/rollback", method = RequestMethod.POST)
    public Result cateringTransferRollback(@RequestBody OrderDataReviseRequest request) {
        logger.info("cateringTransferRollback start!");
        Result result = new Result<>();
        try {
//            result = temporaryService.cateringTransferRollback(request);
        } catch (Exception e) {
            logger.error("TemporaryController[cateringTransferRollback]failed，cause by: {0}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("重新路由index")
    @RequestMapping(value = "/routing/index", method = RequestMethod.POST)
    public Result routingIndex(@RequestBody OrderDataReviseRequest request) {
        logger.info("routingIndex start!");
        Result result = new Result<>();
        try {
            result = temporaryService.routingIndex(request);
        } catch (Exception e) {
            logger.error("TemporaryController[routingIndex]failed，cause by: {}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("补支付数据")
    @RequestMapping(value = "/insert/pay", method = RequestMethod.POST)
    public Result insertPay(@RequestBody OrderDataReviseRequest request) {
        logger.info("insertPay start!");
        Result result = new Result<>();
        try {
            result = temporaryService.insertPay();
        } catch (Exception e) {
            logger.error("TemporaryController[insertPay]failed，cause by: {}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("删除支付数据")
    @RequestMapping(value = "/delete/pay", method = RequestMethod.POST)
    public Result deletePay(@RequestBody OrderDataReviseRequest request) {
        logger.info("deletePay start!");
        Result result = new Result<>();
        try {
            result = temporaryService.deletePay();
        } catch (Exception e) {
            logger.error("TemporaryController[insertPay]failed，cause by: {}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("删除指定支付数据")
    @RequestMapping(value = "/delete/pay-a", method = RequestMethod.POST)
    public void deletePayA(@RequestBody OrderDataReviseRequest request) {
        logger.info("deletePayA start!");
        try {
            temporaryService.deletePayA();
        } catch (Exception e) {
            logger.error("TemporaryController[deletePayA]failed，cause by: {}", e);
        }
    }

    @ApiOperation("装修迁移")
    @RequestMapping(value = "/design", method = RequestMethod.POST)
    public Result design(@RequestBody OrderDataReviseRequest request) {
        logger.info("design start!");
        Result result = new Result<>();
        try {
            result = dataService.design();
        } catch (Exception e) {
            logger.error("TemporaryController[design]failed，cause by: {}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("查询装修列表")
    @RequestMapping(value = "/design/list", method = RequestMethod.POST)
    public Result designList(@RequestBody OrderDataReviseRequest request) {
        Assert.notNull(request.getSellerId(), "商家ID不存在");
        Result result = new Result<>();
        try {
            result = dataService.designList(request);
        } catch (Exception e) {
            logger.error("TemporaryController[design]failed，cause by: {}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("更新装修")
    @RequestMapping(value = "/update/design", method = RequestMethod.POST)
    public Result designList(@RequestBody List<DesignRequest> list) {
        Assert.notEmpty(list, "数据为空");
        try {
            dataService.updateDesign(list);
        } catch (Exception e) {
            logger.error("TemporaryController[design]failed，cause by: {}", e);
            return Result.successNullData();
        }
        return Result.successNullData();
    }

    @ApiOperation("填充加料数据")
    @RequestMapping(value = "/insert/batching", method = RequestMethod.POST)
    public Result insertBatching(@RequestBody OrderDataReviseRequest request) {
        logger.info("insertBatching start!");
        Result result = new Result<>();
        try {
            result = temporaryService.insertBatching();
        } catch (Exception e) {
            logger.error("TemporaryController[insertBatching]failed，cause by: {}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("刷RefundFlag")
    @RequestMapping(value = "/update/refund/flag", method = RequestMethod.POST)
    public Result updateRefundFlag(@RequestBody OrderDataReviseRequest request) {
        logger.info("updateRefundFlag start!");
        Result result = new Result<>();
        try {
            result = dataService.updateRefundFlag();
        } catch (Exception e) {
            logger.error("TemporaryController[insertBatching]failed，cause by: {}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("订单信息迁移")
    @RequestMapping(value = "/update/userId", method = RequestMethod.POST)
    public Result updateUserId(@RequestBody OrderDataReviseRequest request) {
        logger.info("updateUserId start!");
        Result result = new Result<>();
        try {
            result = dataService.updateUserId();
        } catch (Exception e) {
            logger.error("TemporaryController[updateUserId]failed，cause by: {}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("变更用户ID")
    @RequestMapping(value = "/update/user", method = RequestMethod.POST)
    public Result updateUser(@RequestBody OrderDataReviseRequest request) {
        logger.info("updateUserId start!");
        Result result = new Result<>();
        try {
            result = dataService.updateUser(request);
        } catch (Exception e) {
            logger.error("TemporaryController[updateUserId]failed，cause by: {}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }


    @ApiOperation("重新刷支付类型")
    @RequestMapping(value = "/update/payType", method = RequestMethod.POST)
    public Result updatePayType(@RequestBody OrderDataReviseRequest request) {
        logger.info("updatePayType start!");
        Result result = new Result<>();
        try {
            result = temporaryService.updatePayType();
        } catch (Exception e) {
            logger.error("TemporaryController[updatePayType]failed，cause by: {}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("评价迁移")
    @RequestMapping(value = "/comment", method = RequestMethod.POST)
    public Result comment(@RequestBody DataCorrectionRequest request) {
        Result result = new Result();
        try {
            result = dataService.comment();
        } catch (Throwable e) {
            logger.error("TemporaryController[comment]failed,request:{},cause by:{}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("删除评价")
    @RequestMapping(value = "delete/comment", method = RequestMethod.POST)
    public Result deleteComment(@RequestBody DataCorrectionRequest request) {
        Result result = new Result();
        try {
            result = dataService.deleteComment();
        } catch (Throwable e) {
            logger.error("TemporaryController[deleteComment]failed,request:{},cause by:{}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("烘焙数据同步")
    @RequestMapping(value = "baking/order/sync", method = RequestMethod.POST)
    public Result bakingOrderSync(@RequestBody DataCorrectionRequest request) {
        logger.info("bakingOrderSync start!");
        Result result = new Result();
        try {
            result = temporaryService.bakingOrderSync();
        } catch (Throwable e) {
            logger.error("TemporaryController[bakingOrderSync]failed,request:{},cause by:{}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("手动餐饮2.0订单和商品数据迁移")
    @RequestMapping(value = "/catering/transfer/manual", method = RequestMethod.POST)
    public Result cateringTransferManual() {
        logger.info("cateringTransferManual start!");
        Result result = new Result<>();
        try {
            result = temporaryService.cateringTransferManual();
        } catch (Exception e) {
            logger.error("TemporaryController[cateringTransferManual]failed，cause by: {0}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("订正商品优惠")
    @RequestMapping(value = "update/item/discount", method = RequestMethod.POST)
    public Result updateItemDiscount(@RequestBody DataCorrectionRequest request) {
        logger.info("updateItemDiscount start!");
        Result result = new Result();
        try {
            result = temporaryService.updateItemDiscount();
        } catch (Throwable e) {
            logger.error("TemporaryController[updateItemDiscount]failed,request:{},cause by:{}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("变更指定商家下的用户ID")
    @RequestMapping(value = "update/seller/userId", method = RequestMethod.POST)
    public Result updateSellerUserId(@RequestBody DataCorrectionRequest request) {
        logger.info("updateSellerUserId start!");
        Result result = new Result();
        try {
            result = dataService.updateSellerUserId(request);
        } catch (Throwable e) {
            logger.error("TemporaryController[updateSellerUserId]failed,request:{},cause by:{}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("从临时表查询-变更指定商家下的用户ID")
    @RequestMapping(value = "update/seller/userId/temp", method = RequestMethod.POST)
    public Result updateSellerUserIdTemp(@RequestBody DataCorrectionRequest request) {
        logger.info("updateSellerUserId start!");
        Result result = new Result();
        try {
            result = dataService.updateSellerUserIdTemp(request);
        } catch (Throwable e) {
            logger.error("TemporaryController[updateSellerUserId]failed,request:{},cause by:{}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("积分加购价订单迁移")
    @RequestMapping(value = "/integral/order", method = RequestMethod.POST)
    public Result integralOrder(@RequestBody DataCorrectionRequest request) {
        logger.info("integralOrder start!");
        Result result = new Result();
        try {
            result = dataService.integralOrder();
        } catch (Throwable e) {
            logger.error("TemporaryController[integralOrder]failed,request:{},cause by:{}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("规范统一烘焙订单处理")
    @RequestMapping(value = "/field/convert", method = RequestMethod.POST)
    public Result fieldConvert(@RequestBody DataCorrectionRequest request) {
        logger.info("fieldConvert start!");
        Result result = new Result();
        try {
            result = bakingService.fieldConvert();
        } catch (Throwable e) {
            logger.error("TemporaryController[fieldConvert]failed,request:{},cause by:{}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }

    @ApiOperation("规范统一餐饮订单处理")
    @RequestMapping(value = "catering/field/convert", method = RequestMethod.POST)
    public Result cateringFieldConvert(@RequestBody DataCorrectionRequest request) {
        logger.info("cateringFieldConvert start!");
        Result result = new Result();
        try {
            result = bakingService.cateringFieldConvert();
        } catch (Throwable e) {
            logger.error("TemporaryController[cateringFieldConvert]failed,request:{},cause by:{}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }


    @ApiOperation("查询所有deleted-3数据")
    @RequestMapping(value = "/order/merge/deleted", method = RequestMethod.POST)
    public Result findMergeDeleted() {
        logger.info("findMergeDeleted start!");
        Result result = new Result<>();
        try {
            result = temporaryService.findMergeDeleted();
        } catch (Exception e) {
            logger.error("findMergeDeleted,failed，cause by: {0}", e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }
}
