|
|
@@ -276,23 +276,23 @@ public class OrderService {
|
|
|
paymentParams.put("notify_url", adapayProperties.getNotifyUrl() + "/order/" + order.getId());
|
|
|
|
|
|
List<Map<String, Object>> divMembers = new ArrayList<>();
|
|
|
- BigDecimal restAmount = order.getTotalPrice().setScale(2, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal totalAmount = order.getTotalPrice().subtract(order.getGasPrice());
|
|
|
+ BigDecimal restAmount = order.getTotalPrice().multiply(BigDecimal.valueOf(1));
|
|
|
|
|
|
if (collection.getSource().equals(CollectionSource.TRANSFER)) {
|
|
|
Asset asset = assetRepo.findById(collection.getAssetId()).orElseThrow(new BusinessException("无记录"));
|
|
|
User owner = userRepo.findById(asset.getUserId()).orElseThrow(new BusinessException("拥有者用户不存在"));
|
|
|
-
|
|
|
- restAmount = divMoney(order.getTotalPrice(), restAmount, divMembers, "0",
|
|
|
- collection.getServiceCharge() + collection.getRoyalties(), true);
|
|
|
- restAmount = divMoney(order.getTotalPrice(), restAmount, divMembers, owner.getMemberId(),
|
|
|
- -1, false);
|
|
|
+ if (collection.getServiceCharge() + collection.getRoyalties() > 0) {
|
|
|
+ restAmount = divMoney(totalAmount, restAmount, divMembers, "0",
|
|
|
+ collection.getServiceCharge() + collection.getRoyalties(), true);
|
|
|
+ }
|
|
|
+ restAmount = divMoney(restAmount, divMembers, owner.getMemberId(), restAmount, false);
|
|
|
} else {
|
|
|
if (invitor != null) {
|
|
|
- restAmount = divMoney(order.getTotalPrice(), restAmount, divMembers, invitor.getMemberId(),
|
|
|
+ restAmount = divMoney(totalAmount, restAmount, divMembers, invitor.getMemberId(),
|
|
|
invitor.getShareRatio().intValue(), false);
|
|
|
}
|
|
|
- restAmount = divMoney(order.getTotalPrice(), restAmount, divMembers, "0",
|
|
|
- -1, true);
|
|
|
+ restAmount = divMoney(restAmount, divMembers, "0", restAmount, true);
|
|
|
}
|
|
|
if (divMembers.size() > 1) {
|
|
|
paymentParams.put("div_members", JSON.toJSONString(divMembers));
|
|
|
@@ -354,6 +354,18 @@ public class OrderService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static BigDecimal divMoney(BigDecimal restAmount, List<Map<String, Object>> divMembers,
|
|
|
+ String memberId, BigDecimal divAmount, boolean feeFlag) {
|
|
|
+ if (divAmount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ Map<String, Object> divMem = new HashMap<>();
|
|
|
+ divMem.put("member_id", memberId);
|
|
|
+ divMem.put("amount", divAmount.toPlainString());
|
|
|
+ divMem.put("fee_flag", feeFlag ? "Y" : "N");
|
|
|
+ divMembers.add(divMem);
|
|
|
+ }
|
|
|
+ return restAmount.subtract(divAmount);
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional
|
|
|
public void notifyOrder(Long orderId, PayMethod payMethod, String transactionId) {
|
|
|
Order order = orderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|