Commit 3030bdff by jinxin

支付回调加锁处理 + 好办后台列表显示企业微信支付时间

parent 4b505707
......@@ -25,6 +25,7 @@ import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.service.licence.LicenceOrderProgressService;
import com.gic.haoban.manage.service.service.licence.LicenceOrderService;
import com.gic.haoban.manage.service.util.DingUtils;
import com.gic.redis.data.util.RedisUtil;
import com.gic.thirdparty.api.dto.RefundReqDataDTO;
import com.gic.thirdparty.api.dto.RefundResDataDTO;
import com.gic.thirdparty.api.service.Pay4WXService;
......@@ -36,6 +37,7 @@ import com.gic.wechat.api.service.qywx.QywxOrderApiService;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.redisson.client.RedisClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -197,14 +199,19 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
String orderId = object.getString("orderId");
String transactionId = object.getString("transactionId");
String timeEnd = object.getString("timeEnd");
//对同一笔订单上锁
String key = "haoban_wx_licence_order_+"+transactionId;
RedisUtil.lock(key,2L);
TabHaobanLicenceOrder licenceOrder = licenceOrderService.selectByTransactionId(orderId);
if (licenceOrder == null) {
logger.info("微信回调的订单编号:{}异常!!", orderId);
RedisUtil.unlock(key);
return ServiceResponse.success(false);
}
if (licenceOrder.getOrderStatus() == 1) {
//微信会多次回调
logger.info("微信回调的订单已处理!");
RedisUtil.unlock(key);
return ServiceResponse.success(false);
}
Date payTime = DateUtil.strToDate(timeEnd,DateUtil.FORMAT_DATETIME_14);
......@@ -212,6 +219,7 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
licenceOrderService.updateLicenceOrderType(licenceOrder.getOrderId(), 1, licenceOrder.getEnterpriseId(), licenceOrder.getWxEnterpriseId(), "系统", 1);
//保存微信订单id
licenceOrderService.saveTransactionCode(licenceOrder.getOrderId(), null, null, transactionId, payTime,null);
RedisUtil.unlock(key);
//查询gic品牌名称
String enterpriseName = "";
String wxEnterpriseName = "";
......@@ -250,6 +258,9 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
String orderId = object.getString("orderId");
String timeStamp = object.getString("timeStamp");
Integer orderStatus = object.getInteger("orderStatus");
//对同一笔订单上锁
String key = "haoban_qywx_licence_order_+"+orderId;
RedisUtil.lock(key,2L);
TabHaobanLicenceOrder order = licenceOrderService.selectByQywxOrderId(orderId);
//将秒级时间戳转换位Date类型
SimpleDateFormat formatter = new SimpleDateFormat(DateUtil.FORMAT_DATETIME_19);
......@@ -261,6 +272,7 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
if ("license_pay_success".equals(infoType)) {
if (order.getQywxPayTime() != null) {
//该笔订单已处理
RedisUtil.unlock(key);
return ServiceResponse.success(false);
}
//更新企业微信订单状态
......@@ -271,6 +283,7 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
if ("license_refund".equals(infoType)) {
if (order.getQywxRefundTime() != null) {
//该笔订单已处理
RedisUtil.unlock(key);
return ServiceResponse.success(false);
}
//退款回调 订单状态,1:退款成功,2:退款被拒绝。
......@@ -289,6 +302,7 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
licenceOrderService.saveCallBackTime(order.getOrderId(), 3, date);
}
}
RedisUtil.unlock(key);
return ServiceResponse.success(true);
}
......
......@@ -108,6 +108,10 @@ public class LicenceOrderPageVO implements Serializable {
* 创建人名称
*/
private String creatorName;
/**
* 企业微信支付时间
*/
private Date qywxPayTime;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment