| | |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | |
| | | 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); |
| | |
| | | @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("商家不存在"); |
| | | } |
| | |
| | | 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()); |
| | |
| | | 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); |
| | | } |
| | |
| | | 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); |
| | | } |
| | | |