| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import static java.util.Objects.isNull; |
| | | import static java.util.Objects.nonNull; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.panzhihua.service_community.dao.McsConfigDAO; |
| | | import com.panzhihua.service_community.dao.McsGameDAO; |
| | | import com.panzhihua.service_community.entity.McsConfig; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | @Service("mcsMerchantService") |
| | | public class McsMerchantServiceImpl extends ServiceImpl<McsMerchantDAO, McsMerchant> implements McsMerchantService { |
| | | |
| | | private static final String MERCHANT_PUBLISH_LIMIT_KEY = "MERCHANT_PUBLISH_LIMIT"; |
| | | private static final int DEFAULT_PUBLISH_LIMIT = 2; |
| | | |
| | | @Resource |
| | | private UserService userService; |
| | | @Resource |
| | | private McsConfigDAO mcsConfigDAO; |
| | | @Resource |
| | | private McsGameDAO mcsGameDAO; |
| | | |
| | | /** |
| | | * 新增数字商业街商家 |
| | |
| | | } |
| | | mcsMerchant.setExpireAt(DateUtils.addDay(new Date(), litDays)); |
| | | } |
| | | 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); |
| | | mcsMerchant.setUserId(0L); |
| | | int insertResult = this.baseMapper.insert(mcsMerchant); |
| | | if (insertResult > 0) { |
| | |
| | | } |
| | | if (mcsMerchantDTO.getLevel().equals(1)) { |
| | | Integer litDays = mcsMerchantDTO.getLitDays(); |
| | | if (isNull(litDays)) { |
| | | return R.fail("临时商家未设置点亮天数"); |
| | | if (nonNull(litDays)) { |
| | | mcsMerchant.setExpireAt(DateUtils.addDay(new Date(), litDays)); |
| | | } |
| | | mcsMerchant.setExpireAt(DateUtils.addDay(new Date(), litDays)); |
| | | } |
| | | BeanUtils.copyProperties(mcsMerchantDTO, mcsMerchant); |
| | | int result = this.baseMapper.updateById(mcsMerchant); |
| | |
| | | */ |
| | | @Override |
| | | public R getMcsMerchant(Long merchantId) { |
| | | return R.ok(this.baseMapper.getMcsMerchantById(merchantId)); |
| | | McsMerchantVO merchantVO = this.baseMapper.getMcsMerchantById(merchantId); |
| | | if (nonNull(merchantVO)) { |
| | | Integer publishLimit = merchantVO.getPublishLimit(); |
| | | Integer publishCount = mcsGameDAO.selectPublishCount(merchantVO.getId()); |
| | | Integer idleTotal = publishLimit - publishCount; |
| | | merchantVO.setIdleTotal(idleTotal > 0 ? idleTotal : 0); |
| | | } |
| | | return R.ok(merchantVO); |
| | | } |
| | | |
| | | /** |