package com.kym.miniapp.controller;

import com.kym.common.R;
import com.kym.entity.admin.queryParams.CommonQueryParam;
import com.kym.service.miniapp.AccountService;
import com.kym.service.miniapp.RefundLogService;
import com.kym.service.miniapp.WalletDetailService;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户账户表 前端控制器
 * </p>
 *
 * @author skyline
 * @since 2023-08-07
 */
@RestController
@RequestMapping("/account/")
public class AccountController {

    private final AccountService accountService;

    private final WalletDetailService walletDetailService;

    private final RefundLogService refundLogService;

    public AccountController(AccountService accountService, WalletDetailService walletDetailService, RefundLogService refundLogService) {
        this.accountService = accountService;
        this.walletDetailService = walletDetailService;
        this.refundLogService = refundLogService;
    }

    /**
     * 钱包明细
     *
     * @param type
     * @return
     */
    @GetMapping("/walletDetail")
    public R<?> walletDetail(@RequestParam(name = "type", defaultValue = "0", required = false) int type) {
        return R.success(walletDetailService.listWalletDetail(type));
    }

    @PostMapping("/listRefund")
    public R<?> listRefund(@RequestBody CommonQueryParam params) {
        return R.success(refundLogService.listRefundLogForApp(params));
    }


    /**
     * 获取当前用户有效的权益和优惠券
     *
     * @return
     */
    @GetMapping("/listRightsAndCoupons")
    public R<?> listRightsAndCoupons() {
        return R.success(accountService.listRightsAndCoupons());
    }

    /**
     * 获取当前用户当前站点有效的权益和优惠券
     *
     * @return
     */
    @GetMapping("/listStationAvailableRightsAndCoupons")
    public R<?> listStationAvailableRightsAndCoupons(@RequestParam(value = "stationId") String stationId) {
        return R.success(accountService.listStationAvailableRightsAndCoupons(stationId));
    }

}
