소스 검색

update 乐器销售修改

周箭河 4 년 전
부모
커밋
f053a85323

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentInstrumentDao.java

@@ -2,7 +2,11 @@ package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.entity.StudentInstrument;
 import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface StudentInstrumentDao extends BaseDAO<Long, StudentInstrument> {
 
+    int batchAdd(@Param("studentInstruments") List<StudentInstrument> studentInstruments);
 }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentGoodsSellService.java

@@ -4,10 +4,13 @@ package com.ym.mec.biz.service;
 import com.ym.mec.biz.dal.dto.StudentGoodsSellDto;
 import com.ym.mec.biz.dal.dto.StudentPaymentOrderDto;
 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.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 
+import java.util.List;
+
 public interface StudentGoodsSellService extends BaseService<Integer, StudentGoodsSell> {
 
     /**
@@ -42,4 +45,12 @@ public interface StudentGoodsSellService extends BaseService<Integer, StudentGoo
      * @return com.ym.mec.common.page.PageInfo<com.ym.mec.biz.dal.dto.StudentGoodsSellDto>
      */
     PageInfo<StudentPaymentOrderDto> queryStudentPaymentOrders(GoodsSellQueryInfo queryInfo);
+
+
+    /**
+     * 将购买的乐器加入学生乐器列表
+     * @return
+     */
+    List<StudentInstrument> saveStudentInstrument(String orderNo);
+
 }

+ 110 - 69
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentGoodsSellServiceImpl.java

@@ -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;
-	}
 
 }

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java

@@ -73,6 +73,8 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
     private GoodsService goodsService;
     @Autowired
     private StudentInstrumentService studentInstrumentService;
+    @Autowired
+    private StudentGoodsSellService studentGoodsSellService;
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
@@ -720,6 +722,9 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
             paymentDetail.setType(PlatformCashAccountDetailTypeEnum.GOODS_SELL);
             paymentDetail.setUserId(userId);
             sysUserCashAccountDetailService.insert(paymentDetail);
+            //将购买的乐器加入学生乐器列表
+            studentGoodsSellService.saveStudentInstrument(studentPaymentOrder.getOrderNo());
+            //购买的商品加入销售列表
             saveSellOrder(studentPaymentOrder.getOrderNo());
         } else if (studentPaymentOrder.getStatus() == DealStatusEnum.CLOSE || studentPaymentOrder.getStatus() == DealStatusEnum.FAILED) {
             if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {

+ 9 - 0
mec-biz/src/main/resources/config/mybatis/StudentInstrumentMapper.xml

@@ -132,4 +132,13 @@
     </where>
   </sql>
 
+  <insert id="batchAdd" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+    insert into student_instrument (student_id_,organ_id_,goods_id_,goods_name_,goods_brand_,specification_,goods_img_, status_, start_time_, end_time_, create_time_, update_time)
+    VALUE
+    <foreach collection="studentInstruments" item="item" separator=",">
+      (#{item.studentId},#{item.organId},#{item.goodsId},#{item.goodsName},#{item.goodsBrand},#{item.specification},#{item.goodsImg}, #{item.status}, #{item.startTime},
+      #{item.endTime}, NOW(), NOW())
+    </foreach>
+  </insert>
+
 </mapper>