diff --git a/src/main/java/com/peanut/modules/book/controller/BookBuyConfigController.java b/src/main/java/com/peanut/modules/book/controller/BookBuyConfigController.java index a3583343..78fa4efb 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookBuyConfigController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookBuyConfigController.java @@ -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 bookBuyConfigEntities = bookBuyConfigService.getBaseMapper().selectList(new QueryWrapper().eq("type",type).eq("qudao",qudao)); + List bookBuyConfigEntities = bookBuyConfigService.getBaseMapper() + .selectList(new QueryWrapper() + .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); } diff --git a/src/main/java/com/peanut/modules/common/controller/BookBuyConfigController.java b/src/main/java/com/peanut/modules/common/controller/BookBuyConfigController.java index 6ae0feae..606121bf 100644 --- a/src/main/java/com/peanut/modules/common/controller/BookBuyConfigController.java +++ b/src/main/java/com/peanut/modules/common/controller/BookBuyConfigController.java @@ -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 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")); } diff --git a/src/main/java/com/peanut/modules/common/entity/BookBuyConfigEntity.java b/src/main/java/com/peanut/modules/common/entity/BookBuyConfigEntity.java index 60a3bff4..ab2fbd98 100644 --- a/src/main/java/com/peanut/modules/common/entity/BookBuyConfigEntity.java +++ b/src/main/java/com/peanut/modules/common/entity/BookBuyConfigEntity.java @@ -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; } diff --git a/src/main/java/com/peanut/modules/master/controller/BuyConfigController.java b/src/main/java/com/peanut/modules/master/controller/BuyConfigController.java index 88289fba..545bb2c6 100644 --- a/src/main/java/com/peanut/modules/master/controller/BuyConfigController.java +++ b/src/main/java/com/peanut/modules/master/controller/BuyConfigController.java @@ -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 params) { LambdaQueryWrapper 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")); } diff --git a/src/main/java/com/peanut/modules/pay/alipay/service/impl/AliPayServiceImpl.java b/src/main/java/com/peanut/modules/pay/alipay/service/impl/AliPayServiceImpl.java index 82c4401b..e76086cf 100644 --- a/src/main/java/com/peanut/modules/pay/alipay/service/impl/AliPayServiceImpl.java +++ b/src/main/java/com/peanut/modules/pay/alipay/service/impl/AliPayServiceImpl.java @@ -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); diff --git a/src/main/java/com/peanut/modules/pay/weChatPay/service/impl/WxpayServiceImpl.java b/src/main/java/com/peanut/modules/pay/weChatPay/service/impl/WxpayServiceImpl.java index 1a8fb997..13c022d8 100644 --- a/src/main/java/com/peanut/modules/pay/weChatPay/service/impl/WxpayServiceImpl.java +++ b/src/main/java/com/peanut/modules/pay/weChatPay/service/impl/WxpayServiceImpl.java @@ -267,6 +267,20 @@ public class WxpayServiceImpl extends ServiceImpl().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);