package com.bonus.core.auth.mobile.alipay.service.impl;
import com.bonus.core.allocation.api.AllocMetadataApi;
import com.bonus.core.auth.mobile.alipay.service.AliPayService;
import com.bonus.core.common.thirdutils.alipay.AliPayUtil;
import com.bonus.core.common.thirdutils.alipay.model.AlipayReq;
import com.sun.org.slf4j.internal.Logger;
import com.sun.org.slf4j.internal.LoggerFactory;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class AliPayServiceImpl implements AliPayService {
   private static final Logger log = LoggerFactory.getLogger(AliPayServiceImpl.class);
   @Resource
   private AliPayUtil aliPayUtil;
   @Resource
   @Lazy
   private AllocMetadataApi allocMetadataApi;

   @Override
   public String paymentCodeDecod(String authCode) {
      AlipayReq alipayReq = this.getAlipayReq();
      return this.aliPayUtil.paymentCodeDecod(authCode, alipayReq);
   }

   private AlipayReq getAlipayReq() {
      return this.allocMetadataApi.checkAndCreateAlipayReq();
   }

}
