package com.fs.app.controller.app;

import com.fs.app.annotation.Login;
import com.fs.app.controller.AppBaseController;
import com.fs.common.annotation.RepeatSubmit;
import com.fs.common.core.domain.R;
import com.fs.his.enums.PaymentMethodEnum;
import com.fs.his.param.FsIntegralOrderDoPayParam;
import com.fs.his.param.FsUserAddIntegralTemplateParam;
import com.fs.his.service.IFsUserIntegralLogsService;
import com.fs.hisStore.service.IFsStoreOrderScrmService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: APP 相关接口
 * @author: Xgb
 * @createDate: 2026/2/3
 * @version: 1.0
 */
@Api("app登录接口")
@RestController
@RequestMapping(value = "/app/api")
@Slf4j
public class AppController extends AppBaseController {

    @Autowired
    private IFsUserIntegralLogsService userIntegralLogsService;

    @Autowired
    private IFsStoreOrderScrmService fsStoreOrderScrmService;

    /**
     * @Description: APP 获取积分  28-下载
     * @Param:
     * @Return:
     * @Author xgb
     * @Date 2026/2/3 11:06
     */
    @ApiOperation("添加积分")
    @Login
    @PostMapping("/addIntegral")
    public R addIntegral(@RequestBody FsUserAddIntegralTemplateParam param) {
        param.setUserId(Long.parseLong(getUserId()));
        return userIntegralLogsService.addIntegralTemplate(param);
    }


    @Login
    @RepeatSubmit
    @ApiOperation("支付宝支付")
    @PostMapping("/aliPayment")
    public R aliPayment(@Validated @RequestBody FsIntegralOrderDoPayParam param) {
        param.setUserId(Long.parseLong(getUserId()));
        return fsStoreOrderScrmService.payment(param, PaymentMethodEnum.ALIPAY);
    }


    @Login
    @RepeatSubmit
    @ApiOperation("微信支付")
    @PostMapping("/wxPayment")
    public R wxPayment(@Validated @RequestBody FsIntegralOrderDoPayParam param) {
        param.setUserId(Long.parseLong(getUserId()));
        return fsStoreOrderScrmService.payment(param, PaymentMethodEnum.WX_APP);
    }
}
