提交 ea81c190 编写于 作者: X xiaoyu

Merge remote-tracking branch 'origin/dev' into dev

......@@ -13,7 +13,7 @@
<parent>
<groupId>com.jeequan</groupId>
<artifactId>jeepay</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
</parent>
<!-- 项目依赖声明 -->
......
......@@ -13,7 +13,7 @@
<parent>
<groupId>com.jeequan</groupId>
<artifactId>jeepay</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
</parent>
<!-- 项目依赖声明 -->
<dependencies>
......
......@@ -39,9 +39,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;
/**
* 商户管理类
......@@ -115,7 +113,7 @@ public class MchInfoController extends CommonCtrl {
public ApiRes delete(@PathVariable("mchNo") String mchNo) {
List<Long> userIdList = mchInfoService.removeByMchNo(mchNo);
// 推送mq删除redis用户缓存
mqQueue4ModifyMchUserRemove.push(StringUtils.join(userIdList, ","));
mqQueue4ModifyMchUserRemove.push(userIdList);
// 推送mq到目前节点进行更新数据
mqTopic4ModifyMchInfo.push(mchNo);
return ApiRes.ok();
......@@ -130,58 +128,50 @@ public class MchInfoController extends CommonCtrl {
@MethodLog(remark = "更新商户信息")
@RequestMapping(value="/{mchNo}", method = RequestMethod.PUT)
public ApiRes update(@PathVariable("mchNo") String mchNo) {
//获取查询条件
MchInfo mchInfo = getObject(MchInfo.class);
List<Long> userIdCacheList = new ArrayList<>();
mchInfo.setMchNo(mchNo);
// 校验该商户是否为特邀商户
MchInfo dbMchInfo = mchInfoService.getById(mchNo);
if (dbMchInfo == null) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
// 如果为特邀商户则不允许修改服务商及商户类型
if (dbMchInfo.getType() == CS.MCH_TYPE_ISVSUB) {
mchInfo.setType(dbMchInfo.getType());
mchInfo.setIsvNo(dbMchInfo.getIsvNo());
}
mchInfo.setMchNo(mchNo); //设置商户号主键
mchInfo.setType(null); //防止变更商户类型
mchInfo.setIsvNo(null);
// 待删除用户登录信息的ID list
Set<Long> removeCacheUserIdList = new HashSet<>();
// 如果商户状态为禁用状态,清除该商户用户登录信息
if (mchInfo.getState() == CS.NO) {
List<SysUser> userList = sysUserService.list(SysUser.gw()
.eq(SysUser::getBelongInfoId, mchNo)
.eq(SysUser::getSysType, CS.SYS_TYPE.MCH)
);
if (userList.size() > 0) {
for (SysUser user:userList) {
userIdCacheList.add(user.getSysUserId());
}
}
sysUserService.list( SysUser.gw().select(SysUser::getSysUserId).eq(SysUser::getBelongInfoId, mchNo).eq(SysUser::getSysType, CS.SYS_TYPE.MCH) )
.stream().forEach(u -> removeCacheUserIdList.add(u.getSysUserId()));
}
//判断是否重置密码
Boolean resetPass = getReqParamJSON().getBoolean("resetPass");
if (resetPass != null && resetPass) {
//判断是否重置密码
String updatePwd = getReqParamJSON().getBoolean("defaultPass") == false? Base64.decodeStr(getValStringRequired("confirmPwd")):CS.DEFAULT_PWD;
if (StringUtils.isNotEmpty(updatePwd)) {
// 获取商户最初的用户
SysUser sysUser = sysUserService.getOne(SysUser.gw()
.eq(SysUser::getBelongInfoId, mchNo)
.eq(SysUser::getSysType, CS.SYS_TYPE.MCH)
.eq(SysUser::getIsAdmin, CS.YES)
);
sysUserAuthService.resetAuthInfo(sysUser.getSysUserId(), null, null, updatePwd, CS.SYS_TYPE.MCH);
if (mchInfo.getState() == CS.YES) userIdCacheList = Arrays.asList(sysUser.getSysUserId());
}
if (getReqParamJSON().getBooleanValue("resetPass")) {
// 待更新的密码
String updatePwd = getReqParamJSON().getBoolean("defaultPass") ? CS.DEFAULT_PWD : Base64.decodeStr(getValStringRequired("confirmPwd")) ;
// 获取商户超管
Long mchAdminUserId = sysUserService.findMchAdminUserId(mchNo);
//重置超管密码
sysUserAuthService.resetAuthInfo(mchAdminUserId, null, null, updatePwd, CS.SYS_TYPE.MCH);
//删除超管登录信息
removeCacheUserIdList.add(mchAdminUserId);
}
// 推送mq删除redis用户认证信息
if (!removeCacheUserIdList.isEmpty()) {
mqQueue4ModifyMchUserRemove.push(removeCacheUserIdList);
}
// 商户被禁用、修改密码删除mq用户缓存
if (mchInfo.getState() == CS.NO || resetPass) {
// 推送mq删除redis用户缓存
mqQueue4ModifyMchUserRemove.push(StringUtils.join(Arrays.asList(userIdCacheList), ","));
//更新商户信息
if (!mchInfoService.updateById(mchInfo)) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_UPDATE);
}
boolean result = mchInfoService.updateById(mchInfo);
mqTopic4ModifyMchInfo.push(mchNo); // 推送mq到目前节点进行更新数据
if (!result) return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_UPDATE);
// 推送mq到目前节点进行更新数据
mqTopic4ModifyMchInfo.push(mchNo);
return ApiRes.ok();
}
......
......@@ -15,6 +15,7 @@
*/
package com.jeequan.jeepay.mgr.mq.queue;
import com.alibaba.fastjson.JSONArray;
import com.jeequan.jeepay.core.constants.CS;
import lombok.extern.slf4j.Slf4j;
import org.apache.activemq.command.ActiveMQQueue;
......@@ -22,6 +23,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;
import java.util.Collection;
/**
* 商户用户信息清除
*
......@@ -44,8 +47,11 @@ public class MqQueue4ModifyMchUserRemove extends ActiveMQQueue{
* @date: 2021/6/7 16:16
* @describe: 推送消息到各个节点
*/
public void push(String userIdStr) {
this.jmsTemplate.convertAndSend(this, userIdStr);
public void push(Collection<Long> userIdList) {
if(userIdList == null || userIdList.isEmpty()){
return ;
}
this.jmsTemplate.convertAndSend(this,JSONArray.toJSONString(userIdList));
}
}
......@@ -13,7 +13,7 @@
<parent>
<groupId>com.jeequan</groupId>
<artifactId>jeepay</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
</parent>
<!-- 项目依赖声明 -->
<dependencies>
......
......@@ -15,6 +15,7 @@
*/
package com.jeequan.jeepay.mch.mq.queue;
import com.alibaba.fastjson.JSONArray;
import com.jeequan.jeepay.core.cache.RedisUtil;
import com.jeequan.jeepay.core.constants.CS;
import lombok.extern.slf4j.Slf4j;
......@@ -52,7 +53,7 @@ public class MqQueue4ModifyMchUserRemove extends ActiveMQQueue {
log.info("成功接收删除商户用户登录的订阅通知, msg={}", userIdStr);
// 字符串转List<Long>
List<Long> userIdList = Arrays.stream(userIdStr.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
List<Long> userIdList = JSONArray.parseArray(userIdStr, Long.class);
// 删除redis用户缓存
if(userIdList == null || userIdList.isEmpty()){
log.info("用户ID为空");
......
......@@ -13,7 +13,7 @@
<parent>
<groupId>com.jeequan</groupId>
<artifactId>jeepay</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
</parent>
<!-- 项目依赖声明 -->
<dependencies>
......
......@@ -71,7 +71,6 @@ public class AlipayRefundService extends AbstractRefundService {
ChannelRetMsg channelRetMsg = new ChannelRetMsg();
channelRetMsg.setChannelAttach(response.getBody());
channelRetMsg.setChannelOrderId(response.getTradeNo());
// 调用成功
if(response.isSuccess()){
......@@ -102,7 +101,6 @@ public class AlipayRefundService extends AbstractRefundService {
ChannelRetMsg channelRetMsg = new ChannelRetMsg();
channelRetMsg.setChannelAttach(response.getBody());
channelRetMsg.setChannelOrderId(response.getTradeNo());
// 调用成功 & 金额相等 (传入不存在的outRequestNo支付宝仍然返回响应成功只是数据不存在, 调用isSuccess() 仍是成功, 此处需判断金额是否相等)
Long channelRefundAmount = response.getRefundAmount() == null ? null : Long.parseLong(AmountUtil.convertDollar2Cent(response.getRefundAmount()));
......
......@@ -229,6 +229,7 @@ public class RefundOrderController extends ApiController {
}else if(ChannelRetMsg.ChannelState.CONFIRM_FAIL == channelRetMsg.getChannelState()) {
this.updateInitOrderStateThrowException(RefundOrder.STATE_FAIL, refundOrder, channelRetMsg);
payMchNotifyService.refundOrderNotify(refundOrder);
// 上游处理中 || 未知 || 上游接口返回异常 退款单为退款中状态
}else if( ChannelRetMsg.ChannelState.WAITING == channelRetMsg.getChannelState() ||
......
......@@ -18,7 +18,6 @@ package com.jeequan.jeepay.pay.mq.topic;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.pay.service.ConfigContextService;
import lombok.extern.slf4j.Slf4j;
import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;
......@@ -32,14 +31,10 @@ import org.springframework.stereotype.Component;
*/
@Slf4j
@Component
public class MqTopic4ModifyIsvInfo extends ActiveMQTopic{
public class MqTopic4ModifyIsvInfo{
@Autowired private ConfigContextService configContextService;
public MqTopic4ModifyIsvInfo(){
super(CS.MQ.TOPIC_MODIFY_ISV_INFO);
}
/** 接收 更新系统配置项的消息 **/
@JmsListener(destination = CS.MQ.TOPIC_MODIFY_ISV_INFO, containerFactory = "jmsListenerContainer")
public void receive(String isvNo) {
......
......@@ -19,7 +19,6 @@ import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.pay.service.ConfigContextService;
import lombok.extern.slf4j.Slf4j;
import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;
......@@ -33,14 +32,10 @@ import org.springframework.stereotype.Component;
*/
@Slf4j
@Component
public class MqTopic4ModifyMchInfo extends ActiveMQTopic{
public class MqTopic4ModifyMchInfo{
@Autowired private ConfigContextService configContextService;
public MqTopic4ModifyMchInfo(){
super(CS.MQ.TOPIC_MODIFY_MCH_INFO);
}
/** 接收 [商户配置信息] 的消息
* 已知推送节点:
* 1. 更新商户基本资料和状态
......
......@@ -18,28 +18,23 @@ package com.jeequan.jeepay.pay.mq.topic;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.service.impl.SysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;
/*
* 更改系统配置参数
*
*
* @author terrfly
* @site https://www.jeepay.vip
* @date 2021/6/8 17:35
*/
@Slf4j
@Component
public class MqTopic4ModifySysConfig extends ActiveMQTopic{
public class MqTopic4ModifySysConfig{
@Autowired private SysConfigService sysConfigService;
public MqTopic4ModifySysConfig(){
super(CS.MQ.TOPIC_MODIFY_SYS_CONFIG);
}
/** 接收 更新系统配置项的消息 **/
@JmsListener(destination = CS.MQ.TOPIC_MODIFY_SYS_CONFIG, containerFactory = "jmsListenerContainer")
public void receive(String msg) {
......
......@@ -142,6 +142,11 @@ public class ChannelOrderReissueService {
//1. 更新支付订单表为失败状态
refundOrderService.updateIng2Fail(refundOrderId, channelRetMsg.getChannelOrderId(), channelRetMsg.getChannelErrCode(), channelRetMsg.getChannelErrMsg());
// 通知商户系统
if(StringUtils.isNotEmpty(refundOrder.getNotifyUrl())){
payMchNotifyService.refundOrderNotify(refundOrderService.getById(refundOrderId));
}
}
return channelRetMsg;
......
......@@ -156,7 +156,14 @@ public class ConfigContextService {
return;
}
//商户应用信息
//DB已经删除
if(mchAppService.count(MchApp.gw().eq(MchApp::getAppId, appId)) <= 0){
mchAppConfigContextMap.remove(appId); //清除缓存信息
mchInfoConfigContext.getAppMap().remove(appId); //清除主体信息中的appId
return ;
}
//商户应用信息(缓存中存在)
MchApp mchApp = mchInfoConfigContext.getMchApp(appId);
if(mchApp == null){ //说明商户主体信息不存在缓存
......
......@@ -13,7 +13,7 @@
<parent>
<groupId>com.jeequan</groupId>
<artifactId>jeepay</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
</parent>
<!-- 项目依赖声明 -->
......
......@@ -36,23 +36,16 @@ public class MchAppService extends ServiceImpl<MchAppMapper, MchApp> {
if (payCount > 0) throw new BizException("该应用已存在交易数据,不可删除");
// 2.删除应用关联的支付通道
boolean result = mchPayPassageService.remove(MchPayPassage.gw().eq(MchPayPassage::getAppId, appId));
if (!result) {
throw new BizException(ApiCodeEnum.SYS_OPERATION_FAIL_DELETE);
}
mchPayPassageService.remove(MchPayPassage.gw().eq(MchPayPassage::getAppId, appId));
// 3.删除应用配置的支付参数
result = payInterfaceConfigService.remove(PayInterfaceConfig.gw()
payInterfaceConfigService.remove(PayInterfaceConfig.gw()
.eq(PayInterfaceConfig::getInfoId, appId)
.eq(PayInterfaceConfig::getInfoType, CS.INFO_TYPE_MCH_APP)
);
if (!result) {
throw new BizException(ApiCodeEnum.SYS_OPERATION_FAIL_DELETE);
}
// 4.删除当前应用
result = removeById(appId);
if (!result) {
if (!removeById(appId)) {
throw new BizException(ApiCodeEnum.SYS_OPERATION_FAIL_DELETE);
}
}
......
......@@ -158,4 +158,16 @@ public class SysUserService extends ServiceImpl<SysUserMapper, SysUser> {
// 3.删除用户信息
removeById(sysUser.getSysUserId());
}
/** 获取到商户的超管用户ID **/
public Long findMchAdminUserId(String mchNo){
return getOne(SysUser.gw().select(SysUser::getSysUserId)
.eq(SysUser::getBelongInfoId, mchNo)
.eq(SysUser::getSysType, CS.SYS_TYPE.MCH)
.eq(SysUser::getIsAdmin, CS.YES)).getSysUserId();
}
}
......@@ -8,7 +8,7 @@
<packaging>pom</packaging> <!-- 项目的最终打包类型/发布形式, 可选[jar, war, pom, maven-plugin]等 -->
<name>jeepay</name>
<version>1.0.0</version> <!-- pom版本号/项目总版本号, 每个子项目引入的版本号必须一致。 -->
<version>1.1.0</version> <!-- pom版本号/项目总版本号, 每个子项目引入的版本号必须一致。 -->
<description>Jeepay计全支付系统</description> <!-- 项目描述 -->
<url>https://www.jeequan.com</url>
......@@ -34,7 +34,7 @@
<properties>
<java.version>1.8</java.version> <!-- 指定java版本号 -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <!-- 项目构建输出编码 -->
<isys.version>1.0.0</isys.version> <!-- 指定当前[项目]版本号 -->
<isys.version>1.1.0</isys.version> <!-- 指定当前[项目]版本号 -->
<!-- 其他工具包 -->
<fastjson.version>1.2.76</fastjson.version> <!-- fastjson -->
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册