package com.ym.mec.web.controller;


import com.ym.mec.biz.service.SysCouponIssueRecordService;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.common.entity.HttpResponseResult;
import com.ym.mec.common.page.WrapperUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 优惠券发放记录(SysCouponIssueRecord)表控制层
 *
 * @author hgw
 * @since 2021-12-30 16:48:15
 */
@RestController
@RequestMapping("/sysCouponIssue")
public class SysCouponIssueRecordController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private SysCouponIssueRecordService couponIssueRecordService;

    /**
     * 手动发放优惠券
     */
    @ApiOperation("手动发放优惠券")
    @PostMapping(value = "/issueCoupon")
    public HttpResponseResult issueCoupon(@RequestBody Map<String, Object> param) {
        couponIssueRecordService.issueCoupon(param);
        return succeed();
    }

    /**
     * 检查撤销的优惠券
     *
     * @param param issueId发放记录id
     */
    @ApiOperation("检查撤销的优惠券")
    @PostMapping(value = "/checkRevoke")
    public HttpResponseResult checkRevoke(@RequestBody Map<String, Object> param) {
        Integer issueId = WrapperUtil.toInt(param, "issueId", "传入参数错误!");
        return succeed(couponIssueRecordService.checkRevoke(issueId));
    }

    /**
     * 撤销发放优惠券
     *
     * @param param issueId发放记录id
     */
    @ApiOperation("撤销发放优惠券")
    @PostMapping(value = "/revokeCoupon")
    public HttpResponseResult revokeCoupon(@RequestBody Map<String, Object> param) {
        Integer issueId = WrapperUtil.toInt(param, "issueId", "传入参数错误!");
        couponIssueRecordService.revokeCoupon(issueId);
        return succeed();
    }

    /**
     * 查询优惠券发放名单
     *
     * @param param issueId 发放记录id
     * @param param organId 分部id
     * @param param subjectId 声部id
     * @param param usageStatus 状态
     */
    @ApiOperation("查询优惠券发放名单")
    @PostMapping(value = "/queryIssueDetail")
    public HttpResponseResult queryIssueDetail(@RequestBody Map<String, Object> param) {
        return succeed(couponIssueRecordService.queryIssueDetail(param));
    }

    @ApiOperation("查询优惠券发放记录")
    @PostMapping(value = "/queryIssueRecord")
    public HttpResponseResult queryIssueRecord(@RequestBody Map<String, Object> param) {
        return succeed(couponIssueRecordService.queryIssueRecord(param));
    }

}

