
package com.tmerclub.cloud.order.feign;

import com.tmerclub.cloud.api.order.feign.OrderSettlementFeignClient;
import com.tmerclub.cloud.api.order.vo.OrderSettlementPayVO;
import com.tmerclub.cloud.api.order.vo.OrderSettlementSimpleVO;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.common.util.BeanUtil;
import com.tmerclub.cloud.order.model.OrderSettlement;
import com.tmerclub.cloud.order.service.OrderSettlementService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @Author lth
 * @Date 2021/7/14 13:33
 */
@DubboService
public class OrderSettlementFeignController implements OrderSettlementFeignClient {

    @Autowired
    private OrderSettlementService orderSettlementService;


    @Override
    public ServerResponseEntity<List<OrderSettlementSimpleVO>> listOrderIdsByPayIds(Long userId, List<Long> payIds) {
        return ServerResponseEntity.success(orderSettlementService.listOrderIdsByPayIds(userId, payIds));
    }

    @Override
    public ServerResponseEntity<OrderSettlementPayVO> getPayIdByOrderId(Long orderId) {
        OrderSettlement orderSettlement = orderSettlementService.getByOrderId(orderId);
        return ServerResponseEntity.success(BeanUtil.map(orderSettlement, OrderSettlementPayVO.class));
    }
}
