|
|
@ -12,6 +12,7 @@ import com.hfkj.entity.*; |
|
|
|
import com.hfkj.mer.BsMerPayConfigService; |
|
|
|
import com.hfkj.mer.BsMerPayConfigService; |
|
|
|
import com.hfkj.model.order.OrderChildModel; |
|
|
|
import com.hfkj.model.order.OrderChildModel; |
|
|
|
import com.hfkj.model.order.OrderModel; |
|
|
|
import com.hfkj.model.order.OrderModel; |
|
|
|
|
|
|
|
import com.hfkj.service.goods.BsOrderMeiTuanService; |
|
|
|
import com.hfkj.service.hlt.HltCardRefundService; |
|
|
|
import com.hfkj.service.hlt.HltCardRefundService; |
|
|
|
import com.hfkj.service.hlt.HuiLianTongUnionCardService; |
|
|
|
import com.hfkj.service.hlt.HuiLianTongUnionCardService; |
|
|
|
import com.hfkj.service.order.BsOrderChildService; |
|
|
|
import com.hfkj.service.order.BsOrderChildService; |
|
|
@ -35,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
|
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
@ -60,6 +62,8 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { |
|
|
|
private HltCardRefundService hltCardRefundService; |
|
|
|
private HltCardRefundService hltCardRefundService; |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private OrderRefundSuccessService orderRefundSuccessService; |
|
|
|
private OrderRefundSuccessService orderRefundSuccessService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private BsOrderMeiTuanService orderMeiTuanService; |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void editData(BsOrderRefund data) { |
|
|
|
public void editData(BsOrderRefund data) { |
|
|
|
data.setUpdateTime(new Date()); |
|
|
|
data.setUpdateTime(new Date()); |
|
|
@ -248,16 +252,31 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW,rollbackFor= {RuntimeException.class}) |
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW,rollbackFor= {RuntimeException.class}) |
|
|
|
public BsOrderRefund meiTuanRefund(String childOrderNo, String tradeNo , BigDecimal refundPrice, String remark) { |
|
|
|
public BsOrderRefund meiTuanRefund(String tradeRefundNo, String tradeNo , BigDecimal refundPrice, String remark) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询退款订
|
|
|
|
|
|
|
|
BsOrderRefund bsOrderRefund = getRefundByTradeRefundNo(tradeRefundNo); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bsOrderRefund != null) { |
|
|
|
|
|
|
|
return bsOrderRefund; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询业务订单
|
|
|
|
|
|
|
|
BsOrderMeituan orderMeiTuan = orderMeiTuanService.findOrderMeiTuanByTradeNo(tradeNo); |
|
|
|
|
|
|
|
if (orderMeiTuan == null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的业务订单"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 查询子订单
|
|
|
|
// 查询子订单
|
|
|
|
OrderChildModel orderChild = orderChildService.getDetail(childOrderNo); |
|
|
|
OrderChildModel orderChild = orderChildService.getDetail(orderMeiTuan.getChildOrderNo()); |
|
|
|
if (orderChild == null) { |
|
|
|
if (orderChild == null) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的子订单"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的子订单"); |
|
|
|
} |
|
|
|
} |
|
|
|
// if (productCount > orderChild.getSurplusRefundCount()) {
|
|
|
|
|
|
|
|
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!退货数量超过子订单可退数量");
|
|
|
|
if (orderChild.getStatus() != OrderChildStatusEnum.status2.getCode()) { |
|
|
|
// }
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前状态不支持退款!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 查询交易订单
|
|
|
|
// 查询交易订单
|
|
|
|
BsOrder order = orderService.getOrder(orderChild.getOrderNo()); |
|
|
|
BsOrder order = orderService.getOrder(orderChild.getOrderNo()); |
|
|
|
if (order == null) { |
|
|
|
if (order == null) { |
|
|
@ -276,20 +295,35 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { |
|
|
|
orderRefund.setRefundPayChannel(order.getPayChannel()); |
|
|
|
orderRefund.setRefundPayChannel(order.getPayChannel()); |
|
|
|
orderRefund.setReufndPayType(order.getPayType()); |
|
|
|
orderRefund.setReufndPayType(order.getPayType()); |
|
|
|
|
|
|
|
|
|
|
|
// if (orderChild.getSurplusRefundCount().equals(productCount)) {
|
|
|
|
// 是否全额退款
|
|
|
|
// // 全部退款
|
|
|
|
if (orderMeiTuan.getTradeAmount().equals(refundPrice)) { |
|
|
|
// orderRefund.setRefundPrice(orderChild.getSurplusRefundPrice());
|
|
|
|
// 全部退款
|
|
|
|
// orderRefund.setRefundIntegral(orderChild.getSurplusRefundIntegral());
|
|
|
|
orderRefund.setRefundPrice(orderChild.getSurplusRefundPrice()); |
|
|
|
// } else {
|
|
|
|
orderRefund.setRefundIntegral(orderChild.getSurplusRefundIntegral()); |
|
|
|
// // 部分退款
|
|
|
|
} else { |
|
|
|
// // 计算单价
|
|
|
|
// 部分退款
|
|
|
|
// BigDecimal unitPrice = orderChild.getSurplusRefundPrice().divide(new BigDecimal(orderChild.getProductCount().toString()), 2, BigDecimal.ROUND_DOWN).setScale(2);
|
|
|
|
// 计算部分退款比例
|
|
|
|
// BigDecimal unitPriceIntegral = new BigDecimal(orderChild.getSurplusRefundIntegral().toString()).divide(new BigDecimal("100"))
|
|
|
|
BigDecimal proportion = orderChild.getProductTotalPrice().divide(refundPrice, 2, RoundingMode.DOWN); |
|
|
|
// .divide(new BigDecimal(orderChild.getProductCount().toString()), 2, BigDecimal.ROUND_DOWN).setScale(2);
|
|
|
|
// 退积分
|
|
|
|
//
|
|
|
|
Long unitPriceIntegral = new BigDecimal(orderChild.getIntegralDiscountPrice()).multiply(proportion).longValue(); |
|
|
|
// orderRefund.setRefundPrice(unitPrice.multiply(new BigDecimal(productCount.toString())));
|
|
|
|
// 退金额
|
|
|
|
// orderRefund.setRefundIntegral(unitPriceIntegral.multiply(new BigDecimal("100")).longValue());
|
|
|
|
BigDecimal price = orderChild.getProductActualPrice().multiply(proportion); |
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// 插入退款积分
|
|
|
|
|
|
|
|
if (unitPriceIntegral > orderChild.getSurplusRefundIntegral()) { |
|
|
|
|
|
|
|
orderRefund.setRefundIntegral(orderChild.getSurplusRefundIntegral()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
orderRefund.setRefundIntegral(unitPriceIntegral); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 插入退款金额
|
|
|
|
|
|
|
|
if (price.compareTo(orderChild.getSurplusRefundPrice()) > 0) { |
|
|
|
|
|
|
|
orderRefund.setRefundPrice(orderChild.getSurplusRefundPrice()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
orderRefund.setRefundPrice(price); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (orderRefund.getRefundIntegral() > 0L) { |
|
|
|
if (orderRefund.getRefundIntegral() > 0L) { |
|
|
@ -358,6 +392,17 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public BsOrderRefund getRefundByTradeRefundNo(String tradeRefundNo) { |
|
|
|
|
|
|
|
BsOrderRefundExample example = new BsOrderRefundExample(); |
|
|
|
|
|
|
|
example.createCriteria().andTradeRefundNoEqualTo(tradeRefundNo); |
|
|
|
|
|
|
|
List<BsOrderRefund> list = orderRefundMapper.selectByExample(example); |
|
|
|
|
|
|
|
if (!list.isEmpty()){ |
|
|
|
|
|
|
|
return list.get(0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<BsOrderRefund> getRefundList(Map<String, Object> param) { |
|
|
|
public List<BsOrderRefund> getRefundList(Map<String, Object> param) { |
|
|
|
BsOrderRefundExample example = new BsOrderRefundExample(); |
|
|
|
BsOrderRefundExample example = new BsOrderRefundExample(); |
|
|
|