0) { $pagenum = I('pagenum/s'); } $oldurl = U('Admin/Marketinglibao/index', array( "p" => $getp )); $ishis = I('ishis'); $this->assign('oldurl', urlencode($oldurl)); $this->assign('pagenum', $pagenum); $this->assign('cur_page', $getp); $this->assign('ishis', $ishis); return $this->fetch('', getAdmStoId()); } //--- 礼包列表页ajax --- public function ajaxindex() { $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; } $startTime = I('startTime') ? trim(I('startTime')) : ''; // 开始时间 $endTime = I('endTime') ? trim(I('endTime')) : ''; // 结束时间 $activityName = I('activityName') ? trim(I('activityName')) : ''; // 活动名称 $activityId = I('activityId') ? trim(I('activityId')) : ''; // 活动编号 $status = I('status');//活动状态 $ishis = I('ishis'); $ylp_postdata["startTime"] = urlencode($startTime); $ylp_postdata["endTime"] = urlencode($endTime); $ylp_postdata["activityName"] = urlencode($activityName); $ylp_postdata["id"] = urlencode($activityId); $ylp_postdata["status"] = $status; $url = parameter_connect($ylp_postdata); $oldurl = U('Admin/Marketinglibao/ajaxindex', array( "pagenum" => $pagenum, "p" => $cur_page )); $key_word = I('activityName') ? trim(I('activityName')) : ''; // 关键词搜索 if ($key_word !== "") { $where['lbtitle'] = array('like', '%' . $key_word . '%'); } if ($startTime) { $where['startime'] = array('egt', strtotime($startTime)); } if ($endTime) { $where['endtime'] = array('elt', strtotime($endTime)); } $where['isdel'] = 0; if ($ishis) $where['isdel'] = 1; if ($status != "" && $status != null) { $where['isshow'] = $status; } $data1 = M('marketing_libao_form')->where($where)->count(); $Page = new AjaxPage($data1, $pagenum); $show = $Page->show(); $data = M('marketing_libao_form')->where($where)->limit($Page->firstRow . ',' . $Page->listRows)->order(array('sort_order' => 'desc', 'addtime' => 'desc'))->select(); foreach ($data as $k => $v) { $num = M("marketing_user_buyreceive_form") ->where("pay_state=1 and act_type=0") ->where("lb_id", $v['id'])->where('store_id', getAdmStoId())->count(); $data[$k]['bnum'] = $num; } $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); return $this->fetch('', getAdmStoId()); } //--- 添加修改礼包 --- public function addindex() { $getadmstoid = getAdmStoId(); $accdb = getERPId(); $rank_switch = tpCache('shopping.rank_switch', $getadmstoid);//PLUS开关 $islook = I("islook"); $this->assign("islook", $islook); if ($rank_switch) { $this->assign('rank_switch', $rank_switch); $plus_data['storeId'] = $getadmstoid; $plus_list = getApiData_mini("/api/weshop/plus/vip/mem/bership/list", $plus_data, $getadmstoid); if ($plus_list) { $plus_list = json_decode($plus_list, true); if ($plus_list['code'] == 0 && $plus_list['data']) { $this->assign('plus_list', $plus_list['data']); } } } //会员权益 $grade_data['storeId'] = $getadmstoid; $init_data = getApiData_mini("api/weshop/users/grade/vip/init/get", $grade_data, $getadmstoid); $isBool = 0; if ($init_data) { $init_data = json_decode($init_data, true); if ($init_data['code'] === 0 && $init_data['data']) { try { $isBool = $init_data['data']['isBool']; } catch (\Exception $e) { } $this->assign('isBool', $isBool); if ($isBool) { //会员权益列表 $grade_list = getApiData_mini("/api/weshop/users/grade/vipgradeinfo/page", $grade_data, $getadmstoid); if ($grade_list) { $grade_list = json_decode($grade_list, true); if ($grade_list['code'] == 0 && $grade_list['data']['pageData']) { $this->assign('grade_list', $grade_list['data']['pageData']); } } } } } //默认添加 $m = db::query("select max(sort_order)odr from __PREFIX__marketing_libao_form where store_id=" . $getadmstoid); $md = (int)$m[0]["odr"]; $md++; $deatillp['sort_order'] = $md; $deatillp['isshow'] = 1; $deatillp['lb_type'] = ",1,"; $deatillp['startime'] = date('Y-m-d H:i:s'); $deatillp['endtime'] = date('Y-m-d 23:59:59', time() + 3600 * 24 * 30); //---如果有ID的话,是修改---- $id = I("id"); if ($id) { $deatillp = M("marketing_libao_form")->where("store_id", $getadmstoid)->where("id", $id)->find(); if (empty($deatillp)) { $this->error("找不到相关信息"); } //开始时间大于当前时间 if ($deatillp['startime'] < time()) { $this->assign('is_stime', 1); } //-- 时间修改 -- if ($deatillp['startime']) $deatillp['startime'] = date("Y-m-d H:i:s", $deatillp['startime']); if ($deatillp['endtime']) $deatillp['endtime'] = date("Y-m-d H:i:s", $deatillp['endtime']); if ($deatillp['exchange_starttime']) $deatillp['exchange_starttime'] = date("Y-m-d H:i:s", $deatillp['exchange_starttime']); if ($deatillp['exchange_endtime']) $deatillp['exchange_endtime'] = date("Y-m-d H:i:s", $deatillp['exchange_endtime']); $deatillp_list1 = M("marketing_libao_list")->where("lbtype", 1)->where("store_id", $getadmstoid)->where("lbid", $id)->select(); $deatillp_list2 = M("marketing_libao_list")->where("lbtype", 2)->where("store_id", $getadmstoid)->where("lbid", $id)->select(); $deatillp_list3 = M("marketing_libao_list")->where("lbtype", 3)->where("store_id", $getadmstoid)->where("lbid", $id)->select(); if ($deatillp_list1) { foreach ($deatillp_list1 as $k => $v) { $g = M("goods")->where("goods_id", $v['fromid'])->find(); $deatillp_list1[$k]['goods_sn'] = $g['goods_sn']; $deatillp_list1[$k]['goods_name'] = $g['goods_name']; $deatillp_list1[$k]['goods_code'] = $g['sku']; $deatillp_list1[$k]['pos_price'] = $g['market_price']; } $this->assign('deatillp_list1', $deatillp_list1); //礼品的 } if ($deatillp_list2) { foreach ($deatillp_list2 as $k => $v) { $g = M("coupon")->where("id", $v['fromid'])->find(); $deatillp_list2[$k]['name'] = $g['name']; $deatillp_list2[$k]['use_start_time'] = date("Y-m-d", $g['use_start_time']); $deatillp_list2[$k]['use_end_time'] = date("Y-m-d", $g['use_end_time']); $deatillp_list2[$k]['money'] = $g['money']; $deatillp_list2[$k]['condition'] = $g['condition']; switch ($g['type']) { case 1: $deatillp_list2[$k]['type'] = '免费发放'; break; case 2: $deatillp_list2[$k]['type'] = '注册发放'; break; case 3: $deatillp_list2[$k]['type'] = '邀请发放'; break; case 5: $deatillp_list2[$k]['type'] = '优惠活动'; break; case 6: $deatillp_list2[$k]['type'] = '包邮券'; $deatillp_list2[$k]['money'] = '无'; break; case 7: $deatillp_list2[$k]['type'] = '会员权益'; break; case 8: $deatillp_list2[$k]['type'] = '新人专享'; break; case 9: $deatillp_list2[$k]['type'] = 'PLUS专享'; break; default: break; } } $this->assign('deatillp_list2', $deatillp_list2); //礼券的 } if ($deatillp_list3) $this->assign('deatillp_list3', $deatillp_list3); //服务项目 } else { $deatillp['exchange_type'] = 1; } $this->assign('deatillp', $deatillp); $this->initEditor(); // 编辑器 return $this->fetch('', getAdmStoId()); } //--- 礼包保存 --- public function addMarketinglibaohand() { $parm = I("post."); $stoid = getAdmStoId(); //-- 礼包类型的处理,要用逗号连接 -- $lb_type = ","; if ($parm["lb_type1"]) { $lb_type .= "1,"; unset($parm['lb_type1']); } if ($parm["lb_type2"]) { $lb_type .= "2,"; unset($parm['lb_type2']); } if ($parm["lb_type3"]) { $lb_type .= "3,"; unset($parm['lb_type3']); } if ($parm["lb_type4"]) { $lb_type .= "4,"; unset($parm['lb_type4']); } if ($parm["lb_type5"]) { $lb_type .= "5,"; unset($parm['lb_type5']); } if ($lb_type != ",") { $parm["lb_type"] = $lb_type; } //-- input值 --- $g_arr = $parm['grade_str']; $p_arr = $parm['plustype_str']; //-- checkbox值 --- // $gs_arr= $parm["grade_state"]; // $ps_arr= $parm["plustype_state"]; $grade_str = ""; if ($g_arr) { foreach ($g_arr as $k => $v) { $val = $parm["grade_state" . ($k + 1)]; if ($val) { $grade_str .= $v . ","; } } if ($grade_str) $parm['grade'] = $grade_str; } $plus_str = ""; if ($p_arr) { foreach ($p_arr as $k => $v) { $val = $parm["plustype_state" . ($k + 1)]; if ($val) { $plus_str .= $p_arr[$k] . ","; } } if ($plus_str) $parm['plustype'] = $plus_str; } if ($parm["startime"]) $parm["startime"] = strtotime($parm["startime"]); if ($parm["endtime"]) $parm["endtime"] = strtotime($parm["endtime"]); if ($parm["exchange_starttime"]) $parm["exchange_starttime"] = strtotime($parm["exchange_starttime"]); if ($parm["exchange_endtime"]) $parm["exchange_endtime"] = strtotime($parm["exchange_endtime"]); //---如果有ID就是修改--- if ($parm['id']) { $id = $parm['id']; unset($parm['id']); if ($parm['is_act']) $parm['is_act'] = 1; $rs = M("marketing_libao_form")->where("id", $id)->update($parm); $rs_str = M("marketing_libao_form")->where("id", $id)->fetchSql(true)->update($parm); if ($rs !== false) { M("marketing_libao_list")->where('lbid', $id)->delete(); $num = $parm['num']; $list_arr = null; foreach ($num as $k => $v) { $in_data = null; $in_data['lbid'] = $id; $in_data['store_id'] = $stoid; $in_data['billdate'] = time(); $in_data['lbtype'] = $parm['lbtype'][$k]; $in_data['fromid'] = $parm['fromid'][$k]; $in_data['num'] = $v; $in_data['fw_name'] = ""; $in_data['fw_no'] = ""; if ($parm['fw_name'][$k]) $in_data['fw_name'] = $parm['fw_name'][$k]; if ($parm['fw_no'][$k]) $in_data['fw_no'] = $parm['fw_no'][$k]; $list_arr[] = $in_data; } if ($list_arr) $rs = M("marketing_libao_list")->insertAll($list_arr); $this->success("保存成功", U('Admin/Marketinglibao/index')); } } else { $parm['store_id'] = $stoid; $parm['addtime'] = time(); //--- 添加数据 --- $rs = M("marketing_libao_form")->insertGetId($parm); if ($rs) { $num = $parm['num']; $list_arr = null; if ($num) { foreach ($num as $k => $v) { $in_data = null; $in_data['lbid'] = $rs; $in_data['store_id'] = $stoid; $in_data['billdate'] = time(); $in_data['lbtype'] = $parm['lbtype'][$k]; $in_data['fromid'] = $parm['fromid'][$k]; $in_data['num'] = $v; $in_data['fw_name'] = ""; $in_data['fw_no'] = ""; if ($parm['fw_name'][$k]) $in_data['fw_name'] = $parm['fw_name'][$k]; if ($parm['fw_no'][$k]) $in_data['fw_no'] = $parm['fw_no'][$k]; $list_arr[] = $in_data; } } if ($list_arr) $rs = M("marketing_libao_list")->insertAll($list_arr); $this->success("保存成功", U('Admin/Marketinglibao/index')); } $this->error("保存失败"); } } //--- 礼包编辑器 --- private function initEditor() { $this->assign("URL_upload", U('Admin/Ueditor/imageUp', array('savepath' => 'marketinglibao', 'savepath1' => strtolower(getERPId())))); $this->assign("URL_fileUp", U('Admin/Ueditor/fileUp', array('savepath' => 'marketinglibao', 'savepath1' => strtolower(getERPId())))); $this->assign("URL_scrawlUp", U('Admin/Ueditor/scrawlUp', array('savepath' => 'marketinglibao', 'savepath1' => strtolower(getERPId())))); $this->assign("URL_getRemoteImage", U('Admin/Ueditor/getRemoteImage', array('savepath' => 'marketinglibao', 'savepath1' => strtolower(getERPId())))); $this->assign("URL_imageManager", U('Admin/Ueditor/imageManager', array('savepath' => 'marketinglibao', 'savepath1' => strtolower(getERPId())))); $this->assign("URL_imageUp", U('Admin/Ueditor/imageUp', array('savepath' => 'marketinglibao', 'savepath1' => strtolower(getERPId())))); $this->assign("URL_getMovie", U('Admin/Ueditor/getMovie', array('savepath' => 'marketinglibao', 'savepath1' => strtolower(getERPId())))); $this->assign("URL_Home", ""); } /*--渲染商品,选中商品的代码--*/ function search() { $is_ajax = I("is_ajax"); if ($is_ajax) { /*--访问接口选择商品--*/ $p = I('p/d', 1); $key = trim(urldecode(I('key/s'))); if ($key) { $where['goods_name|goods_sn|sku'] = array('like', '%' . $key . '%'); } $t = time(); $where['store_id'] = getAdmStoId(); $rs = M('goods')->where($where) ->where("is_on_sale=1 and on_time<" . $t . " and (down_time>" . $t . " or down_time=0 or down_time='')") ->order('goods_id desc')->page("$p,20")->select(); if ($rs) { $data['code'] = 1; $data['msg'] = "获取商品列表成功"; $data['count'] = count($rs); foreach ($rs as $k => $v) { $data['data'][$k]['Id'] = $v['goods_id']; $data['data'][$k]['WaresType'] = $v['is_virtual'] == 1 ? 2 : 0; $data['data'][$k]['WareNo'] = $v['goods_sn']; $data['data'][$k]['WareName'] = $v['goods_name']; $data['data'][$k]['BarCode'] = $v['sku']; $data['data'][$k]['PosPrice'] = number_format(empty($v['market_price']) ? 0 : $v['market_price'], 2, ".", ""); $data['data'][$k]['VipPrice'] = number_format(empty($v['shop_price']) ? 0 : $v['shop_price'], 2, ".", ""); } return json($data); } else { return json(["code" => -1, "msg" => "无商品信息"]); } } return $this->fetch('', getAdmStoId()); } //服务项目查询 public function smitemlist() { $cur_page = I('p/d', 0);//当前页数 if ($cur_page <= 0) { $cur_page = 1; } $this->assign('cur_page', $cur_page); $keyword = I('keyword'); $pagenum = I('pagenum/d', 10); $this->assign("pagenum", $pagenum); $this->assign("keyword", $keyword); return $this->fetch('', getAdmStoId()); } //---服务项目查询---- public function ajax_smitem() { $stoid = getAdmStoId(); $sto = tpCache('shop_info', $stoid);//商户信息 $sto_erpid = $sto['ERPId']; $keyword = I('keyword'); $getp = I('p/d', 1); $PrivilegeId = I('PrivilegeId/s'); $pagenum = I('pagenum/d', 10); $where = array(); $where["XZType"] = "SMItem"; if ($keyword != "") { $where["XZName"] = urlencode($keyword); } $list = getApiData_java_p("/api/erp/grade/smitem/page", $sto_erpid, $where, $getp, $pagenum, null, "GET"); if ($list) { $list = json_decode($list, true); if ($list['code'] == 0) { $count = $list['data']['total']; $list = $list['data']['pageData']; $Page = new AjaxPage($count, $pagenum); $show = $Page->show(); $this->assign('page', $show); $this->assign('pager', $Page); $this->assign('count', $count); $this->assign("list", $list); } } return $this->fetch('', getAdmStoId()); } public function dellibao() { $id = $this->request->param('id'); $return_arr = null; if (empty($id)) { $return_arr = array( 'status' => 0, 'msg' => '删除失败,参数有误', 'data' => array('url' => U('admin/Marketinglibao/index')), ); $this->ajaxReturn($return_arr); } $getadmstoid = getAdmStoId(); //判断是否新人有礼有用 $new_info = M('marketing_newpeople_gift')->where(array('store_id' => $getadmstoid, 'isdel' => 0, 'gifbagid' => $id))->find(); if ($new_info) { $return_arr = array( 'status' => 0, 'msg' => '删除失败,该礼包新人专享活动正在使用', 'data' => array('url' => U('admin/Marketinglibao/index')), ); $this->ajaxReturn($return_arr); } //评价有礼 $commentsinfo = M('marketing_comments_reward')->where(array('store_id' => $getadmstoid, 'isdel' => 0, 'giftbagid' => $id))->find(); if ($commentsinfo) { $return_arr = array( 'status' => 0, 'msg' => '删除失败,该礼包评价有礼活动正在使用', 'data' => array('url' => U('admin/Marketinglibao/index')), ); $this->ajaxReturn($return_arr); } //节日有礼 $commentsinfo = M('marketing_holiday_reward')->where(array('store_id' => $getadmstoid, 'isdel' => 0, 'giftbagid' => $id))->find(); if ($commentsinfo) { $return_arr = array( 'status' => 0, 'msg' => '删除失败,该礼包节日有礼活动正在使用', 'data' => array('url' => U('admin/Marketinglibao/index')), ); $this->ajaxReturn($return_arr); } //生日有礼 $commentsinfo = M('marketing_birthday_reward')->where(array('store_id' => $getadmstoid, 'isdel' => 0, 'giftbagid' => $id))->find(); if ($commentsinfo) { $return_arr = array( 'status' => 0, 'msg' => '删除失败,该礼包生日有礼活动正在使用', 'data' => array('url' => U('admin/Marketinglibao/index')), ); $this->ajaxReturn($return_arr); } //生日有礼 $commentsinfo = M('marketing_birthday_reward')->where(array('store_id' => $getadmstoid, 'isdel' => 0, 'giftbagid' => $id))->find(); if ($commentsinfo) { $return_arr = array( 'status' => 0, 'msg' => '删除失败,该礼包生日有礼活动正在使用', 'data' => array('url' => U('admin/Marketinglibao/index')), ); $this->ajaxReturn($return_arr); } $commentsinfo = M('wxd_marketing_help_list')->alias('a') ->join('marketing_help_form b','a.store_id=b.store_id and a.help_id=b.id','left') ->where(array('a.store_id' => $getadmstoid, 'b.isdel' => 0, 'a.giftbagid' => $id))->find(); if ($commentsinfo) { $return_arr = array( 'status' => 0, 'msg' => '删除失败,该礼包助力有礼活动正在使用', 'data' => array('url' => U('admin/Marketinglibao/index')), ); $this->ajaxReturn($return_arr); } $rs = M('marketing_libao_form')->where(array('store_id' => getAdmStoId(), 'id' => $id))->save(array('isdel' => 1)); if (empty($rs)) { $return_arr = array( 'status' => 0, 'msg' => '删除失败', 'data' => array('url' => U('admin/Marketinglibao/index')), ); $this->ajaxReturn($return_arr); } $return_arr = array( 'status' => 1, 'msg' => '操作成功', 'data' => array('url' => U('admin/Marketinglibao/index')), ); $this->ajaxReturn($return_arr); } //购买礼包记录 public function salelist() { $pagenum = 20;//每页显示多少条 if ((int)I('pagenum/s') > 0) { $pagenum = I('pagenum/s'); } $p = I('p', 1); $start_time = I('add_time_begin'); $end_time = I('add_time_end'); $begin = $this->begin; $end = $this->end; if (empty($start_time)) { $lastweek = date('Y-m-d', strtotime("-1 month"));//30天前 $start_time = $lastweek . ' 00:00:00'; } if (empty($end_time)) { $end_time = I('end', date('Y-m-d')) . ' 23:59:59'; } $this->assign('start_time', $start_time); $this->assign('end_time', $end_time); $mobile = I('mobile');//手机号码 $order_sn = I('order_sn');//手机号码 $lbid = I('lbid');//礼包ID $this->assign('lbid', $lbid); $keyword = I('keyword');//关键字 if (empty($keyword)) $keyword = $mobile; $getisend = I('act_id'); $where = " a.store_id=" . getAdmStoId(); if ($keyword) { $where .= " and (c.mobile='" . $keyword . "' or c.nickname like '%" . $keyword . "%') "; } if ($lbid) { $where .= " and a.lb_id=" . $lbid; } if ($start_time) { $start_time = urldecode($start_time); $where .= " and a.addtime>=" . strtotime($start_time); } if ($end_time) { $end_time = urldecode($end_time); $where .= " and a.addtime<=" . strtotime($end_time); } $where .= " and a.act_type=0"; // 只查礼包 $lbtype = I('lbtype'); if ($lbtype != "") { $where .= " and b.lbtype=" . $lbtype; } $paytype = I('paytype'); $paytypes = intval($paytype); switch ($paytypes) { case 3: //未付款 $where .= " and pay_state=0 && pay_type=2"; break; case 1: //积分兑换 $where .= " and a.pay_state=1 and a.pay_type=2 and a.pay_integral <> ''"; break; case 2: //微支付 $where .= " and a.pay_state=1 and a.pay_type=2 "; break; } $qdrecord = M('marketing_user_buyreceive_form'); $count = $qdrecord->alias('a') ->join('marketing_libao_form b', ' a.lb_id=b.id', 'left') ->join('(select nickname,vipname,mobile,user_id from wxd_users where store_id=' . getAdmStoId() . ') c', ' a.user_id=c.user_id', 'left') ->where($where) ->count(); $Page = $pager = new Page($count, $pagenum);// 实例化分页类 传入总记录数和每页显示的记录数 $redmoneylist = $qdrecord->alias('a') ->join('marketing_libao_form b', ' a.lb_id=b.id', 'left') ->join('(select nickname,mobile,user_id from wxd_users where store_id=' . getAdmStoId() . ') c', ' a.user_id=c.user_id ', 'left') ->where($where) ->limit($Page->firstRow . ',' . $Page->listRows) ->order('a.addtime desc') ->field('a.*,c.nickname,c.mobile,b.lb_type,b.lbtitle') ->select();// 查询满足要求的总记录数 $redmoneylist_s = $qdrecord->alias('a') ->join('marketing_libao_form b', ' a.lb_id=b.id', 'left') ->join('(select nickname,mobile,user_id from wxd_users where store_id=' . getAdmStoId() . ') c', ' a.user_id=c.user_id ', 'left') ->where($where) ->limit($Page->firstRow . ',' . $Page->listRows) ->order('a.addtime desc') ->field('a.*,c.nickname,c.mobile,b.lb_type,b.lbtitle') ->fetchSql(true) ->select();// 查询满足要求的总记录数 $lblist = M('marketing_libao_form')->where('store_id=' . getAdmStoId())->select(); $show = $Page->show(); $this->assign('page', $show); $this->assign('total', $count); $this->assign('lblist', $lblist); $this->assign('p', $p - 1); $this->assign('order_sn', $order_sn); $this->assign('lbtype', $lbtype); $this->assign('paytype', $paytype); $this->assign('keyword', $keyword); $this->assign('redmoneylist', $redmoneylist); $this->assign('pagenum', $pagenum); $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 export_salelist() { $begin = I('add_time_begin'); $end = I('add_time_end'); $this->assign('start_time', $begin); $this->assign('end_time', $end); $mobile = I('mobile');//手机号码 $order_sn = I('order_sn');//手机号码 $lbid = I('lbid');//礼包ID $this->assign('lbid', $lbid); $keyword = I('keyword');//关键字 $where = " a.store_id=" . getAdmStoId(); if ($keyword) { $where .= " and (c.mobile='" . $keyword . "' or c.nickname like '%" . $keyword . "%') "; } if ($lbid) { $where .= " and a.lb_id=" . $lbid; } if ($begin) { $where .= " and a.addtime>=" . strtotime($begin); } if ($end) { $where .= " and a.addtime<=" . strtotime($end); } $paytype = I('paytype'); switch ($paytype) { //未付款 case 3: $condition['pay_state'] = 0; break; //积分兑换 case 1: $where .= " and a.pay_state=1 and a.pay_type=1 "; break; //微支付 case 2: $where .= " and a.pay_state=1 and a.pay_type=2 "; break; } $qdrecord = M('marketing_user_buyreceive_form'); $redmoneylist = $qdrecord->alias('a') ->join('marketing_libao_form b', ' a.lb_id=b.id', 'left') ->join('(select nickname,mobile,user_id from wxd_users where store_id=' . getAdmStoId() . ') c', ' a.user_id=c.user_id', 'left') ->where($where) ->where($condition) ->order('a.addtime desc') ->field('a.*,c.nickname,c.mobile,b.lb_type,b.lbtitle') ->select();// 查询满足要求的总记录数 $strTable = ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; if (is_array($redmoneylist)) { foreach ($redmoneylist as $k => $val) { $strTable .= ''; $strTable .= ''; $strTable .= ''; $type = ""; if (stripos($val[lb_type], ',1,') !== false) $type .= "礼品"; if (stripos($val[lb_type], ',2,') !== false) $type .= " 优惠券"; if (stripos($val[lb_type], ',3,') !== false) $type .= " 服务项目"; if (stripos($val[lb_type], ',4,') !== false) $type .= " 积分"; if (stripos($val[lb_type], ',5,') !== false) $type .= " 成长值"; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; } } $strTable .= '
序号礼包名称礼包类型会员昵称手机号购买时间
 ' . ($k + 1) . '' . $val['lbtitle'] . ' ' . $type . '' . $val['nickname'] . ' ' . $val['mobile'] . ' ' . date("Y-m-d H:i:s", $val['addtime']) . '
'; echo $strTable; unset($redmoneylist); downloadExcel($strTable, '购买礼包记录'); exit(); } public function details() { //echo "1"; exit; $lbvipid = I('id'); //礼包购买数量 $by = M('marketing_user_buyreceive_form') ->alias('a') ->where('a.id=' . $lbvipid) ->find(); //礼包 $libao = M("marketing_libao_form")->where("id", $by['lb_id'])->find(); $list = M('marketing_libao_list')->where("lbid", $by['lb_id'])->order("lbtype")->select(); foreach ($list as $k => $v) { //$libao['lbtype']=$v['lbtype']; if ($v['lbtype'] == 1) { $g = M("goods")->where("goods_id", $v['fromid'])->find(); $list[$k]['goods_sn'] = $g['goods_sn']; $list[$k]['goods_name'] = $g['goods_name']; $list[$k]['goods_code'] = $g['sku']; $list[$k]['pos_price'] = $g['market_price']; } if ($v['lbtype'] == 2) { $g = M("coupon")->where("id", $v['fromid'])->find(); $list[$k]['name'] = $g['name']; $list[$k]['use_start_time'] = date("Y-m-d", $g['use_start_time']); $list[$k]['use_end_time'] = date("Y-m-d", $g['use_end_time']); $list[$k]['money'] = $g['money']; $list[$k]['condition'] = $g['condition']; switch ($g['type']) { case 1: $list[$k]['type'] = '免费发放'; break; case 2: $list[$k]['type'] = '注册发放'; break; case 3: $list[$k]['type'] = '邀请发放'; break; case 5: $list[$k]['type'] = '优惠活动'; break; case 6: $list[$k]['type'] = '包邮券'; $list[$k]['money'] = "无"; break; case 7: $list[$k]['type'] = '会员权益'; break; case 8: $list[$k]['type'] = '新人专享'; break; case 9: $list[$k]['type'] = 'PLUS专享'; break; default: break; } } } $this->assign('lbtype', $libao['lbtype']); $this->assign('isget', $by['pay_state']); $this->assign('list', $list); return $this->fetch('', getAdmStoId()); } /*--渲染优惠券--*/ 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'); $w = " and ((endtype=0 and (use_end_time>" . time() . " or use_end_time=0)) or endtype=1)"; $w .= " and send_end_time>" . time(); if ($cptype) { $where['type'] = array('=', $cptype); } $count = M('coupon')->where($where)->where('(type=5 or type=6) ' . $w)->count(); $Page = new Page($count, 10); $show = $Page->show(); $data = M('coupon')->where($where)->where('(type=5 or type=6) ' . $w) ->order('add_time desc')->limit($Page->firstRow . ',' . $Page->listRows)->select(); mlog(json_encode($data, true) . ' 记录数:' . $count . '页面:' . $Page->firstRow . ',' . $Page->listRows . ' 条件:' . json_encode($where), "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 5: $data[$k]['type'] = '优惠活动'; break; case 6: $data[$k]['type'] = '包邮券'; $data[$k]['money'] = '无'; break; default: break; } } return json(['code' => 1, "data" => $data, 'msg' => '数据获取成功', 'count' => $count]); } else { return json(["code" => -1, "msg" => "未找到您要搜索的优惠券"]); } } }