package com.buy507.mall.portal.controller;

import java.util.List;

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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.buy507.mall.common.api.CommonResult;
import com.buy507.mall.portal.domain.OmsOrderReturnApplyParam;
import com.buy507.mall.portal.domain.OrderReturnResult;
import com.buy507.mall.portal.service.OmsPortalOrderReturnService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;

/**
 * 订单退货管理Controller
 */
@RestController
@Api(tags = "OmsPortalOrderReturnController", description = "订单退货管理")
@RequestMapping("/member/order/return")
public class OmsPortalOrderReturnController {
    @Autowired
    private OmsPortalOrderReturnService returnService;

    @ApiOperation("申请退货")
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public CommonResult create(@RequestBody OmsOrderReturnApplyParam returnApply) {
        int count = returnService.create(returnApply);
        if (count > 0) {
            return CommonResult.success(count);
        }
        return CommonResult.failed();
    }
    
    @ApiOperation("获取退货原因")
    @RequestMapping(value = "/getReturnReason", method = RequestMethod.GET)
    public CommonResult<List<String>> getReturnReason() {
    	return CommonResult.success(returnService.getReturnReason());
    }
    
    @ApiOperation("获取会员退货订单信息列表")
    @RequestMapping(value = "/getMemberOrderReturnList", method = RequestMethod.GET)
    public CommonResult<List<OrderReturnResult>> getMemberOrderReturnList(@RequestParam Integer pageSize, @RequestParam Integer pageNum) {
    	return CommonResult.success(returnService.getMemberOrderReturnList(pageSize, pageNum));
    }
    
    @ApiOperation("获取会员退货订单详细信息")
    @ApiModelProperty(name = "orderReturnId", value = "退货订单ID")
    @RequestMapping(value = "/getMemberOrderReturnDetailInfo", method = RequestMethod.GET)
    public CommonResult<OrderReturnResult> getMemberOrderReturnDetailInfo(@RequestParam Long orderReturnId) {
    	return CommonResult.success(returnService.getMemberOrderReturnDetailInfo(orderReturnId));
    }
    
}
