VIP改版
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.peanut.modules.pay.applePay.service;
|
||||
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.pay.IOSPay.Result;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -30,7 +29,7 @@ public interface ApplePayService {
|
||||
|
||||
|
||||
|
||||
R getAppPay(String verifyResult, String transactionID);
|
||||
// R getAppPay(String verifyResult, String transactionID);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.peanut.modules.pay.applePay.service.impl;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import com.peanut.common.utils.DateUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.pay.IOSPay.Result;
|
||||
import com.peanut.modules.pay.applePay.service.ApplePayService;
|
||||
import com.peanut.modules.pay.applePay.utils.*;
|
||||
@@ -15,8 +12,6 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
@@ -122,63 +117,38 @@ public class ApplePayServiceImpl implements ApplePayService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public R getAppPay(String verifyResult, String transactionID) {
|
||||
log.info("##########################苹果支付验证!########################");
|
||||
JSONObject jsonObject = JSONObject.parseObject(verifyResult);
|
||||
String status = jsonObject.getString("status");
|
||||
//判断是否验证成功
|
||||
if ("0".equals(status)) {
|
||||
//app端所提供的收据是有效的,验证成功
|
||||
String receipt = jsonObject.getString("receipt");
|
||||
JSONObject returnJson = JSONObject.parseObject(receipt);
|
||||
String in_app = returnJson.getString("in_app");
|
||||
JSONObject in_appJson = JSONObject.parseObject(in_app.substring(1, in_app.length() - 1));
|
||||
String transactionId = in_appJson.getString("transaction_id");
|
||||
String in_app_ownership_type = in_appJson.getString("in_app_ownership_type");
|
||||
//如果验证后的订单号与app端传来的订单号一致并且状态为已支付状态则处理自己的业务
|
||||
if (transactionID.equals(transactionId) && "PURCHASED".equals(in_app_ownership_type)) {
|
||||
//===================处理自己的业务 ============================
|
||||
BuyOrder order = this.buyOrderService.getOne(new QueryWrapper<BuyOrder>().eq("order_sn", transactionId ));
|
||||
PayWechatOrderEntity wechat = new PayWechatOrderEntity();
|
||||
// @Override
|
||||
// @Transactional
|
||||
// public R getAppPay(String verifyResult, String transactionID) {
|
||||
// log.info("##########################苹果支付验证!########################");
|
||||
// JSONObject jsonObject = JSONObject.parseObject(verifyResult);
|
||||
// String status = jsonObject.getString("status");
|
||||
// //判断是否验证成功
|
||||
// if ("0".equals(status)) {
|
||||
// //app端所提供的收据是有效的,验证成功
|
||||
// String receipt = jsonObject.getString("receipt");
|
||||
// JSONObject returnJson = JSONObject.parseObject(receipt);
|
||||
// String in_app = returnJson.getString("in_app");
|
||||
// JSONObject in_appJson = JSONObject.parseObject(in_app.substring(1, in_app.length() - 1));
|
||||
// String transactionId = in_appJson.getString("transaction_id");
|
||||
// String in_app_ownership_type = in_appJson.getString("in_app_ownership_type");
|
||||
// //如果验证后的订单号与app端传来的订单号一致并且状态为已支付状态则处理自己的业务
|
||||
// if (transactionID.equals(transactionId) && "PURCHASED".equals(in_app_ownership_type)) {
|
||||
// //===================处理自己的业务 ============================
|
||||
// BuyOrder order = this.buyOrderService.getOne(new QueryWrapper<BuyOrder>().eq("order_sn", transactionId ));
|
||||
// PayWechatOrderEntity wechat = new PayWechatOrderEntity();
|
||||
//
|
||||
//
|
||||
// }
|
||||
// return R.ok();
|
||||
// }
|
||||
// return R.error("苹果内购验证失败");
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
if ("vip".equals(order.getOrderType())) {
|
||||
//会员记录
|
||||
BookBuyConfigEntity bookBuyConfigEntity = bookBuyConfigService.getById(wechat.getBuyOrderId());
|
||||
String month = bookBuyConfigEntity.getMonth();
|
||||
userService.openMember(Integer.valueOf(transactionId),Integer.valueOf(month));
|
||||
buyOrderService.updateOrderStatus(Integer.valueOf(transactionId),order.getOrderSn(),"2");
|
||||
|
||||
|
||||
|
||||
}
|
||||
if ("order".equals(order.getOrderType())) {
|
||||
|
||||
BuyOrder orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>().eq("order_sn", wechat.getOrderId()));
|
||||
BigDecimal realMoney = orderEntity.getRealMoney();
|
||||
//更新 订单 记录
|
||||
|
||||
}
|
||||
if ("point".equals(order.getOrderType())) {
|
||||
BookBuyConfigEntity bookBuyConfigEntity = bookBuyConfigService.getById(wechat.getBuyOrderId());
|
||||
MyUserEntity userEntity = userService.getById(Integer.valueOf(order.getUserId()));
|
||||
String realMoney = bookBuyConfigEntity.getRealMoney();
|
||||
userService.rechargeHSPoint(userEntity,Integer.valueOf(realMoney));
|
||||
//插入虚拟币消费记录
|
||||
transactionDetailsService.rechargeRecord(userEntity,realMoney,wechat.getId().intValue(),"苹果支付",order.getOrderSn());
|
||||
//插入花生币充值记录
|
||||
payPaymentOrderService.insertDetail(userEntity,bookBuyConfigEntity,wechat.getId().toString());
|
||||
buyOrderService.updateOrderStatus(Integer.valueOf(order.getUserId()),order.getOrderSn(),"2");
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("苹果内购验证失败");
|
||||
}}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user