yzc 1 年之前
父節點
當前提交
1bc4f169b9

+ 46 - 0
hx-account/src/main/java/com/fjhx/account/controller/write/WriteOffRecordsController.java

@@ -0,0 +1,46 @@
+package com.fjhx.account.controller.write;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.account.entity.write.dto.WriteOffRecordsDto;
+import com.fjhx.account.entity.write.dto.WriteOffRecordsSelectDto;
+import com.fjhx.account.entity.write.vo.WriteOffRecordsVo;
+import com.fjhx.account.service.write.WriteOffRecordsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+
+/**
+ * <p>
+ * 冲销记录表 前端控制器
+ * </p>
+ *
+ * @author
+ * @since 2023-07-12
+ */
+@RestController
+@RequestMapping("/writeOffRecords")
+public class WriteOffRecordsController {
+
+    @Autowired
+    private WriteOffRecordsService writeOffRecordsService;
+
+    /**
+     * 冲销记录表分页
+     */
+    @PostMapping("/page")
+    public Page<WriteOffRecordsVo> page(@RequestBody WriteOffRecordsSelectDto dto) {
+        return writeOffRecordsService.getPage(dto);
+    }
+
+    /**
+     * 冲销记录表新增
+     */
+    @PostMapping("/add")
+    public void add(@RequestBody WriteOffRecordsDto writeOffRecordsDto) {
+        writeOffRecordsService.add(writeOffRecordsDto);
+    }
+
+}

+ 17 - 0
hx-account/src/main/java/com/fjhx/account/entity/write/dto/WriteOffRecordsDto.java

@@ -0,0 +1,17 @@
+package com.fjhx.account.entity.write.dto;
+
+import com.fjhx.account.entity.write.po.WriteOffRecords;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 冲销记录表新增编辑入参实体
+ *
+ * @author
+ * @since 2023-07-12
+ */
+@Getter
+@Setter
+public class WriteOffRecordsDto extends WriteOffRecords {
+
+}

+ 27 - 0
hx-account/src/main/java/com/fjhx/account/entity/write/dto/WriteOffRecordsSelectDto.java

@@ -0,0 +1,27 @@
+package com.fjhx.account.entity.write.dto;
+
+import com.ruoyi.common.core.domain.BaseSelectDto;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 冲销记录表列表查询入参实体
+ *
+ * @author
+ * @since 2023-07-12
+ */
+@Getter
+@Setter
+public class WriteOffRecordsSelectDto extends BaseSelectDto {
+
+    /**
+     * 归属公司
+     */
+    private Long corporationId;
+
+    /**
+     * 数据来源过滤
+     */
+    private Integer type;
+
+}

+ 38 - 0
hx-account/src/main/java/com/fjhx/account/entity/write/po/WriteOffRecords.java

@@ -0,0 +1,38 @@
+package com.fjhx.account.entity.write.po;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.common.core.domain.BasePo;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+
+/**
+ * <p>
+ * 冲销记录表
+ * </p>
+ *
+ * @author
+ * @since 2023-07-12
+ */
+@Getter
+@Setter
+@TableName("write_off_records")
+public class WriteOffRecords extends BasePo {
+
+    /**
+     * 打款id
+     */
+    private Long accountPaymentId;
+
+    /**
+     * 打款时间
+     */
+    private Date accountPaymentDate;
+
+    /**
+     * 冲销原因
+     */
+    private String remark;
+
+}

+ 58 - 0
hx-account/src/main/java/com/fjhx/account/entity/write/vo/WriteOffRecordsVo.java

@@ -0,0 +1,58 @@
+package com.fjhx.account.entity.write.vo;
+
+import com.fjhx.account.entity.write.po.WriteOffRecords;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 冲销记录表列表查询返回值实体
+ *
+ * @author
+ * @since 2023-07-12
+ */
+@Getter
+@Setter
+public class WriteOffRecordsVo extends WriteOffRecords {
+
+    /**
+     * 归属公司
+     */
+    private Long corporationId;
+    /**
+     * 数据来源
+     */
+    private Integer type;
+    /**
+     * 合同编号列表
+     */
+    private String contractCodes;
+    /**
+     * 申请时间
+     */
+    private Date applicationTime;
+    /**
+     * 申请金额
+     */
+    private BigDecimal amount;
+    /**
+     * 币种
+     */
+    private String currency;
+    /**
+     * 打款业务id
+     */
+    private Long businessId;
+
+    /**
+     * 归属公司名称
+     */
+    private String corporationName;
+    /**
+     * 冲销人名称
+     */
+    private String WriteOffUserName;
+
+}

+ 26 - 0
hx-account/src/main/java/com/fjhx/account/mapper/write/WriteOffRecordsMapper.java

@@ -0,0 +1,26 @@
+package com.fjhx.account.mapper.write;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.account.entity.write.po.WriteOffRecords;
+import com.fjhx.account.entity.write.vo.WriteOffRecordsVo;
+import com.ruoyi.common.utils.wrapper.IWrapper;
+import org.apache.ibatis.annotations.Param;
+
+
+/**
+ * <p>
+ * 冲销记录表 Mapper 接口
+ * </p>
+ *
+ * @author
+ * @since 2023-07-12
+ */
+public interface WriteOffRecordsMapper extends BaseMapper<WriteOffRecords> {
+
+    /**
+     * 冲销记录表分页
+     */
+    Page<WriteOffRecordsVo> getPage(@Param("page") Page<Object> page, @Param("ew") IWrapper<WriteOffRecords> wrapper);
+
+}

+ 31 - 0
hx-account/src/main/java/com/fjhx/account/service/write/WriteOffRecordsService.java

@@ -0,0 +1,31 @@
+package com.fjhx.account.service.write;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.account.entity.write.dto.WriteOffRecordsDto;
+import com.fjhx.account.entity.write.dto.WriteOffRecordsSelectDto;
+import com.fjhx.account.entity.write.po.WriteOffRecords;
+import com.fjhx.account.entity.write.vo.WriteOffRecordsVo;
+import com.ruoyi.common.core.service.BaseService;
+
+
+/**
+ * <p>
+ * 冲销记录表 服务类
+ * </p>
+ *
+ * @author
+ * @since 2023-07-12
+ */
+public interface WriteOffRecordsService extends BaseService<WriteOffRecords> {
+
+    /**
+     * 冲销记录表分页
+     */
+    Page<WriteOffRecordsVo> getPage(WriteOffRecordsSelectDto dto);
+
+    /**
+     * 冲销记录表新增
+     */
+    void add(WriteOffRecordsDto writeOffRecordsDto);
+
+}

+ 100 - 0
hx-account/src/main/java/com/fjhx/account/service/write/impl/WriteOffRecordsServiceImpl.java

@@ -0,0 +1,100 @@
+package com.fjhx.account.service.write.impl;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.account.entity.account.po.AccountPayment;
+import com.fjhx.account.entity.account.po.AccountRemainder;
+import com.fjhx.account.entity.account.po.AccountRunningWater;
+import com.fjhx.account.entity.write.dto.WriteOffRecordsDto;
+import com.fjhx.account.entity.write.dto.WriteOffRecordsSelectDto;
+import com.fjhx.account.entity.write.po.WriteOffRecords;
+import com.fjhx.account.entity.write.vo.WriteOffRecordsVo;
+import com.fjhx.account.mapper.write.WriteOffRecordsMapper;
+import com.fjhx.account.service.account.AccountPaymentService;
+import com.fjhx.account.service.account.AccountRemainderService;
+import com.fjhx.account.service.account.AccountRunningWaterService;
+import com.fjhx.account.service.write.WriteOffRecordsService;
+import com.fjhx.common.service.corporation.CorporationService;
+import com.fjhx.common.utils.Assert;
+import com.fjhx.file.utils.ObsFileUtil;
+import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.wrapper.IWrapper;
+import com.ruoyi.system.utils.UserUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+
+/**
+ * <p>
+ * 冲销记录表 服务实现类
+ * </p>
+ *
+ * @author
+ * @since 2023-07-12
+ */
+@Service
+public class WriteOffRecordsServiceImpl extends ServiceImpl<WriteOffRecordsMapper, WriteOffRecords> implements WriteOffRecordsService {
+    @Autowired
+    private CorporationService corporationService;
+    @Autowired
+    private AccountPaymentService accountPaymentService;
+    @Autowired
+    private AccountRemainderService accountRemainderService;
+    @Autowired
+    private AccountRunningWaterService accountRunningWaterService;
+
+    @Override
+    public Page<WriteOffRecordsVo> getPage(WriteOffRecordsSelectDto dto) {
+        IWrapper<WriteOffRecords> wrapper = getWrapper();
+        wrapper.eq("ap.corporation_id", dto.getCorporationId());
+        wrapper.eq("ap.type", dto.getType());
+        wrapper.orderByDesc("wor", WriteOffRecords::getId);
+        Page<WriteOffRecordsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
+        List<WriteOffRecordsVo> records = page.getRecords();
+        //赋值归属公司
+        corporationService.attributeAssign(records, WriteOffRecordsVo::getCorporationId, (item, corporation) -> {
+            item.setCorporationName(corporation.getName());
+        });
+        //赋值冲销人
+        UserUtil.assignmentNickName(records, WriteOffRecordsVo::getCreateUser, WriteOffRecordsVo::setWriteOffUserName);
+        return page;
+    }
+
+    @Override
+    @DSTransactional
+    public void add(WriteOffRecordsDto writeOffRecordsDto) {
+        Assert.notEmpty(writeOffRecordsDto.getAccountPaymentId(), "打款id不能为空");
+        AccountPayment accountPayment = accountPaymentService.getById(writeOffRecordsDto.getAccountPaymentId());
+        Assert.notEmpty(accountPayment, "查询不到打款信息");
+        //修改打款状态为未打款
+        accountPayment.setStatus("20");
+        accountPaymentService.updateById(accountPayment);
+        //清理历史附件
+        ObsFileUtil.removeFile(accountPayment.getId());
+        //赋值之前的打款时间
+        writeOffRecordsDto.setAccountPaymentDate(accountPayment.getExpensesTime());
+        this.save(writeOffRecordsDto);
+        //根据币种回滚余额
+        AccountRemainder accountRemainder = accountRemainderService.getOne(Wrappers.<AccountRemainder>lambdaQuery()
+                .eq(AccountRemainder::getAccountManagementId, accountPayment.getAccountManagementId())
+                .eq(AccountRemainder::getCurrency, accountPayment.getCurrency()));
+        // 如果不存在这条数据则返回币种不存在
+        if (ObjectUtil.isEmpty(accountRemainder)) {
+            throw new ServiceException("该账户不存在此币种,请前往资金账户添加");
+        }
+        accountRemainderService.update(q -> q
+                .eq(AccountRemainder::getId, accountRemainder.getId())
+                .setSql("remainder = remainder + " + accountPayment.getAmount())
+        );
+        //删除打款对应的流水
+        AccountRunningWater accountRunningWater = accountRunningWaterService.getOne(q -> q.eq(AccountRunningWater::getBusinessId, accountPayment.getId()));
+        Assert.notEmpty(accountRunningWater, "查询不到打款流水信息");
+        accountRunningWaterService.removeById(accountRunningWater);
+    }
+
+}

+ 34 - 0
hx-account/src/main/resources/mapper/write/WriteOffRecordsMapper.xml

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fjhx.account.mapper.write.WriteOffRecordsMapper">
+    <select id="getPage" resultType="com.fjhx.account.entity.write.vo.WriteOffRecordsVo">
+        select wor.id,
+               wor.account_payment_id,
+               wor.account_payment_date,
+               wor.remark,
+               wor.create_user,
+               wor.create_time,
+               wor.update_user,
+               wor.update_time,
+               ap.corporation_id,
+               ap.type,
+               ap.currency,
+               ap.business_id,
+               if(type!=20,
+                  (SELECT GROUP_CONCAT(t4.`code`)
+                   FROM account_request_funds t2
+                            LEFT JOIN account_request_funds_detail t3 ON t2.id = t3.account_request_funds_id
+                            LEFT JOIN `bytesailing_sale`.contract t4 ON t3.contract_id = t4.id
+                   where ap.business_id = t2.id),
+                  (SELECT GROUP_CONCAT(if(c.`code` is null, p.`code`, c.`code`))
+                   FROM bytesailing_purchase.pay pa
+                            LEFT JOIN bytesailing_purchase.pay_detail pad ON pad.pay_id = pa.id LEFT JOIN bytesailing_purchase.purchase p ON pad.purchase_id = p.id LEFT JOIN bytesailing_sale.contract c ON p.data_resource_id = c.id WHERE ap.business_id = pa.id)
+	        )                 as contractCodes,
+               ap.create_time as applicationTime,
+               ap.amount
+        from write_off_records wor
+                 LEFT JOIN account_payment ap ON wor.account_payment_id = ap.id
+            ${ew.customSqlSegment}
+    </select>
+
+</mapper>