package com.jeequan.jeepay.member.ctrl.member;

import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.core.model.QRCodeParams;
import com.jeequan.jeepay.core.model.context.MchAppConfigContext;
import com.jeequan.jeepay.db.entity.MemberInfo;
import com.jeequan.jeepay.member.ctrl.CommonCtrl;
import com.jeequan.jeepay.service.impl.MemberInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* 会员服务入口controller
*
* @author zx
* @date 2023/4/12 17:27
*/
@RestController
@RequestMapping("/api/member")
public class MemberInfoController extends CommonCtrl {

    @Autowired private MemberInfoService memberInfoService;

    /**
     * 获取会员信息
     */
    @GetMapping
    public ApiRes memberInfo() {

        // token转换对象
        QRCodeParams qrCodeParams = tokenConvert();

        // 获取商户配置信息
        MchAppConfigContext mchAppConfigContext = getQrParamsMchAppConfigContext(qrCodeParams, false);

        // 查询会员信息
        MemberInfo memberInfo = memberInfoService.selectOne(mchAppConfigContext.getMchNo(), getCurrentMbrId());
        memberInfo.setWxMpOpenId(null);
        memberInfo.setWxLiteOpenId(null);
        memberInfo.setAliUserId(null);
        memberInfo.setYsfUserId(null);

        return ApiRes.ok(memberInfo);
    }


}
