mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 21:32:07 +08:00
1、充值活动serviceimpl单元测试完善;2、充值活动id改为自增、无用字段移除;
This commit is contained in:
-2
@@ -61,6 +61,4 @@ public class GiftMoneyDetailsDO extends BaseDO {
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
private Boolean deleted;
|
||||
}
|
||||
|
||||
+10
-25
@@ -1,8 +1,6 @@
|
||||
package com.cf.imes.module.system.service.funds.recharge;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.Assert.AssertUtils;
|
||||
import com.cf.imes.framework.common.util.date.LocalDateTimeUtils;
|
||||
@@ -12,7 +10,6 @@ import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargePage
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargeSaveReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.recharge.GiftMoneyDetailsDO;
|
||||
import com.cf.imes.module.system.dal.mysql.funds.recharge.GiftMoneyDetailsMapper;
|
||||
import com.cf.imes.module.system.framework.snowflake.config.MybatisIdProperties;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -34,26 +31,20 @@ import static com.cf.imes.module.system.enums.ErrorCodeConstants.RECHARGE_ACTIVE
|
||||
@Validated
|
||||
public class RechargeActiveServiceImpl implements RechargeActiveService{
|
||||
|
||||
@Resource
|
||||
private MybatisIdProperties mybatisIdProperties;
|
||||
|
||||
@Resource
|
||||
private GiftMoneyDetailsMapper giftMoneyDetailsMapper;
|
||||
|
||||
@Override
|
||||
public Long create(RechargeSaveReqVO createReqVO) {
|
||||
|
||||
long id = IdUtil.getSnowflake(mybatisIdProperties.getWorkerId(), mybatisIdProperties.getDatacenterId()).nextId();
|
||||
|
||||
GiftMoneyDetailsDO giftMoneyDetailsDO = giftMoneyDetailsMapper.selectOne(new LambdaQueryWrapperX<GiftMoneyDetailsDO>()
|
||||
.eq(GiftMoneyDetailsDO::getDeleted, false)
|
||||
.eq(GiftMoneyDetailsDO::getActivityName,createReqVO.getActivityName()));
|
||||
|
||||
AssertUtils.empty(giftMoneyDetailsDO,RECHARGE_ACTIVE_NAME_IS_EXIST);
|
||||
|
||||
GiftMoneyDetailsDO giftMoneyDetailsDOn = BeanUtils.toBean(createReqVO, GiftMoneyDetailsDO.class).setId(id);
|
||||
GiftMoneyDetailsDO giftMoneyDetailsDOn = BeanUtils.toBean(createReqVO, GiftMoneyDetailsDO.class);
|
||||
giftMoneyDetailsMapper.insert(giftMoneyDetailsDOn);
|
||||
return id;
|
||||
return giftMoneyDetailsDOn.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,19 +92,13 @@ public class RechargeActiveServiceImpl implements RechargeActiveService{
|
||||
|
||||
@Override
|
||||
public List<GiftMoneyDetailsDO> getAvailableRechargeActiveList() {
|
||||
RechargePageReqVO rechargePageReqVO = new RechargePageReqVO();
|
||||
// 查询全部
|
||||
rechargePageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
// 查询条件
|
||||
rechargePageReqVO.setDeleted(false);
|
||||
PageResult<GiftMoneyDetailsDO> giftMoneyDetailsDOPageResult = giftMoneyDetailsMapper.selectPage(rechargePageReqVO);
|
||||
List<GiftMoneyDetailsDO> resultList = giftMoneyDetailsDOPageResult.getList();
|
||||
if (CollUtil.isNotEmpty(resultList)) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
// 筛选掉投放时间还没到和过期的
|
||||
resultList = resultList.stream().filter(item -> item.getStartTime().isBefore(now) && item.getEndTime().isAfter(now)).toList();
|
||||
}
|
||||
return resultList;
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
// 筛选掉投放时间还没到和过期的
|
||||
return giftMoneyDetailsMapper.selectList(new LambdaQueryWrapper<GiftMoneyDetailsDO>()
|
||||
.eq(GiftMoneyDetailsDO::getDeleted, false)
|
||||
.le(GiftMoneyDetailsDO::getStartTime, now)
|
||||
.ge(GiftMoneyDetailsDO::getEndTime, now)
|
||||
);
|
||||
}
|
||||
|
||||
// 校验是否存在
|
||||
|
||||
Reference in New Issue
Block a user