package com.yiqi.api.controller.activity;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yiqi.common.exception.ServiceException;
import com.yiqi.activity.domain.ActivityCouponInfo;
import com.yiqi.activity.domain.ActivityInfo;
import com.yiqi.activity.domain.dto.weapp.WeAppActivityCouponQueryDTO;
import com.yiqi.activity.domain.dto.weapp.WeAppActivityRechargeQueryDTO;
import com.yiqi.activity.domain.vo.ActivityCouponItemVO;
import com.yiqi.activity.domain.vo.ActivityRechargeItemVO;
import com.yiqi.activity.domain.vo.weapp.WeAppActivityCouponInfoVO;
import com.yiqi.activity.domain.vo.weapp.WeAppActivityCouponQueryVO;
import com.yiqi.activity.domain.vo.weapp.WeAppActivityRechargeInfoVO;
import com.yiqi.activity.domain.vo.weapp.WeAppActivityRechargeQueryVO;
import com.yiqi.activity.service.IActivityCouponInfoService;
import com.yiqi.activity.service.IActivityCouponItemService;
import com.yiqi.activity.service.IActivityInfoService;
import com.yiqi.activity.service.IActivityRechargeItemService;
import com.yiqi.app.domain.AppUser;
import com.yiqi.app.service.IAppUserService;
import com.yiqi.common.constant.UrlConstants;
import com.yiqi.common.core.controller.BaseController;
import com.yiqi.common.core.domain.AuthHolder;
import com.yiqi.common.core.domain.R;
import com.yiqi.common.enums.OrderActivityStatusType;
import com.yiqi.common.enums.StatusType;
import com.yiqi.common.enums.SysBoolType;
import com.yiqi.order.domain.OrderActivity;
import com.yiqi.order.service.IOrderActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.stream.Collectors;

@Api(tags = "app充值活动")
@RestController
@RequestMapping(value = UrlConstants.wxappApi + "/activity/recharge")
public class WeAppActivityRechargeController extends BaseController {

    @Autowired
    private IActivityInfoService activityInfoService;
    @Autowired
    private IActivityRechargeItemService activityRechargeItemService;
    /**
     * 查询充值活动列表
     */
    @PostMapping("/findPage")
    @ApiOperation(value = "查询充值活动列表")
    public R<List<WeAppActivityRechargeQueryVO>> findPage(@RequestBody WeAppActivityRechargeQueryDTO weAppActivityRechargeQueryDTO) {
        List<WeAppActivityRechargeQueryVO> list = activityInfoService.selectActivityRechargeList(weAppActivityRechargeQueryDTO);
        return R.ok(list);
    }

    /**
     * 查询充值活动明细
     */
    @GetMapping("/getInfoActivityId")
    @ApiOperation(value = "查询充值活动明细")
    public R<WeAppActivityRechargeInfoVO> getInfoActivityId(@RequestParam Long activityId) {
        WeAppActivityRechargeInfoVO weAppActivityRechargeInfoVO = new WeAppActivityRechargeInfoVO();
        ActivityInfo activityInfo = activityInfoService.getOne(new QueryWrapper<ActivityInfo>()
                .lambda().eq(ActivityInfo::getId,activityId));
        BeanUtils.copyProperties(activityInfo,weAppActivityRechargeInfoVO);

        List<ActivityRechargeItemVO> list = activityRechargeItemService.getRechargeActivityItemInfo(activityId);
        weAppActivityRechargeInfoVO.setActivityRechargeItemVOList(list);
        return R.ok(weAppActivityRechargeInfoVO);
    }
}









