package com.bonus.canteen.core.account.v3.api;

import cn.hutool.json.JSONUtil;
import com.bonus.canteen.core.account.v3.service.AccExceptionRecordService;
import com.bonus.canteen.core.account.v3.service.AccTradeWalletDetailService;
import com.bonus.canteen.core.account.v3.web.dto.AccAddExceptionRecordDTO;
import com.bonus.canteen.core.account.v3.web.dto.AccUpdateExceptionRecordDTO;
import com.bonus.canteen.core.account.v3.web.vo.AccOrdTradeVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class AccBusinessApi {
   private static final Logger log = LoggerFactory.getLogger(AccBusinessApi.class);
   @Resource
   @Lazy
   private AccExceptionRecordService accExceptionRecordService;
   @Autowired
   @Lazy
   private AccTradeWalletDetailService accTradeWalletDetailService;

   public void addAccExceptionRecord(AccAddExceptionRecordDTO addDTO) {
      this.accExceptionRecordService.addAccExceptionRecord(addDTO);
   }

   public void updateAccExceptionRecord(AccUpdateExceptionRecordDTO updateDTO) {
      this.accExceptionRecordService.updateAccExceptionRecord(updateDTO);
   }

   public boolean existExceptionRecordByRelatedId(Long relatedId, Integer recordStatus) {
      return this.accExceptionRecordService.existExceptionRecordByRelatedId(relatedId, recordStatus);
   }

   public AccOrdTradeVO queryTradeDetailByOrderId(Long orderId) {
      AccOrdTradeVO accOrdTradeVO = this.accTradeWalletDetailService.queryAccTradeOrderDetailByLeOrderNo(orderId);
      log.info("根据订单id查询交易明细,orderId_{},trade={}", orderId, JSONUtil.toJsonStr(accOrdTradeVO));
      return accOrdTradeVO;
   }

}
