ios内购

This commit is contained in:
wuchunlei
2024-07-09 16:48:28 +08:00
parent ec17636fe6
commit 472021ca9b
7 changed files with 93 additions and 99 deletions

View File

@@ -38,6 +38,7 @@ public class BookBuyConfigController {
if (params.containsKey("qudao")&&StringUtils.isNotEmpty(params.get("qudao").toString())){ if (params.containsKey("qudao")&&StringUtils.isNotEmpty(params.get("qudao").toString())){
wrapper.eq(BookBuyConfigEntity::getQudao,params.get("qudao")); wrapper.eq(BookBuyConfigEntity::getQudao,params.get("qudao"));
} }
wrapper.orderByAsc(BookBuyConfigEntity::getRealMoney);
List<BookBuyConfigEntity> list = service.list(wrapper); List<BookBuyConfigEntity> list = service.list(wrapper);
return R.ok().put("bookBuyConfigList",list); return R.ok().put("bookBuyConfigList",list);
} }

View File

@@ -43,6 +43,15 @@ public class SysFeedbackController {
return R.ok().put("sysFeedback",sysFeedbackService.getById(params)); return R.ok().put("sysFeedback",sysFeedbackService.getById(params));
} }
@RequestMapping("/editStatusById")
public R editStatusById(@RequestBody Map<String,Object> params){
if (sysFeedbackService.editStatusById(params)>0){
return R.ok();
}else {
return R.error("修改失败");
}
}
@RequestMapping("/delById") @RequestMapping("/delById")
public R delById(@RequestBody Map<String,Object> params){ public R delById(@RequestBody Map<String,Object> params){
if (sysFeedbackService.delById(params)>0){ if (sysFeedbackService.delById(params)>0){

View File

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
import java.util.Date;
@Data @Data
@TableName("sys_feedback") @TableName("sys_feedback")
@@ -26,6 +27,10 @@ public class SysFeedback {
private String status; private String status;
private Date createTime;
private Date updateTime;
@TableLogic @TableLogic
private Integer delFlag; private Integer delFlag;

View File

@@ -13,6 +13,8 @@ public interface SysFeedbackService extends IService<SysFeedback> {
SysFeedback getById(Map<String,Object> params); SysFeedback getById(Map<String,Object> params);
int editStatusById(Map<String,Object> params);
int delById(Map<String,Object> params); int delById(Map<String,Object> params);
} }

View File

@@ -8,6 +8,8 @@ import com.peanut.modules.common.service.SysFeedbackService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -23,6 +25,9 @@ public class SysFeedbackServiceImpl extends ServiceImpl<SysFeedbackDao, SysFeedb
@Override @Override
public List<SysFeedback> getList(Map<String, Object> params) { public List<SysFeedback> getList(Map<String, Object> params) {
LambdaQueryWrapper<SysFeedback> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SysFeedback> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.orderByAsc(SysFeedback::getStatus);
queryWrapper.orderByDesc(SysFeedback::getCreateTime);
queryWrapper.orderByDesc(SysFeedback::getUpdateTime);
if (StringUtils.isNotBlank(params.get("account").toString())){ if (StringUtils.isNotBlank(params.get("account").toString())){
queryWrapper.like(SysFeedback::getAccount,params.get("account")); queryWrapper.like(SysFeedback::getAccount,params.get("account"));
} }
@@ -40,6 +45,17 @@ public class SysFeedbackServiceImpl extends ServiceImpl<SysFeedbackDao, SysFeedb
return this.baseMapper.selectById(params.get("sysFeedbackId").toString()); return this.baseMapper.selectById(params.get("sysFeedbackId").toString());
} }
@Override
public int editStatusById(Map<String, Object> params) {
SysFeedback entity = this.baseMapper.selectById(params.get("sysFeedbackId").toString());
if (entity != null) {
entity.setStatus("1");
entity.setUpdateTime(new Date());
return this.baseMapper.updateById(entity);
}
return 0;
}
@Override @Override
public int delById(Map<String, Object> params) { public int delById(Map<String, Object> params) {
return this.baseMapper.deleteById(params.get("sysFeedbackId").toString()); return this.baseMapper.deleteById(params.get("sysFeedbackId").toString());

View File

@@ -10,6 +10,7 @@ public interface VerifyReceiptConstant {
*/ */
String APP_BUNDLE_IDENTIFIER = "com.cn.nuttyreading"; String APP_BUNDLE_IDENTIFIER = "com.cn.nuttyreading";
String MEDICINE_APP_BUNDLE_IDENTIFIER = "com.cn.medicine";
String URL_SANDBOX = "https://sandbox.itunes.apple.com/verifyReceipt"; String URL_SANDBOX = "https://sandbox.itunes.apple.com/verifyReceipt";
String URL_VERIFY = "https://buy.itunes.apple.com/verifyReceipt"; String URL_VERIFY = "https://buy.itunes.apple.com/verifyReceipt";

View File

@@ -46,7 +46,6 @@ public class AppController {
@Autowired @Autowired
private BuyOrderService buyOrderService; private BuyOrderService buyOrderService;
@RequestMapping(value = "/text", method = RequestMethod.POST) @RequestMapping(value = "/text", method = RequestMethod.POST)
public String verif() { public String verif() {
return "test"; return "test";
@@ -58,19 +57,11 @@ public class AppController {
* @param dto 入参: 订单id, 苹果凭证 * @param dto 入参: 订单id, 苹果凭证
* @return 验证结果 * @return 验证结果
*/ */
@RequestMapping(value = "/veri", method = RequestMethod.POST) @RequestMapping(value = "/veri", method = RequestMethod.POST)
public Result verifyIap(@RequestBody IapRequestDTO dto) { public Result verifyIap(@RequestBody IapRequestDTO dto) {
Lock lock = new ReentrantLock(); Lock lock = new ReentrantLock();
lock.lock(); lock.lock();
try { try {
// 1. 校验入参 // 1. 校验入参
if (dto == null) if (dto == null)
return Result.error("入参不能为空"); return Result.error("入参不能为空");
@@ -84,122 +75,91 @@ public class AppController {
return Result.error("内购订单号不能为空"); return Result.error("内购订单号不能为空");
if (dto.getReceiptData().isEmpty()) if (dto.getReceiptData().isEmpty())
return Result.error("凭证不能为空"); return Result.error("凭证不能为空");
IapResponseDTO receipt = iapVerifyReceiptService.verifyIapReceipt(dto.getReceiptData(), dto.isSandBox()); IapResponseDTO receipt = iapVerifyReceiptService.verifyIapReceipt(dto.getReceiptData(), dto.isSandBox());
BuyOrder order2 = this.buyOrderService.getOne(new QueryWrapper<BuyOrder>().eq("order_sn", dto.getOrderId()).eq("del_flag", "0")); BuyOrder order2 = this.buyOrderService.getOne(new QueryWrapper<BuyOrder>().eq("order_sn", dto.getOrderId()).eq("del_flag", "0"));
order2.setPaymentDate(new Date()); order2.setPaymentDate(new Date());
order2.setProductId(dto.getProductId()); order2.setProductId(dto.getProductId());
this.buyOrderService.updateById(order2); this.buyOrderService.updateById(order2);
IosPayOrderEntity order = new IosPayOrderEntity(); IosPayOrderEntity order = new IosPayOrderEntity();
//todo 判断状态 订单状态 0-未付款 1-待发货 2-已发货 3-交易成功 4-交易失败 //todo 判断状态 订单状态 0-未付款 1-待发货 2-已发货 3-交易成功 4-交易失败
String order01 = order.getOrderid(); String order01 = order.getOrderid();
String order02 = order2.getOrderSn(); String order02 = order2.getOrderSn();
if (order01 == order02) { if (order01 == order02) {
return Result.ok(); return Result.ok();
} }
else else
if (order01 == null ) { if (order01 == null ) {
// 3.1 校验bundle id // 3.1 校验bundle id
if (!receipt.getReceipt().getBundle_id().equals(VerifyReceiptConstant.APP_BUNDLE_IDENTIFIER)) { if (!receipt.getReceipt().getBundle_id().equals(VerifyReceiptConstant.APP_BUNDLE_IDENTIFIER)&&
!receipt.getReceipt().getBundle_id().equals(VerifyReceiptConstant.MEDICINE_APP_BUNDLE_IDENTIFIER)) {
return Result.error1(); return Result.error1();
} }
if (receipt.getStatus().equals("0")) { if (receipt.getStatus().equals("0")) {
for (IapResponseDTO.AppleOrder appleOrder : receipt.getReceipt().getIn_app()) { IapResponseDTO.AppleOrder appleOrder = receipt.getReceipt().getIn_app()[0];
if (appleOrder.getTransaction_id().equals(dto.getTransactionId()) && if (appleOrder.getTransaction_id().equals(dto.getTransactionId()) &&
appleOrder.getProduct_id().equals(dto.getProductId())) { //p+productid为吴门医述商品单id为疯子读书商品
System.out.println("开始进入判断3"+appleOrder.getTransaction_id()+"====="+dto.getTransactionId()+"====="+ (appleOrder.getProduct_id().equals(dto.getProductId())||
appleOrder.getProduct_id()+"====="+dto.getProductId()); appleOrder.getProduct_id().equals("p"+dto.getProductId()))) {
System.out.println("开始进入判断3"+appleOrder.getTransaction_id()+"====="+dto.getTransactionId()+"====="+
appleOrder.getProduct_id()+"====="+dto.getProductId());
order.setOrderid(dto.getOrderId()); order.setOrderid(dto.getOrderId());
order.setReceiptData(dto.getReceiptData()); order.setReceiptData(dto.getReceiptData());
order.setProductID(dto.getProductId()); order.setProductID(dto.getProductId());
order.setTransactionId(dto.getTransactionId()); order.setTransactionId(dto.getTransactionId());
order.setCustomerOid(dto.getCustomerOid()); order.setCustomerOid(dto.getCustomerOid());
order.setOrderStatus(order2.getOrderStatus()); order.setOrderStatus(order2.getOrderStatus());
order.setDelFlag(order2.getDelFlag()); order.setDelFlag(order2.getDelFlag());
order.setCloseOrder(0); order.setCloseOrder(0);
order.setCreateTime(new Date()); order.setCreateTime(new Date());
order.setFailureflag(dto.getFailureflag()); order.setFailureflag(dto.getFailureflag());
orderService.saveOrUpdate(order); orderService.saveOrUpdate(order);
String customerid = dto.getCustomerOid(); String customerid = dto.getCustomerOid();
String subject = "point"; String body = dto.getProductId();
String body = dto.getProductId(); // 插入花生币 变动记录
if ("point".equals(subject)) { BookBuyConfigEntity bookBuyConfigEntity = this.bookBuyConfigService.getById(Integer.valueOf(body));
// 插入花生币 变动记录 String realMoney = bookBuyConfigEntity.getMoney();
Integer money = Integer.valueOf(realMoney);
BookBuyConfigEntity bookBuyConfigEntity = this.bookBuyConfigService.getById(Integer.valueOf(body)); userService.rechargeHSPoint(Integer.valueOf(customerid), money);
String realMoney = bookBuyConfigEntity.getMoney(); TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity();
Integer money = Integer.valueOf(realMoney); transactionDetailsEntity.setUserId(Integer.valueOf(customerid));
userService.rechargeHSPoint(Integer.valueOf(customerid), money); transactionDetailsEntity.setChangeAmount(new BigDecimal(money));
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity(); transactionDetailsEntity.setOrderType("充值");
transactionDetailsEntity.setUserId(Integer.valueOf(customerid)); transactionDetailsEntity.setRelationId(order.getId());
transactionDetailsEntity.setChangeAmount(new BigDecimal(money)); transactionDetailsEntity.setRemark("充值");
transactionDetailsEntity.setOrderType("充值"); MyUserEntity user = userService.getById(Integer.valueOf(customerid));
transactionDetailsEntity.setRelationId(order.getId()); BigDecimal peanutCoin = user.getPeanutCoin();
transactionDetailsEntity.setRemark("充值"); transactionDetailsEntity.setUserBalance(peanutCoin);
MyUserEntity user = userService.getById(Integer.valueOf(customerid)); transactionDetailsEntity.setUserName(user.getNickname());
BigDecimal peanutCoin = user.getPeanutCoin(); transactionDetailsEntity.setTel(user.getTel());
transactionDetailsEntity.setUserBalance(peanutCoin); transactionDetailsService.save(transactionDetailsEntity);
transactionDetailsEntity.setUserName(user.getNickname()); // 插入 花生币 充值记录
transactionDetailsEntity.setTel(user.getTel()); PayPaymentOrderEntity payPaymentOrderEntity = new PayPaymentOrderEntity();
transactionDetailsService.save(transactionDetailsEntity); payPaymentOrderEntity.setUserId(Integer.valueOf(customerid));
// 插入 花生币 充值记录 payPaymentOrderEntity.setOrderId(order.getTransactionId());
PayPaymentOrderEntity payPaymentOrderEntity = new PayPaymentOrderEntity(); payPaymentOrderEntity.setRealAmount(new BigDecimal(bookBuyConfigEntity.getRealMoney()));
payPaymentOrderEntity.setUserId(Integer.valueOf(customerid)); payPaymentOrderEntity.setRechargeAmount(new BigDecimal(bookBuyConfigEntity.getMoney()));
payPaymentOrderEntity.setOrderId(order.getTransactionId()); payPaymentOrderEntity.setRechargeChannel(bookBuyConfigEntity.getQudao());
payPaymentOrderEntity.setRealAmount(new BigDecimal(bookBuyConfigEntity.getRealMoney())); payPaymentOrderEntity.setRechargeStatus("success");
payPaymentOrderEntity.setRechargeAmount(new BigDecimal(bookBuyConfigEntity.getMoney())); payPaymentOrderEntity.setSuccessTime(new Date());
payPaymentOrderEntity.setRechargeChannel(bookBuyConfigEntity.getQudao()); payPaymentOrderEntity.setUserName(user.getNickname());
payPaymentOrderEntity.setRechargeStatus("success"); payPaymentOrderEntity.setTel(user.getTel());
payPaymentOrderEntity.setSuccessTime(new Date()); payPaymentOrderService.save(payPaymentOrderEntity);
payPaymentOrderEntity.setUserName(user.getNickname()); buyOrderService.updateOrderStatus(Integer.valueOf(customerid), dto.getOrderId(), "2");
payPaymentOrderEntity.setTel(user.getTel()); order.setMoney(Integer.valueOf(bookBuyConfigEntity.getRealMoney()));
payPaymentOrderService.save(payPaymentOrderEntity); order.setUsername(user.getName());
buyOrderService.updateOrderStatus(Integer.valueOf(customerid), dto.getOrderId(), "2"); orderService.saveOrUpdate(order);
order.setMoney(Integer.valueOf(bookBuyConfigEntity.getRealMoney())); orderService.update();
order.setUsername(user.getName()); return Result.ok0();
orderService.saveOrUpdate(order); }else {
return Result.nook(500,"订单id错误或者商品id");
}
orderService.update();
}
} }
return Result.ok0();
} }
return Result.ok("第一次付款成功"); return Result.ok("第一次付款成功");
} }
return Result.nook(500,"订单加载失败"); return Result.nook(500,"订单加载失败");
} finally { } finally {
lock.unlock(); lock.unlock();
} }
} }