assign('start_time', $begin); $this->assign('end_time', $end); $this->begin = strtotime($begin); $this->end = strtotime($end); $this->assign('timegap', date('Y-m-d h:m:s', $this->begin) . ' - ' . date('Y-m-d h:m:s', $this->end)); } $this->assign('ishis', $ishis); } public function index() { $getp = I('p'); if (empty($getp)) { $getp = 0; } $pagenum = 10;//每页显示多少条 if ((int)I('pagenum/s') > 0) { $pagenum = I('pagenum/s'); } $oldurl = U('Admin/Marketinglibao/index', array( "p" => $getp )); $this->assign('oldurl', urlencode($oldurl)); $this->assign('pagenum', $pagenum); $this->assign('cur_page', $getp); return $this->fetch('', getAdmStoId()); } public function ajaxindex() { $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'); $ylp_postdata["pageSize"] = $pagenum; } $begin = $this->begin; $end = $this->end; $activityName = I('activityName') ? trim(I('activityName')) : ''; // 活动名称 $status = I('status');//活动状态 $where["a.store_id"] = getAdmStoId(); if ($begin) { $where['a.begindate'] = array('egt', $begin); } if ($end) { $where['a.enddate'] = array('elt', $end); } //$where['a.isdel'] = 0; if ($activityName) { $where["a.activity_name"] = array('like','%'.$activityName.'%'); } if ($status != "") { switch ($status) { case "0": $where['a.isdel'] = 0; $where['a.begindate'] = array('gt', time()); break; case "1": $where['a.isdel'] = 0; $where['a.begindate'] = array('elt', time()); $where['a.enddate'] = array('gt', time()); break; case "-1": //$where['a.isdel'] = 1; $where="a.isdel=1 or a.enddate<".time(); break; } } $data1 = M('marketing_newpeople_gift')->alias("a")->where($where)->select(); $count = count($data1); $Page = new AjaxPage($count, $pagenum); $show = $Page->show(); $list = M('marketing_newpeople_gift')->alias("a") ->join('marketing_libao_form b', 'a.store_id=b.store_id and a.gifbagid=b.id', 'left') ->where($where) ->limit($Page->firstRow . ',' . $Page->listRows) ->field('a.*,b.lbtitle') ->order(array('sort_order', 'id' => 'desc')) ->select(); $oldurl = U('Admin/Newpeoplegift/ajaxindex', 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('list', $list); $this->assign('timegap', date('Y-m-d h:m:s', $this->begin) . ' - ' . date('Y-m-d h:m:s', $this->end)); return $this->fetch('', getAdmStoId()); } public function addindex() { $getadmstoid = getAdmStoId(); $accdb = getERPId(); $m = db::query("select max(sort_order)odr from __PREFIX__marketing_newpeople_gift where store_id=" . $getadmstoid); $md = (int)$m[0]["odr"]; $md++; $deatillp['sort_order'] = $md; $deatillp['is_show'] = 1; $deatillp['begindate'] = time(); $deatillp['enddate'] = time() + 3600 * 24 * 30; $getid = I('id/d', 0); $lblist = M('marketing_libao_form')->where(array('store_id' => $getadmstoid, 'is_act' => 1,"isdel"=>0))->select(); $this->assign('lblist', $lblist); //修改 if ($getid) { $deatillp = M('marketing_newpeople_gift')->where(array('store_id' => getAdmStoId(), 'id' => $getid))->find(); if($deatillp){ //开始时间大于当前时间 if ($deatillp['startime']assign('is_stime', 1); } } } $this->assign('deatillp', $deatillp); $this->initEditor(); // 编辑器 return $this->fetch('', getAdmStoId()); } public function addindexhand() { if (IS_POST) { $data = input('post.'); $lbid = $data['id']; $rr = M("admin")->where("admin_id", getAdminId())->find(); $data['begindate'] = strtotime($data['begindate']); $data['enddate'] = strtotime($data['enddate']); if ($lbid) { $oldurl = I('oldurl/s'); if ($oldurl) { $oldurl = urldecode(urldecode($oldurl)); } $this->assign('oldurl', $oldurl); unset($data['id']); $data['edittime'] = time(); $data['editip'] = getIP(); $data['editman'] = $rr['ERPName']; $results = M('marketing_newpeople_gift')->where(array('store_id' => getAdmStoId(), 'id' => $lbid))->save($data); if ($results) { $this->success('操作成功', U('admin/Newpeoplegift/index')); exit; } else { $this->error('操作失败'); exit; } } else { $data['store_id'] = getAdmStoId(); $data['edittime'] = time(); $data['addtime'] = time(); $data['addip'] = getIP(); $data['addman'] = $rr['ERPName']; $results = M('marketing_newpeople_gift')->save($data); if ($results) { $this->success('操作成功', U('admin/Newpeoplegift/addindex')); exit; } else { $this->error('操作失败'); exit; } } } } //删除礼包活动 public function dellibao() { $getadmstoid = getAdmStoId(); $id = $this->request->param('id'); //$lqnum = M('marketing_user_buyreceive_form')->where(array('store_id' => $getadmstoid, 'act_id' => $id, 'act_type' => 1))->count(); //if ($lqnum > 0) { $updatadata['isdel'] = 1; M('marketing_newpeople_gift')->where(array('store_id' => $getadmstoid, 'id' => $id, 'isdel' => 0))->save($updatadata); //} /*--- else { M('marketing_newpeople_gift')->where(array('store_id' => $getadmstoid, 'id' => $id))->delete(); }--*/ $return_arr = array( 'status' => 1, 'msg' => '操作成功', 'data' => array('url' => U('admin/Newpeoplegift/index')), ); $this->ajaxReturn($return_arr); } private function initEditor() { $this->assign("URL_upload", U('Admin/Ueditor/imageUp', array('savepath' => 'newpeoplegift', 'savepath1' => strtolower(getERPId())))); $this->assign("URL_fileUp", U('Admin/Ueditor/fileUp', array('savepath' => 'newpeoplegift', 'savepath1' => strtolower(getERPId())))); $this->assign("URL_scrawlUp", U('Admin/Ueditor/scrawlUp', array('savepath' => 'newpeoplegift', 'savepath1' => strtolower(getERPId())))); $this->assign("URL_getRemoteImage", U('Admin/Ueditor/getRemoteImage', array('savepath' => 'newpeoplegift', 'savepath1' => strtolower(getERPId())))); $this->assign("URL_imageManager", U('Admin/Ueditor/imageManager', array('savepath' => 'newpeoplegift', 'savepath1' => strtolower(getERPId())))); $this->assign("URL_imageUp", U('Admin/Ueditor/imageUp', array('savepath' => 'newpeoplegift', 'savepath1' => strtolower(getERPId())))); $this->assign("URL_getMovie", U('Admin/Ueditor/getMovie', array('savepath' => 'newpeoplegift', 'savepath1' => strtolower(getERPId())))); $this->assign("URL_Home", ""); } //领取记录 public function lqlist() { //--查看购买记录的类型-- $type=I("type",1); $this->assign('type', $type); $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'); $ylp_postdata["pageSize"] = $pagenum; } if ($this->begin > 100 && $this->end > 100) { $begin = $this->begin; $end = $this->end; $this->assign('timegap', date('Y-m-d h:m:s', $this->begin) . '-' . date('Y-m-d h:m:s', $this->end)); } $begin= $add_time_begin=I("add_time_begin"); $end=$add_time_end=I("add_time_end"); if($add_time_begin){ $this->assign('start_time', $add_time_begin); $this->assign('end_time', $add_time_end); $this->assign('timegap', $add_time_begin . ' - ' . $add_time_end); } $mobile = I('mobile') ? trim(I('mobile')) : ''; $where["a.store_id"] = getAdmStoId(); $where2="1=1"; if ($begin) { $where2.= ' and a.addtime>='. strtotime($begin); } if ($end) { $where2.= ' and a.addtime<='.strtotime($end); } if ($mobile) { $where['c.mobile|c.nickname'] = array('like', urldecode(urldecode($mobile))); } $where["a.act_type"] = $type; if ($mobile) { $where["c.mobile"] = urldecode($mobile); } $count = M('marketing_user_buyreceive_form')->alias("a") ->join('marketing_libao_form b', 'a.store_id=b.store_id and a.lb_id=b.id', 'left') ->join('(select store_id,user_id,mobile,vipname,nickname from wxd_users where store_id=' . getAdmStoId() . ') c', 'a.user_id=c.user_id', 'left') ->where($where) ->where($where2) //->fetchSql(true) ->count(); $Page = new Page($count, $pagenum); $show = $Page->show(); $list = M('marketing_user_buyreceive_form')->alias("a") ->join('marketing_libao_form b', 'a.store_id=b.store_id and a.lb_id=b.id', 'left') ->join('(select store_id,user_id,mobile,vipname,nickname from wxd_users where store_id=' . getAdmStoId() . ') c', 'a.user_id=c.user_id', 'left') ->where($where) ->where($where2) ->limit($Page->firstRow . ',' . $Page->listRows) ->field('a.*,b.lbtitle,b.lb_type,c.mobile,c.nickname') ->order(array('id' => 'desc')) ->select(); $oldurl = U('Admin/Newpeoplegift/lqlist', array( "pagenum" => $pagenum, "p" => $cur_page )); $this->assign('oldurl', urlencode($oldurl)); $this->assign('keyword', $mobile); $this->assign('page', $show); $this->assign('pager', $Page); $this->assign('pagenum', $pagenum); $this->assign('cur_page', $cur_page); $this->assign('list', $list); return $this->fetch('', getAdmStoId()); } /*购买记录导出*/ public function export_lqlist() { $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'); $ylp_postdata["pageSize"] = $pagenum; } if ($this->begin > 100 && $this->end > 100) { $begin = $this->begin; $end = $this->end; $this->assign('timegap', date('Y-m-d h:m:s', $this->begin) . ' - ' . date('Y-m-d h:m:s', $this->end)); } $mobile = I('mobile') ? trim(I('mobile')) : ''; $where["a.store_id"] = getAdmStoId(); if ($begin) { $where['a.addtime'] = array('egt', $begin); } if ($end) { $where['a.addtime'] = array('elt', $end); } if ($mobile) { $where['c.mobile|c.nickname'] = array('like', urldecode(urldecode($mobile))); } $where["a.act_type"] = 1; if ($mobile) { $where["c.mobile"] = urldecode($mobile); } $list = M('marketing_user_buyreceive_form')->alias("a") ->join('marketing_libao_form b', 'a.store_id=b.store_id and a.lb_id=b.id', 'left') ->join('(select store_id,user_id,mobile,vipname,nickname from wxd_users where store_id=' . getAdmStoId() . ') c', 'a.user_id=c.user_id', 'left') ->where($where) ->field('a.*,b.lbtitle,b.lb_type,c.mobile,c.nickname') ->order(array('id' => 'desc')) ->select(); $strTable = ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; if (is_array($list)) { foreach ($list as $k => $val) { $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; } } $strTable .= '
礼包名称礼包类型会员昵称手机号购买时间
' . $val['lbtitle'] . ' ' . (stripos($val['lb_type'], ',1,') !== false ? "礼品" : "") . (stripos($val['lb_type'], ',2,') !== false ? "/优惠券" : "") . (stripos($val['lb_type'], ',3,') !== false ? "/服务项目" : "") . (stripos($val['lb_type'], ',4,') !== false ? "/积分" : "") . (stripos($val['lb_type'], ',5,') !== false ? "/成长值" : "") . '' . $val['nickname'] . ' ' . $val['mobile'] . ' ' . date("Y-m-d H:i:s", $val['addtime']) . '
'; echo $strTable; unset($redmoneylist); downloadExcel($strTable, '新人有礼领取礼包记录'); exit(); } //礼包详细 public function details() { $getId = I('id/d'); $getadmstoid = getAdmStoId(); if (empty($getId)) { $this->error('传递参数有误'); exit; } $info = M('marketing_user_buyreceive_form')->alias("a") ->join('marketing_libao_form b', 'a.store_id=b.store_id and a.lb_id=b.id', 'left') ->field('a.*,b.lbtitle,b.lb_type') ->where(array('a.store_id' => $getadmstoid, 'a.id' => $getId))->find(); if (empty($info)) { $this->error('找不到相关信息'); exit; } $deatillp_list1 = M('marketing_user_buyreceive_list')->alias("a") ->join("(select goods_id,goods_sn,goods_name,sku,market_price from wxd_goods where store_id=" . $getadmstoid . ") g", 'a.goods_id=g.goods_id', 'left') ->where(array('a.store_id' => $getadmstoid, 'a.form_order_sn' => $info['order_sn'], 'a.lbtype' => 1))->select(); $deatillp_list2 = M('marketing_user_buyreceive_list')->where(array('store_id' => $getadmstoid, 'form_order_sn' => $info['order_sn'], 'lbtype' => 2))->select(); $deatillp_list3 = M('marketing_user_buyreceive_list')->alias("a") ->join("(select fromid,fw_name,fw_no from wxd_marketing_libao_list where store_id=" . $getadmstoid . " and lbid=".$info['lb_id']." ) g", ' a.service_init_id=g.fromid ') ->where(array('a.store_id' => $getadmstoid, 'a.form_order_sn' => $info['order_sn'], 'a.lbtype' => 3))->select(); $deatillp_list4 = M('marketing_user_buyreceive_list')->where(array('store_id' => $getadmstoid, 'form_order_sn' => $info['order_sn'], 'lbtype' => 4))->find(); $deatillp_list5 = M('marketing_user_buyreceive_list')->where(array('store_id' => $getadmstoid, 'form_order_sn' => $info['order_sn'], 'lbtype' => 5))->find(); $this->assign('deatillp', $info); $this->assign('deatillp_list1', $deatillp_list1); $this->assign('deatillp_list2', $deatillp_list2); $this->assign('deatillp_list3', $deatillp_list3); $this->assign('deatillp_list4', $deatillp_list4); $this->assign('deatillp_list5', $deatillp_list5); return $this->fetch('', getAdmStoId()); } //新人礼判断是否时间有交叉 public function is_time_ok(){ $start=I("begindate"); $end=I("enddate"); $id=I("id"); $wh="1=1 and isdel=0"; if($start) $start=strtotime($start); if($end) $end=strtotime($end); if($id) $wh.=" and id<>".$id; $res=M("marketing_newpeople_gift")->where("store_id",getAdmStoId())->where($wh) ->where("begindate<=".$start." and ". $start."<=enddate")->find(); if($res) return json(["code" => -1, "msg" => "活动时间不能交叉"]); $res=M("marketing_newpeople_gift")->where("store_id",getAdmStoId())->where($wh) ->where("begindate<=".$end." and ". $end."<=enddate")->find(); if($res) return json(["code" => -1, "msg" => "活动时间交叉"]); $res=M("marketing_newpeople_gift")->where("store_id",getAdmStoId())->where($wh) ->where("begindate>=".$start." and ". $end.">=enddate")->find(); if($res) json(["code" => -1, "msg" => "活动时间交叉"]); return json(["code" => 0, "msg" => "活动时间OK"]); } }