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