于继渤 1 год назад
Родитель
Сommit
54cf13c032

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

@@ -102,7 +102,10 @@
 
         <result column="outboundQuantity" property="outboundQuantity"/>
         <result column="outboundAmount" property="outboundAmount"/>
-
+        <result column="outboundNotAmount" property="outboundNotAmount"/>
+        <result column="outboundNotQuantity" property="outboundNotQuantity"/>
+        <result column="outboundReturnQuantity" property="outboundReturnQuantity"/>
+        <result column="outboundReturnAmount" property="outboundReturnAmount"/>
     </resultMap>
 
     <!-- 通用条件列 -->
@@ -257,31 +260,61 @@
     <select id="selectByIdRespone" resultMap="BaseResultMapResponse">
         SELECT
         <include refid="Base_Column_List_Response"/>,
-        tmd.data_value  AS  "cusFromName",
-        tmsc.channel_name  AS  "channelName",
-        tmo.org_name  AS  "orgName",
-        tms.staff_name  AS  "staffName",
-        tms2.staff_name  AS  "reportStaffName",
-        tdk.kind_name_i18n  ->>  #{i18n} AS "saleStatusName",
---         tccfs.follow_staff  as follow_staff,
---         tms1.staff_name  as follow_staff_name
-        (SELECT COUNT(1) FROM  dkic_b.t_psi_order tpo  WHERE tpo.cus_id = tmc.cus_id AND  tpo.cp_id = tmc.cp_id AND tpo.flg_valid) AS "orderQuantity",
-        (SELECT sum(tpo.sum_amount) FROM  dkic_b.t_psi_order tpo  WHERE tpo.cus_id = tmc.cus_id AND  tpo.cp_id = tmc.cp_id AND tpo.flg_valid) AS "orderAmount",
+        tmd.data_value AS "cusFromName",
+        tmsc.channel_name AS "channelName",
+        tmo.org_name AS "orgName",
+        tms.staff_name AS "staffName",
+        tms2.staff_name AS "reportStaffName",
+        tdk.kind_name_i18n ->> #{i18n} AS "saleStatusName",
+        -- tccfs.follow_staff as follow_staff,
+        -- tms1.staff_name as follow_staff_name
+        (SELECT COUNT(1) FROM dkic_b.t_psi_order tpo WHERE tpo.cus_id = tmc.cus_id AND tpo.cp_id = tmc.cp_id AND
+        tpo.flg_valid) AS "orderQuantity",
+        (SELECT sum(tpo.sum_amount) FROM dkic_b.t_psi_order tpo WHERE tpo.cus_id = tmc.cus_id AND tpo.cp_id = tmc.cp_id
+        AND tpo.flg_valid) AS "orderAmount",
 
 
-        (SELECT COUNT(1) FROM  dkic_b.t_psi_outbound tpob  WHERE tpob.cus_id = tmc.cus_id AND  tpob.cp_id = tmc.cp_id AND tpob.flg_valid AND tpob.out_type = '出库类型-销售出库' AND tpob.out_status = '出库状态-已出库') AS "outboundQuantity",
-        (SELECT sum(tpob.out_amt) FROM  dkic_b.t_psi_outbound tpob  WHERE tpob.cus_id = tmc.cus_id AND  tpob.cp_id = tmc.cp_id AND tpob.flg_valid AND tpob.out_type = '出库类型-销售出库' AND tpob.out_status = '出库状态-已出库') AS "outboundAmount"
-        FROM dkic_b.t_mst_customer tmc
-        LEFT JOIN  dkic_b.t_mst_dictionary_data tmd  on tmd.data_id =  tmc.cus_from
-        LEFT JOIN  dkic_b.t_mst_sale_channel tmsc  on tmsc.channel_id =  tmc.channel_id
-        LEFT JOIN  dkic_b.t_mst_org tmo  on tmo.org_id =  tmc.org_id
-        LEFT JOIN  dkic_b.t_mst_staff tms  on tms.staff_id =  tmc.staff_id
-        LEFT JOIN  dkic_b.t_mst_staff tms2  on tms2.staff_id =  tmc.report_staff
-        LEFT JOIN  sys.t_data_kind tdk  on tdk.kind_code =  tmc.sale_status
+        (SELECT COUNT(1) FROM dkic_b.t_psi_outbound tpob WHERE tpob.cus_id = tmc.cus_id AND tpob.cp_id = tmc.cp_id AND
+        tpob.flg_valid AND tpob.out_type = '出库类型-销售出库' AND tpob.out_status = '出库状态-已出库') AS
+        "outboundQuantity",
+        (SELECT sum(tpob.out_amt) FROM dkic_b.t_psi_outbound tpob WHERE tpob.cus_id = tmc.cus_id AND tpob.cp_id =
+        tmc.cp_id AND tpob.flg_valid AND tpob.out_type = '出库类型-销售出库' AND tpob.out_status = '出库状态-已出库') AS
+        "outboundAmount",
 
 
---         LEFT JOIN  dkic_b.t_crm_cus_follow_staff  tccfs on tccfs.follow_staff = any(tmc.follow_staffs)
---         LEFT JOIN  dkic_b.t_mst_staff tms1  on tms1.staff_id =  tccfs.follow_staff
+        (SELECT COUNT(1) FROM dkic_b.t_psi_order tpo WHERE tpo.cus_id = tmc.cus_id AND tpo.cp_id =
+        tmc.cp_id AND tpo.flg_valid AND tpo.out_status = '出库状态-待出库' AND tpo.order_status = '订单状态-成交') AS
+        "outboundNotQuantity",
+
+        (SELECT sum(tpo.sum_amount) FROM dkic_b.t_psi_order tpo WHERE tpo.cus_id = tmc.cus_id AND tpo.cp_id =
+        tmc.cp_id AND tpo.flg_valid AND tpo.out_status = '出库状态-待出库' AND tpo.order_status = '订单状态-成交') AS
+        "outboundNotAmount",
+
+
+        (SELECT  COUNT(1) FROM dkic_b.t_psi_outbound tpob WHERE tpob.cus_id = tmc.cus_id AND tpob.cp_id =
+        tmc.cp_id AND tpob.flg_valid AND tpob.out_type = '出库类型-销退回库') AS
+        "outboundReturnQuantity",
+
+        (SELECT sum(tpob.out_amt) FROM dkic_b.t_psi_outbound tpob WHERE tpob.cus_id = tmc.cus_id AND tpob.cp_id =
+        tmc.cp_id AND tpob.flg_valid AND tpob.out_type = '出库类型-销退回库') AS
+        "outboundReturnAmount",
+
+        tma.receivable_residue,
+        tma.receipt_residue
+
+
+
+        FROM dkic_b.t_mst_customer tmc
+        LEFT JOIN dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tmc.cus_from
+        LEFT JOIN dkic_b.t_mst_sale_channel tmsc on tmsc.channel_id = tmc.channel_id
+        LEFT JOIN dkic_b.t_mst_org tmo on tmo.org_id = tmc.org_id
+        LEFT JOIN dkic_b.t_mst_staff tms on tms.staff_id = tmc.staff_id
+        LEFT JOIN dkic_b.t_mst_staff tms2 on tms2.staff_id = tmc.report_staff
+        LEFT JOIN sys.t_data_kind tdk on tdk.kind_code = tmc.sale_status
+        LEFT JOIN  dkic_b.t_mac_account tma  on tma.object_id =  tmc.cus_id
+
+        -- LEFT JOIN dkic_b.t_crm_cus_follow_staff tccfs on tccfs.follow_staff = any(tmc.follow_staffs)
+        -- LEFT JOIN dkic_b.t_mst_staff tms1 on tms1.staff_id = tccfs.follow_staff
         WHERE tmc.cus_id = #{id}::uuid
     </select>
 

+ 16 - 1
src/main/java/com/dk/mdm/model/response/mst/CustomerResponse.java

@@ -312,15 +312,30 @@ public class CustomerResponse extends PageInfo<CustomerResponse> implements Seri
     @ApiModelProperty(value = "总收款金额-总应收收款金额+总应收优惠金额(现金池)")
     private BigDecimal receiptResidue;
 
-
+    @ApiModelProperty(value = "订单数量")
     private BigDecimal orderQuantity;
 
+    @ApiModelProperty(value = "订单金额")
     private BigDecimal orderAmount;
 
+    @ApiModelProperty(value = "出库数量")
     private BigDecimal outboundQuantity;
 
+    @ApiModelProperty(value = "出库金额")
     private BigDecimal outboundAmount;
 
+    @ApiModelProperty(value = "未出库金额")
+    private BigDecimal outboundNotAmount;
+
+    @ApiModelProperty(value = "未出库数量")
+    private BigDecimal outboundNotQuantity;
+
+    @ApiModelProperty(value = "退货数量")
+    private BigDecimal outboundReturnQuantity;
+
+    @ApiModelProperty(value = "退货金额")
+    private BigDecimal outboundReturnAmount;
+
 
 
 

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

@@ -215,10 +215,10 @@ public class CusFollowService extends BaseService<CusFollow> {
             List<CustomerResponse> cusList = customerMapper.selectByCond(
                     new CustomerQuery().setCpId(customer.getCpId()).setCusPhone(customer.getCusPhone()).setFlgValid(true)
             );
-            if (cusList != null && cusList.size() > 0 && cusList.stream().anyMatch(a -> !a.getCusId().equals(customer.getCusId()))) {
-                throw new BaseBusinessException(ErrorCodeEnum.CUSTOMER_SAME_COMPANY_TELEPHONE.getCode(),
-                        ErrorCodeEnum.CUSTOMER_SAME_COMPANY_TELEPHONE.getMessage());
-            }
+//            if (cusList != null && cusList.size() > 0 && cusList.stream().anyMatch(a -> !a.getCusId().equals(customer.getCusId()))) {
+//                throw new BaseBusinessException(ErrorCodeEnum.CUSTOMER_SAME_COMPANY_TELEPHONE.getCode(),
+//                        ErrorCodeEnum.CUSTOMER_SAME_COMPANY_TELEPHONE.getMessage());
+//            }
             customer.setLastFollowId(cusFollow.getFollowId());
             customer.setLastFollowTime(cusFollow.getFollowTime());
             customer.setLastFollowStaff(cusFollow.getFollowStaff());
@@ -255,10 +255,10 @@ public class CusFollowService extends BaseService<CusFollow> {
             Long count = customerMapper.countByCond(
                     new CustomerQuery().setCpId(customer.getCpId()).setCusPhone(customer.getCusPhone()).setFlgValid(true)
             );
-            if (count > 0) {
-                return ResponseResultUtil.error(ErrorCodeEnum.CUSTOMER_SAME_COMPANY_TELEPHONE.getCode(),
-                        ErrorCodeEnum.CUSTOMER_SAME_COMPANY_TELEPHONE.getMessage());
-            }
+//            if (count > 0) {
+//                return ResponseResultUtil.error(ErrorCodeEnum.CUSTOMER_SAME_COMPANY_TELEPHONE.getCode(),
+//                        ErrorCodeEnum.CUSTOMER_SAME_COMPANY_TELEPHONE.getMessage());
+//            }
 
             //放入公海客户,清除跟进人
             if (Constant.IntentionConstant.SEA.getValue().equals(cusFollowVO.getIntention())) {