Commit 3353dea6 by 林冲

Merge branch 'v5.8.2' into 'master'

上线合并

See merge request !5
2 parents 882ed6be 36a41000
......@@ -2,6 +2,7 @@ package cn.com.glsx.dj.financial.dto;
import cn.com.glsx.dj.financial.model.NbCbAccDetail;
import cn.com.glsx.dj.financial.model.NbCbDetailLog;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
......@@ -103,4 +104,7 @@ public class NbCbAccDetailDTO extends NbCbAccDetail {
*/
private Byte receiptJdSync;
@ApiModelProperty(name = "custType", notes = "主体类型:1-广联 2-优加", dataType = "Integer")
private Integer custType;
}
......@@ -31,4 +31,10 @@ public class H5ApprovalRecordRequest implements Serializable {
@ApiModelProperty(name = "endDate", notes = "结束日期", dataType = "String")
private Date endDate;
@ApiModelProperty(name = "custType", notes = "主体类型:1-广联 2-优加", dataType = "Integer")
private Integer custType;
@ApiModelProperty(name = "custId", notes = "主体id(前端不需要传)", dataType = "String")
private String custId;
}
package cn.com.glsx.dj.financial.config;
import com.alibaba.fastjson.JSON;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.util.List;
@Data
@Component
@ConfigurationProperties(prefix = "merchant.corp.agent")
public class MerchantCorpProperties {
private List<MerchantCorpConfig> config;
public void setConfig(String configJson) {
this.config = JSON.parseArray(configJson, MerchantCorpConfig.class);
}
@Data
public static class MerchantCorpConfig {
private Integer merchantId;
private String agentId;
private String corpId;
private String corpSecret;
// 主体类型 1-广联 2-优加
private Integer custType;
}
}
......@@ -79,15 +79,15 @@ public class QWManager {
@SetDefaultMerchantId
public SendWorkWechatMessageResponseDTO sendMessage(
SendWorkWechatMessageRequestDTO sendWorkWechatMessageRequestDTO) {
log.info("发送企微应用消息:{}", JSON.toJSONString(sendWorkWechatMessageRequestDTO));
log.info("发送企微应用消息request:{}", JSON.toJSONString(sendWorkWechatMessageRequestDTO));
SendWorkWechatMessageResponseDTO responseDTO=null;
try {
String baseurl = environment.getProperty("wechant.base.path")+"wechat/message/sendMessage";
responseDTO = HttpUtil.post(baseurl,JSONObject.parseObject(JSONObject.toJSONString(sendWorkWechatMessageRequestDTO)), SendWorkWechatMessageResponseDTO.class);
log.info("发送企微应用消息 ropResponse:{}", JSON.toJSONString(responseDTO));
log.info("发送企微应用消息request:{},ropResponse:{}",JSON.toJSONString(sendWorkWechatMessageRequestDTO), JSON.toJSONString(responseDTO));
} catch (Exception e) {
e.printStackTrace();
log.info("发送企微应用消息异常:", e);
log.info("发送企微应用消息异常request:{}",JSON.toJSONString(sendWorkWechatMessageRequestDTO), e);
}
return responseDTO;
}
......
......@@ -3,9 +3,11 @@ package cn.com.glsx.dj.financial.service;
import cn.com.glsx.dj.financial.dto.approval.H5ApprovalRecordDTO;
import cn.com.glsx.dj.financial.mapper.ApprovalRecordsMapper;
import cn.com.glsx.dj.financial.mapper.ApprovalTemplateDetailMapper;
import cn.com.glsx.dj.financial.mapper.NbCbCustInfoMapper;
import cn.com.glsx.dj.financial.mapper.NbCbReceiptMapper;
import cn.com.glsx.dj.financial.model.ApprovalRecords;
import cn.com.glsx.dj.financial.model.ApprovalTemplateDetail;
import cn.com.glsx.dj.financial.model.NbCbCustInfo;
import cn.com.glsx.dj.financial.request.approval.H5ApprovalRecordRequest;
import cn.com.glsx.dj.financial.util.FileUtils;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
......@@ -18,6 +20,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.*;
import java.util.stream.Collectors;
......@@ -42,6 +45,9 @@ public class ApprovalRecordService {
@Autowired
private Environment env;
@Autowired
private NbCbCustInfoMapper nbCbCustInfoMapper;
/**
* 到账伴侣H5页面-审批详情
*
......@@ -145,6 +151,15 @@ public class ApprovalRecordService {
* @return
*/
public Page<H5ApprovalRecordDTO> getH5ApprovalRecordList(RpcPagination<H5ApprovalRecordRequest> pagination) {
if (pagination.getCondition().getCustType() != null) {
Example example = new Example(NbCbCustInfo.class);
example.createCriteria().andEqualTo("delFlag",0)
.andEqualTo("custType", pagination.getCondition().getCustType());
List<NbCbCustInfo> nbCbCustInfos = nbCbCustInfoMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(nbCbCustInfos)) {
pagination.getCondition().setCustId(nbCbCustInfos.get(0).getCustId());
}
}
Page<H5ApprovalRecordDTO> page = PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize(), pagination.isNeedCount());
approvalRecordsMapper.getH5ApprovalRecordList(pagination.getCondition());
return page;
......
package cn.com.glsx.dj.financial.service;
import cn.com.glsx.dj.financial.config.MerchantCorpProperties;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
@Slf4j
@Service
public class MerchantCorpConfigService {
@Autowired
private MerchantCorpProperties merchantCorpProperties;
// 内存缓存 Map,Key 为 merchantId
private Map<Integer, MerchantCorpProperties.MerchantCorpConfig> configMap;
/**
* 项目启动时,自动将 List 转换为 Map,方便快速查找
*/
@PostConstruct
public void init() {
if (merchantCorpProperties.getConfig() != null) {
configMap = merchantCorpProperties.getConfig().stream()
.collect(Collectors.toMap(
MerchantCorpProperties.MerchantCorpConfig::getMerchantId,
config -> config,
(key1, key2) -> key1 // 如果 merchantId 重复,保留第一个
));
}
log.info("初始化商户配置完成,共 {} 条数据,configMap:{}", configMap.size(), JSON.toJSONString(configMap));
}
/**
* 根据 merchantId 获取对应的完整配置
*/
public Optional<MerchantCorpProperties.MerchantCorpConfig> getConfigByMerchantId(Integer merchantId) {
if (configMap == null || merchantId == null) {
return Optional.empty();
}
return Optional.ofNullable(configMap.get(merchantId));
}
/**
* 便捷方法:直接根据 merchantId 获取 agentId
*/
public String getAgentIdByMerchantId(Integer merchantId) {
return getConfigByMerchantId(merchantId)
.map(MerchantCorpProperties.MerchantCorpConfig::getAgentId)
.orElseThrow(() -> new IllegalArgumentException("未找到该商户对应的配置: " + merchantId));
}
/**
* 便捷方法:直接根据 merchantId 获取 custType
*/
public Integer getCustTypeByMerchantId(Integer merchantId) {
return getConfigByMerchantId(merchantId)
.map(MerchantCorpProperties.MerchantCorpConfig::getCustType)
.orElseThrow(() -> new IllegalArgumentException("未找到该商户对应的配置: " + merchantId));
}
}
package cn.com.glsx.dj.financial.service;
import cn.com.glsx.dj.financial.config.MerchantCorpProperties;
import cn.com.glsx.dj.financial.enums.NbCbCustEnum;
import cn.com.glsx.dj.financial.enums.QWApprovalOrderStatusEnum;
import cn.com.glsx.dj.financial.manager.QWManager;
import cn.com.glsx.dj.financial.mapper.ApprovalRecordsMapper;
......@@ -72,6 +74,9 @@ public class QWApprovalService {
@Autowired
private NbCbCustInfoService nbCbCustInfoService;
@Autowired
private MerchantCorpConfigService merchantCorpConfigService;
/**
* 1.处理审批记录 2.记录审批记录
*
......@@ -610,10 +615,23 @@ public class QWApprovalService {
if (com.alibaba.nacos.common.utils.StringUtils.isEmpty(property)){
return;
}
Optional<MerchantCorpProperties.MerchantCorpConfig> merchantCorpConfig = merchantCorpConfigService.getConfigByMerchantId(approvalRecord.getMerchantId());
boolean present = merchantCorpConfig.isPresent();
if (!present) {
log.info("未找到商户企微应用配置信息,merchantId:{}", approvalRecord.getMerchantId());
throw new RuntimeException("未找到商户企微应用配置信息");
}
Integer custType = merchantCorpConfig.get().getCustType();
if (!Objects.equals(custType, NbCbCustEnum.GL_CUST.getCustType()) && !Objects.equals(custType, NbCbCustEnum.YJ_CUST.getCustType())) {
log.info("商户不是广联主体或者优加主体,merchantId:{},custType:{}",approvalRecord.getMerchantId(),custType);
throw new RuntimeException("商户不是广联主体或者优加主体");
}
String agentId = merchantCorpConfig.get().getAgentId();
SendWorkWechatMessageRequestDTO sendWorkWechatMessageRequestDTO = new SendWorkWechatMessageRequestDTO();
sendWorkWechatMessageRequestDTO.setMsgType("text");
sendWorkWechatMessageRequestDTO.setToUser(approvalRecord.getApplyerUserid());
sendWorkWechatMessageRequestDTO.setAgentId(environment.getProperty("default.agentid")==null?"1000008":environment.getProperty("default.agentid"));
// sendWorkWechatMessageRequestDTO.setAgentId(environment.getProperty("default.agentid")==null?"1000008":environment.getProperty("default.agentid"));
sendWorkWechatMessageRequestDTO.setAgentId(agentId);
WorkWechatTextMessageDTO workWechatTextMessageDTO = new WorkWechatTextMessageDTO();
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("【").append(approvalRecord.getPayTitle()).append("】").append("推送付款信息失败\n");
......
package cn.com.glsx.dj.financial.service;
import cn.com.glsx.dj.financial.config.MerchantCorpProperties;
import cn.com.glsx.dj.financial.dto.NbCbBatchTransferParamDTO;
import cn.com.glsx.dj.financial.enums.BatchTransferSourceEnum;
import cn.com.glsx.dj.financial.enums.NbCbCustEnum;
import cn.com.glsx.dj.financial.enums.QWApprovalOrderStatusEnum;
import cn.com.glsx.dj.financial.manager.QWManager;
import cn.com.glsx.dj.financial.mapper.ApprovalRecordsMapper;
......@@ -52,6 +54,9 @@ public class ThirdPartyNiBoBatchStrategy implements ThirdPartyStrategy{
@Autowired
private ApprovalTemplateConfigMapper approvalTemplateConfigMapper;
@Autowired
private MerchantCorpConfigService merchantCorpConfigService;
@Override
public Object buildRequestParams(ApprovalRecords approvalRecord,String custId, Integer custType) {
int remarksLengthMax = 35;
......@@ -182,6 +187,18 @@ public class ThirdPartyNiBoBatchStrategy implements ThirdPartyStrategy{
public void callBack(CallbackData callbackData, ApprovalRecords approvalRecords) {
// 1.处理订单状态
if (("0").equals(callbackData.getStatus())) {
Optional<MerchantCorpProperties.MerchantCorpConfig> merchantCorpConfig = merchantCorpConfigService.getConfigByMerchantId(approvalRecords.getMerchantId());
boolean present = merchantCorpConfig.isPresent();
if (!present) {
log.info("未找到商户企微应用配置信息,merchantId:{}", approvalRecords.getMerchantId());
throw new RuntimeException("未找到商户企微应用配置信息");
}
Integer custType = merchantCorpConfig.get().getCustType();
if (!Objects.equals(custType, NbCbCustEnum.GL_CUST.getCustType()) && !Objects.equals(custType, NbCbCustEnum.YJ_CUST.getCustType())) {
log.info("商户不是广联主体或者优加主体,merchantId:{},custType:{}",approvalRecords.getMerchantId(),custType);
throw new RuntimeException("商户不是广联主体或者优加主体");
}
String agentId = merchantCorpConfig.get().getAgentId();
approvalRecords.setThirdRequestStatus(QWApprovalOrderStatusEnum.CALLBACK_SUCCESS.getValue());
// 2.发送企微通知
......@@ -202,7 +219,8 @@ public class ThirdPartyNiBoBatchStrategy implements ThirdPartyStrategy{
}
sendMessageRequestDTO.setTextCard(workWechatTextCardMessageDTO);
sendMessageRequestDTO.setAgentId(environment.getProperty("default.agentid")==null?"1000008":environment.getProperty("default.agentid"));
// sendMessageRequestDTO.setAgentId(environment.getProperty("default.agentid")==null?"1000008":environment.getProperty("default.agentid"));
sendMessageRequestDTO.setAgentId(agentId);
Set<String> qwUserIdList = new HashSet<>();
qwUserIdList.add(approvalRecords.getApplyerUserid());
......@@ -214,7 +232,12 @@ public class ThirdPartyNiBoBatchStrategy implements ThirdPartyStrategy{
String url = workWechatTextCardMessageDTO.getUrl();
for (String qwUserId : qwUserIdList) {
if (StringUtils.isNotBlank(url)) {
workWechatTextCardMessageDTO.setUrl(String.format("%s&qwUserId=%s", url, qwUserId));
if (Objects.equals(custType, NbCbCustEnum.YJ_CUST.getCustType())) {
workWechatTextCardMessageDTO.setUrl(String.format("%s&qwUserId=%s&sysSource=YJ", url, qwUserId));
}
else {
workWechatTextCardMessageDTO.setUrl(String.format("%s&qwUserId=%s&sysSource=GL", url, qwUserId));
}
}
sendMessageRequestDTO.setToUser(qwUserId);
......
......@@ -606,9 +606,12 @@ public class NbCbAccDetailService {
public Page<NbCbAccDetailDTO> page(RpcPagination<NbCbAccDetailDTO> pagination) {
RpcAssert.assertNotNull(pagination, DefaultErrorEnum.DATA_NULL, "pagination not be null");
try {
Page<NbCbAccDetailDTO> page = PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize(), pagination.isNeedCount());
//获取主体配置
String custId = nbCbCustInfoService.getCustIdByType(pagination.getCondition().getCustType());
NbCbAccDetailDTO condition = pagination.getCondition();
condition.setCustId(env.getProperty("nbcb.custId", "9000919969"));
Page<NbCbAccDetailDTO> page = PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize(), pagination.isNeedCount());
// condition.setCustId(env.getProperty("nbcb.custId", "9000919969"));
condition.setCustId(custId);
List<NbCbAccDetailDTO> list = nbCbAccDetailMapper.list(condition);
List<String> subSerialNoList = list.stream().map(NbCbAccDetailDTO::getSubSerialNo).collect(Collectors.toList());
......@@ -738,7 +741,8 @@ public class NbCbAccDetailService {
throw new RpcServiceException(DefaultErrorEnum.VALIDATE_FAILED, "交易开始时间不能大于交易结束时间");
}
//先默认为广联主体
String custId = nbCbCustInfoService.getCustIdByType(NbCbCustEnum.GL_CUST.getCustType());
// String custId = nbCbCustInfoService.getCustIdByType(NbCbCustEnum.GL_CUST.getCustType());
String custId = nbCbCustInfoService.getCustIdByType(nbCbAccDetailDTO.getCustType());
NbCbAccDetailDTO condition = new NbCbAccDetailDTO();
condition.setAccNameList(nbCbAccDetailDTO.getAccNameList());
condition.setBankType(nbCbAccDetailDTO.getBankType());
......@@ -750,8 +754,8 @@ public class NbCbAccDetailService {
}
taskExecutor.execute(() -> {
try {
nbReceiptService.reFetchReceipt(bankAccList, transTimeStart, transTimeEnd, nbCbAccDetailDTO.getUpdatedBy(),custId,NbCbCustEnum.GL_CUST.getCustType());
reFetchAccDetail(bankAccList, transTimeStart, transTimeEnd, nbCbAccDetailDTO.getUpdatedBy(),custId,NbCbCustEnum.GL_CUST.getCustType());
nbReceiptService.reFetchReceipt(bankAccList, transTimeStart, transTimeEnd, nbCbAccDetailDTO.getUpdatedBy(),custId, nbCbAccDetailDTO.getCustType());
reFetchAccDetail(bankAccList, transTimeStart, transTimeEnd, nbCbAccDetailDTO.getUpdatedBy(),custId, nbCbAccDetailDTO.getCustType());
} catch (RpcServiceException e) {
throw e;
} catch (Exception e) {
......@@ -792,7 +796,8 @@ public class NbCbAccDetailService {
public NbCbAccDetailDTO accDetailConfig(NbCbAccDetailDTO condition) {
try {
String custId = nbCbCustInfoService.getCustIdByType(NbCbCustEnum.GL_CUST.getCustType());
// String custId = nbCbCustInfoService.getCustIdByType(NbCbCustEnum.GL_CUST.getCustType());
String custId = nbCbCustInfoService.getCustIdByType(condition.getCustType());
condition.setCustId(custId);
NbCbAccDetailDTO nbCbAccDetailDTO = new NbCbAccDetailDTO();
nbCbAccDetailDTO.setAccNameList(nbCbAccDetailMapper.selectAccNameList(condition));
......
......@@ -133,6 +133,9 @@
<if test="endDate != null">
and date(d.trans_time) &lt;= date(#{endDate})
</if>
<if test="custId != null">
and r.custId = #{custId}
</if>
</where>
union all
......@@ -171,6 +174,9 @@
<if test="endDate != null">
and date(d.trans_time) &lt;= date(#{endDate})
</if>
<if test="custId != null">
and r.custId = #{custId}
</if>
</where>
) t1
order by t1.created_date desc
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!