提交 4a2f2a0c authored 作者: 吴德鹏's avatar 吴德鹏

Collection items paging processing

上级 db1a44f2
......@@ -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>
......
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;
}
}
package com.example.afrishop_v3.config;
public enum PaypalPaymentIntent {
sale, authorize, order
}
package com.example.afrishop_v3.config;
public enum PaypalPaymentMethod {
credit_card, paypal
}
......@@ -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?
*/
......
//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;
// }
//}
......@@ -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(pageSize, pageNum));
Page<TbCfItemCollection> allByUserId = itemCollectionRepository.findAllByUserId(user.userId(), PageRequest.of(pageNo, pageSize));
return new Result<>(allByUserId);
}
......
......@@ -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);
......
......@@ -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
......@@ -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
......@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论