package com.gree.mall.manager.controller.activity;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gree.mall.manager.bean.activity.PromotionGroupBean;
import com.gree.mall.manager.bean.activity.PromotionGroupList;
import com.gree.mall.manager.helper.ResponseHelper;
import com.gree.mall.manager.logic.activity.PromotionGroupLogic;
import com.gree.mall.manager.logic.activity.PromotionGroupUserLogic;
import com.gree.mall.manager.plus.entity.PromotionGroupSpecUser;
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 java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@Api(value = "团购团长管理", tags ={"团购团长管理"} )
@RequestMapping(value = "/promotion/user", produces = "application/json; charset=utf-8")
public class PromotionGroupUserController {

    @Autowired
    PromotionGroupUserLogic promotionGroupUserLogic;

    @GetMapping("/list")
    @ApiOperation(value = "团购活动列表")
    public ResponseHelper page(
            @ApiParam(value = "团购商品规格id") @RequestParam(required = false) String promotionGroupSpecId,
            @ApiParam(value = "名称") @RequestParam(required = false) String name,
            @ApiParam(value = "手机号") @RequestParam(required = false) String phone,
            @ApiParam(value = "团购价") @RequestParam(required = false) BigDecimal groupPrice,
            @ApiParam(value = "分享金额") @RequestParam(required = false) BigDecimal shareAmount
    ) throws Exception {
        List<PromotionGroupSpecUser> list = promotionGroupUserLogic.list(promotionGroupSpecId, name, phone, groupPrice, shareAmount);
        return ResponseHelper.success(list);
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改团购价")
    public ResponseHelper update(
            @RequestBody List<PromotionGroupSpecUser> specUserList
    ) throws Exception {
        promotionGroupUserLogic.update(specUserList);
        return ResponseHelper.success(specUserList);
    }


}
