package shop.alien.store.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import shop.alien.entity.result.R;
import shop.alien.entity.store.vo.LifeUserExpertOrderVo;
import shop.alien.store.service.LifeUserExpertOrderService;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 达人订单表 前端控制器
 * </p>
 *
 * @author ssk
 * @since 2025-02-19
 */
@Api(tags = {"用户-达人订单管理"})
@Slf4j
@RestController
@CrossOrigin
@RequiredArgsConstructor
@RequestMapping("/lifeUserExpertOrder")
public class LifeUserExpertOrderController {

    private final LifeUserExpertOrderService lifeUserExpertOrderService;

    @ApiOperation("推广订单总计信息")
    @ApiOperationSupport(order = 1)
    @GetMapping("/getExpertOrderDetails")
    public R<List<LifeUserExpertOrderVo>> getExpertOrderDetails(@RequestParam("expertId") Long expertId) {
        log.info("StoreUserExpertOrderController.getExpertOrderDetails?id={}", expertId);
        return R.data(lifeUserExpertOrderService.getExpertOrderDetails(expertId));
    }

    @ApiOperation("推广订单信息列表")
    @ApiOperationSupport(order = 2)
    @GetMapping("/getPromotionOrderInfoList")
    public R<IPage<LifeUserExpertOrderVo>> getPromotionOrderInfoList(@RequestParam("expertId") Long expertId,@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int size){
        log.info("StoreUserExpertOrderController.getPromotionOrderInfoList?id={},page={},size={}", expertId, page, size);
        return R.data(lifeUserExpertOrderService.getPromotionOrderInfoList(expertId,page, size));
    }

    @ApiOperation("达人订单详情")
    @ApiOperationSupport(order = 3)
    @GetMapping("/fetchExpertOrderInfo")
    public R<List<Map<String, Object>>> fetchExpertOrderInfo(@RequestParam("expertId") Long expertId, @RequestParam("orderId") String orderId) {
        log.info("LifeUserExpertController.fetchExpertOrderInfo?expertId={},orderId={}", expertId, orderId);
        return R.data(lifeUserExpertOrderService.fetchExpertOrderInfo(expertId, orderId));
    }

    @ApiOperation("申请款项按钮")
    @ApiOperationSupport(order = 4)
    @GetMapping("/getApplicationFunds")
    public R<Map<String, Object>> getApplicationFunds( @RequestParam("buttonType") String buttonType,@RequestParam("buttonStatus") String buttonStatus,@RequestParam("orderNo") String orderNo,@RequestParam("userPhone") String userPhone) {
        log.info("LifeUserExpertController.getApplicationFunds?buttonType={},buttonStatus={},orderNo={},userPhone={}", buttonType, buttonStatus,orderNo, userPhone);
        return R.data(lifeUserExpertOrderService.getApplicationFunds(buttonType, buttonStatus, orderNo,userPhone));
    }



}
