| | |
| | | package com.ruoyi.order.service.impl.account; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.github.binarywang.wxpay.bean.ecommerce.ProfitSharingResult; |
| | | import com.ruoyi.order.domain.pojo.account.ProfitSharing; |
| | | import com.ruoyi.order.domain.vo.PaymentDelaytransHFTXVo; |
| | | 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); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void saveProfitSharing1(Long shopId, String orderId, BigDecimal orderMoney, String huifuId, Double amount, PaymentDelaytransHFTXVo result) { |
| | | ProfitSharing profitSharing = new ProfitSharing(); |
| | | profitSharing.setShareId(result.getReqSeqId()); |
| | | profitSharing.setDelFlag(0); |
| | | profitSharing.setShareStatus("P".equals(result.getTransStat()) ? 1 : "S".equals(result.getTransStat()) ? 2 : 3); |
| | | profitSharing.setShopId(shopId); |
| | | profitSharing.setOrderId(orderId); |
| | | profitSharing.setOrderMoney(orderMoney); |
| | | profitSharing.setReceiverAccount(huifuId); |
| | | profitSharing.setReceiverAmount(new BigDecimal(amount)); |
| | | profitSharing.setFinishFlag("S".equals(result.getTransStat()) ? 1 : 0); |
| | | profitSharing.setFailReason(result.getRespDesc()); |
| | | profitSharing.setDetailId(result.getReqSeqId()); |
| | | profitSharing.setCreateTime(new Date()); |
| | | this.saveOrUpdate(profitSharing); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * @description 通过订单id获取 |
| | | * @author jqs |
| | | * @date 2023/9/8 10:34 |
| | | * @param orderId |
| | | * @return ProfitSharing |
| | | */ |
| | | @Override |
| | | public ProfitSharing getByOrderId(String orderId){ |
| | | LambdaQueryWrapper<ProfitSharing> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(ProfitSharing::getDelFlag,0); |
| | | queryWrapper.eq(ProfitSharing::getOrderId,orderId); |
| | | return this.getOne(queryWrapper,false); |
| | | } |
| | | } |