package com.gree.mall.miniapp.controller.acitivy;

import com.gree.mall.miniapp.bean.order.OrderBuyBean;
import com.gree.mall.miniapp.helper.ResponseHelper;
import com.gree.mall.miniapp.logic.acitivy.PromotionApplyLogic;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@Slf4j
@RestController
@Api(value = "优惠申请API", tags ={"优惠申请API"} )
@RequestMapping(value = "/promotion/apply", produces = "application/json; charset=utf-8")
public class PromotionApplyController {

    @Autowired
    PromotionApplyLogic promotionApplyLogic;


    @PostMapping("/apply")
    @ApiOperation(value = "申请优惠价格")
    public ResponseHelper page(
            @ApiParam(value = "昵称手机号",required = true) @RequestBody OrderBuyBean orderBuyBean,
            HttpServletRequest request
    ) throws Exception {
        promotionApplyLogic.apply(orderBuyBean,request);
        return ResponseHelper.success();
    }


    @PostMapping("/examine")
    @ApiOperation(value = "审核优惠价格")
    public ResponseHelper examine(
            @ApiParam(value = "订单号",required = true) @RequestParam String orderId,
            @ApiParam(value = "审核结果 true=通过 false=驳回",required = true) @RequestParam Boolean examineReuslt,
            @ApiParam(value = "驳回原因",required = false) @RequestParam(required = false) String promotionApplyRejectRemmark,
            HttpServletRequest request
    ) throws Exception {
        promotionApplyLogic.examine(orderId,examineReuslt,promotionApplyRejectRemmark,request);
        return ResponseHelper.success();
    }


}
