Browse Source

update 月保修改成乐保

周箭河 4 years ago
parent
commit
134fb90676

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/GoodsDao.java

@@ -148,8 +148,16 @@ public interface GoodsDao extends BaseDAO<Integer, Goods> {
 
     /**
      * 获取
+     *
      * @param id
      * @return
      */
     Goods getGoodsInfo(@Param("id") Integer id);
+
+    /**
+     * 根据id获取商品和分类
+     * @param goodsIds
+     * @return
+     */
+    List<Goods> getGoodiesAndCate(@Param("goodsIds") List<Integer> goodsIds);
 }

+ 3 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentGoodsSellServiceImpl.java

@@ -121,13 +121,15 @@ public class StudentGoodsSellServiceImpl extends BaseServiceImpl<Integer, Studen
         if (goodsIds.size() <= 0) {
             return null;
         }
-        List<Goods> goodies = goodsDao.getGoodies(goodsIds);
+        List<Goods> goodies = goodsDao.getGoodiesAndCate(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.setGoodsCategoryId(goods.getGoodsCategoryId());
+            studentInstrument.setGoodsCategoryName(goods.getGoodsCategoryName());
             studentInstrument.setGoodsName(goods.getName());
             studentInstrument.setGoodsBrand(goods.getBrand());
             studentInstrument.setSpecification(goods.getSpecification());

+ 11 - 2
mec-biz/src/main/resources/config/mybatis/GoodsMapper.xml

@@ -270,7 +270,7 @@
 
     <!-- 根据主键删除一条记录 -->
     <delete id="delete">
-		DELETE FROM goods WHERE id_ = #{id} 
+		DELETE FROM goods WHERE id_ = #{id}
 	</delete>
 
     <!-- 分页查询 -->
@@ -415,8 +415,17 @@
     </select>
 
     <select id="getGoodsInfo" resultMap="Goods">
-        SELECT g.*,gc.name_ FROM goods g
+        SELECT g.*,gc.name_ goods_category_name_ FROM goods g
         LEFT JOIN goods_category gc on g.goods_category_id_ = gc.id_
         WHERE g.id_=#{id}
     </select>
+
+    <select id="getGoodiesAndCate" resultMap="Goods">
+        SELECT g.*,gc.name_ goods_category_name_ FROM goods g
+        LEFT JOIN goods_category gc on g.goods_category_id_ = gc.id_
+        WHERE g.id_ IN
+        <foreach collection="goodsIds" item="goodsId" open="(" close=")" separator=",">
+            #{goodsId}
+        </foreach>
+    </select>
 </mapper>

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

@@ -133,10 +133,10 @@
   </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)
+    insert into student_instrument (student_id_,organ_id_,goods_id_,goods_category_id_,goods_category_name_,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.studentId},#{item.organId},#{item.goodsId},#{item.goodsCategoryId},#{item.goodsCategoryName},#{item.goodsName},#{item.goodsBrand},#{item.specification},#{item.goodsImg}, #{item.status}, #{item.startTime},
       #{item.endTime}, NOW(), NOW())
     </foreach>
   </insert>