|
@@ -1,24 +1,14 @@
|
|
|
package com.fs.his.service.impl;
|
|
package com.fs.his.service.impl;
|
|
|
|
|
|
|
|
-import java.lang.reflect.Field;
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
|
|
-import java.time.LocalDateTime;
|
|
|
|
|
-import java.util.*;
|
|
|
|
|
-import java.util.concurrent.CompletableFuture;
|
|
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
|
|
-
|
|
|
|
|
import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.TypeReference;
|
|
import com.alibaba.fastjson.TypeReference;
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.fs.common.annotation.DataScope;
|
|
import com.fs.common.annotation.DataScope;
|
|
|
-import com.fs.common.annotation.Log;
|
|
|
|
|
-import com.fs.common.core.domain.AjaxResult;
|
|
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.common.exception.CustomException;
|
|
import com.fs.common.exception.CustomException;
|
|
@@ -26,7 +16,6 @@ import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.common.utils.ServletUtils;
|
|
import com.fs.common.utils.ServletUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.common.utils.ip.IpUtils;
|
|
import com.fs.common.utils.ip.IpUtils;
|
|
|
-import com.fs.common.utils.poi.ExcelUtil;
|
|
|
|
|
import com.fs.company.domain.Company;
|
|
import com.fs.company.domain.Company;
|
|
|
import com.fs.company.domain.CompanyUser;
|
|
import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.company.mapper.CompanyConfigMapper;
|
|
import com.fs.company.mapper.CompanyConfigMapper;
|
|
@@ -39,19 +28,17 @@ import com.fs.config.cloud.CloudHostProper;
|
|
|
import com.fs.core.config.WxMaConfiguration;
|
|
import com.fs.core.config.WxMaConfiguration;
|
|
|
import com.fs.core.config.WxPayProperties;
|
|
import com.fs.core.config.WxPayProperties;
|
|
|
import com.fs.core.utils.OrderCodeUtils;
|
|
import com.fs.core.utils.OrderCodeUtils;
|
|
|
-import com.fs.course.config.CourseConfig;
|
|
|
|
|
import com.fs.course.config.RedPacketConfig;
|
|
import com.fs.course.config.RedPacketConfig;
|
|
|
-import com.fs.course.domain.FsCourseRedPacketLog;
|
|
|
|
|
-import com.fs.course.mapper.FsCourseRedPacketLogMapper;
|
|
|
|
|
import com.fs.course.service.IFsCourseRedPacketLogService;
|
|
import com.fs.course.service.IFsCourseRedPacketLogService;
|
|
|
import com.fs.course.service.IFsUserCourseOrderService;
|
|
import com.fs.course.service.IFsUserCourseOrderService;
|
|
|
import com.fs.course.service.IFsUserVipOrderService;
|
|
import com.fs.course.service.IFsUserVipOrderService;
|
|
|
-import com.fs.erp.dto.ErpRefundUpdateRequest;
|
|
|
|
|
-import com.fs.his.domain.*;
|
|
|
|
|
|
|
+import com.fs.his.domain.FsPayConfig;
|
|
|
|
|
+import com.fs.his.domain.FsStorePayment;
|
|
|
|
|
+import com.fs.his.domain.FsUser;
|
|
|
|
|
+import com.fs.his.domain.FsUserWx;
|
|
|
import com.fs.his.dto.PayConfigDTO;
|
|
import com.fs.his.dto.PayConfigDTO;
|
|
|
import com.fs.his.enums.PaymentMethodEnum;
|
|
import com.fs.his.enums.PaymentMethodEnum;
|
|
|
import com.fs.his.mapper.*;
|
|
import com.fs.his.mapper.*;
|
|
|
-import com.fs.his.param.FsStoreOrderParam;
|
|
|
|
|
import com.fs.his.param.FsStorePaymentParam;
|
|
import com.fs.his.param.FsStorePaymentParam;
|
|
|
import com.fs.his.param.PayOrderParam;
|
|
import com.fs.his.param.PayOrderParam;
|
|
|
import com.fs.his.param.WxSendRedPacketParam;
|
|
import com.fs.his.param.WxSendRedPacketParam;
|
|
@@ -77,7 +64,6 @@ import com.fs.system.oss.CloudStorageService;
|
|
|
import com.fs.system.oss.OSSFactory;
|
|
import com.fs.system.oss.OSSFactory;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import com.fs.tzBankPay.TzBankService.TzBankService;
|
|
import com.fs.tzBankPay.TzBankService.TzBankService;
|
|
|
-import com.fs.tzBankPay.TzBankService.TzBankServiceImpl.TzBankServiceImpl;
|
|
|
|
|
import com.fs.tzBankPay.doman.*;
|
|
import com.fs.tzBankPay.doman.*;
|
|
|
import com.fs.ybPay.domain.CreateWxOrderResult;
|
|
import com.fs.ybPay.domain.CreateWxOrderResult;
|
|
|
import com.fs.ybPay.domain.OrderResult;
|
|
import com.fs.ybPay.domain.OrderResult;
|
|
@@ -85,36 +71,23 @@ import com.fs.ybPay.dto.OrderQueryDTO;
|
|
|
import com.fs.ybPay.dto.RefundDTO;
|
|
import com.fs.ybPay.dto.RefundDTO;
|
|
|
import com.fs.ybPay.dto.WxJspayDTO;
|
|
import com.fs.ybPay.dto.WxJspayDTO;
|
|
|
import com.fs.ybPay.service.IPayService;
|
|
import com.fs.ybPay.service.IPayService;
|
|
|
-import com.github.binarywang.wxpay.bean.merchanttransfer.TransferCreateRequest;
|
|
|
|
|
-import com.github.binarywang.wxpay.bean.merchanttransfer.TransferCreateResult;
|
|
|
|
|
import com.github.binarywang.wxpay.bean.notify.SignatureHeader;
|
|
import com.github.binarywang.wxpay.bean.notify.SignatureHeader;
|
|
|
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
|
|
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
|
|
|
import com.github.binarywang.wxpay.bean.notify.WxPayTransferBatchesNotifyV3Result;
|
|
import com.github.binarywang.wxpay.bean.notify.WxPayTransferBatchesNotifyV3Result;
|
|
|
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
|
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
|
|
import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
|
|
import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
|
|
|
-import com.github.binarywang.wxpay.bean.request.WxPaySendRedpackRequest;
|
|
|
|
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
|
|
import com.github.binarywang.wxpay.bean.result.WxPayRefundQueryResult;
|
|
import com.github.binarywang.wxpay.bean.result.WxPayRefundQueryResult;
|
|
|
import com.github.binarywang.wxpay.bean.result.WxPayRefundResult;
|
|
import com.github.binarywang.wxpay.bean.result.WxPayRefundResult;
|
|
|
import com.github.binarywang.wxpay.bean.transfer.*;
|
|
import com.github.binarywang.wxpay.bean.transfer.*;
|
|
|
import com.github.binarywang.wxpay.config.WxPayConfig;
|
|
import com.github.binarywang.wxpay.config.WxPayConfig;
|
|
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
|
|
-import com.github.binarywang.wxpay.service.MerchantTransferService;
|
|
|
|
|
-import com.github.binarywang.wxpay.service.RedpackService;
|
|
|
|
|
import com.github.binarywang.wxpay.service.TransferService;
|
|
import com.github.binarywang.wxpay.service.TransferService;
|
|
|
import com.github.binarywang.wxpay.service.WxPayService;
|
|
import com.github.binarywang.wxpay.service.WxPayService;
|
|
|
-import com.github.binarywang.wxpay.service.impl.RedpackServiceImpl;
|
|
|
|
|
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
|
|
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
|
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
|
import com.hc.openapi.tool.fastjson.JSON;
|
|
import com.hc.openapi.tool.fastjson.JSON;
|
|
|
-import com.wechat.pay.java.service.transferbatch.TransferBatchService;
|
|
|
|
|
-import com.wechat.pay.java.service.transferbatch.model.InitiateBatchTransferRequest;
|
|
|
|
|
-import me.chanjar.weixin.common.bean.WxJsapiSignature;
|
|
|
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
-import me.chanjar.weixin.mp.api.WxMpService;
|
|
|
|
|
-import org.apache.commons.lang.exception.ExceptionUtils;
|
|
|
|
|
-import org.apache.hc.core5.concurrent.CompletedFuture;
|
|
|
|
|
-import org.redisson.api.RLock;
|
|
|
|
|
import org.redisson.api.RedissonClient;
|
|
import org.redisson.api.RedissonClient;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -122,12 +95,15 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
-import org.springframework.scheduling.annotation.Async;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
+import java.lang.reflect.Field;
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 支付明细Service业务层处理
|
|
* 支付明细Service业务层处理
|
|
@@ -186,10 +162,10 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
private CloudHostProper cloudHostProper;
|
|
private CloudHostProper cloudHostProper;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- private RedisTemplate<String,BigDecimal> redisTemplate;
|
|
|
|
|
|
|
+ private RedisTemplate<String, BigDecimal> redisTemplate;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- private RedisTemplate<String,Integer> redisTemplateInteger;
|
|
|
|
|
|
|
+ private RedisTemplate<String, Integer> redisTemplateInteger;
|
|
|
/**
|
|
/**
|
|
|
* 红包领取数量限制 默认一个用户当天最多只能领取10个
|
|
* 红包领取数量限制 默认一个用户当天最多只能领取10个
|
|
|
*/
|
|
*/
|
|
@@ -333,15 +309,15 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
QueryOrderResult body = result.getBody();
|
|
QueryOrderResult body = result.getBody();
|
|
|
logger.info("手动回调内容:" + body);
|
|
logger.info("手动回调内容:" + body);
|
|
|
if (fsStorePayment.getBusinessType() == 1) {
|
|
if (fsStorePayment.getBusinessType() == 1) {
|
|
|
- inquiryOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), body.getPayType(), 1,null,null);
|
|
|
|
|
|
|
+ inquiryOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), body.getPayType(), 1, null, null);
|
|
|
} else if (fsStorePayment.getBusinessType() == 2) {
|
|
} else if (fsStorePayment.getBusinessType() == 2) {
|
|
|
- storeOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), body.getPayType(), 1,null,null);
|
|
|
|
|
|
|
+ storeOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), body.getPayType(), 1, null, null);
|
|
|
} else if (fsStorePayment.getBusinessType() == 3) {
|
|
} else if (fsStorePayment.getBusinessType() == 3) {
|
|
|
- packageOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), body.getPayType(), 1,null,null);
|
|
|
|
|
- }else if (fsStorePayment.getBusinessType() == 4) {
|
|
|
|
|
- courseOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "", 1,null,null);
|
|
|
|
|
- }else if (fsStorePayment.getBusinessType() == 5) {
|
|
|
|
|
- vipOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "", 1,null,null);
|
|
|
|
|
|
|
+ packageOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), body.getPayType(), 1, null, null);
|
|
|
|
|
+ } else if (fsStorePayment.getBusinessType() == 4) {
|
|
|
|
|
+ courseOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "", 1, null, null);
|
|
|
|
|
+ } else if (fsStorePayment.getBusinessType() == 5) {
|
|
|
|
|
+ vipOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "", 1, null, null);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -355,15 +331,15 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
logger.info("手动查询内容:" + paymentId + ":" + orderResult);
|
|
logger.info("手动查询内容:" + paymentId + ":" + orderResult);
|
|
|
if (orderResult.getStatus().equals("100")) {
|
|
if (orderResult.getStatus().equals("100")) {
|
|
|
if (fsStorePayment.getBusinessType() == 1) {
|
|
if (fsStorePayment.getBusinessType() == 1) {
|
|
|
- inquiryOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "14", 1,null,null);
|
|
|
|
|
|
|
+ inquiryOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "14", 1, null, null);
|
|
|
} else if (fsStorePayment.getBusinessType() == 2) {
|
|
} else if (fsStorePayment.getBusinessType() == 2) {
|
|
|
- storeOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "14", 1,null,null);
|
|
|
|
|
|
|
+ storeOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "14", 1, null, null);
|
|
|
} else if (fsStorePayment.getBusinessType() == 3) {
|
|
} else if (fsStorePayment.getBusinessType() == 3) {
|
|
|
- packageOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "14", 1,null,null);
|
|
|
|
|
- }else if (fsStorePayment.getBusinessType() == 4) {
|
|
|
|
|
- courseOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "", 1,null,null);
|
|
|
|
|
- }else if (fsStorePayment.getBusinessType() == 5) {
|
|
|
|
|
- vipOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "", 1,null,null);
|
|
|
|
|
|
|
+ packageOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "14", 1, null, null);
|
|
|
|
|
+ } else if (fsStorePayment.getBusinessType() == 4) {
|
|
|
|
|
+ courseOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "", 1, null, null);
|
|
|
|
|
+ } else if (fsStorePayment.getBusinessType() == 5) {
|
|
|
|
|
+ vipOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "", 1, null, null);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -379,47 +355,49 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException(e);
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
}
|
|
|
- logger.info("汇付返回"+queryOrderResult);
|
|
|
|
|
|
|
+ logger.info("汇付返回" + queryOrderResult);
|
|
|
if ("00000000".equals(queryOrderResult.getResp_code())) {
|
|
if ("00000000".equals(queryOrderResult.getResp_code())) {
|
|
|
if (queryOrderResult.getTrans_stat().equals("S")) {
|
|
if (queryOrderResult.getTrans_stat().equals("S")) {
|
|
|
logger.info("手动查询内容:" + paymentId + ":" + request);
|
|
logger.info("手动查询内容:" + paymentId + ":" + request);
|
|
|
- if (fsStorePayment.getBusinessType() == 1) {
|
|
|
|
|
- inquiryOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "14", 1,queryOrderResult.getOut_trans_id(),queryOrderResult.getParty_order_id());
|
|
|
|
|
- } else if (fsStorePayment.getBusinessType() == 2) {
|
|
|
|
|
- storeOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "14", 1,queryOrderResult.getOut_trans_id(),queryOrderResult.getParty_order_id());
|
|
|
|
|
- } else if (fsStorePayment.getBusinessType() == 3) {
|
|
|
|
|
- packageOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "14", 1,queryOrderResult.getOut_trans_id(),queryOrderResult.getParty_order_id());
|
|
|
|
|
- } else if (fsStorePayment.getBusinessType() == 4) {
|
|
|
|
|
- courseOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "", 1,queryOrderResult.getOut_trans_id(),queryOrderResult.getParty_order_id());
|
|
|
|
|
- }else if (fsStorePayment.getBusinessType() == 5) {
|
|
|
|
|
- vipOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "", 1,queryOrderResult.getOut_trans_id(),queryOrderResult.getParty_order_id());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (fsStorePayment.getBusinessType() == 1) {
|
|
|
|
|
+ inquiryOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "14", 1, queryOrderResult.getOut_trans_id(), queryOrderResult.getParty_order_id());
|
|
|
|
|
+ } else if (fsStorePayment.getBusinessType() == 2) {
|
|
|
|
|
+ storeOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "14", 1, queryOrderResult.getOut_trans_id(), queryOrderResult.getParty_order_id());
|
|
|
|
|
+ } else if (fsStorePayment.getBusinessType() == 3) {
|
|
|
|
|
+ packageOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "14", 1, queryOrderResult.getOut_trans_id(), queryOrderResult.getParty_order_id());
|
|
|
|
|
+ } else if (fsStorePayment.getBusinessType() == 4) {
|
|
|
|
|
+ courseOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "", 1, queryOrderResult.getOut_trans_id(), queryOrderResult.getParty_order_id());
|
|
|
|
|
+ } else if (fsStorePayment.getBusinessType() == 5) {
|
|
|
|
|
+ vipOrderService.payConfirm("", fsStorePayment.getPayCode(), fsStorePayment.getTradeNo(), "", 1, queryOrderResult.getOut_trans_id(), queryOrderResult.getParty_order_id());
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return "同步完成";
|
|
return "同步完成";
|
|
|
-}
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
IPayService payService;
|
|
IPayService payService;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public R refundFsStorePayment(Long paymentId) {
|
|
public R refundFsStorePayment(Long paymentId) {
|
|
|
FsStorePayment fsStorePayment = fsStorePaymentMapper.selectFsStorePaymentByPaymentId(paymentId);
|
|
FsStorePayment fsStorePayment = fsStorePaymentMapper.selectFsStorePaymentByPaymentId(paymentId);
|
|
|
- if(fsStorePayment!=null){
|
|
|
|
|
- String orderType="";
|
|
|
|
|
- if (fsStorePayment.getBusinessType()==1){
|
|
|
|
|
- orderType="inquiry";
|
|
|
|
|
- }else if (fsStorePayment.getBusinessType()==2){
|
|
|
|
|
- orderType="store";
|
|
|
|
|
- }else if (fsStorePayment.getBusinessType()==3){
|
|
|
|
|
- orderType="package";
|
|
|
|
|
- }else if (fsStorePayment.getBusinessType()==4){
|
|
|
|
|
- orderType="course";
|
|
|
|
|
- }else if (fsStorePayment.getBusinessType()==5){
|
|
|
|
|
- orderType="appvip";
|
|
|
|
|
|
|
+ if (fsStorePayment != null) {
|
|
|
|
|
+ String orderType = "";
|
|
|
|
|
+ if (fsStorePayment.getBusinessType() == 1) {
|
|
|
|
|
+ orderType = "inquiry";
|
|
|
|
|
+ } else if (fsStorePayment.getBusinessType() == 2) {
|
|
|
|
|
+ orderType = "store";
|
|
|
|
|
+ } else if (fsStorePayment.getBusinessType() == 3) {
|
|
|
|
|
+ orderType = "package";
|
|
|
|
|
+ } else if (fsStorePayment.getBusinessType() == 4) {
|
|
|
|
|
+ orderType = "course";
|
|
|
|
|
+ } else if (fsStorePayment.getBusinessType() == 5) {
|
|
|
|
|
+ orderType = "appvip";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(fsStorePayment.getPayMode().equals("wx")){
|
|
|
|
|
|
|
+ if (fsStorePayment.getPayMode().equals("wx")) {
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
|
|
SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
|
|
|
FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
|
|
FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
|
|
@@ -431,72 +409,69 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
wxPayService.setConfig(payConfig);
|
|
wxPayService.setConfig(payConfig);
|
|
|
WxPayRefundRequest refundRequest = new WxPayRefundRequest();
|
|
WxPayRefundRequest refundRequest = new WxPayRefundRequest();
|
|
|
- refundRequest.setOutTradeNo(orderType+"-"+fsStorePayment.getPayCode());
|
|
|
|
|
- refundRequest.setOutRefundNo(orderType+"-"+fsStorePayment.getPayCode());
|
|
|
|
|
|
|
+ refundRequest.setOutTradeNo(orderType + "-" + fsStorePayment.getPayCode());
|
|
|
|
|
+ refundRequest.setOutRefundNo(orderType + "-" + fsStorePayment.getPayCode());
|
|
|
refundRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(fsStorePayment.getPayMoney().toString()));
|
|
refundRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(fsStorePayment.getPayMoney().toString()));
|
|
|
refundRequest.setRefundFee(WxPayUnifiedOrderRequest.yuanToFen(fsStorePayment.getPayMoney().toString()));
|
|
refundRequest.setRefundFee(WxPayUnifiedOrderRequest.yuanToFen(fsStorePayment.getPayMoney().toString()));
|
|
|
try {
|
|
try {
|
|
|
WxPayRefundResult refundResult = wxPayService.refund(refundRequest);
|
|
WxPayRefundResult refundResult = wxPayService.refund(refundRequest);
|
|
|
WxPayRefundQueryResult refundQueryResult = wxPayService.refundQuery("", refundResult.getOutTradeNo(), refundResult.getOutRefundNo(), refundResult.getRefundId());
|
|
WxPayRefundQueryResult refundQueryResult = wxPayService.refundQuery("", refundResult.getOutTradeNo(), refundResult.getOutRefundNo(), refundResult.getRefundId());
|
|
|
- if(refundQueryResult!=null&&refundQueryResult.getResultCode().equals("SUCCESS")){
|
|
|
|
|
- FsStorePayment paymentMap=new FsStorePayment();
|
|
|
|
|
|
|
+ if (refundQueryResult != null && refundQueryResult.getResultCode().equals("SUCCESS")) {
|
|
|
|
|
+ FsStorePayment paymentMap = new FsStorePayment();
|
|
|
paymentMap.setPaymentId(fsStorePayment.getPaymentId());
|
|
paymentMap.setPaymentId(fsStorePayment.getPaymentId());
|
|
|
paymentMap.setStatus(-1);
|
|
paymentMap.setStatus(-1);
|
|
|
paymentMap.setRefundTime(DateUtils.getNowDate());
|
|
paymentMap.setRefundTime(DateUtils.getNowDate());
|
|
|
paymentMap.setRefundMoney(fsStorePayment.getPayMoney());
|
|
paymentMap.setRefundMoney(fsStorePayment.getPayMoney());
|
|
|
fsStorePaymentMapper.updateFsStorePayment(paymentMap);
|
|
fsStorePaymentMapper.updateFsStorePayment(paymentMap);
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- throw new CustomException("退款请求失败"+refundQueryResult.getReturnMsg());
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new CustomException("退款请求失败" + refundQueryResult.getReturnMsg());
|
|
|
}
|
|
}
|
|
|
} catch (WxPayException e) {
|
|
} catch (WxPayException e) {
|
|
|
- throw new CustomException("退款请求失败"+e.getReturnMsg());
|
|
|
|
|
|
|
+ throw new CustomException("退款请求失败" + e.getReturnMsg());
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- else if(fsStorePayment.getPayMode().equals("yb")){
|
|
|
|
|
|
|
+ } else if (fsStorePayment.getPayMode().equals("yb")) {
|
|
|
//易宝
|
|
//易宝
|
|
|
- RefundDTO refundDTO=new RefundDTO();
|
|
|
|
|
|
|
+ RefundDTO refundDTO = new RefundDTO();
|
|
|
refundDTO.setRefundMoney(fsStorePayment.getPayMoney().toString());
|
|
refundDTO.setRefundMoney(fsStorePayment.getPayMoney().toString());
|
|
|
- refundDTO.setLowRefundNo(orderType+"-"+fsStorePayment.getPayCode());
|
|
|
|
|
|
|
+ refundDTO.setLowRefundNo(orderType + "-" + fsStorePayment.getPayCode());
|
|
|
refundDTO.setUpOrderId(fsStorePayment.getTradeNo());
|
|
refundDTO.setUpOrderId(fsStorePayment.getTradeNo());
|
|
|
- com.fs.ybPay.domain.RefundResult result=payService.refund(refundDTO);
|
|
|
|
|
- logger.info("订单退款返回结果:退款订单id:"+paymentId+result);
|
|
|
|
|
- if(result.getState().equals("5")){
|
|
|
|
|
- FsStorePayment paymentMap=new FsStorePayment();
|
|
|
|
|
|
|
+ com.fs.ybPay.domain.RefundResult result = payService.refund(refundDTO);
|
|
|
|
|
+ logger.info("订单退款返回结果:退款订单id:" + paymentId + result);
|
|
|
|
|
+ if (result.getState().equals("5")) {
|
|
|
|
|
+ FsStorePayment paymentMap = new FsStorePayment();
|
|
|
paymentMap.setPaymentId(fsStorePayment.getPaymentId());
|
|
paymentMap.setPaymentId(fsStorePayment.getPaymentId());
|
|
|
paymentMap.setStatus(-1);
|
|
paymentMap.setStatus(-1);
|
|
|
paymentMap.setRefundTime(DateUtils.getNowDate());
|
|
paymentMap.setRefundTime(DateUtils.getNowDate());
|
|
|
paymentMap.setRefundMoney(fsStorePayment.getPayMoney());
|
|
paymentMap.setRefundMoney(fsStorePayment.getPayMoney());
|
|
|
fsStorePaymentMapper.updateFsStorePayment(paymentMap);
|
|
fsStorePaymentMapper.updateFsStorePayment(paymentMap);
|
|
|
- }else {
|
|
|
|
|
- throw new CustomException("退款请求失败"+result.getMessage());
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new CustomException("退款请求失败" + result.getMessage());
|
|
|
}
|
|
}
|
|
|
- } else if(fsStorePayment.getPayMode().equals("tz")){
|
|
|
|
|
|
|
+ } else if (fsStorePayment.getPayMode().equals("tz")) {
|
|
|
RefundParam tzBankResult = new RefundParam();
|
|
RefundParam tzBankResult = new RefundParam();
|
|
|
// 使用set方法为对象的字段赋值
|
|
// 使用set方法为对象的字段赋值
|
|
|
//商户原支付订单号
|
|
//商户原支付订单号
|
|
|
- tzBankResult.setOldPayOutOrderNo(orderType+fsStorePayment.getPayCode());
|
|
|
|
|
|
|
+ tzBankResult.setOldPayOutOrderNo(orderType + fsStorePayment.getPayCode());
|
|
|
// 商户退款订单号 对接平台系统里自己生成的退款订单号
|
|
// 商户退款订单号 对接平台系统里自己生成的退款订单号
|
|
|
- tzBankResult.setRefundOrderNo(orderType+fsStorePayment.getPayCode());
|
|
|
|
|
|
|
+ tzBankResult.setRefundOrderNo(orderType + fsStorePayment.getPayCode());
|
|
|
// 交易发送时间 yyyyMMddHHmmss
|
|
// 交易发送时间 yyyyMMddHHmmss
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
tzBankResult.setTrxSendTime(sdf.format(new Date()));
|
|
tzBankResult.setTrxSendTime(sdf.format(new Date()));
|
|
|
// 退款金额
|
|
// 退款金额
|
|
|
tzBankResult.setRefundOrdTransAmt(fsStorePayment.getPayMoney().doubleValue());
|
|
tzBankResult.setRefundOrdTransAmt(fsStorePayment.getPayMoney().doubleValue());
|
|
|
TzBankResult<com.fs.tzBankPay.doman.RefundResult> result = tzBankService.refund(tzBankResult);
|
|
TzBankResult<com.fs.tzBankPay.doman.RefundResult> result = tzBankService.refund(tzBankResult);
|
|
|
- logger.info("订单退款返回结果:退款订单id:"+paymentId+result);
|
|
|
|
|
- if(result.getBody().getRefundOrdStatus().equals("90")||result.getBody().getRefundOrdStatus().equals("60")){
|
|
|
|
|
- FsStorePayment paymentMap=new FsStorePayment();
|
|
|
|
|
|
|
+ logger.info("订单退款返回结果:退款订单id:" + paymentId + result);
|
|
|
|
|
+ if (result.getBody().getRefundOrdStatus().equals("90") || result.getBody().getRefundOrdStatus().equals("60")) {
|
|
|
|
|
+ FsStorePayment paymentMap = new FsStorePayment();
|
|
|
paymentMap.setPaymentId(fsStorePayment.getPaymentId());
|
|
paymentMap.setPaymentId(fsStorePayment.getPaymentId());
|
|
|
paymentMap.setStatus(-1);
|
|
paymentMap.setStatus(-1);
|
|
|
paymentMap.setRefundTime(DateUtils.getNowDate());
|
|
paymentMap.setRefundTime(DateUtils.getNowDate());
|
|
|
paymentMap.setRefundMoney(fsStorePayment.getPayMoney());
|
|
paymentMap.setRefundMoney(fsStorePayment.getPayMoney());
|
|
|
fsStorePaymentMapper.updateFsStorePayment(paymentMap);
|
|
fsStorePaymentMapper.updateFsStorePayment(paymentMap);
|
|
|
- }else {
|
|
|
|
|
- throw new CustomException("退款请求失败"+result.getRetMsg());
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new CustomException("退款请求失败" + result.getRetMsg());
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- else if(fsStorePayment.getPayMode().equals("hf")){
|
|
|
|
|
|
|
+ } else if (fsStorePayment.getPayMode().equals("hf")) {
|
|
|
if (fsStorePayment.getIsShare() == 1 && fsStorePayment.getShareStatus() == 1) {
|
|
if (fsStorePayment.getIsShare() == 1 && fsStorePayment.getShareStatus() == 1) {
|
|
|
V2TradePaymentDelaytransConfirmrefundRequest confirmRefundRequest = new V2TradePaymentDelaytransConfirmrefundRequest();
|
|
V2TradePaymentDelaytransConfirmrefundRequest confirmRefundRequest = new V2TradePaymentDelaytransConfirmrefundRequest();
|
|
|
//Map<String, Object> extendInfoMap = new HashMap<>();
|
|
//Map<String, Object> extendInfoMap = new HashMap<>();
|
|
@@ -510,12 +485,12 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
//多汇付使用appID
|
|
//多汇付使用appID
|
|
|
HuifuConfirmrefundResult result = huiFuService.confirmRefund(confirmRefundRequest, null);
|
|
HuifuConfirmrefundResult result = huiFuService.confirmRefund(confirmRefundRequest, null);
|
|
|
if (result.getResp_code().equals("00000000") && (result.getTrans_stat().equals("S") || result.getTrans_stat().equals("P"))) {
|
|
if (result.getResp_code().equals("00000000") && (result.getTrans_stat().equals("S") || result.getTrans_stat().equals("P"))) {
|
|
|
- refund(fsStorePayment,orderType,paymentId);
|
|
|
|
|
|
|
+ refund(fsStorePayment, orderType, paymentId);
|
|
|
} else {
|
|
} else {
|
|
|
throw new CustomException("交易确认退款请求失败" + result.getResp_desc());
|
|
throw new CustomException("交易确认退款请求失败" + result.getResp_desc());
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- refund(fsStorePayment,orderType,paymentId);
|
|
|
|
|
|
|
+ refund(fsStorePayment, orderType, paymentId);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -557,14 +532,15 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private RedPacketLogMapper redPacketLogMapper;
|
|
private RedPacketLogMapper redPacketLogMapper;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
- @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
|
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
|
|
|
public R sendRedPacket(WxSendRedPacketParam param) {
|
|
public R sendRedPacket(WxSendRedPacketParam param) {
|
|
|
|
|
|
|
|
String json;
|
|
String json;
|
|
|
RedPacketConfig config = new RedPacketConfig();
|
|
RedPacketConfig config = new RedPacketConfig();
|
|
|
// 根据红包模式获取配置
|
|
// 根据红包模式获取配置
|
|
|
- switch (param.getRedPacketMode()){
|
|
|
|
|
|
|
+ switch (param.getRedPacketMode()) {
|
|
|
case 1:
|
|
case 1:
|
|
|
json = configService.selectConfigByKey("redPacket.config");
|
|
json = configService.selectConfigByKey("redPacket.config");
|
|
|
config = JSONUtil.toBean(json, RedPacketConfig.class);
|
|
config = JSONUtil.toBean(json, RedPacketConfig.class);
|
|
@@ -575,25 +551,42 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
//H5的用公众号的appid发,小程序的用小程序的appid来发
|
|
//H5的用公众号的appid发,小程序的用小程序的appid来发
|
|
|
- if (param.getSource()==2){
|
|
|
|
|
|
|
+ if (param.getSource() == 2) {
|
|
|
// 传参appId为空时,仍然使用配置里面的
|
|
// 传参appId为空时,仍然使用配置里面的
|
|
|
String appId = StringUtils.isBlank(param.getAppId()) ? config.getMiniappId() : param.getAppId();
|
|
String appId = StringUtils.isBlank(param.getAppId()) ? config.getMiniappId() : param.getAppId();
|
|
|
config.setAppId(appId);
|
|
config.setAppId(appId);
|
|
|
}
|
|
}
|
|
|
- logger.info("最终传参 {}",config);
|
|
|
|
|
|
|
+ logger.info("最终传参 {}", config);
|
|
|
//组合返回参数
|
|
//组合返回参数
|
|
|
- R result = new R();
|
|
|
|
|
// 根据 isNew 判断使用哪种发红包方式
|
|
// 根据 isNew 判断使用哪种发红包方式
|
|
|
|
|
+ R result;
|
|
|
if (config.getIsNew() != null && config.getIsNew() == 1) {
|
|
if (config.getIsNew() != null && config.getIsNew() == 1) {
|
|
|
result = sendRedPacketV3Internal(param, config);
|
|
result = sendRedPacketV3Internal(param, config);
|
|
|
} else {
|
|
} else {
|
|
|
- result= sendRedPacketLegacyInternal(param, config);
|
|
|
|
|
|
|
+ result = sendRedPacketLegacyInternal(param, config);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (result.getMsg().equals("余额不足") && param.getRedPacketMode() == 1) {
|
|
|
|
|
+ String backConfigStr = configService.selectConfigByKey("redPacket.config.back");
|
|
|
|
|
+ if (StringUtils.isNotBlank(backConfigStr)) {
|
|
|
|
|
+ List<RedPacketConfig> backConfigList = JSONArray.parseArray(backConfigStr, RedPacketConfig.class);
|
|
|
|
|
+ for (RedPacketConfig redPacketConfig : backConfigList) {
|
|
|
|
|
+ if (config.getIsNew() != null && config.getIsNew() == 1) {
|
|
|
|
|
+ result = sendRedPacketV3Internal(param, redPacketConfig);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ result = sendRedPacketLegacyInternal(param, redPacketConfig);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (result.isSuccess()) {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- result.put("mchId",config.getMchId()+"");
|
|
|
|
|
- result.put("isNew",config.getIsNew());
|
|
|
|
|
- logger.info("红包返回:{}",result);
|
|
|
|
|
|
|
+ result.put("mchId", config.getMchId() + "");
|
|
|
|
|
+ result.put("isNew", config.getIsNew());
|
|
|
|
|
+ logger.info("红包返回:{}", result);
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
private static long getExpireSeconds() {
|
|
private static long getExpireSeconds() {
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
|
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
|
@@ -604,6 +597,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
// 计算从现在到明天凌晨的秒数
|
|
// 计算从现在到明天凌晨的秒数
|
|
|
return (calendar.getTimeInMillis() - System.currentTimeMillis()) / 1000;
|
|
return (calendar.getTimeInMillis() - System.currentTimeMillis()) / 1000;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
// 内部方法:处理新版本的发红包逻辑
|
|
// 内部方法:处理新版本的发红包逻辑
|
|
|
private R sendRedPacketV3Internal(WxSendRedPacketParam param, RedPacketConfig config) {
|
|
private R sendRedPacketV3Internal(WxSendRedPacketParam param, RedPacketConfig config) {
|
|
|
|
|
|
|
@@ -617,8 +611,8 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
request.setAppid(config.getAppId());
|
|
request.setAppid(config.getAppId());
|
|
|
request.setOpenid(param.getOpenId());
|
|
request.setOpenid(param.getOpenId());
|
|
|
|
|
|
|
|
- String code = OrderCodeUtils.getOrderSn();
|
|
|
|
|
- if(StringUtils.isEmpty(code)){
|
|
|
|
|
|
|
+ String code = OrderCodeUtils.getOrderSn();
|
|
|
|
|
+ if (StringUtils.isEmpty(code)) {
|
|
|
return R.error("订单生成失败,请重试");
|
|
return R.error("订单生成失败,请重试");
|
|
|
}
|
|
}
|
|
|
// String code = String.valueOf(IdUtil.getSnowflake(0, 0).nextId());
|
|
// String code = String.valueOf(IdUtil.getSnowflake(0, 0).nextId());
|
|
@@ -649,8 +643,11 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
TransferBillsResult transferBillsResult = transferService.transferBills(request);
|
|
TransferBillsResult transferBillsResult = transferService.transferBills(request);
|
|
|
logger.info("商家转账支付完成:[msg:{}]", transferBillsResult);
|
|
logger.info("商家转账支付完成:[msg:{}]", transferBillsResult);
|
|
|
return R.ok("发送红包成功").put("data", transferBillsResult);
|
|
return R.ok("发送红包成功").put("data", transferBillsResult);
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- logger.error("商家转账支付失败:参数: {} :原因: {}",JSON.toJSONString(param), e.getMessage(),e);
|
|
|
|
|
|
|
+ } catch (WxPayException e) {
|
|
|
|
|
+ logger.error("商家转账支付失败:参数: {} :原因: {}", JSON.toJSONString(param), e.getMessage(), e);
|
|
|
|
|
+ if ("NOT_ENOUGH".equals(e.getErrCode())) {
|
|
|
|
|
+ return R.error("余额不足");
|
|
|
|
|
+ }
|
|
|
return R.error("发送红包失败");
|
|
return R.error("发送红包失败");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -659,7 +656,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
private R sendRedPacketLegacyInternal(WxSendRedPacketParam param, RedPacketConfig config) {
|
|
private R sendRedPacketLegacyInternal(WxSendRedPacketParam param, RedPacketConfig config) {
|
|
|
//如果服务号的配置存在,小程序红包接口可以使用服务号来发红包,重新赋值
|
|
//如果服务号的配置存在,小程序红包接口可以使用服务号来发红包,重新赋值
|
|
|
//仅老商户支持
|
|
//仅老商户支持
|
|
|
- if (param.getUser().getMpOpenId()!=null && StringUtils.isNotEmpty(param.getMpAppId())){
|
|
|
|
|
|
|
+ if (param.getUser().getMpOpenId() != null && StringUtils.isNotEmpty(param.getMpAppId())) {
|
|
|
config.setAppId(param.getMpAppId());
|
|
config.setAppId(param.getMpAppId());
|
|
|
param.setOpenId(param.getUser().getMpOpenId());
|
|
param.setOpenId(param.getUser().getMpOpenId());
|
|
|
}
|
|
}
|
|
@@ -675,11 +672,11 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
|
|
|
|
|
// todo 如果未配置负载均衡请还原原本的单号方式
|
|
// todo 如果未配置负载均衡请还原原本的单号方式
|
|
|
// String code = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
// String code = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
- String code = OrderCodeUtils.getOrderSn();
|
|
|
|
|
- if(StringUtils.isEmpty(code)){
|
|
|
|
|
|
|
+ String code = OrderCodeUtils.getOrderSn();
|
|
|
|
|
+ if (StringUtils.isEmpty(code)) {
|
|
|
return R.error("红包单号生成失败,请重试");
|
|
return R.error("红包单号生成失败,请重试");
|
|
|
}
|
|
}
|
|
|
- request.setOutBatchNo("fsCourse"+cloudHostProper.getProjectCode() + code);
|
|
|
|
|
|
|
+ request.setOutBatchNo("fsCourse" + cloudHostProper.getProjectCode() + code);
|
|
|
request.setBatchRemark("课堂答题奖励");
|
|
request.setBatchRemark("课堂答题奖励");
|
|
|
request.setBatchName("课堂答题奖励");
|
|
request.setBatchName("课堂答题奖励");
|
|
|
Integer amount = WxPayUnifiedOrderRequest.yuanToFen(param.getAmount().toString());
|
|
Integer amount = WxPayUnifiedOrderRequest.yuanToFen(param.getAmount().toString());
|
|
@@ -691,7 +688,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
TransferBatchesRequest.TransferDetail transferDetail = new TransferBatchesRequest.TransferDetail();
|
|
TransferBatchesRequest.TransferDetail transferDetail = new TransferBatchesRequest.TransferDetail();
|
|
|
transferDetail.setOpenid(param.getOpenId());
|
|
transferDetail.setOpenid(param.getOpenId());
|
|
|
String code1 = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
String code1 = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
- transferDetail.setOutDetailNo("fsCourse"+cloudHostProper.getProjectCode() + code1);
|
|
|
|
|
|
|
+ transferDetail.setOutDetailNo("fsCourse" + cloudHostProper.getProjectCode() + code1);
|
|
|
transferDetail.setTransferAmount(amount);
|
|
transferDetail.setTransferAmount(amount);
|
|
|
transferDetail.setTransferRemark("恭喜同学,认真听课,奖励你一朵小红花!");
|
|
transferDetail.setTransferRemark("恭喜同学,认真听课,奖励你一朵小红花!");
|
|
|
transferDetailList.add(transferDetail);
|
|
transferDetailList.add(transferDetail);
|
|
@@ -700,22 +697,25 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
try {
|
|
try {
|
|
|
TransferBatchesResult transferBatchesResult = transferService.transferBatches(request);
|
|
TransferBatchesResult transferBatchesResult = transferService.transferBatches(request);
|
|
|
return R.ok("发送红包成功").put("orderCode", transferBatchesResult.getOutBatchNo()).put("batchId", transferBatchesResult.getBatchId());
|
|
return R.ok("发送红包成功").put("orderCode", transferBatchesResult.getOutBatchNo()).put("batchId", transferBatchesResult.getBatchId());
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- logger.error("商家转账支付失败:参数: {} :原因: {}",JSON.toJSONString(param), e.getMessage(),e);
|
|
|
|
|
- throw new RuntimeException(e);
|
|
|
|
|
|
|
+ } catch (WxPayException e) {
|
|
|
|
|
+ logger.error("商家转账支付失败:参数: {} :原因: {}", JSON.toJSONString(param), e.getMessage(), e);
|
|
|
|
|
+ if ("NOT_ENOUGH".equals(e.getErrCode())) {
|
|
|
|
|
+ return R.error("余额不足");
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.error("发送红包失败");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public String transferNotify(String notifyData, HttpServletRequest request) {
|
|
public String transferNotify(String notifyData, HttpServletRequest request) {
|
|
|
- logger.info("zyp \n【收到转账回调】:{}",notifyData);
|
|
|
|
|
|
|
+ logger.info("zyp \n【收到转账回调】:{}", notifyData);
|
|
|
try {
|
|
try {
|
|
|
String json = configService.selectConfigByKey("redPacket.config");
|
|
String json = configService.selectConfigByKey("redPacket.config");
|
|
|
RedPacketConfig config = JSONUtil.toBean(json, RedPacketConfig.class);
|
|
RedPacketConfig config = JSONUtil.toBean(json, RedPacketConfig.class);
|
|
|
//创建微信订单
|
|
//创建微信订单
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
- BeanUtils.copyProperties(config,payConfig);
|
|
|
|
|
|
|
+ BeanUtils.copyProperties(config, payConfig);
|
|
|
WxPayService wxPayService = new WxPayServiceImpl();
|
|
WxPayService wxPayService = new WxPayServiceImpl();
|
|
|
wxPayService.setConfig(payConfig);
|
|
wxPayService.setConfig(payConfig);
|
|
|
SignatureHeader signatureHeader = new SignatureHeader();
|
|
SignatureHeader signatureHeader = new SignatureHeader();
|
|
@@ -723,17 +723,17 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
signatureHeader.setNonce(request.getHeader("Wechatpay-Nonce"));
|
|
signatureHeader.setNonce(request.getHeader("Wechatpay-Nonce"));
|
|
|
signatureHeader.setSerial(request.getHeader("Wechatpay-Serial"));
|
|
signatureHeader.setSerial(request.getHeader("Wechatpay-Serial"));
|
|
|
signatureHeader.setSignature(request.getHeader("Wechatpay-Signature"));
|
|
signatureHeader.setSignature(request.getHeader("Wechatpay-Signature"));
|
|
|
- WxPayTransferBatchesNotifyV3Result result = wxPayService.parseTransferBatchesNotifyV3Result(notifyData,signatureHeader);
|
|
|
|
|
- logger.info("到零钱回调:{}",result.getResult());
|
|
|
|
|
- if (result.getResult().getBatchStatus().equals("FINISHED") && result.getResult().getFailNum()==0) {
|
|
|
|
|
- R r = redPacketLogService.syncRedPacket(result.getResult().getOutBatchNo(),result.getResult().getBatchId());
|
|
|
|
|
- logger.info("result:{}",r);
|
|
|
|
|
- if (r.get("code").equals(200)){
|
|
|
|
|
|
|
+ WxPayTransferBatchesNotifyV3Result result = wxPayService.parseTransferBatchesNotifyV3Result(notifyData, signatureHeader);
|
|
|
|
|
+ logger.info("到零钱回调:{}", result.getResult());
|
|
|
|
|
+ if (result.getResult().getBatchStatus().equals("FINISHED") && result.getResult().getFailNum() == 0) {
|
|
|
|
|
+ R r = redPacketLogService.syncRedPacket(result.getResult().getOutBatchNo(), result.getResult().getBatchId());
|
|
|
|
|
+ logger.info("result:{}", r);
|
|
|
|
|
+ if (r.get("code").equals(200)) {
|
|
|
return WxPayNotifyResponse.success("处理成功");
|
|
return WxPayNotifyResponse.success("处理成功");
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
return WxPayNotifyResponse.fail("");
|
|
return WxPayNotifyResponse.fail("");
|
|
|
}
|
|
}
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
return WxPayNotifyResponse.fail("");
|
|
return WxPayNotifyResponse.fail("");
|
|
|
}
|
|
}
|
|
|
} catch (WxPayException e) {
|
|
} catch (WxPayException e) {
|
|
@@ -777,7 +777,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
|
|
|
|
|
//创建微信订单
|
|
//创建微信订单
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
- BeanUtils.copyProperties(config,payConfig);
|
|
|
|
|
|
|
+ BeanUtils.copyProperties(config, payConfig);
|
|
|
WxPayService wxPayService = new WxPayServiceImpl();
|
|
WxPayService wxPayService = new WxPayServiceImpl();
|
|
|
wxPayService.setConfig(payConfig);
|
|
wxPayService.setConfig(payConfig);
|
|
|
TransferService transferService = wxPayService.getTransferService();
|
|
TransferService transferService = wxPayService.getTransferService();
|
|
@@ -792,9 +792,9 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
// return R.error("订单生成失败,请重试");
|
|
// return R.error("订单生成失败,请重试");
|
|
|
// }
|
|
// }
|
|
|
String code = String.valueOf(IdUtil.getSnowflake(0, 0).nextId());
|
|
String code = String.valueOf(IdUtil.getSnowflake(0, 0).nextId());
|
|
|
- request.setOutBillNo("fsCourse"+code);
|
|
|
|
|
|
|
+ request.setOutBillNo("fsCourse" + code);
|
|
|
//转账金额
|
|
//转账金额
|
|
|
- Integer amount = WxPayUnifiedOrderRequest.yuanToFen(param.getAmount()!=null ? param.getAmount().toString() : "0.1");
|
|
|
|
|
|
|
+ Integer amount = WxPayUnifiedOrderRequest.yuanToFen(param.getAmount() != null ? param.getAmount().toString() : "0.1");
|
|
|
request.setTransferAmount(amount);
|
|
request.setTransferAmount(amount);
|
|
|
request.setTransferRemark("活动奖励");
|
|
request.setTransferRemark("活动奖励");
|
|
|
//用户感知
|
|
//用户感知
|
|
@@ -816,14 +816,14 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
request.setTransferSceneReportInfos(transferSceneReportInfos);
|
|
request.setTransferSceneReportInfos(transferSceneReportInfos);
|
|
|
|
|
|
|
|
//发起商家转账API(新)
|
|
//发起商家转账API(新)
|
|
|
- TransferBillsResult transferBillsResult=null;
|
|
|
|
|
|
|
+ TransferBillsResult transferBillsResult = null;
|
|
|
try {
|
|
try {
|
|
|
transferBillsResult = transferService.transferBills(request);
|
|
transferBillsResult = transferService.transferBills(request);
|
|
|
- logger.info("商家转账支付完成:[msg:{}]",transferBillsResult);
|
|
|
|
|
- return R.ok("发送红包成功").put("data",transferBillsResult);
|
|
|
|
|
|
|
+ logger.info("商家转账支付完成:[msg:{}]", transferBillsResult);
|
|
|
|
|
+ return R.ok("发送红包成功").put("data", transferBillsResult);
|
|
|
} catch (WxPayException e) {
|
|
} catch (WxPayException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
- logger.info("商家转账支付失败:[msg:{}]",e.getMessage());
|
|
|
|
|
|
|
+ logger.info("商家转账支付失败:[msg:{}]", e.getMessage());
|
|
|
return R.error("发送失败");
|
|
return R.error("发送失败");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -831,13 +831,13 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public String v3TransferNotify(String notifyData, HttpServletRequest request) {
|
|
public String v3TransferNotify(String notifyData, HttpServletRequest request) {
|
|
|
- logger.info("zyp \n【收到转账回调】:{}",notifyData);
|
|
|
|
|
|
|
+ logger.info("zyp \n【收到转账回调】:{}", notifyData);
|
|
|
try {
|
|
try {
|
|
|
String json = configService.selectConfigByKey("redPacket.config");
|
|
String json = configService.selectConfigByKey("redPacket.config");
|
|
|
RedPacketConfig config = JSONUtil.toBean(json, RedPacketConfig.class);
|
|
RedPacketConfig config = JSONUtil.toBean(json, RedPacketConfig.class);
|
|
|
//创建微信订单
|
|
//创建微信订单
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
- BeanUtils.copyProperties(config,payConfig);
|
|
|
|
|
|
|
+ BeanUtils.copyProperties(config, payConfig);
|
|
|
WxPayService wxPayService = new WxPayServiceImpl();
|
|
WxPayService wxPayService = new WxPayServiceImpl();
|
|
|
wxPayService.setConfig(payConfig);
|
|
wxPayService.setConfig(payConfig);
|
|
|
SignatureHeader signatureHeader = new SignatureHeader();
|
|
SignatureHeader signatureHeader = new SignatureHeader();
|
|
@@ -845,17 +845,17 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
signatureHeader.setNonce(request.getHeader("Wechatpay-Nonce"));
|
|
signatureHeader.setNonce(request.getHeader("Wechatpay-Nonce"));
|
|
|
signatureHeader.setSerial(request.getHeader("Wechatpay-Serial"));
|
|
signatureHeader.setSerial(request.getHeader("Wechatpay-Serial"));
|
|
|
signatureHeader.setSignature(request.getHeader("Wechatpay-Signature"));
|
|
signatureHeader.setSignature(request.getHeader("Wechatpay-Signature"));
|
|
|
- TransferBillsNotifyResult result = wxPayService.parseTransferBillsNotifyV3Result(notifyData,signatureHeader);
|
|
|
|
|
- logger.info("到零钱回调:{}",result.getResult());
|
|
|
|
|
|
|
+ TransferBillsNotifyResult result = wxPayService.parseTransferBillsNotifyV3Result(notifyData, signatureHeader);
|
|
|
|
|
+ logger.info("到零钱回调:{}", result.getResult());
|
|
|
if (result.getResult().getState().equals("SUCCESS")) {
|
|
if (result.getResult().getState().equals("SUCCESS")) {
|
|
|
- R r = redPacketLogService.syncRedPacket(result.getResult().getOutBillNo(),result.getResult().getTransferBillNo());
|
|
|
|
|
- logger.info("result:{}",r);
|
|
|
|
|
- if (r.get("code").equals(200)){
|
|
|
|
|
|
|
+ R r = redPacketLogService.syncRedPacket(result.getResult().getOutBillNo(), result.getResult().getTransferBillNo());
|
|
|
|
|
+ logger.info("result:{}", r);
|
|
|
|
|
+ if (r.get("code").equals(200)) {
|
|
|
return WxPayNotifyResponse.success("处理成功");
|
|
return WxPayNotifyResponse.success("处理成功");
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
return WxPayNotifyResponse.fail("");
|
|
return WxPayNotifyResponse.fail("");
|
|
|
}
|
|
}
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
return WxPayNotifyResponse.fail("");
|
|
return WxPayNotifyResponse.fail("");
|
|
|
}
|
|
}
|
|
|
} catch (WxPayException e) {
|
|
} catch (WxPayException e) {
|
|
@@ -872,7 +872,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
RedPacketConfig config = JSONUtil.toBean(json, RedPacketConfig.class);
|
|
RedPacketConfig config = JSONUtil.toBean(json, RedPacketConfig.class);
|
|
|
//创建微信订单
|
|
//创建微信订单
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
- BeanUtils.copyProperties(config,payConfig);
|
|
|
|
|
|
|
+ BeanUtils.copyProperties(config, payConfig);
|
|
|
payConfig.setAppId("wxc3f0a952b7bc2b94");
|
|
payConfig.setAppId("wxc3f0a952b7bc2b94");
|
|
|
WxPayService wxPayService = new WxPayServiceImpl();
|
|
WxPayService wxPayService = new WxPayServiceImpl();
|
|
|
wxPayService.setConfig(payConfig);
|
|
wxPayService.setConfig(payConfig);
|
|
@@ -887,42 +887,43 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
// return R.error("订单生成失败,请重试");
|
|
// return R.error("订单生成失败,请重试");
|
|
|
// }
|
|
// }
|
|
|
String code = String.valueOf(IdUtil.getSnowflake(0, 0).nextId());
|
|
String code = String.valueOf(IdUtil.getSnowflake(0, 0).nextId());
|
|
|
- request.setOutBatchNo("fsCourse"+code);
|
|
|
|
|
|
|
+ request.setOutBatchNo("fsCourse" + code);
|
|
|
request.setBatchRemark("课堂答题奖励");
|
|
request.setBatchRemark("课堂答题奖励");
|
|
|
request.setBatchName("课堂答题奖励");
|
|
request.setBatchName("课堂答题奖励");
|
|
|
- Integer amount = WxPayUnifiedOrderRequest.yuanToFen(param.getAmount()!=null ? param.getAmount().toString() : "0.1");
|
|
|
|
|
|
|
+ Integer amount = WxPayUnifiedOrderRequest.yuanToFen(param.getAmount() != null ? param.getAmount().toString() : "0.1");
|
|
|
request.setTotalAmount(amount);
|
|
request.setTotalAmount(amount);
|
|
|
request.setTotalNum(1);
|
|
request.setTotalNum(1);
|
|
|
request.setNotifyUrl(config.getNotifyUrl());
|
|
request.setNotifyUrl(config.getNotifyUrl());
|
|
|
ArrayList<TransferBatchesRequest.TransferDetail> transferDetailList = new ArrayList<>();
|
|
ArrayList<TransferBatchesRequest.TransferDetail> transferDetailList = new ArrayList<>();
|
|
|
TransferBatchesRequest.TransferDetail transferDetail = new TransferBatchesRequest.TransferDetail();
|
|
TransferBatchesRequest.TransferDetail transferDetail = new TransferBatchesRequest.TransferDetail();
|
|
|
transferDetail.setOpenid(param.getOpenId());
|
|
transferDetail.setOpenid(param.getOpenId());
|
|
|
- String code1 = String.valueOf(IdUtil.getSnowflake(0, 0).nextId());
|
|
|
|
|
- transferDetail.setOutDetailNo("fsCourse"+code1);
|
|
|
|
|
|
|
+ String code1 = String.valueOf(IdUtil.getSnowflake(0, 0).nextId());
|
|
|
|
|
+ transferDetail.setOutDetailNo("fsCourse" + code1);
|
|
|
transferDetail.setTransferAmount(amount);
|
|
transferDetail.setTransferAmount(amount);
|
|
|
transferDetail.setTransferRemark("恭喜同学,认真听课,奖励你一朵小红花!");
|
|
transferDetail.setTransferRemark("恭喜同学,认真听课,奖励你一朵小红花!");
|
|
|
transferDetailList.add(transferDetail);
|
|
transferDetailList.add(transferDetail);
|
|
|
request.setTransferDetailList(transferDetailList);
|
|
request.setTransferDetailList(transferDetailList);
|
|
|
- TransferBatchesResult transferBatchesResult=null;
|
|
|
|
|
|
|
+ TransferBatchesResult transferBatchesResult = null;
|
|
|
try {
|
|
try {
|
|
|
transferBatchesResult = transferService.transferBatches(request);
|
|
transferBatchesResult = transferService.transferBatches(request);
|
|
|
- logger.info("商家转账支付完成:[msg:{}]",transferBatchesResult);
|
|
|
|
|
- return R.ok("发送红包成功").put("orderCode",transferBatchesResult.getOutBatchNo());
|
|
|
|
|
|
|
+ logger.info("商家转账支付完成:[msg:{}]", transferBatchesResult);
|
|
|
|
|
+ return R.ok("发送红包成功").put("orderCode", transferBatchesResult.getOutBatchNo());
|
|
|
} catch (WxPayException e) {
|
|
} catch (WxPayException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
- logger.info("商家转账支付失败:[msg:{}]",e.getMessage());
|
|
|
|
|
|
|
+ logger.info("商家转账支付失败:[msg:{}]", e.getMessage());
|
|
|
return R.error("发送失败");
|
|
return R.error("发送失败");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- @DataScope(deptAlias = "cu",userAlias = "cu")
|
|
|
|
|
|
|
+ @DataScope(deptAlias = "cu", userAlias = "cu")
|
|
|
public List<FsStorePaymentVO> selectFsStorePaymentListQueryVO(FsStorePaymentParam fsStorePayment) {
|
|
public List<FsStorePaymentVO> selectFsStorePaymentListQueryVO(FsStorePaymentParam fsStorePayment) {
|
|
|
return fsStorePaymentMapper.selectFsStorePaymentListQueryVO(fsStorePayment);
|
|
return fsStorePaymentMapper.selectFsStorePaymentListQueryVO(fsStorePayment);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 发起支付
|
|
* 发起支付
|
|
|
|
|
+ *
|
|
|
* @param payOrderParam 入参
|
|
* @param payOrderParam 入参
|
|
|
* @return R
|
|
* @return R
|
|
|
*/
|
|
*/
|
|
@@ -936,7 +937,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
FsUser user = userMapper.selectFsUserById(payOrderParam.getUserId());
|
|
FsUser user = userMapper.selectFsUserById(payOrderParam.getUserId());
|
|
|
- if (Objects.isNull(user)){
|
|
|
|
|
|
|
+ if (Objects.isNull(user)) {
|
|
|
throw new CustomException("用户不存在");
|
|
throw new CustomException("用户不存在");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -946,7 +947,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
|
|
|
|
|
if (isWechatPayment(payOrderParam.getPaymentMethod())) {
|
|
if (isWechatPayment(payOrderParam.getPaymentMethod())) {
|
|
|
String openId = getOpenIdForPaymentMethod(user, payOrderParam.getPaymentMethod(), payConfig);
|
|
String openId = getOpenIdForPaymentMethod(user, payOrderParam.getPaymentMethod(), payConfig);
|
|
|
- if (StringUtils.isBlank(openId)){
|
|
|
|
|
|
|
+ if (StringUtils.isBlank(openId)) {
|
|
|
throw new CustomException("用户OPENID不存在");
|
|
throw new CustomException("用户OPENID不存在");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1187,6 +1188,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 判断是否微信支付
|
|
* 判断是否微信支付
|
|
|
|
|
+ *
|
|
|
* @param method 支付类型
|
|
* @param method 支付类型
|
|
|
* @return boolean
|
|
* @return boolean
|
|
|
*/
|
|
*/
|
|
@@ -1262,14 +1264,14 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public R getWxaCodeByPayment(FsStorePaymentGetWxaCodeParam param) {
|
|
|
|
|
|
|
+ public R getWxaCodeByPayment(FsStorePaymentGetWxaCodeParam param) {
|
|
|
final WxMaService wxMaService = WxMaConfiguration.getMaService(param.getAppId());
|
|
final WxMaService wxMaService = WxMaConfiguration.getMaService(param.getAppId());
|
|
|
String scene;
|
|
String scene;
|
|
|
//判断销售id
|
|
//判断销售id
|
|
|
- if (param.getCompanyUserId() == null){
|
|
|
|
|
- scene = "companyId="+ param.getCompanyId();
|
|
|
|
|
- }else {
|
|
|
|
|
- scene = "companyId="+ param.getCompanyId()+"&"+"companyUserId="+ param.getCompanyUserId();
|
|
|
|
|
|
|
+ if (param.getCompanyUserId() == null) {
|
|
|
|
|
+ scene = "companyId=" + param.getCompanyId();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ scene = "companyId=" + param.getCompanyId() + "&" + "companyUserId=" + param.getCompanyUserId();
|
|
|
}
|
|
}
|
|
|
byte[] file;
|
|
byte[] file;
|
|
|
try {
|
|
try {
|
|
@@ -1289,16 +1291,16 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
String url;
|
|
String url;
|
|
|
try {
|
|
try {
|
|
|
url = storage.uploadSuffix(file, suffix);
|
|
url = storage.uploadSuffix(file, suffix);
|
|
|
- } catch (Exception e) {
|
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
// 记录错误日志
|
|
// 记录错误日志
|
|
|
- logger.error("生成图片失败:{}",e.getMessage(),e);
|
|
|
|
|
|
|
+ logger.error("生成图片失败:{}", e.getMessage(), e);
|
|
|
return R.error("生成图片失败");
|
|
return R.error("生成图片失败");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- redisCache.setCacheObject("company-wxa-code:"+param.getCompanyId()+":"+param.getAppId(),url);
|
|
|
|
|
|
|
+ redisCache.setCacheObject("company-wxa-code:" + param.getCompanyId() + ":" + param.getAppId(), url);
|
|
|
|
|
|
|
|
// 返回成功信息
|
|
// 返回成功信息
|
|
|
- return R.ok().put("url",url);
|
|
|
|
|
|
|
+ return R.ok().put("url", url);
|
|
|
|
|
|
|
|
} catch (WxErrorException e) {
|
|
} catch (WxErrorException e) {
|
|
|
logger.error(e.getMessage(), e);
|
|
logger.error(e.getMessage(), e);
|
|
@@ -1325,7 +1327,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
@Override
|
|
@Override
|
|
|
public R paymentByWxaCode(FsStorePaymentPayParam param) {
|
|
public R paymentByWxaCode(FsStorePaymentPayParam param) {
|
|
|
FsUser user = userMapper.selectFsUserById(param.getUserId());
|
|
FsUser user = userMapper.selectFsUserById(param.getUserId());
|
|
|
- if (user==null){
|
|
|
|
|
|
|
+ if (user == null) {
|
|
|
return R.error("用户不存在!");
|
|
return R.error("用户不存在!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1345,27 +1347,27 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
} else {
|
|
} else {
|
|
|
appId = payConfigDTO.getAppId();
|
|
appId = payConfigDTO.getAppId();
|
|
|
openId = Objects.isNull(user) ? "" : user.getMaOpenId();
|
|
openId = Objects.isNull(user) ? "" : user.getMaOpenId();
|
|
|
- if (StringUtils.isBlank(openId)){
|
|
|
|
|
|
|
+ if (StringUtils.isBlank(openId)) {
|
|
|
Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
|
|
Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
|
|
|
.eq(FsUserWx::getFsUserId, param.getUserId())
|
|
.eq(FsUserWx::getFsUserId, param.getUserId())
|
|
|
.eq(FsUserWx::getAppId, appId);
|
|
.eq(FsUserWx::getAppId, appId);
|
|
|
FsUserWx fsUserWx = userWxMapper.selectOne(queryWrapper);
|
|
FsUserWx fsUserWx = userWxMapper.selectOne(queryWrapper);
|
|
|
- if (Objects.nonNull(fsUserWx)){
|
|
|
|
|
|
|
+ if (Objects.nonNull(fsUserWx)) {
|
|
|
openId = fsUserWx.getOpenId();
|
|
openId = fsUserWx.getOpenId();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Company company = companyService.selectCompanyById(param.getCompanyId());
|
|
Company company = companyService.selectCompanyById(param.getCompanyId());
|
|
|
- if (company==null || company.getStatus()==0){
|
|
|
|
|
|
|
+ if (company == null || company.getStatus() == 0) {
|
|
|
return R.error("服务商不存在,或已被停用!");
|
|
return R.error("服务商不存在,或已被停用!");
|
|
|
}
|
|
}
|
|
|
- if(param.getPayMoney().compareTo(new BigDecimal(0.0))<1){
|
|
|
|
|
|
|
+ if (param.getPayMoney().compareTo(new BigDecimal(0.0)) < 1) {
|
|
|
return R.error("支付金额必须大于0");
|
|
return R.error("支付金额必须大于0");
|
|
|
}
|
|
}
|
|
|
- if (param.getCompanyUserId()!=null){
|
|
|
|
|
|
|
+ if (param.getCompanyUserId() != null) {
|
|
|
CompanyUser companyUser = companyUserService.selectCompanyUserById(param.getCompanyUserId());
|
|
CompanyUser companyUser = companyUserService.selectCompanyUserById(param.getCompanyUserId());
|
|
|
- if(companyUser == null || companyUser.getStatus().equals("1")){
|
|
|
|
|
|
|
+ if (companyUser == null || companyUser.getStatus().equals("1")) {
|
|
|
return R.error("注册失败客服已停用,或不存在!");
|
|
return R.error("注册失败客服已停用,或不存在!");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1373,10 +1375,10 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
|
|
|
|
|
//生成支付流水
|
|
//生成支付流水
|
|
|
String orderSn = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
String orderSn = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
- FsStorePayment storePayment=new FsStorePayment();
|
|
|
|
|
|
|
+ FsStorePayment storePayment = new FsStorePayment();
|
|
|
storePayment.setCompanyId(param.getCompanyId());
|
|
storePayment.setCompanyId(param.getCompanyId());
|
|
|
//判断销售是否存在
|
|
//判断销售是否存在
|
|
|
- if (param.getCompanyUserId()!=null){
|
|
|
|
|
|
|
+ if (param.getCompanyUserId() != null) {
|
|
|
storePayment.setCompanyUserId(param.getCompanyUserId());
|
|
storePayment.setCompanyUserId(param.getCompanyUserId());
|
|
|
}
|
|
}
|
|
|
storePayment.setStatus(0);
|
|
storePayment.setStatus(0);
|
|
@@ -1394,23 +1396,23 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
o.setTradeType("T_MINIAPP");
|
|
o.setTradeType("T_MINIAPP");
|
|
|
o.setOpenid(openId);
|
|
o.setOpenid(openId);
|
|
|
- o.setReqSeqId("payment-"+storePayment.getPayCode());
|
|
|
|
|
|
|
+ o.setReqSeqId("payment-" + storePayment.getPayCode());
|
|
|
o.setTransAmt(storePayment.getPayMoney().toString());
|
|
o.setTransAmt(storePayment.getPayMoney().toString());
|
|
|
o.setGoodsDesc("商城订单支付");
|
|
o.setGoodsDesc("商城订单支付");
|
|
|
o.setAppId(appId);
|
|
o.setAppId(appId);
|
|
|
HuifuCreateOrderResult result = huiFuService.createOrder(o);
|
|
HuifuCreateOrderResult result = huiFuService.createOrder(o);
|
|
|
- if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
|
|
|
|
|
- FsStorePayment mt=new FsStorePayment();
|
|
|
|
|
|
|
+ if (result.getResp_code() != null && (result.getResp_code().equals("00000000") || result.getResp_code().equals("00000100"))) {
|
|
|
|
|
+ FsStorePayment mt = new FsStorePayment();
|
|
|
mt.setPaymentId(storePayment.getPaymentId());
|
|
mt.setPaymentId(storePayment.getPaymentId());
|
|
|
mt.setTradeNo(result.getHf_seq_id());
|
|
mt.setTradeNo(result.getHf_seq_id());
|
|
|
mt.setAppId(appId);
|
|
mt.setAppId(appId);
|
|
|
fsStorePaymentMapper.updateFsStorePayment(mt);
|
|
fsStorePaymentMapper.updateFsStorePayment(mt);
|
|
|
- Map<String, Object> resultMap = com.alibaba.fastjson.JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
|
|
|
|
|
|
|
+ Map<String, Object> resultMap = com.alibaba.fastjson.JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {
|
|
|
|
|
+ });
|
|
|
String s = (String) resultMap.get("package");
|
|
String s = (String) resultMap.get("package");
|
|
|
- resultMap.put("packageValue",s);
|
|
|
|
|
- return R.ok().put("result",resultMap);
|
|
|
|
|
- }
|
|
|
|
|
- else{
|
|
|
|
|
|
|
+ resultMap.put("packageValue", s);
|
|
|
|
|
+ return R.ok().put("result", resultMap);
|
|
|
|
|
+ } else {
|
|
|
return R.error(result.getResp_desc());
|
|
return R.error(result.getResp_desc());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|