package com.younike.wxpay.service.impl;

import com.younike.wxpay.params.ProfitSharingParams;
import com.younike.wxpay.responses.ProfitSharingResponse;
import com.younike.wxpay.responses.QuerySharingResponse;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

/**
 * 分账相关服务
 *
 * @author chenpengfei
 */
@Service
public class ProfitSharingServiceImpl extends BasePayServiceImpl {

    @PostConstruct
    public void setup() {
        super.setup(PaymentConfig.builder()
                .isSupplier(true)
                .mchId("1552257391")
                .appId("wxcc56354382c8f8b4")
                .mchSerialNo("6B9A4B7AFDD4BE5213B68564252CCA5A126401DD")
                .apiV3Key("olJz7dYC7GbikgTw0QwTAmAjlFc7az9p")
                .certificatesPath("certs/uxx-supplier")
                .build());
    }

    /**
     * 发起分账请求
     *
     * @param params     分账参数
     * @return 分账结果
     */
    @Override
    public ProfitSharingResponse profitSharing(ProfitSharingParams params) {
        params.setAppid(config.appId);
        return super.profitSharing(params);
    }

    /**
     * 查询分账结果
     *
     * @param outTradeNo 商户分账单号
     */
    @Override
    public QuerySharingResponse querySharing(String outTradeNo, String transactionId, String subMchid) {
        return super.querySharing(outTradeNo,transactionId,subMchid);
    }

}
