package cn.iocoder.yudao.module.custom.controller.admin;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.custom.entity.CustomerActive;
import cn.iocoder.yudao.module.custom.service.CustomerBalanceService;
import cn.iocoder.yudao.module.custom.vo.CustomerActiveRespVO;
import cn.iocoder.yudao.module.custom.vo.CustomerBalanceSaveReqVO;
import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 用户积分（余额）")
@RestController
@RequestMapping("/base/customer-balance")
@Validated
public class CustomerBalanceController {

    @Resource
    private CustomerBalanceService customerBalanceService;

//    /**
//     * 更新用户余额信息(充值完成的回调)
//     * @author PQZ
//     * @date 21:42 2024/9/23
//     * @param createReqVO CustomerBalanceSaveReqVO
//     * @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.Boolean>
//    **/
//    @PostMapping("/saveBalance")
//    @Operation(summary = "创建用户积分（余额）")
//    @PreAuthorize("@ss.hasPermission('base:customer-balance:create')")
//    public CommonResult<Boolean> saveBalance(@RequestBody CustomerBalanceSaveReqVO createReqVO) {
//        customerBalanceService.saveBalance(createReqVO.getCusId(),createReqVO.getOrderId(),createReqVO.getActiveId());
//        return success(true);
//    }


    @PostMapping("/create")
    @Operation(summary = "创建用户积分（余额）")
    @PreAuthorize("@ss.hasPermission('base:customer-balance:create')")
    public CommonResult<String> createCustomerBalance(@Valid @RequestBody CustomerBalanceSaveReqVO createReqVO) {
        return success(customerBalanceService.createCustomerBalance(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新用户积分（余额）")
    @PreAuthorize("@ss.hasPermission('base:customer-balance:update')")
    public CommonResult<Boolean> updateCustomerBalance(@Valid @RequestBody CustomerBalanceSaveReqVO updateReqVO) {
        customerBalanceService.updateCustomerBalance(updateReqVO);
        return success(true);
    }



}