From eb49b39db4de118a2161fd2a57b96f8f1b84eade Mon Sep 17 00:00:00 2001 From: puhanshu <a9236326> Date: 星期三, 05 一月 2022 18:11:01 +0800 Subject: [PATCH] 商家后台相关代码提交2 --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsMerchantServiceImpl.java | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsMerchantServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsMerchantServiceImpl.java index 4594b34..61acf86 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsMerchantServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsMerchantServiceImpl.java @@ -5,6 +5,7 @@ import java.util.Arrays; import java.util.Date; +import java.util.List; import javax.annotation.Resource; @@ -67,6 +68,7 @@ return R.fail("临时商家未设置点亮天数"); } mcsMerchant.setExpireAt(DateUtils.addDay(new Date(), litDays)); + mcsMerchant.setFirstLitAt(new Date()); } McsConfig publishLimitConfig = mcsConfigDAO.selectOne(new QueryWrapper<McsConfig>().lambda().eq(McsConfig::getKey, MERCHANT_PUBLISH_LIMIT_KEY)); mcsMerchant.setPublishLimit(nonNull(publishLimitConfig) ? Integer.parseInt(publishLimitConfig.getValue()) : DEFAULT_PUBLISH_LIMIT); @@ -96,6 +98,7 @@ @Transactional(rollbackFor = Exception.class) public R putMcsMerchant(McsMerchantDTO mcsMerchantDTO) { McsMerchant mcsMerchant = this.baseMapper.selectById(mcsMerchantDTO.getId()); + Long userId = mcsMerchant.getUserId(); if (isNull(mcsMerchant)) { return R.fail("商家不存在"); } @@ -109,7 +112,7 @@ int result = this.baseMapper.updateById(mcsMerchant); if (result > 0) { //修改商家绑定账户号 - mcsMerchantDTO.setUserId(mcsMerchant.getUserId()); + mcsMerchantDTO.setUserId(userId); R putResult = userService.putMcsMerchantUser(mcsMerchantDTO); if (!R.isOk(putResult)) { throw new ServiceException("406", putResult.getMsg()); @@ -132,6 +135,10 @@ Integer publishCount = mcsGameDAO.selectPublishCount(merchantVO.getId()); Integer idleTotal = publishLimit - publishCount; merchantVO.setIdleTotal(idleTotal > 0 ? idleTotal : 0); + if (nonNull(merchantVO.getExpireAt())) { + int surplusLitDays = DateUtils.differentDays(new Date(), merchantVO.getExpireAt()); + merchantVO.setSurplusLitDays(surplusLitDays > 0 ? surplusLitDays : 0); + } } return R.ok(merchantVO); } @@ -164,6 +171,16 @@ page.setSize(pageMcsMerchantDTO.getPageSize()); page.setCurrent(pageMcsMerchantDTO.getPageNum()); IPage<McsMerchantVO> mcsMerchants = this.baseMapper.pageMcsMerchant(page, pageMcsMerchantDTO); + List<McsMerchantVO> records = mcsMerchants.getRecords(); + if (nonNull(records) && !records.isEmpty()) { + Date nowDate = new Date(); + records.forEach(e -> { + if (nonNull(e.getExpireAt())) { + int surplusLitDays = DateUtils.differentDays(nowDate, e.getExpireAt()); + e.setSurplusLitDays(surplusLitDays > 0 ? surplusLitDays : 0); + } + }); + } return R.ok(mcsMerchants); } -- Gitblit v1.7.1