Authored by 陈峰

Merge branch 'release/0823' into 'master'

Release/0823



See merge request !43
... ... @@ -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]
}
... ...
... ... @@ -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;
... ...
... ... @@ -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
})
};
... ...
... ... @@ -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);
... ...
... ... @@ -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>
... ...
... ... @@ -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);
... ...
... ... @@ -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) {
... ...
... ... @@ -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 用
... ...
... ... @@ -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: 'https://cdn.yoho.cn/',
max_file_size: '10mb',
max_retries: 3,
chunk_size: '10mb',
... ...
... ... @@ -59,7 +59,6 @@ class SqlHelper {
});
}
async execute(sql, params, options = {}) {
console.log(sql);
let cacheTime = parseInt(options.cache, 10) || 0;
let cacheKey;
... ...