Authored by yyq

添加开奖信息

... ... @@ -197,7 +197,7 @@ module.exports = class extends global.yoho.BaseModel {
}
return mysqlCli.query(`select u.*, p.name, p.price, p.status, p.cover_img,
p.start_time, p.end_time, p.is_full from
p.start_time, p.end_time, p.is_full, p.lottery_info from
${TABLE_ACT_PRIZE_PRODUCT_USER} u left join
${TABLE_ACT_PRIZE_PRODUCT} p on u.act_prize_id = p.id
where u.act_id = :actId and u.uid = :uid and ${where}
... ...
... ... @@ -61,8 +61,9 @@ const zeroBuy = {
let ctx = req.ctx(ActivityModel);
let id = req.body.id;
let channel = req.body.channel;
let lotteryInfo = req.body.lotteryInfo;
ctx.editZerobuyStatus(id, 2).then(result => {
ctx.setZeroBuyPublish(id, lotteryInfo).then(result => {
if (result.code === 200) {
ctx.sendWechatMessage(id, channel);
}
... ...
... ... @@ -488,12 +488,12 @@ class AdminModel extends global.yoho.BaseModel {
});
}
/**
* 获取0元购活动列表
* @param id 活动id
* @returns {*}
*/
/**
* 设置0元够活动状态
* @param id 活动id
* @param status 活动status
* @returns {*}
*/
editZerobuyStatus(id, status) {
if (!id || !_.inRange(status, 0, 3)) {
return Promise.resolve({
... ... @@ -513,6 +513,29 @@ class AdminModel extends global.yoho.BaseModel {
});
}
/**
* 设置活动开奖
* @param id 活动id
* @param lotteryInfo 活动开奖信息
* @returns {*}
*/
setZeroBuyPublish(id, lotteryInfo) {
return mysqlCli.update(`update ${TABLE_ACT_PRIZE_PRODUCT} set status = 2, lottery_info = :lotteryInfo where id = :id`, {
id,
lotteryInfo: lotteryInfo
}).then(() => {
return {
code: 200,
message: '操作成功'
};
});
}
/**
* 获取0元购活动导出列表
* @param id 活动id
* @returns {*}
*/
getZerobuyExportList(id) {
return Promise.all([
mysqlCli.query(`select uid, user_name, prize_code, is_share_take, share_uid, create_time
... ...
... ... @@ -121,7 +121,27 @@
<h3>确认开奖</h3>
</div>
<div class="modal-body">
<p>确认将此活动设为开奖状态?开奖后无法进行状态变更</p>
<p>请输入中奖提示信息</p>
<form class="form-horizontal" id="publish-form">
<div class="form-group">
<span class="control-label col-md-2 col-xs-12">APP</span>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" class="form-control" name="app" placeholder="请输入抽奖码">
</div>
</div>
<div class="form-group">
<span class="control-label col-md-2 col-xs-12">小程序</span>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" class="form-control" name="miniapp" placeholder="请输入文案">
</div>
</div>
<div class="form-group">
<span class="control-label col-md-2 col-xs-12">H5</span>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" class="form-control" name="h5" placeholder="请输入跳转的H5链接">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<a class="btn btn-success" data-dismiss="modal">取消</a>
... ...
/*
0元购开奖信息
@author: yyq <kingcoon@163.com>
@date: 2018-12-24 11:43:47
*/
#注意:GO;分割执行块
ALTER TABLE act_prize_product ADD `lottery_info` VARCHAR(800) DEFAULT '' comment '开奖信息';
GO;
... ...
module.exports = ['_migration', '20170913102356', '20170927092926', '20171025145423', '20171102104558', '20171115144710', '20180131104311', '20180402134610', '20180413105509', '20180719134813', '20180806151252', '20180810104355', '20180816142744', '20180920153207', '20181108134201', '20181114190801', '20181119101042'];
module.exports = ['_migration', '20170913102356', '20170927092926', '20171025145423', '20171102104558', '20171115144710', '20180131104311', '20180402134610', '20180413105509', '20180719134813', '20180806151252', '20180810104355', '20180816142744', '20180920153207', '20181108134201', '20181114190801', '20181119101042', '20181224114347'];
... ...
... ... @@ -5,9 +5,15 @@ const _ = require('lodash');
const $alert = $('#alert-modal');
const $confirm = $('#confirm-modal');
$alert.showMsg = function(msg) {
this.find('.modal-text').text(msg);
this.modal('show');
};
function bindListPageEvent() {
const $searchKey = $('#search-key');
const $statusSwitch = $('#status-switch');
const $publishForm = $('#publish-form');
const searchFn = function() {
let val = $searchKey.val();
... ... @@ -62,12 +68,30 @@ function bindListPageEvent() {
};
const publishFn = function() {
let t = $publishForm.serializeArray();
let tips = {};
let error;
$.each(t, function() {
if (!this.value) {
error = true;
return;
}
tips[this.name] = this.value;
});
if (error) {
alert('请填写完整各端提示信息后进行开奖');
}
$.ajax({
method: 'post',
url: '/admin/activity/zerobuy/publish',
data: {
id: $confirm.data('id'),
channel: $confirm.data('channel')
channel: $confirm.data('channel'),
lotteryInfo: JSON.stringify(tips)
}
}).then(res => {
if (res.code === 200) {
... ...