Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pisns-forum-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
scrmGroup
pisns-forum-api
Commits
a1c6e58f
Commit
a1c6e58f
authored
Jan 07, 2015
by
杨翌文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交接口
parent
41353044
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
473 deletions
+0
-473
memberInfo.js
app/controllers/memberInfo.js
+0
-175
memberIntegral.js
app/controllers/memberIntegral.js
+0
-298
No files found.
app/controllers/memberInfo.js
deleted
100644 → 0
View file @
41353044
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../utils/returnCode'
),
_
=
require
(
'lodash'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/member'
,
router
);
};
//新增会员信息
router
.
post
(
'/info/create'
,
function
(
req
,
res
,
next
)
{
var
rs
=
{};
dataSource
.
Member
.
findOne
({
where
:
{
uid
:
req
.
body
.
uid
,
ent_code
:
Number
(
req
.
body
.
ent_code
)
}
}).
then
(
function
(
member
)
{
if
(
member
)
{
res
.
json
(
returnCode
.
UNIQUE_DATA_EXITS
);
}
else
{
dataSource
.
Member
.
create
(
req
.
body
).
then
(
function
(
member
)
{
rs
=
_
.
assign
(
member
,
returnCode
.
SUCCESS
);
res
.
json
(
rs
);
},
function
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
});
}
},
function
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
});
});
//获取目标会员信息
router
.
get
(
'/info/get/:mid'
,
function
(
req
,
res
,
next
)
{
var
mid
=
req
.
params
.
mid
||
null
;
var
rs
=
{};
if
(
mid
)
{
dataSource
.
Member
.
findOne
({
where
:
{
id
:
Number
(
mid
)
}
}).
then
(
function
(
member
)
{
if
(
member
)
{
rs
=
_
.
assign
(
rs
,
returnCode
.
SUCCESS
);
rs
.
data
=
member
;
}
else
{
rs
=
_
.
assign
(
rs
,
returnCode
.
DATA_NOTEXITS
);
}
res
.
json
(
rs
);
},
function
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//更新目标会员信息
router
.
post
(
'/info/set/:mid'
,
function
(
req
,
res
,
next
)
{
var
mid
=
req
.
params
.
mid
||
null
;
if
(
mid
&&
!
_
.
isEmpty
(
req
.
body
))
{
if
(
req
.
body
.
uid
||
req
.
body
.
ent_code
||
req
.
body
.
id
||
req
.
body
.
rank_code
)
{
res
.
json
(
returnCode
.
UPDATE_READONLY_ATTR
);
return
;
}
dataSource
.
Member
.
update
(
req
.
body
,
{
where
:
{
id
:
Number
(
mid
)
},
limit
:
1
,
}).
then
(
function
(
rowCount
)
{
if
(
1
===
rowCount
[
0
])
{
res
.
json
(
returnCode
.
SUCCESS
);
}
else
{
res
.
json
(
returnCode
.
DATA_NOTEXITS
);
}
},
function
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//更新目标会员信息并返回最新的会员数据
router
.
post
(
'/info/touch/:mid'
,
function
(
req
,
res
,
next
)
{
var
mid
=
req
.
params
.
mid
||
null
;
mid
=
Number
(
mid
);
var
rs
=
{};
if
(
mid
&&
!
_
.
isEmpty
(
req
.
body
))
{
if
(
req
.
body
.
uid
||
req
.
body
.
ent_code
||
req
.
body
.
id
||
req
.
body
.
rank_code
)
{
res
.
json
(
returnCode
.
UPDATE_READONLY_ATTR
);
return
;
}
dataSource
.
Member
.
update
(
req
.
body
,
{
where
:
{
id
:
mid
},
limit
:
1
,
}).
then
(
function
(
rowCount
)
{
if
(
1
===
rowCount
[
0
])
{
dataSource
.
Member
.
findOne
({
where
:
{
id
:
mid
}
}).
then
(
function
(
member
)
{
rs
.
data
=
member
;
rs
=
_
.
assign
(
rs
,
returnCode
.
SUCCESS
);
res
.
json
(
rs
);
},
function
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
});
}
else
{
res
.
json
(
returnCode
.
DATA_NOTEXITS
);
}
},
function
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//----------------后台管理专属接口---------------------------
//查询目标企业会员列表
router
.
post
(
'/info/ent/:ent_code'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
where
=
req
.
body
.
where
||
{};
var
order
=
req
.
body
.
order
||
'id'
;
var
rs
=
{};
var
offset
=
(
pageNo
-
1
)
*
pageSize
;
where
.
ent_code
=
Number
(
req
.
params
.
ent_code
);
dataSource
.
Member
.
findAndCountAll
({
where
:
where
,
order
:
order
,
limit
:
pageSize
,
offset
:
offset
}).
then
(
function
(
result
)
{
if
(
result
.
count
>
0
)
{
rs
.
data
=
{
pageNo
:
pageNo
,
pageSize
:
pageSize
,
total
:
result
.
count
,
items
:
result
.
rows
};
}
else
{
rs
.
data
=
{
pageNo
:
pageNo
,
pageSize
:
pageSize
,
total
:
0
,
items
:
[]
};
}
rs
=
_
.
assign
(
rs
,
returnCode
.
SUCCESS
);
res
.
json
(
rs
);
},
function
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
});
});
\ No newline at end of file
app/controllers/memberIntegral.js
deleted
100644 → 0
View file @
41353044
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
async
=
require
(
'async'
),
returnCode
=
require
(
'../utils/returnCode'
),
_
=
require
(
'lodash'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/member'
,
router
);
};
//获取目标会员积分
router
.
get
(
'/integral/get/:mid'
,
function
(
req
,
res
,
next
)
{
var
mid
=
req
.
params
.
mid
||
null
;
var
rs
=
{};
mid
=
Number
(
mid
);
if
(
mid
)
{
dataSource
.
Integral
.
findOne
({
where
:
{
mid
:
mid
}
}).
then
(
function
(
integral
)
{
if
(
integral
)
{
rs
.
data
=
{
mid
:
integral
.
mid
,
integral
:
integral
.
integral
,
exp
:
integral
.
exp
};
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
else
{
dataSource
.
Member
.
findOne
({
where
:
{
id
:
mid
}
}).
then
(
function
(
member
)
{
if
(
member
)
{
rs
.
data
=
{
mid
:
mid
,
integral
:
0
,
exp
:
0
};
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
dataSource
.
Integral
.
create
({
mid
:
mid
,
integral
:
0
,
exp
:
0
});
}
else
{
res
.
json
(
returnCode
.
DATA_NOTEXITS
);
}
},
function
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
});
}
},
function
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//增加目标会员积分
router
.
post
(
'/integral/incr/:mid'
,
function
(
req
,
res
,
next
)
{
var
mid
=
req
.
params
.
mid
||
null
;
var
incr
=
req
.
body
;
var
rs
=
{};
mid
=
Number
(
mid
);
var
amount
=
Number
(
incr
.
amount
);
async
.
waterfall
([
function
(
cb
)
{
//查找积分
dataSource
.
Integral
.
findOne
({
where
:
{
id
:
mid
},
include
:
[{
model
:
dataSource
.
Member
}]
}).
then
(
function
(
integral
)
{
if
(
integral
)
{
cb
(
null
,
integral
);
}
else
{
cb
(
returnCode
.
DATA_NOTEXITS
);
}
},
function
(
err
)
{
console
.
error
(
err
);
cb
(
returnCode
.
BUSY
);
});
},
function
(
integral
,
cb
)
{
//更新积分和经验
integral
.
increment
([
'integral'
,
'exp'
],
{
by
:
amount
}).
then
(
function
()
{
cb
(
null
,
integral
);
},
function
(
err
)
{
console
.
error
(
err
);
cb
(
returnCode
.
BUSY
);
});
},
function
(
integral
,
cb
)
{
//插入积分历史
dataSource
.
IntegralHistory
.
create
({
mid
:
mid
,
amount
:
amount
,
ent_code
:
integral
.
Member
.
ent_code
,
change_type
:
1
,
change_reason
:
incr
.
change_reason
}).
then
(
function
()
{
cb
(
null
,
integral
);
},
function
(
err
)
{
console
.
error
(
err
);
cb
(
returnCode
.
BUSY
);
});
},
function
(
integral
,
cb
)
{
//重载积分
integral
.
reload
().
then
(
function
(
newIns
)
{
cb
(
null
,
newIns
);
},
function
(
err
)
{
console
.
error
(
err
);
cb
(
returnCode
.
BUSY
);
});
}],
function
(
err
,
result
)
{
if
(
err
)
{
res
.
json
(
err
);
}
else
{
rs
.
data
=
{
mid
:
result
.
mid
,
integral
:
result
.
integral
,
exp
:
result
.
exp
}
rs
=
_
.
assign
(
rs
,
returnCode
.
SUCCESS
);
res
.
json
(
rs
);
}
});
});
//减少目标会员积分
router
.
post
(
'/integral/decr/:mid'
,
function
(
req
,
res
,
next
)
{
var
mid
=
req
.
params
.
mid
||
null
;
var
decr
=
req
.
body
;
var
rs
=
{};
mid
=
Number
(
mid
);
var
amount
=
Number
(
decr
.
amount
);
async
.
waterfall
([
function
(
cb
)
{
//查找积分
dataSource
.
Integral
.
findOne
({
where
:
{
id
:
mid
},
include
:
[{
model
:
dataSource
.
Member
}]
}).
then
(
function
(
integral
)
{
console
.
log
(
integral
);
if
(
integral
)
{
cb
(
null
,
integral
);
}
else
{
cb
(
returnCode
.
DATA_NOTEXITS
);
}
},
function
(
err
)
{
console
.
error
(
err
);
cb
(
returnCode
.
BUSY
);
});
},
function
(
integral
,
cb
)
{
//插入积分历史
dataSource
.
IntegralHistory
.
create
({
mid
:
mid
,
amount
:
amount
,
ent_code
:
integral
.
Member
.
ent_code
,
change_type
:
2
,
change_reason
:
decr
.
change_reason
}).
then
(
function
()
{
cb
(
null
,
integral
);
},
function
(
err
)
{
console
.
error
(
err
);
cb
(
returnCode
.
BUSY
);
});
},
function
(
integral
,
cb
)
{
//更新积分和经验
if
(
integral
.
integral
-
amount
>=
0
)
{
integral
.
decrement
(
'integral'
,
{
by
:
amount
}).
then
(
function
()
{
cb
(
null
,
integral
);
},
function
(
err
)
{
console
.
error
(
err
);
cb
(
returnCode
.
BUSY
);
});
}
else
{
cb
(
returnCode
.
INTEGRAL_NOT_ENOUGH
);
}
},
function
(
integral
,
cb
)
{
//重载积分
integral
.
reload
().
then
(
function
(
newIns
)
{
cb
(
null
,
newIns
);
},
function
(
err
)
{
console
.
error
(
err
);
cb
(
returnCode
.
BUSY
);
});
}],
function
(
err
,
result
)
{
if
(
err
)
{
res
.
json
(
err
);
}
else
{
rs
.
data
=
{
mid
:
result
.
mid
,
integral
:
result
.
integral
,
exp
:
result
.
exp
}
rs
=
_
.
assign
(
rs
,
returnCode
.
SUCCESS
);
res
.
json
(
rs
);
}
});
});
//查询目标会员积分历史
router
.
post
(
'/integral/history/:mid'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
where
=
req
.
body
.
where
||
{};
var
order
=
req
.
body
.
order
||
'id desc'
;
var
rs
=
{};
var
offset
=
(
pageNo
-
1
)
*
pageSize
;
where
.
mid
=
Number
(
req
.
params
.
mid
);
dataSource
.
IntegralHistory
.
findAndCountAll
({
where
:
where
,
order
:
order
,
limit
:
pageSize
,
offset
:
offset
,
include
:
[{
model
:
dataSource
.
Member
,
attributes
:
[
'name'
,
'sex'
,
'mobile'
,
'uid'
]
}]
}).
then
(
function
(
result
)
{
if
(
result
.
count
>
0
)
{
rs
.
data
=
{
pageNo
:
pageNo
,
pageSize
:
pageSize
,
total
:
result
.
count
,
items
:
result
.
rows
};
}
else
{
rs
.
data
=
{
pageNo
:
pageNo
,
pageSize
:
pageSize
,
total
:
0
,
items
:
[]
};
}
rs
=
_
.
assign
(
rs
,
returnCode
.
SUCCESS
);
res
.
json
(
rs
);
},
function
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
});
});
//----------------后台管理专属接口---------------------------
//查询目标企业会员信息和积分列表
router
.
post
(
'/integral/ent/:ent_code'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
where
=
req
.
body
.
where
||
{};
var
order
=
req
.
body
.
order
||
'id desc'
;
var
rs
=
{};
var
offset
=
(
pageNo
-
1
)
*
pageSize
;
where
.
ent_code
=
Number
(
req
.
params
.
ent_code
);
dataSource
.
IntegralHistory
.
findAndCountAll
({
where
:
where
,
order
:
order
,
limit
:
pageSize
,
offset
:
offset
,
include
:
[{
model
:
dataSource
.
Member
,
attributes
:
[
'name'
,
'sex'
,
'mobile'
,
'uid'
]
}]
}).
then
(
function
(
result
)
{
if
(
result
.
count
>
0
)
{
rs
.
data
=
{
pageNo
:
pageNo
,
pageSize
:
pageSize
,
total
:
result
.
count
,
items
:
result
.
rows
};
}
else
{
rs
.
data
=
{
pageNo
:
pageNo
,
pageSize
:
pageSize
,
total
:
0
,
items
:
[]
};
}
rs
=
_
.
assign
(
rs
,
returnCode
.
SUCCESS
);
res
.
json
(
rs
);
},
function
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
});
});
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment