package com.red.circle.other.app.inner.endpoint.team;

import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.inner.service.team.TeamBillCycleClientService;
import com.red.circle.other.app.inner.service.team.UserBillDiamondBalanceClientService;
import com.red.circle.other.infra.database.rds.entity.team.BillDiamondBalance;
import com.red.circle.other.inner.endpoint.team.target.api.UserBillDiamondBalanceClientApi;
import com.red.circle.other.inner.model.dto.agency.agency.BillDiamondBalanceDTO;
import com.red.circle.tool.core.tuple.PennyAmount;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * 用户账单钻石余额.
 *
 * @author xiaofei on 2024/05/07
 */
@Validated
@RestController
@RequestMapping(value = UserBillDiamondBalanceClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class UserBillDiamondBalanceClientEndpoint implements UserBillDiamondBalanceClientApi {

  private final UserBillDiamondBalanceClientService userBillDiamondBalanceClientService;

  @Override
  public ResultResponse<BillDiamondBalanceDTO> getEntityByBillBelongAndUserId(String sysOrigin, Integer billBelong, Long userId) {
    return ResultResponse.success(userBillDiamondBalanceClientService.getEntityByBillBelongAndUserId(sysOrigin, billBelong, userId));
  }

  @Override
  public ResultResponse<BillDiamondBalanceDTO> decr(Long userId, Integer billBelong, BigDecimal amount) {
    return ResultResponse.success(userBillDiamondBalanceClientService.decr(userId, billBelong, amount));
  }

  @Override
  public ResultResponse<BillDiamondBalanceDTO> decrAgent(Long userId, Integer billBelong, BigDecimal amount) {
    return ResultResponse.success(userBillDiamondBalanceClientService.decrAgent(userId, billBelong, amount));
  }


}
