Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-activity-platform
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
陈峰
7 years ago
Commit
d01a6f21e9fde11eb6828a61535bc7ddf8940bfc
2 parents
349aa304
b90f5efd
Merge branch 'release/0823' into 'master'
Release/0823 See merge request
!43
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
73 additions
and
11 deletions
apps/activity/models/zero-buy.js
apps/admin/controllers/coupon.js
apps/admin/models/activity.js
apps/admin/router.js
apps/admin/views/action/coupon/list.hbs
apps/api/controllers/qiniu.js
apps/api/controllers/yohood.js
config/common.js
public/js/admin/zero-buy.page.js
utils/mysql.js
apps/activity/models/zero-buy.js
View file @
d01a6f2
...
...
@@ -68,6 +68,14 @@ function getActivityStatus(info = {}, num, now) {
return
resStatus
;
}
function
replaceHttp
(
url
)
{
if
(
url
&&
url
.
indexOf
(
'http:'
)
>
-
1
)
{
url
=
url
.
replace
(
/http:/ig
,
'https:'
);
}
return
url
;
}
function
handelActivityList
(
list
,
nums
)
{
let
now
=
new
Date
().
getTime
()
/
1000
;
...
...
@@ -75,6 +83,7 @@ function handelActivityList(list, nums) {
nums
=
_
.
concat
([],
nums
);
_
.
forEach
(
list
,
(
value
,
index
)
=>
{
value
.
cover_img
=
replaceHttp
(
value
.
cover_img
);
value
.
price
=
'¥'
+
(
value
.
price
||
0
).
toFixed
(
2
);
value
.
status
=
getActivityStatus
(
value
,
nums
[
index
],
now
);
});
...
...
@@ -100,11 +109,27 @@ module.exports = class extends global.yoho.BaseModel {
page
=
parseInt
(
page
,
10
)
||
1
;
let
limit
=
`
$
{(
page
-
1
)
*
PAGE_SIZE
},
$
{
PAGE_SIZE
}
`
;
let
where
=
[
'act_id = :actId'
];
let
now
=
new
Date
().
getTime
()
/
1000
;
switch
(
+
extra
.
type
)
{
case
1
:
where
.
push
(
'status > 0 and start_time > :now'
);
break
;
case
2
:
where
.
push
(
'status > 0'
);
where
.
push
(
'(end_time < :now or is_full > 0)'
);
break
;
default
:
where
.
push
(
'status = 1 and start_time <= :now and end_time >= :now and is_full = 0'
);
break
;
}
return
mysqlCli
.
query
(
`
select
*
from
$
{
TABLE_ACT_PRIZE_PRODUCT
}
where
act_id
=
:
actId
and
status
>
0
order
by
sort
desc
limit
$
{
limit
}
`
,
{
actId
where
$
{
where
.
join
(
' and '
)}
order
by
sort
desc
limit
$
{
limit
}
`
,
{
actId
,
now
},
{
cache
:
PRODUCT_CACHE_TIMES
}).
then
(
result
=>
{
...
...
@@ -216,11 +241,16 @@ module.exports = class extends global.yoho.BaseModel {
if
(
product
&&
product
.
length
)
{
resData
=
product
[
0
]
||
{};
resData
.
content
=
_
.
sortBy
(
content
||
[],
o
=>
{
if
(
+
o
.
floor_type
===
2
)
{
o
.
content
=
replaceHttp
(
o
.
content
);
}
return
o
.
sort
;
});
let
joinNum
=
_
.
get
(
count
,
'join_num'
,
0
);
resData
.
cover_img
=
replaceHttp
(
resData
.
cover_img
);
resData
.
price
=
'¥'
+
resData
.
price
.
toFixed
(
2
);
resData
.
joinNum
=
joinNum
;
resData
.
status
=
getActivityStatus
(
resData
,
joinNum
);
...
...
@@ -492,7 +522,7 @@ module.exports = class extends global.yoho.BaseModel {
params
:
JSON
.
stringify
({
activityTitle
:
extra
.
actName
,
activityTime
:
`
$
{
timeFormat
(
extra
.
actStartTime
)}
-
$
{
timeFormat
(
extra
.
actEndTime
)}
`
,
pageUrl
:
'
/
page/subPackage/pages/zeroSell/detail?actPrizeId='
+
actPrizeId
pageUrl
:
'page/subPackage/pages/zeroSell/detail?actPrizeId='
+
actPrizeId
}),
uidList
:
[
uid
]
}
...
...
apps/admin/controllers/coupon.js
View file @
d01a6f2
...
...
@@ -147,6 +147,24 @@ const couponController = {
next
;
}
},
downloadTpl
(
req
,
res
)
{
let
conf
=
{
name
:
'mysheet'
,
cols
:
[
{
caption
:
'couponNo'
,
type
:
'String'
}
],
rows
:
[[
'c3236233105'
],
[
'c3236233105'
]]
};
let
exportFile
=
excelExport
.
execute
(
conf
);
res
.
setHeader
(
'Content-Type'
,
'application/vnd.openxmlformats'
);
res
.
setHeader
(
'Content-Disposition'
,
'attachment; filename=couponNoTpl.xlsx'
);
res
.
end
(
exportFile
,
'binary'
);
},
downloadNoList
(
req
,
res
,
next
)
{
const
couponId
=
req
.
query
.
id
;
...
...
apps/admin/models/activity.js
View file @
d01a6f2
...
...
@@ -761,7 +761,7 @@ class AdminModel extends global.yoho.BaseModel {
params
:
JSON
.
stringify
({
activityTitle
:
productInfo
.
name
,
activityTime
:
moment
().
format
(
'YYYY-MM-DD HH:mm'
)
+
':00'
,
pageUrl
:
'
/
page/subPackage/pages/zeroSell/detail?actPrizeId='
+
id
pageUrl
:
'page/subPackage/pages/zeroSell/detail?actPrizeId='
+
id
})
};
...
...
apps/admin/router.js
View file @
d01a6f2
...
...
@@ -67,6 +67,7 @@ router.post('/api/coupon/modify', coupon.modifyCoupon);
router
.
post
(
'/api/coupon/batchAddNo'
,
mutilpartMiddleware
,
coupon
.
loadCouponNoList
);
router
.
get
(
'/api/coupon/downloadNo'
,
coupon
.
downloadNoList
);
router
.
get
(
'/api/coupon/delete'
,
coupon
.
deleteCoupon
);
router
.
get
(
'/api/coupon/downloadTpl'
,
coupon
.
downloadTpl
);
// 用户管理[ajax]
router
.
post
(
'/api/user/delete'
,
user
.
deleteUser
);
...
...
apps/admin/views/action/coupon/list.hbs
View file @
d01a6f2
...
...
@@ -6,6 +6,7 @@
<div
class=
"x_panel"
>
<div
class=
"x_title"
>
<a
href=
"/admin/coupon/option"
class=
"btn btn-primary"
>
创建券
</a>
<a
href=
"/admin/api/coupon/downloadTpl"
class=
"btn btn-primary"
>
下载导入券码模版
</a>
<div
class=
"btn-group"
style=
"vertical-align: top"
>
<button
type=
"button"
class=
"btn btn-default dropdown-toggle"
data-toggle=
"dropdown"
aria-haspopup=
"true"
aria-expanded=
"false"
>
<span
id=
"dropdown-toggle-txt"
>
全部
</span>
<span
class=
"caret"
></span>
...
...
apps/api/controllers/qiniu.js
View file @
d01a6f2
...
...
@@ -5,11 +5,18 @@
*/
const
qiniu
=
require
(
'qiniu'
);
const
qiniuConfig
=
global
.
yoho
.
config
.
qiniu
;
const
qiniuYohoCdnConfig
=
global
.
yoho
.
config
.
qiniuYohoCdn
;
function
getToken
(
req
,
res
)
{
let
mac
=
new
qiniu
.
auth
.
digest
.
Mac
(
qiniuConfig
.
ACCESS_KEY
,
qiniuConfig
.
SECRET_KEY
);
let
conf
=
qiniuConfig
;
if
(
req
.
query
.
type
===
'yohoCdn'
)
{
conf
=
qiniuYohoCdnConfig
;
}
let
mac
=
new
qiniu
.
auth
.
digest
.
Mac
(
conf
.
ACCESS_KEY
,
conf
.
SECRET_KEY
);
let
options
=
{
scope
:
qiniuConfig
.
BUCKET_NAME
,
scope
:
conf
.
BUCKET_NAME
};
let
putPolicy
=
new
qiniu
.
rs
.
PutPolicy
(
options
);
let
uploadToken
=
putPolicy
.
uploadToken
(
mac
);
...
...
apps/api/controllers/yohood.js
View file @
d01a6f2
...
...
@@ -217,7 +217,7 @@ const yohood = {
let
couponDetail
=
await
req
.
ctx
(
YohoodModel
).
getCouponDetail
(
uid
,
couponId
);
// console.log('couponDetail:', couponDetail);
// console.log('couponDetail:', couponDetail
, uid, couponId
);
// console.log('couponInfo', couponInfo.data[0].coupon_num);
if
(
couponDetail
.
code
===
200
&&
couponDetail
.
data
.
length
>
0
)
{
...
...
config/common.js
View file @
d01a6f2
...
...
@@ -108,6 +108,12 @@ module.exports = {
SECRET_KEY
:
'_x2VtO7fEmylgjojmLi7qwTBtRm30S8BrO0FxOPK'
,
BUCKET_NAME
:
'cmsimg01'
},
qiniuYohoCdn
:
{
ACCESS_KEY
:
'BwWhoJN536BnV3CzlE20AjNKC9O2bP0l5tFpKsDU'
,
SECRET_KEY
:
'_x2VtO7fEmylgjojmLi7qwTBtRm30S8BrO0FxOPK'
,
ORIGIN
:
'https://cdn.yoho.cn'
,
BUCKET_NAME
:
'yohocdn'
},
yohoSecret
:
'3bd815162342d9733f06ab6811082c64'
,
wechat
:
{
appID
:
'wx1fe49f08f41b6c26'
,
// jsapi 用
...
...
public/js/admin/zero-buy.page.js
View file @
d01a6f2
...
...
@@ -116,7 +116,7 @@ function initUpload() {
Qiniu
.
uploader
({
// eslint-disable-line
runtimes
:
'html5,flash,html4'
,
browse_button
:
'upload-btn'
,
uptoken_url
:
'/api/getToken'
,
uptoken_url
:
'/api/getToken
?type=yohoCdn
'
,
unique_names
:
true
,
multi_selection
:
false
,
filters
:
{
...
...
@@ -125,7 +125,7 @@ function initUpload() {
}]
},
dragdrop
:
false
,
domain
:
'http
://img01.yohoboys.com
/'
,
domain
:
'http
s://cdn.yoho.cn
/'
,
max_file_size
:
'10mb'
,
max_retries
:
3
,
chunk_size
:
'10mb'
,
...
...
utils/mysql.js
View file @
d01a6f2
...
...
@@ -59,7 +59,6 @@ class SqlHelper {
});
}
async
execute
(
sql
,
params
,
options
=
{})
{
console
.
log
(
sql
);
let
cacheTime
=
parseInt
(
options
.
cache
,
10
)
||
0
;
let
cacheKey
;
...
...
Please
register
or
login
to post a comment