对象为Null的问题"/>
记一次springBoot 自动装载对象为Null的问题
使用@Autowired和@Resource注解是装载对象碰到了对象是Null的问题:如
userCashLogMapper这个对象为Null;
这是由于spring 的IOC必须层层都由其创建,而我写的其中有个类
public class StrategyPayPathInfo {private static final StrategyPayPathInfo obtainStrategyInfo = new StrategyPayPathInfo();public static StrategyPayPathInfo getInstance(){return obtainStrategyInfo;}public void getPayPath(int payPath, String orderNo, OrderPay orderPay, OrderInfo orderNew, String refundId, UserInfo userInfo, String loginUserId, OrderInfo orderInfo1, CorpInfo corpInfo1, UserCashLog cashLog){AbstractStrategyPayPath strategyInfo = new PayPathFactory().getStrategyInfoClass(String.valueOf(payPath));strategyInfo.payPath(payPath,orderNo,orderPay,orderNew,refundId,userInfo,loginUserId,orderInfo1,corpInfo1,cashLog);} }
自己New了两次对象所以导致下面的这个类
public class AlipayPayPath extends AbstractStrategyPayPath
里面自动装载的对象为null
如下解决:
@Component public class AlipayPayPath extends AbstractStrategyPayPath {private static final Logger logger = Logger.getLogger(AlipayPayPath.class);private static PaymentClient paymentClient;private static RefundInfoMapper refundInfoMapper;// @Resource // public void setPaymentClient(PaymentClient paymentClient){ // AlipayPayPath.paymentClient = paymentClient; // } // // @Resource // public void setRefundInfoMapper(RefundInfoMapper refundInfoMapper){ // AlipayPayPath.refundInfoMapper = refundInfoMapper; // }@Autowiredpublic void setPaymentClient(PaymentClient paymentClient,RefundInfoMapper refundInfoMapper){AlipayPayPath.paymentClient = paymentClient;AlipayPayPath.refundInfoMapper = refundInfoMapper;}
private static PaymentClient paymentClient;private static OrderInfoMapper orderInfoMapper;private static RefundInfoMapper refundInfoMapper;private static OrderOperationMapper orderOperationMapper;private static String platFormSubAcctNo;private static String platFormTranNetMemberCode;@Autowired public void setPaymentClient(PaymentClient paymentClient,RefundInfoMapper refundInfoMapper,OrderInfoMapper orderInfoMapper,OrderOperationMapper orderOperationMapper){AbstractStrategyPayPath.paymentClient = paymentClient;AbstractStrategyPayPath.refundInfoMapper = refundInfoMapper;AbstractStrategyPayPath.orderInfoMapper = orderInfoMapper;AbstractStrategyPayPath.orderOperationMapper = orderOperationMapper; }@Value("${payment.pingan.platFormSubAcctNo}") public void setPlatFormSubAcctNo(String platFormSubAcctNo) {AbstractStrategyPayPath.platFormSubAcctNo = platFormSubAcctNo; }@Value("${payment.pingan.platFormTranNetMemberCode}") public void setPlatFormTranNetMemberCode(String platFormTranNetMemberCode) {AbstractStrategyPayPath.platFormTranNetMemberCode = platFormTranNetMemberCode; }
其中需要value属性的
对了上面用@Autowired可以一个方法多个参数但是@Resource注解方法只能一个参数不然会报错
或者全部不new对象全部交给spring 管理ioc默认 单例创建如下:
@Component public class StrategyPayPathInfo {@Resourceprivate PayPathFactory payPathFactory;public void getPayPath(int payPath, String orderNo, OrderPay orderPay, OrderInfo orderNew, String refundId, UserInfo userInfo, String loginUserId, OrderInfo orderInfo1, CorpInfo corpInfo1, UserCashLog cashLog){AbstractStrategyPayPath strategyInfo = payPathFactory.getStrategyInfoClass(String.valueOf(payPath));strategyInfo.payPath(payPath,orderNo,orderPay,orderNew,refundId,userInfo,loginUserId,orderInfo1,corpInfo1,cashLog);} }
@Component public class PayPathFactory {@Resourceprivate AlipayPayPath alipayPayPath;@Resourceprivate WeChatPayPath weChatPayPath;private static Map<String, AbstractStrategyPayPath> strategyInfoMap = new HashMap<>();private void strategyInfoMap(){strategyInfoMap.put(String.valueOf(PayPathEnum.WeChat.getId()), weChatPayPath);strategyInfoMap.put(String.valueOf(PayPathEnum.Alipay.getId()), alipayPayPath);strategyInfoMap.put(String.valueOf(PayPathEnum.UnionPay.getId()), weChatPayPath);strategyInfoMap.put(String.valueOf(PayPathEnum.OfficialAccount.getId()), weChatPayPath);strategyInfoMap.put(String.valueOf(PayPathEnum.MiniProgram.getId()), weChatPayPath);} // static { // strategyInfoMap.put(String.valueOf(PayPathEnum.WeChat.getId()), new weChatPayPath); // strategyInfoMap.put(String.valueOf(PayPathEnum.Alipay.getId()), new AlipayPayPath()); // strategyInfoMap.put(String.valueOf(PayPathEnum.UnionPay.getId()), new WeChatPayPath()); // strategyInfoMap.put(String.valueOf(PayPathEnum.OfficialAccount.getId()), new WeChatPayPath()); // strategyInfoMap.put(String.valueOf(PayPathEnum.MiniProgram.getId()), new WeChatPayPath()); // }public AbstractStrategyPayPath getStrategyInfoClass(String strategy){strategyInfoMap();AbstractStrategyPayPath abstractStrategyPayPath = null;for(String key : strategyInfoMap.keySet()){if(strategy.equals(key)) {abstractStrategyPayPath = strategyInfoMap.get(key);}}return abstractStrategyPayPath;} }
package com.msh.strategy;import com.alibaba.fastjson.JSONObject; import common.core.base.client.PaymentClient; import common.core.businessenum.RefundStatusEnum; import common.core.constant.TokenConstant; import common.core.frame.Consts; import common.core.util.ErrorCode; import common.core.util.JsonUtil; import common.core.util.UUID; import common.core.util.Utils; import com.msh.dao.OrderInfoMapper; import com.msh.dao.OrderOperationMapper; import com.msh.dao.RefundInfoMapper; import com.msh.model.*; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component;import javax.annotation.Resource; import java.math.BigDecimal; import java.util.Date;@Component public abstract class AbstractStrategyPayPath {private static final Logger logger = Logger.getLogger(AbstractStrategyPayPath.class);@Resourceprivate PaymentClient paymentClient;@Resourceprivate OrderInfoMapper orderInfoMapper;@Resourceprivate RefundInfoMapper refundInfoMapper;@Resourceprivate OrderOperationMapper orderOperationMapper;@Value("${payment.pingan.platFormSubAcctNo}")private String platFormSubAcctNo;@Value("${payment.pingan.platFormTranNetMemberCode}")private String platFormTranNetMemberCode;// @Autowired // public void setPaymentClient(PaymentClient paymentClient,RefundInfoMapper refundInfoMapper,OrderInfoMapper orderInfoMapper,OrderOperationMapper orderOperationMapper){ // AbstractStrategyPayPath.paymentClient = paymentClient; // AbstractStrategyPayPath.refundInfoMapper = refundInfoMapper; // AbstractStrategyPayPath.orderInfoMapper = orderInfoMapper; // AbstractStrategyPayPath.orderOperationMapper = orderOperationMapper; // }// @Value("${payment.pingan.platFormSubAcctNo}") // public void setPlatFormSubAcctNo(String platFormSubAcctNo) { // AbstractStrategyPayPath.platFormSubAcctNo = platFormSubAcctNo; // } // // @Value("${payment.pingan.platFormTranNetMemberCode}") // public void setPlatFormTranNetMemberCode(String platFormTranNetMemberCode) { // AbstractStrategyPayPath.platFormTranNetMemberCode = platFormTranNetMemberCode; // }protected String getplatFormSubAcctNo(){return platFormSubAcctNo;}protected String getplatFormTranNetMemberCode(){return platFormTranNetMemberCode;}/***支付方式* @param id*/protected abstract void payPath(int id,String orderNo,OrderPay orderPay,OrderInfo orderNew,String refundId,UserInfo userInfo,String loginUserId,OrderInfo orderInfo1,CorpInfo corpInfo1,UserCashLog cashLog);/*** 分账*/protected abstract void subAccount(UserInfo userInfo, OrderPay orderPay, OrderInfo orderInfo1, CorpInfo corpInfo1, OrderInfo orderNew,String refundId,String orderNo,String loginUserId,UserCashLog cashLog);//写入退款信息表审核protected void refunding(String refundId,String orderNo,String loginUserId ,Integer refundStatus){Date now = new Date();OrderInfo orderInfo = orderInfoMapper.selectByPrimaryKey(orderNo);RefundInfo refund = new RefundInfo();refund.setId(refundId);refund.setRefundReason(0);refund.setRefundMethod(0);refund.setOrderNo(orderNo);refund.setCreateTime(now);refund.setCost(orderInfo.getUserRefundCost());if (refundStatus==RefundStatusEnum.REFUNDING.getId()){refund.setRefundStatus(RefundStatusEnum.REFUNDING.getId());}else {refund.setRefundStatus(RefundStatusEnum.REFUNDED.getId());}refund.setCreateUserId(loginUserId);refundInfoMapper.insertSelective(refund);}protected void insertOrderOperation(int operationType,String operationContent,int operationContentId,String orderNo){Date now = new Date();OrderOperation completeOrderOperation = new OrderOperation();completeOrderOperation.setOperationType(operationType);completeOrderOperation.setOperationContent(operationContent);completeOrderOperation.setOperationContentId(operationContentId);completeOrderOperation.setOrderOperId(UUID.generate());completeOrderOperation.setOrderNo(orderNo);completeOrderOperation.setCreateTime(now);completeOrderOperation.setCreateUserId("admin");orderOperationMapper.insert(completeOrderOperation);}protected void updateRefoundInfo(RefundInfo refundInfo,int refundStatus){Date now = new Date();RefundInfo refundInfo1 = new RefundInfo();refundInfo1.setUpdateTime(now);refundInfo1.setUpdateUserId("admin");refundInfo1.setRefundStatus(refundStatus);refundInfo1.setId(refundInfo.getId());refundInfoMapper.updateByPrimaryKeySelective(refundInfo1);}/*** 微信冻洁* @param userInfo* @param orderNew* @param orderPay* @param orderNo* @param loginUserId* @param refundId*/protected void insertMembershipTrancheFreeze(UserInfo userInfo, OrderInfo orderNew, OrderPay orderPay,String orderNo,String loginUserId,String refundId){JSONObject freezeParam = new JSONObject();freezeParam.put(TokenConstant.TOKEN, TokenConstant.ALLPOWER_TOKEN);freezeParam.put("functionFlag", "2");freezeParam.put("subAcctNo", userInfo.getCustAcctId());freezeParam.put("tranNetMemberCode", userInfo.getUserId());freezeParam.put("tranAmt", Utils.formatMoney(orderNew.getUserRefundCost()));freezeParam.put("tranCommission", Utils.formatMoney(BigDecimal.ZERO));freezeParam.put("orderNo", orderPay.getOutPayId());JSONObject result1 = paymentClient.insertMembershipTrancheFreeze(freezeParam);if (ErrorCode.SUCCESS != JsonUtil.getJInt(result1, Consts.RESULT, ErrorCode.FAILED)) {logger.error(">>>>>>>>>>>>>>解冻失败"+result1);//写入退款信息表退款中RefundInfo refundInfo = refundInfoMapper.selectByOrderNo(orderNo);if(refundInfo==null){refunding(refundId,orderNo,loginUserId, RefundStatusEnum.REFUNDING.getId());}}} }
package com.msh.strategy;import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import common.core.base.client.PaymentClient; import common.core.businessenum.*; import common.core.constant.TokenConstant; import common.core.frame.Consts; import common.core.util.*; import com.msh.dao.RefundInfoMapper; import com.msh.model.*; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component;import javax.annotation.Resource; import java.math.BigDecimal;@Component public class AlipayPayPath extends AbstractStrategyPayPath {private static final Logger logger = Logger.getLogger(AlipayPayPath.class);@Resourceprivate PaymentClient paymentClient;@Resourceprivate RefundInfoMapper refundInfoMapper;// @Resource // public void setPaymentClient(PaymentClient paymentClient){ // AlipayPayPath.paymentClient = paymentClient; // } // // @Resource // public void setRefundInfoMapper(RefundInfoMapper refundInfoMapper){ // AlipayPayPath.refundInfoMapper = refundInfoMapper; // }// @Autowired // public void setPaymentClient(PaymentClient paymentClient,RefundInfoMapper refundInfoMapper){ // AlipayPayPath.paymentClient = paymentClient; // AlipayPayPath.refundInfoMapper = refundInfoMapper; // }@Overrideprotected void payPath(int id, String orderNo, OrderPay orderPay, OrderInfo orderNew, String refundId, UserInfo userInfo, String loginUserId, OrderInfo orderInfo1, CorpInfo corpInfo1, UserCashLog cashLog) {//支付宝分账subAccount(userInfo,orderPay,orderInfo1,corpInfo1,orderNew,refundId,orderNo,loginUserId,cashLog);//用户退款金额小于0只分账不退款if (orderNew.getUserRefundCost()pareTo(BigDecimal.ZERO) <= 0){//写入订单操作记录表操作记录表退款成功insertOrderOperation(OrderOperationTypeEnum.SYSTEM.getValue(),OrderOperationEnum.REFUND_COMPLETE.getDescription(),OrderOperationEnum.REFUND_COMPLETE.getId(),orderNo);//退款信息表写入退款成功RefundInfo refundInfo = refundInfoMapper.selectByOrderNo(orderNo);if(refundInfo==null){refunding(refundId,orderNo,loginUserId,RefundStatusEnum.REFUNDED.getId());}else {//更新退款信息updateRefoundInfo(refundInfo,RefundStatusEnum.REFUNDED.getId());}return;}//支付宝退款JSONObject paramJson = new JSONObject();paramJson.put("orderId", orderPay.getOutPayId());paramJson.put("refundId", orderNo);paramJson.put("refundFee", Utils.formatMoney(orderNew.getUserRefundCost()));paramJson.put("token", TokenConstant.ALLPOWER_TOKEN);JSONObject result = paymentClient.refundAlipay(paramJson);if (YesOrNoEnum.NO.getValue() == JsonUtil.getJInt(result, Consts.RESULT, ErrorCode.FAILED)) {//写入订单操作记录表insertOrderOperation(OrderOperationTypeEnum.SYSTEM.getValue(),OrderOperationEnum.REFUND_COMPLETE.getDescription(),OrderOperationEnum.REFUND_COMPLETE.getId(),orderNo);//退款信息表写入退款成功RefundInfo refundInfo = refundInfoMapper.selectByOrderNo(orderNo);if(refundInfo==null){refunding(refundId,orderNo,loginUserId,RefundStatusEnum.REFUNDED.getId());}else {//更新退款信息updateRefoundInfo(refundInfo,RefundStatusEnum.REFUNDED.getId());}} else {//写入退款信息表退款中RefundInfo refundInfo = refundInfoMapper.selectByOrderNo(orderNo);if(refundInfo==null){refunding(refundId,orderNo,loginUserId,RefundStatusEnum.REFUNDING.getId());}logger.error(">>>>>>>>>>>>>>>>>>>>调用支付宝接口退款失败"+result);}}@Overrideprotected void subAccount(UserInfo userInfo, OrderPay orderPay, OrderInfo orderInfo1, CorpInfo corpInfo1, OrderInfo orderNew, String refundId, String orderNo, String loginUserId, UserCashLog cashLog) {JSONObject payParam = new JSONObject();payParam.put(TokenConstant.TOKEN, TokenConstant.ALLPOWER_TOKEN);payParam.put("outCustAcctId", userInfo.getCustAcctId());payParam.put("outThirdCustId", userInfo.getUserId());payParam.put("handFee", "0");payParam.put("orderNo", orderPay.getOutPayId());JSONArray tranItemArray = new JSONArray();JSONObject jo = new JSONObject();//商家if (orderInfo1.getBusinessIncome()pareTo(new BigDecimal("0.00")) > 0) {JSONObject corpJo = new JSONObject();corpJo.put("inCustAcctId", corpInfo1.getCustAcctId());corpJo.put("inThirdCustId", corpInfo1.getThirdCustId());corpJo.put("tranAmount", StringUtil.toString(orderInfo1.getBusinessIncome()));tranItemArray.add(corpJo);}//平台if (orderNew.getTotalRefund()pareTo(new BigDecimal("0.00")) > 0){jo.put("inCustAcctId", getplatFormSubAcctNo());jo.put("inThirdCustId", getplatFormTranNetMemberCode());jo.put("tranAmount", Utils.formatMoney(orderNew.getTotalRefund().add(orderInfo1.getPlatformCommission())));tranItemArray.add(jo);}if (tranItemArray.size()>0){payParam.put("tranItemArray", tranItemArray);JSONObject result2 = paymentClient.insertMembershipTranchePay(payParam);if (ErrorCode.SUCCESS != JsonUtil.getJInt(result2, Consts.RESULT, ErrorCode.FAILED)) {logger.error(">>>>>>>>>>>>>>>>>>>>>>>>>>结算分账失败"+result2);cashLog.setTranStatus(UserTranStatusEnum.FAILED.getId());}else{cashLog.setTranStatus(UserTranStatusEnum.SUCCESS.getId());}}//写入退款信息表退款中RefundInfo refundInfo6 = refundInfoMapper.selectByOrderNo(orderNo);if(refundInfo6==null){refunding(refundId,orderNo,loginUserId, RefundStatusEnum.REFUNDING.getId());} else{//用户退款金额小于0只分账不退款if (orderNew.getUserRefundCost()pareTo(BigDecimal.ZERO) <= 0){updateRefoundInfo(refundInfo6,RefundStatusEnum.REFUNDED.getId());}}} }
package com.msh.strategy;import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import common.core.base.client.PaymentClient; import common.core.businessenum.*; import common.core.constant.TokenConstant; import common.core.frame.Consts; import common.core.util.*; import com.msh.dao.RefundInfoMapper; import com.msh.model.*; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component;import javax.annotation.Resource; import java.math.BigDecimal;@Component public class WeChatPayPath extends AbstractStrategyPayPath {private static final Logger logger = Logger.getLogger(WeChatPayPath.class);@Resourceprivate PaymentClient paymentClient;@Resourceprivate RefundInfoMapper refundInfoMapper;// @Autowired // public void setPaymentClient(PaymentClient paymentClient,RefundInfoMapper refundInfoMapper){ // WeChatPayPath.paymentClient = paymentClient; // WeChatPayPath.refundInfoMapper = refundInfoMapper; // }@Overridepublic void payPath(int id,String orderNo,OrderPay orderPay,OrderInfo orderNew,String refundId,UserInfo userInfo,String loginUserId,OrderInfo orderInfo1,CorpInfo corpInfo1,UserCashLog cashLog) {if (orderNew.getUserRefundCost()pareTo(BigDecimal.ZERO) > 0){insertMembershipTrancheFreeze(userInfo,orderNew,orderPay,orderNo,loginUserId,refundId);}//分账subAccount(userInfo,orderPay,orderInfo1,corpInfo1,orderNew,refundId,orderNo,loginUserId,cashLog);//用户退款金额小于0只分账不退款if (orderNew.getUserRefundCost()pareTo(BigDecimal.ZERO) <= 0){//写入订单操作记录表操作记录表退款成功insertOrderOperation(OrderOperationTypeEnum.SYSTEM.getValue(),OrderOperationEnum.REFUND_COMPLETE.getDescription(),OrderOperationEnum.REFUND_COMPLETE.getId(),orderNo);//退款信息表写入退款成功RefundInfo refundInfo = refundInfoMapper.selectByOrderNo(orderNo);if(refundInfo==null){refunding(refundId,orderNo,loginUserId,RefundStatusEnum.REFUNDED.getId());}else {//更新退款信息updateRefoundInfo(refundInfo,RefundStatusEnum.REFUNDED.getId());}return;}//银联与微信及公众号逻辑差不多故写一起,银联退款相关逻辑if (orderPay.getPayPath()==PayPathEnum.UnionPay.getId()){unionRefund(orderPay,orderNew,orderNo,refundId,loginUserId);}JSONObject jsonObject = new JSONObject();jsonObject.put("outNo", orderPay.getOutPayId());jsonObject.put("orderNo",orderPay.getOutPayId());jsonObject.put("refundAmount", orderNew.getUserRefundCost().multiply(new BigDecimal(100)).intValue());jsonObject.put("refundOutNo",refundId);jsonObject.put("custAcctId",userInfo.getCustAcctId());jsonObject.put("token", TokenConstant.ALLPOWER_TOKEN);JSONObject result = paymentClient.insertPayRefund(jsonObject);if (YesOrNoEnum.NO.getValue() == JsonUtil.getJInt(result, Consts.RESULT, ErrorCode.FAILED)){//写入操作记录表insertOrderOperation(OrderOperationTypeEnum.SYSTEM.getValue(),OrderOperationEnum.REFUND_COMPLETE.getDescription(),OrderOperationEnum.REFUND_COMPLETE.getId(),orderNo);//退款信息表写入退款成功RefundInfo refundInfo = refundInfoMapper.selectByOrderNo(orderNo);if(refundInfo==null){refunding(refundId,orderNo,loginUserId,RefundStatusEnum.REFUNDED.getId());}else {//更新退款信息updateRefoundInfo(refundInfo,RefundStatusEnum.REFUNDED.getId());}}else{//写入退款信息表退款中RefundInfo refundInfo = refundInfoMapper.selectByOrderNo(orderNo);if(refundInfo==null){refunding(refundId,orderNo,loginUserId,RefundStatusEnum.REFUNDING.getId());}logger.error(">>>>>>>>>>>>>>>>>>>>>>>>>>微信或公众号退款失败"+result);}}@Overridepublic void subAccount(UserInfo userInfo, OrderPay orderPay, OrderInfo orderInfo1, CorpInfo corpInfo1,OrderInfo orderNew,String refundId,String orderNo,String loginUserId,UserCashLog cashLog) {//分账JSONObject payParam = new JSONObject();payParam.put(TokenConstant.TOKEN, TokenConstant.ALLPOWER_TOKEN);payParam.put("outCustAcctId", userInfo.getCustAcctId());payParam.put("outThirdCustId", userInfo.getUserId());payParam.put("handFee", "0");payParam.put("orderNo", orderPay.getOutPayId());JSONArray tranItemArray = new JSONArray();JSONObject jo = new JSONObject();if(orderInfo1.getBusinessIncome()pareTo(new BigDecimal("0.00")) > 0){JSONObject corpJo = new JSONObject();corpJo.put("inCustAcctId",corpInfo1.getCustAcctId());corpJo.put("inThirdCustId",corpInfo1.getThirdCustId());corpJo.put("tranAmount", StringUtil.toString(orderInfo1.getBusinessIncome()));tranItemArray.add(corpJo);}//平台使用优惠券if(orderNew.getTotalRefund().subtract(orderNew.getUserRefundCost())pareTo(new BigDecimal("0.00")) > 0){jo.put("inCustAcctId", getplatFormSubAcctNo());jo.put("inThirdCustId", getplatFormTranNetMemberCode());jo.put("tranAmount", Utils.formatMoney(orderNew.getTotalRefund().subtract(orderNew.getUserRefundCost()).add(orderNew.getPlatformCommission())));tranItemArray.add(jo);}else{if (orderNew.getPlatformCommission()pareTo(new BigDecimal("0.00")) > 0){jo.put("inCustAcctId", getplatFormSubAcctNo());jo.put("inThirdCustId", getplatFormTranNetMemberCode());jo.put("tranAmount", Utils.formatMoney(orderNew.getPlatformCommission()));tranItemArray.add(jo);}}if(tranItemArray.size()>0){payParam.put("tranItemArray", tranItemArray);JSONObject result2 = paymentClient.insertMembershipTranchePay(payParam);if (ErrorCode.SUCCESS != JsonUtil.getJInt(result2, Consts.RESULT, ErrorCode.FAILED).intValue()) {logger.error(">>>>>>>>>>>>>>>>>>>>>>>>>>结算分账失败"+result2);cashLog.setTranStatus(UserTranStatusEnum.FAILED.getId());}else {cashLog.setTranStatus(UserTranStatusEnum.SUCCESS.getId());}}//写入退款信息表退款中RefundInfo refundInfo5 = refundInfoMapper.selectByOrderNo(orderNo);if(refundInfo5==null){refunding(refundId,orderNo,loginUserId, RefundStatusEnum.REFUNDING.getId());}else{//用户退款金额小于0只分账不退款if (orderNew.getUserRefundCost()pareTo(BigDecimal.ZERO) <= 0){updateRefoundInfo(refundInfo5,RefundStatusEnum.REFUNDED.getId());}}}private void unionRefund(OrderPay orderPay,OrderInfo orderNew,String orderNo,String refundId,String loginUserId){JSONObject jsonObject = new JSONObject();jsonObject.put("orderId", orderPay.getOutPayId());jsonObject.put("refundAmt",orderNew.getUserRefundCost());jsonObject.put("token",TokenConstant.ALLPOWER_TOKEN);JSONObject result = paymentClient.insertUnionRefund(jsonObject);if (YesOrNoEnum.NO.getValue() == JsonUtil.getJInt(result, Consts.RESULT, ErrorCode.FAILED)){//写入订单操作记录表insertOrderOperation(OrderOperationTypeEnum.SYSTEM.getValue(),OrderOperationEnum.REFUND_COMPLETE.getDescription(),OrderOperationEnum.REFUND_COMPLETE.getId(),orderNo);//退款信息表写入退款成功RefundInfo refundInfo = refundInfoMapper.selectByOrderNo(orderNo);if(refundInfo==null){refunding(refundId,orderNo,loginUserId,RefundStatusEnum.REFUNDED.getId());}else {//更新退款信息updateRefoundInfo(refundInfo,RefundStatusEnum.REFUNDED.getId());}}else{//写入退款信息表退款中RefundInfo refundInfo = refundInfoMapper.selectByOrderNo(orderNo);if(refundInfo==null){refunding(refundId,orderNo,loginUserId,RefundStatusEnum.REFUNDING.getId());}logger.error(">>>>>>>>>>>>>>>>>>>>>>>>>>银联退款失败"+result);}}}
更多推荐
记一次springBoot 自动装载对象为Null的问题
发布评论