test
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

161 lines
5.1 KiB

<?php
/**
* Comment: ...
* Author: ZZW
* Date: 2018/9/12
* Time: 18:02
*/
defined('IN_IA') or exit('Access Denied');
class Call_WeliamController {
/**
* Comment: 集call活动列表
* Author: zzw
*/
public function callList(){
global $_W,$_GPC;
$name = $_GPC['name'];
$pindex = max(1, intval($_GPC['page']));
$psize = 10;
$where = " a.uniacid = {$_W['uniacid']} AND a.aid = {$_W['aid']} ";
if($name){
$where .= " AND a.title LIKE '%{$name}%' ";
}
$sql = "SELECT
a.id,
a.title as name,
a.number,
a.state,
a.explain,
a.limit,
a.explain,
a.receive_time,
a.use_time,
b.title,
c.storename FROM ".tablename(PDO_NAME."call")
." a LEFT JOIN "
.tablename(PDO_NAME."couponlist")
." b ON a.prize_id = b.id "
." LEFT JOIN "
.tablename(PDO_NAME."merchantdata")
." `c` ON b.merchantid = c.id "
." WHERE {$where} ORDER BY id DESC ";
$sql .= " limit " . ($pindex - 1) * $psize . ',' . $psize;
$list = pdo_fetchall($sql);
$total = pdo_fetchcolumn('SELECT COUNT(1) FROM '.tablename(PDO_NAME.'call'));
$pager = wl_pagination($total, $pindex, $psize);
include wl_template("call/callList");
}
/**
* Comment: 进入编辑集call活动信息页面
* Author: zzw
*/
public function getEditCall(){
global $_W,$_GPC;
$prizeList = pdo_fetchall("SELECT a.id,a.title,b.storename FROM ".tablename(PDO_NAME."couponlist")
." a LEFT JOIN "
.tablename(PDO_NAME."merchantdata")
." b ON a.merchantid = b.id "
." WHERE a.uniacid = {$_W['uniacid']} AND a.aid = {$_W['aid']} AND a.status = 1 AND b.status = 2 AND b.enabled = 1");
if($_GPC['id']){
//修改信息
$info = pdo_get(PDO_NAME."call",array('id'=>$_GPC['id']));
}
include wl_template("call/editCall");
}
/**
* Comment: 对集call活动信息的编辑操作
* Author: zzw
*/
public function editCall(){
global $_W,$_GPC;
$data = $_GPC['data'];
$data['uniacid'] = $_W['uniacid'];
$data['aid'] = $_W['aid'];
$data['receive_time'] = strtotime($data['receive_time']);
$data['use_time'] = strtotime($data['use_time']);
$existence = pdo_get(PDO_NAME."call",$data);
if($_GPC['id']){
//修改活动信息
if($existence){
wl_message('修改失败,未做出如何修改',referer(),'error');
}
$result = pdo_update(PDO_NAME."call",$data,array('id'=>$_GPC['id']));
}else{
//添加活动内容
if($existence){
wl_message('添加失败,内容已存在',referer(),'error');
}
$result = pdo_insert(PDO_NAME."call",$data);
}
if($result){
wl_message('操作成功!',web_url('call/call/callList'),'success');
}else {
wl_message('操作失败,请重试',referer(),'error');
}
}
/**
* Comment: 删除一条集call活动信息
* Author: zzw
*/
public function delCall(){
global $_W,$_GPC;
$id = $_GPC['id'];
$result = pdo_delete(PDO_NAME."call",array('id'=>$id));
if($result){
show_json(1);
}else{
show_json(0,'删除失败');
}
}
/**
* Comment: 已发起集call活动的信息列表
* Author: zzw
*/
public function callLaunchList(){
global $_W,$_GPC;
$name = $_GPC['name'];
$pindex = max(1, intval($_GPC['page']));
$psize = 10;
$where = " a.uniacid = {$_W['uniacid']} AND a.aid = {$_W['aid']} ";
if($name){
$where .= " AND (c.title LIKE '%{$name}%' || b.nickname LIKE '%{$name}%')";
}
$sql = "SELECT
b.nickname,
c.title,
e.title as prize_name,
a.start_time,
c.number,
count(d.list_id) as collect_number,
(number - count(d.list_id)) as surplus_number,
c.receive_time FROM ".tablename(PDO_NAME."call_list")
." a LEFT JOIN "
.tablename(PDO_NAME."member")
." b ON a.mid = b.id LEFT JOIN "
.tablename(PDO_NAME."call")
." `c` ON a.call_id = c.id LEFT JOIN "
.tablename(PDO_NAME."call_hit")
." d ON a.id = d.list_id LEFT JOIN "
.tablename(PDO_NAME."couponlist")
." e ON c.prize_id = e.id "
." WHERE {$where} GROUP BY d.list_id ORDER BY a.start_time DESC ";
$sql .= " limit " . ($pindex - 1) * $psize . ',' . $psize;
$list = pdo_fetchall($sql);
$total = pdo_fetchcolumn('SELECT COUNT(1) FROM '.tablename(PDO_NAME.'call_list'));
$pager = wl_pagination($total, $pindex, $psize);
include wl_template("call/launchList");
}
}