Forráskód Böngészése

feat: 商品进销存

Joburgess 5 éve
szülő
commit
993f631433

+ 10 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SellOrderDao.java

@@ -127,4 +127,13 @@ public interface SellOrderDao extends BaseDAO<Integer, SellOrder> {
      * @return
      */
     List<OperatingReport> getSubjectChangeMonthReport(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
-}
+
+    /**
+     * @describe 获取指定的销售记录
+     * @author Joburgess
+     * @date 2020.10.13
+     * @param sellOrderIds:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.SellOrder>
+     */
+    List<SellOrder> getSellOrders(@Param("sellOrderIds") List<Integer> sellOrderIds);
+}

+ 11 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/GoodsService.java

@@ -4,6 +4,7 @@ import com.ym.mec.biz.dal.dto.GoodsBatchNoDto;
 import com.ym.mec.biz.dal.dto.GoodsSellDto;
 import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.GoodsProcurement;
+import com.ym.mec.biz.dal.entity.SellOrder;
 import com.ym.mec.biz.dal.enums.AccountType;
 import com.ym.mec.common.service.BaseService;
 
@@ -79,6 +80,15 @@ public interface GoodsService extends BaseService<Integer, Goods> {
     void repertoryWarn();
 
     /**
+     * @describe 商品批次号分配
+     * @author Joburgess
+     * @date 2020.10.13
+     * @param goods:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.GoodsProcurement>
+     */
+    List<SellOrder> goodsBatchNoAllot(Goods goods);
+
+    /**
      * @describe 扣减商品库存
      * @author Joburgess
      * @date 2020.10.12
@@ -86,7 +96,7 @@ public interface GoodsService extends BaseService<Integer, Goods> {
      * @param accountType: 收款账户类型
      * @return java.lang.String
      */
-    List<GoodsProcurement> subtractStock(List<Integer> goodsIds, AccountType accountType);
+    List<SellOrder> subtractStock(List<Integer> goodsIds, AccountType accountType);
 
     /**
      * @describe 增加商品库存

+ 28 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java

@@ -4,17 +4,16 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
-import com.ym.mec.biz.dal.dao.GoodsDao;
-import com.ym.mec.biz.dal.dao.GoodsProcurementDao;
-import com.ym.mec.biz.dal.dao.SysConfigDao;
-import com.ym.mec.biz.dal.dao.TeacherDao;
+import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
 import com.ym.mec.biz.dal.dto.GoodsBatchNoDto;
 import com.ym.mec.biz.dal.dto.GoodsSellDto;
 import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.GoodsProcurement;
+import com.ym.mec.biz.dal.entity.SellOrder;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.service.GoodsService;
+import com.ym.mec.biz.service.SellOrderService;
 import com.ym.mec.biz.service.SysMessageService;
 import com.ym.mec.biz.service.UploadFileService;
 import com.ym.mec.common.dal.BaseDAO;
@@ -41,7 +40,6 @@ import org.springframework.web.multipart.MultipartFile;
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
@@ -63,6 +61,8 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 	private SysMessageService sysMessageService;
 	@Autowired
 	private TeacherDao teacherDao;
+	@Autowired
+	private SellOrderDao sellOrderDao;
 
 	@Override
 	public BaseDAO<Integer, Goods> getDAO() {
@@ -304,8 +304,13 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 	}
 
 	@Override
+	public List<SellOrder> goodsBatchNoAllot(Goods goods) {
+		return null;
+	}
+
+	@Override
 	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-	public List<GoodsProcurement> subtractStock(List<Integer> goodsIds, AccountType accountType) {
+	public List<SellOrder> subtractStock(List<Integer> goodsIds, AccountType accountType) {
 		if(CollectionUtils.isEmpty(goodsIds)){
 			return Collections.emptyList();
 		}
@@ -364,6 +369,23 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 	@Override
 	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
 	public void increaseStock(List<Integer> sellOrderIds, AccountType accountType) {
+		if(CollectionUtils.isEmpty(sellOrderIds)){
+			return;
+		}
+
+		List<SellOrder> sellOrders = sellOrderDao.getSellOrders(sellOrderIds);
+		Set<Integer> goodsIdList = new HashSet<>();
+		sellOrders.forEach(so -> {
+			if(Objects.nonNull(so.getParentGoodsId())){
+				goodsIdList.add(so.getParentGoodsId());
+			}else{
+				goodsIdList.add(so.getGoodsId());
+			}
+		});
+
+		List<Goods> goods = goodsDao.lockGoods(new ArrayList<>(goodsIdList));
+
+
 //		Set<Integer> goodsIds = goodsBatchNoDtos.stream().map(GoodsBatchNoDto::getGoodsId).collect(Collectors.toSet());
 //		List<Goods> goodsList = goodsDao.lockGoods(new ArrayList<>(goodsIds));
 //		Map<Integer, Goods> idGoodsMap = goodsList.stream().collect(Collectors.toMap(Goods::getId, g -> g));

+ 8 - 1
mec-biz/src/main/resources/config/mybatis/SellOrderMapper.xml

@@ -397,4 +397,11 @@
           AND sc.sell_time_ <= #{endTime}
         GROUP BY sc.organ_id_, sc.cooperation_organ_id_
         ]]></select>
-</mapper>
+
+    <select id="getSellOrders" resultMap="SellOrder">
+        SELECT * FROM sell_order WHERE id_ IN
+        <foreach collection="sellOrderIds" item="id" open="(" close=")" separator=",">
+            #{id}
+        </foreach>
+    </select>
+</mapper>