浏览代码

资金流水页面,填写了“合同到账”类型数据后,发送业务提醒

24282 2 年之前
父节点
当前提交
8e06fe57db

+ 4 - 4
hx-account/src/main/java/com/fjhx/account/entity/account/po/AccountRunningWater.java

@@ -1,14 +1,14 @@
 package com.fjhx.account.entity.account.po;
 
 import com.baomidou.mybatisplus.annotation.TableField;
-import com.ruoyi.common.core.domain.BasePo;
 import com.baomidou.mybatisplus.annotation.TableName;
-import java.math.BigDecimal;
-import java.util.Date;
+import com.ruoyi.common.core.domain.BasePo;
 import lombok.Getter;
 import lombok.Setter;
 
 import javax.validation.constraints.NotBlank;
+import java.math.BigDecimal;
+import java.util.Date;
 
 /**
  * <p>
@@ -33,7 +33,6 @@ public class AccountRunningWater extends BasePo {
      */
     private Long businessId;
 
-
     /**
      * 流水类型。10:打款
      */
@@ -100,4 +99,5 @@ public class AccountRunningWater extends BasePo {
      */
     @TableField(exist = false)
     private Integer count;
+
 }

+ 70 - 28
hx-account/src/main/java/com/fjhx/account/service/account/impl/AccountRunningWaterServiceImpl.java

@@ -2,6 +2,7 @@ package com.fjhx.account.service.account.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -10,10 +11,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.account.entity.account.bo.AccountRunningWaterBo;
 import com.fjhx.account.entity.account.dto.AccountRunningWaterDto;
 import com.fjhx.account.entity.account.dto.AccountRunningWaterSelectDto;
+import com.fjhx.account.entity.account.po.AccountManagement;
 import com.fjhx.account.entity.account.po.AccountRemainder;
 import com.fjhx.account.entity.account.po.AccountRunningWater;
 import com.fjhx.account.entity.account.vo.AccountRunningWaterVo;
 import com.fjhx.account.mapper.account.AccountRunningWaterMapper;
+import com.fjhx.account.service.account.AccountManagementService;
 import com.fjhx.account.service.account.AccountRemainderService;
 import com.fjhx.account.service.account.AccountRunningWaterService;
 import com.fjhx.common.constant.SourceConstant;
@@ -21,6 +24,7 @@ import com.fjhx.common.entity.corporation.po.Corporation;
 import com.fjhx.common.service.corporation.CorporationService;
 import com.fjhx.common.utils.Assert;
 import com.fjhx.item.util.excel.util.ExcelUtil;
+import com.fjhx.socket.service.WebSocketServer;
 import com.fjhx.tenant.entity.dict.dto.DictTenantDataSelectDto;
 import com.fjhx.tenant.entity.dict.vo.DictTenantDataVo;
 import com.fjhx.tenant.service.dict.DictTenantDataService;
@@ -48,25 +52,29 @@ import java.util.stream.Collectors;
  */
 @Service
 public class AccountRunningWaterServiceImpl extends ServiceImpl<AccountRunningWaterMapper, AccountRunningWater> implements AccountRunningWaterService {
+
     @Autowired
     private AccountRemainderService accountRemainderService;
 
     @Autowired
     private DictTenantDataService dictTenantDataService;
+
     @Autowired
     private CorporationService corporationService;
 
+    @Autowired
+    private AccountManagementService accountManagementService;
 
     @Override
     public Page<AccountRunningWaterVo> getPage(AccountRunningWaterSelectDto dto) {
         QueryWrapper<Object> wrapper = Wrappers.query();
-        //资金账户
+        // 资金账户
         wrapper.eq(ObjectUtil.isNotEmpty(dto.getAccountManagementId()), "arw.account_management_id", dto.getAccountManagementId());
-        //交易类型
+        // 交易类型
         wrapper.eq(ObjectUtil.isNotEmpty(dto.getStatus()), "arw.status", dto.getStatus());
-        //是否合同到账
+        // 是否合同到账
         wrapper.eq(ObjectUtil.isNotEmpty(dto.getReceived()), "arw.received", dto.getReceived());
-        //币种
+        // 币种
         wrapper.eq(ObjectUtil.isNotEmpty(dto.getCurrency()), "arw.currency", dto.getCurrency());
         //是否认领
         wrapper.eq(ObjectUtil.isNotEmpty(dto.getIsClaim()), "arw.is_claim", dto.getIsClaim());
@@ -161,30 +169,64 @@ public class AccountRunningWaterServiceImpl extends ServiceImpl<AccountRunningWa
      */
     @Override
     @Transactional(rollbackFor = {Exception.class})
-    public void add(AccountRunningWaterDto accountRunningWaterDto) {
+    public void add(AccountRunningWaterDto dto) {
 
-        //修改账户余额表的余额
+        // 修改账户余额表的余额
         AccountRemainder accountRemainder = accountRemainderService.getOne(Wrappers.<AccountRemainder>lambdaQuery()
-                .eq(AccountRemainder::getAccountManagementId, accountRunningWaterDto.getAccountManagementId())
-                .eq(AccountRemainder::getCurrency, accountRunningWaterDto.getCurrency())
+                .eq(AccountRemainder::getAccountManagementId, dto.getAccountManagementId())
+                .eq(AccountRemainder::getCurrency, dto.getCurrency())
         );
         if (ObjectUtil.isEmpty(accountRemainder)) {
             throw new ServiceException("该账户不存在此币种,请前往资金账户添加");
         }
-        accountRemainder.setStatus(accountRunningWaterDto.getStatus());
-        //修改变更余额
-        accountRemainder.setChangeRemainder(accountRunningWaterDto.getAmount());
-        if (accountRunningWaterDto.getStatus().equals("10")) {
-            accountRemainder.setRemainder(accountRemainder.getRemainder().add(accountRunningWaterDto.getAmount()));
-        } else if (accountRunningWaterDto.getStatus().equals("20")) {
-            if (accountRemainder.getRemainder().compareTo(accountRunningWaterDto.getAmount()) == -1) {
+        accountRemainder.setStatus(dto.getStatus());
+        // 修改变更余额
+        accountRemainder.setChangeRemainder(dto.getAmount());
+        if (dto.getStatus().equals("10")) {
+            accountRemainder.setRemainder(accountRemainder.getRemainder().add(dto.getAmount()));
+        } else if (dto.getStatus().equals("20")) {
+            if (accountRemainder.getRemainder().compareTo(dto.getAmount()) < 0) {
                 throw new ServiceException("账户余额不足");
             } else {
-                accountRemainder.setRemainder(accountRemainder.getRemainder().subtract(accountRunningWaterDto.getAmount()));
+                accountRemainder.setRemainder(accountRemainder.getRemainder().subtract(dto.getAmount()));
             }
         }
         accountRemainderService.updateById(accountRemainder);
-        this.save(accountRunningWaterDto);
+        this.save(dto);
+
+        // 发送消息推送
+        sendSocket(dto);
+    }
+
+
+    private void sendSocket(AccountRunningWaterDto dto) {
+
+        if (ObjectUtil.notEqual(dto.getStatus(), "10") || ObjectUtil.notEqual(dto.getReceived(), "10")) {
+            return;
+        }
+
+        // 账户id
+        Long accountManagementId = dto.getAccountManagementId();
+        AccountManagement accountManagement = accountManagementService.getById(accountManagementId);
+        if (accountManagement == null) {
+            throw new ServiceException("没有找到公司账户");
+        }
+
+        // 归属公司
+        Long corporationId = accountManagement.getCorporationId();
+        if (corporationId == null) {
+            throw new ServiceException("归属公司id为空");
+        }
+        Corporation corporation = corporationService.getById(corporationId);
+        if (corporation == null) {
+            throw new ServiceException("没有找到归属公司");
+        }
+
+        String msg = "{} - {}账户有一笔新的到账(金额:{} {}),请相应业务员进行认领。";
+
+        WebSocketServer.sendInfoGroup(0, StrUtil.format(
+                msg, corporation.getName(), accountManagement.getName(), dto.getCurrency(), dto.getAmount()));
+
     }
 
 
@@ -194,17 +236,17 @@ public class AccountRunningWaterServiceImpl extends ServiceImpl<AccountRunningWa
     @Override
     @Transactional(rollbackFor = {Exception.class})
     public void edit(AccountRunningWater accountRunningWaterDto) {
-//        //查询资金流水表的数据
-//        AccountRunningWater accountRunningWater = this.getById(accountRunningWaterDto.getId());
-//
-//        //修改账户余额表的余额
-//        AccountRemainder accountRemainder = accountRemainderService.getOne(Wrappers.<AccountRemainder>lambdaQuery()
-//                .eq(AccountRemainder::getAccountManagementId,accountRunningWater.getAccountManagementId())
-//                .eq(AccountRemainder::getCurrency,accountRunningWater.getCurrency())
-//        );
-//        if (accountRemainder.getStatus().equals("10")){
-//            if (accountRemainder.getRemainder().compareTo(accountRunningWater.getAmount())==1)
-//        }
+        //        //查询资金流水表的数据
+        //        AccountRunningWater accountRunningWater = this.getById(accountRunningWaterDto.getId());
+        //
+        //        //修改账户余额表的余额
+        //        AccountRemainder accountRemainder = accountRemainderService.getOne(Wrappers.<AccountRemainder>lambdaQuery()
+        //                .eq(AccountRemainder::getAccountManagementId,accountRunningWater.getAccountManagementId())
+        //                .eq(AccountRemainder::getCurrency,accountRunningWater.getCurrency())
+        //        );
+        //        if (accountRemainder.getStatus().equals("10")){
+        //            if (accountRemainder.getRemainder().compareTo(accountRunningWater.getAmount())==1)
+        //        }
 
         this.updateById(accountRunningWaterDto);
     }