package com.neusoft.smart.pos.gateway.controller;

import com.neusoft.smart.pos.gateway.service.feignService.RemoteOrderService;
import com.neusoft.smart.pos.gateway.service.feignService.RemoteOrgService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/table")
public class TableController {
    private final RemoteOrderService remoteOrderService;
    private final RemoteOrgService remoteOrgService;

    public TableController(RemoteOrderService remoteOrderService, RemoteOrgService remoteOrgService) {
        this.remoteOrderService = remoteOrderService;
        this.remoteOrgService = remoteOrgService;
    }

//    @PostMapping("/open/{tableId}")
//    public ResponseData open(@PathVariable Integer tableId) {
//        final ResponseData<Tables> tablesResponseData = remoteOrgService.selectTableById(tableId);
//        if (!tablesResponseData.getCode().equals(CommonErrorCode.SUCCESS.getCode())) {
//            throw new BusinessCommonException(tablesResponseData);
//        }
//        final Tables table = tablesResponseData.getResult();
//        final String orderNumber = table.getOrderId();
//        if (!StringUtils.isEmpty(orderNumber)) {
//            if (orderNumber.equals("dummy_from_pos")) {
//                throw new BusinessCommonException("500", "POS订单，无法查询详情");
//            }
//            val queryShopOrderInfoResponseData = remoteOrderService.queryWxOrderWithDetails(orderNumber);
//            if (null == queryShopOrderInfoResponseData) {
//                throw new BusinessCommonException("500", "查询订单信息失败");
//            } else if (!ApplicationConstants.SUCCESS_CODE.equals(queryShopOrderInfoResponseData.getCode())) {
//                throw new BusinessCommonException(queryShopOrderInfoResponseData);
//            } else {
//                return new ResponseData(queryShopOrderInfoResponseData);
//            }
//        } else {
//            table.setOrderId("dummy_from_pos");
//            remoteOrgService.updateTable(table);
//            return new ResponseData();
//        }
//    }

}
