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

import com.github.pagehelper.PageInfo;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreZhengzaiCommonParam;
import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.goblin.service.manage.IGoblinInnerService;
import com.liquidnet.service.goblin.service.manage.IGoblinZhengzaiService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
import java.util.List;

/**
 * 正在下单活动管理
 */
@Slf4j
@RestController
@Api(tags = "活动-内部接口调用")
@RequestMapping("inner")
public class GoblinInnerZhengzaiController {

    @Autowired
    IGoblinZhengzaiService goblinZhengzaiService;
    @Autowired
    IGoblinInnerService goblinInnerService;

    @PostMapping("config/del/noAuth")
    @ApiOperation("活动详情-正在下单-删除商铺spu")
    @ApiResponse(code = 200, message = "接口返回对象参数")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "storeId", value = "商铺id", example = "1"),
            @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "selfMarketId", value = "官方活动id", example = "1"),
            @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "spuId", value = "spuId", example = "1"),
    })
    public ResponseDto<Boolean> zhengzaiStoreDelNoAuth(@RequestParam("storeId") @Valid String storeId,
                                                       @RequestParam("selfMarketId") @Valid String selfMarketId,
                                                       @RequestParam("spuId") @Valid String spuId) {
        return goblinZhengzaiService.zhengzaiSpuDel(selfMarketId, storeId, spuId);
    }

    @GetMapping("config/spu")
    @ApiOperation("活动详情-正在下单-获取商铺spu")
    @ApiResponse(code = 200, message = "接口返回对象参数")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "storeId", value = "商铺id", example = "1"),
            @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "selfMarketId", value = "官方活动id", example = "1"),
            @ApiImplicitParam(type = "form", required = true, dataType = "Integer", name = "page", value = "页数", example = "1")
    })
    public ResponseDto<PageInfo<GoblinMarketSpuListVo>> zhengzaiStoreConfigSpuList(@RequestParam("storeId") @Valid String storeId,
                                                                                   @RequestParam("selfMarketId") @Valid String selfMarketId,
                                                                                   @RequestParam("page") @Valid int page) {
        return goblinZhengzaiService.zhengzaiSpuList(selfMarketId, storeId, page);
    }

    @GetMapping("config/sku")
    @ApiOperation("活动详情-正在下单-获取商铺sku")
    @ApiResponse(code = 200, message = "接口返回对象参数")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "storeId", value = "商铺id", example = "1"),
            @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "selfMarketId", value = "官方活动id", example = "1"),
            @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "spuId", value = "spuId", example = "1")
    })
    public ResponseDto<List<GoblinSelfZhengzaiSkuVo>> zhengzaiStoreConfigSkuList(@RequestParam("storeId") @Valid String storeId,
                                                                                 @RequestParam("spuId") @Valid String spuId,
                                                                                 @RequestParam("selfMarketId") @Valid String selfMarketId) {
        return goblinZhengzaiService.zhengzaiSkuList(selfMarketId, storeId, spuId);
    }

    @PostMapping("add/temp/coupon")
    @ApiOperation("添加活动临时券")
    @ApiResponse(code = 200, message = "接口返回对象参数")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "form", dataType = "File", name = "file", value = "文件", required = true),
            @ApiImplicitParam(type = "form", dataType = "String", name = "performanceId", value = "演出id", required = true),
    })
    public ResponseDto<String> insertCoupon(@RequestParam("file") MultipartFile file,
                                            @RequestParam("performanceId") String performanceId) {
        return goblinInnerService.insertCoupon(file, performanceId);
    }

    @PostMapping("ar/data")
    @ApiOperation("获取ar相关离线数据")
    @ApiResponse(code = 200, message = "接口返回对象参数")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "form", dataType = "String", name = "tag", value = "标签", required = true),
            @ApiImplicitParam(type = "form", dataType = "String", name = "performanceId", value = "演出id", required = true),
    })
    public ResponseDto<ArDataVo> getArData(@RequestParam("tag") String tag,
                                           @RequestParam("performanceId") String performanceId) {
        return goblinInnerService.getArData(tag, performanceId);
    }

    @PostMapping("temp/coupon/data")
    @ApiOperation("获取临时券数据")
    @ApiResponse(code = 200, message = "接口返回对象参数")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "form", dataType = "String", name = "ucouponId", value = "券id", required = true),
    })
    public ResponseDto<TempCouponVo> getArData(@RequestParam("ucouponId") String ucouponId) {
        return goblinInnerService.getTempCouponData(ucouponId);
    }
}
