package com.jeequan.jeepay.mgr.ctrl.account;

import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.ApiField;
import com.jeequan.jeepay.JeepayClient;
import com.jeequan.jeepay.components.mq.model.AccountBalanceMQ;
import com.jeequan.jeepay.components.mq.vender.IMQSender;
import com.jeequan.jeepay.core.cache.RedisUtil;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.entity.AccountOperate;
import com.jeequan.jeepay.core.entity.SysUser;
import com.jeequan.jeepay.core.exception.BizException;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.core.model.DBApplicationConfig;
import com.jeequan.jeepay.core.model.DBDefaultConfig;
import com.jeequan.jeepay.core.utils.SeqKit;
import com.jeequan.jeepay.db.entity.*;
import com.jeequan.jeepay.exception.JeepayException;
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.model.DeviceInfo;
import com.jeequan.jeepay.model.JeepayObject;
import com.jeequan.jeepay.request.PayOrderCreateRequest;
import com.jeequan.jeepay.response.PayOrderCreateResponse;
import com.jeequan.jeepay.service.impl.*;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

/**
 * TODO
 *
 * @author crystal
 * @date 2023/12/6 15:11
 */
@RestController
@RequestMapping("/api/account")
public class AccountInfoController extends CommonCtrl {

    @Autowired private AccountInfoService accountInfoService;
    @Autowired private PayOrderService payOrderService;

    /**
     * 获取订单关联的参数
     * @return
     */
    @GetMapping("/{payOrderId}")
    public ApiRes getOrderAccount(@PathVariable("payOrderId") String payOrderId) {
        AccountInfo info = getObject(AccountInfo.class);
        PayOrder order = payOrderService.getById(payOrderId);
        if(order == null){
            throw new BizException("非法参数");
        }
        List<AccountInfo> res = accountInfoService.getAccountInfo(info,order.getMchNo());
        return ApiRes.ok(res);
    }
}
