package com.zanxiang.game.module.manage.rpc.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zanxiang.game.module.base.rpc.IPayBoxRpc;
import com.zanxiang.game.module.manage.service.IAppletCheckService;
import com.zanxiang.game.module.manage.service.IPayApplicationService;
import com.zanxiang.game.module.mybatis.entity.PayApplication;
import com.zanxiang.module.util.pojo.ResultVO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author : lingfeng
 * @time : 2024-01-16
 * @description : 支付盒子
 */
@DubboService
public class PayBoxRpcImpl implements IPayBoxRpc {

    @Autowired
    private IAppletCheckService appletCheckService;

    @Autowired
    private IPayApplicationService payApplicationService;

    @Override
    public ResultVO<Boolean> payBoxBan(String appId) {
        PayApplication payApplication = payApplicationService.getOne(new LambdaQueryWrapper<PayApplication>()
                .eq(PayApplication::getAppId, appId));
        if (payApplication == null) {
            return ResultVO.ok(Boolean.FALSE);
        }
        appletCheckService.payApplicationCheck(payApplication);
        return ResultVO.ok(Boolean.TRUE);
    }
}
