package com.ywt.alipaympapi.face.impl;

import com.alibaba.fastjson.JSONObject;
import com.alipay.api.domain.CommerceAppUploadRequestContent;
import com.alipay.api.request.AlipayCommerceAppAuthUploadRequest;
import com.alipay.api.response.AlipayCommerceAppAuthUploadResponse;
import com.ywt.alipaympapi.face.IAlipayService;
import com.ywt.alipaympapi.face.IHospitalSendFace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class HospitalSendFace implements IHospitalSendFace {
    @Autowired
    private IAlipayService alipayService;

    @Override
    public AlipayCommerceAppAuthUploadResponse hospitalOrder(String appId, String targetId, String tenantAppId, JSONObject json_body) {
        AlipayCommerceAppAuthUploadRequest request = new AlipayCommerceAppAuthUploadRequest();
        request.setServiceName("alipay.commerce.app.data");//应用服务名称 固定值 String(256) 不可空
        request.setTargetId(targetId); //目标用户 String(64) 支付宝用户 PID 不可空

        CommerceAppUploadRequestContent content = new CommerceAppUploadRequestContent(); //服务数据参数
        content.setTenantAppId(tenantAppId); //租户应 用ID String(64) 支付宝分配 不可空
        content.setActivityId("upload_hospital_order"); //业务流程ID String(64) 不可空 此处固定为“upload_hospital_order”

        content.setBody(JSONObject.toJSONString(json_body));
        request.setContent(content);

        System.out.println("入参 == " + JSONObject.toJSONString(request));

        return alipayService.execute(appId, request);
    }
}
