限时购接口修改

This commit is contained in:
zhh
2018-11-19 16:10:34 +08:00
parent 313e0cded0
commit 237ec4d94f
8 changed files with 131 additions and 28 deletions

View File

@@ -1,6 +1,7 @@
package com.macro.mall.controller;
import com.macro.mall.dto.CommonResult;
import com.macro.mall.dto.SmsFlashPromotionSessionDetail;
import com.macro.mall.model.SmsFlashPromotionSession;
import com.macro.mall.service.SmsFlashPromotionSessionService;
import io.swagger.annotations.Api;
@@ -73,11 +74,19 @@ public class SmsFlashPromotionSessionController {
return new CommonResult().success(promotionSession);
}
@ApiOperation("根据状态获取全部场次")
@ApiOperation("获取全部场次")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public Object list(Integer status) {
List<SmsFlashPromotionSession> promotionSessionList = flashPromotionSessionService.list(status);
return new CommonResult().pageSuccess(promotionSessionList);
public Object list() {
List<SmsFlashPromotionSession> promotionSessionList = flashPromotionSessionService.list();
return new CommonResult().success(promotionSessionList);
}
}
@ApiOperation("获取全部可选场次及其数量")
@RequestMapping(value = "/selectList", method = RequestMethod.GET)
@ResponseBody
public Object selectList(Long flashPromotionId) {
List<SmsFlashPromotionSessionDetail> promotionSessionList = flashPromotionSessionService.selectList(flashPromotionId);
return new CommonResult().success(promotionSessionList);
}
}

View File

@@ -0,0 +1,15 @@
package com.macro.mall.dto;
import com.macro.mall.model.SmsFlashPromotionSession;
import lombok.Getter;
import lombok.Setter;
/**
* 包含商品数量的场次信息
* Created by macro on 2018/11/19.
*/
public class SmsFlashPromotionSessionDetail extends SmsFlashPromotionSession {
@Setter
@Getter
private Integer productCount;
}

View File

@@ -39,4 +39,12 @@ public interface SmsFlashPromotionProductRelationService {
* @param flashPromotionSessionId 限时购场次id
*/
List<SmsFlashPromotionProduct> list(Long flashPromotionId, Long flashPromotionSessionId, Integer pageSize, Integer pageNum);
/**
* 根据活动和场次id获取商品关系数量
* @param flashPromotionId
* @param flashPromotionSessionId
* @return
*/
int getCount(Long flashPromotionId,Long flashPromotionSessionId);
}

View File

@@ -1,5 +1,6 @@
package com.macro.mall.service;
import com.macro.mall.dto.SmsFlashPromotionSessionDetail;
import com.macro.mall.model.SmsFlashPromotionSession;
import java.util.List;
@@ -37,5 +38,10 @@ public interface SmsFlashPromotionSessionService {
/**
* 根据启用状态获取场次列表
*/
List<SmsFlashPromotionSession> list(Integer status);
List<SmsFlashPromotionSession> list();
/**
* 获取全部可选场次及其数量
*/
List<SmsFlashPromotionSessionDetail> selectList(Long flashPromotionId);
}

View File

@@ -5,6 +5,7 @@ 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;
@@ -50,4 +51,13 @@ public class SmsFlashPromotionProductRelationServiceImpl implements SmsFlashProm
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);
}
}

View File

@@ -1,12 +1,16 @@
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;
@@ -18,6 +22,8 @@ import java.util.List;
public class SmsFlashPromotionSessionServiceImpl implements SmsFlashPromotionSessionService {
@Autowired
private SmsFlashPromotionSessionMapper promotionSessionMapper;
@Autowired
private SmsFlashPromotionProductRelationService relationService;
@Override
public int create(SmsFlashPromotionSession promotionSession) {
@@ -50,11 +56,24 @@ public class SmsFlashPromotionSessionServiceImpl implements SmsFlashPromotionSes
}
@Override
public List<SmsFlashPromotionSession> list(Integer status) {
public List<SmsFlashPromotionSession> list() {
SmsFlashPromotionSessionExample example = new SmsFlashPromotionSessionExample();
if (status != null) {
example.createCriteria().andStatusEqualTo(status);
}
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;
}
}