修改虚拟币记录

This commit is contained in:
wuchunlei
2024-12-05 15:53:59 +08:00
parent 0240b6fa94
commit e908760c71
12 changed files with 120 additions and 125 deletions

View File

@@ -36,7 +36,7 @@ public interface MyUserService extends IService<MyUserEntity> {
//会员开通 电话 开通 期限 //会员开通 电话 开通 期限
boolean openMember(Integer customerId,Integer openMonth); boolean openMember(Integer customerId,Integer openMonth);
//充值花生币 //充值花生币
boolean rechargeHSPoint(Integer customerId,Integer HSPoint); boolean rechargeHSPoint(MyUserEntity userEntity,Integer HSPoint);
//电子书购买 //电子书购买
String buyEbook(String userId, String bookId,String couponId); String buyEbook(String userId, String bookId,String couponId);

View File

@@ -2,6 +2,8 @@ package com.peanut.modules.book.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.common.utils.PageUtils; import com.peanut.common.utils.PageUtils;
import com.peanut.modules.common.entity.BookBuyConfigEntity;
import com.peanut.modules.common.entity.MyUserEntity;
import com.peanut.modules.common.entity.PayPaymentOrderEntity; import com.peanut.modules.common.entity.PayPaymentOrderEntity;
import java.util.Map; import java.util.Map;
@@ -16,5 +18,7 @@ import java.util.Map;
public interface PayPaymentOrderService extends IService<PayPaymentOrderEntity> { public interface PayPaymentOrderService extends IService<PayPaymentOrderEntity> {
PageUtils queryPage(Map<String, Object> params); PageUtils queryPage(Map<String, Object> params);
void insertDetail(MyUserEntity user, BookBuyConfigEntity bookBuyConfigEntity, int payXxxOrderId);
} }

View File

@@ -25,5 +25,8 @@ public interface TransactionDetailsService extends IService<TransactionDetailsEn
void recordTransaction(BuyOrder buyOrder, MyUserEntity user, BigDecimal totalPrice); void recordTransaction(BuyOrder buyOrder, MyUserEntity user, BigDecimal totalPrice);
void rechargeRecord(MyUserEntity user,String money,int payXxxOrderId,String AppName,String orderSn);
} }

View File

@@ -244,8 +244,7 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
} }
@Override @Override
public boolean rechargeHSPoint(Integer customerId,Integer HSPoint) { public boolean rechargeHSPoint(MyUserEntity user,Integer HSPoint) {
MyUserEntity user = this.getById(customerId);
if (user == null) { if (user == null) {
return false; return false;
} }

View File

@@ -1,8 +1,13 @@
package com.peanut.modules.book.service.impl; package com.peanut.modules.book.service.impl;
import com.peanut.common.utils.ExcludeEmptyQueryWrapper; import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
import com.peanut.modules.common.entity.BookBuyConfigEntity;
import com.peanut.modules.common.entity.MyUserEntity;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Map; import java.util.Map;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -31,4 +36,19 @@ public class PayPaymentOrderServiceImpl extends ServiceImpl<PayPaymentOrderDao,
return new PageUtils(page); return new PageUtils(page);
} }
@Override
public void insertDetail(MyUserEntity user, BookBuyConfigEntity bookBuyConfigEntity,int payXxxOrderId) {
PayPaymentOrderEntity payPaymentOrderEntity = new PayPaymentOrderEntity();
payPaymentOrderEntity.setUserId(user.getId());
payPaymentOrderEntity.setOrderId(payXxxOrderId+"");
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());
getBaseMapper().insert(payPaymentOrderEntity);
}
} }

View File

@@ -64,4 +64,36 @@ public class TransactionDetailsServiceImpl extends ServiceImpl<TransactionDetail
transactionDetailsEntity.setOrderType("购买商品"); transactionDetailsEntity.setOrderType("购买商品");
getBaseMapper().insert(transactionDetailsEntity); getBaseMapper().insert(transactionDetailsEntity);
} }
}
@Override
public void rechargeRecord(MyUserEntity user,String money,int payXxxOrderId,String AppName,String orderSn) {
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity();
transactionDetailsEntity.setUserId(user.getId());
transactionDetailsEntity.setChangeAmount(new BigDecimal(money));
transactionDetailsEntity.setOrderType("充值");
transactionDetailsEntity.setRelationId(payXxxOrderId);
transactionDetailsEntity.setRemark(AppName+"充值:"+orderSn);
transactionDetailsEntity.setUserBalance(user.getPeanutCoin());
transactionDetailsEntity.setUserName(user.getNickname());
transactionDetailsEntity.setTel(user.getTel());
getBaseMapper().insert(transactionDetailsEntity);
}
}

View File

@@ -14,7 +14,7 @@ public class PayPaypalOrder implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@TableId @TableId
private Long id; private Integer id;
//用户Id //用户Id
private Integer userId; private Integer userId;
//订单Id //订单Id

View File

@@ -18,6 +18,7 @@ import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults; import lombok.experimental.FieldDefaults;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -58,6 +59,7 @@ public class AppController {
* @return 验证结果 * @return 验证结果
*/ */
@RequestMapping(value = "/veri", method = RequestMethod.POST) @RequestMapping(value = "/veri", method = RequestMethod.POST)
@Transactional
public Result verifyIap(@RequestBody IapRequestDTO dto) { public Result verifyIap(@RequestBody IapRequestDTO dto) {
Lock lock = new ReentrantLock(); Lock lock = new ReentrantLock();
lock.lock(); lock.lock();
@@ -119,36 +121,16 @@ public class AppController {
String body = dto.getProductId(); String body = dto.getProductId();
// 插入花生币 变动记录 // 插入花生币 变动记录
BookBuyConfigEntity bookBuyConfigEntity = this.bookBuyConfigService.getById(Integer.valueOf(body)); BookBuyConfigEntity bookBuyConfigEntity = this.bookBuyConfigService.getById(Integer.valueOf(body));
MyUserEntity userEntity = userService.getById(Integer.valueOf(customerid));
String realMoney = bookBuyConfigEntity.getMoney(); String realMoney = bookBuyConfigEntity.getMoney();
Integer money = Integer.valueOf(realMoney); userService.rechargeHSPoint(userEntity, Integer.valueOf(realMoney));
userService.rechargeHSPoint(Integer.valueOf(customerid), money); //插入虚拟币消费记录
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity(); transactionDetailsService.rechargeRecord(userEntity,realMoney,order.getId(),"苹果",order.getOrderid());
transactionDetailsEntity.setUserId(Integer.valueOf(customerid)); //插入花生币充值记录
transactionDetailsEntity.setChangeAmount(new BigDecimal(money)); payPaymentOrderService.insertDetail(userEntity,bookBuyConfigEntity,Integer.parseInt(order.getTransactionId()));
transactionDetailsEntity.setOrderType("充值");
transactionDetailsEntity.setRelationId(order.getId());
transactionDetailsEntity.setRemark("苹果充值:"+order.getOrderid());
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"); buyOrderService.updateOrderStatus(Integer.valueOf(customerid), dto.getOrderId(), "2");
order.setMoney(Integer.valueOf(bookBuyConfigEntity.getRealMoney())); order.setMoney(Integer.valueOf(bookBuyConfigEntity.getRealMoney()));
order.setUsername(user.getName()); order.setUsername(userEntity.getName());
orderService.saveOrUpdate(order); orderService.saveOrUpdate(order);
orderService.update(); orderService.update();
return Result.ok0(); return Result.ok0();

View File

@@ -212,9 +212,9 @@ public class AliPayServiceImpl implements AliPayService {
if("point".equals(subject)){ if("point".equals(subject)){
// 插入花生币 变动记录 // 插入花生币 变动记录
BookBuyConfigEntity bookBuyConfigEntity = bookBuyConfigService.getById(Integer.valueOf(body)); BookBuyConfigEntity bookBuyConfigEntity = bookBuyConfigService.getById(Integer.valueOf(body));
MyUserEntity userEntity = userService.getById(order.getUserId());
//充值送积分 //充值送积分
if (bookBuyConfigEntity != null && !"0".equals(bookBuyConfigEntity.getGivejf())) { if (bookBuyConfigEntity != null && !"0".equals(bookBuyConfigEntity.getGivejf())) {
MyUserEntity userEntity = userService.getById(order.getUserId());
userEntity.setJf(userEntity.getJf().add(new BigDecimal(bookBuyConfigEntity.getGivejf()))); userEntity.setJf(userEntity.getJf().add(new BigDecimal(bookBuyConfigEntity.getGivejf())));
userService.updateById(userEntity); userService.updateById(userEntity);
JfTransactionDetails jfTransactionDetails = new JfTransactionDetails(); JfTransactionDetails jfTransactionDetails = new JfTransactionDetails();
@@ -227,33 +227,11 @@ public class AliPayServiceImpl implements AliPayService {
jfTransactionDetailsDao.insert(jfTransactionDetails); jfTransactionDetailsDao.insert(jfTransactionDetails);
} }
String realMoney = bookBuyConfigEntity.getRealMoney(); String realMoney = bookBuyConfigEntity.getRealMoney();
Integer money = Integer.valueOf(realMoney); userService.rechargeHSPoint(userEntity,Integer.valueOf(realMoney));
userService.rechargeHSPoint(Integer.valueOf(customerid),money); //插入虚拟币消费记录
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity(); transactionDetailsService.rechargeRecord(userEntity,realMoney,oldPayZfbOrderEntity.getId().intValue(),"支付宝",order.getOrderSn());
transactionDetailsEntity.setUserId(Integer.valueOf(customerid)); //插入花生币充值记录
transactionDetailsEntity.setChangeAmount(new BigDecimal(money)); payPaymentOrderService.insertDetail(userEntity,bookBuyConfigEntity,oldPayZfbOrderEntity.getId().intValue());
transactionDetailsEntity.setOrderType("充值");
transactionDetailsEntity.setRelationId(oldPayZfbOrderEntity.getId().intValue());
transactionDetailsEntity.setRemark("支付宝充值:"+oldPayZfbOrderEntity.getRelevanceoid());
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(String.valueOf(oldPayZfbOrderEntity.getId()));
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),oldPayZfbOrderEntity.getRelevanceoid(),"2"); buyOrderService.updateOrderStatus(Integer.valueOf(customerid),oldPayZfbOrderEntity.getRelevanceoid(),"2");
} }
if ("order".equals(subject)) { if ("order".equals(subject)) {

View File

@@ -15,6 +15,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
@@ -121,6 +123,7 @@ public class ApplePayServiceImpl implements ApplePayService {
} }
@Override @Override
@Transactional
public R getAppPay(String verifyResult, String transactionID) { public R getAppPay(String verifyResult, String transactionID) {
log.info("##########################苹果支付验证!########################"); log.info("##########################苹果支付验证!########################");
JSONObject jsonObject = JSONObject.parseObject(verifyResult); JSONObject jsonObject = JSONObject.parseObject(verifyResult);
@@ -161,41 +164,15 @@ public class ApplePayServiceImpl implements ApplePayService {
} }
if ("point".equals(order.getOrderType())) { if ("point".equals(order.getOrderType())) {
BookBuyConfigEntity bookBuyConfigEntity = bookBuyConfigService.getById(wechat.getBuyOrderId()); BookBuyConfigEntity bookBuyConfigEntity = bookBuyConfigService.getById(wechat.getBuyOrderId());
MyUserEntity userEntity = userService.getById(Integer.valueOf(order.getUserId()));
String realMoney = bookBuyConfigEntity.getRealMoney(); String realMoney = bookBuyConfigEntity.getRealMoney();
Integer money = Integer.valueOf(realMoney); userService.rechargeHSPoint(userEntity,Integer.valueOf(realMoney));
userService.rechargeHSPoint(Integer.valueOf(order.getUserId()),money); //插入虚拟币消费记录
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity(); transactionDetailsService.rechargeRecord(userEntity,realMoney,wechat.getId().intValue(),"苹果支付",order.getOrderSn());
transactionDetailsEntity.setUserId(Integer.valueOf(order.getUserId())); //插入花生币充值记录
transactionDetailsEntity.setChangeAmount(new BigDecimal(money)); payPaymentOrderService.insertDetail(userEntity,bookBuyConfigEntity,wechat.getId().intValue());
transactionDetailsEntity.setOrderType("充值");
transactionDetailsEntity.setRelationId(wechat.getId().intValue());
transactionDetailsEntity.setRemark("充值");
MyUserEntity user = userService.getById(Integer.valueOf(order.getUserId()));
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(order.getUserId()));
payPaymentOrderEntity.setOrderId(String.valueOf(wechat.getId()));
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(order.getUserId()),order.getOrderSn(),"2"); buyOrderService.updateOrderStatus(Integer.valueOf(order.getUserId()),order.getOrderSn(),"2");
// 插入花生币 变动记录
} }
} }
return R.ok(); return R.ok();

View File

@@ -4,14 +4,13 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.peanut.common.utils.R; import com.peanut.common.utils.R;
import com.peanut.modules.book.service.BuyOrderService; import com.peanut.modules.book.service.*;
import com.peanut.modules.book.service.UserEbookBuyService; import com.peanut.modules.common.entity.*;
import com.peanut.modules.common.entity.BuyOrder;
import com.peanut.modules.common.entity.PayPaypalOrder;
import com.peanut.modules.pay.paypal.config.PaypalConfig; import com.peanut.modules.pay.paypal.config.PaypalConfig;
import com.peanut.modules.pay.paypal.service.PayPaypalOrderService; import com.peanut.modules.pay.paypal.service.PayPaypalOrderService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@@ -35,6 +34,14 @@ public class PaypalController {
private PayPaypalOrderService payPaypalOrderService; private PayPaypalOrderService payPaypalOrderService;
@Autowired @Autowired
private UserEbookBuyService userEbookBuyService; private UserEbookBuyService userEbookBuyService;
@Autowired
private BookBuyConfigService bookBuyConfigService;
@Autowired
private MyUserService userService;
@Autowired
private TransactionDetailsService transactionDetailsService;
@Autowired
private PayPaymentOrderService payPaymentOrderService;
@RequestMapping("/createOrder") @RequestMapping("/createOrder")
public R createOrder(@RequestBody Map<String,Object> params){ public R createOrder(@RequestBody Map<String,Object> params){
@@ -69,6 +76,7 @@ public class PaypalController {
} }
@RequestMapping("/capture") @RequestMapping("/capture")
@Transactional
public R capture(@RequestBody Map<String,Object> params) throws Exception{ public R capture(@RequestBody Map<String,Object> params) throws Exception{
JSONObject res = paypalConfig.capture(params.get("paypalId").toString()); JSONObject res = paypalConfig.capture(params.get("paypalId").toString());
if (res.containsKey("status")&&"COMPLETED".equals(res.get("status").toString())){ if (res.containsKey("status")&&"COMPLETED".equals(res.get("status").toString())){
@@ -80,11 +88,25 @@ public class PaypalController {
JSONArray captures = JSONArray.parseArray(payments.get("captures").toString()); JSONArray captures = JSONArray.parseArray(payments.get("captures").toString());
JSONObject capture = (JSONObject)captures.get(0); JSONObject capture = (JSONObject)captures.get(0);
if ("COMPLETED".equals(capture.get("status").toString())){ if ("COMPLETED".equals(capture.get("status").toString())){
//更新PayPal订单
payPaypalOrder.setCaptureId(capture.get("id").toString()); payPaypalOrder.setCaptureId(capture.get("id").toString());
payPaypalOrder.setCaptureTime(new Date()); payPaypalOrder.setCaptureTime(new Date());
payPaypalOrderService.updateById(payPaypalOrder); payPaypalOrderService.updateById(payPaypalOrder);
BuyOrder buyOrder = buyOrderService.getById(payPaypalOrder.getOrderId()); BuyOrder buyOrder = buyOrderService.getById(payPaypalOrder.getOrderId());
userEbookBuyService.addBookForUser(buyOrder.getUserId(),Arrays.asList(buyOrder.getAbroadBookId())); if ("abroadBook".equals(buyOrder.getOrderType())){
userEbookBuyService.addBookForUser(buyOrder.getUserId(),Arrays.asList(buyOrder.getAbroadBookId()));
}
if ("point".equals(buyOrder.getOrderType())){
BookBuyConfigEntity bookBuyConfigEntity = bookBuyConfigService.getById(buyOrder.getProductId());
MyUserEntity userEntity = userService.getById(buyOrder.getUserId());
String realMoney = bookBuyConfigEntity.getRealMoney();
//更新账户余额
userService.rechargeHSPoint(userEntity,Integer.valueOf(realMoney));
//插入虚拟币消费记录
transactionDetailsService.rechargeRecord(userEntity,realMoney,payPaypalOrder.getId(),"PayPal",buyOrder.getOrderSn());
//插入花生币充值记录
payPaymentOrderService.insertDetail(userEntity,bookBuyConfigEntity,payPaypalOrder.getId());
}
return R.ok(); return R.ok();
} }
} }

View File

@@ -282,9 +282,9 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
PayWechatOrderEntity buy_order_id = payWechatOrderService.getBaseMapper().selectOne(new QueryWrapper<PayWechatOrderEntity>().eq("order_sn", order.getOrderSn())); PayWechatOrderEntity buy_order_id = payWechatOrderService.getBaseMapper().selectOne(new QueryWrapper<PayWechatOrderEntity>().eq("order_sn", order.getOrderSn()));
Integer buyorder = buy_order_id.getBuyOrderId(); Integer buyorder = buy_order_id.getBuyOrderId();
BookBuyConfigEntity bookBuyConfigEntity = bookBuyConfigService.getById(buyorder); BookBuyConfigEntity bookBuyConfigEntity = bookBuyConfigService.getById(buyorder);
MyUserEntity userEntity = userService.getById(order.getUserId());
//充值送积分 //充值送积分
if (bookBuyConfigEntity != null && !"0".equals(bookBuyConfigEntity.getGivejf())) { if (bookBuyConfigEntity != null && !"0".equals(bookBuyConfigEntity.getGivejf())) {
MyUserEntity userEntity = userService.getById(order.getUserId());
userEntity.setJf(userEntity.getJf().add(new BigDecimal(bookBuyConfigEntity.getGivejf()))); userEntity.setJf(userEntity.getJf().add(new BigDecimal(bookBuyConfigEntity.getGivejf())));
userService.updateById(userEntity); userService.updateById(userEntity);
JfTransactionDetails jfTransactionDetails = new JfTransactionDetails(); JfTransactionDetails jfTransactionDetails = new JfTransactionDetails();
@@ -297,33 +297,11 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
jfTransactionDetailsDao.insert(jfTransactionDetails); jfTransactionDetailsDao.insert(jfTransactionDetails);
} }
String realMoney = bookBuyConfigEntity.getRealMoney(); String realMoney = bookBuyConfigEntity.getRealMoney();
int money = Integer.parseInt(realMoney); userService.rechargeHSPoint(userEntity, Integer.parseInt(realMoney));
userService.rechargeHSPoint(order.getUserId(), money); //插入虚拟币消费记录
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity(); transactionDetailsService.rechargeRecord(userEntity,realMoney,buy_order_id.getId().intValue(),"微信",order.getOrderSn());
transactionDetailsEntity.setUserId(order.getUserId()); //插入花生币充值记录
transactionDetailsEntity.setChangeAmount(new BigDecimal(money)); payPaymentOrderService.insertDetail(userEntity,bookBuyConfigEntity,buy_order_id.getId().intValue());
transactionDetailsEntity.setOrderType("充值");
transactionDetailsEntity.setRelationId(buy_order_id.getId().intValue());
transactionDetailsEntity.setRemark("微信充值:"+order.getOrderSn());
MyUserEntity user = userService.getById(order.getUserId());
BigDecimal peanutCoin = user.getPeanutCoin();
transactionDetailsEntity.setUserBalance(peanutCoin);
transactionDetailsEntity.setUserName(user.getNickname());
transactionDetailsEntity.setTel(user.getTel());
transactionDetailsService.save(transactionDetailsEntity);
// 插入 花生币 充值记录
PayPaymentOrderEntity payPaymentOrderEntity = new PayPaymentOrderEntity();
payPaymentOrderEntity.setUserId(order.getUserId());
payPaymentOrderEntity.setOrderId(String.valueOf(buy_order_id.getId()));
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(order.getUserId(), order.getOrderSn(), "2"); buyOrderService.updateOrderStatus(order.getUserId(), order.getOrderSn(), "2");
} }
} }