// Path: tcc-transaction-api/src/main/java/org/pankai/tcctransaction/api/TransactionContext.java
// public class TransactionContext implements Serializable{
// 
//     private TransactionXid xid;
//     private int status;
// 
//     private Map<String,String> attachments = new ConcurrentHashMap<>();
// 
//     public TransactionContext(){
// 
//     }
// 
//     public TransactionContext(TransactionXid xid,int status){
//         this.xid = xid;
//         this.status = status;
//     }
// 
//     public TransactionXid getXid() {
//         return xid;
//     }
// 
//     public void setXid(TransactionXid xid) {
//         this.xid = xid;
//     }
// 
//     public int getStatus() {
//         return status;
//     }
// 
//     public void setStatus(int status) {
//         this.status = status;
//     }
// 
//     public Map<String, String> getAttachments() {
//         return attachments;
//     }
// 
//     public void setAttachments(Map<String, String> attachments) {
//         this.attachments = attachments;
//     }
// }
// 
// Path: tcc-transaction-tutorial-sample/tcc-transaction-sample/tcc-transaction-redpacket/src/main/java/org/pankai/tcctransaction/sample/external/dto/RedPacketTradeOrderDto.java
// public class RedPacketTradeOrderDto implements Serializable {
// 
//     private long selfUserId;
// 
//     private long oppositeUserId;
// 
//     private String orderTitle;
// 
//     private String merchantOrderNo;
// 
//     private BigDecimal amount;
// 
//     public long getSelfUserId() {
//         return selfUserId;
//     }
// 
//     public void setSelfUserId(long selfUserId) {
//         this.selfUserId = selfUserId;
//     }
// 
//     public long getOppositeUserId() {
//         return oppositeUserId;
//     }
// 
//     public void setOppositeUserId(long oppositeUserId) {
//         this.oppositeUserId = oppositeUserId;
//     }
// 
//     public String getOrderTitle() {
//         return orderTitle;
//     }
// 
//     public void setOrderTitle(String orderTitle) {
//         this.orderTitle = orderTitle;
//     }
// 
//     public String getMerchantOrderNo() {
//         return merchantOrderNo;
//     }
// 
//     public void setMerchantOrderNo(String merchantOrderNo) {
//         this.merchantOrderNo = merchantOrderNo;
//     }
// 
//     public BigDecimal getAmount() {
//         return amount;
//     }
// 
//     public void setAmount(BigDecimal amount) {
//         this.amount = amount;
//     }
// }
// 
// Path: tcc-transaction-tutorial-sample/tcc-transaction-sample/tcc-transaction-order/src/main/java/org/pankai/tcctransaction/sample/external/service/request/RedPacketTradeOrderRecordRequest.java
// public class RedPacketTradeOrderRecordRequest {
// 
//     private TransactionContext transactionContext;
//     private RedPacketTradeOrderDto redPacketTradeOrderDto;
// 
//     public TransactionContext getTransactionContext() {
//         return transactionContext;
//     }
// 
//     public void setTransactionContext(TransactionContext transactionContext) {
//         this.transactionContext = transactionContext;
//     }
// 
//     public RedPacketTradeOrderDto getRedPacketTradeOrderDto() {
//         return redPacketTradeOrderDto;
//     }
// 
//     public void setRedPacketTradeOrderDto(RedPacketTradeOrderDto redPacketTradeOrderDto) {
//         this.redPacketTradeOrderDto = redPacketTradeOrderDto;
//     }
// }


import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.pankai.tcctransaction.api.TransactionContext;
import org.pankai.tcctransaction.sample.external.dto.RedPacketTradeOrderDto;
import org.pankai.tcctransaction.sample.external.service.request.RedPacketTradeOrderRecordRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
package org.pankai.tcctransaction.sample.external.service;


/**
 * Created by pktczwd on 2016/12/19.
 */
@Component
public class RedPacketTradeOrderService {

    private static final Logger logger = LoggerFactory.getLogger(RedPacketTradeOrderService.class);

    @Autowired
    private CloseableHttpClient closeableHttpClient;
    @Autowired
    private ObjectMapper objectMapper;

    public String record(TransactionContext transactionContext, RedPacketTradeOrderDto tradeOrderDto) {
        logger.info("RedPacketTradeOrderService record method called.");
        logger.info("Transaction ID:" + transactionContext.getXid().toString());
        logger.info("Transaction status:" + transactionContext.getStatus());

        try {
// Path: tcc-transaction-api/src/main/java/org/pankai/tcctransaction/api/TransactionContext.java
// public class TransactionContext implements Serializable{
// 
//     private TransactionXid xid;
//     private int status;
// 
//     private Map<String,String> attachments = new ConcurrentHashMap<>();
// 
//     public TransactionContext(){
// 
//     }
// 
//     public TransactionContext(TransactionXid xid,int status){
//         this.xid = xid;
//         this.status = status;
//     }
// 
//     public TransactionXid getXid() {
//         return xid;
//     }
// 
//     public void setXid(TransactionXid xid) {
//         this.xid = xid;
//     }
// 
//     public int getStatus() {
//         return status;
//     }
// 
//     public void setStatus(int status) {
//         this.status = status;
//     }
// 
//     public Map<String, String> getAttachments() {
//         return attachments;
//     }
// 
//     public void setAttachments(Map<String, String> attachments) {
//         this.attachments = attachments;
//     }
// }
// 
// Path: tcc-transaction-tutorial-sample/tcc-transaction-sample/tcc-transaction-redpacket/src/main/java/org/pankai/tcctransaction/sample/external/dto/RedPacketTradeOrderDto.java
// public class RedPacketTradeOrderDto implements Serializable {
// 
//     private long selfUserId;
// 
//     private long oppositeUserId;
// 
//     private String orderTitle;
// 
//     private String merchantOrderNo;
// 
//     private BigDecimal amount;
// 
//     public long getSelfUserId() {
//         return selfUserId;
//     }
// 
//     public void setSelfUserId(long selfUserId) {
//         this.selfUserId = selfUserId;
//     }
// 
//     public long getOppositeUserId() {
//         return oppositeUserId;
//     }
// 
//     public void setOppositeUserId(long oppositeUserId) {
//         this.oppositeUserId = oppositeUserId;
//     }
// 
//     public String getOrderTitle() {
//         return orderTitle;
//     }
// 
//     public void setOrderTitle(String orderTitle) {
//         this.orderTitle = orderTitle;
//     }
// 
//     public String getMerchantOrderNo() {
//         return merchantOrderNo;
//     }
// 
//     public void setMerchantOrderNo(String merchantOrderNo) {
//         this.merchantOrderNo = merchantOrderNo;
//     }
// 
//     public BigDecimal getAmount() {
//         return amount;
//     }
// 
//     public void setAmount(BigDecimal amount) {
//         this.amount = amount;
//     }
// }
// 
// Path: tcc-transaction-tutorial-sample/tcc-transaction-sample/tcc-transaction-order/src/main/java/org/pankai/tcctransaction/sample/external/service/request/RedPacketTradeOrderRecordRequest.java
// public class RedPacketTradeOrderRecordRequest {
// 
//     private TransactionContext transactionContext;
//     private RedPacketTradeOrderDto redPacketTradeOrderDto;
// 
//     public TransactionContext getTransactionContext() {
//         return transactionContext;
//     }
// 
//     public void setTransactionContext(TransactionContext transactionContext) {
//         this.transactionContext = transactionContext;
//     }
// 
//     public RedPacketTradeOrderDto getRedPacketTradeOrderDto() {
//         return redPacketTradeOrderDto;
//     }
// 
//     public void setRedPacketTradeOrderDto(RedPacketTradeOrderDto redPacketTradeOrderDto) {
//         this.redPacketTradeOrderDto = redPacketTradeOrderDto;
//     }
// }


// Path: tcc-transaction-tutorial-sample/tcc-transaction-sample/tcc-transaction-order/src/main/java/org/pankai/tcctransaction/sample/external/service/RedPacketTradeOrderService.java
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.pankai.tcctransaction.api.TransactionContext;
import org.pankai.tcctransaction.sample.external.dto.RedPacketTradeOrderDto;
import org.pankai.tcctransaction.sample.external.service.request.RedPacketTradeOrderRecordRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

package org.pankai.tcctransaction.sample.external.service;


/**
 * Created by pktczwd on 2016/12/19.
 */
@Component
public class RedPacketTradeOrderService {

    private static final Logger logger = LoggerFactory.getLogger(RedPacketTradeOrderService.class);

    @Autowired
    private CloseableHttpClient closeableHttpClient;
    @Autowired
    private ObjectMapper objectMapper;

    public String record(TransactionContext transactionContext, RedPacketTradeOrderDto tradeOrderDto) {
        logger.info("RedPacketTradeOrderService record method called.");
        logger.info("Transaction ID:" + transactionContext.getXid().toString());
        logger.info("Transaction status:" + transactionContext.getStatus());

        try {
            RedPacketTradeOrderRecordRequest request = new RedPacketTradeOrderRecordRequest();