|
@@ -3,6 +3,7 @@ package cn.com.ctop.finance.payment.service.impl;
|
|
import cn.com.ctop.common.module.entity.Advertiser;
|
|
import cn.com.ctop.common.module.entity.Advertiser;
|
|
import cn.com.ctop.common.module.entity.Product;
|
|
import cn.com.ctop.common.module.entity.Product;
|
|
import cn.com.ctop.common.module.entity.Project;
|
|
import cn.com.ctop.common.module.entity.Project;
|
|
|
|
+import cn.com.ctop.common.module.entity.UserAllocation;
|
|
import cn.com.ctop.common.module.service.IMessageTemplate;
|
|
import cn.com.ctop.common.module.service.IMessageTemplate;
|
|
import cn.com.ctop.common.module.service.IProductService;
|
|
import cn.com.ctop.common.module.service.IProductService;
|
|
import cn.com.ctop.common.module.service.IProjectService;
|
|
import cn.com.ctop.common.module.service.IProjectService;
|
|
@@ -32,6 +33,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -83,37 +85,42 @@ public class FinancePaymentRechargeApplicationServiceImpl extends ServiceImpl<Fi
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Result add(JSONObject data) {
|
|
public Result add(JSONObject data) {
|
|
- JSONArray list = data.getJSONArray("list");
|
|
|
|
- FinancePaymentRechargeApplication recharge = JSONObject.parseObject(JSONObject.toJSONString(data), FinancePaymentRechargeApplication.class);
|
|
|
|
- FinancePaymentPool pool = financePaymentPoolService.getIdByUniqueKey(recharge.getAdvertiserId(), recharge.getProductId(), recharge.getPaymentMedia());
|
|
|
|
- if (Check.isNull(pool) || Check.isNull(list)) {
|
|
|
|
- return Result.error("数据异常");
|
|
|
|
- }
|
|
|
|
- SysUser user = userService.getById(recharge.getApplicanterId());
|
|
|
|
- if (!Check.isNull(user)) {
|
|
|
|
- recharge.setApplicanter(user.getRealname());
|
|
|
|
- }
|
|
|
|
- Product product = productService.getById(recharge.getProductId());
|
|
|
|
- if (!Check.isNull(product)) {
|
|
|
|
- recharge.setProductName(product.getProductName());
|
|
|
|
- data.put("productName", product.getProductName());
|
|
|
|
- }
|
|
|
|
- List<String> advertiserIds = Arrays.asList(recharge.getAdvertiserId().split(","));
|
|
|
|
- Advertiser advertiser = advertiserService.getById(advertiserIds.get(0));
|
|
|
|
- if (!Check.isNull(advertiser)) {
|
|
|
|
- recharge.setAdvertiserName(advertiser.getName());
|
|
|
|
- data.put("advertiserName", advertiser.getName());
|
|
|
|
- }
|
|
|
|
- Project project = projectService.getById(recharge.getProjectId());
|
|
|
|
- if (!Check.isNull(project)) {
|
|
|
|
- recharge.setProjectName(project.getProjectName());
|
|
|
|
- data.put("projectName", project.getProjectName());
|
|
|
|
- }
|
|
|
|
- //判断审核人和状态
|
|
|
|
- getReviewedRole(recharge);
|
|
|
|
- recharge.setPoolId(pool.getId());
|
|
|
|
- boolean save = this.save(recharge);
|
|
|
|
- if (save) {
|
|
|
|
|
|
+ try {
|
|
|
|
+ JSONArray list = data.getJSONArray("list");
|
|
|
|
+ FinancePaymentRechargeApplication recharge = JSONObject.parseObject(JSONObject.toJSONString(data), FinancePaymentRechargeApplication.class);
|
|
|
|
+ FinancePaymentPool pool = financePaymentPoolService.getIdByUniqueKey(recharge.getAdvertiserId(), recharge.getProductId(), recharge.getPaymentMedia());
|
|
|
|
+ if (Check.isNull(pool) || Check.isNull(list)) {
|
|
|
|
+ return Result.error("数据异常");
|
|
|
|
+ }
|
|
|
|
+ SysUser user = userService.getById(recharge.getApplicanterId());
|
|
|
|
+ if (!Check.isNull(user)) {
|
|
|
|
+ recharge.setApplicanter(user.getRealname());
|
|
|
|
+ }
|
|
|
|
+ Product product = productService.getById(recharge.getProductId());
|
|
|
|
+ if (!Check.isNull(product)) {
|
|
|
|
+ recharge.setProductName(product.getProductName());
|
|
|
|
+ data.put("productName", product.getProductName());
|
|
|
|
+ }
|
|
|
|
+ List<String> advertiserIds = Arrays.asList(recharge.getAdvertiserId().split(","));
|
|
|
|
+ Advertiser advertiser = advertiserService.getById(advertiserIds.get(0));
|
|
|
|
+ if (!Check.isNull(advertiser)) {
|
|
|
|
+ recharge.setAdvertiserName(advertiser.getName());
|
|
|
|
+ data.put("advertiserName", advertiser.getName());
|
|
|
|
+ }
|
|
|
|
+ Project project = projectService.getById(recharge.getProjectId());
|
|
|
|
+ if (!Check.isNull(project)) {
|
|
|
|
+ recharge.setProjectName(project.getProjectName());
|
|
|
|
+ data.put("projectName", project.getProjectName());
|
|
|
|
+ }
|
|
|
|
+ //判断审核人和状态
|
|
|
|
+ getReviewedRole(recharge);
|
|
|
|
+ recharge.setPoolId(pool.getId());
|
|
|
|
+ //添加申请记录
|
|
|
|
+ insertRecord(recharge.getId(), recharge.getApplicanterId(), "0", null, recharge.getFiles(), new Date());
|
|
|
|
+
|
|
|
|
+ Thread.sleep(100);
|
|
|
|
+
|
|
|
|
+ this.save(recharge);
|
|
//添加充值账户信息
|
|
//添加充值账户信息
|
|
List<FinancePaymentRechargeAccount> accountList = new ArrayList<>();
|
|
List<FinancePaymentRechargeAccount> accountList = new ArrayList<>();
|
|
String accountIds = "";
|
|
String accountIds = "";
|
|
@@ -123,7 +130,10 @@ public class FinancePaymentRechargeApplicationServiceImpl extends ServiceImpl<Fi
|
|
account.setRechargeId(recharge.getId());
|
|
account.setRechargeId(recharge.getId());
|
|
account.setProjectId(recharge.getProjectId());
|
|
account.setProjectId(recharge.getProjectId());
|
|
account.setAccountId(obj.getLong("accountId"));
|
|
account.setAccountId(obj.getLong("accountId"));
|
|
- account.setAccountName(userAllocationService.getByAccountId(obj.getLong("accountId")).getAuthName());
|
|
|
|
|
|
+ UserAllocation allocation = userAllocationService.getByAccountId(obj.getLong("accountId"));
|
|
|
|
+ if (!Check.isNull(allocation)) {
|
|
|
|
+ account.setAccountName(allocation.getAuthName());
|
|
|
|
+ }
|
|
account.setCashAmount(obj.getBigDecimal("cashAmount"));
|
|
account.setCashAmount(obj.getBigDecimal("cashAmount"));
|
|
account.setReceivedAmount(obj.getBigDecimal("receivedAmount"));
|
|
account.setReceivedAmount(obj.getBigDecimal("receivedAmount"));
|
|
account.setRebateType(obj.getString("rebateType"));
|
|
account.setRebateType(obj.getString("rebateType"));
|
|
@@ -132,8 +142,6 @@ public class FinancePaymentRechargeApplicationServiceImpl extends ServiceImpl<Fi
|
|
accountIds += obj.getLong("accountId") + ",";
|
|
accountIds += obj.getLong("accountId") + ",";
|
|
}
|
|
}
|
|
rechargeAccountService.saveBatch(accountList);
|
|
rechargeAccountService.saveBatch(accountList);
|
|
- //添加申请记录
|
|
|
|
- insertRecord(recharge.getId(), recharge.getApplicanterId(), "0", null, recharge.getFiles());
|
|
|
|
//消息通知内容
|
|
//消息通知内容
|
|
String message = null;
|
|
String message = null;
|
|
List<SysUser> users = null;
|
|
List<SysUser> users = null;
|
|
@@ -150,14 +158,17 @@ public class FinancePaymentRechargeApplicationServiceImpl extends ServiceImpl<Fi
|
|
for (SysUser u : users) {
|
|
for (SysUser u : users) {
|
|
sendMessageService.sendMessage(u.getId(), message);
|
|
sendMessageService.sendMessage(u.getId(), message);
|
|
}
|
|
}
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
return Result.ok();
|
|
return Result.ok();
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Result<Object> edit(JSONObject data) {
|
|
|
|
|
|
+ public Result<Object> edit(JSONObject data) throws InterruptedException {
|
|
JSONArray list = data.getJSONArray("list");
|
|
JSONArray list = data.getJSONArray("list");
|
|
FinancePaymentRechargeApplication recharge = JSONObject.parseObject(JSONObject.toJSONString(data), FinancePaymentRechargeApplication.class);
|
|
FinancePaymentRechargeApplication recharge = JSONObject.parseObject(JSONObject.toJSONString(data), FinancePaymentRechargeApplication.class);
|
|
|
|
+ FinancePaymentRechargeApplication oldRecharge = this.getById(recharge.getId());
|
|
FinancePaymentPool pool = financePaymentPoolService.getIdByUniqueKey(recharge.getAdvertiserId(), recharge.getProductId(), recharge.getPaymentMedia());
|
|
FinancePaymentPool pool = financePaymentPoolService.getIdByUniqueKey(recharge.getAdvertiserId(), recharge.getProductId(), recharge.getPaymentMedia());
|
|
if (Check.isNull(pool) || Check.isNull(list)) {
|
|
if (Check.isNull(pool) || Check.isNull(list)) {
|
|
return Result.error("数据异常");
|
|
return Result.error("数据异常");
|
|
@@ -185,6 +196,13 @@ public class FinancePaymentRechargeApplicationServiceImpl extends ServiceImpl<Fi
|
|
//判断审核人和状态
|
|
//判断审核人和状态
|
|
getReviewedRole(recharge);
|
|
getReviewedRole(recharge);
|
|
recharge.setPoolId(pool.getId());
|
|
recharge.setPoolId(pool.getId());
|
|
|
|
+
|
|
|
|
+ //添 拒绝记录
|
|
|
|
+ insertRecord(recharge.getId(), oldRecharge.getReviewederId(), oldRecharge.getAuditStatus(), oldRecharge.getApprovalContent(), oldRecharge.getFiles(), oldRecharge.getUpdateTime());
|
|
|
|
+ //添加申请记录 -1 退回修改
|
|
|
|
+ insertRecord(recharge.getId(), recharge.getApplicanterId(), "-1", null, recharge.getFiles(), new Date());
|
|
|
|
+ Thread.sleep(100);
|
|
|
|
+
|
|
this.updateById(recharge);
|
|
this.updateById(recharge);
|
|
|
|
|
|
//添加充值账户信息
|
|
//添加充值账户信息
|
|
@@ -196,7 +214,10 @@ public class FinancePaymentRechargeApplicationServiceImpl extends ServiceImpl<Fi
|
|
account.setRechargeId(recharge.getId());
|
|
account.setRechargeId(recharge.getId());
|
|
account.setProjectId(recharge.getProjectId());
|
|
account.setProjectId(recharge.getProjectId());
|
|
account.setAccountId(obj.getLong("accountId"));
|
|
account.setAccountId(obj.getLong("accountId"));
|
|
- account.setAccountName(userAllocationService.getByAccountId(obj.getLong("accountId")).getAuthName());
|
|
|
|
|
|
+ UserAllocation acco = userAllocationService.getByAccountId(obj.getLong("accountId"));
|
|
|
|
+ if (!Check.isNull(acco)) {
|
|
|
|
+ account.setAccountName(acco.getAuthName());
|
|
|
|
+ }
|
|
account.setCashAmount(obj.getBigDecimal("cashAmount"));
|
|
account.setCashAmount(obj.getBigDecimal("cashAmount"));
|
|
account.setReceivedAmount(obj.getBigDecimal("receivedAmount"));
|
|
account.setReceivedAmount(obj.getBigDecimal("receivedAmount"));
|
|
account.setRebateType(obj.getString("rebateType"));
|
|
account.setRebateType(obj.getString("rebateType"));
|
|
@@ -206,9 +227,6 @@ public class FinancePaymentRechargeApplicationServiceImpl extends ServiceImpl<Fi
|
|
}
|
|
}
|
|
rechargeAccountService.delByRechargeId(recharge.getId());
|
|
rechargeAccountService.delByRechargeId(recharge.getId());
|
|
rechargeAccountService.saveBatch(accountList);
|
|
rechargeAccountService.saveBatch(accountList);
|
|
-
|
|
|
|
- //添加申请记录 -1 退回修改
|
|
|
|
- insertRecord(recharge.getId(), recharge.getApplicanterId(), "-1", null, recharge.getFiles());
|
|
|
|
//消息通知内容
|
|
//消息通知内容
|
|
String message = null;
|
|
String message = null;
|
|
List<SysUser> users = null;
|
|
List<SysUser> users = null;
|
|
@@ -240,12 +258,10 @@ public class FinancePaymentRechargeApplicationServiceImpl extends ServiceImpl<Fi
|
|
String reviewederId = oldRecharge.getReviewederId();
|
|
String reviewederId = oldRecharge.getReviewederId();
|
|
String auditStatus = recharge.getAuditStatus();//1-待审核、2-待充值、3-充值完成、4-临时充值、5-审核拒绝
|
|
String auditStatus = recharge.getAuditStatus();//1-待审核、2-待充值、3-充值完成、4-临时充值、5-审核拒绝
|
|
if ("2".equals(auditStatus)) {
|
|
if ("2".equals(auditStatus)) {
|
|
- recharge.setReviewederId(recharge.getUserId());
|
|
|
|
- SysUser user = userService.getById(recharge.getUserId());
|
|
|
|
- if (!Check.isNull(user)) {
|
|
|
|
- recharge.setRevieweder(user.getRealname());
|
|
|
|
- }
|
|
|
|
- this.updateById(recharge);
|
|
|
|
|
|
+ recharge.setReviewederId("meidaManager");
|
|
|
|
+ recharge.setRevieweder("-");
|
|
|
|
+ //添加审核记录 1:财务审核完成
|
|
|
|
+ insertRecord(recharge.getId(), recharge.getUserId(), "6", recharge.getApprovalContent(), recharge.getFiles(), new Date());
|
|
JSONObject oldData = JSONObject.parseObject(JSONObject.toJSONString(oldRecharge)).toJavaObject(JSONObject.class);
|
|
JSONObject oldData = JSONObject.parseObject(JSONObject.toJSONString(oldRecharge)).toJavaObject(JSONObject.class);
|
|
JSONObject amount = rechargeAccountService.queryAmounts(recharge.getId());
|
|
JSONObject amount = rechargeAccountService.queryAmounts(recharge.getId());
|
|
if (!Check.isNull(amount)) {
|
|
if (!Check.isNull(amount)) {
|
|
@@ -257,8 +273,7 @@ public class FinancePaymentRechargeApplicationServiceImpl extends ServiceImpl<Fi
|
|
for (SysUser u : users) {
|
|
for (SysUser u : users) {
|
|
sendMessageService.sendMessage(u.getId(), message);
|
|
sendMessageService.sendMessage(u.getId(), message);
|
|
}
|
|
}
|
|
- //添加审核记录 1:财务审核完成
|
|
|
|
- insertRecord(recharge.getId(), recharge.getUserId(), "1", recharge.getApprovalContent(), recharge.getFiles());
|
|
|
|
|
|
+ this.updateById(recharge);
|
|
} else if ("3".equals(auditStatus) || "4".equals(auditStatus)) {
|
|
} else if ("3".equals(auditStatus) || "4".equals(auditStatus)) {
|
|
recharge.setReviewederId(recharge.getUserId());
|
|
recharge.setReviewederId(recharge.getUserId());
|
|
SysUser user = userService.getById(recharge.getUserId());
|
|
SysUser user = userService.getById(recharge.getUserId());
|
|
@@ -279,7 +294,7 @@ public class FinancePaymentRechargeApplicationServiceImpl extends ServiceImpl<Fi
|
|
}
|
|
}
|
|
this.updateById(recharge);
|
|
this.updateById(recharge);
|
|
//添加审核记录
|
|
//添加审核记录
|
|
- insertRecord(recharge.getId(), recharge.getUserId(), oldRecharge.getAuditStatus(), oldRecharge.getApprovalContent(), oldRecharge.getFiles());
|
|
|
|
|
|
+ insertRecord(recharge.getId(), recharge.getUserId(), oldRecharge.getAuditStatus(), oldRecharge.getApprovalContent(), oldRecharge.getFiles(), oldRecharge.getUpdateTime());
|
|
JSONObject oldData = JSONObject.parseObject(JSONObject.toJSONString(oldRecharge)).toJavaObject(JSONObject.class);
|
|
JSONObject oldData = JSONObject.parseObject(JSONObject.toJSONString(oldRecharge)).toJavaObject(JSONObject.class);
|
|
String failMessage = null;
|
|
String failMessage = null;
|
|
List<SysUser> users = null;
|
|
List<SysUser> users = null;
|
|
@@ -307,7 +322,7 @@ public class FinancePaymentRechargeApplicationServiceImpl extends ServiceImpl<Fi
|
|
String auditStatus = oldApplication.getAuditStatus();//4-临时通过
|
|
String auditStatus = oldApplication.getAuditStatus();//4-临时通过
|
|
if ("4".equals(auditStatus)) {
|
|
if ("4".equals(auditStatus)) {
|
|
recharge.setAuditStatus("3");
|
|
recharge.setAuditStatus("3");
|
|
- recharge.setApprovalContent(Check.isNull(recharge.getApprovalContent()) ? "补传文件" : recharge.getApprovalContent());
|
|
|
|
|
|
+ recharge.setApprovalContent(Check.isNull(recharge.getApprovalContent()) ? "-" : recharge.getApprovalContent());
|
|
recharge.setReviewederId(recharge.getUserId());
|
|
recharge.setReviewederId(recharge.getUserId());
|
|
SysUser user = userService.getById(recharge.getUserId());
|
|
SysUser user = userService.getById(recharge.getUserId());
|
|
if (!Check.isNull(user)) {
|
|
if (!Check.isNull(user)) {
|
|
@@ -315,7 +330,7 @@ public class FinancePaymentRechargeApplicationServiceImpl extends ServiceImpl<Fi
|
|
}
|
|
}
|
|
this.updateById(recharge);
|
|
this.updateById(recharge);
|
|
//添加审核记录
|
|
//添加审核记录
|
|
- insertRecord(recharge.getId(), oldApplication.getRevieweder(), auditStatus, oldApplication.getApprovalContent(), oldApplication.getFiles());
|
|
|
|
|
|
+ insertRecord(recharge.getId(), oldApplication.getReviewederId(), auditStatus, oldApplication.getApprovalContent(), oldApplication.getFiles(), oldApplication.getUpdateTime());
|
|
}
|
|
}
|
|
return Result.ok();
|
|
return Result.ok();
|
|
}
|
|
}
|
|
@@ -329,21 +344,27 @@ public class FinancePaymentRechargeApplicationServiceImpl extends ServiceImpl<Fi
|
|
String financialReview = recharge.getFinancialReview();
|
|
String financialReview = recharge.getFinancialReview();
|
|
if (!Check.isNull(financialReview) && "1".equals(financialReview)) {
|
|
if (!Check.isNull(financialReview) && "1".equals(financialReview)) {
|
|
recharge.setReviewederId("financialReview");
|
|
recharge.setReviewederId("financialReview");
|
|
|
|
+ recharge.setRevieweder("-");
|
|
recharge.setAuditStatus("1");//待审核
|
|
recharge.setAuditStatus("1");//待审核
|
|
} else {
|
|
} else {
|
|
//媒介
|
|
//媒介
|
|
recharge.setReviewederId("meidaManager");
|
|
recharge.setReviewederId("meidaManager");
|
|
|
|
+ recharge.setRevieweder("-");
|
|
recharge.setAuditStatus("2");//待充值
|
|
recharge.setAuditStatus("2");//待充值
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void insertRecord(Long rechargeId, String operatorId, String status, String txt, String files) {
|
|
|
|
|
|
+ private void insertRecord(Long rechargeId, String operatorId, String status, String txt, String files, Date time) {
|
|
|
|
+ if ("1".equals(status) || "2".equals(status)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
FinancePaymentRechargeApplicationRecord record = new FinancePaymentRechargeApplicationRecord();
|
|
FinancePaymentRechargeApplicationRecord record = new FinancePaymentRechargeApplicationRecord();
|
|
record.setRechargeId(rechargeId);
|
|
record.setRechargeId(rechargeId);
|
|
record.setReviewederId(operatorId);
|
|
record.setReviewederId(operatorId);
|
|
record.setAuditStatus(status);
|
|
record.setAuditStatus(status);
|
|
record.setApprovalContent(txt);
|
|
record.setApprovalContent(txt);
|
|
record.setFiles(files);
|
|
record.setFiles(files);
|
|
|
|
+ record.setCreateTime(time);
|
|
recordMapper.insert(record);
|
|
recordMapper.insert(record);
|
|
}
|
|
}
|
|
|
|
|