Browse Source

增加采购清单接口

周箭河 5 years ago
parent
commit
72a82c3be4

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDetailDao.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 
@@ -16,4 +17,12 @@ public interface StudentPaymentOrderDetailDao extends BaseDAO<Long, StudentPayme
      * @return
      */
     int batchAdd(@Param("studentPaymentOrderDetailList") List<StudentPaymentOrderDetail> studentPaymentOrderDetailList);
+
+    /**
+     * 查询注册支付的订单详情
+     * @param musicGroupId
+     * @param status
+     * @return
+     */
+    List<StudentPaymentOrderDetail> findApplyOrderSuccess(@Param("musicGroupId") String musicGroupId, @Param("status") DealStatusEnum status);
 }

+ 17 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderDetailService.java

@@ -1,6 +1,8 @@
 package com.ym.mec.biz.service;
 
+import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.common.service.BaseService;
 import org.apache.ibatis.annotations.Param;
 
@@ -17,4 +19,19 @@ public interface StudentPaymentOrderDetailService extends BaseService<Long, Stud
      */
     int batchAdd(List<StudentPaymentOrderDetail> studentPaymentOrderDetailList);
 
+    /**
+     * 查询注册支付的订单详情
+     * @param musicGroupId
+     * @param status
+     * @return
+     */
+    List<StudentPaymentOrderDetail> findApplyOrderSuccess(String musicGroupId, DealStatusEnum status);
+
+    /**
+     * 获取乐器的采购清单
+     * @param musicGroupId
+     * @return
+     */
+    List<Goods> getMusicalList(String musicGroupId);
+
 }

+ 36 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderDetailServiceImpl.java

@@ -1,5 +1,8 @@
 package com.ym.mec.biz.service.impl;
 
+import com.ym.mec.biz.dal.entity.Goods;
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
+import com.ym.mec.biz.service.GoodsService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -16,6 +19,8 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
 
     @Autowired
     private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
+    @Autowired
+    private GoodsService goodsService;
 
     @Override
     public BaseDAO<Long, StudentPaymentOrderDetail> getDAO() {
@@ -26,4 +31,35 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
     public int batchAdd(List<StudentPaymentOrderDetail> studentPaymentOrderDetailList) {
         return studentPaymentOrderDetailDao.batchAdd(studentPaymentOrderDetailList);
     }
+
+    @Override
+    public List<StudentPaymentOrderDetail> findApplyOrderSuccess(String musicGroupId, DealStatusEnum status) {
+        return studentPaymentOrderDetailDao.findApplyOrderSuccess(musicGroupId, status);
+    }
+
+    @Override
+    public List<Goods> getMusicalList(String musicGroupId) {
+        List<StudentPaymentOrderDetail> applyOrder = findApplyOrderSuccess(musicGroupId, DealStatusEnum.SUCCESS);
+        String goodsIdsStr = "";
+        for (StudentPaymentOrderDetail studentPaymentOrderDetail : applyOrder) {
+            if (studentPaymentOrderDetail.getGoodsIdList() != null && !studentPaymentOrderDetail.getGoodsIdList().isEmpty()) {
+                goodsIdsStr += studentPaymentOrderDetail.getGoodsIdList()+",";
+            }
+        }
+        goodsIdsStr = goodsIdsStr.substring(0, goodsIdsStr.length() - 1);
+
+        String[] goodSIdArr = goodsIdsStr.split(",");
+
+        List<Goods> goodies = goodsService.findGoodsByIds(goodsIdsStr);
+
+        for (Goods goods : goodies) {
+            goods.setSellCount(0);
+            for (String goodsIdStr : goodSIdArr) {
+                if(goods.getId().equals(Integer.parseInt(goodsIdStr))){
+                    goods.setSellCount(goods.getSellCount()+1);
+                }
+            }
+        }
+        return goodies;
+    }
 }

+ 20 - 8
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderDetailMapper.xml

@@ -18,13 +18,15 @@
 
     <!-- 根据主键查询一条记录 -->
     <select id="get" resultMap="StudentPaymentOrderDetail">
-		SELECT * FROM student_payment_order_detail WHERE id_ = #{id} 
-	</select>
+        SELECT * FROM student_payment_order_detail WHERE id_ = #{id}
+    </select>
 
     <!-- 全查询 -->
     <select id="findAll" resultMap="StudentPaymentOrderDetail">
-		SELECT * FROM student_payment_order_detail ORDER BY id_
-	</select>
+        SELECT *
+        FROM student_payment_order_detail
+        ORDER BY id_
+    </select>
 
     <!-- 向数据库增加一条记录 -->
     <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail" useGeneratedKeys="true"
@@ -64,8 +66,8 @@
 
     <!-- 根据主键删除一条记录 -->
     <delete id="delete">
-		DELETE FROM student_payment_order_detail WHERE id_ = #{id} 
-	</delete>
+        DELETE FROM student_payment_order_detail WHERE id_ = #{id}
+    </delete>
 
     <!-- 分页查询 -->
     <select id="queryPage" resultMap="StudentPaymentOrderDetail" parameterType="map">
@@ -75,8 +77,9 @@
 
     <!-- 查询当前表的总记录数 -->
     <select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM student_payment_order_detail
-	</select>
+        SELECT COUNT(*)
+        FROM student_payment_order_detail
+    </select>
 
     <insert id="batchAdd" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id_">
         INSERT INTO student_payment_order_detail
@@ -86,4 +89,13 @@
             (#{orderDetail.id},#{orderDetail.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{orderDetail.goodsIdList},#{orderDetail.price},#{orderDetail.createTime},#{orderDetail.updateTime},#{orderDetail.paymentOrderId})
         </foreach>
     </insert>
+
+    <!-- 查询注册订单详情 -->
+    <select id="findApplyOrderSuccess" resultMap="StudentPaymentOrderDetail">
+        SELECT spod.* FROM student_payment_order spo
+        LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
+        WHERE spo.music_group_id_ = #{musicGroupId}
+        AND spo.status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        AND spo.type_ = 'APPLY'
+    </select>
 </mapper>

+ 14 - 0
mec-web/src/main/java/com/ym/mec/web/controller/StudentPaymentOrderController.java

@@ -1,6 +1,9 @@
 package com.ym.mec.web.controller;
 
+import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +23,8 @@ public class StudentPaymentOrderController extends BaseController {
 
     @Autowired
     private StudentPaymentOrderService studentPaymentOrderService;
+    @Autowired
+    private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
 
     @ApiOperation(value = "获取订单列表")
     @GetMapping("/queryPage")
@@ -28,4 +33,13 @@ public class StudentPaymentOrderController extends BaseController {
         return succeed(studentPaymentOrderService.queryPage(queryInfo));
     }
 
+    @ApiOperation(value = "获取乐器采购清单")
+    @GetMapping("/getMusicalList")
+    //@PreAuthorize("@pcs.hasPermissions('order/getMusicalList')")
+    @ApiImplicitParams({@ApiImplicitParam(name = "musicGroupId", value = "乐团id", required = true, dataType = "String")})
+    public Object getMusicalList(String musicGroupId){
+        return succeed(studentPaymentOrderDetailService.getMusicalList(musicGroupId));
+    }
+
+
 }