package com.czg.controller.user;

import com.czg.market.service.MkShopRechargeService;
import com.czg.market.vo.MkShopRechargeShopListVO;
import com.czg.market.vo.MkShopRechargeVO;
import com.czg.market.vo.RechargeListVO;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
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;

/**
 * 充值相关
 *
 * @author Administrator
 */
@RestController
@RequestMapping("/user/recharge")
public class URechargeController {
    @Resource
    private MkShopRechargeService shopRechargeService;

    /**
     * 获取充值配置
     * @param shopId 店铺id
     */
    @GetMapping("/config")
    public CzgResult<MkShopRechargeVO> getConfig(@RequestParam Long shopId) {
        return CzgResult.success(shopRechargeService.detail(shopId));
    }

    /**
     * 可用店铺列表
     * @param shopId 店铺id
     */
    @GetMapping("/config/shopList")
    public CzgResult<List<MkShopRechargeShopListVO>> shopList(@RequestParam Long shopId, @RequestParam(required = false) String shopName) {
        return CzgResult.success(shopRechargeService.shopList(shopId, shopName));
    }

    /**
     * 充值列表
     */
    @GetMapping("/list")
    public CzgResult<List<RechargeListVO>> getList() {
        return CzgResult.success(shopRechargeService.getList(StpKit.USER.getLoginIdAsLong()));
    }

}
