| | |
| | | package com.ruoyi.order.service.impl.account; |
| | | |
| | | import com.github.binarywang.wxpay.bean.ecommerce.ProfitSharingResult; |
| | | import com.ruoyi.common.core.utils.uuid.IdUtils; |
| | | import com.ruoyi.order.domain.pojo.account.ProfitSharing; |
| | | import com.ruoyi.order.mapper.account.ProfitSharingMapper; |
| | | import com.ruoyi.order.service.account.ProfitSharingService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class ProfitSharingServiceImpl extends ServiceImpl<ProfitSharingMapper, ProfitSharing> implements ProfitSharingService { |
| | | |
| | | @Override |
| | | public void saveProfitSharing(Long shopId, String orderId, BigDecimal orderMoney, ProfitSharingResult result) { |
| | | ProfitSharing profitSharing = new ProfitSharing(); |
| | | profitSharing.setShareId(result.getOutOrderNo()); |
| | | profitSharing.setDelFlag(0); |
| | | profitSharing.setShareStatus("FINISHED".equals(result.getStatus()) ? 2 : 1); |
| | | profitSharing.setShopId(shopId); |
| | | profitSharing.setOrderId(orderId); |
| | | profitSharing.setOrderMoney(orderMoney); |
| | | |
| | | List<ProfitSharingResult.Receiver> receivers = result.getReceivers(); |
| | | if(null != receivers && !receivers.isEmpty()){ |
| | | ProfitSharingResult.Receiver receiver = receivers.get(0); |
| | | profitSharing.setReceiverAccount(receiver.getReceiverMchid()); |
| | | BigDecimal receiverAmount = new BigDecimal(receiver.getAmount()); |
| | | receiverAmount = receiverAmount.divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP); |
| | | profitSharing.setReceiverAmount(receiverAmount); |
| | | profitSharing.setSurpMoney(orderMoney.subtract(receiverAmount)); |
| | | profitSharing.setReceiverDescription(receiver.getDescription()); |
| | | profitSharing.setFinishFlag(0); |
| | | profitSharing.setFailReason(receiver.getFailReason()); |
| | | profitSharing.setDetailId(receiver.getDetailId()); |
| | | } |
| | | profitSharing.setCreateTime(new Date()); |
| | | |
| | | this.saveOrUpdate(profitSharing); |
| | | } |
| | | } |