提交 33728965 编写于 作者: Z zhuxiao

运营平台、商户系统新增商户应用及相关支付配置

上级 fdbb0edf
...@@ -253,7 +253,7 @@ CREATE TABLE `t_mch_pay_passage` ( ...@@ -253,7 +253,7 @@ CREATE TABLE `t_mch_pay_passage` (
`created_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) COMMENT '创建时间', `created_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) COMMENT '创建时间',
`updated_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6) COMMENT '更新时间', `updated_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6) COMMENT '更新时间',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `Uni_MchNo_WayCode` (`mch_no`,`if_code`, `way_code`) UNIQUE KEY `Uni_AppId_WayCode` (`app_id`,`if_code`, `way_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商户支付通道表'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商户支付通道表';
...@@ -399,12 +399,21 @@ insert into t_sys_entitlement values('ENT_MCH', '商户管理', 'shop', '', 'Rou ...@@ -399,12 +399,21 @@ insert into t_sys_entitlement values('ENT_MCH', '商户管理', 'shop', '', 'Rou
insert into t_sys_entitlement values('ENT_MCH_INFO_EDIT', '按钮:编辑', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_INFO', '0', 'MGR', now(), now()); insert into t_sys_entitlement values('ENT_MCH_INFO_EDIT', '按钮:编辑', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_INFO', '0', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_MCH_INFO_VIEW', '按钮:详情', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_INFO', '0', 'MGR', now(), now()); insert into t_sys_entitlement values('ENT_MCH_INFO_VIEW', '按钮:详情', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_INFO', '0', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_MCH_INFO_DEL', '按钮:删除', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_INFO', '0', 'MGR', now(), now()); insert into t_sys_entitlement values('ENT_MCH_INFO_DEL', '按钮:删除', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_INFO', '0', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_CONFIG_LIST', '商户支付参数配置列表', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_INFO', '0', 'MGR', now(), now()); insert into t_sys_entitlement values('ENT_MCH_APP_CONFIG', '应用配置', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_INFO', '0', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_CONFIG_ADD', '商户支付参数配置', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_PAY_CONFIG_LIST', '0', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_CONFIG_VIEW', '商户支付参数配置详情', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_PAY_CONFIG_LIST', '0', 'MGR', now(), now()); -- 应用管理
insert into t_sys_entitlement values('ENT_MCH_PAY_PASSAGE_LIST', '商户支付通道配置列表', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_INFO', '0', 'MGR', now(), now()); insert into t_sys_entitlement values('ENT_MCH_APP', '应用列表', 'appstore', '/apps', 'MchAppPage', 'ML', 0, 1, 'ENT_MCH', '20', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_PASSAGE_CONFIG', '商户支付通道配置入口', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_PAY_PASSAGE_LIST', '0', 'MGR', now(), now()); insert into t_sys_entitlement values('ENT_MCH_APP_LIST', '页面:应用列表', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_APP', '0', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_PASSAGE_ADD', '商户支付通道配置保存', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_PAY_PASSAGE_LIST', '0', 'MGR', now(), now()); insert into t_sys_entitlement values('ENT_MCH_APP_ADD', '按钮:新增', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_APP', '0', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_MCH_APP_EDIT', '按钮:编辑', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_APP', '0', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_MCH_APP_VIEW', '按钮:详情', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_APP', '0', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_MCH_APP_DEL', '按钮:删除', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_APP', '0', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_CONFIG_LIST', '应用支付参数配置列表', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_APP', '0', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_CONFIG_ADD', '应用支付参数配置', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_PAY_CONFIG_LIST', '0', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_CONFIG_VIEW', '应用支付参数配置详情', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_PAY_CONFIG_LIST', '0', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_PASSAGE_LIST', '应用支付通道配置列表', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_APP', '0', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_PASSAGE_CONFIG', '应用支付通道配置入口', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_PAY_PASSAGE_LIST', '0', 'MGR', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_PASSAGE_ADD', '应用支付通道配置保存', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_PAY_PASSAGE_LIST', '0', 'MGR', now(), now());
-- 服务商管理 -- 服务商管理
insert into t_sys_entitlement values('ENT_ISV', '服务商管理', 'block', '', 'RouteView', 'ML', 0, 1, 'ROOT', '40', 'MGR', now(), now()); insert into t_sys_entitlement values('ENT_ISV', '服务商管理', 'block', '', 'RouteView', 'ML', 0, 1, 'ROOT', '40', 'MGR', now(), now());
...@@ -492,9 +501,20 @@ insert into t_sys_entitlement values('ENT_MCH_MAIN', '主页', 'home', '/main', ...@@ -492,9 +501,20 @@ insert into t_sys_entitlement values('ENT_MCH_MAIN', '主页', 'home', '/main',
insert into t_sys_entitlement values('ENT_MCH_MAIN_USER_INFO', '主页用户信息', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_MAIN', '0', 'MCH', now(), now()); insert into t_sys_entitlement values('ENT_MCH_MAIN_USER_INFO', '主页用户信息', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_MAIN', '0', 'MCH', now(), now());
-- 【商户系统】 商户中心 -- 【商户系统】 商户中心
-- insert into t_sys_entitlement values('ENT_MCH_CENTER', '商户中心', 'team', '', 'RouteView', 'ML', 0, 'ROOT', '10', 'MCH', now(), now()); insert into t_sys_entitlement values('ENT_MCH_CENTER', '商户中心', 'team', '', 'RouteView', 'ML', 0, 1, 'ROOT', '10', 'MCH', now(), now());
-- insert into t_sys_entitlement values('ENT_MCH_INFO', '商户信息', 'user', '/mch', 'MchInfoPage', 'ML', 0, 'ENT_MCH_CENTER', '10', 'MCH', now(), now()); insert into t_sys_entitlement values('ENT_MCH_APP', '应用管理', 'appstore', '/apps', 'MchAppPage', 'ML', 0, 1, 'ENT_MCH_CENTER', '10', 'MCH', now(), now());
-- insert into t_sys_entitlement values('ENT_MCH_INFO_EDIT', '按钮:修改商户信息', 'no-icon', '', '', 'PB', 0, 'ENT_MCH_INFO', '0', 'MCH', now(), now()); insert into t_sys_entitlement values('ENT_MCH_APP_LIST', '页面:应用列表', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_APP', '0', 'MCH', now(), now());
insert into t_sys_entitlement values('ENT_MCH_APP_ADD', '按钮:新增', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_APP', '0', 'MCH', now(), now());
insert into t_sys_entitlement values('ENT_MCH_APP_EDIT', '按钮:编辑', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_APP', '0', 'MCH', now(), now());
insert into t_sys_entitlement values('ENT_MCH_APP_VIEW', '按钮:详情', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_APP', '0', 'MCH', now(), now());
insert into t_sys_entitlement values('ENT_MCH_APP_DEL', '按钮:删除', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_APP', '0', 'MCH', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_CONFIG_LIST', '应用支付参数配置列表', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_APP', '0', 'MCH', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_CONFIG_ADD', '应用支付参数配置', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_PAY_CONFIG_LIST', '0', 'MCH', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_CONFIG_VIEW', '应用支付参数配置详情', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_PAY_CONFIG_LIST', '0', 'MCH', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_PASSAGE_LIST', '应用支付通道配置列表', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_APP', '0', 'MCH', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_PASSAGE_CONFIG', '应用支付通道配置入口', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_PAY_PASSAGE_LIST', '0', 'MCH', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_PASSAGE_ADD', '应用支付通道配置保存', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_PAY_PASSAGE_LIST', '0', 'MCH', now(), now());
-- 【商户系统】 订单管理 -- 【商户系统】 订单管理
insert into t_sys_entitlement values('ENT_ORDER', '订单中心', 'transaction', '', 'RouteView', 'ML', 0, 1, 'ROOT', '20', 'MCH', now(), now()); insert into t_sys_entitlement values('ENT_ORDER', '订单中心', 'transaction', '', 'RouteView', 'ML', 0, 1, 'ROOT', '20', 'MCH', now(), now());
...@@ -505,16 +525,6 @@ insert into t_sys_entitlement values('ENT_ORDER', '订单中心', 'transaction', ...@@ -505,16 +525,6 @@ insert into t_sys_entitlement values('ENT_ORDER', '订单中心', 'transaction',
insert into t_sys_entitlement values('ENT_REFUND_LIST', '页面:退款订单列表', 'no-icon', '', '', 'PB', 0, 1, 'ENT_REFUND_ORDER', '0', 'MCH', now(), now()); insert into t_sys_entitlement values('ENT_REFUND_LIST', '页面:退款订单列表', 'no-icon', '', '', 'PB', 0, 1, 'ENT_REFUND_ORDER', '0', 'MCH', now(), now());
insert into t_sys_entitlement values('ENT_REFUND_ORDER_VIEW', '按钮:详情', 'no-icon', '', '', 'PB', 0, 1, 'ENT_REFUND_ORDER', '0', 'MCH', now(), now()); insert into t_sys_entitlement values('ENT_REFUND_ORDER_VIEW', '按钮:详情', 'no-icon', '', '', 'PB', 0, 1, 'ENT_REFUND_ORDER', '0', 'MCH', now(), now());
-- 【商户系统】 支付配置
insert into t_sys_entitlement values('ENT_MCH_PC', '支付配置', 'file-done', '', 'RouteView', 'ML', 0, 1, 'ROOT', '30', 'MCH', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_CONFIG_LIST', '支付参数', 'interaction', '/pay/config', 'PayConfigPage', 'ML', 0, 1, 'ENT_MCH_PC', '10', 'MCH', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_CONFIG_ADD', '商户支付参数配置', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_PAY_CONFIG_LIST', '0', 'MCH', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_CONFIG_VIEW', '商户支付参数配置详情', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_PAY_CONFIG_LIST', '0', 'MCH', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_PASSAGE_LIST', '支付通道', 'appstore', '/pay/passage', 'PayPassagePage', 'ML', 0, 1, 'ENT_MCH_PC', '20', 'MCH', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_PASSAGE_CONFIG', '商户支付通道配置入口', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_PAY_PASSAGE_LIST', '0', 'MCH', now(), now());
insert into t_sys_entitlement values('ENT_MCH_PAY_PASSAGE_ADD', '商户支付通道配置保存', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_PAY_PASSAGE_LIST', '0', 'MCH', now(), now());
-- 【商户系统】 系统管理 -- 【商户系统】 系统管理
insert into t_sys_entitlement values('ENT_SYS_CONFIG', '系统管理', 'setting', '', 'RouteView', 'ML', 0, 1, 'ROOT', '200', 'MCH', now(), now()); insert into t_sys_entitlement values('ENT_SYS_CONFIG', '系统管理', 'setting', '', 'RouteView', 'ML', 0, 1, 'ROOT', '200', 'MCH', now(), now());
insert into t_sys_entitlement values('ENT_UR', '用户角色管理', 'team', '', 'RouteView', 'ML', 0, 1, 'ENT_SYS_CONFIG', '10', 'MCH', now(), now()); insert into t_sys_entitlement values('ENT_UR', '用户角色管理', 'team', '', 'RouteView', 'ML', 0, 1, 'ENT_SYS_CONFIG', '10', 'MCH', now(), now());
......
package com.jeequan.jeepay.core.entity; package com.jeequan.jeepay.core.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
...@@ -35,7 +36,7 @@ public class MchApp extends BaseModel { ...@@ -35,7 +36,7 @@ public class MchApp extends BaseModel {
/** /**
* 应用ID * 应用ID
*/ */
@TableId @TableId(value = "app_id", type = IdType.ASSIGN_UUID)
private String appId; private String appId;
/** /**
......
...@@ -54,7 +54,7 @@ public class IsvPayInterfaceConfigController extends CommonCtrl { ...@@ -54,7 +54,7 @@ public class IsvPayInterfaceConfigController extends CommonCtrl {
@GetMapping @GetMapping
public ApiRes list() { public ApiRes list() {
List<PayInterfaceDefine> list = payInterfaceConfigService.selectAllPayIfConfigListByInfoId(CS.INFO_TYPE_ISV, getValStringRequired("isvNo")); List<PayInterfaceDefine> list = payInterfaceConfigService.selectAllPayIfConfigListByIsvNo(CS.INFO_TYPE_ISV, getValStringRequired("isvNo"));
return ApiRes.ok(list); return ApiRes.ok(list);
} }
......
/*
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeequan.jeepay.mgr.ctrl.merchant;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jeequan.jeepay.core.aop.MethodLog;
import com.jeequan.jeepay.core.constants.ApiCodeEnum;
import com.jeequan.jeepay.core.entity.MchApp;
import com.jeequan.jeepay.core.entity.MchInfo;
import com.jeequan.jeepay.core.entity.PayOrder;
import com.jeequan.jeepay.core.exception.BizException;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.mgr.mq.queue.MqQueue4ModifyMchUserRemove;
import com.jeequan.jeepay.mgr.mq.topic.MqTopic4ModifyMchApp;
import com.jeequan.jeepay.service.impl.MchAppService;
import com.jeequan.jeepay.service.impl.MchInfoService;
import com.jeequan.jeepay.service.impl.PayOrderService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
/**
* 商户应用管理类
*
* @author zhuxiao
* @site https://www.jeepay.vip
* @date 2021-06-16 09:15
*/
@RestController
@RequestMapping("/api/mchApps")
public class MchAppController extends CommonCtrl {
@Autowired private MchInfoService mchInfoService;
@Autowired private MchAppService mchAppService;
@Autowired private MqTopic4ModifyMchApp mqTopic4ModifyMchApp;
/**
* @Author: ZhuXiao
* @Description: 应用列表
* @Date: 9:59 2021/6/16
*/
@PreAuthorize("hasAuthority('ENT_MCH_APP_LIST')")
@GetMapping
public ApiRes list() {
MchApp mchApp = getObject(MchApp.class);
LambdaQueryWrapper<MchApp> wrapper = MchApp.gw();
if (StringUtils.isNotEmpty(mchApp.getMchNo())) wrapper.eq(MchApp::getMchNo, mchApp.getMchNo());
if (StringUtils.isNotEmpty(mchApp.getAppId())) wrapper.eq(MchApp::getAppId, mchApp.getAppId());
if (StringUtils.isNotEmpty(mchApp.getAppName())) wrapper.eq(MchApp::getAppName, mchApp.getAppName());
if (mchApp.getState() != null) wrapper.eq(MchApp::getState, mchApp.getState());
wrapper.orderByDesc(MchApp::getCreatedAt);
IPage<MchApp> pages = mchAppService.page(getIPage(), wrapper);
return ApiRes.ok(pages);
}
/**
* @Author: ZhuXiao
* @Description: 新建应用
* @Date: 10:05 2021/6/16
*/
@PreAuthorize("hasAuthority('ENT_MCH_APP_ADD')")
@MethodLog(remark = "新建应用")
@PostMapping
public ApiRes add() {
MchApp mchApp = getObject(MchApp.class);
if(mchInfoService.getById(mchApp.getMchNo()) == null) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
boolean result = mchAppService.save(mchApp);
if (!result) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_CREATE);
}
return ApiRes.ok();
}
/**
* @Author: ZhuXiao
* @Description: 应用详情
* @Date: 10:13 2021/6/16
*/
@PreAuthorize("hasAnyAuthority('ENT_MCH_APP_VIEW', 'ENT_MCH_APP_EDIT')")
@GetMapping("/{appId}")
public ApiRes detail(@PathVariable("appId") String appId) {
MchApp mchApp = mchAppService.getById(appId);
if (mchApp == null) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
return ApiRes.ok(mchApp);
}
/**
* @Author: ZhuXiao
* @Description: 更新应用信息
* @Date: 10:11 2021/6/16
*/
@PreAuthorize("hasAuthority('ENT_MCH_APP_EDIT')")
@MethodLog(remark = "更新应用信息")
@PutMapping("/{appId}")
public ApiRes update(@PathVariable("appId") String appId) {
MchApp mchApp = getObject(MchApp.class);
mchApp.setAppId(appId);
boolean result = mchAppService.updateById(mchApp);
if (!result) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_UPDATE);
}
// 推送修改应用消息
mqTopic4ModifyMchApp.push(mchApp.getMchNo(), mchApp.getAppId());
return ApiRes.ok();
}
/**
* @Author: ZhuXiao
* @Description: 删除应用
* @Date: 10:14 2021/6/16
*/
@PreAuthorize("hasAuthority('ENT_MCH_APP_DEL')")
@MethodLog(remark = "删除应用")
@DeleteMapping("/{appId}")
public ApiRes delete(@PathVariable("appId") String appId) {
MchApp mchApp = mchAppService.getById(appId);
mchAppService.removeByAppId(appId);
// 推送mq到目前节点进行更新数据
mqTopic4ModifyMchApp.push(mchApp.getMchNo(), appId);
return ApiRes.ok();
}
}
...@@ -18,11 +18,14 @@ package com.jeequan.jeepay.mgr.ctrl.merchant; ...@@ -18,11 +18,14 @@ package com.jeequan.jeepay.mgr.ctrl.merchant;
import com.jeequan.jeepay.core.aop.MethodLog; import com.jeequan.jeepay.core.aop.MethodLog;
import com.jeequan.jeepay.core.constants.ApiCodeEnum; import com.jeequan.jeepay.core.constants.ApiCodeEnum;
import com.jeequan.jeepay.core.constants.CS; import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.entity.MchApp;
import com.jeequan.jeepay.core.entity.PayInterfaceConfig; import com.jeequan.jeepay.core.entity.PayInterfaceConfig;
import com.jeequan.jeepay.core.entity.PayInterfaceDefine; import com.jeequan.jeepay.core.entity.PayInterfaceDefine;
import com.jeequan.jeepay.core.model.ApiRes; import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl; import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.mgr.mq.topic.MqTopic4ModifyMchApp;
import com.jeequan.jeepay.mgr.mq.topic.MqTopic4ModifyMchInfo; import com.jeequan.jeepay.mgr.mq.topic.MqTopic4ModifyMchInfo;
import com.jeequan.jeepay.service.impl.MchAppService;
import com.jeequan.jeepay.service.impl.PayInterfaceConfigService; import com.jeequan.jeepay.service.impl.PayInterfaceConfigService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
...@@ -43,30 +46,31 @@ import java.util.List; ...@@ -43,30 +46,31 @@ import java.util.List;
public class MchPayInterfaceConfigController extends CommonCtrl { public class MchPayInterfaceConfigController extends CommonCtrl {
@Autowired private PayInterfaceConfigService payInterfaceConfigService; @Autowired private PayInterfaceConfigService payInterfaceConfigService;
@Autowired private MqTopic4ModifyMchInfo mqTopic4ModifyMchInfo; @Autowired private MqTopic4ModifyMchApp mqTopic4ModifyMchApp;
@Autowired private MchAppService mchAppService;
/** /**
* @Author: ZhuXiao * @Author: ZhuXiao
* @Description: 查询商户支付接口配置列表 * @Description: 查询应用支付接口配置列表
* @Date: 15:50 2021/4/27 * @Date: 15:50 2021/4/27
*/ */
@PreAuthorize("hasAuthority('ENT_MCH_PAY_CONFIG_LIST')") @PreAuthorize("hasAuthority('ENT_MCH_PAY_CONFIG_LIST')")
@GetMapping @GetMapping
public ApiRes list() { public ApiRes list() {
List<PayInterfaceDefine> list = payInterfaceConfigService.selectAllPayIfConfigListByInfoId(CS.INFO_TYPE_MCH, getValStringRequired("mchNo")); List<PayInterfaceDefine> list = payInterfaceConfigService.selectAllPayIfConfigListByAppId(getValStringRequired("appId"));
return ApiRes.ok(list); return ApiRes.ok(list);
} }
/** /**
* @Author: ZhuXiao * @Author: ZhuXiao
* @Description: 根据 商户号、接口类型 获取商户参数配置 * @Description: 根据 appId、接口类型 获取应用参数配置
* @Date: 17:03 2021/4/27 * @Date: 17:03 2021/4/27
*/ */
@PreAuthorize("hasAuthority('ENT_MCH_PAY_CONFIG_VIEW')") @PreAuthorize("hasAuthority('ENT_MCH_PAY_CONFIG_VIEW')")
@GetMapping("/{mchNo}/{ifCode}") @GetMapping("/{appId}/{ifCode}")
public ApiRes getByMchNo(@PathVariable(value = "mchNo") String mchNo, @PathVariable(value = "ifCode") String ifCode) { public ApiRes getByAppId(@PathVariable(value = "appId") String appId, @PathVariable(value = "ifCode") String ifCode) {
PayInterfaceConfig payInterfaceConfig = payInterfaceConfigService.getByInfoIdAndIfCode(CS.INFO_TYPE_MCH, mchNo, ifCode); PayInterfaceConfig payInterfaceConfig = payInterfaceConfigService.getByInfoIdAndIfCode(CS.INFO_TYPE_MCH_APP, appId, ifCode);
if (payInterfaceConfig != null && payInterfaceConfig.getIfRate() != null) { if (payInterfaceConfig != null && payInterfaceConfig.getIfRate() != null) {
payInterfaceConfig.setIfRate(payInterfaceConfig.getIfRate().multiply(new BigDecimal("100"))); payInterfaceConfig.setIfRate(payInterfaceConfig.getIfRate().multiply(new BigDecimal("100")));
} }
...@@ -75,19 +79,25 @@ public class MchPayInterfaceConfigController extends CommonCtrl { ...@@ -75,19 +79,25 @@ public class MchPayInterfaceConfigController extends CommonCtrl {
/** /**
* @Author: ZhuXiao * @Author: ZhuXiao
* @Description: 商户支付接口配置 * @Description: 应用支付接口配置
* @Date: 16:13 2021/4/27 * @Date: 16:13 2021/4/27
*/ */
@PreAuthorize("hasAuthority('ENT_MCH_PAY_CONFIG_ADD')") @PreAuthorize("hasAuthority('ENT_MCH_PAY_CONFIG_ADD')")
@PostMapping @PostMapping
@MethodLog(remark = "更新商户支付参数") @MethodLog(remark = "更新应用支付参数")
public ApiRes saveOrUpdate() { public ApiRes saveOrUpdate() {
String infoId = getValStringRequired("infoId"); String infoId = getValStringRequired("infoId");
String ifCode = getValStringRequired("ifCode"); String ifCode = getValStringRequired("ifCode");
MchApp mchApp = mchAppService.getById(infoId);
if (mchApp == null || mchApp.getState() != CS.YES) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
PayInterfaceConfig payInterfaceConfig = getObject(PayInterfaceConfig.class); PayInterfaceConfig payInterfaceConfig = getObject(PayInterfaceConfig.class);
payInterfaceConfig.setInfoType(CS.INFO_TYPE_MCH); payInterfaceConfig.setInfoType(CS.INFO_TYPE_MCH_APP);
payInterfaceConfig.setInfoId(infoId);
// 存入真实费率 // 存入真实费率
if (payInterfaceConfig.getIfRate() != null) { if (payInterfaceConfig.getIfRate() != null) {
...@@ -101,7 +111,7 @@ public class MchPayInterfaceConfigController extends CommonCtrl { ...@@ -101,7 +111,7 @@ public class MchPayInterfaceConfigController extends CommonCtrl {
payInterfaceConfig.setUpdatedBy(realName); payInterfaceConfig.setUpdatedBy(realName);
//根据 商户号、接口类型 获取商户参数配置 //根据 商户号、接口类型 获取商户参数配置
PayInterfaceConfig dbRecoed = payInterfaceConfigService.getByInfoIdAndIfCode(CS.INFO_TYPE_MCH, infoId, ifCode); PayInterfaceConfig dbRecoed = payInterfaceConfigService.getByInfoIdAndIfCode(CS.INFO_TYPE_MCH_APP, infoId, ifCode);
//若配置存在,为saveOrUpdate添加ID,第一次配置添加创建者 //若配置存在,为saveOrUpdate添加ID,第一次配置添加创建者
if (dbRecoed != null) { if (dbRecoed != null) {
payInterfaceConfig.setId(dbRecoed.getId()); payInterfaceConfig.setId(dbRecoed.getId());
...@@ -115,7 +125,7 @@ public class MchPayInterfaceConfigController extends CommonCtrl { ...@@ -115,7 +125,7 @@ public class MchPayInterfaceConfigController extends CommonCtrl {
return ApiRes.fail(ApiCodeEnum.SYSTEM_ERROR, "配置失败"); return ApiRes.fail(ApiCodeEnum.SYSTEM_ERROR, "配置失败");
} }
mqTopic4ModifyMchInfo.push(infoId); // 推送mq到目前节点进行更新数据 mqTopic4ModifyMchApp.push(mchApp.getMchNo(), infoId); // 推送mq到目前节点进行更新数据
return ApiRes.ok(); return ApiRes.ok();
} }
......
...@@ -23,16 +23,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -23,16 +23,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jeequan.jeepay.core.aop.MethodLog; import com.jeequan.jeepay.core.aop.MethodLog;
import com.jeequan.jeepay.core.constants.ApiCodeEnum; import com.jeequan.jeepay.core.constants.ApiCodeEnum;
import com.jeequan.jeepay.core.constants.CS; import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.entity.MchInfo; import com.jeequan.jeepay.core.entity.*;
import com.jeequan.jeepay.core.entity.MchPayPassage; import com.jeequan.jeepay.core.exception.BizException;
import com.jeequan.jeepay.core.entity.PayInterfaceConfig;
import com.jeequan.jeepay.core.entity.PayWay;
import com.jeequan.jeepay.core.model.ApiRes; import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl; import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.service.impl.MchInfoService; import com.jeequan.jeepay.service.impl.*;
import com.jeequan.jeepay.service.impl.MchPayPassageService;
import com.jeequan.jeepay.service.impl.PayInterfaceConfigService;
import com.jeequan.jeepay.service.impl.PayWayService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -54,9 +49,9 @@ import java.util.List; ...@@ -54,9 +49,9 @@ import java.util.List;
public class MchPayPassageConfigController extends CommonCtrl { public class MchPayPassageConfigController extends CommonCtrl {
@Autowired private MchPayPassageService mchPayPassageService; @Autowired private MchPayPassageService mchPayPassageService;
@Autowired private PayInterfaceConfigService payInterfaceConfigService;
@Autowired private PayWayService payWayService; @Autowired private PayWayService payWayService;
@Autowired private MchInfoService mchInfoService; @Autowired private MchInfoService mchInfoService;
@Autowired private MchAppService mchAppService;
/** /**
...@@ -68,7 +63,7 @@ public class MchPayPassageConfigController extends CommonCtrl { ...@@ -68,7 +63,7 @@ public class MchPayPassageConfigController extends CommonCtrl {
@GetMapping @GetMapping
public ApiRes list() { public ApiRes list() {
String mchNo = getValStringRequired("mchNo"); String appId = getValStringRequired("appId");
String wayCode = getValString("wayCode"); String wayCode = getValString("wayCode");
String wayName = getValString("wayName"); String wayName = getValString("wayName");
...@@ -84,10 +79,10 @@ public class MchPayPassageConfigController extends CommonCtrl { ...@@ -84,10 +79,10 @@ public class MchPayPassageConfigController extends CommonCtrl {
List<String> wayCodeList = new LinkedList<>(); List<String> wayCodeList = new LinkedList<>();
payWayPage.getRecords().stream().forEach(payWay -> wayCodeList.add(payWay.getWayCode())); payWayPage.getRecords().stream().forEach(payWay -> wayCodeList.add(payWay.getWayCode()));
// 商户支付通道集合 // 应用支付通道集合
List<MchPayPassage> mchPayPassageList = mchPayPassageService.list(MchPayPassage.gw() List<MchPayPassage> mchPayPassageList = mchPayPassageService.list(MchPayPassage.gw()
.select(MchPayPassage::getWayCode, MchPayPassage::getState) .select(MchPayPassage::getWayCode, MchPayPassage::getState)
.eq(MchPayPassage::getMchNo, mchNo) .eq(MchPayPassage::getAppId, appId)
.in(MchPayPassage::getWayCode, wayCodeList)); .in(MchPayPassage::getWayCode, wayCodeList));
for (PayWay payWay : payWayPage.getRecords()) { for (PayWay payWay : payWayPage.getRecords()) {
...@@ -107,41 +102,32 @@ public class MchPayPassageConfigController extends CommonCtrl { ...@@ -107,41 +102,32 @@ public class MchPayPassageConfigController extends CommonCtrl {
/** /**
* @Author: ZhuXiao * @Author: ZhuXiao
* @Description: 根据商户号、支付方式查询可用的支付接口列表 * @Description: 根据appId、支付方式查询可用的支付接口列表
* @Date: 17:55 2021/5/8 * @Date: 17:55 2021/5/8
*/ */
@PreAuthorize("hasAuthority('ENT_MCH_PAY_PASSAGE_CONFIG')") @PreAuthorize("hasAuthority('ENT_MCH_PAY_PASSAGE_CONFIG')")
@GetMapping("/availablePayInterface/{mchNo}/{wayCode}") @GetMapping("/availablePayInterface/{appId}/{wayCode}")
public ApiRes availablePayInterface(@PathVariable("mchNo") String mchNo, @PathVariable("wayCode") String wayCode) { public ApiRes availablePayInterface(@PathVariable("appId") String appId, @PathVariable("wayCode") String wayCode) {
MchInfo mchInfo = mchInfoService.getById(mchNo); MchApp mchApp = mchAppService.getById(appId);
if (mchApp == null || mchApp.getState() != CS.YES) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
MchInfo mchInfo = mchInfoService.getById(mchApp.getMchNo());
if (mchInfo == null || mchInfo.getState() != CS.YES) { if (mchInfo == null || mchInfo.getState() != CS.YES) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE); return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
} }
// 根据支付方式查询可用支付接口列表 // 根据支付方式查询可用支付接口列表
List<JSONObject> list = mchPayPassageService.selectAvailablePayInterfaceList(wayCode, mchNo, CS.INFO_TYPE_MCH, mchInfo.getType()); List<JSONObject> list = mchPayPassageService.selectAvailablePayInterfaceList(wayCode, appId, CS.INFO_TYPE_MCH_APP, mchInfo.getType());
return ApiRes.ok(list); return ApiRes.ok(list);
} }
/** /**
* @Author: ZhuXiao * @Author: ZhuXiao
* @Description: 根据 商户号、接口类型 获取商户参数配置 * @Description: 应用支付通道配置
* @Date: 17:03 2021/4/27
*/
@GetMapping("/{mchNo}/{ifCode}")
public ApiRes getByMchNo(@PathVariable(value = "mchNo") String mchNo, @PathVariable(value = "ifCode") String ifCode) {
PayInterfaceConfig payInterfaceConfig = payInterfaceConfigService.getByInfoIdAndIfCode(CS.INFO_TYPE_MCH, mchNo, ifCode);
if (payInterfaceConfig != null && payInterfaceConfig.getIfRate() != null) {
payInterfaceConfig.setIfRate(payInterfaceConfig.getIfRate().multiply(new BigDecimal("100")));
}
return ApiRes.ok(payInterfaceConfig);
}
/**
* @Author: ZhuXiao
* @Description: 商户支付通道配置
* @Date: 17:36 2021/5/8 * @Date: 17:36 2021/5/8
*/ */
@PreAuthorize("hasAuthority('ENT_MCH_PAY_PASSAGE_ADD')") @PreAuthorize("hasAuthority('ENT_MCH_PAY_PASSAGE_ADD')")
...@@ -153,7 +139,15 @@ public class MchPayPassageConfigController extends CommonCtrl { ...@@ -153,7 +139,15 @@ public class MchPayPassageConfigController extends CommonCtrl {
try { try {
List<MchPayPassage> mchPayPassageList = JSONArray.parseArray(reqParams, MchPayPassage.class); List<MchPayPassage> mchPayPassageList = JSONArray.parseArray(reqParams, MchPayPassage.class);
mchPayPassageService.saveOrUpdateBatchSelf(mchPayPassageList); if (CollectionUtils.isEmpty(mchPayPassageList)) {
throw new BizException("操作失败");
}
MchApp mchApp = mchAppService.getById(mchPayPassageList.get(0).getAppId());
if (mchApp == null || mchApp.getState() != CS.YES) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
mchPayPassageService.saveOrUpdateBatchSelf(mchPayPassageList, mchApp.getMchNo());
return ApiRes.ok(); return ApiRes.ok();
}catch (Exception e) { }catch (Exception e) {
return ApiRes.fail(ApiCodeEnum.SYSTEM_ERROR); return ApiRes.fail(ApiCodeEnum.SYSTEM_ERROR);
......
/*
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeequan.jeepay.mch.ctrl.merchant;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jeequan.jeepay.core.aop.MethodLog;
import com.jeequan.jeepay.core.constants.ApiCodeEnum;
import com.jeequan.jeepay.core.entity.MchApp;
import com.jeequan.jeepay.core.exception.BizException;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.mch.ctrl.CommonCtrl;
import com.jeequan.jeepay.mch.mq.topic.MqTopic4ModifyMchApp;
import com.jeequan.jeepay.service.impl.MchAppService;
import com.jeequan.jeepay.service.impl.MchInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
/**
* 商户应用管理类
*
* @author zhuxiao
* @site https://www.jeepay.vip
* @date 2021-06-16 09:15
*/
@RestController
@RequestMapping("/api/mchApps")
public class MchAppController extends CommonCtrl {
@Autowired private MchAppService mchAppService;
@Autowired private MqTopic4ModifyMchApp mqTopic4ModifyMchApp;
/**
* @Author: ZhuXiao
* @Description: 应用列表
* @Date: 9:59 2021/6/16
*/
@PreAuthorize("hasAuthority('ENT_MCH_APP_LIST')")
@GetMapping
public ApiRes list() {
MchApp mchApp = getObject(MchApp.class);
LambdaQueryWrapper<MchApp> wrapper = MchApp.gw();
wrapper.eq(MchApp::getMchNo, getCurrentMchNo());
if (StringUtils.isNotEmpty(mchApp.getAppId())) wrapper.eq(MchApp::getAppId, mchApp.getAppId());
if (StringUtils.isNotEmpty(mchApp.getAppName())) wrapper.eq(MchApp::getAppName, mchApp.getAppName());
if (mchApp.getState() != null) wrapper.eq(MchApp::getState, mchApp.getState());
wrapper.orderByDesc(MchApp::getCreatedAt);
IPage<MchApp> pages = mchAppService.page(getIPage(), wrapper);
return ApiRes.ok(pages);
}
/**
* @Author: ZhuXiao
* @Description: 新建应用
* @Date: 10:05 2021/6/16
*/
@PreAuthorize("hasAuthority('ENT_MCH_APP_ADD')")
@MethodLog(remark = "新建应用")
@PostMapping
public ApiRes add() {
MchApp mchApp = getObject(MchApp.class);
mchApp.setMchNo(getCurrentMchNo());
boolean result = mchAppService.save(mchApp);
if (!result) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_CREATE);
}
return ApiRes.ok();
}
/**
* @Author: ZhuXiao
* @Description: 应用详情
* @Date: 10:13 2021/6/16
*/
@PreAuthorize("hasAnyAuthority('ENT_MCH_APP_VIEW', 'ENT_MCH_APP_EDIT')")
@GetMapping("/{appId}")
public ApiRes detail(@PathVariable("appId") String appId) {
MchApp mchApp = mchAppService.getById(appId);
if (mchApp == null || !mchApp.getMchNo().equals(getCurrentMchNo())) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
return ApiRes.ok(mchApp);
}
/**
* @Author: ZhuXiao
* @Description: 更新应用信息
* @Date: 10:11 2021/6/16
*/
@PreAuthorize("hasAuthority('ENT_MCH_APP_EDIT')")
@MethodLog(remark = "更新应用信息")
@PutMapping("/{appId}")
public ApiRes update(@PathVariable("appId") String appId) {
MchApp mchApp = getObject(MchApp.class);
mchApp.setAppId(appId);
MchApp dbRecord = mchAppService.getById(appId);
if (!dbRecord.getMchNo().equals(getCurrentMchNo())) {
throw new BizException("无权操作!");
}
boolean result = mchAppService.updateById(mchApp);
if (!result) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_UPDATE);
}
// 推送修改应用消息
mqTopic4ModifyMchApp.push(getCurrentMchNo(), mchApp.getAppId());
return ApiRes.ok();
}
/**
* @Author: ZhuXiao
* @Description: 删除应用
* @Date: 10:14 2021/6/16
*/
@PreAuthorize("hasAuthority('ENT_MCH_APP_DEL')")
@MethodLog(remark = "删除应用")
@DeleteMapping("/{appId}")
public ApiRes delete(@PathVariable("appId") String appId) {
MchApp mchApp = mchAppService.getById(appId);
if (!mchApp.getMchNo().equals(getCurrentMchNo())) {
throw new BizException("无权操作!");
}
mchAppService.removeByAppId(appId);
// 推送mq到目前节点进行更新数据
mqTopic4ModifyMchApp.push(getCurrentMchNo(), appId);
return ApiRes.ok();
}
}
...@@ -23,6 +23,7 @@ import com.jeequan.jeepay.core.entity.PayInterfaceDefine; ...@@ -23,6 +23,7 @@ import com.jeequan.jeepay.core.entity.PayInterfaceDefine;
import com.jeequan.jeepay.core.exception.BizException; import com.jeequan.jeepay.core.exception.BizException;
import com.jeequan.jeepay.core.model.ApiRes; import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.mch.ctrl.CommonCtrl; import com.jeequan.jeepay.mch.ctrl.CommonCtrl;
import com.jeequan.jeepay.mch.mq.topic.MqTopic4ModifyMchApp;
import com.jeequan.jeepay.service.impl.MchInfoService; import com.jeequan.jeepay.service.impl.MchInfoService;
import com.jeequan.jeepay.service.impl.PayInterfaceConfigService; import com.jeequan.jeepay.service.impl.PayInterfaceConfigService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -44,6 +45,7 @@ import java.util.List; ...@@ -44,6 +45,7 @@ import java.util.List;
public class MchPayInterfaceConfigController extends CommonCtrl { public class MchPayInterfaceConfigController extends CommonCtrl {
@Autowired private PayInterfaceConfigService payInterfaceConfigService; @Autowired private PayInterfaceConfigService payInterfaceConfigService;
@Autowired private MqTopic4ModifyMchApp mqTopic4ModifyMchApp;
@Autowired private MchInfoService mchInfoService; @Autowired private MchInfoService mchInfoService;
/** /**
...@@ -55,7 +57,7 @@ public class MchPayInterfaceConfigController extends CommonCtrl { ...@@ -55,7 +57,7 @@ public class MchPayInterfaceConfigController extends CommonCtrl {
@GetMapping @GetMapping
public ApiRes list() { public ApiRes list() {
MchInfo mchInfo = mchInfoService.getById(getCurrentUser().getSysUser().getBelongInfoId()); MchInfo mchInfo = mchInfoService.getById(getCurrentUser().getSysUser().getBelongInfoId());
List<PayInterfaceDefine> list = payInterfaceConfigService.selectAllPayIfConfigListByInfoId(CS.INFO_TYPE_MCH, getCurrentUser().getSysUser().getBelongInfoId()); List<PayInterfaceDefine> list = payInterfaceConfigService.selectAllPayIfConfigListByAppId(getValStringRequired("appId"));
for (PayInterfaceDefine define : list) { for (PayInterfaceDefine define : list) {
define.addExt("mchParams", mchInfo.getType() == CS.MCH_TYPE_NORMAL ? define.getNormalMchParams() : define.getIsvsubMchParams()); define.addExt("mchParams", mchInfo.getType() == CS.MCH_TYPE_NORMAL ? define.getNormalMchParams() : define.getIsvsubMchParams());
...@@ -71,9 +73,9 @@ public class MchPayInterfaceConfigController extends CommonCtrl { ...@@ -71,9 +73,9 @@ public class MchPayInterfaceConfigController extends CommonCtrl {
* @Date: 10:54 2021/5/13 * @Date: 10:54 2021/5/13
*/ */
@PreAuthorize("hasAuthority('ENT_MCH_PAY_CONFIG_VIEW')") @PreAuthorize("hasAuthority('ENT_MCH_PAY_CONFIG_VIEW')")
@GetMapping("/{ifCode}") @GetMapping("/{appId}/{ifCode}")
public ApiRes getByMchNo(@PathVariable(value = "ifCode") String ifCode) { public ApiRes getByMchNo(@PathVariable(value = "appId") String appId, @PathVariable(value = "ifCode") String ifCode) {
PayInterfaceConfig payInterfaceConfig = payInterfaceConfigService.getByInfoIdAndIfCode(CS.INFO_TYPE_MCH, getCurrentUser().getSysUser().getBelongInfoId(), ifCode); PayInterfaceConfig payInterfaceConfig = payInterfaceConfigService.getByInfoIdAndIfCode(CS.INFO_TYPE_MCH_APP, appId, ifCode);
if (payInterfaceConfig != null && payInterfaceConfig.getIfRate() != null) { if (payInterfaceConfig != null && payInterfaceConfig.getIfRate() != null) {
payInterfaceConfig.setIfRate(payInterfaceConfig.getIfRate().multiply(new BigDecimal("100"))); payInterfaceConfig.setIfRate(payInterfaceConfig.getIfRate().multiply(new BigDecimal("100")));
} }
...@@ -90,12 +92,12 @@ public class MchPayInterfaceConfigController extends CommonCtrl { ...@@ -90,12 +92,12 @@ public class MchPayInterfaceConfigController extends CommonCtrl {
@MethodLog(remark = "更新商户支付参数") @MethodLog(remark = "更新商户支付参数")
public ApiRes saveOrUpdate() { public ApiRes saveOrUpdate() {
String mchNo = getCurrentUser().getSysUser().getBelongInfoId();
String ifCode = getValStringRequired("ifCode"); String ifCode = getValStringRequired("ifCode");
String infoId = getValStringRequired("infoId");
PayInterfaceConfig payInterfaceConfig = getObject(PayInterfaceConfig.class); PayInterfaceConfig payInterfaceConfig = getObject(PayInterfaceConfig.class);
payInterfaceConfig.setInfoType(CS.INFO_TYPE_MCH); payInterfaceConfig.setInfoType(CS.INFO_TYPE_MCH_APP);
payInterfaceConfig.setInfoId(mchNo); payInterfaceConfig.setInfoId(infoId);
// 存入真实费率 // 存入真实费率
if (payInterfaceConfig.getIfRate() != null) { if (payInterfaceConfig.getIfRate() != null) {
...@@ -109,7 +111,7 @@ public class MchPayInterfaceConfigController extends CommonCtrl { ...@@ -109,7 +111,7 @@ public class MchPayInterfaceConfigController extends CommonCtrl {
payInterfaceConfig.setUpdatedBy(realName); payInterfaceConfig.setUpdatedBy(realName);
//根据 商户号、接口类型 获取商户参数配置 //根据 商户号、接口类型 获取商户参数配置
PayInterfaceConfig dbRecoed = payInterfaceConfigService.getByInfoIdAndIfCode(CS.INFO_TYPE_MCH, mchNo, ifCode); PayInterfaceConfig dbRecoed = payInterfaceConfigService.getByInfoIdAndIfCode(CS.INFO_TYPE_MCH_APP, infoId, ifCode);
//若配置存在,为saveOrUpdate添加ID,第一次配置添加创建者 //若配置存在,为saveOrUpdate添加ID,第一次配置添加创建者
if (dbRecoed != null) { if (dbRecoed != null) {
payInterfaceConfig.setId(dbRecoed.getId()); payInterfaceConfig.setId(dbRecoed.getId());
...@@ -122,6 +124,9 @@ public class MchPayInterfaceConfigController extends CommonCtrl { ...@@ -122,6 +124,9 @@ public class MchPayInterfaceConfigController extends CommonCtrl {
if (!result) { if (!result) {
throw new BizException("配置失败"); throw new BizException("配置失败");
} }
mqTopic4ModifyMchApp.push(getCurrentMchNo(), infoId); // 推送mq到目前节点进行更新数据
return ApiRes.ok(); return ApiRes.ok();
} }
......
...@@ -25,13 +25,11 @@ import com.jeequan.jeepay.core.constants.ApiCodeEnum; ...@@ -25,13 +25,11 @@ import com.jeequan.jeepay.core.constants.ApiCodeEnum;
import com.jeequan.jeepay.core.constants.CS; import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.entity.MchInfo; import com.jeequan.jeepay.core.entity.MchInfo;
import com.jeequan.jeepay.core.entity.MchPayPassage; import com.jeequan.jeepay.core.entity.MchPayPassage;
import com.jeequan.jeepay.core.entity.PayInterfaceConfig;
import com.jeequan.jeepay.core.entity.PayWay; import com.jeequan.jeepay.core.entity.PayWay;
import com.jeequan.jeepay.core.model.ApiRes; import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.mch.ctrl.CommonCtrl; import com.jeequan.jeepay.mch.ctrl.CommonCtrl;
import com.jeequan.jeepay.service.impl.MchInfoService; import com.jeequan.jeepay.service.impl.MchInfoService;
import com.jeequan.jeepay.service.impl.MchPayPassageService; import com.jeequan.jeepay.service.impl.MchPayPassageService;
import com.jeequan.jeepay.service.impl.PayInterfaceConfigService;
import com.jeequan.jeepay.service.impl.PayWayService; import com.jeequan.jeepay.service.impl.PayWayService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
...@@ -54,7 +52,6 @@ import java.util.List; ...@@ -54,7 +52,6 @@ import java.util.List;
public class MchPayPassageConfigController extends CommonCtrl { public class MchPayPassageConfigController extends CommonCtrl {
@Autowired private MchPayPassageService mchPayPassageService; @Autowired private MchPayPassageService mchPayPassageService;
@Autowired private PayInterfaceConfigService payInterfaceConfigService;
@Autowired private PayWayService payWayService; @Autowired private PayWayService payWayService;
@Autowired private MchInfoService mchInfoService; @Autowired private MchInfoService mchInfoService;
...@@ -67,14 +64,14 @@ public class MchPayPassageConfigController extends CommonCtrl { ...@@ -67,14 +64,14 @@ public class MchPayPassageConfigController extends CommonCtrl {
@GetMapping @GetMapping
public ApiRes list() { public ApiRes list() {
String mchNo = getCurrentUser().getSysUser().getBelongInfoId(); String appId = getValStringRequired("appId");
String wayCode = getValString("wayCode"); String wayCode = getValString("wayCode");
String wayName = getValString("wayName"); String wayName = getValString("wayName");
//支付方式集合 //支付方式集合
LambdaQueryWrapper<PayWay> wrapper = PayWay.gw(); LambdaQueryWrapper<PayWay> wrapper = PayWay.gw();
if (StrUtil.isNotBlank(wayCode)) wrapper.eq(PayWay::getWayCode, wayCode); if (StrUtil.isNotBlank(wayCode)) wrapper.eq(PayWay::getWayCode, wayCode);
if (StrUtil.isNotBlank(wayName)) wrapper.like(PayWay::getWayName, "%" + wayName + "%"); if (StrUtil.isNotBlank(wayName)) wrapper.like(PayWay::getWayName, wayName);
IPage<PayWay> payWayPage = payWayService.page(getIPage(), wrapper); IPage<PayWay> payWayPage = payWayService.page(getIPage(), wrapper);
if (!CollectionUtils.isEmpty(payWayPage.getRecords())) { if (!CollectionUtils.isEmpty(payWayPage.getRecords())) {
...@@ -86,7 +83,8 @@ public class MchPayPassageConfigController extends CommonCtrl { ...@@ -86,7 +83,8 @@ public class MchPayPassageConfigController extends CommonCtrl {
// 商户支付通道集合 // 商户支付通道集合
List<MchPayPassage> mchPayPassageList = mchPayPassageService.list(MchPayPassage.gw() List<MchPayPassage> mchPayPassageList = mchPayPassageService.list(MchPayPassage.gw()
.select(MchPayPassage::getWayCode, MchPayPassage::getState) .select(MchPayPassage::getWayCode, MchPayPassage::getState)
.eq(MchPayPassage::getMchNo, mchNo) .eq(MchPayPassage::getAppId, appId)
.eq(MchPayPassage::getMchNo, getCurrentMchNo())
.in(MchPayPassage::getWayCode, wayCodeList)); .in(MchPayPassage::getWayCode, wayCodeList));
for (PayWay payWay : payWayPage.getRecords()) { for (PayWay payWay : payWayPage.getRecords()) {
...@@ -106,12 +104,12 @@ public class MchPayPassageConfigController extends CommonCtrl { ...@@ -106,12 +104,12 @@ public class MchPayPassageConfigController extends CommonCtrl {
/** /**
* @Author: ZhuXiao * @Author: ZhuXiao
* @Description: 根据商户号、支付方式查询可用的支付接口列表 * @Description: 根据appId、支付方式查询可用的支付接口列表
* @Date: 11:05 2021/5/13 * @Date: 11:05 2021/5/13
*/ */
@PreAuthorize("hasAuthority('ENT_MCH_PAY_PASSAGE_CONFIG')") @PreAuthorize("hasAuthority('ENT_MCH_PAY_PASSAGE_CONFIG')")
@GetMapping("/availablePayInterface/{wayCode}") @GetMapping("/availablePayInterface/{appId}/{wayCode}")
public ApiRes availablePayInterface(@PathVariable("wayCode") String wayCode) { public ApiRes availablePayInterface(@PathVariable("appId") String appId, @PathVariable("wayCode") String wayCode) {
String mchNo = getCurrentUser().getSysUser().getBelongInfoId(); String mchNo = getCurrentUser().getSysUser().getBelongInfoId();
MchInfo mchInfo = mchInfoService.getById(mchNo); MchInfo mchInfo = mchInfoService.getById(mchNo);
...@@ -120,26 +118,11 @@ public class MchPayPassageConfigController extends CommonCtrl { ...@@ -120,26 +118,11 @@ public class MchPayPassageConfigController extends CommonCtrl {
} }
// 根据支付方式查询可用支付接口列表 // 根据支付方式查询可用支付接口列表
List<JSONObject> list = mchPayPassageService.selectAvailablePayInterfaceList(wayCode, mchNo, CS.INFO_TYPE_MCH, mchInfo.getType()); List<JSONObject> list = mchPayPassageService.selectAvailablePayInterfaceList(wayCode, appId, CS.INFO_TYPE_MCH_APP, mchInfo.getType());
return ApiRes.ok(list); return ApiRes.ok(list);
} }
/**
* @Author: ZhuXiao
* @Description: 根据 商户号、接口类型 获取商户参数配置
* @Date: 11:05 2021/5/13
*/
@GetMapping("/{ifCode}")
public ApiRes getByMchNo(@PathVariable(value = "ifCode") String ifCode) {
String mchNo = getCurrentUser().getSysUser().getBelongInfoId();
PayInterfaceConfig payInterfaceConfig = payInterfaceConfigService.getByInfoIdAndIfCode(CS.INFO_TYPE_MCH, mchNo, ifCode);
if (payInterfaceConfig != null && payInterfaceConfig.getIfRate() != null) {
payInterfaceConfig.setIfRate(payInterfaceConfig.getIfRate().multiply(new BigDecimal("100")));
}
return ApiRes.ok(payInterfaceConfig);
}
/** /**
* @Author: ZhuXiao * @Author: ZhuXiao
* @Description: * @Description:
...@@ -156,19 +139,19 @@ public class MchPayPassageConfigController extends CommonCtrl { ...@@ -156,19 +139,19 @@ public class MchPayPassageConfigController extends CommonCtrl {
/** /**
* @Author: ZhuXiao * @Author: ZhuXiao
* @Description: 商户支付通道配置 * @Description: 应用支付通道配置
* @Date: 11:05 2021/5/13 * @Date: 11:05 2021/5/13
*/ */
@PreAuthorize("hasAuthority('ENT_MCH_PAY_PASSAGE_ADD')") @PreAuthorize("hasAuthority('ENT_MCH_PAY_PASSAGE_ADD')")
@PostMapping @PostMapping
@MethodLog(remark = "更新商户支付通道") @MethodLog(remark = "更新应用支付通道")
public ApiRes saveOrUpdate() { public ApiRes saveOrUpdate() {
String reqParams = getValStringRequired("reqParams"); String reqParams = getValStringRequired("reqParams");
try { try {
List<MchPayPassage> mchPayPassageList = JSONArray.parseArray(reqParams, MchPayPassage.class); List<MchPayPassage> mchPayPassageList = JSONArray.parseArray(reqParams, MchPayPassage.class);
mchPayPassageService.saveOrUpdateBatchSelf(mchPayPassageList, getCurrentUser().getSysUser().getBelongInfoId()); mchPayPassageService.saveOrUpdateBatchSelf(mchPayPassageList, getCurrentMchNo());
return ApiRes.ok(); return ApiRes.ok();
}catch (Exception e) { }catch (Exception e) {
return ApiRes.fail(ApiCodeEnum.SYSTEM_ERROR); return ApiRes.fail(ApiCodeEnum.SYSTEM_ERROR);
......
/*
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeequan.jeepay.mch.mq.topic;
import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.utils.JsonKit;
import lombok.extern.slf4j.Slf4j;
import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;
/*
* 更改商户应用信息
*
* @author terrfly
* @site https://www.jeepay.vip
* @date 2021/6/8 17:10
*/
@Slf4j
@Component
public class MqTopic4ModifyMchApp extends ActiveMQTopic{
@Autowired private JmsTemplate jmsTemplate;
public MqTopic4ModifyMchApp(){
super(CS.MQ.TOPIC_MODIFY_MCH_APP);
}
/** 推送消息到各个节点 **/
public void push(String mchNo, String appId) {
JSONObject jsonObject = JsonKit.newJson("mchNo", mchNo);
jsonObject.put("appId", appId);
this.jmsTemplate.convertAndSend(this, jsonObject.toString());
}
}
package com.jeequan.jeepay.service.impl; package com.jeequan.jeepay.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jeequan.jeepay.core.constants.ApiCodeEnum;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.entity.MchApp; import com.jeequan.jeepay.core.entity.MchApp;
import com.jeequan.jeepay.core.entity.MchPayPassage;
import com.jeequan.jeepay.core.entity.PayInterfaceConfig;
import com.jeequan.jeepay.core.entity.PayOrder;
import com.jeequan.jeepay.core.exception.BizException;
import com.jeequan.jeepay.service.mapper.MchAppMapper; import com.jeequan.jeepay.service.mapper.MchAppMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/** /**
* <p> * <p>
...@@ -16,4 +24,36 @@ import org.springframework.stereotype.Service; ...@@ -16,4 +24,36 @@ import org.springframework.stereotype.Service;
@Service @Service
public class MchAppService extends ServiceImpl<MchAppMapper, MchApp> { public class MchAppService extends ServiceImpl<MchAppMapper, MchApp> {
@Autowired private PayOrderService payOrderService;
@Autowired private MchPayPassageService mchPayPassageService;
@Autowired private PayInterfaceConfigService payInterfaceConfigService;
@Transactional(rollbackFor = Exception.class)
public void removeByAppId(String appId) {
// 1.查看当前应用是否存在交易数据
int payCount = payOrderService.count(PayOrder.gw().eq(PayOrder::getAppId, appId));
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);
}
// 3.删除应用配置的支付参数
result = 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) {
throw new BizException(ApiCodeEnum.SYS_OPERATION_FAIL_DELETE);
}
}
} }
...@@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedList;
import java.util.List; import java.util.List;
/** /**
...@@ -54,6 +55,8 @@ public class MchInfoService extends ServiceImpl<MchInfoMapper, MchInfo> { ...@@ -54,6 +55,8 @@ public class MchInfoService extends ServiceImpl<MchInfoMapper, MchInfo> {
@Autowired private IsvInfoService isvInfoService; @Autowired private IsvInfoService isvInfoService;
@Autowired private MchAppService mchAppService;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void addMch(MchInfo mchInfo, String loginUserName) { public void addMch(MchInfo mchInfo, String loginUserName) {
...@@ -104,9 +107,11 @@ public class MchInfoService extends ServiceImpl<MchInfoMapper, MchInfo> { ...@@ -104,9 +107,11 @@ public class MchInfoService extends ServiceImpl<MchInfoMapper, MchInfo> {
mchPayPassageService.remove(MchPayPassage.gw().eq(MchPayPassage::getMchNo, mchNo)); mchPayPassageService.remove(MchPayPassage.gw().eq(MchPayPassage::getMchNo, mchNo));
// 3.删除当前商户支付接口配置参数 // 3.删除当前商户支付接口配置参数
List<String> appIdList = new LinkedList<>();
mchAppService.list(MchApp.gw().eq(MchApp::getMchNo, mchNo)).forEach(item -> appIdList.add(item.getAppId()));
payInterfaceConfigService.remove(PayInterfaceConfig.gw() payInterfaceConfigService.remove(PayInterfaceConfig.gw()
.eq(PayInterfaceConfig::getInfoId, mchNo) .in(PayInterfaceConfig::getInfoId, appIdList)
.eq(PayInterfaceConfig::getInfoType, CS.INFO_TYPE_MCH) .eq(PayInterfaceConfig::getInfoType, CS.INFO_TYPE_MCH_APP)
); );
List<SysUser> userList = sysUserService.list(SysUser.gw() List<SysUser> userList = sysUserService.list(SysUser.gw()
......
...@@ -47,10 +47,10 @@ public class MchPayPassageService extends ServiceImpl<MchPayPassageMapper, MchPa ...@@ -47,10 +47,10 @@ public class MchPayPassageService extends ServiceImpl<MchPayPassageMapper, MchPa
* @Description: 根据支付方式查询可用的支付接口列表 * @Description: 根据支付方式查询可用的支付接口列表
* @Date: 9:56 2021/5/10 * @Date: 9:56 2021/5/10
*/ */
public List<JSONObject> selectAvailablePayInterfaceList(String wayCode, String mchNo, Byte infoType, Byte mchType) { public List<JSONObject> selectAvailablePayInterfaceList(String wayCode, String appId, Byte infoType, Byte mchType) {
Map params = new HashMap(); Map params = new HashMap();
params.put("wayCode", wayCode); params.put("wayCode", wayCode);
params.put("mchNo", mchNo); params.put("appId", appId);
params.put("infoType", infoType); params.put("infoType", infoType);
params.put("mchType", mchType); params.put("mchType", mchType);
List<JSONObject> list = baseMapper.selectAvailablePayInterfaceList(params); List<JSONObject> list = baseMapper.selectAvailablePayInterfaceList(params);
...@@ -59,7 +59,7 @@ public class MchPayPassageService extends ServiceImpl<MchPayPassageMapper, MchPa ...@@ -59,7 +59,7 @@ public class MchPayPassageService extends ServiceImpl<MchPayPassageMapper, MchPa
// 添加通道状态 // 添加通道状态
for (JSONObject object : list) { for (JSONObject object : list) {
MchPayPassage payPassage = baseMapper.selectOne(MchPayPassage.gw() MchPayPassage payPassage = baseMapper.selectOne(MchPayPassage.gw()
.eq(MchPayPassage::getMchNo, mchNo) .eq(MchPayPassage::getAppId, appId)
.eq(MchPayPassage::getWayCode, wayCode) .eq(MchPayPassage::getWayCode, wayCode)
.eq(MchPayPassage::getIfCode, object.getString("ifCode")) .eq(MchPayPassage::getIfCode, object.getString("ifCode"))
); );
...@@ -77,16 +77,8 @@ public class MchPayPassageService extends ServiceImpl<MchPayPassageMapper, MchPa ...@@ -77,16 +77,8 @@ public class MchPayPassageService extends ServiceImpl<MchPayPassageMapper, MchPa
return list; return list;
} }
@Transactional(rollbackFor = Exception.class)
public void saveOrUpdateBatchSelf(List<MchPayPassage> mchPayPassageList) {
saveOrUpdateBatchSelf(mchPayPassageList, null);
}
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void saveOrUpdateBatchSelf(List<MchPayPassage> mchPayPassageList, String mchNo) { public void saveOrUpdateBatchSelf(List<MchPayPassage> mchPayPassageList, String mchNo) {
if (CollectionUtils.isEmpty(mchPayPassageList)) {
throw new BizException("操作失败");
}
for (MchPayPassage payPassage : mchPayPassageList) { for (MchPayPassage payPassage : mchPayPassageList) {
if (payPassage.getState() == CS.NO && payPassage.getId() == null) { if (payPassage.getState() == CS.NO && payPassage.getId() == null) {
continue; continue;
......
...@@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jeequan.jeepay.core.constants.ApiCodeEnum; import com.jeequan.jeepay.core.constants.ApiCodeEnum;
import com.jeequan.jeepay.core.constants.CS; import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.entity.MchApp;
import com.jeequan.jeepay.core.entity.MchInfo; import com.jeequan.jeepay.core.entity.MchInfo;
import com.jeequan.jeepay.core.entity.PayInterfaceConfig; import com.jeequan.jeepay.core.entity.PayInterfaceConfig;
import com.jeequan.jeepay.core.entity.PayInterfaceDefine; import com.jeequan.jeepay.core.entity.PayInterfaceDefine;
...@@ -48,6 +49,9 @@ public class PayInterfaceConfigService extends ServiceImpl<PayInterfaceConfigMap ...@@ -48,6 +49,9 @@ public class PayInterfaceConfigService extends ServiceImpl<PayInterfaceConfigMap
@Autowired @Autowired
private MchInfoService mchInfoService; private MchInfoService mchInfoService;
@Autowired
private MchAppService mchAppService;
/** /**
* @Author: ZhuXiao * @Author: ZhuXiao
* @Description: 根据 账户类型、账户号、接口类型 获取支付参数配置 * @Description: 根据 账户类型、账户号、接口类型 获取支付参数配置
...@@ -66,63 +70,88 @@ public class PayInterfaceConfigService extends ServiceImpl<PayInterfaceConfigMap ...@@ -66,63 +70,88 @@ public class PayInterfaceConfigService extends ServiceImpl<PayInterfaceConfigMap
* @Description: 根据 账户类型、账户号 获取支付参数配置列表 * @Description: 根据 账户类型、账户号 获取支付参数配置列表
* @Date: 14:19 2021/5/7 * @Date: 14:19 2021/5/7
*/ */
public List<PayInterfaceDefine> selectAllPayIfConfigListByInfoId(Byte infoType, String infoId) { public List<PayInterfaceDefine> selectAllPayIfConfigListByIsvNo(Byte infoType, String infoId) {
// 支付定义列表 // 支付定义列表
LambdaQueryWrapper<PayInterfaceDefine> queryWrapper = PayInterfaceDefine.gw(); LambdaQueryWrapper<PayInterfaceDefine> queryWrapper = PayInterfaceDefine.gw();
queryWrapper.eq(PayInterfaceDefine::getState, CS.YES); queryWrapper.eq(PayInterfaceDefine::getState, CS.YES);
queryWrapper.eq(PayInterfaceDefine::getIsIsvMode, CS.YES); // 支持服务商模式
// 根据商户类型,添加接口是否支持该商户类型条件 List<PayInterfaceDefine> defineList = payInterfaceDefineService.list(queryWrapper);
MchInfo mchInfo = null;
Map<String, PayInterfaceConfig> isvPayConfigMap = new HashMap<>(); // 服务商支付参数配置集合
if (infoType == CS.INFO_TYPE_MCH) {
//商户信息
mchInfo = mchInfoService.getById(infoId);
if (mchInfo == null || mchInfo.getState() != CS.YES) throw new BizException(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
if (mchInfo.getType() == CS.MCH_TYPE_NORMAL) { // 支付参数列表
queryWrapper.eq(PayInterfaceDefine::getIsMchMode, CS.YES); // 支持普通商户模式 LambdaQueryWrapper<PayInterfaceConfig> wrapper = PayInterfaceConfig.gw();
} wrapper.eq(PayInterfaceConfig::getInfoId, infoId);
if (mchInfo.getType() == CS.MCH_TYPE_ISVSUB) { wrapper.eq(PayInterfaceConfig::getInfoType, infoType);
queryWrapper.eq(PayInterfaceDefine::getIsIsvMode, CS.YES); // 支持服务商模式 List<PayInterfaceConfig> configList = this.list(wrapper);
// 商户类型为特约商户,服务商应已经配置支付参数
List<PayInterfaceConfig> isvConfigList = this.list(PayInterfaceConfig.gw() for (PayInterfaceDefine define : defineList) {
.eq(PayInterfaceConfig::getInfoId, mchInfo.getIsvNo()) for (PayInterfaceConfig config : configList) {
.eq(PayInterfaceConfig::getInfoType, CS.INFO_TYPE_ISV) if (define.getIfCode().equals(config.getIfCode())) {
.eq(PayInterfaceConfig::getState, CS.YES) define.addExt("ifConfigState", config.getState()); // 配置状态
.ne(PayInterfaceConfig::getIfParams, " ")
.isNotNull(PayInterfaceConfig::getIfParams));
for (PayInterfaceConfig config : isvConfigList) {
isvPayConfigMap.put(config.getIfCode(), config);
} }
} }
} }
if (infoType == CS.INFO_TYPE_ISV) { return defineList;
}
public List<PayInterfaceDefine> selectAllPayIfConfigListByAppId(String appId) {
MchApp mchApp = mchAppService.getById(appId);
if (mchApp == null|| mchApp.getState() != CS.YES) {
throw new BizException(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
MchInfo mchInfo = mchInfoService.getById(mchApp.getMchNo());
if (mchInfo == null || mchInfo.getState() != CS.YES) {
throw new BizException(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
// 支付定义列表
LambdaQueryWrapper<PayInterfaceDefine> queryWrapper = PayInterfaceDefine.gw();
queryWrapper.eq(PayInterfaceDefine::getState, CS.YES);
Map<String, PayInterfaceConfig> isvPayConfigMap = new HashMap<>(); // 服务商支付参数配置集合
// 根据商户类型,添加接口是否支持该商户类型条件
if (mchInfo.getType() == CS.MCH_TYPE_NORMAL) {
queryWrapper.eq(PayInterfaceDefine::getIsMchMode, CS.YES); // 支持普通商户模式
}
if (mchInfo.getType() == CS.MCH_TYPE_ISVSUB) {
queryWrapper.eq(PayInterfaceDefine::getIsIsvMode, CS.YES); // 支持服务商模式 queryWrapper.eq(PayInterfaceDefine::getIsIsvMode, CS.YES); // 支持服务商模式
// 商户类型为特约商户,服务商应已经配置支付参数
List<PayInterfaceConfig> isvConfigList = this.list(PayInterfaceConfig.gw()
.eq(PayInterfaceConfig::getInfoId, mchInfo.getIsvNo())
.eq(PayInterfaceConfig::getInfoType, CS.INFO_TYPE_ISV)
.eq(PayInterfaceConfig::getState, CS.YES)
.ne(PayInterfaceConfig::getIfParams, "")
.isNotNull(PayInterfaceConfig::getIfParams));
for (PayInterfaceConfig config : isvConfigList) {
isvPayConfigMap.put(config.getIfCode(), config);
}
} }
List<PayInterfaceDefine> defineList = payInterfaceDefineService.list(queryWrapper); List<PayInterfaceDefine> defineList = payInterfaceDefineService.list(queryWrapper);
// 支付参数列表 // 支付参数列表
LambdaQueryWrapper<PayInterfaceConfig> wrapper = PayInterfaceConfig.gw(); LambdaQueryWrapper<PayInterfaceConfig> wrapper = PayInterfaceConfig.gw();
wrapper.eq(PayInterfaceConfig::getInfoId, infoId); wrapper.eq(PayInterfaceConfig::getInfoId, appId);
wrapper.eq(PayInterfaceConfig::getInfoType, infoType); wrapper.eq(PayInterfaceConfig::getInfoType, CS.INFO_TYPE_MCH_APP);
List<PayInterfaceConfig> configList = this.list(wrapper); List<PayInterfaceConfig> configList = this.list(wrapper);
for (PayInterfaceDefine define : defineList) { for (PayInterfaceDefine define : defineList) {
define.addExt("mchType", mchInfo.getType()); // 所属商户类型
for (PayInterfaceConfig config : configList) { for (PayInterfaceConfig config : configList) {
if (define.getIfCode().equals(config.getIfCode())) { if (define.getIfCode().equals(config.getIfCode())) {
define.addExt("ifConfigState", config.getState()); // 配置状态 define.addExt("ifConfigState", config.getState()); // 配置状态
} }
} }
if (infoType == CS.INFO_TYPE_MCH && mchInfo.getType() == CS.MCH_TYPE_ISVSUB && isvPayConfigMap.get(define.getIfCode()) == null) { if (mchInfo.getType() == CS.MCH_TYPE_ISVSUB && isvPayConfigMap.get(define.getIfCode()) == null) {
define.addExt("subMchIsvConfig", CS.NO); // 特约商户,服务商支付参数的配置状态,0表示未配置 define.addExt("subMchIsvConfig", CS.NO); // 特约商户,服务商支付参数的配置状态,0表示未配置
} }
} }
return defineList; return defineList;
} }
} }
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
and pid.state = 1 and pid.state = 1
and pic.state = 1 and pic.state = 1
and pic.info_type = #{infoType} and pic.info_type = #{infoType}
and pic.info_id = #{mchNo} and pic.info_id = #{appId}
and (pic.if_params is not null and trim(pic.if_params) != '') and (pic.if_params is not null and trim(pic.if_params) != '')
<if test="mchType == 1"> <if test="mchType == 1">
and pid.is_mch_mode = 1 and pid.is_mch_mode = 1
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册