记得上下班打卡 | git大法好,push需谨慎

Commit dbfe65f3 authored by zhengfuxin's avatar zhengfuxin

苹果支付。。。

parent a1631329
...@@ -10,4 +10,13 @@ public class ApplePayRefundDto implements Serializable { ...@@ -10,4 +10,13 @@ public class ApplePayRefundDto implements Serializable {
private String productId; private String productId;
private static final ApplePayRefundDto obj = new ApplePayRefundDto();
public static ApplePayRefundDto getNew() {
try {
return (ApplePayRefundDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new ApplePayRefundDto();
}
}
} }
...@@ -36,6 +36,7 @@ public class DragonPayBaseReqDto implements Serializable, Cloneable{ ...@@ -36,6 +36,7 @@ public class DragonPayBaseReqDto implements Serializable, Cloneable{
private String showUrl; private String showUrl;
private String returnUrl; private String returnUrl;
private String authCode; private String authCode;
// 苹果的
private String receiptData; private String receiptData;
//苹果的stransactionId //苹果的stransactionId
private String transactionId; private String transactionId;
......
...@@ -119,6 +119,8 @@ public class DragonOrdersDto implements Serializable, Cloneable { ...@@ -119,6 +119,8 @@ public class DragonOrdersDto implements Serializable, Cloneable {
*/ */
private LocalDateTime deletedAt; private LocalDateTime deletedAt;
private String receiptData;
private static final DragonOrdersDto obj = new DragonOrdersDto(); private static final DragonOrdersDto obj = new DragonOrdersDto();
public static DragonOrdersDto getNew() { public static DragonOrdersDto getNew() {
......
...@@ -102,3 +102,6 @@ CREATE TABLE `dragon_order_refund_logs` ...@@ -102,3 +102,6 @@ CREATE TABLE `dragon_order_refund_logs`
DEFAULT CHARSET = utf8 DEFAULT CHARSET = utf8
COLLATE = utf8_unicode_ci COLLATE = utf8_unicode_ci
ROW_FORMAT = DYNAMIC COMMENT '退款订单信息表'; ROW_FORMAT = DYNAMIC COMMENT '退款订单信息表';
alter table dragon_orders add receipt_data text comment '苹果支付回调的code';
...@@ -56,6 +56,7 @@ public class DragonServiceCommonBiz { ...@@ -56,6 +56,7 @@ public class DragonServiceCommonBiz {
// orders.setFinishedAt(); // orders.setFinishedAt();
orders.setCreatedAt(LocalDateTime.now()); orders.setCreatedAt(LocalDateTime.now());
// orders.setUpdatedAt(); // orders.setUpdatedAt();
orders.setReceiptData(dragonPayBaseReqDto.getReceiptData());
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
...@@ -72,7 +73,7 @@ public class DragonServiceCommonBiz { ...@@ -72,7 +73,7 @@ public class DragonServiceCommonBiz {
, orders.getNotifyUrl(), orders.getNotifyStatus(),orders.getPaymentType(), , orders.getNotifyUrl(), orders.getNotifyStatus(),orders.getPaymentType(),
orders.getPaymentId(), orders.getPaymentAt() orders.getPaymentId(), orders.getPaymentAt()
, orders.getFinishedAt(), orders.getCreatedAt() , orders.getFinishedAt(), orders.getCreatedAt()
, orders.getUpdatedAt(),orders.getDeletedAt()} , orders.getUpdatedAt(),orders.getDeletedAt(),orders.getReceiptData()}
,DragonConstant.MysqlRedisQueueEnum.DRAGON_PAY_KEY.getCode() ,DragonConstant.MysqlRedisQueueEnum.DRAGON_PAY_KEY.getCode()
); );
log.info("redis-queue-sendMySqlRedis->耗时:{}",(System.currentTimeMillis() - startTime)+"毫秒"); log.info("redis-queue-sendMySqlRedis->耗时:{}",(System.currentTimeMillis() - startTime)+"毫秒");
......
...@@ -2,6 +2,7 @@ package com.liquidnet.service.dragon.controller; ...@@ -2,6 +2,7 @@ package com.liquidnet.service.dragon.controller;
import com.liquidnet.commons.lang.util.IDGenerator; import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.commons.lang.util.StringUtil; import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto; import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto;
import com.liquidnet.service.dragon.service.IDragonOrdersService; import com.liquidnet.service.dragon.service.IDragonOrdersService;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
...@@ -64,7 +65,7 @@ public class PayNotifyController { ...@@ -64,7 +65,7 @@ public class PayNotifyController {
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "expireTime", value = "订单过期时间", example = "1000"), @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "expireTime", value = "订单过期时间", example = "1000"),
@ApiImplicitParam(type = "form", required = false, dataType = "String", name = "authCode", value = "付款码", example = "1000"), @ApiImplicitParam(type = "form", required = false, dataType = "String", name = "authCode", value = "付款码", example = "1000"),
}) })
public String dragonNotifyApple( public ResponseDto dragonNotifyApple(
@RequestParam(value = "payType") @NotNull(message = "支付类型不能为空") String payType, @RequestParam(value = "payType") @NotNull(message = "支付类型不能为空") String payType,
@RequestParam(value = "deviceFrom") @NotNull(message = "设备来源不能为空") String deviceFrom, @RequestParam(value = "deviceFrom") @NotNull(message = "设备来源不能为空") String deviceFrom,
@RequestParam(value = "openId", required = false) String openId, @RequestParam(value = "openId", required = false) String openId,
...@@ -80,7 +81,8 @@ public class PayNotifyController { ...@@ -80,7 +81,8 @@ public class PayNotifyController {
@RequestParam(value = "showUrl", required = false) String showUrl, @RequestParam(value = "showUrl", required = false) String showUrl,
@RequestParam(value = "createDate", required = true) String createDate, @RequestParam(value = "createDate", required = true) String createDate,
@RequestParam(value = "expireTime", required = true) String expireTime, @RequestParam(value = "expireTime", required = true) String expireTime,
@RequestParam(value = "authCode", required = false) String authCode @RequestParam(value = "receiptData", required = true) String receiptData,
@RequestParam(value = "transactionId", required = true) String transactionId
) throws Exception { ) throws Exception {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
DragonPayBaseReqDto dragonPayBaseReqDto = DragonPayBaseReqDto.getNew(); DragonPayBaseReqDto dragonPayBaseReqDto = DragonPayBaseReqDto.getNew();
...@@ -88,7 +90,6 @@ public class PayNotifyController { ...@@ -88,7 +90,6 @@ public class PayNotifyController {
dragonPayBaseReqDto.setDeviceFrom(deviceFrom); dragonPayBaseReqDto.setDeviceFrom(deviceFrom);
dragonPayBaseReqDto.setType(type); dragonPayBaseReqDto.setType(type);
dragonPayBaseReqDto.setPrice(price); dragonPayBaseReqDto.setPrice(price);
dragonPayBaseReqDto.setAuthCode(authCode);
if(StringUtil.isNotNull(name)&&name.length()>=32){ if(StringUtil.isNotNull(name)&&name.length()>=32){
name = name.substring(0,32); name = name.substring(0,32);
} }
...@@ -105,8 +106,12 @@ public class PayNotifyController { ...@@ -105,8 +106,12 @@ public class PayNotifyController {
dragonPayBaseReqDto.setCreateDate(createDate); dragonPayBaseReqDto.setCreateDate(createDate);
dragonPayBaseReqDto.setExpireTime(expireTime); dragonPayBaseReqDto.setExpireTime(expireTime);
dragonPayBaseReqDto.setCode(IDGenerator.payCode()); dragonPayBaseReqDto.setCode(IDGenerator.payCode());
/* return dragonOrdersService.dragonNotify(request,payType,deviceFrom);*/ dragonPayBaseReqDto.setReceiptData(receiptData);
return null; dragonPayBaseReqDto.setTransactionId(transactionId);
//调用苹果
dragonOrdersService.dragonNotifyApple(dragonPayBaseReqDto);
return ResponseDto.success(null);
} }
} }
...@@ -11,10 +11,7 @@ import com.liquidnet.service.dragon.channel.strategy.PayChannelStrategyContext; ...@@ -11,10 +11,7 @@ import com.liquidnet.service.dragon.channel.strategy.PayChannelStrategyContext;
import com.liquidnet.service.dragon.channel.strategy.biz.DragonPayBiz; import com.liquidnet.service.dragon.channel.strategy.biz.DragonPayBiz;
import com.liquidnet.service.dragon.constant.DragonConstant; import com.liquidnet.service.dragon.constant.DragonConstant;
import com.liquidnet.service.dragon.constant.DragonErrorCodeEnum; import com.liquidnet.service.dragon.constant.DragonErrorCodeEnum;
import com.liquidnet.service.dragon.dto.DragonOrdersDto; import com.liquidnet.service.dragon.dto.*;
import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto;
import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
import com.liquidnet.service.dragon.dto.DragonPayOrderQueryRespDto;
import com.liquidnet.service.dragon.service.IDragonOrdersService; import com.liquidnet.service.dragon.service.IDragonOrdersService;
import com.liquidnet.service.dragon.utils.ApplepayUtils; import com.liquidnet.service.dragon.utils.ApplepayUtils;
import com.liquidnet.service.dragon.utils.DataUtils; import com.liquidnet.service.dragon.utils.DataUtils;
...@@ -103,6 +100,7 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService { ...@@ -103,6 +100,7 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService {
if (verifyResult == null) { if (verifyResult == null) {
// 苹果服务器没有返回验证结果 // 苹果服务器没有返回验证结果
log.info("苹果支付,app调用,查不到订单信息"); log.info("苹果支付,app调用,查不到订单信息");
return;
} else { } else {
JSONObject job = JSONObject.parseObject(verifyResult); JSONObject job = JSONObject.parseObject(verifyResult);
String states = job.getString("status"); String states = job.getString("status");
...@@ -111,20 +109,22 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService { ...@@ -111,20 +109,22 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService {
JSONObject returnJson = JSONObject.parseObject(r_receipt); JSONObject returnJson = JSONObject.parseObject(r_receipt);
String in_app = returnJson.getString("in_app"); String in_app = returnJson.getString("in_app");
JSONObject in_appJson = JSONObject.parseObject(in_app.substring(1, in_app.length() - 1)); JSONObject in_appJson = JSONObject.parseObject(in_app.substring(1, in_app.length() - 1));
ApplePayRefundDto applePayRefundDto=ApplePayRefundDto.getNew();
String product_id = in_appJson.getString("product_id"); String product_id = in_appJson.getString("product_id");
applePayRefundDto.setProductId(product_id);
String transaction_id = in_appJson.getString("transaction_id"); // 订单号 String transaction_id = in_appJson.getString("transaction_id"); // 订单号
//如果单号一致 则开始处理逻辑 //如果单号一致 则开始处理逻辑
if(dragonPayBaseReqDto.getTransactionId().equals(transaction_id)){ if(dragonPayBaseReqDto.getTransactionId().equals(transaction_id)){
String[] moneys = product_id.split("\\.");//实际支付金额 /*String[] moneys = product_id.split("\\.");//实际支付金额
//此处开始业务逻辑 //此处开始业务逻辑*/
} }
} else { } else {
return;
} }
} }
//2 插入支付该支付的东西(预支付的东西)//dragon_orders //2 插入支付该支付的东西(预支付的东西)//dragon_orders
dragonServiceCommonBiz.buildPayOrders(dragonPayBaseReqDto,null); dragonServiceCommonBiz.buildPayOrders(dragonPayBaseReqDto,null);
//第二部
} }
......
...@@ -8,7 +8,7 @@ dragon_order_refund_call_back.update=UPDATE `dragon_order_refunds` SET updated_a ...@@ -8,7 +8,7 @@ dragon_order_refund_call_back.update=UPDATE `dragon_order_refunds` SET updated_a
dragon_order_refund_log.insert=INSERT INTO `dragon_order_refund_logs`(`order_refund_id` ,`refund_type` ,`content`,`created_at`,`updated_at`)VALUES(?,?,?,?,?); dragon_order_refund_log.insert=INSERT INTO `dragon_order_refund_logs`(`order_refund_id` ,`refund_type` ,`content`,`created_at`,`updated_at`)VALUES(?,?,?,?,?);
dragon_orders.insert=insert into dragon_orders(order_id, status, code, type, price, name, detail, order_code, order_code_id, client_ip, notify_url,notify_status, payment_type, payment_id, payment_at, finished_at, created_at, updated_at, deleted_at) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) dragon_orders.insert=insert into dragon_orders(order_id, status, code, type, price, name, detail, order_code, order_code_id, client_ip, notify_url,notify_status, payment_type, payment_id, payment_at, finished_at, created_at, updated_at, deleted_at,receipt_data) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
dragon_order_logs.insert=insert into dragon_order_logs(code, payment_type, content, created_at, updated_at, deleted_at) values(?,?,?,?,?,?) dragon_order_logs.insert=insert into dragon_order_logs(code, payment_type, content, created_at, updated_at, deleted_at) values(?,?,?,?,?,?)
dragon_pay_notify.insert=insert into dragon_pay_notify (code, order_code, notify_url, notify_data, created_at, updated_at) values(?,?,?,?,?,?) dragon_pay_notify.insert=insert into dragon_pay_notify (code, order_code, notify_url, notify_data, created_at, updated_at) values(?,?,?,?,?,?)
dragon_pay_notify_fail.insert=insert into dragon_pay_notify_fail (code, order_code, notify_url, notify_data, fail_desc, created_at, updated_at) values(?,?,?,?,?,?,?) dragon_pay_notify_fail.insert=insert into dragon_pay_notify_fail (code, order_code, notify_url, notify_data, fail_desc, created_at, updated_at) values(?,?,?,?,?,?,?)
......
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