Procházet zdrojové kódy

Merge branch 'master' of http://git.dongkesoft.com:9001/iBOSS-2.0-Mini/iboss-server-mdm

姜永辉 před 1 rokem
rodič
revize
bdb00ae4be

+ 121 - 21
src/main/java/com/dk/mdm/mapper/ivt/InboundItemMapper.xml

@@ -742,36 +742,54 @@
         tpii.sku_model AS "skuModel",
         tpii.sku_model AS "skuModel",
         tpii.sku_name AS "skuName",
         tpii.sku_name AS "skuName",
         tpii.sku_id AS "skuId",
         tpii.sku_id AS "skuId",
-        tpii.cost_price  AS "costPrice",
-        tpii.cost_amt  AS "costAmt",
+        tpii.cost_price AS "costPrice",
+        tpii.cost_amt AS "costAmt",
         tmgs.brand_id AS "brandId",
         tmgs.brand_id AS "brandId",
         tmgs.sku_images AS "skuImages",
         tmgs.sku_images AS "skuImages",
-        tmgb.brand_name  as "brandName",
-        tmgb.short_name  as "shortName",
-        json_agg(json_build_object(
-        'itemId', tpii.item_id,
-        'intoId', tpii.into_id,
-        'invId', tpii.inv_id,
-        'fromId', tpii.from_id,
-        'fromItemId', tpii.from_item_id,
-        'skuModel', tpii.sku_model,
-        'skuName', tpii.sku_name,
-        'skuId', tpii.sku_id,
-        'intoQty', tpii.into_qty,
-        'costPrice', tpii.cost_price,
-        'costAmt', tpii.cost_amt,
-        'brandId', tmgs.brand_id,
-        'fromItemId', tpii.from_item_id
-        )) AS "itemList"
+        tmgb.brand_name AS "brandName",
+        tmgb.short_name AS "shortName",
+        json_agg (
+        json_build_object (
+        'itemId',
+        tpii.item_id,
+        'intoId',
+        tpii.into_id,
+        'outId',
+        NULL,
+        'invId',
+        tpii.inv_id,
+        'fromId',
+        tpii.from_id,
+        'fromItemId',
+        tpii.from_item_id,
+        'skuModel',
+        tpii.sku_model,
+        'skuName',
+        tpii.sku_name,
+        'skuId',
+        tpii.sku_id,
+        'intoQty',
+        tpii.into_qty,
+        'costPrice',
+        tpii.cost_price,
+        'costAmt',
+        tpii.cost_amt,
+        'brandId',
+        tmgs.brand_id,
+        'fromItemId',
+        tpii.from_item_id
+        )
+        ) AS "itemList"
         FROM
         FROM
         dkic_b.t_psi_inbound_item tpii
         dkic_b.t_psi_inbound_item tpii
         LEFT JOIN dkic_b.t_psi_inbound tpi ON tpi.into_id = tpii.into_id
         LEFT JOIN dkic_b.t_psi_inbound tpi ON tpi.into_id = tpii.into_id
         LEFT JOIN dkic_b.t_mst_goods_sku tmgs ON tmgs.sku_id = tpii.sku_id
         LEFT JOIN dkic_b.t_mst_goods_sku tmgs ON tmgs.sku_id = tpii.sku_id
-        left join dkic_b.t_mst_goods_brand tmgb on tmgb.brand_id = tmgs.brand_id
+        LEFT JOIN dkic_b.t_mst_goods_brand tmgb ON tmgb.brand_id = tmgs.brand_id
         <where>
         <where>
             tpii.cost_price = 0
             tpii.cost_price = 0
             AND tpii.into_qty != 0
             AND tpii.into_qty != 0
-            AND tpii.sku_model is not null
+            AND tpii.sku_model IS NOT NULL
+            AND tpii.into_type != '入库类型-采退入库'
             <if test="intoId != null and intoId != ''">
             <if test="intoId != null and intoId != ''">
                 AND tpii.into_id = #{intoId}::uuid
                 AND tpii.into_id = #{intoId}::uuid
             </if>
             </if>
@@ -813,6 +831,88 @@
         tmgs.sku_images,
         tmgs.sku_images,
         tmgb.brand_name,
         tmgb.brand_name,
         tmgb.short_name
         tmgb.short_name
+
+        UNION ALL
+        SELECT
+        tpoi.sku_model AS "skuModel",
+        tpoi.sku_name AS "skuName",
+        tpoi.sku_id AS "skuId",
+        tpoi.cost_price AS "costPrice",
+        tpoi.cost_amt AS "costAmt",
+        tmgs.brand_id AS "brandId",
+        tmgs.sku_images AS "skuImages",
+        tmgb.brand_name AS "brandName",
+        tmgb.short_name AS "shortName",
+        json_agg (
+        json_build_object (
+        'itemId',
+        tpoi.item_id,
+        'intoId',
+        NULL,
+        'outId',
+        tpoi.out_id,
+        'invId',
+        tpoi.inv_id,
+        'fromId',
+        tpoi.from_id,
+        'fromItemId',
+        tpoi.from_item_id,
+        'skuModel',
+        tpoi.sku_model,
+        'skuName',
+        tpoi.sku_name,
+        'skuId',
+        tpoi.sku_id,
+        'intoQty',
+        tpoi.out_qty,
+        'costPrice',
+        tpoi.cost_price,
+        'costAmt',
+        tpoi.cost_amt,
+        'brandId',
+        tmgs.brand_id,
+        'fromItemId',
+        tpoi.from_item_id
+        )
+        ) AS "itemList"
+        FROM
+        dkic_b.t_psi_outbound_item tpoi
+        LEFT JOIN dkic_b.t_psi_outbound tpo ON tpo.out_id = tpoi.out_id
+        LEFT JOIN dkic_b.t_mst_goods_sku tmgs ON tmgs.sku_id = tpoi.sku_id
+        LEFT JOIN dkic_b.t_mst_goods_brand tmgb ON tmgb.brand_id = tmgs.brand_id
+
+        <where>
+            tpoi.cost_price = 0
+            AND tpoi.out_qty != 0
+            AND tpoi.sku_model IS NOT NULL
+            <if test="outId != null and outId != ''">
+                AND tpoi.out_id = #{outId}::uuid
+            </if>
+            <if test="cpId != null">
+                AND tpoi.cp_id = #{cpId}
+            </if>
+            <if test="intoDateStart != null">
+                AND tpo.out_date &gt;= #{intoDateStart}::timestamp with time zone
+            </if>
+            <if test="intoDateEnd != null">
+                AND tpo.out_date &lt; #{intoDateEnd}::timestamp with time zone + interval '1 day'
+            </if>
+            <if test="searchText !=null">
+                AND  (tpii.sku_model LIKE concat('%',my_ex.likequery(#{searchText}), '%')
+                OR   tpii.sku_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
+                )
+            </if>
+        </where>
+        GROUP BY
+        tpoi.sku_model,
+        tpoi.sku_name,
+        tpoi.sku_id,
+        tpoi.cost_price,
+        tpoi.cost_amt,
+        tmgs.brand_id,
+        tmgs.sku_images,
+        tmgb.brand_name,
+        tmgb.short_name
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
             limit #{end} offset #{start}
         </if>
         </if>

+ 1 - 1
src/main/java/com/dk/mdm/mapper/ivt/OutboundItemCostMapper.xml

@@ -182,7 +182,7 @@
     <!-- 修改最后一条出库成本(入库成本核对)-->
     <!-- 修改最后一条出库成本(入库成本核对)-->
     <update id="updateLastCost" parameterType="com.dk.mdm.model.pojo.ivt.OutboundItemCost">
     <update id="updateLastCost" parameterType="com.dk.mdm.model.pojo.ivt.OutboundItemCost">
         update dkic_b.t_psi_outbound_item_cost
         update dkic_b.t_psi_outbound_item_cost
-        set cost_amt += #{costAmt,jdbcType=NUMERIC}
+        set cost_amt = cost_amt + #{costAmt,jdbcType=NUMERIC}
         where batch_id = #{batchId,typeHandler=UuidTypeHandler}
         where batch_id = #{batchId,typeHandler=UuidTypeHandler}
     </update>
     </update>
 
 

+ 1 - 1
src/main/java/com/dk/mdm/mapper/ivt/OutboundItemMapper.xml

@@ -824,7 +824,7 @@ sys.f_remove_zero(out_qty) as out_qty, out_amt, sys.f_remove_zero(return_qty) as
     <!-- 修改最后一条出库成本(入库成本核对)-->
     <!-- 修改最后一条出库成本(入库成本核对)-->
     <update id="updateLastCost" parameterType="com.dk.mdm.model.pojo.ivt.OutboundItem">
     <update id="updateLastCost" parameterType="com.dk.mdm.model.pojo.ivt.OutboundItem">
         update dkic_b.t_psi_outbound_item
         update dkic_b.t_psi_outbound_item
-        set cost_amt += #{costAmt,jdbcType=NUMERIC}
+        set cost_amt = cost_amt + #{costAmt,jdbcType=NUMERIC}
         where item_id = #{itemId,typeHandler=UuidTypeHandler}
         where item_id = #{itemId,typeHandler=UuidTypeHandler}
     </update>
     </update>
 
 

+ 2 - 0
src/main/java/com/dk/mdm/model/query/ivt/InboundItemQuery.java

@@ -172,6 +172,8 @@ public class InboundItemQuery extends PageInfo<InboundItemQuery>  {
     @TableField(typeHandler = UuidTypeHandler.class)
     @TableField(typeHandler = UuidTypeHandler.class)
     private String invId;
     private String invId;
 
 
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String outId;
 
 
     /**
     /**
      * 成本单价
      * 成本单价

+ 1 - 1
src/main/java/com/dk/mdm/service/ivt/inbound/InboundCheckService.java

@@ -122,7 +122,7 @@ public class InboundCheckService extends BaseService<Inbound> {
         //region  查询当前入库明细中是否存在未空或者0的入库价,如果存在去库存流水差最近一条有价格的数据赋值到当前明细
         //region  查询当前入库明细中是否存在未空或者0的入库价,如果存在去库存流水差最近一条有价格的数据赋值到当前明细
         Boolean priceIntoFlag = false;
         Boolean priceIntoFlag = false;
         for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
         for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
-            if(inboundItemVO.getPriceInto()==null || inboundItemVO.getPriceInto().compareTo(BigDecimal.ZERO)==0){
+            if(inboundItemVO.getCostPrice()==null || inboundItemVO.getCostPrice().compareTo(BigDecimal.ZERO)==0){
                 priceIntoFlag = true;
                 priceIntoFlag = true;
                 //查询库存批次最近一条入库价
                 //查询库存批次最近一条入库价
                 InboundItemResponse inboundItemResponse = this.selectPriceInto(inboundItemVO);
                 InboundItemResponse inboundItemResponse = this.selectPriceInto(inboundItemVO);

+ 24 - 6
src/main/java/com/dk/mdm/service/ivt/inbound/InboundItemService.java

@@ -124,11 +124,21 @@ public class InboundItemService extends BaseService<InboundItem> {
 	public ResponseResultVO<?> CostCheckOk(List<InboundItemQuery> inboundItemQuery) {
 	public ResponseResultVO<?> CostCheckOk(List<InboundItemQuery> inboundItemQuery) {
 		for(InboundItemQuery inboundItem : inboundItemQuery){
 		for(InboundItemQuery inboundItem : inboundItemQuery){
 			//修改入库明细表
 			//修改入库明细表
-			InboundItem inboundItem1 = new InboundItem()
-					.setItemId(inboundItem.getItemId())
-					.setCostPrice(inboundItem.getCostPrice())
-					.setCostAmt(inboundItem.getCostAmt());
-			inboundItemMapper.updateCost(inboundItem1);
+			if(inboundItem.getOutId() != null){
+				//修改出库明细表
+				OutboundItemQuery outboundItemQuery = new OutboundItemQuery()
+						.setItemId(inboundItem.getItemId())
+						.setCostPrice(inboundItem.getCostPrice())
+						.setCostAmt(inboundItem.getCostAmt());
+				outboundItemMapper.updateOutCost(outboundItemQuery);
+			}else{
+				InboundItem inboundItem1 = new InboundItem()
+						.setItemId(inboundItem.getItemId())
+						.setCostPrice(inboundItem.getCostPrice())
+						.setCostAmt(inboundItem.getCostAmt());
+				inboundItemMapper.updateCost(inboundItem1);
+			}
+
 			//修改销售订单
 			//修改销售订单
 			if(inboundItem.getFromItemId() != null){
 			if(inboundItem.getFromItemId() != null){
 				OrderItem orderItem = new OrderItem()
 				OrderItem orderItem = new OrderItem()
@@ -192,7 +202,15 @@ public class InboundItemService extends BaseService<InboundItem> {
 					}
 					}
 					//出库成本 金额之和 加上 存货批次明细成本金额(存货资产) = 核对金额
 					//出库成本 金额之和 加上 存货批次明细成本金额(存货资产) = 核对金额
 					//如果出库成本核对有差额 就更最后一条数据
 					//如果出库成本核对有差额 就更最后一条数据
-					BigDecimal batchCostAmt = inboundItem.getCostPrice().multiply(inventoryBatchResponse.getInvQty());//存货资产
+					BigDecimal batchCostAmt = BigDecimal.ZERO;
+					if(inboundItem.getOutId() != null){
+						//有出库退货
+						BigDecimal batchCostAmt1 = inboundItem.getCostPrice().multiply(inventoryBatchResponse.getInvQty());//存货资产
+						batchCostAmt = batchCostAmt1.multiply(new BigDecimal(-1));
+					}else{
+						 batchCostAmt = inboundItem.getCostPrice().multiply(inventoryBatchResponse.getInvQty());//存货资产
+					}
+
 					//修改的成本金额总和(存货资产 + 出库成本 金额)
 					//修改的成本金额总和(存货资产 + 出库成本 金额)
 					BigDecimal costAmtTotal = batchCostAmt.add(outCostAmtTotal);
 					BigDecimal costAmtTotal = batchCostAmt.add(outCostAmtTotal);
 					if(costAmtTotal.compareTo(inboundItem.getCostAmt())!= 0){
 					if(costAmtTotal.compareTo(inboundItem.getCostAmt())!= 0){

+ 1 - 1
src/main/java/com/dk/mdm/service/ivt/inbound/InboundOtherService.java

@@ -144,7 +144,7 @@ public class InboundOtherService extends BaseService<Inbound> {
         //region  查询当前入库明细中是否存在未空或者0的入库价,如果存在去库存流水差最近一条有价格的数据赋值到当前明细
         //region  查询当前入库明细中是否存在未空或者0的入库价,如果存在去库存流水差最近一条有价格的数据赋值到当前明细
         Boolean priceIntoFlag = false;
         Boolean priceIntoFlag = false;
         for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
         for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
-            if(inboundItemVO.getPriceInto()==null || inboundItemVO.getPriceInto().compareTo(BigDecimal.ZERO)==0){
+            if(inboundItemVO.getCostPrice()==null || inboundItemVO.getCostPrice().compareTo(BigDecimal.ZERO)==0){
                 priceIntoFlag = true;
                 priceIntoFlag = true;
                 //查询库存批次最近一条入库价
                 //查询库存批次最近一条入库价
                 InboundItemResponse inboundItemResponse = this.selectPriceInto(inboundItemVO);
                 InboundItemResponse inboundItemResponse = this.selectPriceInto(inboundItemVO);

+ 1 - 1
src/main/java/com/dk/mdm/service/ivt/inbound/InboundPurchaseService.java

@@ -153,7 +153,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
         //region  查询当前入库明细中是否存在未空或者0的入库价,如果存在去库存流水差最近一条有价格的数据赋值到当前明细
         //region  查询当前入库明细中是否存在未空或者0的入库价,如果存在去库存流水差最近一条有价格的数据赋值到当前明细
         Boolean priceIntoFlag = false;
         Boolean priceIntoFlag = false;
         for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
         for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
-            if(inboundItemVO.getPriceInto() == null || inboundItemVO.getPriceInto().compareTo(BigDecimal.ZERO)==0){
+            if(inboundItemVO.getCostPrice() == null || inboundItemVO.getCostPrice().compareTo(BigDecimal.ZERO)==0){
                 priceIntoFlag = true;
                 priceIntoFlag = true;
                 //查询库存批次最近一条入库价
                 //查询库存批次最近一条入库价
                 InboundItemResponse inboundItemResponse = this.selectPriceInto(inboundItemVO);
                 InboundItemResponse inboundItemResponse = this.selectPriceInto(inboundItemVO);

+ 2 - 2
src/main/java/com/dk/mdm/service/ivt/outbound/OutboundSaleReturnService.java

@@ -386,7 +386,8 @@ public class OutboundSaleReturnService extends BaseService<Outbound> {
         //region  查询当前入库明细中是否存在未空或者0的入库价,如果存在去库存流水差最近一条有价格的数据赋值到当前明细
         //region  查询当前入库明细中是否存在未空或者0的入库价,如果存在去库存流水差最近一条有价格的数据赋值到当前明细
         Boolean priceIntoFlag = false;
         Boolean priceIntoFlag = false;
         for (OutboundItemVO outboundItemVO : outboundVO.getItemList()) {
         for (OutboundItemVO outboundItemVO : outboundVO.getItemList()) {
-            if (outboundItemVO.getPriceOut() == null || outboundItemVO.getPriceOut().compareTo(BigDecimal.ZERO) == 0) {
+            //todo 2024-7-5 11:44:12 z确认修改为cost
+            if (outboundItemVO.getCostPrice() == null || outboundItemVO.getCostPrice().compareTo(BigDecimal.ZERO) == 0) {
                 priceIntoFlag = true;
                 priceIntoFlag = true;
                 //查询库存批次最近一条入库价
                 //查询库存批次最近一条入库价
                 InboundItemResponse inboundItemResponse = this.selectPriceInto(outboundItemVO);
                 InboundItemResponse inboundItemResponse = this.selectPriceInto(outboundItemVO);
@@ -873,7 +874,6 @@ public class OutboundSaleReturnService extends BaseService<Outbound> {
             );
             );
             //endregion
             //endregion
 
 
-
             //region  修改库存
             //region  修改库存
             Map<String, Object> map = new HashMap<>();
             Map<String, Object> map = new HashMap<>();
             map.put("delOutDetail", outboundItemResponseList);
             map.put("delOutDetail", outboundItemResponseList);

+ 7 - 0
src/main/java/com/dk/mdm/service/sale/OrderService.java

@@ -1101,6 +1101,13 @@ public class OrderService extends BaseService<Order> {
      * @author : 寇珊珊
      * @author : 寇珊珊
      */
      */
     public ResponseResultVO<?> oneKeyInvalid(String id) {
     public ResponseResultVO<?> oneKeyInvalid(String id) {
+        //region  查询当前订单下是否存在有效的退货单
+        List<OutboundItemResponse> outboundItemResponseList = outboundItemMapper.selectByCond(new OutboundItemQuery().setFromId(id).setFlgValid(true));
+        if (outboundItemResponseList != null && outboundItemResponseList.size() > 0) {
+            throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ORDER_IS_EXISTS_RETURN_ORDERS.getMessage());
+        }
+        //endregion
+
         Order orderForUpdate = orderMapper.selectByIdForUpdate(id);
         Order orderForUpdate = orderMapper.selectByIdForUpdate(id);
         //region并发校验
         //region并发校验
         if (!orderForUpdate.getFlgValid()) {
         if (!orderForUpdate.getFlgValid()) {