Browse Source

[BL_2018100024]销售退货单的数量必须小于出货单数量

guq 7 years ago
parent
commit
2b17f674be

+ 1 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/exception/BizExceptionCode.java

@@ -128,6 +128,7 @@ public enum BizExceptionCode implements BaseExceptionCode {
     UNPOSTSTOCKPROFIT_EXISTS(76500, "存在当前仓库+物料未审核的盘盈盘亏单"),
     STORAGE_WAREHOUSE_SAME(76501, "调拨单拨入拨出仓库一致"),
     STORAGE_WAREHOUSE_SAMES(76502, "调拨单: %s 拨入拨出仓库一致"),
+    SALEIN_OUTOFQTY(76503, "销售退货单数量大于出货单数量"),
     STOCKPROFIT_NULL(76600, "没有需要生成的盘盈盘亏单")
     ;
     private int code;

+ 2 - 0
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/mapper/ProdInOutMapper.java

@@ -47,4 +47,6 @@ public interface ProdInOutMapper extends CommonBaseMapper<ProdInOut> {
     List<HashMap<String, Object>> getWareHouseByCode(@Param("code") String code, @Param("companyId") Long companyId);
 
     void updateCreator(@Param("userId") Long userId, @Param("userName") String userName, @Param("id") Long id);
+
+    Integer checkSaleInQty(Long pi_id);
 }

+ 6 - 1
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/ProdInOutServiceImpl.java

@@ -165,6 +165,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
                 updateDetails.add(detail);
             }
         }
+
         //插入从表
         if (insertDetails.size()>0) {
             prodIODetailMapper.batchInsert(insertDetails);
@@ -173,7 +174,11 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         if (updateDetails.size()>0) {
             prodIODetailMapper.batchUpdate(updateDetails);
         }
-
+        //销售退货单的数量必须小于出货单数量
+        Integer inQty = prodInOutMapper.checkSaleInQty(pi_id);
+        if (inQty > 0) {
+            throw new BizException(BizExceptionCode.SALEIN_OUTOFQTY);
+        }
         baseDTO = getBaseDTOById(pi_id,pi_class,pi_inoutno);
         ProdInOut prodInOutNow = checkAndReturnOrder(pi_id);
         //更新明细金额等

+ 5 - 0
applications/sale/sale-server/src/main/resources/mapper/ProdInOutMapper.xml

@@ -565,4 +565,9 @@ update ProdInOut SET
   <update id="updateCreator">
     update ProdInOut set creatorId = #{userId} , createTime=now(), creatorName=#{userName} where pi_id=#{id}
   </update>
+
+  <select id="checkSaleInQty" resultType="int" parameterType="long">
+    select count(1) from prodinout left join prodiodetail a on pi_id=pd_piid where
+    pi_class='销售退货单' and ifnull(pd_inqty,0) > (select ifnull(pd_outqty,0) from prodiodetail where pd_id=a.pd_ioid) and pi_id=#{pi_id};
+  </select>
 </mapper>