package com.ylx.shoppingfunds.controller;

import com.ylx.common.core.domain.R;
import com.ylx.massage.service.TWxUserService;
import com.ylx.shoppingfunds.domain.dto.MyShoppingFundsUpdateDto;
import com.ylx.shoppingfunds.domain.vo.MyShoppingFundsQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 类描述：我的购物金
 *
 * @author Administrator
 * @version 1.0
 * @date 2026/6/1 8:53
 */
@RestController
@RequestMapping("/shoppingFunds")
@Api(tags = {"我的购物金"})
@Slf4j
public class MyShoppingFundsController {
    @Resource
    private TWxUserService wxUserService;


    @ApiOperation("查询我的购物金剩余")
    @GetMapping(value="queryMyShoppingFunds")
    public R<MyShoppingFundsQueryVo> queryMyShoppingFunds(@RequestParam("userId")String userId) {
        return R.ok(wxUserService.queryMyShoppingFunds(userId));
    }

    @ApiOperation("更新购物金")
    @PostMapping(value="updateMyShoppingFunds")
    public R<?> updateMyShoppingFunds(@Validated  @RequestBody MyShoppingFundsUpdateDto myShoppingFundsUpdateDto) {
       wxUserService.updateMyShoppingFunds(myShoppingFundsUpdateDto.getWxUserId(), myShoppingFundsUpdateDto.getAmount(), myShoppingFundsUpdateDto.getExpenseType());
        return R.ok();
    }

}