ios内购
This commit is contained in:
@@ -38,6 +38,7 @@ public class BookBuyConfigController {
|
||||
if (params.containsKey("qudao")&&StringUtils.isNotEmpty(params.get("qudao").toString())){
|
||||
wrapper.eq(BookBuyConfigEntity::getQudao,params.get("qudao"));
|
||||
}
|
||||
wrapper.orderByAsc(BookBuyConfigEntity::getRealMoney);
|
||||
List<BookBuyConfigEntity> list = service.list(wrapper);
|
||||
return R.ok().put("bookBuyConfigList",list);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,15 @@ public class SysFeedbackController {
|
||||
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")
|
||||
public R delById(@RequestBody Map<String,Object> params){
|
||||
if (sysFeedbackService.delById(params)>0){
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("sys_feedback")
|
||||
@@ -26,6 +27,10 @@ public class SysFeedback {
|
||||
|
||||
private String status;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ public interface SysFeedbackService extends IService<SysFeedback> {
|
||||
|
||||
SysFeedback getById(Map<String,Object> params);
|
||||
|
||||
int editStatusById(Map<String,Object> params);
|
||||
|
||||
int delById(Map<String,Object> params);
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.peanut.modules.common.service.SysFeedbackService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -23,6 +25,9 @@ public class SysFeedbackServiceImpl extends ServiceImpl<SysFeedbackDao, SysFeedb
|
||||
@Override
|
||||
public List<SysFeedback> getList(Map<String, Object> params) {
|
||||
LambdaQueryWrapper<SysFeedback> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.orderByAsc(SysFeedback::getStatus);
|
||||
queryWrapper.orderByDesc(SysFeedback::getCreateTime);
|
||||
queryWrapper.orderByDesc(SysFeedback::getUpdateTime);
|
||||
if (StringUtils.isNotBlank(params.get("account").toString())){
|
||||
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());
|
||||
}
|
||||
|
||||
@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
|
||||
public int delById(Map<String, Object> params) {
|
||||
return this.baseMapper.deleteById(params.get("sysFeedbackId").toString());
|
||||
|
||||
@@ -10,6 +10,7 @@ public interface VerifyReceiptConstant {
|
||||
*/
|
||||
|
||||
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_VERIFY = "https://buy.itunes.apple.com/verifyReceipt";
|
||||
|
||||
@@ -46,7 +46,6 @@ public class AppController {
|
||||
@Autowired
|
||||
private BuyOrderService buyOrderService;
|
||||
|
||||
|
||||
@RequestMapping(value = "/text", method = RequestMethod.POST)
|
||||
public String verif() {
|
||||
return "test";
|
||||
@@ -58,19 +57,11 @@ public class AppController {
|
||||
* @param dto 入参: 订单id, 苹果凭证
|
||||
* @return 验证结果
|
||||
*/
|
||||
|
||||
|
||||
@RequestMapping(value = "/veri", method = RequestMethod.POST)
|
||||
public Result verifyIap(@RequestBody IapRequestDTO dto) {
|
||||
|
||||
|
||||
Lock lock = new ReentrantLock();
|
||||
lock.lock();
|
||||
|
||||
try {
|
||||
|
||||
|
||||
|
||||
// 1. 校验入参
|
||||
if (dto == null)
|
||||
return Result.error("入参不能为空");
|
||||
@@ -84,122 +75,91 @@ public class AppController {
|
||||
return Result.error("内购订单号不能为空");
|
||||
if (dto.getReceiptData().isEmpty())
|
||||
return Result.error("凭证不能为空");
|
||||
|
||||
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"));
|
||||
order2.setPaymentDate(new Date());
|
||||
|
||||
|
||||
|
||||
order2.setProductId(dto.getProductId());
|
||||
this.buyOrderService.updateById(order2);
|
||||
|
||||
IosPayOrderEntity order = new IosPayOrderEntity();
|
||||
|
||||
//todo 判断状态 订单状态 0-未付款 1-待发货 2-已发货 3-交易成功 4-交易失败
|
||||
String order01 = order.getOrderid();
|
||||
String order02 = order2.getOrderSn();
|
||||
if (order01 == order02) {
|
||||
|
||||
return Result.ok();
|
||||
|
||||
}
|
||||
else
|
||||
if (order01 == null ) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (receipt.getStatus().equals("0")) {
|
||||
for (IapResponseDTO.AppleOrder appleOrder : receipt.getReceipt().getIn_app()) {
|
||||
if (appleOrder.getTransaction_id().equals(dto.getTransactionId()) &&
|
||||
appleOrder.getProduct_id().equals(dto.getProductId())) {
|
||||
System.out.println("开始进入判断3"+appleOrder.getTransaction_id()+"====="+dto.getTransactionId()+"====="+
|
||||
appleOrder.getProduct_id()+"====="+dto.getProductId());
|
||||
|
||||
|
||||
order.setOrderid(dto.getOrderId());
|
||||
order.setReceiptData(dto.getReceiptData());
|
||||
order.setProductID(dto.getProductId());
|
||||
order.setTransactionId(dto.getTransactionId());
|
||||
order.setCustomerOid(dto.getCustomerOid());
|
||||
order.setOrderStatus(order2.getOrderStatus());
|
||||
order.setDelFlag(order2.getDelFlag());
|
||||
order.setCloseOrder(0);
|
||||
order.setCreateTime(new Date());
|
||||
order.setFailureflag(dto.getFailureflag());
|
||||
orderService.saveOrUpdate(order);
|
||||
String customerid = dto.getCustomerOid();
|
||||
String subject = "point";
|
||||
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);
|
||||
userService.rechargeHSPoint(Integer.valueOf(customerid), money);
|
||||
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity();
|
||||
transactionDetailsEntity.setUserId(Integer.valueOf(customerid));
|
||||
transactionDetailsEntity.setChangeAmount(new BigDecimal(money));
|
||||
transactionDetailsEntity.setOrderType("充值");
|
||||
transactionDetailsEntity.setRelationId(order.getId());
|
||||
transactionDetailsEntity.setRemark("充值");
|
||||
MyUserEntity user = userService.getById(Integer.valueOf(customerid));
|
||||
BigDecimal peanutCoin = user.getPeanutCoin();
|
||||
transactionDetailsEntity.setUserBalance(peanutCoin);
|
||||
transactionDetailsEntity.setUserName(user.getNickname());
|
||||
transactionDetailsEntity.setTel(user.getTel());
|
||||
transactionDetailsService.save(transactionDetailsEntity);
|
||||
// 插入 花生币 充值记录
|
||||
PayPaymentOrderEntity payPaymentOrderEntity = new PayPaymentOrderEntity();
|
||||
payPaymentOrderEntity.setUserId(Integer.valueOf(customerid));
|
||||
payPaymentOrderEntity.setOrderId(order.getTransactionId());
|
||||
payPaymentOrderEntity.setRealAmount(new BigDecimal(bookBuyConfigEntity.getRealMoney()));
|
||||
payPaymentOrderEntity.setRechargeAmount(new BigDecimal(bookBuyConfigEntity.getMoney()));
|
||||
payPaymentOrderEntity.setRechargeChannel(bookBuyConfigEntity.getQudao());
|
||||
payPaymentOrderEntity.setRechargeStatus("success");
|
||||
payPaymentOrderEntity.setSuccessTime(new Date());
|
||||
payPaymentOrderEntity.setUserName(user.getNickname());
|
||||
payPaymentOrderEntity.setTel(user.getTel());
|
||||
payPaymentOrderService.save(payPaymentOrderEntity);
|
||||
buyOrderService.updateOrderStatus(Integer.valueOf(customerid), dto.getOrderId(), "2");
|
||||
order.setMoney(Integer.valueOf(bookBuyConfigEntity.getRealMoney()));
|
||||
order.setUsername(user.getName());
|
||||
orderService.saveOrUpdate(order);
|
||||
|
||||
|
||||
|
||||
}
|
||||
orderService.update();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
IapResponseDTO.AppleOrder appleOrder = receipt.getReceipt().getIn_app()[0];
|
||||
if (appleOrder.getTransaction_id().equals(dto.getTransactionId()) &&
|
||||
//p+productid为吴门医述商品,单id为疯子读书商品
|
||||
(appleOrder.getProduct_id().equals(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.setReceiptData(dto.getReceiptData());
|
||||
order.setProductID(dto.getProductId());
|
||||
order.setTransactionId(dto.getTransactionId());
|
||||
order.setCustomerOid(dto.getCustomerOid());
|
||||
order.setOrderStatus(order2.getOrderStatus());
|
||||
order.setDelFlag(order2.getDelFlag());
|
||||
order.setCloseOrder(0);
|
||||
order.setCreateTime(new Date());
|
||||
order.setFailureflag(dto.getFailureflag());
|
||||
orderService.saveOrUpdate(order);
|
||||
String customerid = dto.getCustomerOid();
|
||||
String body = dto.getProductId();
|
||||
// 插入花生币 变动记录
|
||||
BookBuyConfigEntity bookBuyConfigEntity = this.bookBuyConfigService.getById(Integer.valueOf(body));
|
||||
String realMoney = bookBuyConfigEntity.getMoney();
|
||||
Integer money = Integer.valueOf(realMoney);
|
||||
userService.rechargeHSPoint(Integer.valueOf(customerid), money);
|
||||
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity();
|
||||
transactionDetailsEntity.setUserId(Integer.valueOf(customerid));
|
||||
transactionDetailsEntity.setChangeAmount(new BigDecimal(money));
|
||||
transactionDetailsEntity.setOrderType("充值");
|
||||
transactionDetailsEntity.setRelationId(order.getId());
|
||||
transactionDetailsEntity.setRemark("充值");
|
||||
MyUserEntity user = userService.getById(Integer.valueOf(customerid));
|
||||
BigDecimal peanutCoin = user.getPeanutCoin();
|
||||
transactionDetailsEntity.setUserBalance(peanutCoin);
|
||||
transactionDetailsEntity.setUserName(user.getNickname());
|
||||
transactionDetailsEntity.setTel(user.getTel());
|
||||
transactionDetailsService.save(transactionDetailsEntity);
|
||||
// 插入 花生币 充值记录
|
||||
PayPaymentOrderEntity payPaymentOrderEntity = new PayPaymentOrderEntity();
|
||||
payPaymentOrderEntity.setUserId(Integer.valueOf(customerid));
|
||||
payPaymentOrderEntity.setOrderId(order.getTransactionId());
|
||||
payPaymentOrderEntity.setRealAmount(new BigDecimal(bookBuyConfigEntity.getRealMoney()));
|
||||
payPaymentOrderEntity.setRechargeAmount(new BigDecimal(bookBuyConfigEntity.getMoney()));
|
||||
payPaymentOrderEntity.setRechargeChannel(bookBuyConfigEntity.getQudao());
|
||||
payPaymentOrderEntity.setRechargeStatus("success");
|
||||
payPaymentOrderEntity.setSuccessTime(new Date());
|
||||
payPaymentOrderEntity.setUserName(user.getNickname());
|
||||
payPaymentOrderEntity.setTel(user.getTel());
|
||||
payPaymentOrderService.save(payPaymentOrderEntity);
|
||||
buyOrderService.updateOrderStatus(Integer.valueOf(customerid), dto.getOrderId(), "2");
|
||||
order.setMoney(Integer.valueOf(bookBuyConfigEntity.getRealMoney()));
|
||||
order.setUsername(user.getName());
|
||||
orderService.saveOrUpdate(order);
|
||||
orderService.update();
|
||||
return Result.ok0();
|
||||
}else {
|
||||
return Result.nook(500,"订单id错误或者商品id");
|
||||
}
|
||||
return Result.ok0();
|
||||
}
|
||||
|
||||
return Result.ok("第一次付款成功");
|
||||
|
||||
|
||||
}
|
||||
return Result.nook(500,"订单加载失败");
|
||||
} finally {
|
||||
lock.unlock();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user