haungfuli 2 سال پیش
والد
کامیت
3eb167979c

+ 5 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/constant/StatusEnum.java

@@ -118,6 +118,11 @@ public enum StatusEnum {
     PEND_ING("3", "暂缓中", "PEND_ING"),
     PAYMENT_ED("5", "已付款", "PAYMENT_ED"),
 
+    //货主还款状态
+    OUTSTANDING("1", "未还款", "outstanding"),
+    PARTIAL_REPAYMENT("3", "部分还款", "partial_repayment"),
+    REPAID("5", "已还款", "repaid"),
+
     ;
     @Getter
     private String flag;

+ 18 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/RepaymentInfoController.java

@@ -1,6 +1,11 @@
 package com.yh.saas.plugin.yiliangyiyun.controller;
 
 
+import com.baomidou.mybatisplus.plugins.Page;
+import com.yh.saas.plugin.yiliangyiyun.entity.RepaymentInfo;
+import com.yh.saas.plugin.yiliangyiyun.service.IRepaymentInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 
 import org.springframework.web.bind.annotation.RestController;
@@ -17,5 +22,18 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/repaymentInfo")
 public class RepaymentInfoController {
 
+    @Autowired
+    private IRepaymentInfoService repaymentInfoService;
+
+    /**
+     * 后台管理垫付还款结算列表
+     *
+     * @param repaymentInfo
+     * @return
+     */
+    @GetMapping("/selectAdvanceRepayment")
+    Page<RepaymentInfo> selectAdvanceRepayment(RepaymentInfo repaymentInfo){
+        return repaymentInfoService.selectAdvanceRepayment(repaymentInfo);
+    }
 }
 

+ 51 - 1
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/RepaymentInfo.java

@@ -1,5 +1,6 @@
 package com.yh.saas.plugin.yiliangyiyun.entity;
 
+import com.baomidou.mybatisplus.annotations.TableField;
 import com.baomidou.mybatisplus.annotations.TableId;
 import com.baomidou.mybatisplus.annotations.TableName;
 import com.baomidou.mybatisplus.enums.IdType;
@@ -74,6 +75,12 @@ public class RepaymentInfo extends BaseModel<RepaymentInfo> {
      * 未还
      */
     private Double notRepaid;
+    /**
+     * 还款时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date repaymentDate;
     /**
      * 状态key(1未还款3部分还款5已还款)
      */
@@ -83,7 +90,50 @@ public class RepaymentInfo extends BaseModel<RepaymentInfo> {
      */
     private String status;
 
-
+    /**
+     * 模糊查询
+     */
+    @TableField(exist = false)
+    private String searchKeyWord;
+    /**
+     * 查询类型(1待还款2已还款)
+     */
+    @TableField(exist = false)
+    private String searchType;
+    /**
+     * 筛选开始日期
+     */
+    @TableField(exist = false)
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    private String startDate;
+    /**
+     * 筛选结束日期
+     */
+    @TableField(exist = false)
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    private String endDate;
+    /**
+     * 订单编号
+     */
+    @TableField(exist = false)
+    private String orderNo;
+    /**
+     * 货主姓名
+     */
+    @TableField(exist = false)
+    private String cargoOwnerName;
+    /**
+     * 账号
+     */
+    @TableField(exist = false)
+    private String accountNumber;
+    /**
+     * 所属企业
+     */
+    @TableField(exist = false)
+    private String affiliatedEnterprise;
 
 
     @Override

+ 19 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/mapper/RepaymentInfoMapper.java

@@ -1,8 +1,12 @@
 package com.yh.saas.plugin.yiliangyiyun.mapper;
 
+import com.yh.saas.plugin.yiliangyiyun.entity.HyFreightSettlementInfo;
 import com.yh.saas.plugin.yiliangyiyun.entity.RepaymentInfo;
 import com.baomidou.mybatisplus.mapper.BaseMapper;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 还款信息 Mapper 接口
@@ -13,4 +17,19 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
  */
 public interface RepaymentInfoMapper extends BaseMapper<RepaymentInfo> {
 
+    /**
+     * 根据条件查询垫付还款结算总数
+     *
+     * @param pageView
+     * @return
+     */
+    Integer getCountByCondition(Map<String, Object> pageView);
+
+    /**
+     * 根据条件查询垫付还款结算列表
+     *
+     * @param pageView
+     * @return
+     */
+    List<RepaymentInfo> getListByCondition(Map<String, Object> pageView);
 }

+ 8 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/IRepaymentInfoService.java

@@ -1,5 +1,6 @@
 package com.yh.saas.plugin.yiliangyiyun.service;
 
+import com.baomidou.mybatisplus.plugins.Page;
 import com.yh.saas.plugin.yiliangyiyun.entity.RepaymentInfo;
 import com.baomidou.mybatisplus.service.IService;
 
@@ -13,4 +14,11 @@ import com.baomidou.mybatisplus.service.IService;
  */
 public interface IRepaymentInfoService extends IService<RepaymentInfo> {
 
+    /**
+     * 后台管理垫付还款结算列表
+     *
+     * @param repaymentInfo
+     * @return
+     */
+    Page<RepaymentInfo> selectAdvanceRepayment(RepaymentInfo repaymentInfo);
 }

+ 21 - 12
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/HyFreightSettlementInfoServiceImpl.java

@@ -112,6 +112,8 @@ public class HyFreightSettlementInfoServiceImpl extends ServiceImpl<HyFreightSet
                 //查询费用信息
                 FreightInfo freightInfo = freightInfoService.selectOne(new EntityWrapper<FreightInfo>()
                         .eq("order_id", hyFreightSettlementInfo1.getOrderId()));
+                //查询订单信息
+                OrderInfo orderInfo1 = orderInfoService.selectById(hyFreightSettlementInfo1.getOrderId());
                 //判断是否是垫付订单
                 if ("1".equals(hyFreightSettlementInfo1.getFreightAdvance())) {
                     //垫付订单
@@ -122,6 +124,21 @@ public class HyFreightSettlementInfoServiceImpl extends ServiceImpl<HyFreightSet
                         freightInfo.setPayabledFreight(hyFreightSettlementInfo1.getAmountMoney());
                         freightInfo.setNopayableFreight(freightInfo.getPayableFreight() - freightInfo.getPrepaidFreight());
                         freightInfo.setReceivableFreight(freightInfo.getPrepaidFreight());
+                        //生成还款信息
+                        RepaymentInfo repaymentInfo = new RepaymentInfo();
+                        repaymentInfo.setId(IdGenerator.generateUUID());
+                        repaymentInfo.setOrderId(orderInfo1.getId());
+                        repaymentInfo.setCommonId(orderInfo1.getCargoCommonId());
+                        repaymentInfo.setFreightId(freightInfo.getId());
+                        repaymentInfo.setFreight(freightInfo.getPrepaidFreight());
+                        repaymentInfo.setOverdueFee(0d);
+                        repaymentInfo.setInterestRate(0.03);
+                        repaymentInfo.setTotalRepayable(freightInfo.getReceivableFreight());
+                        repaymentInfo.setAlreadyRepaid(0d);
+                        repaymentInfo.setNotRepaid(freightInfo.getReceivableFreight());
+                        repaymentInfo.setStatusKey(StatusEnum.OUTSTANDING.getFlag());
+                        repaymentInfo.setStatus(StatusEnum.OUTSTANDING.getName());
+                        repaymentInfoService.insert(repaymentInfo);
                     } else {
                         //尾款
                         freightInfo.setFreightBalance(hyFreightSettlementInfo1.getAmountMoney());
@@ -135,25 +152,18 @@ public class HyFreightSettlementInfoServiceImpl extends ServiceImpl<HyFreightSet
                         freightInfo.setReceivableFreight(d1 + freightInfo.getOwnerFreightBalance() + freightInfo.getOwnerServiceCharge());
                         freightInfo.setTotalPayment(freightInfo.getActualFreight() + freightInfo.getOwnerServiceCharge());
                         //修改订单运费
-                        OrderInfo orderInfo1 = orderInfoService.selectById(hyFreightSettlementInfo1.getOrderId());
                         if (orderInfo1 != null) {
                             orderInfo1.setFreight(freightInfo.getPrepaidFreight() + freightInfo.getFreightBalance());
                             orderInfoService.updateById(orderInfo1);
                         }
-                        //生成还款信息
-                        RepaymentInfo repaymentInfo = new RepaymentInfo();
-                        repaymentInfo.setId(IdGenerator.generateUUID());
-                        repaymentInfo.setOrderId(orderInfo1.getId());
-                        repaymentInfo.setCommonId(orderInfo1.getCargoCommonId());
-                        repaymentInfo.setFreightId(freightInfo.getId());
+                        //修改还款信息
+                        RepaymentInfo repaymentInfo = repaymentInfoService.selectOne(new EntityWrapper<RepaymentInfo>()
+                                .eq("order_id",orderInfo1.getId()).eq("delete_flag","0"));
                         repaymentInfo.setFreight(freightInfo.getActualFreight());
-                        repaymentInfo.setOverdueFee(0d);
-                        repaymentInfo.setInterestRate(0.03);
                         repaymentInfo.setServiceCharge(freightInfo.getOwnerServiceCharge());
                         repaymentInfo.setTotalRepayable(freightInfo.getReceivableFreight());
-                        repaymentInfo.setAlreadyRepaid(0d);
                         repaymentInfo.setNotRepaid(freightInfo.getReceivableFreight());
-                        repaymentInfoService.insert(repaymentInfo);
+                        repaymentInfoService.updateById(repaymentInfo);
                         //冻结货主可用余额
                         if (orderInfo1.getCompId() != null && !orderInfo1.getCompId().isEmpty()) {
                             //货主是公司
@@ -203,7 +213,6 @@ public class HyFreightSettlementInfoServiceImpl extends ServiceImpl<HyFreightSet
                         freightInfo.setPayabledFreight(d + hyFreightSettlementInfo1.getAmountMoney());
                         freightInfo.setNopayableFreight(freightInfo.getPayableFreight() - freightInfo.getPayabledFreight());
                         //修改订单运费
-                        OrderInfo orderInfo1 = orderInfoService.selectById(hyFreightSettlementInfo1.getOrderId());
                         if (orderInfo1 != null) {
                             orderInfo1.setFreight(freightInfo.getPrepaidFreight() + freightInfo.getFreightBalance());
                             orderInfoService.updateById(orderInfo1);

+ 35 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/RepaymentInfoServiceImpl.java

@@ -1,11 +1,17 @@
 package com.yh.saas.plugin.yiliangyiyun.service.impl;
 
+import com.baomidou.mybatisplus.plugins.Page;
+import com.google.common.collect.Lists;
 import com.yh.saas.plugin.yiliangyiyun.entity.RepaymentInfo;
 import com.yh.saas.plugin.yiliangyiyun.mapper.RepaymentInfoMapper;
 import com.yh.saas.plugin.yiliangyiyun.service.IRepaymentInfoService;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 还款信息 服务实现类
@@ -17,4 +23,33 @@ import org.springframework.stereotype.Service;
 @Service
 public class RepaymentInfoServiceImpl extends ServiceImpl<RepaymentInfoMapper, RepaymentInfo> implements IRepaymentInfoService {
 
+
+    /**
+     * 后台管理垫付还款结算列表
+     *
+     * @param repaymentInfo
+     * @return
+     */
+    @Override
+    public Page<RepaymentInfo> selectAdvanceRepayment(RepaymentInfo repaymentInfo) {
+        Map<String, Object> pageView = new HashMap<>(8);
+        pageView.put("startRecord", (repaymentInfo.getCurrentPage() - 1)
+                * repaymentInfo.getPageSize());
+        //用户id
+        pageView.put("searchKeyWord", repaymentInfo.getSearchKeyWord());
+        pageView.put("searchType", repaymentInfo.getSearchType());
+        pageView.put("startDate", repaymentInfo.getStartDate());
+        pageView.put("endDate", repaymentInfo.getEndDate());
+        pageView.put("pageSize", repaymentInfo.getPageSize());
+        pageView.put("currentPage", repaymentInfo.getCurrentPage());
+        // 查询账单总数
+        Integer dataCount = baseMapper.getCountByCondition(pageView);
+        List<RepaymentInfo> dataList = baseMapper.getListByCondition(pageView);
+        Page<RepaymentInfo> page = new Page<>();
+        page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
+        page.setTotal(dataCount == null ? 0 : dataCount);
+        page.setCurrent(repaymentInfo.getCurrentPage());
+        page.setSize(repaymentInfo.getPageSize());
+        return page;
+    }
 }

+ 84 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/resources/mapper/RepaymentInfoMapper.xml

@@ -2,4 +2,88 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.yh.saas.plugin.yiliangyiyun.mapper.RepaymentInfoMapper">
 
+
+    <!-- 获得垫付还款结算总数 -->
+    <select id="getCountByCondition" parameterType="Map" resultType="java.lang.Integer">
+        select
+        count(r.id)
+        FROM hy_repayment_info r
+        LEFT JOIN hy_order_info o on r.order_id = o.id and o.delete_flag = 0
+        LEFT JOIN hy_cargo_owner_info c on c.common_id = r.common_id and c.delete_flag = 0
+        WHERE
+        r.delete_flag = '0'
+        <if test="searchKeyWord != null and searchKeyWord != ''">
+            AND (lower(c.name) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower(o.order_no) like lower(CONCAT('%',#{searchKeyWord},'%')))
+        </if>
+        <if test="searchType != null and searchType != ''">
+            <if test="searchType == 1">
+                AND (r.status_key = '1' OR r.status_key = '3')
+            </if>
+            <if test="searchType == 2">
+                AND r.status_key = '5'
+            </if>
+        </if>
+        <if test="startDate != null and startDate != ''">
+            AND (DATE_FORMAT(r.repayment_date,"%Y%m%d") >=
+            DATE_FORMAT(#{startDate},"%Y%m%d"))
+        </if>
+        <if test="endDate != null and endDate != ''">
+            AND (DATE_FORMAT(r.repayment_date,"%Y%m%d") &lt;=
+            DATE_FORMAT(#{endDate},"%Y%m%d"))
+        </if>
+    </select>
+
+    <!-- 垫付还款结算列表查询 -->
+    <select id="getListByCondition" parameterType="Map"
+            resultType="com.yh.saas.plugin.yiliangyiyun.entity.RepaymentInfo">
+        SELECT
+        r.id,
+        r.order_id as orderId,
+        r.common_id as commonId,
+        r.freight_id as freightId,
+        o.order_no as orderNo,
+        c.name as cargoOwnerName,
+        c.phone as accountNumber,
+        o.comp_name as affiliatedEnterprise,
+        r.freight,
+        r.overdue_fee as overdueFee,
+        r.service_charge as serviceCharge,
+        r.total_repayable as totalRepayable,
+        r.already_repaid as alreadyRepaid,
+        r.not_repaid as notRepaid,
+        r.status_key as statusKey,
+        r.status,
+        r.repayment_date as repaymentDate,
+        r.create_date as createDate
+        FROM hy_repayment_info r
+        LEFT JOIN hy_order_info o on r.order_id = o.id and o.delete_flag = 0
+        LEFT JOIN hy_cargo_owner_info c on c.common_id = r.common_id and c.delete_flag = 0
+        WHERE
+        r.delete_flag = '0'
+        <if test="searchKeyWord != null and searchKeyWord != ''">
+            AND (lower(c.name) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower(o.order_no) like lower(CONCAT('%',#{searchKeyWord},'%')))
+        </if>
+        <if test="searchType != null and searchType != ''">
+            <if test="searchType == 1">
+                AND (r.status_key = '1' OR r.status_key = '3')
+            </if>
+            <if test="searchType == 2">
+                AND r.status_key = '5'
+            </if>
+        </if>
+        <if test="startDate != null and startDate != ''">
+            AND (DATE_FORMAT(r.repayment_date,"%Y%m%d") >=
+            DATE_FORMAT(#{startDate},"%Y%m%d"))
+        </if>
+        <if test="endDate != null and endDate != ''">
+            AND (DATE_FORMAT(r.repayment_date,"%Y%m%d") &lt;=
+            DATE_FORMAT(#{endDate},"%Y%m%d"))
+        </if>
+        ORDER BY r.status_key ASC,r.repayment_date DESC
+        <if test="currentPage != null and currentPage != ''">
+            LIMIT ${startRecord}, ${pageSize}
+        </if>
+    </select>
 </mapper>