package org.jeecg.modules.apiservice.impl;

import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.apiservice.LoginApiService;
import org.jeecg.modules.bean.LoginReq;
import org.jeecg.modules.cheerConf.entity.CheerConf;
import org.jeecg.modules.cheerConf.service.ICheerConfService;
import org.jeecg.modules.cheerRecharge.entity.CheerRecharge;
import org.jeecg.modules.cheerRecharge.service.ICheerRechargeService;
import org.jeecg.modules.service.AppletLoginService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class LoginApiServiceImpl implements LoginApiService {

    @Resource
    private AppletLoginService appletLoginService;
    @Resource
    private ICheerConfService cheerConfService;
    @Resource
    private ICheerRechargeService cheerRechargeService;

    //小程序-登录接口
    @Override
    public Result<?> login(LoginReq loginReq)
    {
        return appletLoginService.appletLogin(loginReq);
    }


    //小程序-获取用户协议
    @Override
    public Result<?> getUserAgreement()
    {

        return Result.OK("用户协议");
    }

    //获取隐私政策
    @Override
    public Result<?> getPrivacyPolicy()
    {

        return Result.OK("隐私政策");
    }


    //获取联系电话
    @Override
    public Result<?> getPhone(){
        CheerConf one = cheerConfService.lambdaQuery()
                .eq(CheerConf::getKeyValue, "phone")
                .one();

        return Result.OK("电话",one.getKeyCentent());
    }

    //获取联系微信
    @Override
    public Result<?> getWechat(){
        CheerConf one = cheerConfService.lambdaQuery()
                .eq(CheerConf::getKeyValue, "wx")
                .one();

        return Result.OK("微信",one.getKeyCentent());
    }

    //获取折扣
    @Override
    public Result<?> getDiscount(){
        CheerConf one = cheerConfService.lambdaQuery()
                .eq(CheerConf::getKeyValue, "preferential")
                .one();

        return Result.OK("折扣",one.getKeyCentent());
    }


    //获取套餐列表
    @Override
    public Result<?> getPackageList(){
        List<CheerRecharge> list = cheerRechargeService.lambdaQuery()
                .orderByDesc(CheerRecharge::getCreateTime)
                .list();
        return Result.OK("套餐列表",list);
    }







}
