package com.liquidnet.service.goblin.controller.manage;

import com.github.pagehelper.PageInfo;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreBackOrderListVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreOrderListVo;
import com.liquidnet.service.goblin.param.RefundCallbackParam;
import com.liquidnet.service.goblin.service.manage.IGoblinStoreBackOrderService;
import com.liquidnet.service.goblin.service.manage.IGoblinStoreOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.math.BigDecimal;

@ApiSupport(order = 149101)
@Api(tags = "店铺-订单")
@Slf4j
@Validated
@RestController
@RequestMapping("store/orderBack")
public class GoblinStoreBackOrderController {
    @Autowired
    IGoblinStoreBackOrderService goblinStoreBackOrderService;

    @ApiOperation(value = "订单列表")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "form", required = true, dataType = "Integer", name = "page", value = "页数"),
            @ApiImplicitParam(type = "form", required = false, dataType = "String", name = "orderBackCode", value = "订单退款编号"),
            @ApiImplicitParam(type = "form", required = false, dataType = "Integer", name = "type", value = "退款类型[0-全部|1-退款|2-退货|3-退款退货]"),
            @ApiImplicitParam(type = "form", required = false, dataType = "String", name = "cst", value = "申请起始时间"),
            @ApiImplicitParam(type = "form", required = false, dataType = "String", name = "cet", value = "申请终止时间"),
            @ApiImplicitParam(type = "form", required = false, dataType = "String", name = "orderCode", value = "订单编号"),
            @ApiImplicitParam(type = "form", required = false, dataType = "String", name = "spuName", value = "商品名称"),
            @ApiImplicitParam(type = "form", required = false, dataType = "Integer", name = "status", value = "订单状态[1-待处理|2-已退款|9-已拒绝|11-已取消|0-退款中|7-退货中]"),
    })
    @GetMapping(value = "list")
    public ResponseDto<PageInfo<GoblinStoreBackOrderListVo>> orderBackList(@RequestParam(value = "page", required = true) @Valid Integer page,
                                                                           @RequestParam(value = "orderBackCode", required = false) String orderBackCode,
                                                                           @RequestParam(value = "type", required = false) Integer type,
                                                                           @RequestParam(value = "cst", required = false) String cst,
                                                                           @RequestParam(value = "cet", required = false) String cet,
                                                                           @RequestParam(value = "orderCode", required = false) String orderCode,
                                                                           @RequestParam(value = "spuName", required = false) String spuName,
                                                                           @RequestParam(value = "status", required = false) Integer status) {

        return goblinStoreBackOrderService.orderBackList(page, orderBackCode, type, cst, cet, orderCode, spuName, status);
    }

    @ApiOperation(value = "退款订单详情")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "backOrderId", value = "订单id"),
    })
    @GetMapping(value = "details")
    public ResponseDto<GoblinStoreBackOrderListVo> orderList(@RequestParam(value = "backOrderId", required = true) @Valid String backOrderId) {
        return goblinStoreBackOrderService.orderDetails(backOrderId);
    }
}
