|
@@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.cyksj.common.AliPayCommon;
|
|
import com.cyksj.common.AliPayCommon;
|
|
|
import com.cyksj.common.EnvCommonService;
|
|
import com.cyksj.common.EnvCommonService;
|
|
|
|
|
+import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.common.constant.TaskTypeEnum;
|
|
import com.cyksj.common.constant.TaskTypeEnum;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.snowflake.Sequence;
|
|
import com.cyksj.common.snowflake.Sequence;
|
|
@@ -229,7 +230,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//锁定座位
|
|
//锁定座位
|
|
|
- setRelation(relation.getId(), user.getId(), goodsDon.getId());
|
|
|
|
|
|
|
+ setRelation(relation.getId(), user.getId(), goodsDon.getId(), payRequest.getIsLoginPopularize());
|
|
|
relation.setUserId(user.getId());
|
|
relation.setUserId(user.getId());
|
|
|
relation.setStatus(GroupsRelation.Status.locking);
|
|
relation.setStatus(GroupsRelation.Status.locking);
|
|
|
groupsRelationMapper.updateById(relation);
|
|
groupsRelationMapper.updateById(relation);
|
|
@@ -281,6 +282,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
orderDon.setStatus(OrderDon.Status.noPayment);
|
|
orderDon.setStatus(OrderDon.Status.noPayment);
|
|
|
orderDon.setUserId(user.getId());
|
|
orderDon.setUserId(user.getId());
|
|
|
orderDon.setType(OrderDon.Type.getType(payRequest.getType()));
|
|
orderDon.setType(OrderDon.Type.getType(payRequest.getType()));
|
|
|
|
|
+ orderDon.setIsWebPay(payRequest.getIsWebPay());
|
|
|
if (isNoLogin == null || !isNoLogin) {
|
|
if (isNoLogin == null || !isNoLogin) {
|
|
|
//虚拟商品订单,是否是分销订单
|
|
//虚拟商品订单,是否是分销订单
|
|
|
if (goodsDon.getType() == 1) {
|
|
if (goodsDon.getType() == 1) {
|
|
@@ -655,7 +657,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public AliPayParams aliPay(Long orderId, String productCode) throws Exception {
|
|
|
|
|
|
|
+ public AliPayParams aliPay(Long orderId, String productCode,String qrPayMode) throws Exception {
|
|
|
OrderDon orderDon = getById(orderId);
|
|
OrderDon orderDon = getById(orderId);
|
|
|
String appId = ShopConfig.ZFB_DEFAULT_APP_ID;
|
|
String appId = ShopConfig.ZFB_DEFAULT_APP_ID;
|
|
|
|
|
|
|
@@ -668,7 +670,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
orderDon.setType(OrderDon.Type.ALI_PAY);
|
|
orderDon.setType(OrderDon.Type.ALI_PAY);
|
|
|
orderDon.setShopId(appId);
|
|
orderDon.setShopId(appId);
|
|
|
this.updateById(orderDon);
|
|
this.updateById(orderDon);
|
|
|
- return commonAliPay(orderId, productCode, appId);
|
|
|
|
|
|
|
+ return commonAliPay(orderId, productCode, appId, qrPayMode);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -894,7 +896,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
.eq(OrderDon::getRelationId, relationId)
|
|
.eq(OrderDon::getRelationId, relationId)
|
|
|
.eq(OrderDon::getUserId, orderDon.getUserId())
|
|
.eq(OrderDon::getUserId, orderDon.getUserId())
|
|
|
.ne(OrderDon::getId, orderDon.getId())
|
|
.ne(OrderDon::getId, orderDon.getId())
|
|
|
- .notIn(OrderDon::getStatus, OrderCustomerHandleScheduler.noOrderStatus)
|
|
|
|
|
|
|
+ .notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
|
|
|
.orderByDesc(OrderDon::getId)
|
|
.orderByDesc(OrderDon::getId)
|
|
|
.last("limit 1"));
|
|
.last("limit 1"));
|
|
|
if (otherOrder != null) {
|
|
if (otherOrder != null) {
|
|
@@ -962,7 +964,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
.eq(OrderDon::getRelationId, orderDon.getRelationId())
|
|
.eq(OrderDon::getRelationId, orderDon.getRelationId())
|
|
|
.eq(OrderDon::getUserId, orderDon.getUserId())
|
|
.eq(OrderDon::getUserId, orderDon.getUserId())
|
|
|
.ne(OrderDon::getId, orderDon.getId())
|
|
.ne(OrderDon::getId, orderDon.getId())
|
|
|
- .notIn(OrderDon::getStatus, OrderCustomerHandleScheduler.noOrderStatus)
|
|
|
|
|
|
|
+ .notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
|
|
|
.eq(OrderDon::getOrderType, 2)
|
|
.eq(OrderDon::getOrderType, 2)
|
|
|
.orderByDesc(OrderDon::getId)
|
|
.orderByDesc(OrderDon::getId)
|
|
|
.last("limit 1"));
|
|
.last("limit 1"));
|
|
@@ -1055,10 +1057,12 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
log.info("微信退款: 退款单号[{}] 退款成功.", outRefundNo);
|
|
log.info("微信退款: 退款单号[{}] 退款成功.", outRefundNo);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void setRelation(Long relationId, Long userId, Long goodsId) {
|
|
|
|
|
- int noPayCount = count(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getUserId, userId).eq(OrderDon::getGoodsId, goodsId).eq(OrderDon::getStatus, OrderDon.Status.noPayment.toString()));
|
|
|
|
|
- if (noPayCount > 0) {
|
|
|
|
|
- throw new BusinessRuntimeException("您有未支付订单.");
|
|
|
|
|
|
|
+ public void setRelation(Long relationId, Long userId, Long goodsId, Boolean isLoginPopularize) {
|
|
|
|
|
+ if (isLoginPopularize == null || !isLoginPopularize) {
|
|
|
|
|
+ int noPayCount = count(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getUserId, userId).eq(OrderDon::getGoodsId, goodsId).eq(OrderDon::getStatus, OrderDon.Status.noPayment.toString()));
|
|
|
|
|
+ if (noPayCount > 0) {
|
|
|
|
|
+ throw new BusinessRuntimeException("您有未支付订单.");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (redisService.get(RedisKey.GROUPS_RELATION_NUM_KEY + relationId) != null) {
|
|
if (redisService.get(RedisKey.GROUPS_RELATION_NUM_KEY + relationId) != null) {
|
|
@@ -1104,22 +1108,23 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
orderDonTransportMapper.insert(transport);
|
|
orderDonTransportMapper.insert(transport);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public AliPayParams commonAliPay(Long orderId, String productCode, String appId) throws Exception {
|
|
|
|
|
|
|
+ public AliPayParams commonAliPay(Long orderId, String productCode, String appId, String qrPayMode) throws Exception {
|
|
|
ShopConfig shopConfig = shopConfigMapper.getByAppId(Optional.ofNullable(appId).orElse(ShopConfig.ZFB_DEFAULT_APP_ID));
|
|
ShopConfig shopConfig = shopConfigMapper.getByAppId(Optional.ofNullable(appId).orElse(ShopConfig.ZFB_DEFAULT_APP_ID));
|
|
|
|
|
|
|
|
AlipayClient alipayClient = AliPayCommon.getAlipayClient(shopConfig);
|
|
AlipayClient alipayClient = AliPayCommon.getAlipayClient(shopConfig);
|
|
|
// 创建API对应的request
|
|
// 创建API对应的request
|
|
|
- AlipayRequest alipayRequest = getAliAayRequest(orderId, productCode);
|
|
|
|
|
|
|
+ AlipayRequest alipayRequest = getAliAayRequest(orderId, productCode, qrPayMode);
|
|
|
if (alipayRequest == null) {
|
|
if (alipayRequest == null) {
|
|
|
throw BusinessRuntimeException.getInstance("支付宝不支持该支付方式:{0}", productCode);
|
|
throw BusinessRuntimeException.getInstance("支付宝不支持该支付方式:{0}", productCode);
|
|
|
}
|
|
}
|
|
|
//回调地址
|
|
//回调地址
|
|
|
String host = envCommonService.getHost();
|
|
String host = envCommonService.getHost();
|
|
|
String notifyUrl = String.format("%s%s", host, BaseZfbConfig.notifyUrl);
|
|
String notifyUrl = String.format("%s%s", host, BaseZfbConfig.notifyUrl);
|
|
|
- //去除返回地址
|
|
|
|
|
-// String returnUrl = String.format("https://%s/%s", host, BaseZfbConfig.returnUrl);
|
|
|
|
|
|
|
+ if (BaseZfbConfig.qrPayMode_redirect.equals(qrPayMode)) {
|
|
|
|
|
+ String returnUrl = String.format("%s%s", envCommonService.getDomain(), BaseZfbConfig.loginReturnUrl);
|
|
|
|
|
+ alipayRequest.setReturnUrl(returnUrl);
|
|
|
|
|
+ }
|
|
|
alipayRequest.setNotifyUrl(notifyUrl);
|
|
alipayRequest.setNotifyUrl(notifyUrl);
|
|
|
-// alipayRequest.setReturnUrl(returnUrl);
|
|
|
|
|
String form = null;
|
|
String form = null;
|
|
|
try {
|
|
try {
|
|
|
//调用SDK生成表单
|
|
//调用SDK生成表单
|
|
@@ -1137,7 +1142,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
* @param productCode 销售产品码,与支付宝签约的产品码名称
|
|
* @param productCode 销售产品码,与支付宝签约的产品码名称
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- private AlipayRequest getAliAayRequest(Long orderId, String productCode) throws Exception {
|
|
|
|
|
|
|
+ private AlipayRequest getAliAayRequest(Long orderId, String productCode, String qrPayMode) throws Exception {
|
|
|
OrderAttach attach = new OrderAttach();
|
|
OrderAttach attach = new OrderAttach();
|
|
|
attach.setO(orderId);
|
|
attach.setO(orderId);
|
|
|
String body = Codec.DoBase64.custom()
|
|
String body = Codec.DoBase64.custom()
|
|
@@ -1175,7 +1180,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
alipayTradePagePayModel.setProductCode(productCode);
|
|
alipayTradePagePayModel.setProductCode(productCode);
|
|
|
//5分钟订单失效时间
|
|
//5分钟订单失效时间
|
|
|
alipayTradePagePayModel.setTimeExpire(DateUtil.offsetMinute(orderDon.getCreatedTime(), 5).toString());
|
|
alipayTradePagePayModel.setTimeExpire(DateUtil.offsetMinute(orderDon.getCreatedTime(), 5).toString());
|
|
|
- alipayTradePagePayModel.setQrPayMode("4");
|
|
|
|
|
|
|
+ alipayTradePagePayModel.setQrPayMode(qrPayMode);
|
|
|
alipayTradePagePayRequest.setBizModel(alipayTradePagePayModel);
|
|
alipayTradePagePayRequest.setBizModel(alipayTradePagePayModel);
|
|
|
return alipayTradePagePayRequest;
|
|
return alipayTradePagePayRequest;
|
|
|
}
|
|
}
|