Commit 6a689f20 authored by 1486327116's avatar 1486327116

添加代理相关接口

parent 1f405d7e
......@@ -31,16 +31,16 @@ export const agentList = async (req: any, pageVO: AgentPageVO) => {
* @param req
* @param authConfigVO
*/
export const agentSet = async (req: any, agentVO: AgentVO) => {
export const agentSet = async (req: any, vo: AgentUserVO) => {
let func_name = "contractAgent.control.agentSet";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
if ( !agentVO.user_id) {
if ( !vo.user_id) {
throw ErrorCode.PARAM_MISS
}
let res = await contractAgentService.agentSet(agentVO.user_id, currentUserId, ip);
let res = await contractAgentService.agentSet(vo, currentUserId, ip);
return Res3Utils.result(res);
}
catch (e) {
......@@ -123,7 +123,7 @@ export const agentUserSet = async (req: any, agentUserVO: AgentUserVO) => {
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
if (!agentUserVO.agent_id || !agentUserVO.user_id) {
if (!agentUserVO.user_id) {
throw ErrorCode.PARAM_MISS
}
......
......@@ -76,19 +76,27 @@ export async function agentList(pageVO: AgentPageVO) {
return res;
}
export async function agentSet(user_id: any, currentUserId: any, ip: string | undefined) {
let exist = await userAgent.prototype.find({
where: {
user_id
},
raw: true
});
if (exist && exist.agent_id != 0) {
throw ErrorCode.DATA_EXIST;
export async function agentSet(agentUserVO: AgentUserVO, currentUserId: any, ip: string | undefined) {
let user_id = agentUserVO.user_id;
let agent_id = agentUserVO.agent_id;
if (agent_id==0) {
await setAgent(user_id, 0);
}else {
await setAgent(user_id, user_id);
// 添加
let exist = await userAgent.prototype.find({
where: {
user_id,agent_id
},
raw: true
});
if (exist && exist.agent_id != 0) {
throw ErrorCode.DATA_EXIST;
}else {
await setAgent(user_id, user_id);
}
}
addOptLog(currentUserId, 0, '合约接单账户配置', ip, user_id, '合约接单账户配置');
return 'success';
}
......@@ -143,17 +151,21 @@ export async function agentUserSet(agentUserVO: AgentUserVO, currentUserId: any,
let user_id = agentUserVO.user_id;
let agent_id = agentUserVO.agent_id;
let exist = await userAgent.prototype.find({
where: {
user_id,
agent_id
},
raw: true
});
if (exist && exist.agent_id != 0) {
throw ErrorCode.DATA_EXIST;
if (agent_id==0) {
await setAgent(user_id, 0);
}else {
await setAgent(user_id, agent_id);
let exist = await userAgent.prototype.find({
where: {
user_id,
agent_id
},
raw: true
});
if (exist && exist.agent_id != 0) {
throw ErrorCode.DATA_EXIST;
}else {
await setAgent(user_id, agent_id);
}
}
//管理后台操作日志
addOptLog(currentUserId, 0, '合约接单账户关联配置', ip, JSON.stringify(agentUserVO), '合约接单账户关联');
......
......@@ -224,13 +224,13 @@ const postFunc = {
'fiance/other/contract/limit/trade/set': contractLimitTradeCtrl.set,
'fiance/other/contract/limit/trade/list': contractLimitTradeCtrl.list,
//金融部-其他管理-合约接单账户配置(代理商)
'fiance/other/contract/agent/set': contractAgentCtrl.agentSet, // 参数只要user_id
'fiance/other/contract/agent/list': contractAgentCtrl.agentList, // 参数支持user_id 或者 agent_id 返回值只有user_id agent_id 时间
'fiance/other/contract/agent/hedgeRatio/set': contractAgentCtrl.hedgeRatioSet, // 給代理商添加对冲配置参数 agent_id product(合约交易对) ratio对冲比例0-1之间
'fiance/other/contract/agent/hedgeRatio/list': contractAgentCtrl.hedgeRatioList, // 返回值返回list里面 product交易对 ratio对冲比例 qty 对冲数量
'fiance/other/contract/agent/set': contractAgentCtrl.agentSet, // 参数 user_id agent_id agent_id 只能为0(删除代理关系) 或者和user_id同值
'fiance/other/contract/agent/list': contractAgentCtrl.agentList, // 可以传1000 全捞出来 参数支持user_id 或者 agent_id 返回值只有user_id agent_id 时间
'fiance/other/contract/agent/hedgeRatio/set': contractAgentCtrl.hedgeRatioSet, // 新增 給代理商添加对冲配置参数 agent_id product(合约交易对) ratio对冲比例0-1之间
'fiance/other/contract/agent/hedgeRatio/list': contractAgentCtrl.hedgeRatioList, // 新增 返回值返回list里面 product交易对 ratio对冲比例 qty 对冲数量
//金融部-其他管理-合约接单账户关联(代理用户)
'fiance/other/contract/agent/user/set': contractAgentCtrl.agentUserSet, // 参数user_id agent_id
'fiance/other/contract/agent/user/set': contractAgentCtrl.agentUserSet, // 参数user_id agent_id agent为0(删除代理关系)
'fiance/other/contract/agent/user/list': contractAgentCtrl.agentUserList, // 参数支持user_id 或者 agent_id 返回值只有user_id agent_id 时间
//金融部-其他管理-合约渠道用户管理(代理商渠道)
'fiance/other/contract/agent/channel/set': contractAgentCtrl.agentChannelSet,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment