Kaynağa Gözat

个贷所有订单查询

wucl 6 ay önce
ebeveyn
işleme
0da80d802e

+ 26 - 0
biz-base/src/main/java/com/dayou/controller/PersonalController.java

@@ -195,6 +195,32 @@ public class PersonalController extends BaseController {
         return RestResponse.data(ret);
     }
 
+    /**
+     * 获取全部的订单列表
+     * @param personal
+     * @param page
+     * @param keyword
+     * @return
+     */
+    @GetMapping("/all")
+    public RestResponse<Page<PersonalVO>> getAllOrder(PersonalVO personal, Page page,String keyword){
+        Page<PersonalVO> ret = personalService.getAllOrder(personal,page,keyword);
+        return RestResponse.data(ret);
+    }
+
+    /**
+     * 获取全部的订单总数
+     * @param personal
+     * @param page
+     * @param keyword
+     * @return
+     */
+    @GetMapping("/count")
+    public RestResponse<Long> getAllOrderCount(PersonalVO personal, Page page,String keyword){
+        Long ret = personalService.getAllOrderCount(personal,page,keyword);
+        return RestResponse.data(ret);
+    }
+
 
 }
 

+ 2 - 0
dao/src/main/java/com/dayou/mapper/DyoaHistoryMapper.java

@@ -24,6 +24,8 @@ public interface DyoaHistoryMapper {
 
     Map<String, Object> queryPersonalOrder(@Param("id") String id);
 
+    Map<String,Object> queryPersonalTarget(@Param("id") String id);
+
     List<String> getNewOrderIds(@Param("max") Date max);
 
     Map<String, Object> getRealAmountInfo(@Param("id") String max);

+ 2 - 0
dao/src/main/java/com/dayou/mapper/DyoaRecordMapper.java

@@ -21,6 +21,8 @@ public interface DyoaRecordMapper extends CustomBaseMapper<DyoaRecord> {
 
     Date getMaxOrderTime();
 
+    Date getMaxPersonalTargetTime();
+
     Date getMaxRealAmountCreatedTime();
 
     Date getMaxClaimDate();

+ 4 - 0
dao/src/main/java/com/dayou/mapper/PersonalMapper.java

@@ -37,4 +37,8 @@ public interface PersonalMapper extends CustomBaseMapper<Personal> {
     Page<PersonalVO> waitingAllotOrderPage(Page page,@Param("keyword") String keyword);
 
     void batchUpdateOutWardStaffId(@Param("userId") Long userId, @Param("priceStaffId") Long priceStaffId,@Param("list") List<Long> orderIds);
+
+    Page<PersonalVO> selectOrder(Page page, @Param("personal") PersonalVO personal,@Param("keyword") String keyword);
+
+    Long getAllOrderCount(@Param("personal")PersonalVO personal, @Param("keyword")String keyword);
 }

+ 16 - 0
dao/src/main/resources/mapper/DyoaHistoryMapper.xml

@@ -190,11 +190,27 @@
         select id from dy_order where masterName is not null
     </select>
 
+    <select id="queryPersonalTarget" parameterType="java.lang.String" resultType="map">
+        SELECT
+            id,
+            orderNo,
+            locations,
+            area,
+            money,
+            price
+        FROM
+            dy_order_loan where id = #{id}
+    </select>
+
+
     <select id="queryPersonalOrder" parameterType="java.lang.String" resultType="map">
         SELECT
             id,
             orderNo,
             locations,
+            area,
+            money,
+            price,
             target,
             purpose,
             loanMaxMoney,

+ 4 - 0
dao/src/main/resources/mapper/DyoaRecordMapper.xml

@@ -27,6 +27,10 @@
         select max(order_datetime) from dyoa_record where mbs_type = 'PERSONAL_ORDER'
     </select>
 
+    <select id="getMaxPersonalTargetTime" resultType="java.util.Date">
+        select max(order_datetime) from dyoa_record where mbs_type = 'PERSONAL_TARGET'
+    </select>
+
     <select id="getMaxRealAmountCreatedTime" resultType="java.util.Date">
         select max(order_datetime) from dyoa_record where mbs_type = 'REAL_AMOUNT'
     </select>

+ 174 - 0
dao/src/main/resources/mapper/PersonalMapper.xml

@@ -470,4 +470,178 @@
             </foreach>
             )
     </update>
+
+    <select id="selectOrder" parameterType="com.dayou.vo.PersonalVO" resultType="com.dayou.vo.PersonalVO">
+        SELECT
+        p.id,
+        p.order_id,
+        p.location,
+        p.agent,
+        p.bailorA,
+        p.bailorB,
+        p.bailorA_tel,
+        p.bailorB_tel,
+        p.client_manager_id,
+        p.remark,
+        pt.acreage,
+        pt.price,
+        pt.amount,
+        pt.created AS valueTiming,
+        found.real_amount,
+        cc1.NAME AS clientName,
+        cc2.NAME AS clientSubName,
+        cl1.NAME AS contactName,
+        cl1.mobile AS contactTel,
+        u.NAME AS clientManager,
+        u1.NAME AS outwardStaffName,
+        u2.NAME AS inwardStaffName,
+        u3.NAME AS pricingStaffName,
+        p.created,
+        p.created as xCreated
+        FROM
+        personal p
+        LEFT JOIN (select personal_id,acreage,price,amount,created from personal_target where deleted = 0) pt ON pt.personal_id = p.id
+        LEFT JOIN (
+        SELECT
+        f.business_id,
+        f.real_amount
+        FROM
+        order_fund f
+        WHERE
+        f.business_type = 'PERSONAL_BUSINESS'
+        AND f.deleted = 0
+        ) found ON found.business_id = p.id
+        LEFT JOIN (select id,name from customer_company where deleted=0) cc1 ON cc1.id = p.clientele_id
+        LEFT JOIN (select id,name from customer_company where deleted=0) cc2 ON cc2.id = p.clientele_sub_id
+        LEFT JOIN (select id,name,mobile from customer_linkman where deleted = 0) cl1 ON cl1.id = p.clientele_contact_id
+        LEFT JOIN (select id,name from user where deleted = 0) u ON u.id = p.client_manager_id
+        LEFT JOIN (select id,name from user where deleted = 0) u1 ON u1.id = p.outward_staff
+        LEFT JOIN (select id,name from user where deleted = 0) u2 ON u2.id = p.inward_staff
+        LEFT JOIN (select id,name from user where deleted = 0) u3 ON u3.id = p.pricing_staff
+        WHERE
+        p.deleted = 0
+        <if test="keyword!=null and keyword!='' ">
+            and (
+            p.location like concat ('%',#{keyword},'%')
+            or p.order_id like concat('%',#{keyword},'%')
+            or p.agent like concat('%',#{keyword},'%')
+            or p.bailorA like concat('%',#{keyword},'%')
+            or p.bailorB like concat('%',#{keyword},'%')
+            or cc1.name like concat('%',#{keyword},'%')
+            or cc2.name like concat('%',#{keyword},'%')
+            or cl1.name like concat('%',#{keyword},'%')
+            or p.bailorA_tel like concat('%',#{keyword},'%')
+            or p.bailorB_tel like concat('%',#{keyword},'%')
+            )
+        </if>
+        <if test="personal!=null and personal.personalRealAmount!=null and personal.personalRealAmount==true ">
+            and (found.real_amount is not null and found.real_amount !=0)
+        </if>
+        <if test="personal!=null and personal.personalRealAmount!=null and personal.personalRealAmount==false ">
+            and (found.real_amount is null or found.real_amount=0)
+        </if>
+        <if test="personal!=null and personal.startDate!=null and personal.startDate!=''">
+            and p.created &gt;= #{personal.startDate}
+        </if>
+        <if test="personal!=null and personal.endDate!=null and personal.endDate!=''">
+            and p.created &lt;= #{personal.endDate}
+        </if>
+        <if test="personal!=null and personal.clientName!=null and personal.clientName!=''">
+            and cc1.NAME like concat('%',#{personal.clientName},'%')
+        </if>
+        <if test="personal!=null and personal.clientSubName!=null and personal.clientSubName!=''">
+            and cc2.NAME like concat('%',#{personal.clientSubName},'%')
+        </if>
+        <if test="personal!=null and personal.clientManager!=null and personal.clientManager!='' ">
+            and u.name like concat('%',#{personal.clientManager},'%')
+        </if>
+        <if test="personal!=null and personal.outwardStaffName!=null and personal.outwardStaffName!='' ">
+            and u1.name like concat('%',#{personal.outwardStaffName},'%')
+        </if>
+        <if test="personal!=null and personal.inwardStaffName!=null and personal.inwardStaffName!='' ">
+            and u2.name like concat('%',#{personal.inwardStaffName},'%')
+        </if>
+        <if test="personal!=null and personal.pricingStaffName!=null and personal.pricingStaffName!='' ">
+            and u3.name like concat('%',#{personal.pricingStaffName},'%')
+        </if>
+        <if test="personal!=null and personal.handlerName!=null and personal.handlerName!='' ">
+            and u4.name like concat('%',#{personal.handlerName},'%')
+        </if>
+        order by p.created desc
+    </select>
+
+    <select id="getAllOrderCount" parameterType="com.dayou.vo.PersonalVO" resultType="java.lang.Long">
+        SELECT
+            count(1)
+        FROM
+        personal p
+        LEFT JOIN (select personal_id,acreage,price,amount,created from personal_target where deleted = 0) pt ON pt.personal_id = p.id
+        LEFT JOIN (
+        SELECT
+        f.business_id,
+        f.real_amount
+        FROM
+        order_fund f
+        WHERE
+        f.business_type = 'PERSONAL_BUSINESS'
+        AND f.deleted = 0
+        ) found ON found.business_id = p.id
+        LEFT JOIN (select id,name from customer_company where deleted=0) cc1 ON cc1.id = p.clientele_id
+        LEFT JOIN (select id,name from customer_company where deleted=0) cc2 ON cc2.id = p.clientele_sub_id
+        LEFT JOIN (select id,name,mobile from customer_linkman where deleted = 0) cl1 ON cl1.id = p.clientele_contact_id
+        LEFT JOIN (select id,name from user where deleted = 0) u ON u.id = p.client_manager_id
+        LEFT JOIN (select id,name from user where deleted = 0) u1 ON u1.id = p.outward_staff
+        LEFT JOIN (select id,name from user where deleted = 0) u2 ON u2.id = p.inward_staff
+        LEFT JOIN (select id,name from user where deleted = 0) u3 ON u3.id = p.pricing_staff
+        WHERE
+        p.deleted = 0
+        <if test="keyword!=null and keyword!='' ">
+            and (
+            p.location like concat ('%',#{keyword},'%')
+            or p.order_id like concat('%',#{keyword},'%')
+            or p.agent like concat('%',#{keyword},'%')
+            or p.bailorA like concat('%',#{keyword},'%')
+            or p.bailorB like concat('%',#{keyword},'%')
+            or cc1.name like concat('%',#{keyword},'%')
+            or cc2.name like concat('%',#{keyword},'%')
+            or cl1.name like concat('%',#{keyword},'%')
+            or p.bailorA_tel like concat('%',#{keyword},'%')
+            or p.bailorB_tel like concat('%',#{keyword},'%')
+            )
+        </if>
+        <if test="personal!=null and personal.personalRealAmount!=null and personal.personalRealAmount==true ">
+            and (found.real_amount is not null and found.real_amount !=0)
+        </if>
+        <if test="personal!=null and personal.personalRealAmount!=null and personal.personalRealAmount==false ">
+            and (found.real_amount is null or found.real_amount=0)
+        </if>
+        <if test="personal!=null and personal.startDate!=null and personal.startDate!=''">
+            and p.created &gt;= #{personal.startDate}
+        </if>
+        <if test="personal!=null and personal.endDate!=null and personal.endDate!=''">
+            and p.created &lt;= #{personal.endDate}
+        </if>
+        <if test="personal!=null and personal.clientName!=null and personal.clientName!=''">
+            and cc1.NAME like concat('%',#{personal.clientName},'%')
+        </if>
+        <if test="personal!=null and personal.clientSubName!=null and personal.clientSubName!=''">
+            and cc2.NAME like concat('%',#{personal.clientSubName},'%')
+        </if>
+        <if test="personal!=null and personal.clientManager!=null and personal.clientManager!='' ">
+            and u.name like concat('%',#{personal.clientManager},'%')
+        </if>
+        <if test="personal!=null and personal.outwardStaffName!=null and personal.outwardStaffName!='' ">
+            and u1.name like concat('%',#{personal.outwardStaffName},'%')
+        </if>
+        <if test="personal!=null and personal.inwardStaffName!=null and personal.inwardStaffName!='' ">
+            and u2.name like concat('%',#{personal.inwardStaffName},'%')
+        </if>
+        <if test="personal!=null and personal.pricingStaffName!=null and personal.pricingStaffName!='' ">
+            and u3.name like concat('%',#{personal.pricingStaffName},'%')
+        </if>
+        <if test="personal!=null and personal.handlerName!=null and personal.handlerName!='' ">
+            and u4.name like concat('%',#{personal.handlerName},'%')
+        </if>
+        order by p.created desc
+    </select>
 </mapper>

+ 22 - 0
domain/src/main/java/com/dayou/vo/PersonalVO.java

@@ -5,6 +5,7 @@ import com.dayou.entity.Personal;
 import lombok.Data;
 
 import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.util.Date;
 
 /**
@@ -182,4 +183,25 @@ public class PersonalVO extends Personal {
      */
     @Excel(name = "下单时间")
     private Date created;
+
+    /**
+     * 最新实收款认领日期
+     */
+    private Date claimDateTime;
+
+    /**
+     * 是否认领实收款
+     */
+    private Boolean personalRealAmount;
+
+    /**
+     * 价值时点
+     */
+    private LocalDate valueTiming;
+
+    /**
+     * 下单日期
+     */
+    private LocalDate xCreated;
+
 }

+ 34 - 8
service/src/main/java/com/dayou/dyoa/DyoaHistoryServiceImpl.java

@@ -19,10 +19,7 @@ import com.dayou.entity.*;
 import com.dayou.enums.MainBusinessEnum;
 import com.dayou.enums.ProductionEnum;
 import com.dayou.exception.ErrorCode;
-import com.dayou.mapper.DyoaHistoryMapper;
-import com.dayou.mapper.DyoaRecordMapper;
-import com.dayou.mapper.FinanceClaimMapper;
-import com.dayou.mapper.ProductionFundMapper;
+import com.dayou.mapper.*;
 import com.dayou.service.*;
 import com.dayou.service.impl.AssetsServiceImpl;
 import com.dayou.utils.DateUtils;
@@ -147,6 +144,9 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
     @Autowired
     private IFinanceInvoiceService financeInvoiceService;
 
+    @Autowired
+    private IPersonalTargetService personalTargetService;
+
     static {
 //        MAJOR_ORDER_COLUM.put("id","id");
         MAJOR_ORDER_COLUM.put("name","name");
@@ -325,6 +325,10 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
 
     @Autowired
     private ProductionFundMapper productionFundMapper;
+    @Autowired
+    private DyoaRecordMapper dyoaRecordMapper;
+    @Autowired
+    private PersonalTargetMapper personalTargetMapper;
 
 
     @Override
@@ -496,6 +500,9 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
         });
     }
 
+
+
+
     @DSTransactional
     @Override
     public void fetchRealAmountClaimData() {
@@ -889,10 +896,29 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
     private void fetchAboutPersonal(String dyoaId) {
         Map<String, Object> dyoaPersonalOrder = dyoaHistoryMapper.queryPersonalOrder(dyoaId);
         try {
-            //1.插入personal表
-            Personal personal = this.doCreatePersonalOrder(dyoaPersonalOrder);
-            //2.创建订单收款记录
-            this.doCreatedOrderFund(personal);
+            DyoaRecord record = dyoaRecordService.getOne(new LambdaQueryWrapper<DyoaRecord>()
+                    .eq(DyoaRecord::getDyoaId, dyoaId).eq(DyoaRecord::getMbsType, "PERSONAL_ORDER"));
+            Long mbsId = null;
+            if (record!=null){
+                mbsId = record.getMbsId();
+            }else{
+                //1.插入personal表
+                Personal personal = this.doCreatePersonalOrder(dyoaPersonalOrder);
+                //2.创建订单收款记录
+                this.doCreatedOrderFund(personal);
+                mbsId = personal.getId();
+            }
+            PersonalTarget target = new PersonalTarget();
+            target.setPersonalId(mbsId);
+            Object locations = dyoaPersonalOrder.get("locations");
+            target.setLocation(locations==null?"": (String) locations);
+            Object area = dyoaPersonalOrder.get("area");
+            target.setAcreage(area==null?null:BigDecimal.valueOf((Double) area));
+            Object money = dyoaPersonalOrder.get("money");
+            target.setAmount(money==null?null:BigDecimal.valueOf((Double) money));
+            Object price = dyoaPersonalOrder.get("price");
+            target.setPrice(price==null?null:BigDecimal.valueOf((Double) price));
+            personalTargetService.save(target);
         } catch (NoSuchFieldException e) {
             throw new RuntimeException(e);
         } catch (IllegalAccessException e) {

+ 2 - 0
service/src/main/java/com/dayou/service/IDyoaRecordService.java

@@ -30,6 +30,8 @@ public interface IDyoaRecordService extends IService<DyoaRecord> {
 
         Date getMaxOrderTime();
 
+        Date getMaxPersonalTargetTime();
+
         Date getMaxRealAmountCreatedTime();
 
         Date getMaxClaimDate();

+ 4 - 0
service/src/main/java/com/dayou/service/IPersonalService.java

@@ -68,4 +68,8 @@ public interface IPersonalService extends IService<Personal> {
     Long fixationPriceStaff(Long outwardStaffId);
 
     void fixationInwardStaff(Long personalId);
+
+    Page<PersonalVO> getAllOrder(PersonalVO personal, Page page, String keyword);
+
+    Long getAllOrderCount(PersonalVO personal, Page page, String keyword);
 }

+ 5 - 0
service/src/main/java/com/dayou/service/impl/DyoaRecordServiceImpl.java

@@ -69,6 +69,11 @@ public class DyoaRecordServiceImpl extends ServiceImpl<DyoaRecordMapper, DyoaRec
     }
 
     @Override
+    public Date getMaxPersonalTargetTime() {
+        return dyoaRecordMapper.getMaxPersonalTargetTime();
+    }
+
+    @Override
     public Date getMaxRealAmountCreatedTime() {
         return dyoaRecordMapper.getMaxRealAmountCreatedTime();
     }

+ 11 - 0
service/src/main/java/com/dayou/service/impl/PersonalServiceImpl.java

@@ -319,6 +319,17 @@ public class PersonalServiceImpl extends ServiceImpl<PersonalMapper, Personal> i
         }
     }
 
+    @Override
+    public Page<PersonalVO> getAllOrder(PersonalVO personal, Page page, String keyword) {
+        page.setSearchCount(false);
+        return personalMapper.selectOrder(page,personal,keyword);
+    }
+
+    @Override
+    public Long getAllOrderCount(PersonalVO personal, Page page, String keyword) {
+        return personalMapper.getAllOrderCount(personal,keyword);
+    }
+
     /**
      * 由外业人员确定定价内业
      * @return

+ 2 - 0
service/src/main/java/com/dayou/service/impl/PersonalTargetServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
+import com.baomidou.dynamic.datasource.annotation.DS;
 import com.dayou.common.BaseEntity;
 import com.dayou.dto.TaskRecordDTO;
 import com.dayou.entity.Personal;
@@ -51,6 +52,7 @@ import static com.dayou.enums.CertificateEnum.*;
  * @author wucl
  * @since 2024-03-01
  */
+@DS("mbs")
 @Service
 public class PersonalTargetServiceImpl extends ServiceImpl<PersonalTargetMapper, PersonalTarget> implements IPersonalTargetService {