ezhizao_zx 1 rok pred
rodič
commit
fff66fabcf

+ 2 - 0
src/main/java/cn/ezhizao/project/business/collection/controller/BizCollectionController.java

@@ -87,6 +87,7 @@ public class BizCollectionController extends BaseController {
 
     @ApiOperation(value = "主从保存", notes = "主从保存")
     @PostMapping("/save")
+    @PreAuthorize("@ss.hasPermi('business:collection:edit')")
     @Transactional(rollbackFor = Exception.class)
     @ResponseBody
     public AjaxResult saveAll(@RequestBody BizCollection collection) throws NoSuchFieldException, IllegalAccessException {
@@ -195,6 +196,7 @@ public class BizCollectionController extends BaseController {
             detail.setTaskTypeName(l.getTaskTypeName());
             detail.setTaskTypeId(l.getTaskTypeId());
             detail.setAmount(l.getAmount());
+            detail.setArrived(l.getArrived());
             bizCollection.getDetails().add(detail);
         });
         return success(bizCollection);

+ 3 - 0
src/main/java/cn/ezhizao/project/business/order/domain/BizArchiveInput.java

@@ -213,4 +213,7 @@ public class BizArchiveInput extends BaseEntity {
 
     @TableField(exist = false)
     private boolean nonpayment;
+
+    @TableField(exist = false)
+    private BigDecimal paidAmount;
 }

+ 3 - 0
src/main/java/cn/ezhizao/project/business/order/domain/BizArchiveInputDetail.java

@@ -111,4 +111,7 @@ public class BizArchiveInputDetail extends BaseEntity
     @ApiModelProperty("变更来源外键")
     private Long fromId;
 
+    @ApiModelProperty("已付款")
+    private BigDecimal arrived;
+
 }

+ 35 - 9
src/main/java/cn/ezhizao/project/business/payment/controller/BizPaymentController.java

@@ -2,6 +2,8 @@ package cn.ezhizao.project.business.payment.controller;
 
 import cn.ezhizao.common.exception.ServiceException;
 import cn.ezhizao.common.utils.uuid.SnowflakeIdWorker;
+import cn.ezhizao.framework.aspectj.lang.annotation.Log;
+import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
 import cn.ezhizao.framework.web.controller.BaseController;
 import cn.ezhizao.framework.web.domain.AjaxResult;
 import cn.ezhizao.framework.web.page.TableDataInfo;
@@ -76,6 +78,8 @@ public class BizPaymentController extends BaseController {
     @ApiOperation(value = "主从保存", notes = "主从保存")
     @PostMapping("/save")
     @Transactional(rollbackFor = Exception.class)
+    @PreAuthorize("@ss.hasPermi('business:payment:add')")
+    @Log(title = "支付保存", businessType = BusinessType.INSERT)
     @ResponseBody
     public AjaxResult saveAll(@RequestBody BizPayment payment) throws NoSuchFieldException, IllegalAccessException {
         boolean changeFormNo = true;
@@ -180,12 +184,12 @@ public class BizPaymentController extends BaseController {
         List<BizArchiveInput> list = archiveInputService.getList(condition);
         return getDataTable(list);
     }
+
     @ApiOperation("获取合同")
     @GetMapping("/listContractDetail")
     @PreAuthorize("@ss.hasPermi('business:payment:query')")
     @ResponseBody
-    public TableDataInfo listContractDetail(BizArchiveInputDetail condition) throws NoSuchFieldException, IllegalAccessException
-    {
+    public TableDataInfo listContractDetail(BizArchiveInputDetail condition) throws NoSuchFieldException, IllegalAccessException {
         setTenantId(condition);
         startPage();
         List<BizArchiveInputDetail> list = contractDetailService.getList(condition);
@@ -193,10 +197,29 @@ public class BizPaymentController extends BaseController {
     }
 
 
+    @PreAuthorize("@ss.hasPermi('expenditure:subject:remove')")
+    @Log(title = "支付删除", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable List<Long> ids) {
+        //查询所有需要删除的数据
+        List<BizPayment> list = paymentService.getByIds(ids);
+        for (BizPayment l:list){
+            //判读是否已经审核
+            if (l.getVerifyStatus() == 1) {
+                //已经审核无法删除
+                return error("删除失败,审核通过的不能删除");
+            }
+        }
+        //全未审核则删除
+        return toAjax(paymentService.removeBatchByIds(ids)&&paymentService.removePaymentDetail(ids));
+    }
 
 
     private BizPayment getForId(Long paymentId) {
-        BizPayment payment = paymentService.getById(paymentId);
+        BizPayment payment = new BizPayment();
+        payment.setId(paymentId);
+        List<BizPayment> payments = paymentService.getListByBean(payment);
+        payment = payments.isEmpty() ? null : payments.get(0);
         if (payment != null) {
             BizArchiveInput condition = new BizArchiveInput();
             condition.setId(payment.getContractId());
@@ -204,11 +227,13 @@ public class BizPaymentController extends BaseController {
             BizArchiveInput archiveInput = archiveInputs.isEmpty() ? null : archiveInputs.get(0);
             if (archiveInput != null) {
                 payment.setContractNo(archiveInput.getContractNo());
-                payment.setContractAmount(archiveInput.getAmount());
-                BizPayment collectionCondition = new BizPayment();
-                collectionCondition.setContractId(archiveInput.getId());
-                List<BizPayment> collections = paymentService.getListByBean(collectionCondition);
-                payment.setNonpayment(archiveInput.getAmount().subtract(BigDecimal.valueOf(collections.stream().mapToDouble(v -> v.getAmount().doubleValue()).sum())).compareTo(BigDecimal.ZERO) > 0);
+                payment.setContractAmount(archiveInput.getTrueAmount());
+                BizPayment payemntConditions = new BizPayment();
+                payemntConditions.setContractId(archiveInput.getId());
+                payemntConditions.setVerifyStatus((byte)1);
+                List<BizPayment> payed = paymentService.getListByBean(payemntConditions);
+//                payment.setNonpayment(archiveInput.getAmount().subtract(BigDecimal.valueOf(collections.stream().mapToDouble(v -> v.getAmount().doubleValue()).sum())).compareTo(BigDecimal.ZERO) > 0);
+                payment.setPayedAmount(BigDecimal.valueOf(payed.stream().mapToDouble(v -> v.getAmount().doubleValue()).sum()));
             }
             SysFileStorage fileConditions = new SysFileStorage();
             fileConditions.setMasterId(payment.getId());
@@ -229,6 +254,8 @@ public class BizPaymentController extends BaseController {
 
     @ApiOperation("审核")
     @PostMapping("/verified")
+    @Log(title = "支付审核", businessType = BusinessType.UPDATE)
+    @PreAuthorize("@ss.hasPermi('business:payment:submitVerify')")
     @Transactional(rollbackFor = Exception.class)
     public AjaxResult verified(@RequestBody BizPayment payment) {
         try {
@@ -239,5 +266,4 @@ public class BizPaymentController extends BaseController {
         }
     }
 
-
 }

+ 2 - 0
src/main/java/cn/ezhizao/project/business/payment/domain/BizPayment.java

@@ -157,4 +157,6 @@ public class BizPayment extends BaseEntity {
     private Timestamp verifyEndDate;
     @TableField(exist = false)
     private String keyword;
+    @TableField(exist = false)
+    private BigDecimal payedAmount;
 }

+ 4 - 0
src/main/java/cn/ezhizao/project/business/payment/mapper/BizPaymentMapper.java

@@ -35,6 +35,10 @@ public interface BizPaymentMapper extends BaseMapper<BizPayment> {
     int getTotal(Map<String,Object> conditions);
 
     List<BizPayment> getList(BizPayment collectionCondition);
+
+    List<BizPayment> getByIds(List<Long> ids);
+
+    boolean removePaymentDetail(List<Long> ids);
 }
 
 

+ 5 - 0
src/main/java/cn/ezhizao/project/business/payment/service/IBizPaymentService.java

@@ -32,4 +32,9 @@ public interface IBizPaymentService extends IService<BizPayment> {
      int getTotal(Map<String,Object> conditions);
 
     List<BizPayment> getListByBean(BizPayment collectionCondition);
+
+
+    List<BizPayment> getByIds(List<Long> ids);
+
+    boolean removePaymentDetail(List<Long> ids);
 }

+ 10 - 0
src/main/java/cn/ezhizao/project/business/payment/service/impl/BizPaymentServiceImpl.java

@@ -42,4 +42,14 @@ public class BizPaymentServiceImpl extends ServiceImpl<BizPaymentMapper, BizPaym
     public List<BizPayment> getListByBean(BizPayment collectionCondition) {
         return bizPaymentMapper.getList(collectionCondition);
     }
+
+    @Override
+    public List<BizPayment> getByIds(List<Long> ids) {
+        return bizPaymentMapper.getByIds(ids);
+    }
+
+    @Override
+    public boolean removePaymentDetail(List<Long> ids) {
+        return bizPaymentMapper.removePaymentDetail(ids);
+    }
 }

+ 7 - 0
src/main/resources/mybatis/business/BizArchiveInputDetailMapper.xml

@@ -6,8 +6,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <resultMap type="cn.ezhizao.project.business.order.domain.BizArchiveInputDetail" id="BizArchiveInputDetailResult">
         <id column="id" property="id"/>
+        <association property="arrived" column="id" select="getArrived" javaType="java.math.BigDecimal" />
     </resultMap>
 
+    <select id="getArrived" resultType="java.math.BigDecimal">
+        SELECT sum(t1.arrive_amount) from biz_collection_detail t1
+        left join biz_collection t2 on t2.id = t1.collection_id
+        where t1.deleted = 0 and t1.contract_detail_id = #{id} and t2.status = 1
+    </select>
 
     <select id="getList" parameterType="BizArchiveInputDetail" resultMap="BizArchiveInputDetailResult">
         SELECT t1.*, t2.name as task_type_name, t2.pay_address
@@ -15,6 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         left join biz_task_type t2 on t2.id = t1.task_type_id
         <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
             t1.deleted = 0
+            <if test="id != null "> AND t1.id = #{id}</if>
             <if test="companyId != null "> AND t1.company_id = #{companyId}</if>
             <if test="contractId != null "> AND t1.contract_id = #{contractId}</if>
             <if test="serviceNum != null "> AND t1.service_num = #{serviceNum}</if>

+ 2 - 1
src/main/resources/mybatis/business/BizArchiveInputMapper.xml

@@ -16,7 +16,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         t2.social_credit_code as social_credit_code,
         t3.nick_name as signer_name,
         t4.title as source_category_name,
-        t4.referrer_data_source
+        t4.referrer_data_source,
+        (select sum(t5.amount) from biz_payment t5 where t5.contract_id = t1.id and t5.verify_status = 1) as paid_amount
         FROM biz_archive_input t1
         left join biz_company t2 on t2.id = t1.company_id
         left join sys_user t3 on t3.user_id = t1.signer_id

+ 23 - 0
src/main/resources/mybatis/business/BizPaymentMapper.xml

@@ -12,6 +12,9 @@
         <if test="id != null">
             AND id = #{id}
         </if>
+        <if test="paymentId != null">
+            AND payment_id = #{paymentId}
+        </if>
     </delete>
 
     <!--带条件的List查询-->
@@ -20,6 +23,20 @@
         order by id desc
     </select>
 
+    <select id="getByIds" resultMap="BaseResultMap">
+        SELECT * FROM biz_payment
+        WHERE id IN <foreach item="id" index="index" collection="ids" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </select>
+
+    <update id="removePaymentDetail">
+        UPDATE biz_payment_detail set deleted = 1 FROM biz_payment_detail WHERE payment_id IN
+        <foreach item="id" index="index" collection="ids" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </update>
+
     <!--带条件的List查询 数据总条数-->
     <select id="getTotal" resultType="java.lang.Integer">
         SELECT COUNT(1) FROM (<include refid="getListSql"/>) AS C
@@ -27,6 +44,9 @@
 
     <sql id="getListSql">
         SELECT t1.id, t1.flow_no, t1.form_date, t1.subsidiary_id, t1.subsidiary, t1.subsidiary_name,
+        t1.contract_id,
+        t1.verify_date,
+        t1.verify_comment,
         t1.subsidiary_bank_account
         , t1.subsidiary_bank_name, t1.company_id, case when b.id is null then t1.company_name else b.name end as
         company_name, t1.amount, t1.payment_cause_id, t1.payment_status
@@ -54,6 +74,9 @@
         <if test="tenantId != null">
             AND t1.tenant_id = #{tenantId}
         </if>
+        <if test="contractId != null">
+            AND t1.contract_id = #{contractId}
+        </if>
         <if test="flowNo != null and flowNo != ''">
             AND t1.flow_no = #{flowNo}
         </if>