Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
A
Afrishop refactored project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Whispa
Afrishop refactored project
Commits
4a2f2a0c
提交
4a2f2a0c
authored
11月 27, 2020
作者:
吴德鹏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Collection items paging processing
上级
db1a44f2
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
258 行增加
和
5 行删除
+258
-5
pom.xml
pom.xml
+5
-0
PaypalConfig.java
...ain/java/com/example/afrishop_v3/config/PaypalConfig.java
+43
-0
PaypalPaymentIntent.java
...a/com/example/afrishop_v3/config/PaypalPaymentIntent.java
+7
-0
PaypalPaymentMethod.java
...a/com/example/afrishop_v3/config/PaypalPaymentMethod.java
+5
-0
DpoPayController.java
...com/example/afrishop_v3/controllers/DpoPayController.java
+1
-1
PaypalContoller.java
.../com/example/afrishop_v3/controllers/PaypalContoller.java
+164
-0
UserController.java
...a/com/example/afrishop_v3/controllers/UserController.java
+2
-3
OrderTask.java
src/main/java/com/example/afrishop_v3/quartz/OrderTask.java
+1
-1
application-dev.yml
src/main/resources/application-dev.yml
+10
-0
application-prod.yml
src/main/resources/application-prod.yml
+10
-0
application-test.yml
src/main/resources/application-test.yml
+10
-0
没有找到文件。
pom.xml
浏览文件 @
4a2f2a0c
...
...
@@ -140,6 +140,11 @@
<version>
1.12.1
</version>
</dependency>
<dependency>
<groupId>
com.paypal.sdk
</groupId>
<artifactId>
rest-api-sdk
</artifactId>
<version>
1.4.2
</version>
</dependency>
<!--stripe-->
<dependency>
...
...
src/main/java/com/example/afrishop_v3/config/PaypalConfig.java
0 → 100644
浏览文件 @
4a2f2a0c
package
com
.
example
.
afrishop_v3
.
config
;
import
com.paypal.base.rest.APIContext
;
import
com.paypal.base.rest.OAuthTokenCredential
;
import
com.paypal.base.rest.PayPalRESTException
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
java.util.HashMap
;
import
java.util.Map
;
@Configuration
public
class
PaypalConfig
{
@Value
(
"${paypal.client_app}"
)
private
String
clientId
;
@Value
(
"${paypal.client_secret}"
)
private
String
clientSecret
;
@Value
(
"${paypal.mode}"
)
private
String
mode
;
@Bean
public
Map
<
String
,
String
>
paypalSdkConfig
()
{
Map
<
String
,
String
>
sdkConfig
=
new
HashMap
<>();
sdkConfig
.
put
(
"mode"
,
mode
);
return
sdkConfig
;
}
@Bean
public
OAuthTokenCredential
authTokenCredential
()
{
return
new
OAuthTokenCredential
(
clientId
,
clientSecret
,
paypalSdkConfig
());
}
@Bean
public
APIContext
apiContext
()
throws
PayPalRESTException
{
APIContext
apiContext
=
new
APIContext
(
authTokenCredential
().
getAccessToken
());
apiContext
.
setConfigurationMap
(
paypalSdkConfig
());
return
apiContext
;
}
}
src/main/java/com/example/afrishop_v3/config/PaypalPaymentIntent.java
0 → 100644
浏览文件 @
4a2f2a0c
package
com
.
example
.
afrishop_v3
.
config
;
public
enum
PaypalPaymentIntent
{
sale
,
authorize
,
order
}
src/main/java/com/example/afrishop_v3/config/PaypalPaymentMethod.java
0 → 100644
浏览文件 @
4a2f2a0c
package
com
.
example
.
afrishop_v3
.
config
;
public
enum
PaypalPaymentMethod
{
credit_card
,
paypal
}
src/main/java/com/example/afrishop_v3/controllers/DpoPayController.java
浏览文件 @
4a2f2a0c
...
...
@@ -119,7 +119,7 @@ public class DpoPayController extends Controller {
if
(
config
.
getSuccessCode
().
equals
(
resCode
))
{
TbCfUserInfo
user
=
this
.
user
.
user
();
System
.
out
.
println
(
"this.user==========="
+
this
.
user
);
System
.
out
.
println
(
"user================"
+
user
);
System
.
out
.
println
(
"user================"
+
order
.
getUserId
()
);
/**
* so now the user is anonymous, so there is no way to send messages to the user?
*/
...
...
src/main/java/com/example/afrishop_v3/controllers/PaypalContoller.java
0 → 100644
浏览文件 @
4a2f2a0c
//package com.example.afrishop_v3.controllers;
//
//import com.diaoyun.zion.chinafrica.constant.KeyConstant;
//import com.diaoyun.zion.chinafrica.entity.TbCfOrderEntity;
//import com.diaoyun.zion.chinafrica.enums.OrderStatusEnum;
//import com.diaoyun.zion.chinafrica.service.PayPalService;
//import com.diaoyun.zion.chinafrica.service.TbCfOrderService;
//import com.diaoyun.zion.chinafrica.vo.TbCfOrderVo;
//import com.diaoyun.zion.master.base.Result;
//import com.diaoyun.zion.master.common.RedisCache;
//import com.diaoyun.zion.master.config.PaypalPaymentIntent;
//import com.diaoyun.zion.master.config.PaypalPaymentMethod;
//import com.diaoyun.zion.master.enums.ResultCodeEnum;
//import com.example.afrishop_v3.base.Result;
//import com.example.afrishop_v3.bo.KeyConstant;
//import com.example.afrishop_v3.config.PaypalPaymentIntent;
//import com.example.afrishop_v3.config.PaypalPaymentMethod;
//import com.example.afrishop_v3.enums.OrderStatusEnum;
//import com.example.afrishop_v3.enums.ResultCodeEnum;
//import com.example.afrishop_v3.models.TbCfOrder;
//import com.example.afrishop_v3.repository.TbCfOrderRepository;
//import com.paypal.api.payments.Links;
//import com.paypal.api.payments.Payment;
//import com.paypal.base.rest.APIContext;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.apache.commons.lang3.StringUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.web.bind.annotation.*;
//
//import javax.annotation.Resource;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.math.BigDecimal;
//import java.util.Date;
//import java.util.Optional;
//
///**
// * @Auther: wudepeng
// * @Date: 2020/11/10
// * @Description:paypal支付
// */
//@RestController
//@RequestMapping(value = "/paypal")
//public class PaypalContoller {
//
// private static Logger logger = LoggerFactory.getLogger(PaypalContoller.class);
//
// @Value("${paypal.success_url}")
// private String PAYPAL_SUCCESS_URL;
//
// @Value("${paypal.cancel_url}")
// private String PAYPAL_CANCEL_URL;
//
// @Value("${paypal.success_page}")
// private String PAYPAL_SUCCESS_PAGE;
//
// @Value("${paypal.failed_page}")
// private String PAYPAL_FAILED_PAGE;
//
// @Autowired
// private APIContext apiContext;
//
// @Autowired
// private TbCfOrderRepository orderRepository;
//
// /**
// * 发起paypal支付
// *
// * @param orderId 订单号
// * @return Result
// */
// @PostMapping("/payment/{orderId}")
// public Result payment(@PathVariable("orderId") String orderId) {
// Result result = new Result();
// //==========================支付信息校验==========================
//
// //订单号
// if (StringUtils.isBlank(orderId)) {
// logger.error("paypal支付,订单Id不能为空");
// return payErrorInfo(result);
// }
//
//// //从缓存中获取订单信息
//// TbCfOrderVo orderCache = (TbCfOrderVo) orderRedisCache.get(KeyConstant.ORDER_DET + orderId);
////
//// if (orderCache == null) {
//// //订单已过期或者不存在
//// logger.error("paypal支付,订单不存在");
//// return payErrorInfo(result);
//// }
//
// //订单信息
// Optional<TbCfOrder> byId = orderRepository.findById(orderId);
// if (byId.isPresent()) {
// TbCfOrder order = byId.get();
// //价格不存在或错误
// if (order.getRealityPay() == null || order.getRealityPay().compareTo(BigDecimal.ZERO) <= 0) {
// logger.error("paypal支付,订单[" + order.getOrderNo() + "]价格错误");
// return payErrorInfo(result);
// }
//
//
// //订单已支付
// if (OrderStatusEnum.PAID.getValue().equals(order.getPayStatus().toString())) {
// logger.error("paypal支付,订单[" + order.getOrderNo() + "]已支付");
// return payErrorInfo(result);
// }
//
//
// //价格转double类型
// BigDecimal realityPay = order.getRealityPay();
// String price = realityPay.toString();
// double orderPrice = Double.parseDouble(price);
//
// //==========================paypal支付业务开始==========================
//
// logger.info("paypal支付开始,时间:" + new Date());
// String orderInfo = order.getDeliveryName() + "'s payment information";
// logger.info(orderInfo);
// String currency = "USD";
// try {
// Payment payment = payPalService.payment(
// orderId,
// orderPrice,
// currency,
// PaypalPaymentMethod.paypal,
// PaypalPaymentIntent.sale,
// orderInfo,
// PAYPAL_CANCEL_URL,
// PAYPAL_SUCCESS_URL);
//
// String paymentId = payment.getId();
// orderRedisCache.set(KeyConstant.ORDER_DET + "_" + paymentId, orderId);
// logger.info("paypal支付完成,时间:" + new Date());
// for (Links links : payment.getLinks()) {
// if (links.getRel().equals("approval_url")) {
// return result.setData(links.getHref());
// }
// }
// } catch (Exception e) {
// logger.info("paypal支付发生异常,时间:" + new Date() + e.getMessage());
// return payErrorInfo(result);
// }
// }
//
// return payErrorInfo(result);
// }
//
// /**
// * 支付失败提示
// *
// * @param result
// */
// public Result payErrorInfo(Result result) {
// result.setCode(ResultCodeEnum.ORDER_PAY_ERROR.getCode());
// result.setMessage(ResultCodeEnum.ORDER_PAY_ERROR.getDesc());
// return result;
// }
//}
src/main/java/com/example/afrishop_v3/controllers/UserController.java
浏览文件 @
4a2f2a0c
...
...
@@ -283,10 +283,9 @@ public class UserController extends Controller {
@GetMapping
(
"/queryCollectionByUserId"
)
public
Result
queryCollectionByUserId
(
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
Integer
pageSize
,
@RequestParam
(
value
=
"pageNum"
,
defaultValue
=
"12"
)
Integer
pageNum
)
{
public
Result
queryCollectionByUserId
(
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"0"
)
Integer
pageNo
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"12"
)
Integer
pageSize
)
{
Page
<
TbCfItemCollection
>
allByUserId
=
itemCollectionRepository
.
findAllByUserId
(
user
.
userId
(),
PageRequest
.
of
(
page
Size
,
pageNum
));
Page
<
TbCfItemCollection
>
allByUserId
=
itemCollectionRepository
.
findAllByUserId
(
user
.
userId
(),
PageRequest
.
of
(
page
No
,
pageSize
));
return
new
Result
<>(
allByUserId
);
}
...
...
src/main/java/com/example/afrishop_v3/quartz/OrderTask.java
浏览文件 @
4a2f2a0c
...
...
@@ -85,7 +85,7 @@ public class OrderTask {
/**
* 将超时(24小时)未付款的订单释放库存
*/
@Scheduled
(
cron
=
"0 0
/10 * * * ?
"
)
@Scheduled
(
cron
=
"0 0
0-23 * * ?
"
)
public
void
orderReleaseStock
()
throws
ExecutionException
,
InterruptedException
{
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
20
);
...
...
src/main/resources/application-dev.yml
浏览文件 @
4a2f2a0c
...
...
@@ -73,3 +73,13 @@ flutter:
public_key
:
FLWPUBK_TEST-e3cc948e7cb24b2128fca3b781f6fce0-X
secret_key
:
FLWSECK_TEST-f88371ca63a989a4af95625475a0d22d-X
#paypal支付配置
paypal
:
success_url
:
https://dev.diaosaas.com/zion/paypal/success
cancel_url
:
https://dev.diaosaas.com/zion/paypal/cancel
client_app
:
AXD2kJ8UK9Z-8XnztFF6H4_G3t3fPE9xWrMDV7GoAwuWIw9Z32_7vsrLeDDPFJeAyr7KdZyBYuyqRsYu
client_secret
:
EOsClSHvNzcL-oO9qflJ1rJuluvGstgU8LZGyFmCBHKbhYqFFP5JREhQS8CNbvgoHKWUiCv_Qh7dlBkQ
success_page
:
https://www.afrieshop.com/payment_successful
failed_page
:
https://www.afrieshop.com/payment_failed
mode
:
live
src/main/resources/application-prod.yml
浏览文件 @
4a2f2a0c
...
...
@@ -73,3 +73,13 @@ flutter:
public_key
:
FLWPUBK-ee0f5d653f5f33fc89e6caf9de6a4c34-X
secret_key
:
FLWSECK-c06cdc19526077f3855b76045ca77de3-X
#paypal支付配置
paypal
:
success_url
:
https://www.afrieshop.com/zion/paypal/success
cancel_url
:
https://www.afrieshop.com/zion/paypal/cancel
client_app
:
AXD2kJ8UK9Z-8XnztFF6H4_G3t3fPE9xWrMDV7GoAwuWIw9Z32_7vsrLeDDPFJeAyr7KdZyBYuyqRsYu
client_secret
:
EOsClSHvNzcL-oO9qflJ1rJuluvGstgU8LZGyFmCBHKbhYqFFP5JREhQS8CNbvgoHKWUiCv_Qh7dlBkQ
success_page
:
https://www.afrieshop.com/payment_successful
failed_page
:
https://www.afrieshop.com/payment_failed
mode
:
live
src/main/resources/application-test.yml
浏览文件 @
4a2f2a0c
...
...
@@ -76,3 +76,13 @@ flutter:
public_key
:
FLWPUBK_TEST-e3cc948e7cb24b2128fca3b781f6fce0-X
secret_key
:
FLWSECK_TEST-f88371ca63a989a4af95625475a0d22d-X
#paypal支付配置
paypal
:
success_url
:
https://dev.diaosaas.com/zion/paypal/success
cancel_url
:
https://dev.diaosaas.com/zion/paypal/cancel
client_app
:
Ad2N5bYO08PCve8gys1qaEiNlHV-HbHWqUzz3yNnKUffXW8AQHWz87WwpdCr4blMAvvMDdfAsBd2D2-C
client_secret
:
EFL1jVn93-ojQOg9H-CujDWfM_MSESgPR0m0qXGO6OvCzhbuwseB_soNvU6yKW7WBxp_URxmN3Fpjzay
success_page
:
https://www.afrieshop.com/payment_successful
failed_page
:
https://www.afrieshop.com/payment_failed
mode
:
sandbox
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论