限时购管理代码

master
王皓雯 6 years ago
parent 60855bbdc4
commit 09b6e91215

@ -0,0 +1,62 @@
package com.macro.mall.service.impl;
import com.github.pagehelper.PageHelper;
import com.macro.mall.dao.SmsFlashPromotionProductRelationDao;
import com.macro.mall.dto.SmsFlashPromotionProduct;
import com.macro.mall.mapper.SmsFlashPromotionProductRelationMapper;
import com.macro.mall.model.SmsFlashPromotionProductRelation;
import com.macro.mall.model.SmsFlashPromotionProductRelationExample;
import com.macro.mall.service.SmsFlashPromotionProductRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Service
*/
@Service
public class SmsFlashPromotionProductRelationServiceImpl implements SmsFlashPromotionProductRelationService {
@Autowired
private SmsFlashPromotionProductRelationMapper relationMapper;
@Autowired
private SmsFlashPromotionProductRelationDao relationDao;
@Override
public int create(List<SmsFlashPromotionProductRelation> relationList) {
for (SmsFlashPromotionProductRelation relation : relationList) {
relationMapper.insert(relation);
}
return relationList.size();
}
@Override
public int update(Long id, SmsFlashPromotionProductRelation relation) {
relation.setId(id);
return relationMapper.updateByPrimaryKey(relation);
}
@Override
public int delete(Long id) {
return relationMapper.deleteByPrimaryKey(id);
}
@Override
public SmsFlashPromotionProductRelation getItem(Long id) {
return relationMapper.selectByPrimaryKey(id);
}
@Override
public List<SmsFlashPromotionProduct> list(Long flashPromotionId, Long flashPromotionSessionId, Integer pageSize, Integer pageNum) {
PageHelper.startPage(pageNum,pageSize);
return relationDao.getList(flashPromotionId,flashPromotionSessionId);
}
@Override
public int getCount(Long flashPromotionId, Long flashPromotionSessionId) {
SmsFlashPromotionProductRelationExample example = new SmsFlashPromotionProductRelationExample();
example.createCriteria()
.andFlashPromotionIdEqualTo(flashPromotionId)
.andFlashPromotionSessionIdEqualTo(flashPromotionSessionId);
return relationMapper.countByExample(example);
}
}

@ -0,0 +1,62 @@
package com.macro.mall.service.impl;
import com.github.pagehelper.PageHelper;
import com.macro.mall.mapper.SmsFlashPromotionMapper;
import com.macro.mall.model.SmsFlashPromotion;
import com.macro.mall.model.SmsFlashPromotionExample;
import com.macro.mall.service.SmsFlashPromotionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.List;
/**
* ÏÞʱ¹º»î¯¹ÜÀíServiceʵÏÖÀà
*/
@Service
public class SmsFlashPromotionServiceImpl implements SmsFlashPromotionService {
@Autowired
private SmsFlashPromotionMapper flashPromotionMapper;
@Override
public int create(SmsFlashPromotion flashPromotion) {
flashPromotion.setCreateTime(new Date());
return flashPromotionMapper.insert(flashPromotion);
}
@Override
public int update(Long id, SmsFlashPromotion flashPromotion) {
flashPromotion.setId(id);
return flashPromotionMapper.updateByPrimaryKey(flashPromotion);
}
@Override
public int delete(Long id) {
return flashPromotionMapper.deleteByPrimaryKey(id);
}
@Override
public int updateStatus(Long id, Integer status) {
SmsFlashPromotion flashPromotion = new SmsFlashPromotion();
flashPromotion.setId(id);
flashPromotion.setStatus(status);
return flashPromotionMapper.updateByPrimaryKeySelective(flashPromotion);
}
@Override
public SmsFlashPromotion getItem(Long id) {
return flashPromotionMapper.selectByPrimaryKey(id);
}
@Override
public List<SmsFlashPromotion> list(String keyword, Integer pageSize, Integer pageNum) {
PageHelper.startPage(pageNum, pageSize);
SmsFlashPromotionExample example = new SmsFlashPromotionExample();
if (!StringUtils.isEmpty(keyword)) {
example.createCriteria().andTitleLike("%" + keyword + "%");
}
return flashPromotionMapper.selectByExample(example);
}
}

@ -0,0 +1,78 @@
package com.macro.mall.service.impl;
import com.macro.mall.dto.SmsFlashPromotionSessionDetail;
import com.macro.mall.mapper.SmsFlashPromotionSessionMapper;
import com.macro.mall.model.SmsFlashPromotionSession;
import com.macro.mall.model.SmsFlashPromotionSessionExample;
import com.macro.mall.service.SmsFlashPromotionProductRelationService;
import com.macro.mall.service.SmsFlashPromotionSessionService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* ÏÞʱ¹º³¡´Î¹ÜÀíServiceʵÏÖÀà
*/
@Service
public class SmsFlashPromotionSessionServiceImpl implements SmsFlashPromotionSessionService {
@Autowired
private SmsFlashPromotionSessionMapper promotionSessionMapper;
@Autowired
private SmsFlashPromotionProductRelationService relationService;
@Override
public int create(SmsFlashPromotionSession promotionSession) {
promotionSession.setCreateTime(new Date());
return promotionSessionMapper.insert(promotionSession);
}
@Override
public int update(Long id, SmsFlashPromotionSession promotionSession) {
promotionSession.setId(id);
return promotionSessionMapper.updateByPrimaryKey(promotionSession);
}
@Override
public int updateStatus(Long id, Integer status) {
SmsFlashPromotionSession promotionSession = new SmsFlashPromotionSession();
promotionSession.setId(id);
promotionSession.setStatus(status);
return promotionSessionMapper.updateByPrimaryKeySelective(promotionSession);
}
@Override
public int delete(Long id) {
return promotionSessionMapper.deleteByPrimaryKey(id);
}
@Override
public SmsFlashPromotionSession getItem(Long id) {
return promotionSessionMapper.selectByPrimaryKey(id);
}
@Override
public List<SmsFlashPromotionSession> list() {
SmsFlashPromotionSessionExample example = new SmsFlashPromotionSessionExample();
return promotionSessionMapper.selectByExample(example);
}
@Override
public List<SmsFlashPromotionSessionDetail> selectList(Long flashPromotionId) {
List<SmsFlashPromotionSessionDetail> result = new ArrayList<>();
SmsFlashPromotionSessionExample example = new SmsFlashPromotionSessionExample();
example.createCriteria().andStatusEqualTo(1);
List<SmsFlashPromotionSession> list = promotionSessionMapper.selectByExample(example);
for (SmsFlashPromotionSession promotionSession : list) {
SmsFlashPromotionSessionDetail detail = new SmsFlashPromotionSessionDetail();
BeanUtils.copyProperties(promotionSession, detail);
int count = relationService.getCount(flashPromotionId, promotionSession.getId());
detail.setProductCount(count);
result.add(detail);
}
return result;
}
}
Loading…
Cancel
Save