充值送积分

This commit is contained in:
wuchunlei
2024-11-08 16:51:29 +08:00
parent d16264103b
commit 0810035f58
6 changed files with 51 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
package com.peanut.modules.book.controller;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -97,7 +98,11 @@ public class BookBuyConfigController {
*/
@RequestMapping("/getVipOrPoint")
public R getVipOrPoint(@RequestParam("type") String type,@RequestParam("qudao") String qudao){
List<BookBuyConfigEntity> bookBuyConfigEntities = bookBuyConfigService.getBaseMapper().selectList(new QueryWrapper<BookBuyConfigEntity>().eq("type",type).eq("qudao",qudao));
List<BookBuyConfigEntity> bookBuyConfigEntities = bookBuyConfigService.getBaseMapper()
.selectList(new QueryWrapper<BookBuyConfigEntity>()
.and(t->t.eq("effective",0).or(q->q.le("start_time",new Date()).ge("end_time",new Date())))
.eq("type",type)
.eq("qudao",qudao));
return R.ok().put("list",bookBuyConfigEntities);
}

View File

@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -32,6 +33,8 @@ public class BookBuyConfigController {
@RequestMapping("/getBookBuyConfigList")
public R getBookBuyConfigList(@RequestBody Map params){
LambdaQueryWrapper<BookBuyConfigEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.and(t->t.eq(BookBuyConfigEntity::getEffective,0)
.or(q->q.le(BookBuyConfigEntity::getStartTime,new Date()).ge(BookBuyConfigEntity::getEndTime,new Date())));
if (params.containsKey("type")&&StringUtils.isNotEmpty(params.get("type").toString())){
wrapper.eq(BookBuyConfigEntity::getType,params.get("type"));
}

View File

@@ -40,6 +40,10 @@ public class BookBuyConfigEntity implements Serializable {
* 金额
*/
private String money;
/**
* 赠送积分
*/
private String givejf;
/**
* vip开通月份
*/
@@ -48,5 +52,11 @@ public class BookBuyConfigEntity implements Serializable {
* 充值名称
*/
private String description;
/**
* 生效类型 0长期有效 1有时间限制
*/
private int effective;
private Date startTime;
private Date endTime;
}

View File

@@ -11,6 +11,8 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.Map;
/**
@@ -29,6 +31,8 @@ public class BuyConfigController {
@RequestMapping("/getBookBuyConfigList")
public R getBookBuyConfigList(@RequestBody Map<String, Object> params) {
LambdaQueryWrapper<BookBuyConfigEntity> wrapper = new LambdaQueryWrapper();
wrapper.and(t->t.eq(BookBuyConfigEntity::getEffective,0)
.or(q->q.le(BookBuyConfigEntity::getStartTime,new Date()).ge(BookBuyConfigEntity::getEndTime,new Date())));
if (StringUtils.isNotEmpty(params.get("qudao").toString())) {
wrapper.eq(BookBuyConfigEntity::getQudao,params.get("qudao"));
}

View File

@@ -197,6 +197,20 @@ public class AliPayServiceImpl implements AliPayService {
if("point".equals(subject)){
// 插入花生币 变动记录
BookBuyConfigEntity bookBuyConfigEntity = bookBuyConfigService.getById(Integer.valueOf(body));
//充值送积分
if (bookBuyConfigEntity != null && !"0".equals(bookBuyConfigEntity.getGivejf())) {
MyUserEntity userEntity = userService.getById(order.getUserId());
userEntity.setJf(userEntity.getJf().add(new BigDecimal(bookBuyConfigEntity.getGivejf())));
userService.updateById(userEntity);
JfTransactionDetails jfTransactionDetails = new JfTransactionDetails();
jfTransactionDetails.setUserId(userEntity.getId());
jfTransactionDetails.setChangeAmount(new BigDecimal(bookBuyConfigEntity.getGivejf()));
jfTransactionDetails.setActType(0);
jfTransactionDetails.setUserBalance(userEntity.getJf());
jfTransactionDetails.setRelationId(order.getOrderId());
jfTransactionDetails.setRemark("充币送积分:"+bookBuyConfigEntity.getDescription()+",订单号:"+order.getOrderSn());
jfTransactionDetailsDao.insert(jfTransactionDetails);
}
String realMoney = bookBuyConfigEntity.getRealMoney();
Integer money = Integer.valueOf(realMoney);
userService.rechargeHSPoint(Integer.valueOf(customerid),money);

View File

@@ -267,6 +267,20 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
PayWechatOrderEntity buy_order_id = payWechatOrderService.getBaseMapper().selectOne(new QueryWrapper<PayWechatOrderEntity>().eq("order_sn", order.getOrderSn()));
Integer buyorder = buy_order_id.getBuyOrderId();
BookBuyConfigEntity bookBuyConfigEntity = bookBuyConfigService.getById(buyorder);
//充值送积分
if (bookBuyConfigEntity != null && !"0".equals(bookBuyConfigEntity.getGivejf())) {
MyUserEntity userEntity = userService.getById(order.getUserId());
userEntity.setJf(userEntity.getJf().add(new BigDecimal(bookBuyConfigEntity.getGivejf())));
userService.updateById(userEntity);
JfTransactionDetails jfTransactionDetails = new JfTransactionDetails();
jfTransactionDetails.setUserId(userEntity.getId());
jfTransactionDetails.setChangeAmount(new BigDecimal(bookBuyConfigEntity.getGivejf()));
jfTransactionDetails.setActType(0);
jfTransactionDetails.setUserBalance(userEntity.getJf());
jfTransactionDetails.setRelationId(order.getOrderId());
jfTransactionDetails.setRemark("充币送积分:"+bookBuyConfigEntity.getDescription()+",订单号:"+order.getOrderSn());
jfTransactionDetailsDao.insert(jfTransactionDetails);
}
String realMoney = bookBuyConfigEntity.getRealMoney();
int money = Integer.parseInt(realMoney);
userService.rechargeHSPoint(order.getUserId(), money);