Ver código fonte

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

changhaoning 1 ano atrás
pai
commit
24ec606d91

+ 4 - 0
src/main/java/com/dk/mdm/mapper/ivt/InboundMapper.xml

@@ -471,6 +471,9 @@
         ,tmo.org_name as "orgName"
         ,tms.staff_name as "staffName"
         ,tms1.staff_name as "makeStaffName"
+        ,tmc.cus_name    as "cusName"
+        ,tmc.cus_phone   as "cusPhone"
+        ,tmc.cus_from    as "cusFrom"
         ,tmp.sup_name as "supplierName"
         ,tmw.wh_name as "whName"
         ,tmd.data_value  as into_reason_name
@@ -482,6 +485,7 @@
         Left join dkic_b.t_psi_purchase tpp on tpp.pur_id = tpi.from_id
         Left join dkic_b.t_mst_org tmo on tmo.org_id = tpi.org_id
         Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpi.sup_id
+        left join dkic_b.t_mst_customer tmc on tpi.cus_id = tmc.cus_id
         Left join dkic_b.t_mst_staff tms on tms.staff_id = tpi.staff_id
         Left join dkic_b.t_mst_staff tms1 on tms1.staff_id = tpi.make_staff
         Left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpi.wh_id

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

@@ -430,9 +430,10 @@
                tmgs.sku_name            as "skuName",
                t.pack_box,
                t.price_out,
-               t.outing_qty + t.out_qty as outing_qty,
-
-               t.outing_amt + t.out_amt as outing_amt,
+               t.outing_qty,
+               t.outing_box,
+               t.outing_piece,
+               t.outing_amt,
                t.out_qty,
                t.out_amt,
                t.non_std_code,

+ 3 - 3
src/main/java/com/dk/mdm/mapper/mst/CustomerMapper.xml

@@ -323,7 +323,7 @@
         SELECT
         <include refid="Base_Column_List"/>
         FROM dkic_b.t_mst_customer
-        WHERE cus_id = #{cusId}
+        WHERE cus_id = #{id} ::uuid
         for update
     </select>
 
@@ -416,7 +416,7 @@
     <update id="updateFollowStaffs">
         update dkic_b.t_mst_customer
         set
-            follow_staffs = null
-        where cus_id = #{id}::uuid
+            follow_staffs = #{followStaffs,typeHandler=UuidListTypeHandler}
+        where cus_id = #{cusId}::uuid
     </update>
 </mapper>

+ 1 - 0
src/main/java/com/dk/mdm/mapper/report/ReportMapper.xml

@@ -29,6 +29,7 @@
         tpi.inv_qty as "invQty",
         tpi.outing_qty as "outingQty",
         tpi.usable_qty as "usableQty",
+        tpi.freeze_qty as "freezeQty",
         tpi.wh_id as "whId",
         tmw.wh_code as "whCode",
         tmw.wh_name as "whName",

+ 16 - 0
src/main/java/com/dk/mdm/service/ivt/outbound/OutCommon.java

@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -57,15 +58,29 @@ public class OutCommon {
             // 创建客户,获取编码和主键UuId
             Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.CUSTOMER.getName(), true);
             Customer customer = new Customer();
+            // 增加跟进人,用于权限分配
+            List<String> followStaffs = new ArrayList<>();
+            followStaffs.add(outboundVO.getMakeStaff());
             customer.setCusId(codeMap.get("outId").toString()).setCusCode(codeMap.get("outNote").toString()).setCusName(outboundVO.getCusName())
                     .setCusPhone(outboundVO.getCusPhone()).setAddressArea(outboundVO.getAddressArea()).setAddressName(outboundVO.getAddressName())
                     .setAddressNo(outboundVO.getAddressNo()).setAddressGcj02(outboundVO.getAddressGcj02()).setAddressFull(outboundVO.getAddressFull())
                     .setContactName(outboundVO.getContactName()).setContactPhone(outboundVO.getContactPhone()).setCusFrom(outboundVO.getCusFrom())
                     .setChannelId(outboundVO.getSalesChannel()).setOrgId(outboundVO.getOrgId()).setStaffId(outboundVO.getStaffId())
+                    .setFollowStaffs(followStaffs)
                     .setReportStaff(outboundVO.getMakeStaff()).setSaleStatus(Constant.SaleStatus.CHENGJIAO.getName()).setCpId(outboundVO.getCpId());
             customerMapper.insert(customer);
             outboundVO.setCusId(customer.getCusId());
         }else {
+            // 如果当前跟进人
+            Customer cus = customerMapper.selectByIdForUpdate(outboundVO.getCusId());
+            List<String> followStaffs = cus.getFollowStaffs();
+            if(followStaffs == null ){
+                followStaffs.add(outboundVO.getMakeStaff());
+            }else{
+                if(!followStaffs.contains(outboundVO.getMakeStaff())){
+                    followStaffs.add(outboundVO.getMakeStaff());
+                }
+            }
             //编辑客户
             Customer customer = new Customer();
             customer.setCusName(outboundVO.getCusName()).setCusId(outboundVO.getCusId())
@@ -73,6 +88,7 @@ public class OutCommon {
                     .setAddressNo(outboundVO.getAddressNo()).setAddressGcj02(outboundVO.getAddressGcj02()).setAddressFull(outboundVO.getAddressFull())
                     .setContactName(outboundVO.getContactName()).setContactPhone(outboundVO.getContactPhone()).setCusFrom(outboundVO.getCusFrom())
                     .setChannelId(outboundVO.getSalesChannel()).setOrgId(outboundVO.getOrgId()).setStaffId(outboundVO.getStaffId())
+                    .setFollowStaffs(followStaffs)
                     .setSaleStatus(Constant.SaleStatus.CHENGJIAO.getName());
             customerService.updateByUuid(customer);
         }

+ 30 - 26
src/main/java/com/dk/mdm/service/ivt/outbound/OutboundSaleOrderService.java

@@ -261,9 +261,6 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
     @Transactional(rollbackFor = {Exception.class})
     public ResponseResultVO<?> saleOrderOutboundInsert(OutboundVO outboundVO) {
         //region 如果没有客户id,要新建
-//        if (outboundVO.getCusId() == null) {
-//
-//        }
         outboundVO = outCommon.insertCustomer(outboundVO);
         //endregion
 
@@ -286,7 +283,7 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
         outboundVO.setOutId(codeMap.get("outId").toString()).
                 setOutNo(codeMap.get("outNote").toString());
         //出库类型
-        outboundVO.setOutType(Constant.OutType.SALE.getName());
+        outboundVO.setOutType(Constant.OutType.SALE.getName()).setOutDate(LocalDate.now());
         //自动入库标识
         if (outboundVO.getFlgAutoHandle()) {
             //已出库
@@ -1098,10 +1095,11 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
             //region  编辑明细
             if (outboundItemVO.getItemId() != null) {
                 outboundItemVO
-                        .setOutQty(outboundItemResponse.getOutQty().add(outboundItemVO.getOutingQty()))
-                        .setOutAmt(outboundItemResponse.getOutAmt().add(outboundItemVO.getOutingAmt()))
-                        .setOutingQty(outboundItemResponse.getOutingQty().subtract(outboundItemVO.getOutingQty()))
-                        .setOutingAmt(outboundItemResponse.getOutingAmt().subtract(outboundItemVO.getOutingAmt()))
+                        .setOutQty(outboundItemVO.getOutingQty())
+                        .setOutBox(outboundItemVO.getOutingBox()).setOutPiece(outboundItemVO.getOutingPiece())
+                        .setOutAmt(outboundItemVO.getOutAmt())
+                        .setOutingQty(BigDecimal.ZERO).setOutingBox(0).setOutingPiece(0)
+                        .setOutingAmt(BigDecimal.ZERO)
                         .setCostPrice(outboundItemVO.getPriceOut())
                         .setCostAmt(outboundItemVO.getOutQty().multiply(outboundItemVO.getPriceOut()).setScale(2, BigDecimal.ROUND_HALF_UP))
                 ;
@@ -1135,6 +1133,7 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
                 outboundItemVO
                         .setOutId(outboundItemVO.getOutId())
                         .setOutQty(outboundItemVO.getOutingQty())
+                        .setOutBox(outboundItemVO.getOutingBox()).setOutPiece(outboundItemVO.getOutingPiece())
                         .setOutAmt(outboundItemVO.getOutingAmt())
                         .setCostPrice(outboundItemVO.getPriceOut())
                         .setCostAmt(outboundItemVO.getOutQty().multiply(outboundItemVO.getPriceOut()).setScale(2, BigDecimal.ROUND_HALF_UP))
@@ -1286,29 +1285,34 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
         accountService.accReceivable(outboundResponse.getOutId(), Constant.InventoryDocCode.OUTBOUND.getTableName());
         //endregion
 
-        //region 外协品新建外协入库单
-        //筛选出skuId为空的 走外协品逻辑
-        List<OutboundItemVO> outsideGoods = outboundVO.getItemList().stream().filter(it -> it.getSkuId() == null).collect(Collectors.toList());
-        //删除外协品生产外协入库单
-        this.deleteOutsideGoodsInto(outboundVO, outsideGoods);
-        //新建外协品生产外协入库单
-        this.insertOutsideGoodsInto(outboundVO, outsideGoods);
-        List<OutboundItemVO> delOutsideGoods = outboundVO.getDeleteItemList().stream().filter(it -> it.getSkuId() == null).collect(Collectors.toList());
-        //删除外协品生产外协入库单
-        this.deleteOutsideGoodsInto(outboundVO, delOutsideGoods);
-        //endregion
+        //region 库存明细处理
+        if(outboundVO.getItemList()!=null && outboundVO.getItemList().size()>0){
+            Map<String, Object> map = new HashMap<>(); // 定义map值 修改库存用
+            // 获取外协数据
+            List<OutboundItemVO>  outsideGoods = outboundVO.getItemList().stream().filter(it -> it.getSkuId() == null).collect(Collectors.toList());
+            //新建外协品生产外协入库单
+            this.insertOutsideGoodsInto(outboundVO, outsideGoods);
+            // 获取商品明细数据
+            List<OutboundItemVO> invList = outboundVO.getItemList().stream().filter(it -> it.getSkuId() != null).collect(Collectors.toList());
 
-        //region   调用库存
-        //筛选出skuId不为空的 走库存
-        List<OutboundItemVO> invList = outboundVO.getItemList().stream().filter(it -> it.getSkuId() != null).collect(Collectors.toList());
-        List<OutboundItemVO> invDelList = outboundVO.getDeleteItemList().stream().filter(it -> it.getSkuId() != null).collect(Collectors.toList());
-        if ((invList != null && invList.size() > 0) || (invDelList != null && invDelList.size() > 0)) {
-            Map<String, Object> map = new HashMap<>();
+            // 赋值修改明细
             map.put("outDetail", invList);
-            map.put("delOutDetail", invDelList);
+            // 删除的商品
+            if(outboundVO.getDeleteItemList()!=null && outboundVO.getDeleteItemList().size()>0){
+                // 获取外协删除数据
+                List<OutboundItemVO> invsideDelList = outboundVO.getDeleteItemList().stream().filter(it -> it.getSkuId() == null).collect(Collectors.toList());
+                //删除外协品生产外协入库单
+                this.deleteOutsideGoodsInto(outboundVO, invsideDelList);
+                // 获取删除商品数据
+                List<OutboundItemVO> invDelList = outboundVO.getDeleteItemList().stream().filter(it -> it.getSkuId() == null).collect(Collectors.toList());
+                // 赋值删除明细
+                map.put("delOutDetail", invDelList);
+            }
+            // 调用修改库存信息方法
             inventoryService.operatingInventoryInformation(map);
         }
         //endregion
+
         return ResponseResultUtil.success(outboundVO);
     }
 

+ 1 - 3
src/main/java/com/dk/mdm/service/mst/CusFollowService.java

@@ -475,10 +475,8 @@ public class CusFollowService extends BaseService<CusFollow> {
         if (cusFollowVO.getSaleStatus() != null && (cusFollowVO.getSaleStatus().equals(Constant.saleCustomerStatusConstant.SALE_STATUS_INTE.getName()) || cusFollowVO.getSaleStatus().equals(Constant.saleCustomerStatusConstant.SALE_STATUS_LOST.getName()))) {
             //公海客户清空跟进人
             if (cusFollowVO.getSaleStatus().equals(Constant.saleCustomerStatusConstant.SALE_STATUS_INTE.getName())) {
-                customerMapper.updateFollowStaffs(new Customer().setCusId(cusFollowVO.getCusId()));
+                customerMapper.updateFollowStaffs(new Customer().setCusId(cusFollowVO.getCusId()).setFollowStaffs(null));
             }
-
-
         }
         if (cusFollowVO.getCusId() != null) {
             Customer customer = new Customer();

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

@@ -216,14 +216,37 @@ public class OrderService extends BaseService<Order> {
             // 创建客户,获取编码和主键UuId
             Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.CUSTOMER.getName(), true);
             Customer customer = new Customer();
+            // 增加跟进人,用于权限分配
+            List<String> followStaffs = new ArrayList<>();
+            followStaffs.add(orderVO.getMakeStaff());
             customer.setCusId(codeMap.get("outId").toString()).setCusCode(codeMap.get("outNote").toString()).setCusName(orderVO.getCusName())
                     .setCusPhone(orderVO.getCusPhone()).setAddressArea(orderVO.getAddressArea()).setAddressName(orderVO.getAddressName())
                     .setAddressNo(orderVO.getAddressNo()).setAddressGcj02(orderVO.getAddressGcj02()).setAddressFull(orderVO.getAddressFull())
                     .setContactName(orderVO.getContactName()).setContactPhone(orderVO.getContactPhone()).setCusFrom(orderVO.getCusFrom())
                     .setChannelId(orderVO.getSalesChannel()).setOrgId(orderVO.getOrgId()).setStaffId(orderVO.getStaffId())
+                    .setFollowStaffs(followStaffs)
                     .setReportStaff(orderVO.getMakeStaff()).setSaleStatus(Constant.SaleStatus.CHENGJIAO.getName()).setCpId(orderVO.getCpId());
             customerMapper.insert(customer);
             orderVO.setCusId(customer.getCusId());
+        }else{
+            // 如果当前跟进人
+            Customer cus = customerMapper.selectByIdForUpdate(orderVO.getCusId());
+            List<String> followStaffs = cus.getFollowStaffs();
+            Boolean updateFollowFlag = false;
+            if(followStaffs == null ){
+                followStaffs.add(orderVO.getMakeStaff());
+                updateFollowFlag = true;
+            }else{
+                if(!followStaffs.contains(orderVO.getMakeStaff())){
+                    followStaffs.add(orderVO.getMakeStaff());
+                    updateFollowFlag = true;
+                }
+            }
+            if(updateFollowFlag){
+                // 更新当前跟进人
+                customerMapper.updateFollowStaffs(new Customer().setCusId(orderVO.getCusId())
+                                                    .setFollowStaffs(followStaffs));
+            }
         }
 
         // 获取单号