From 09b6e91215421654cb0ea78875f2c9e1a43e8a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=9A=93=E9=9B=AF?= <18868469283@qq.com> Date: Sun, 13 Jan 2019 15:05:17 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=90=E6=97=B6=E8=B4=AD=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...shPromotionProductRelationServiceImpl.java | 62 +++++++++++++++ .../impl/SmsFlashPromotionServiceImpl.java | 62 +++++++++++++++ .../SmsFlashPromotionSessionServiceImpl.java | 78 +++++++++++++++++++ 3 files changed, 202 insertions(+) create mode 100644 代码库/mall-admin/src/main/java/com/sock/mall/service/impl/SmsFlashPromotionProductRelationServiceImpl.java create mode 100644 代码库/mall-admin/src/main/java/com/sock/mall/service/impl/SmsFlashPromotionServiceImpl.java create mode 100644 代码库/mall-admin/src/main/java/com/sock/mall/service/impl/SmsFlashPromotionSessionServiceImpl.java diff --git a/代码库/mall-admin/src/main/java/com/sock/mall/service/impl/SmsFlashPromotionProductRelationServiceImpl.java b/代码库/mall-admin/src/main/java/com/sock/mall/service/impl/SmsFlashPromotionProductRelationServiceImpl.java new file mode 100644 index 0000000..3ff5e50 --- /dev/null +++ b/代码库/mall-admin/src/main/java/com/sock/mall/service/impl/SmsFlashPromotionProductRelationServiceImpl.java @@ -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 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 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); + } +} \ No newline at end of file diff --git a/代码库/mall-admin/src/main/java/com/sock/mall/service/impl/SmsFlashPromotionServiceImpl.java b/代码库/mall-admin/src/main/java/com/sock/mall/service/impl/SmsFlashPromotionServiceImpl.java new file mode 100644 index 0000000..6519fd3 --- /dev/null +++ b/代码库/mall-admin/src/main/java/com/sock/mall/service/impl/SmsFlashPromotionServiceImpl.java @@ -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 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); + } +} diff --git a/代码库/mall-admin/src/main/java/com/sock/mall/service/impl/SmsFlashPromotionSessionServiceImpl.java b/代码库/mall-admin/src/main/java/com/sock/mall/service/impl/SmsFlashPromotionSessionServiceImpl.java new file mode 100644 index 0000000..2d682ef --- /dev/null +++ b/代码库/mall-admin/src/main/java/com/sock/mall/service/impl/SmsFlashPromotionSessionServiceImpl.java @@ -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 list() { + SmsFlashPromotionSessionExample example = new SmsFlashPromotionSessionExample(); + return promotionSessionMapper.selectByExample(example); + } + + @Override + public List selectList(Long flashPromotionId) { + List result = new ArrayList<>(); + SmsFlashPromotionSessionExample example = new SmsFlashPromotionSessionExample(); + example.createCriteria().andStatusEqualTo(1); + List 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; + } +} \ No newline at end of file