|
|
@ -2,6 +2,9 @@ package com.hfkj.openapi.v1.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.hfkj.channel.lakala.LaKaLaTradeService; |
|
|
|
import com.hfkj.channel.lakala.LaKaLaTradeService; |
|
|
|
|
|
|
|
import com.hfkj.common.exception.ErrorCode; |
|
|
|
|
|
|
|
import com.hfkj.common.exception.ErrorHelp; |
|
|
|
|
|
|
|
import com.hfkj.common.exception.SysCode; |
|
|
|
import com.hfkj.entity.BsTradeOrder; |
|
|
|
import com.hfkj.entity.BsTradeOrder; |
|
|
|
import com.hfkj.entity.BsTradeOrderExample; |
|
|
|
import com.hfkj.entity.BsTradeOrderExample; |
|
|
|
import com.hfkj.entity.BsTradeOrderRefund; |
|
|
|
import com.hfkj.entity.BsTradeOrderRefund; |
|
|
@ -13,12 +16,14 @@ import com.hfkj.service.BsMerKeyService; |
|
|
|
import com.hfkj.service.BsTradeOrderRefundService; |
|
|
|
import com.hfkj.service.BsTradeOrderRefundService; |
|
|
|
import com.hfkj.service.BsTradeOrderService; |
|
|
|
import com.hfkj.service.BsTradeOrderService; |
|
|
|
import com.hfkj.sysenum.TradeOrderRefundStatusEnum; |
|
|
|
import com.hfkj.sysenum.TradeOrderRefundStatusEnum; |
|
|
|
|
|
|
|
import com.hfkj.sysenum.TradeOrderStatusEnum; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -65,28 +70,47 @@ public class OpenApiTradeOrderServiceImpl implements OpenApiTradeOrderService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public ResponseRefundTradeModel refund(RequestRefundTradeModel refundTrade) { |
|
|
|
public ResponseRefundTradeModel refund(RequestRefundTradeModel refundTrade) throws Exception { |
|
|
|
|
|
|
|
// 查询交易订单
|
|
|
|
|
|
|
|
BsTradeOrder tradeOrder = getOrderByOutTradeNo(refundTrade.getOutTradeNo()); |
|
|
|
/* BsTradeOrderRefund orderRefund = new BsTradeOrderRefund(); |
|
|
|
if (tradeOrder == null) { |
|
|
|
orderRefund.setTradeOrderId(order.getId()); |
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "未知的交易订单"); |
|
|
|
orderRefund.setOutTradeNo(order.getOutTradeNo()); |
|
|
|
} |
|
|
|
orderRefund.setTradeOrderId(order.getId()); |
|
|
|
if (!tradeOrder.getStatus().equals(TradeOrderStatusEnum.status3.getNumber())) { |
|
|
|
orderRefund.setAgentId(order.getAgentId()); |
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "交易订单状态不处于已支付"); |
|
|
|
orderRefund.setSalesmanId(order.getSalesmanId()); |
|
|
|
} |
|
|
|
orderRefund.setMerId(order.getMerId()); |
|
|
|
|
|
|
|
orderRefund.setStoreId(order.getStoreId()); |
|
|
|
BsTradeOrderRefund orderRefund = new BsTradeOrderRefund(); |
|
|
|
orderRefund.setPlatformType(order.getPlatformType()); |
|
|
|
orderRefund.setSalesmanId(tradeOrder.getSalesmanId()); |
|
|
|
orderRefund.setRefundNo(refundNo); |
|
|
|
orderRefund.setAgentId(tradeOrder.getAgentId()); |
|
|
|
orderRefund.setTotalAmount(order.getTradeAmount()); |
|
|
|
orderRefund.setMerId(tradeOrder.getMerId()); |
|
|
|
orderRefund.setRefundAmount(body.getBigDecimal("refundAmount")); |
|
|
|
orderRefund.setStoreId(tradeOrder.getStoreId()); |
|
|
|
orderRefund.setRefundReason(body.getString("refundReason")); |
|
|
|
|
|
|
|
|
|
|
|
orderRefund.setPlatformType(tradeOrder.getPlatformType()); |
|
|
|
|
|
|
|
orderRefund.setTradeOrderId(tradeOrder.getId()); |
|
|
|
|
|
|
|
orderRefund.setOutTradeNo(tradeOrder.getOutTradeNo()); |
|
|
|
|
|
|
|
orderRefund.setRefundNo(refundTrade.getRefundTradeNo()); |
|
|
|
|
|
|
|
orderRefund.setTotalAmount(tradeOrder.getTradeAmount()); |
|
|
|
|
|
|
|
orderRefund.setRefundAmount(new BigDecimal(refundTrade.getRefundAmount())); |
|
|
|
|
|
|
|
orderRefund.setRefundReason(refundTrade.getRefundReason()); |
|
|
|
orderRefund.setStatus(TradeOrderRefundStatusEnum.status1.getNumber()); |
|
|
|
orderRefund.setStatus(TradeOrderRefundStatusEnum.status1.getNumber()); |
|
|
|
orderRefund.setOperatorId(userInfoModel.getSecUser().getId()); |
|
|
|
orderRefund.setOperatorId(0L); |
|
|
|
orderRefund.setOperatorName(userInfoModel.getSecUser().getUserName()); |
|
|
|
orderRefund.setOperatorName("API接口"); |
|
|
|
|
|
|
|
bsTradeOrderRefundService.editOrderRefund(orderRefund); |
|
|
|
bsTradeOrderRefundService.tradeOrderRefund()*/ |
|
|
|
|
|
|
|
return null; |
|
|
|
Map<String, Object> refundMap = bsTradeOrderRefundService.tradeOrderRefund(orderRefund); |
|
|
|
|
|
|
|
orderRefund = (BsTradeOrderRefund) refundMap.get("orderRefund"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ResponseRefundTradeModel refundTradeModel = new ResponseRefundTradeModel(); |
|
|
|
|
|
|
|
refundTradeModel.setMerchantNo(tradeOrder.getMerNo()); |
|
|
|
|
|
|
|
refundTradeModel.setOutTradeNo(tradeOrder.getOutTradeNo()); |
|
|
|
|
|
|
|
refundTradeModel.setPayMode(tradeOrder.getPayMode()); |
|
|
|
|
|
|
|
refundTradeModel.setRefundTradeNo(orderRefund.getRefundNo()); |
|
|
|
|
|
|
|
refundTradeModel.setRefundAmount(orderRefund.getRefundAmount().toString()); |
|
|
|
|
|
|
|
refundTradeModel.setRefundPayerAmount(orderRefund.getPayerAmount().toString()); |
|
|
|
|
|
|
|
refundTradeModel.setRefundTime(orderRefund.getRefundTime()); |
|
|
|
|
|
|
|
refundTradeModel.setSign(SignatureUtil.createSign(refundTradeModel, merKeyService.getKeyByMerNo(tradeOrder.getMerNo()))); |
|
|
|
|
|
|
|
return refundTradeModel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|