|
@@ -1,11 +1,17 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.ym.mec.biz.dal.dao.GoodsDao;
|
|
|
import com.ym.mec.biz.dal.dao.StudentGoodsSellDao;
|
|
|
+import com.ym.mec.biz.dal.dao.StudentInstrumentDao;
|
|
|
import com.ym.mec.biz.dal.dao.SysConfigDao;
|
|
|
+import com.ym.mec.biz.dal.dto.GoodsSellDto;
|
|
|
import com.ym.mec.biz.dal.dto.StudentGoodsSellDto;
|
|
|
import com.ym.mec.biz.dal.dto.StudentPaymentOrderDto;
|
|
|
+import com.ym.mec.biz.dal.entity.Goods;
|
|
|
import com.ym.mec.biz.dal.entity.StudentGoodsSell;
|
|
|
+import com.ym.mec.biz.dal.entity.StudentInstrument;
|
|
|
import com.ym.mec.biz.dal.page.GoodsSellQueryInfo;
|
|
|
import com.ym.mec.biz.service.StudentGoodsSellService;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
@@ -25,78 +31,113 @@ import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
public class StudentGoodsSellServiceImpl extends BaseServiceImpl<Integer, StudentGoodsSell> implements StudentGoodsSellService {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private StudentGoodsSellDao studentGoodsSellDao;
|
|
|
- @Autowired
|
|
|
- private SysConfigDao sysConfigDao;
|
|
|
|
|
|
- @Override
|
|
|
- public BaseDAO<Integer, StudentGoodsSell> getDAO() {
|
|
|
- return studentGoodsSellDao;
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ private StudentGoodsSellDao studentGoodsSellDao;
|
|
|
+ @Autowired
|
|
|
+ private SysConfigDao sysConfigDao;
|
|
|
+ @Autowired
|
|
|
+ private GoodsDao goodsDao;
|
|
|
+ @Autowired
|
|
|
+ private StudentInstrumentDao studentInstrumentDao;
|
|
|
|
|
|
- @Override
|
|
|
- public PageInfo<StudentGoodsSellDto> queryStudentGoodsOrders(GoodsSellQueryInfo queryInfo) {
|
|
|
- //根据订单状态和教务老师获取订单列表
|
|
|
- PageInfo<StudentGoodsSellDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- MapUtil.populateMap(params, queryInfo);
|
|
|
- List<StudentGoodsSellDto> dataList = null;
|
|
|
- int count = studentGoodsSellDao.countStudentGoodsOrders(params);
|
|
|
- if (count > 0) {
|
|
|
- pageInfo.setTotal(count);
|
|
|
- params.put("offset", pageInfo.getOffset());
|
|
|
- dataList = studentGoodsSellDao.queryStudentGoodsOrders(params);
|
|
|
- Integer autoAffirmReceiveTime = Integer.parseInt(sysConfigDao.findConfigValue("auto_affirm_receive_time"));
|
|
|
- dataList.forEach(e->{
|
|
|
- e.setAutoAffirmReceiveTime(autoAffirmReceiveTime);
|
|
|
- });
|
|
|
- }
|
|
|
- if (count == 0) {
|
|
|
- dataList = new ArrayList<>();
|
|
|
- }
|
|
|
- pageInfo.setRows(dataList);
|
|
|
- return pageInfo;
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public BaseDAO<Integer, StudentGoodsSell> getDAO() {
|
|
|
+ return studentGoodsSellDao;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public void affirmReceive(String orderNo) {
|
|
|
- String str = "MANUAL_RECEIVE";
|
|
|
- //如果订单编号为空,那么自动确认
|
|
|
- if(StringUtils.isEmpty(orderNo)){
|
|
|
- String autoAffirmReceiveTime = sysConfigDao.findConfigValue("auto_affirm_receive_time");
|
|
|
- //获取到期的订单编号
|
|
|
- orderNo = studentGoodsSellDao.queryNoAffirmOrderNo(autoAffirmReceiveTime);
|
|
|
- str = "AUTO_RECEIVE";
|
|
|
- }
|
|
|
- if(StringUtils.isNotEmpty(orderNo)){
|
|
|
- studentGoodsSellDao.autoAffirmReceive(orderNo,str);
|
|
|
- }
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public PageInfo<StudentGoodsSellDto> queryStudentGoodsOrders(GoodsSellQueryInfo queryInfo) {
|
|
|
+ //根据订单状态和教务老师获取订单列表
|
|
|
+ PageInfo<StudentGoodsSellDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
+ List<StudentGoodsSellDto> dataList = null;
|
|
|
+ int count = studentGoodsSellDao.countStudentGoodsOrders(params);
|
|
|
+ if (count > 0) {
|
|
|
+ pageInfo.setTotal(count);
|
|
|
+ params.put("offset", pageInfo.getOffset());
|
|
|
+ dataList = studentGoodsSellDao.queryStudentGoodsOrders(params);
|
|
|
+ Integer autoAffirmReceiveTime = Integer.parseInt(sysConfigDao.findConfigValue("auto_affirm_receive_time"));
|
|
|
+ dataList.forEach(e -> {
|
|
|
+ e.setAutoAffirmReceiveTime(autoAffirmReceiveTime);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (count == 0) {
|
|
|
+ dataList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ pageInfo.setRows(dataList);
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void affirmReceive(String orderNo) {
|
|
|
+ String str = "MANUAL_RECEIVE";
|
|
|
+ //如果订单编号为空,那么自动确认
|
|
|
+ if (StringUtils.isEmpty(orderNo)) {
|
|
|
+ String autoAffirmReceiveTime = sysConfigDao.findConfigValue("auto_affirm_receive_time");
|
|
|
+ //获取到期的订单编号
|
|
|
+ orderNo = studentGoodsSellDao.queryNoAffirmOrderNo(autoAffirmReceiveTime);
|
|
|
+ str = "AUTO_RECEIVE";
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(orderNo)) {
|
|
|
+ studentGoodsSellDao.autoAffirmReceive(orderNo, str);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo<StudentPaymentOrderDto> queryStudentPaymentOrders(GoodsSellQueryInfo queryInfo) {
|
|
|
+ PageInfo<StudentPaymentOrderDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
+ List<StudentPaymentOrderDto> dataList = null;
|
|
|
+ int count = studentGoodsSellDao.countStudentPaymentOrders(params);
|
|
|
+ if (count > 0) {
|
|
|
+ pageInfo.setTotal(count);
|
|
|
+ params.put("offset", pageInfo.getOffset());
|
|
|
+ dataList = studentGoodsSellDao.queryStudentPaymentOrders(params);
|
|
|
+ Integer autoAffirmReceiveTime = Integer.parseInt(sysConfigDao.findConfigValue("auto_affirm_receive_time"));
|
|
|
+ dataList.forEach(e -> {
|
|
|
+ e.setAutoAffirmReceiveTime(autoAffirmReceiveTime);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (count == 0) {
|
|
|
+ dataList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ pageInfo.setRows(dataList);
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<StudentInstrument> saveStudentInstrument(String orderNo) {
|
|
|
+ StudentGoodsSell studentGoodsSell = studentGoodsSellDao.findByOrderNo(orderNo);
|
|
|
+ List<GoodsSellDto> goodsSellDtos = JSONObject.parseArray(studentGoodsSell.getGoodsJson(), GoodsSellDto.class);
|
|
|
+ List<Integer> goodsIds = new ArrayList<>();
|
|
|
+ for (GoodsSellDto goodsSellDto : goodsSellDtos) {
|
|
|
+ if (!goodsSellDto.getGoodsType().equals("INSTRUMENT")) continue;
|
|
|
+ goodsIds.add(goodsSellDto.getGoodsId());
|
|
|
+ }
|
|
|
+ if (goodsIds.size() <= 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<Goods> goodies = goodsDao.getGoodies(goodsIds);
|
|
|
+ List<StudentInstrument> studentInstruments = new ArrayList<>();
|
|
|
+ for (Goods goods : goodies) {
|
|
|
+ StudentInstrument studentInstrument = new StudentInstrument();
|
|
|
+ studentInstrument.setStudentId(studentGoodsSell.getUserId());
|
|
|
+ studentInstrument.setOrganId(studentGoodsSell.getOrganId());
|
|
|
+ studentInstrument.setGoodsId(goods.getId());
|
|
|
+ studentInstrument.setGoodsName(goods.getName());
|
|
|
+ studentInstrument.setGoodsBrand(goods.getBrand());
|
|
|
+ studentInstrument.setSpecification(goods.getSpecification());
|
|
|
+ studentInstrument.setGoodsImg(goods.getImage());
|
|
|
+ studentInstrument.setStatus(0);
|
|
|
+ studentInstruments.add(studentInstrument);
|
|
|
+ }
|
|
|
+ studentInstrumentDao.batchAdd(studentInstruments);
|
|
|
+ return studentInstruments;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public PageInfo<StudentPaymentOrderDto> queryStudentPaymentOrders(GoodsSellQueryInfo queryInfo) {
|
|
|
- PageInfo<StudentPaymentOrderDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- MapUtil.populateMap(params, queryInfo);
|
|
|
- List<StudentPaymentOrderDto> dataList = null;
|
|
|
- int count = studentGoodsSellDao.countStudentPaymentOrders(params);
|
|
|
- if (count > 0) {
|
|
|
- pageInfo.setTotal(count);
|
|
|
- params.put("offset", pageInfo.getOffset());
|
|
|
- dataList = studentGoodsSellDao.queryStudentPaymentOrders(params);
|
|
|
- Integer autoAffirmReceiveTime = Integer.parseInt(sysConfigDao.findConfigValue("auto_affirm_receive_time"));
|
|
|
- dataList.forEach(e->{
|
|
|
- e.setAutoAffirmReceiveTime(autoAffirmReceiveTime);
|
|
|
- });
|
|
|
- }
|
|
|
- if (count == 0) {
|
|
|
- dataList = new ArrayList<>();
|
|
|
- }
|
|
|
- pageInfo.setRows(dataList);
|
|
|
- return pageInfo;
|
|
|
- }
|
|
|
|
|
|
}
|