fetch('', getAdmStoId());
}
//签到记录
public function integralinfo()
{
$pagenum=20;//每页显示多少条
if ((int)I('pagenum/s')>0)
{
$pagenum=I('pagenum/s');
}
$p = I('p',1);
$timegap = I('timegap');
$timegap=urldecode(urldecode($timegap));
if($timegap){
$gap = explode(' - ', $timegap);
$begin = $gap[0];
$end = $gap[1];
}
else{
$lastweek = date('Y-m-d',strtotime("-1 month")).' 00:00:00';//30天前
$begin = I('begin',$lastweek);
$end = I('end',date('Y-m-d')).' 23:59:59';
}
$this->assign('start_time',$begin);
$this->assign('end_time',$end);
$this->begin = strtotime($begin);
$this->end = strtotime($end)/*+86399*/;
$mobile=I('mobile');//手机号码
$where=" a.store_id=".getAdmStoId();
$where.=" and a.billdate>$this->begin and a.billdate<$this->end ";
if($mobile)
{
$where.=" and b.mobile='".$mobile."' ";
}
$qdrecord=M('qd_record');
$sumnum= $qdrecord->alias('a')
->join('(select user_id,pickup_id,store_id,nickname,mobile from wxd_users where store_id='.getAdmStoId().') b','a.user_id=b.user_id','left')
->where($where)->sum("daynum");
$count= $qdrecord->alias('a')
->join('(select user_id,pickup_id,store_id,nickname,mobile from wxd_users where store_id='.getAdmStoId().') b','a.user_id=b.user_id','left')
->where($where)->count();
$Page = $pager = new Page($count,$pagenum);// 实例化分页类 传入总记录数和每页显示的记录数
$res = $qdrecord->alias('a')
->join('(select user_id,pickup_id,store_id,nickname,mobile from wxd_users where store_id='.getAdmStoId().') b','a.user_id=b.user_id','left')
->join('(select pickup_id,store_id,pickup_name from wxd_pick_up where store_id='.getAdmStoId().') c','b.pickup_id=c.pickup_id','left')
->field('a.id,a.qdbh,a.daynum,a.qd_type,FROM_UNIXTIME(a.billdate)billdate,a.integerstate,b.nickname,b.mobile,c.pickup_name')
->where($where)
->limit($Page->firstRow.','.$Page->listRows)
->order('a.billdate desc')
->select();// 查询满足要求的总记录数
$show = $Page->show();
$this->assign('page',$show);
$this->assign('total',$count);
$this->assign('sumnum',$sumnum==""?0:$sumnum);
$this->assign('info',$res);
$this->assign('timegap',date('Y-m-d h:m:s',$this->begin).' - '.date('Y-m-d h:m:s',$this->end));
session('excel_integralist_'.getAdmStoId(),$res);
return $this->fetch('', getAdmStoId());
}
/*
* ajax 签到记录单页导出
*/
public function export_integralinfo_report_page()
{
$orderList = session('excel_integralist_' . getAdmStoId());
$page=I('page/d',1);
if (empty($orderList)) {
return json(array('code' => -1, 'msg' => '无数据'));
}
$strTable = '
';
$strTable .= '';
$strTable .= '签到单号 | ';
$strTable .= '会员名称 | ';
$strTable .= '手机号码 | ';
$strTable .= '领取积分 | ';
$strTable .= '提交时间 | ';
$strTable .= '签到类型 | ';
$strTable .= '所属门店 | ';
$strTable .= '线下是否充积分 | ';
$strTable .= '
';
$getrowspan = "";
if (is_array($orderList)) {
foreach ($orderList as $k => $val) {
if ($val['daynum']>0 && $val['isbq']!=1)
{
if ($val['qd_type']==2)
{
$val['daynum_desc'] = "连续签到";
}
else {
if ($val['qd_type'] == 3) {
$val['daynum_desc'] = "累计签到";
} else
{
$val['daynum_desc'] = "每日签到";
}
}
}
else
{
$val['daynum_desc'] = "补签扣分";
}
switch ($val['status']) {
case "0":
$val['order_status_desc'] = "未处理";
break;
case "1":
$val['order_status_desc'] = "处理中";
break;
case "2":
$val['order_status_desc'] = "已完成";
break;
case "3":
$val['order_status_desc'] = "已拒绝";
break;
}
$strTable .= '';
$strTable .= ' ' . $val['qdbh'] . ' | ';
$strTable .= ' ' . $val['nickname'] . ' | ';
$strTable .= ' ' . $val['mobile'] . ' | ';
$strTable .= ' ' . $val['daynum'] . ' | ';
$strTable .= ' ' . $val['billdate'] . ' | ';
$strTable .= ' ' . $val['daynum_desc'] . ' | ';
$strTable .= ' ' . $val['pickup_name'] . ' | ';
$strTable .= ' ' . ($val['integerstate'] == 1 ? '是' : '否') . ' | ';
$strTable .= '
';
}
}
$strTable .= '
';
echo $strTable;
unset($orderList);
downloadExcel($strTable, '签到记录'.$page);
exit();
}
/*
* ajax 签到记录列表导出
*/
public function export_integralinfo_report(){
// 搜索条件
$pagenum=20;//每页显示多少条
if ((int)I('pagenum/s')>0)
{
$pagenum=I('pagenum/s');
}
$p = I('p',1);
$timegap = I('timegap');
$timegap=urldecode(urldecode($timegap));
if($timegap){
$gap = explode(' - ', $timegap);
$begin = $gap[0];
$end = $gap[1];
}
else{
$lastweek = date('Y-m-d',strtotime("-1 month")).' 00:00:00';//30天前
$begin = I('begin',$lastweek);
$end = I('end',date('Y-m-d')).' 23:59:59';
}
$this->assign('start_time',$begin);
$this->assign('end_time',$end);
$this->begin = strtotime($begin);
$this->end = strtotime($end)/*+86399*/;
$mobile=I('mobile');//手机号码
$where=" a.store_id=".getAdmStoId();
$where.=" and a.billdate>$this->begin and a.billdate<$this->end ";
if($mobile)
{
$where.=" and b.mobile='".$mobile."' ";
}
$qdrecord=M('qd_record');
$res = $qdrecord->alias('a')
->join('(select user_id,pickup_id,store_id,nickname,mobile from wxd_users where store_id='.getAdmStoId().') b','a.user_id=b.user_id','left')
->join('(select pickup_id,store_id,pickup_name from wxd_pick_up where store_id='.getAdmStoId().') c','b.pickup_id=c.pickup_id','left')
->field('a.id,a.qdbh,a.daynum,a.qd_type,FROM_UNIXTIME(a.billdate)billdate,a.integerstate,b.nickname,b.mobile,c.pickup_name')
->where($where)
->order('a.billdate desc')
->select();// 查询满足要求的总记录数
if (empty($res)) {
return json(array('code' => -1, 'msg' => '无数据'));
}
$strTable = '';
$strTable .= '';
$strTable .= '签到单号 | ';
$strTable .= '会员名称 | ';
$strTable .= '手机号码 | ';
$strTable .= '领取积分 | ';
$strTable .= '提交时间 | ';
$strTable .= '签到类型 | ';
$strTable .= '所属门店 | ';
$strTable .= '线下是否充积分 | ';
$strTable .= '
';
$getrowspan = "";
if (is_array($res)) {
foreach ($res as $k => $val) {
if ($val['daynum']>0 && $val['isbq']!=1)
{
if ($val['qd_type']==2)
{
$val['daynum_desc'] = "连续签到";
}
else {
if ($val['qd_type'] == 3) {
$val['daynum_desc'] = "累计签到";
} else
{
$val['daynum_desc'] = "每日签到";
}
}
}
else
{
$val['daynum_desc'] = "补签扣分";
}
switch ($val['status']) {
case "0":
$val['order_status_desc'] = "未处理";
break;
case "1":
$val['order_status_desc'] = "处理中";
break;
case "2":
$val['order_status_desc'] = "已完成";
break;
case "3":
$val['order_status_desc'] = "已拒绝";
break;
}
$strTable .= '';
$strTable .= ' ' . $val['qdbh'] . ' | ';
$strTable .= ' ' . $val['nickname'] . ' | ';
$strTable .= ' ' . $val['mobile'] . ' | ';
$strTable .= ' ' . $val['daynum'] . ' | ';
$strTable .= ' ' . $val['billdate'] . ' | ';
$strTable .= ' ' . $val['daynum_desc'] . ' | ';
$strTable .= ' ' . $val['pickup_name'] . ' | ';
$strTable .= ' ' . ($val['integerstate'] == 1 ? '是' : '否') . ' | ';
$strTable .= '
';
}
}
$strTable .= '
';
echo $strTable;
unset($res);
downloadExcel($strTable, '签到记录');
exit();
}
/**
* 商品活动列表
*/
public function round_list()
{
$getp = I('p');
$pagenum = 10;//每页显示多少条
if ((int)I('pagenum/s') > 0) {
$pagenum = I('pagenum/s');
}
$oldurl = U('Admin/Marketing/round_list', array(
"p" => $getp
));
$this->assign('oldurl', urlencode($oldurl));
$this->assign('pagenum', $pagenum);
$this->assign('cur_page', $getp);
return $this->fetch('', getAdmStoId());
}
public function ajaxround_list()
{
$header[0] = "token:" . getylp_token(getERPId()) . "";
$cur_page = 1;//当前页数
if ((int)I('p/s') > 0) {
$cur_page = I('p/s');
}
$ylp_postdata["page"] = $cur_page;
$pagenum = 10;//每页显示多少条
if ((int)I('pagenum/s') > 0) {
$pagenum = I('pagenum/s');
$ylp_postdata["pageSize"] = $pagenum;
}
$url = parameter_connect($ylp_postdata);
$ylpres = httpRequest(YLPHD_URL . "/activityb/luckwheel/querylist/?" . $url, 'get', $ylp_postdata, $header);
mlog("列表:" . $ylpres, "ajaxround_list/" . getAdmStoId());
//测试
$data = json_decode($ylpres, true);
if ($data['code'] == 0) {
$count = $data['data']['total'];
$data = $data['data']['pageData'];
} else {
$count = 0;
$data = $data['data'];
}
$Page = new AjaxPage($count, $pagenum);
$show = $Page->show();
$oldurl = U('Admin/Marketing/round_list', array(
"pagenum" => $pagenum,
"p" => $cur_page
));
$this->assign('oldurl', urlencode($oldurl));
$this->assign('page', $show);
$this->assign('pager', $Page);
$this->assign('pagenum', $pagenum);
$this->assign('cur_page', $cur_page);
$this->assign('goodsList', $data);
// upload_ylp_log('大转盘活动');
return $this->fetch('', getAdmStoId());
}
public function lpinfo()
{
$header[0] = "token:" . getylp_token(getERPId()) . "";
$getid = I('goods_id');
$getpostdata["resourceId"] = $getid;
$ylpres = httpRequest(YLPZY_URL . "/source/resource/" . $getid, 'get', $getpostdata, $header);
$data = json_decode($ylpres, true);
if ($data['code'] == 0) {
$return_arr = array(
'status' => 0,
'msg' => "",
'giftname' => $data['data']['resourceName'],
'resourcePrice' => $data['data']['resourcePrice'],
'imageLink' => $data['data']['resourceImages'][0]['imageLink'],
);
} else {
$return_arr = array(
'status' => 1,
'msg' => "",
);
}
return $return_arr;
}
public function addround()
{
$header[0] = "token:" . getylp_token(getERPId()) . "";
//模板
$ylpres_moban = httpRequest(YLPHD_URL . "/activityb/template/querylist?type=LUCKWHEEL&state=0", 'get', '', $header);
mlog("模板:" . $ylpres_moban, "addround/" . getAdmStoId());
$data = json_decode($ylpres_moban, true);
if ($data['code'] == 0) {
$this->assign('moban', $data['data']['pageData']);
}
//礼品列表
$ylp_postdata["token"] = getylp_token(getERPId());
$ylp_postdata["pageSize"] = 100;
$url = parameter_connect($ylp_postdata);
$ylpres = httpRequest(YLPZY_URL . "/source/resource/list/?" . $url, 'get');
// mlog($ylpres,"addround");
$data1 = json_decode($ylpres, true);
$data1 = $data1['data']['pageData'];
$this->assign('lplist', $data1);
$type = I('id') > 0 ? 2 : 1; // 标识自动验证时的 场景 1 表示插入 2 表示更新
if ($type == 2)//获取详细信息
{
$hdid = I('id');
//活动详细
$ylp_deatil = httpRequest(YLPHD_URL . "/activityb/luckwheel/query?id=" . $hdid, 'get', '', $header);
mlog($ylp_deatil,"addround/".getAdmStoId());
$deatildata = json_decode($ylp_deatil, true);
if ($deatildata['code'] == 0) {
$this->assign('deatildata', $deatildata['data']);
$goods_list1 = $deatildata['data']['goods_list'];
$goods_list1 = json_encode($goods_list1);
$goods_list1 = json_decode($goods_list1, true);
$this->assign('goodsList', $goods_list1);
}
}
$this->initEditor(); // 编辑器
return $this->fetch('', getAdmStoId());
}
public function addroundhand()
{
$header[0] = "token:" . getylp_token(getERPId()) . "";
if (IS_POST) {
$getdata = input('post.');
$getdata = json_encode($getdata);
$getdata = json_decode($getdata);
//门店查询
// $ylpres_md = httpRequest(YLPSQ_URL . "/company/branch/search", 'get','',$header);
//
// $datamd=json_decode($ylpres_md,true);
// if ($datamd['code']==0)
// {
// // mlog("门店值:".$ylpres_md,"addroundhand");
// $branches=$datamd['data']['pageData'][0]['codeNum'];
//
// }
if ($getdata) {
$activity_id = $getdata->activity_id;//修改值 不为空为修改
$activity_name = $getdata->activity_name;
$total_rate = $getdata->total_rate;
$raffle_count = $getdata->raffle_count;
$lottery_count = $getdata->lottery_count;
$batch_send_gift = $getdata->batch_send_gift;
$is_share = $getdata->is_share;
$start_time = $getdata->start_time;
$end_time = $getdata->end_time;
$exchange_start_time = $getdata->exchange_start_time;
$exchange_end_time = $getdata->exchange_end_time;
$template_id = $getdata->template_id;
$detail = $getdata->detail;
$activity_type = "LUCKWHEEL";
if (!empty($activity_id)) {
$postdata["activity_id"] = $activity_id;
}
$postdata["activity_name"] = $activity_name;
$postdata["total_rate"] = $total_rate;
$postdata["raffle_count"] = $raffle_count;
$postdata["lottery_count"] = $lottery_count;
$postdata["batch_send_gift"] = $batch_send_gift;
$postdata["is_share"] = $is_share;
$postdata["start_time"] = $start_time;
$postdata["end_time"] = $end_time;
$postdata["exchange_start_time"] = $exchange_start_time;
$postdata["exchange_end_time"] = $exchange_end_time;
$postdata["template_id"] = $template_id;
$postdata["branches"] = "";
$postdata["detail"] = $detail;
$postdata["activity_type"] = $activity_type;
$goods_list1 = $getdata->goods_list;
mlog("商品值:" . json_encode($goods_list1), "addroundhand/".getAdmStoId());
$goods_list1 = json_encode($goods_list1);
$goods_list1 = json_decode($goods_list1, true);
foreach ($goods_list1 as $k => $v) {
if (!empty($v['id'])) {
$goods_list['id'] = $v['id'];
} else {
$goods_list['id'] = "";
}
$goods_list['goods_id'] = $v['goods_id'];
$goods_list['goods_type'] = $v['goods_type'];
$goods_list['stock'] = $v['stock'];
$goods_list['refer_price'] = $v['refer_price'];
$goods_list['price'] = $v['price'];
$goods_list['gift_name'] = $v['gift_name'];
$goods_list['image'] = $v['image'];
$goods1[] = $goods_list;
}
$postdata['goods_list'] = json_encode($goods1);
$postdata = json_encode($postdata);
}
mlog("POST:" . $postdata, "addroundhand/".getAdmStoId());
$postdata = json_decode($postdata);
//修改商家门店基本信息
// $geterpdbaccid=getERPId();
//
// if ($geterpdbaccid == "ppt") {
//
// $resstore=M('store')->where('ERPId',$geterpdbaccid)->field('store_name,store_contact,store_tel')->find();
//
//
// $base_postdata["displayName"] = $resstore['store_contact'];
// $base_postdata["phoneNumber"] = $resstore['store_tel'];
// $base_postdata["enterpriseName"] = $resstore['store_name'];
// $base_postdata["province"]="福建省";
// $base_postdata["city"] = "泉州市";
// $base_postdata["area"] = "丰泽区";
// $base_postdata["streetAddress"] = '泉州软件园';
// }
// else
// {
// //正式
// $erpai_res = json_decode(httpRequest(WXDURL . "?access_token=wxdoa.cust.list.get&accdb=" . $geterpdbaccid), true);
// if ($erpai_res && $erpai_res['code'] == 1) {
// $base_postdata["displayName"] = $erpai_res['data'][0]['bossman'];
// $base_postdata["phoneNumber"] = $erpai_res['data'][0]['mobiletel'];
// $base_postdata["enterpriseName"] = $erpai_res['data'][0]['custname'];
//
// $getarea = $erpai_res['data'][0]['areaname'];
// $getarea = explode('\\', $getarea);
// if (!empty($getarea[0])) {
// $base_postdata["province"] = $getarea[0];
// }
// if (!empty($getarea[1])) {
// $base_postdata["city"] = $getarea[1];
// }
// if (!empty($getarea[2])) {
// $base_postdata["area"] = $getarea[2];
// }
// $base_postdata["streetAddress"] = $erpai_res['data'][0]['address'];
//
// }
//
// }
// $base_ylpres = httpRequest(YLPSQ_URL . "/third/erp/modify", 'POST', $base_postdata, $header);
// mlog($base_ylpres, "addroundhand");
//
if (!empty($activity_id)) {
$sucessmsg = "修改成功!";
$ylpres = httpRequest(YLPHD_URL . "/activityb/luckwheel/update", 'POST', $postdata, $header);
} else {
upload_ylp_log('C04大转盘活动添加/确认提交');
$sucessmsg = "创建成功!";
$ylpres = httpRequest(YLPHD_URL . "/activityb/luckwheel/add", 'POST', $postdata, $header);
}
$data = json_decode($ylpres, true);
if ($data['code'] == 0) {
$return_arr = array(
'status' => 0,
'msg' => $sucessmsg,
// 'data' => array('url' => $oldurl),
);
} else {
$return_arr = array(
'status' => 0,
'msg' => $data['msg'],
// 'data' => array('url' => $oldurl),
);
}
$this->ajaxReturn($return_arr);
}
}
/**
* 礼品列表
*/
public function lplist()
{
$key_word = I('key_word') ? trim(I('key_word')) : ''; // 关键词搜索
$key_no = I('key_no') ? trim(I('key_no')) : ''; //关键编号
$is_on_sale = I('is_on_sale');//有/无库存
$getp = I('p');
$pagenum = 10;//每页显示多少条
if ((int)I('pagenum/s') > 0) {
$pagenum = I('pagenum/s');
}
$oldurl = U('Admin/Marketing/lplist', array(
"is_on_sale" => $is_on_sale,
"key_word" => $key_word,
"pagenum" => $pagenum,
"p" => $getp
));
$this->assign('oldurl', urlencode($oldurl));
$this->assign('key_word', $key_word);
$this->assign('key_no', $key_no);
$this->assign('is_on_sale', $is_on_sale == "" ? 2 : $is_on_sale);
$this->assign('pagenum', $pagenum);
$this->assign('cur_page', $getp);
return $this->fetch('', getAdmStoId());
}
/**
* 添加礼品
*/
public function addlp()
{
$oldurl = I('oldurl/s');
if ($oldurl) {
$oldurl = urldecode(urldecode($oldurl));
}
$this->assign('oldurl', $oldurl);
$type = I('id') > 0 ? 2 : 1; // 标识自动验证时的 场景 1 表示插入 2 表示更新
if ($type == 2) {
$header[0] = "token:" . getylp_token(getERPId()) . "";
$getid = I('id');
$getpostdata["resourceId"] = $getid;
$ylpres = httpRequest(YLPZY_URL . "/source/resource/" . $getid, 'get', $getpostdata, $header);
$data = json_decode($ylpres, true);
if ($data['code'] == 0) {
$this->assign('deatillp', $data['data']);
}
}
//ajax提交验证
if (IS_POST && (I('is_ajax') == 1)) {
$data = input('post.');
// mlog(json_encode($data), "addlp");
// $data = "{\"oldurl\":\"\",\"goods_name\":\"\u73c0\u83b1\u96c5\u8702\u871c\u725b\u5976\u51c0\u767d\u4fee\u62a4\u773c\u971c\",\"goods_sn\":\"6948043413309\",\"shop_price\":\"324\",\"original_img\":\"\/public\/upload\/marketing\/temp\/2017\/07-04\/b0ad94438ee4e96ad561223d90a95d12.jpg\",\"store_count\":\"0\",\"goods_content\":\"232323<\/p>\",\"goods_id\":\"\"}";
$lpid = $data['goods_id'];
if (!empty($lpid)) { //更新
$header[0] = "token:" . getylp_token(getERPId()) . "";
$resource["id"] = $lpid;
} else {
mlog("add", "addlp");
$ylp_postdata["token"] = getylp_token(getERPId());
}
//
if (!empty($data['original_img'])) {
$upfilepath = ROOT_PATH . $data['original_img'];
if (file_exists($upfilepath)) {
$img_data = [
'img' => $upfilepath,
'imgname' => basename($data['original_img']),
];
$post_data = image_form_data_splice($img_data['img'], $img_data['imgname']);
if (!empty($post_data)) {
$post_data .= FORM_HYPHENS . FORM_BOUNDARY . FORM_HYPHENS;
}
$req_headers = [
'Content-Type: multipart/form-data; boundary=' . FORM_BOUNDARY,
];
$ylpres = httpRequest(YLPZY_URL . "/accounts/imgs", 'POST', $post_data, $req_headers);
$data1 = json_decode($ylpres, true);
if ($data1['code'] == 0) {
$yaccessimg = $data1['data']['download_url'];
try {
mdelFile($upfilepath);
} catch (\Exception $ex) {
mlog($ex, "addlp");
}
} else {
$yaccessimg = $data['original_img'];
}
} else {
$yaccessimg = $data['original_img'];
}
}
//
$resource["resourceName"] = $data['goods_name'];
$resource["resourceType"] = "GOODS";
$resource["resourceCode"] = $data['goods_sn'];
$resource["resourcePrice"] = $data['shop_price'];
$resource["surplusStock"] = $data['store_count'];
$resource["resourceDetails"] = $data['goods_content'];
$resource["resourceImages"] = array(['imageLink' => $yaccessimg]);
$ylp_postdata["resource"] = json_encode($resource);
mlog(json_encode($ylp_postdata), "addlp");
if (empty($lpid)) { //插入
upload_ylp_log('C03礼品管理添加/确认提交');
$ylpres = httpRequest(YLPZY_URL . "/source/resource/add", 'POST', $ylp_postdata);
$msgstr = "添加成功!";
$data = json_decode($ylpres, true);
} else {
$ylpres = httpRequest(YLPZY_URL . "/source/resource/update", 'put', $ylp_postdata, $header);
$data = json_decode($ylpres, true);
$msgstr = "修改成功!";
}
if ($data['code'] == 0) {
$return_arr = array(
'status' => 1,
'msg' => $msgstr,
'data' => array('url' => U('admin/Marketing/lplist')),
);
} else {
$return_arr = array(
'status' => 0,
'msg' => $data['msg']
);
}
// upload_ylp_log('添加修改礼品');
$this->ajaxReturn($return_arr);
}
$this->initEditor(); // 编辑器
return $this->fetch('_lipin', getAdmStoId());
}
public function testup()
{
// $streamData = file_get_contents('php://input');
//
// mlog($streamData, "testup");
//
// $ylp_postdata["token"] =getylp_token(getERPId());
// $ylp_postdata["image"] =$streamData;
// $ylpres = httpRequest(YLPIMG_URL . "/accounts/imgs",'POST',$ylp_postdata);
// var_dump($ylpres);
return $this->fetch('testup', getAdmStoId());
}
public function ajaxtestup()
{
$streamData = file_get_contents('php://input');
mlog($streamData, "testup");
$ylp_postdata["token"] = getylp_token(getERPId());
$ylp_postdata["image"] = $streamData;
$ylpres = httpRequest(YLPIMG_URL . "/accounts/imgs", 'POST', $ylp_postdata);
var_dump($ylpres);
return $this->fetch('testup', getAdmStoId());
}
/**
* 礼品列表
*/
public function ajaxlpList()
{
// var_dump(getylp_token(getERPId()));die;//
$ylp_postdata["token"] = getylp_token(getERPId());
$key_word = I('key_word') ? trim(I('key_word')) : ''; // 关键词搜索
$key_no = I('key_no') ? trim(I('key_no')) : ''; // 关键编号搜索
$is_on_sale = I('is_on_sale');//有库存/无库存
$cur_page = 1;//当前页数
if ((int)I('p/s') > 0) {
$cur_page = I('p/s');
}
$ylp_postdata["page"] = $cur_page;
$pagenum = 10;//每页显示多少条
if ((int)I('pagenum/s') > 0) {
$pagenum = I('pagenum/s');
$ylp_postdata["pageSize"] = $pagenum;
}
if ($key_word !== "") {
$ylp_postdata["resourceName"] = urlencode($key_word);
}
if ($key_no !== "") {
$ylp_postdata['logicId'] = urlencode($key_no);
}
if ($is_on_sale !== "") {
$ylp_postdata["stockState"] = $is_on_sale;
}
$url = parameter_connect($ylp_postdata);
mlog("返回URL:" . YLPZY_URL . "/source/resource/list/?" . $url, "ajaxlpList/" . getAdmStoId());
$ylpres = httpRequest(YLPZY_URL . "/source/resource/list/?" . $url, 'get');
mlog("返回:" . $ylpres, "ajaxlpList/" . getAdmStoId());
$data = json_decode($ylpres, true);
$count = $data['data']['total'];
$Page = new AjaxPage($count, $pagenum);
$show = $Page->show();
$data = $data['data']['pageData'];
$oldurl = U('Admin/Marketing/lpList', array(
"is_on_sale" => $is_on_sale,
"key_word" => $key_word,
"pagenum" => $pagenum,
"p" => $cur_page
));
$this->assign('oldurl', urlencode($oldurl));
$this->assign('key_word', $key_word);
$this->assign('key_no', $key_no);
$this->assign('page', $show);
$this->assign('is_on_sale', $is_on_sale);
$this->assign('pager', $Page);
$this->assign('pagenum', $pagenum);
$this->assign('cur_page', $cur_page);
//$this->assign('store_warning_storage',tpCache('basic.warning_storage', getAdmStoId()));
//var_dump($data);die;
$this->assign('goodsList', $data);
// upload_ylp_log('礼品查询');
return $this->fetch('', getAdmStoId());
}
public function dellp()
{
$id = $this->request->param('id');
$ylp_postdata["token"] = getylp_token(getERPId());
$url = parameter_connect($ylp_postdata);
$ylpres = httpRequest(YLPZY_URL . "/source/resource/delete/" . $id . "?" . $url, 'delete');
$data = json_decode($ylpres, true);
if ($data['code'] == 0) {
// upload_ylp_log('删除礼品');
$return_arr = array(
'status' => 1,
'msg' => '操作成功',
'data' => array('url' => U('admin/Marketing/lpList')),
// 'data' => array('url' => $oldurl),
);
} else {
$return_arr = array(
'status' => 0,
'msg' => '删除失败',
'data' => array('url' => U('admin/Marketing/lpList')),
// 'data' => array('url' => $oldurl),
);
}
$this->ajaxReturn($return_arr);
}
// /**
// * 礼包列表
// */
// public function lblist()
// {
// $key_word = I('key_word') ? trim(I('key_word')) : ''; // 关键词搜索
// $lbtype= I('lbtype');
// $getp = I('p');
// $pagenum = 10;//每页显示多少条
// if ((int)I('pagenum/s') > 0) {
// $pagenum = I('pagenum/s');
// }
// $oldurl = U('Admin/Marketing/lblist', array(
// "key_word" => $key_word,
// "pagenum" => $pagenum,
// "p" => $getp
// ));
// $this->assign('lbtype', $lbtype);
// $this->assign('oldurl', urlencode($oldurl));
// $this->assign('key_word', $key_word);
// $this->assign('pagenum', $pagenum);
// $this->assign('cur_page', $getp);
//
// return $this->fetch('', getAdmStoId());
// }
//
// /**
// * 添加礼包
// */
// public function addlb()
// {
// $oldurl = I('oldurl/s');
// if ($oldurl) {
// $oldurl = urldecode(urldecode($oldurl));
// }
// $this->assign('oldurl', $oldurl);
// $type = I('id') > 0 ? 2 : 1; // 标识自动验证时的 场景 1 表示插入 2 表示更新
// if ($type == 2) {
//
// $getid = I('id');
// $getpostdata["resourceId"] = $getid;
//
// $data = M('libao_form')->where(array('store_id'=>getAdmStoId(),'id'=>$getid))->select();
//
// if ($data) {
// $data=$data[0];
// $data['endtime'] = date('Y-m-d H:i:s', $data['endtime']);
// $data['startime'] = date('Y-m-d H:i:s', $data['startime']);
// $data['lburls']=QCLOUD_IMGURL.$data['lburl'];
// if($data['lbtype']==1)
// {
// $data1=M('libao_list')->where('lbid='.$getid)->select();
// }
// else{//优惠券·
// $data1 = db::name('libao_list')
// ->alias('a')
// ->join('coupon b ', 'a.cpid=b.id', 'left')
// ->where('a.lbid='.$getid)
// ->field('a.goods_num,b.*')
// ->order('a.id desc')
// ->select();
// foreach ($data1 as $k => $v) {
// $data1[$k]['use_end_time']=date('Y-m-d H:i:s', $v['use_end_time']);
// $data1[$k]['use_start_time']=date('Y-m-d H:i:s', $v['use_start_time']);
// switch ($v['type'])
// {
// case 1: $data1[$k]['type']='免费发放';
// break;
// case 2: $data1[$k]['type']='注册发放';
// break;
// case 3: $data1[$k]['type']='邀请发放';
// break;
// case 4: $data1[$k]['type']='优惠活动';
// break;
// case 5: $data1[$k]['type']='包邮券';
// break;
// default:break;
// }
// }
//
// }
//
// $this->assign('goods',$data1);
// $this->assign('deatillp', $data);
// }
// }
// else{
// $m = db::query("select max(sort_order)odr from __PREFIX__libao_form where store_id=". getAdmStoId());
// $md = (int)$m[0]["odr"];
// $md++;
//
// $data['startime'] = date('Y-m-d H:i:s');
// $data['endtime'] = date('Y-m-d 23:59:59', time() + 3600 * 24 * 60);
// $data['sort_order']=$md;
// $this->assign('deatillp', $data);
//
// }
//
//
// //ajax提交验证
//
// if (IS_POST) {
//
//
// $data = input('post.');
// $lbid = $data['lbid'];
// //
// $resource['store_id'] = getAdmStoId();
// $resource["lbtitle"] = $data['lbtitle'];
// $resource["startime"] = strtotime($data['startime']);
// $resource["endtime"] = strtotime($data['endtime']);
// $resource['lbtype']= $data['lbtype'];
// $resource["lburl"] = $data['lburl'];
// $resource['isgift']=$data['isgift'];
// $resource["lbprice"] = $data['lbprice'];
// $resource["lbintegral"] = $data['lbintegral'];
// $resource["num"] = $data['num'];
// $resource["limitnum"] = $data['limitnum'];
// $resource["usertype"] = $data['usertype'];
// $resource['codetype']=0;
// $resource["lbintro"] = $data['lbintro'];
// $resource["expday"] = $data['expday'];
// $resource["sort_order"] = $data['sort_order'];
// $resource["billdate"] = time();
//
//
//
//
//
// //启动事务
// db::startTrans();
// try {
// if (empty($lbid)) { //插入
// $result=M('libao_form')->add($resource);
// $lbid=$result;
// }
// else
// {
// M('libao_list')->where('lbid='.$lbid)->delete();
// $result=M('libao_form')->where('id='.$lbid)->save($resource);
//
// }
// if ($result > 0) {
//// $return_arr = array(
//// 'status' => 1,
//// 'msg'=>'操作成功',
//// 'data' => array('url' => U('admin/Marketing/lblist')),
//// );
//
// for($i=0;$iwhere('id='.$lbid)->save(array('codetype'=>1));
// $lblist['state']=2; //有虚拟商品(服务按次)
// }
// else{
// $lblist['state']=1; //实物
// }
// $lblist['goods_sn']=$data['goods_sn'][$i];
// $lblist['goods_name']=$data['goods_name'][$i];
// $lblist['goods_code']=$data['goods_code'][$i];
// $lblist['pos_price']=$data['pos_price'][$i];
// }
// else
// {
// $lblist['state']=3; //优惠券
// $lblist['cpid']=$data['cpid'][$i];
// }
//
//
// $lblist['goods_num']=$data['goods_num'][$i];
// $lblist['lbid']=$lbid;
// $lblist['store_id']=getAdmStoId();
// $lblist['billdate']=time();
// M('libao_list')->add($lblist);
// }
// $results=1;
//
//
//
// }
//
// Db::commit();
// }catch (\Exception $e) {
// // 回滚事务
// db::rollback();
//// M('libao_form')->where('id='.$result)->delete();
// }
// if($results){
// $this->success('操作成功', U('admin/Marketing/lblist'));
// exit;
// }
// else{
// $this->error('操作失败');
// exit;
// }
//
//
// upload_ylp_log('添加修改礼包');
//// $this->ajaxReturn($return_arr);
//
//
// }
//
// return $this->fetch('_libin', getAdmStoId());
// }
//
//
// /*--渲染商品--*/
// function getGoods()
// {
// return $this->fetch('search', getAdmStoId());
// }
//
// /*--访问接口选择商品--*/
// public function SelectGood()
// {
// $p = I('p/d', 1);
// $key = trim(urldecode(I('key/s')));
// if($key)
// {
// $where['WareName|WareNo|BarCode'] = array('like', '%' . $key . '%');
// }
//
// $where['State'] = array('=', 1);
//
// mlog(json_encode($where), "good/" . getAdmStoId());
// $getapi_token=tpCache('shop_info.api_token', getAdmStoId());
//
// $rs = getApiData('wxd.mshop.wares.list.get', $getapi_token, null, $where, $p, 10,null);
// mlog($rs, "good/" . getAdmStoId());
//// upload_ylp_log('商品选择');
//
// if ($rs) {
// $data = json_decode($rs, true);
// if ($data['data']) {
// foreach ($data['data'] as $k => $v) {
// $data['data'][$k]['PurPrice'] = number_format(empty($v['PurPrice']) ? 0 : $v['PurPrice'], 2, ".", "");
// $data['data'][$k]['PosPrice'] = number_format(empty($v['PosPrice']) ? 0 : $v['PosPrice'], 2, ".", "");
// $data['data'][$k]['VipPrice'] = number_format(empty($v['VipPrice']) ? 0 : $v['VipPrice'], 2, ".", "");
// $data['data'][$k]['TradePrice'] = number_format(empty($v['TradePrice']) ? 0 : $v['TradePrice'], 2, ".", "");
// }
// return json($data);
// } else {
// $check = M('goods')->where('goods_sn= "'.$key.'" or goods_name="'.$key.'" or sku="'.$key.'%" ')->where('store_id',getAdmStoId())->find();
// if ($check){
// return json(['code' => -1 ,'msg'=>'该商品已添加']);
// }else{
// return json(["code" => -1, "msg" => "未找到您要搜索的商品"]);
// }
//
// }
// } else {
// return json(["code" => -1, "msg" => "获取接口数据错误"]);
// }
// }
//
//
// /*--渲染优惠券--*/
// function getCp()
// {
// return $this->fetch('searchcp', getAdmStoId());
// }
//
// /*--访问接口选择优惠券--*/
// public function SelectCp()
// {
// $p = I('p/d', 1);
// $key = trim(urldecode(I('key/s')));
// if($key)
// {
// $where['name|money|condition'] = array('like', '%' . $key . '%');
// }
//
// $where['store_id'] = array('=', getAdmStoId());
//
//
//
//
// $cptype = I('coupontype');
//
//
// if($cptype){
// $where['type'] = array('=',$cptype);
// }
// $count = M('coupon')->where($where)->count();
// $Page = new Page($count,10);
// $show = $Page->show();
// $data = M('coupon')->where($where)->order('add_time desc')->limit($Page->firstRow.','.$Page->listRows)->select();
//
//
//
//
//
//
// mlog(json_encode($data,true), "lbcp/" . getAdmStoId());
//// upload_ylp_log('商品选择');
//
//
//
// if ($data) {
// foreach ($data as $k => $v) {
// $data[$k]['use_end_time']=date('Y-m-d H:i:s', $v['use_end_time']);
// $data[$k]['use_start_time']=date('Y-m-d H:i:s', $v['use_start_time']);
// switch ($v['type'])
// {
// case 1: $data[$k]['type']='免费发放';
// break;
// case 2: $data[$k]['type']='注册发放';
// break;
// case 3: $data[$k]['type']='邀请发放';
// break;
// case 4: $data[$k]['type']='优惠活动';
// break;
// case 5: $data[$k]['type']='包邮券';
// break;
// default:break;
// }
// }
//
// return json(['code'=>1,"data"=>$data,'msg'=>'数据获取成功','count'=>$count]);
// } else {
// return json(["code" => -1, "msg" => "未找到您要搜索的优惠券"]);
// }
//
// }
//
//
// /**
// * 礼包列表
// */
// public function ajaxlbList()
// {
//
//
//
// $key_word = I('key_word') ? trim(I('key_word')) : ''; // 关键词搜索
// $lbtype=I('lbtype');
// $cur_page = 1;//当前页数
// if ((int)I('p/s') > 0) {
// $cur_page = I('p/s');
//
// }
//
// $pagenum = 10;//每页显示多少条
// if ((int)I('pagenum/s') > 0) {
// $pagenum = I('pagenum/s');
//
// }
// $where['store_id'] = array('=',getAdmStoId());
// if ($key_word !== "") {
//// $key_word = urlencode($key_word);
// $where['lbtitle']=array('like','%'.$key_word.'%');
//
// }
// if ($lbtype)
// {
// $where['lbtype']=$lbtype;
// }
//
// $data=M('libao_form')->where($where)->order(array('sort_order','billdate'=>'desc'))->select();
//
//
// $count = count($data);
// $Page = new AjaxPage($count, $pagenum);
// $show = $Page->show();
//
//
//
// $oldurl = U('Admin/Marketing/lbList', array(
// "key_word" => $key_word,
// "pagenum" => $pagenum,
// "p" => $cur_page
// ));
// $this->assign('oldurl', urlencode($oldurl));
// $this->assign('key_word', $key_word);
// $this->assign('page', $show);
// $this->assign('pager', $Page);
// $this->assign('pagenum', $pagenum);
// $this->assign('cur_page', $cur_page);
//
// //$this->assign('store_warning_storage',tpCache('basic.warning_storage', getAdmStoId()));
//
//
// //var_dump($data);die;
// $this->assign('goodsList', $data);
//// upload_ylp_log('礼品查询');
// return $this->fetch('', getAdmStoId());
// }
//
// //删除礼包活动
// public function dellb()
// {
//
// $id = $this->request->param('id');
//
//
// //启动事务
// db::startTrans();
// try {
// M('libao_form')->where(array('store_id'=>getAdmStoId(),'id'=>$id))->delete();
// M('libao_list')->where(array('store_id'=>getAdmStoId(),'lbid'=>$id))->delete();
// Db::commit();
// $return_arr = array(
// 'status' => 1,
// 'msg' => '操作成功',
// 'data' => array('url' => U('admin/Marketing/lbList')),
// // 'data' => array('url' => $oldurl),
// );
// }catch (\Exception $e) {
// // 回滚事务
// db::rollback();
// $return_arr = array(
// 'status' => 0,
// 'msg' => '删除失败',
// 'data' => array('url' => U('admin/Marketing/lbList')),
// // 'data' => array('url' => $oldurl),
// );
// }
//
//
// $this->ajaxReturn($return_arr);
//
// }
/**
* 兑换列表
*/
public function giftstore()
{
$state = I('state'); // 状态
$phone = I('phone'); // 手机号
$qr_code = I('qr_code'); // 兑换码
$activity_name = I('activity_name'); // 活动名称
$gift_name = I('gift_name'); // 礼品名称
$add_time_begin = I('add_time_begin') ? trim(I('add_time_begin')) : ''; //活动时间
$add_time_end = I('add_time_end') ? trim(I('add_time_end')) : ''; // 活动时间
$exchange_begin_time = I('exchange_begin_time') ? trim(I('exchange_begin_time')) : ''; // 兑换时间
$exchange_end_time = I('exchange_end_time') ? trim(I('exchange_end_time')) : ''; // 兑换结束时间
$getp = I('p');
$pagenum = 10;//每页显示多少条
if ((int)I('pagenum/s') > 0) {
$pagenum = I('pagenum/s');
}
$oldurl = U('Admin/Marketing/gifstore', array(
"state" => $state,
"phone" => $phone,
"activity_name" => $activity_name,
"gift_name" => $gift_name,
"add_time_begin" => $add_time_begin,
"add_time_end" => $add_time_end,
"exchange_begin_time" => $exchange_begin_time,
"exchange_end_time" => $exchange_end_time,
"pagenum" => $pagenum,
));
$url1 = "&state=" . $state . "&phone=" . $phone . "&qr_code=" . $qr_code . "&activity_name=" . $activity_name . "&gift_name=" . $gift_name . "&add_time_begin=" . $add_time_begin . "&add_time_end=" . $add_time_end . "&exchange_begin_time=" . $exchange_begin_time . "&exchange_end_time=" . $exchange_end_time . "";
$excelurl = YLPHD_URL . "/activityb/luckwheel/export?token=" . getylp_token(getERPId()) . $url1;
$this->assign('oldurl', urlencode($oldurl));
$this->assign('state', $state);
$this->assign('phone', $phone);
$this->assign('activity_name', $activity_name);
$this->assign('gift_name', $gift_name);
$this->assign('add_time_begin', $add_time_begin);
$this->assign('add_time_end', $add_time_end);
$this->assign('exchange_begin_time', $exchange_begin_time);
$this->assign('exchange_end_time', $exchange_end_time);
$this->assign('excelurl', $excelurl);
$this->assign('pagenum', $pagenum);
$this->assign('cur_page', $getp);
return $this->fetch('', getAdmStoId());
}
/**
* 兑换内容加载
*/
public function ajaxgiftstore()
{
//var_dump(getylp_token(getERPId()));die;getylp_token(getERPId());//
$header[0] = "token:" . getylp_token(getERPId()) . "";
$state = I('state/d'); // 状态
$phone = I('phone'); // 手机号
$qr_code = I('qr_code'); // 兑换码
$activity_name = I('activity_name'); // 活动名称
$gift_name = I('gift_name'); // 礼品名称
$add_time_begin = I('add_time_begin1') ? trim(I('add_time_begin1')) : ''; //活动时间
$add_time_end = I('add_time_end1') ? trim(I('add_time_end1')) : ''; // 活动时间
$exchange_begin_time = I('add_time_begin2') ? trim(I('add_time_begin2')) : ''; // 兑换时间
$exchange_end_time = I('add_time_end2') ? trim(I('add_time_end2')) : ''; // 兑换结束时间
$cur_page = 1;//当前页数
if ((int)I('p/s') > 0) {
$cur_page = I('p/s');
}
$ylp_postdata["page"] = $cur_page;
$pagenum = 10;//每页显示多少条
if ((int)I('pagenum/s') > 0) {
$pagenum = I('pagenum/s');
$ylp_postdata["pageSize"] = $pagenum;
}
if ($state !== "") {
$ylp_postdata["state"] = $state;
}
if ($phone !== "") {
$ylp_postdata['phone'] = urlencode($phone);
}
if ($qr_code !== "") {
$ylp_postdata["qr_code"] = urlencode($qr_code);
}
if ($activity_name !== "") {
$ylp_postdata["activity_name"] = urlencode($activity_name);
}
//var_dump($activity_name);die;
if ($gift_name !== "") {
$ylp_postdata["gift_name"] = urlencode($gift_name);
}
if ($add_time_begin !== "") {
$ylp_postdata["activity_start_time"] = urlencode($add_time_begin);
}
if ($add_time_end !== "") {
$ylp_postdata["activity_end_time"] = urlencode($add_time_end);
}
if ($exchange_begin_time !== "") {
$ylp_postdata["exchange_begin_time"] = urlencode($exchange_begin_time);
}
if ($exchange_end_time !== "") {
$ylp_postdata["exchange_end_time"] = urlencode($exchange_end_time);
}
$url = parameter_connect($ylp_postdata);
$excelurl = YLPHD_URL . "/activityb/luckwheel/export?token=" . getylp_token(getERPId()) . "&" . $url;
$ylpres = httpRequest(YLPHD_URL . "/activityb/luckwheel/queryexchangerecords/?" . $url, 'get', $ylp_postdata, $header);
//$ylpres="{\"code\":0,\"msg\":\"\",\"data\":{\"total\":2,\"page\":1,\"pageSize\":10,\"pageData\":[{\"exchange_user\":\"testsj\",\"exchange_time\":\"2017-06-06 11:51:17\",\"start_time\":\"2017-06-05 11:44:17\",\"end_time\":\"2017-06-11 23:59:00\",\"create_time\":\"2017-06-05 14:13:14\",\"phone\":\"18620612806\",\"qr_code\":\"805869280851\",\"state\":1,\"gift_name\":\"卡姿兰(Carslan)致美靓颜基础套装\",\"id\":2868,\"activity_name\":\"花Young大转盘\"},{\"exchange_user\":\"testsj\",\"exchange_time\":\"2017-06-06 11:51:19\",\"start_time\":\"2017-06-05 11:44:17\",\"end_time\":\"2017-06-11 23:59:00\",\"create_time\":\"2017-06-05 11:50:01\",\"phone\":\"18620612806\",\"qr_code\":\"805558299750\",\"state\":1,\"gift_name\":\"卡姿兰彩妆套装全套组合 初学者淡妆裸妆美妆化妆品套装 含美妆工具 3#自然妆\",\"id\":2868,\"activity_name\":\"花Young大转盘\"}]}}";
// mlog($ylpres,"ajaxgiftstore");
$data = json_decode($ylpres, true);
// var_dump($data);
// die();
if ($data['code'] == 0) {
$count = $data['data']['total'];
$data = $data['data']['pageData'];
} else {
$count = 0;
$data = "";
}
$Page = new AjaxPage($count, $pagenum);
$show = $Page->show();
$oldurl = U('Admin/Marketing/gifstore', array(
"state" => $state,
"phone" => $phone,
"activity_name" => $activity_name,
"gift_name" => $gift_name,
"add_time_begin" => $add_time_begin,
"add_time_end" => $add_time_end,
"exchange_begin_time" => $exchange_begin_time,
"exchange_end_time" => $exchange_end_time,
"pagenum" => $pagenum,
"p" => $cur_page
));
$this->assign('oldurl', urlencode($oldurl));
$this->assign('page', $show);
$this->assign('pager', $Page);
$this->assign('pagenum', $pagenum);
$this->assign('cur_page', $cur_page);
//var_dump($data);die;
$this->assign('excelurl', $excelurl);
$this->assign('goodsList', $data);
// upload_ylp_log('兑换');
return $this->fetch('', getAdmStoId());
}
/**
* 兑换列表
*/
public function businessdatalist()
{
$header[0] = "token:" . getylp_token(getERPId()) . "";
$activityId = I('activityId') ? trim(I('activityId')) : ''; // 活动Id
$ylp_postdata["token"] = getylp_token(getERPId());
$ylp_postdata["activityId"] = $activityId;
$url = parameter_connect($ylp_postdata);
$ylpres = httpRequest(YLPCOUNT_URL . "/api/activityb/business/overview/getLuckWheelAllOverview/?" . $url, 'get', $ylp_postdata, $header);
//$ylpres="{\"code\":0,\"data\":{\"totalPv\":2,\"totalUv\":1,\"totalExchangeCount\":2,\"totalShareCount\":1,\"totalParticipateCount\":2,\"totalWinCount\":2},\"msg\":\"获取大转盘数据成功!\"}";
$data = json_decode($ylpres, true);
//var_dump($data);
if ($data['code'] == 0) {
$data = $data['data'];
}
$this->assign('datacount', $data);
$getp = I('p');
$pagenum = 10;//每页显示多少条
if ((int)I('pagenum/s') > 0) {
$pagenum = I('pagenum/s');
}
$this->assign('activityId', $activityId);
$this->assign('pagenum', $pagenum);
$this->assign('cur_page', $getp);
return $this->fetch('', getAdmStoId());
}
/**
* 兑换内容加载
*/
public function ajaxbusinessdata()
{
//var_dump(getylp_token(getERPId()));die;getylp_token(getERPId());//
$header[0] = "token:" . getylp_token(getERPId()) . "";
$activityId = I('activityId') ? trim(I('activityId')) : ''; // 活动Id
$cur_page = 1;//当前页数
if ((int)I('p/s') > 0) {
$cur_page = I('p/s');
}
$ylp_postdata["page"] = $cur_page;
$pagenum = 10;//每页显示多少条
if ((int)I('pagenum/s') > 0) {
$pagenum = I('pagenum/s');
$ylp_postdata["pageSize"] = $pagenum;
}
if (!empty($activityId)) {
$ylp_postdata["activityId"] = $activityId;
}
$url = parameter_connect($ylp_postdata);
$excelurl = YLPCOUNT_URL . "/api/activityb/business/overview/exportQueryLuckWheelOverview?token=" . getylp_token(getERPId()) . "&" . $url;
$ylpres = httpRequest(YLPCOUNT_URL . "/api/activityb/business/overview/pageQueryLuckWheelOverview?" . $url, 'get', $ylp_postdata, $header);
//$ylpres="{\"code\":0,\"data\":{\"total\":18,\"page\":1,\"pageSize\":10,\"pageData\":[{\"recordTime\":\"2017-06-11 00:00:00\",\"pv\":0,\"uv\":0,\"shareCount\":0,\"participateCount\":0,\"participatePeopleCount\":0,\"winCount\":0,\"winPeopleCount\":0,\"exchangeCount\":0},{\"recordTime\":\"2017-06-10 00:00:00\",\"pv\":0,\"uv\":0,\"shareCount\":0,\"participateCount\":0,\"participatePeopleCount\":0,\"winCount\":0,\"winPeopleCount\":0,\"exchangeCount\":0},{\"recordTime\":\"2017-06-09 00:00:00\",\"pv\":0,\"uv\":0,\"shareCount\":0,\"participateCount\":0,\"participatePeopleCount\":0,\"winCount\":0,\"winPeopleCount\":0,\"exchangeCount\":0},{\"recordTime\":\"2017-06-08 00:00:00\",\"pv\":0,\"uv\":0,\"shareCount\":0,\"participateCount\":0,\"participatePeopleCount\":0,\"winCount\":0,\"winPeopleCount\":0,\"exchangeCount\":0},{\"recordTime\":\"2017-06-07 00:00:00\",\"pv\":4,\"uv\":2,\"shareCount\":0,\"participateCount\":0,\"participatePeopleCount\":0,\"winCount\":0,\"winPeopleCount\":0,\"exchangeCount\":0},{\"recordTime\":\"2017-06-06 00:00:00\",\"pv\":0,\"uv\":0,\"shareCount\":0,\"participateCount\":0,\"participatePeopleCount\":0,\"winCount\":0,\"winPeopleCount\":0,\"exchangeCount\":0},{\"recordTime\":\"2017-06-05 00:00:00\",\"pv\":0,\"uv\":0,\"shareCount\":0,\"participateCount\":0,\"participatePeopleCount\":0,\"winCount\":0,\"winPeopleCount\":0,\"exchangeCount\":0},{\"recordTime\":\"2017-06-04 00:00:00\",\"pv\":0,\"uv\":0,\"shareCount\":0,\"participateCount\":0,\"participatePeopleCount\":0,\"winCount\":0,\"winPeopleCount\":0,\"exchangeCount\":0},{\"recordTime\":\"2017-06-03 00:00:00\",\"pv\":8,\"uv\":2,\"shareCount\":0,\"participateCount\":0,\"participatePeopleCount\":0,\"winCount\":0,\"winPeopleCount\":0,\"exchangeCount\":0},{\"recordTime\":\"2017-06-02 00:00:00\",\"pv\":0,\"uv\":0,\"shareCount\":0,\"participateCount\":0,\"participatePeopleCount\":0,\"winCount\":0,\"winPeopleCount\":0,\"exchangeCount\":0}]},\"msg\":\"获取大转盘数据统计列表成功!\"}";
$data = json_decode($ylpres, true);
//var_dump($data);
//die();
if ($data['code'] == 0) {
$count = $data['data']['total'];
$data = $data['data']['pageData'];
} else {
$count = 0;
$data = "";
}
$Page = new AjaxPage($count, $pagenum);
$show = $Page->show();
$this->assign('page', $show);
$this->assign('pager', $Page);
$this->assign('pagenum', $pagenum);
$this->assign('excelurl', $excelurl);
$this->assign('cur_page', $cur_page);
//var_dump($data);die;
$this->assign('goodsList', $data);
// upload_ylp_log('大转盘数据');
return $this->fetch('', getAdmStoId());
}
private function initEditor()
{
$this->assign("URL_upload", U('Admin/Ueditor/imageUp', array('savepath' => 'Marketing')));
$this->assign("URL_fileUp", U('Admin/Ueditor/fileUp', array('savepath' => 'Marketing')));
$this->assign("URL_scrawlUp", U('Admin/Ueditor/scrawlUp', array('savepath' => 'Marketing')));
$this->assign("URL_getRemoteImage", U('Admin/Ueditor/getRemoteImage', array('savepath' => 'Marketing')));
$this->assign("URL_imageManager", U('Admin/Ueditor/imageManager', array('savepath' => 'Marketing')));
$this->assign("URL_imageUp", U('Admin/Ueditor/imageUp', array('savepath' => 'Marketing')));
$this->assign("URL_getMovie", U('Admin/Ueditor/getMovie', array('savepath' => 'Marketing')));
$this->assign("URL_Home", "");
}
//积分签到
public function integral()
{
$info = M("qd_config")->where(array("store_id" => getAdmStoId()))->select();//
if (IS_POST) {
$getdata = input('post.');
$getdata = json_encode($getdata);
//mlog($getdata,"addroundhand");
$getdata = json_decode($getdata);
if ($getdata) {
if (empty($getdata->typeid)) {
$return_arr = array(
'status' => 1,
'msg' => '必须选择一个签到方式',
);
return $return_arr;
}
$edit = $getdata->edit;
$postdata["store_id"] = getAdmStoId();
$postdata["typeid"] = $getdata->typeid;
$postdata["integralnum1"] = $getdata->integralnum1;
$postdata["daynum2"] = $getdata->daynum2;
$postdata["dayintegral1"] = $getdata->dayintegral1;
$postdata["dayintegral2"] = $getdata->dayintegral2;
$postdata["dayintegral3"] = $getdata->dayintegral3;
$postdata["dayintegral4"] = $getdata->dayintegral4;
$postdata["dayintegral5"] = $getdata->dayintegral5;
$postdata["dayintegral6"] = $getdata->dayintegral6;
$postdata["dayintegral7"] = $getdata->dayintegral7;
$postdata["dayintegral8"] = $getdata->dayintegral8;
$postdata["dayintegral9"] = $getdata->dayintegral9;
$postdata["dayintegral10"] = $getdata->dayintegral10;
$postdata["bqday"] = $getdata->bqday;
$postdata["bqnum"] = $getdata->bqnum;
$postdata["bqintegral1"] = $getdata->bqintegral1;
$postdata["bqintegral2"] = $getdata->bqintegral2;
$postdata["bqintegral3"] = $getdata->bqintegral3;
$postdata["bqintegral4"] = $getdata->bqintegral4;
$postdata["bqintegral5"] = $getdata->bqintegral5;
$postdata["daynum3"] = $getdata->daynum3;
$postdata["integralnum3"] = $getdata->integralnum3;
$postdata["is_show"] = $getdata->is_show;
$postdata["qdrules"] = $getdata->qdrules;
//确保有id
if($info && empty($edit)){
$edit=$info[0]['id'];
}
if ($edit) // 编辑
{
$postdata["editdate"] = time();
$postdata["editip"] = getIP();
$row = M('qd_config')->where(array("id" => $edit))->save($postdata);
} else {
$postdata["billdate"] = time();
$postdata["billip"] = getIP();
upload_ylp_log('C01积分签到添加/确认提交');
$row = M('qd_config')->add($postdata);
}
if ($row == 1) {
$return_arr = array(
'status' => 0,
'msg' => '修改成功',
// 'data' => array('url' => $oldurl),
);
} else {
$return_arr = array(
'status' => 1,
'msg' => '修改失败',
// 'data' => array('url' => $oldurl),
);
}
return $return_arr;
}
}
$this->assign('info', $info[0]);
return $this->fetch('', getAdmStoId());
}
//积分购
public function integral_sale()
{
$pagenum = 10;//每页显示多少条
if ((int)I('pagenum/s') > 0) {
$pagenum = I('pagenum/s');
}
//var_dump(strtotime("-1 day"));die;
$this->updategoodstype('4');
$condition = array();
$condition['store_id'] = getAdmStoId();
$condition['is_end'] = 0;
$keywords = trim(urldecode(urldecode(I('keywords'))));
$condition['name'] = array('like', '%' . $keywords . '%');
$model = M('integral_buy');
$count = $model->where($condition)->count();
$Page = new Page($count, $pagenum);
$show = $Page->show();
$prom_list = $model->where($condition)->order("id desc")->limit($Page->firstRow . ',' . $Page->listRows)->select();
$this->assign('prom_list', $prom_list);
$this->assign('keywords',$keywords);
$this->assign('page', $show);// 赋值分页输出
$this->assign('pager', $Page);
$this->assign('pagenum', $pagenum);
// upload_ylp_log('积分购');
return $this->fetch('', getAdmStoId());
}
//添加积分购
public function integral_shop()
{
$pattern=tpCache('distribut.pattern',getAdmStoId());
$this->assign('pattern', $pattern);
if (IS_POST) {
ClearALLCache();
delFile(TEMP_PATH . "/" . getAdmStoId());
$data = I('post.');
mlog(json_encode($data), "integral_shop");
$data['end_time'] = strtotime($data['end_time']);
$data['start_time'] = strtotime($data['start_time']);
if ($data['end_time'] <= $data['start_time']) {
$this->error('结束时间必须大于结束时间');
}
$data['store_id'] = getAdmStoId();
$admid = getAdminId();
$amdinfo = getAdminInfo($admid);
$data['edit_man'] = $amdinfo['ERPName'];
$adata['edit_man'] = $amdinfo['ERPName'];
/*---操作活动总表---*/
$adata['prom_type'] = 4;
$adata['goods_listid'] = "," . $data['goods_id'] . ",";
$adata['is_show'] = $data['is_show'];
$adata['is_end'] = 0;
$adata['warm_uptime'] = 0;
$adata['s_time'] = $data['start_time'];
$adata['e_time'] = $data['end_time'];
$adata['prom_price'] = $data['addmoney'];
$adata['prom_integral'] = $data['integral'];
$adata['store_id'] = getAdmStoId();
if($data['commission'])
$adata['commission'] = $data['commission'];
if($pattern==1){
$adata['fir_rate'] = $data['fir_rate'];
$adata['sec_rate'] = $data['sec_rate'];
$adata['thi_rate'] = $data['thi_rate'];
}
if (empty($data['id'])) {
$data['add_time'] = time();
$data['add_ip'] = getIP();
$r = M('integral_buy')->add($data);
M('goods')->where("goods_id=" . $data['goods_id'])->save(array('prom_id' => $r, 'prom_type' => 4));
adminLog("管理员添加积分购活动 " . $data['name']);
$adata['add_time'] = time();
$adata['add_ip'] = getIP();
$adata['act_id'] = $r;
M('activitylist')->save($adata);
upload_ylp_log('C02积分购添加/确认提交');
} else {
$data['edit_time'] = time();
$data['edit_mark'] = "编辑抢购活动";
$data['edit_ip'] = getIP();
$r = M('integral_buy')->where("id=" . $data['id'])->save($data);
M('goods')->where("goods_id=" . $data['goods_id'])->save(array('prom_id' => $data['id'], 'prom_type' => 4));
$adata['edit_time'] = time();
$adata['edit_ip'] =getIP();
M('activitylist')->where('act_id', $data['id'])->where('prom_type', 4)->save($adata);
}
if ($r) {
$this->success('编辑积分购活动成功', U('Marketing/integral_sale'));
exit;
} else {
$this->error('编辑积分购活动失败', U('Marketing/integral_sale'));
}
}
$id = I('id');
$info['start_time'] = date('Y-m-d H:i:s');
$info['end_time'] = date('Y-m-d 23:59:59', time() + 3600 * 24 * 60);
$info['is_show']=1;
if ($id > 0) {
$info = M('integral_buy')->where("id=$id")->find();
$is_start=0;
if( $info['start_time']