package com.jeesharp.business.setting.controller;

import com.jeesharp.business.modules.setting.application.MarketingActivityApplicationService;
import com.jeesharp.business.modules.setting.vo.MarketingActivityListVO;
import com.jeesharp.business.modules.setting.vo.MarketingActivityMobileDetailVO;
import com.jeesharp.business.modules.setting.vo.MarketingPosterTemplateVO;
import com.jeesharp.business.modules.setting.vo.MarketingShareConfigVO;
import com.jeesharp.business.modules.setting.vo.PromotionGiftConfigVO;
import com.jeesharp.business.modules.setting.vo.ShareCommissionConfigVO;
import com.jeesharp.framework.pojo.AjaxResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("${jeesharp.web.mobilePath}/marketing")
@Tag(name = "小程序-活动营销")
@AllArgsConstructor
public class MarketingMobileController {

    private final MarketingActivityApplicationService marketingActivityApplicationService;

    @Operation(summary = "活动列表")
    @GetMapping("/activity/list")
    public AjaxResult<List<MarketingActivityListVO>> list(@RequestParam(value = "scene", required = false) String scene,
                                                          @RequestParam(value = "activityType", required = false) String activityType,
                                                          @RequestParam(value = "status", required = false) String status) {
        return AjaxResult.okData(marketingActivityApplicationService.listForMobile(scene, activityType, status));
    }

    @Operation(summary = "活动详情")
    @GetMapping("/activity/detail/{id}")
    public AjaxResult<MarketingActivityMobileDetailVO> detail(@PathVariable("id") String id) {
        return AjaxResult.okData(marketingActivityApplicationService.getMobileDetail(id));
    }

    @Operation(summary = "活动分享配置")
    @GetMapping("/activity/share-config")
    public AjaxResult<MarketingShareConfigVO> shareConfig(@RequestParam("activityId") String activityId,
                                                          @RequestParam(value = "scene", required = false) String scene,
                                                          @RequestParam(value = "bizType", required = false) String bizType,
                                                          @RequestParam(value = "bizId", required = false) String bizId) {
        return AjaxResult.okData(marketingActivityApplicationService.getShareConfig(activityId, scene, bizType, bizId));
    }

    @Operation(summary = "推广有礼说明")
    @GetMapping("/promotion-gift/detail")
    public AjaxResult<PromotionGiftConfigVO> promotionGiftDetail(@RequestParam(value = "activityId", required = false) String activityId,
                                                                 @RequestParam(value = "scene", required = false) String scene) {
        return AjaxResult.okData(marketingActivityApplicationService.getPromotionGiftDetail(activityId, scene));
    }

    @Operation(summary = "分享返佣说明")
    @GetMapping("/share-commission/detail")
    public AjaxResult<ShareCommissionConfigVO> shareCommissionDetail(@RequestParam(value = "activityId", required = false) String activityId,
                                                                     @RequestParam(value = "bizType", required = false) String bizType,
                                                                     @RequestParam(value = "bizId", required = false) String bizId) {
        return AjaxResult.okData(marketingActivityApplicationService.getShareCommissionDetail(activityId, bizType, bizId));
    }

    @Operation(summary = "营销海报模板")
    @GetMapping("/poster/template")
    public AjaxResult<MarketingPosterTemplateVO> posterTemplate(@RequestParam(value = "activityId", required = false) String activityId,
                                                                @RequestParam(value = "templateType", required = false) String templateType,
                                                                @RequestParam(value = "scene", required = false) String scene) {
        return AjaxResult.okData(marketingActivityApplicationService.getPosterTemplate(activityId, templateType, scene));
    }
}
