回调中添加自定义充值判断
This commit is contained in:
@@ -141,7 +141,12 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
if (buyOrder!=null){
|
||||
//组装充值配置详情
|
||||
if (buyOrder.getProductId()!=null){
|
||||
buyOrder.setBookBuyConfigEntity(bookBuyConfigDao.selectById(buyOrder.getProductId()));
|
||||
BookBuyConfigEntity bookBuyConfigEntity = bookBuyConfigDao.selectById(buyOrder.getProductId());
|
||||
if ("0".equals(buyOrder.getProductId())){
|
||||
bookBuyConfigEntity.setRealMoney(buyOrder.getRealMoney());
|
||||
bookBuyConfigEntity.setMoney(buyOrder.getRealMoney());
|
||||
}
|
||||
buyOrder.setBookBuyConfigEntity(bookBuyConfigEntity);
|
||||
}
|
||||
if (buyOrder.getVipBuyConfigId()!=null&&buyOrder.getAiBuyConfigId()!=0){
|
||||
buyOrder.setVipBuyConfigEntity(vipBuyConfigDao.selectById(buyOrder.getVipBuyConfigId()));
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.JfTransactionDetailsService;
|
||||
import com.peanut.modules.pay.IOSPay.Result;
|
||||
import com.peanut.modules.pay.IOSPay.constant.VerifyReceiptConstant;
|
||||
import com.peanut.modules.pay.IOSPay.model.dto.IapRequestDTO;
|
||||
@@ -19,6 +20,7 @@ import lombok.experimental.FieldDefaults;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.math.BigDecimal;
|
||||
@@ -43,6 +45,8 @@ public class AppController {
|
||||
@Autowired
|
||||
private TransactionDetailsService transactionDetailsService;
|
||||
@Autowired
|
||||
private JfTransactionDetailsService jfTransactionDetailsService;
|
||||
@Autowired
|
||||
private PayPaymentOrderService payPaymentOrderService;
|
||||
@Autowired
|
||||
private BuyOrderService buyOrderService;
|
||||
@@ -132,6 +136,18 @@ public class AppController {
|
||||
// 插入花生币 变动记录
|
||||
BookBuyConfigEntity bookBuyConfigEntity = this.bookBuyConfigService.getById(Integer.valueOf(body));
|
||||
MyUserEntity userEntity = userService.getById(Integer.valueOf(customerid));
|
||||
if (bookBuyConfigEntity != null && bookBuyConfigEntity.getGivejf().compareTo(BigDecimal.ZERO)>0) {
|
||||
userEntity.setJf(userEntity.getJf().add(bookBuyConfigEntity.getGivejf()));
|
||||
userService.updateById(userEntity);
|
||||
JfTransactionDetails jfTransactionDetails = new JfTransactionDetails();
|
||||
jfTransactionDetails.setUserId(userEntity.getId());
|
||||
jfTransactionDetails.setChangeAmount(bookBuyConfigEntity.getGivejf());
|
||||
jfTransactionDetails.setActType(0);
|
||||
jfTransactionDetails.setUserBalance(userEntity.getJf());
|
||||
jfTransactionDetails.setRelationId(order2.getOrderId());
|
||||
jfTransactionDetails.setRemark("充币送积分:"+bookBuyConfigEntity.getDescription()+",订单号:"+order2.getOrderSn());
|
||||
jfTransactionDetailsService.save(jfTransactionDetails);
|
||||
}
|
||||
BigDecimal realMoney = bookBuyConfigEntity.getMoney();
|
||||
userService.rechargeHSPoint(userEntity, realMoney.intValue());
|
||||
//插入虚拟币消费记录
|
||||
@@ -151,6 +167,7 @@ public class AppController {
|
||||
}
|
||||
return Result.nook(500,"订单加载失败");
|
||||
} finally {
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,6 +218,11 @@ public class AliPayServiceImpl implements AliPayService {
|
||||
// 插入花生币 变动记录
|
||||
BookBuyConfigEntity bookBuyConfigEntity = bookBuyConfigService.getById(Integer.valueOf(body));
|
||||
MyUserEntity userEntity = userService.getById(order.getUserId());
|
||||
if (Integer.valueOf(body)==0){//自定义充值
|
||||
bookBuyConfigEntity.setRealMoney(order.getRealMoney());
|
||||
bookBuyConfigEntity.setMoney(order.getRealMoney());
|
||||
bookBuyConfigEntity.setQudao("Android");
|
||||
}
|
||||
//充值送积分
|
||||
if (bookBuyConfigEntity != null && bookBuyConfigEntity.getGivejf().compareTo(BigDecimal.ZERO)>0) {
|
||||
userEntity.setJf(userEntity.getJf().add(bookBuyConfigEntity.getGivejf()));
|
||||
|
||||
@@ -295,9 +295,14 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
|
||||
buyOrderService.updateOrderStatus(order.getUserId(), order.getOrderSn(), ActString);
|
||||
}
|
||||
if ("point".equals(order.getOrderType())) {
|
||||
PayWechatOrderEntity buy_order_id = payWechatOrderService.getBaseMapper().selectOne(new QueryWrapper<PayWechatOrderEntity>().eq("order_sn", order.getOrderSn()));
|
||||
Integer buyorder = buy_order_id.getBuyOrderId();
|
||||
PayWechatOrderEntity payWechatOrder = payWechatOrderService.getBaseMapper().selectOne(new QueryWrapper<PayWechatOrderEntity>().eq("order_sn", order.getOrderSn()));
|
||||
Integer buyorder = payWechatOrder.getBuyOrderId();
|
||||
BookBuyConfigEntity bookBuyConfigEntity = bookBuyConfigService.getById(buyorder);
|
||||
if (buyorder==0){//自定义充值
|
||||
bookBuyConfigEntity.setRealMoney(payWechatOrder.getTotalAmount());
|
||||
bookBuyConfigEntity.setMoney(payWechatOrder.getTotalAmount());
|
||||
bookBuyConfigEntity.setQudao("Android");
|
||||
}
|
||||
MyUserEntity userEntity = userService.getById(order.getUserId());
|
||||
//充值送积分
|
||||
if (bookBuyConfigEntity != null && bookBuyConfigEntity.getGivejf().compareTo(BigDecimal.ZERO)>0) {
|
||||
@@ -315,9 +320,9 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
|
||||
BigDecimal realMoney = bookBuyConfigEntity.getRealMoney();
|
||||
userService.rechargeHSPoint(userEntity, realMoney.intValue());
|
||||
//插入虚拟币消费记录
|
||||
transactionDetailsService.rechargeRecord(userEntity,realMoney.toString(),buy_order_id.getId().intValue(),"微信",order.getOrderSn());
|
||||
transactionDetailsService.rechargeRecord(userEntity,realMoney.toString(),payWechatOrder.getId().intValue(),"微信",order.getOrderSn());
|
||||
//插入花生币充值记录
|
||||
payPaymentOrderService.insertDetail(userEntity,bookBuyConfigEntity,buy_order_id.getId().toString());
|
||||
payPaymentOrderService.insertDetail(userEntity,bookBuyConfigEntity,payWechatOrder.getId().toString());
|
||||
buyOrderService.updateOrderStatus(order.getUserId(), order.getOrderSn(), "2");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user