mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 20:49:00 +08:00
✨ Introducing new features. #2351 【支付管理】支持YunGouOS 小微商户支付模式
This commit is contained in:
1 parent
eb8bd5b2d1
commit
19e54584a2
9 files changed
+33
-102
No files matched your search
-22
@@ -1,22 +0,0 @@
|
||||
package com.pig4cloud.pigx.pay.config;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2021/1/4
|
||||
* <p>
|
||||
* 聚合支付
|
||||
*/
|
||||
@Data
|
||||
public class MergePayConfig {
|
||||
/**
|
||||
* 前端回调地址
|
||||
*/
|
||||
private String returnUrl;
|
||||
|
||||
/**
|
||||
* 服务端回调地址
|
||||
*/
|
||||
private String notifyUrl;
|
||||
}
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
package com.pig4cloud.pigx.pay.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2019-06-18
|
||||
*/
|
||||
@Data
|
||||
@RefreshScope
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "pigx.pay")
|
||||
public class PayCommonProperties {
|
||||
|
||||
/**
|
||||
* 支付宝支付参数
|
||||
*/
|
||||
private AliPayConfig aliPayConfig;
|
||||
|
||||
/**
|
||||
* 微信支付参数
|
||||
*/
|
||||
private WxPayConfig wxPayConfig;
|
||||
|
||||
/**
|
||||
* 聚合支付参数
|
||||
*/
|
||||
private MergePayConfig mergePayConfig;
|
||||
}
|
||||
+9
-12
@@ -51,13 +51,16 @@ import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 商品
|
||||
*
|
||||
@@ -77,7 +80,6 @@ public class PayGoodsOrderController {
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 商品订单
|
||||
* @param goods 商品
|
||||
@@ -165,8 +167,7 @@ public class PayGoodsOrderController {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param page 分页对象
|
||||
* @param payGoodsOrder 商品订单表
|
||||
* @return
|
||||
*/
|
||||
@@ -178,7 +179,6 @@ public class PayGoodsOrderController {
|
||||
|
||||
/**
|
||||
* 通过id查询商品订单表
|
||||
*
|
||||
* @param goodsOrderId id
|
||||
* @return R
|
||||
*/
|
||||
@@ -190,7 +190,6 @@ public class PayGoodsOrderController {
|
||||
|
||||
/**
|
||||
* 新增商品订单表
|
||||
*
|
||||
* @param payGoodsOrder 商品订单表
|
||||
* @return R
|
||||
*/
|
||||
@@ -204,7 +203,6 @@ public class PayGoodsOrderController {
|
||||
|
||||
/**
|
||||
* 修改商品订单表
|
||||
*
|
||||
* @param payGoodsOrder 商品订单表
|
||||
* @return R
|
||||
*/
|
||||
@@ -218,7 +216,6 @@ public class PayGoodsOrderController {
|
||||
|
||||
/**
|
||||
* 通过id删除商品订单表
|
||||
*
|
||||
* @param goodsOrderId id
|
||||
* @return R
|
||||
*/
|
||||
|
||||
-3
@@ -46,9 +46,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2019-05-31
|
||||
|
||||
+5
-9
@@ -1,5 +1,7 @@
|
||||
package com.pig4cloud.pigx.pay.handler.impl;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
@@ -19,8 +21,6 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2021/1/4
|
||||
@@ -42,7 +42,6 @@ public class YungouosMergePayNotifyCallbakHandler extends AbstractPayNotifyCallb
|
||||
|
||||
/**
|
||||
* 初始化执行
|
||||
*
|
||||
* @param params
|
||||
*/
|
||||
@Override
|
||||
@@ -53,7 +52,6 @@ public class YungouosMergePayNotifyCallbakHandler extends AbstractPayNotifyCallb
|
||||
|
||||
/**
|
||||
* 去重处理
|
||||
*
|
||||
* @param params 回调报文
|
||||
* @return
|
||||
*/
|
||||
@@ -70,7 +68,6 @@ public class YungouosMergePayNotifyCallbakHandler extends AbstractPayNotifyCallb
|
||||
|
||||
/**
|
||||
* 验签逻辑
|
||||
*
|
||||
* @param params 回调报文
|
||||
* @return
|
||||
*/
|
||||
@@ -81,7 +78,6 @@ public class YungouosMergePayNotifyCallbakHandler extends AbstractPayNotifyCallb
|
||||
|
||||
/**
|
||||
* 解析报文
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@@ -97,7 +93,8 @@ public class YungouosMergePayNotifyCallbakHandler extends AbstractPayNotifyCallb
|
||||
if (OrderStatusEnum.SUCCESS.getStatus().equals(mergeCode)) {
|
||||
goodsOrder.setStatus(OrderStatusEnum.SUCCESS.getStatus());
|
||||
tradeOrder.setStatus(OrderStatusEnum.SUCCESS.getStatus());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
goodsOrder.setStatus(OrderStatusEnum.FAIL.getStatus());
|
||||
tradeOrder.setStatus(OrderStatusEnum.FAIL.getStatus());
|
||||
}
|
||||
@@ -111,10 +108,8 @@ public class YungouosMergePayNotifyCallbakHandler extends AbstractPayNotifyCallb
|
||||
return "SUCCESS";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存回调记录
|
||||
*
|
||||
* @param params 回调报文
|
||||
* @param result 处理结果
|
||||
*/
|
||||
@@ -125,4 +120,5 @@ public class YungouosMergePayNotifyCallbakHandler extends AbstractPayNotifyCallb
|
||||
MapUtil.renameKey(params, PayConstants.MERGE_OUT_TRADE_NO, PayConstants.OUT_TRADE_NO);
|
||||
saveRecord(params, result, record, notifyId, recordService);
|
||||
}
|
||||
|
||||
}
|
||||
+7
-13
@@ -24,8 +24,7 @@ import org.springframework.stereotype.Service;
|
||||
* @author lengleng
|
||||
* @date 2021/1/4
|
||||
* <p>
|
||||
* https://open.pay.yungouos.com/#/api/api/pay/merge/nativePay
|
||||
* 服务商聚合支付模式
|
||||
* https://open.pay.yungouos.com/#/api/api/pay/merge/nativePay 服务商聚合支付模式
|
||||
*/
|
||||
@Slf4j
|
||||
@Service("MERGE_PAY")
|
||||
@@ -87,21 +86,15 @@ public class YungouosMergePayOrderHandler extends AbstractPayOrderHandler {
|
||||
PayChannel channel = ChannelPayApiConfigKit.get();
|
||||
|
||||
String money = NumberUtil.div(tradeOrder.getAmount(), "100", 2).toString();
|
||||
return MergePay.nativePay(tradeOrder.getOrderId(), money, "100106279016"
|
||||
, tradeOrder.getBody()
|
||||
, "1"
|
||||
, tradeOrder.getBody()
|
||||
, commonProperties.getMergePayConfig().getNotifyUrl()
|
||||
, commonProperties.getMergePayConfig().getReturnUrl()
|
||||
, ""
|
||||
, ""
|
||||
, ""
|
||||
, "759492493EBC43B498955E261E1A494F");
|
||||
|
||||
return MergePay.nativePay(tradeOrder.getOrderId(), money, channel.getChannelMchId(), tradeOrder.getBody(), "1",
|
||||
TenantContextHolder.getTenantId().toString(),
|
||||
ChannelPayApiConfigKit.get().getNotifyUrl() + "/pay/notify/merge/callbak",
|
||||
ChannelPayApiConfigKit.get().getReturnUrl(), "", "", "", channel.getParam());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新订单信息
|
||||
*
|
||||
* @param goodsOrder 商品订单
|
||||
* @param tradeOrder 交易订单
|
||||
*/
|
||||
@@ -110,4 +103,5 @@ public class YungouosMergePayOrderHandler extends AbstractPayOrderHandler {
|
||||
tradeOrderMapper.updateById(tradeOrder);
|
||||
goodsOrderMapper.updateById(goodsOrder);
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -17,11 +17,11 @@
|
||||
|
||||
package com.pig4cloud.pigx.pay.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.pig4cloud.pigx.pay.entity.PayGoodsOrder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 商品
|
||||
*
|
||||
@@ -33,7 +33,7 @@ public interface PayGoodsOrderService extends IService<PayGoodsOrder> {
|
||||
/**
|
||||
* 购买商品
|
||||
* @param goodsOrder goods
|
||||
* @param isMerge 是否是服务商
|
||||
* @param isMerge 是否是服务商
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> buy(PayGoodsOrder goodsOrder, boolean isMerge);
|
||||
|
||||
+5
-5
@@ -16,6 +16,11 @@
|
||||
*/
|
||||
package com.pig4cloud.pigx.pay.service.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pigx.pay.entity.PayGoodsOrder;
|
||||
import com.pig4cloud.pigx.pay.handler.PayOrderHandler;
|
||||
@@ -28,10 +33,6 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 商品
|
||||
*
|
||||
@@ -50,7 +51,6 @@ public class PayGoodsOrderServiceImpl extends ServiceImpl<PayGoodsOrderMapper, P
|
||||
|
||||
/**
|
||||
* 下单购买
|
||||
*
|
||||
* @param goodsOrder
|
||||
* @param isMerge
|
||||
* @return
|
||||
|
||||
+4
-3
@@ -45,16 +45,17 @@ public enum PayChannelNameEnum {
|
||||
|
||||
/**
|
||||
* 通过ua 判断所属渠道
|
||||
*
|
||||
* @param ua 浏览器类型
|
||||
* @return
|
||||
*/
|
||||
public static Enum getChannel(String ua) {
|
||||
if (ua.contains(PayConstants.ALIPAY)) {
|
||||
return PayChannelNameEnum.ALIPAY_WAP;
|
||||
} else if (ua.contains(PayConstants.MICRO_MESSENGER)) {
|
||||
}
|
||||
else if (ua.contains(PayConstants.MICRO_MESSENGER)) {
|
||||
return PayChannelNameEnum.WEIXIN_MP;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return PayChannelNameEnum.MERGE_PAY;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user