fetch('', getAdmStoId()); } //订单活动到期,更新活动状态 public function updateprom_order() { $time = time(); M('prom_order')->where(array('store_id' => getAdmStoId(), 'is_end' => 0, 'end_time' => ['<', $time]))->save(array('is_end' => 1)); } //订单活动历史 public function prom_order_history() { $parse_type = array('0' => '直接打折', '1' => '减价优惠', '2' => '满额送积分', '3' => '满额送优惠券'); /*--更新活动状态--*/ $this->updateprom_order(); //获取优惠券列表 $pagenum = 10;//每页显示多少条 if ((int)I('pagenum/s') > 0) { $pagenum = I('pagenum/d'); } $key = urldecode(urldecode(I('actname/s'))); $condition = 'store_id=' . getAdmStoId() . ' and is_end=1 and is_show=1 '; if (!empty($key)) { $condition .= 'and name like "%' . $key . '%"'; } $prom_type = I('prom_type'); if ($prom_type != "") { $condition .= ' and type=' . $prom_type; } $count = M('prom_order')->where($condition)->count(); $Page = new Page($count, $pagenum); $show = $Page->show(); $list = M('prom_order')->where($condition)->limit($Page->firstRow . ',' . $Page->listRows)->order('id desc')->select(); $this->assign([ 'key' => $key, 'pager' => $Page, 'page' => $show, 'pagenum' => $pagenum, 'list' => $list ]); $this->assign('parse_type', $parse_type); // upload_ylp_log('历史搭配促销'); return $this->fetch('', getAdmStoId()); } //抢到记录 public function flash_sale_orderlist() { $pagenum = 20;//每页显示多少条 if ((int)I('pagenum/s') > 0) { $pagenum = I('pagenum/s'); } $p = I('p', 1); $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');//手机号码 $flashsaleid = I('flashsaleid');//ID $picksle = urldecode(urldecode(trim(I('picksle')))); $pstype = I('picksle_type'); $getisend = I('isend'); $where = " a.store_id=" . getAdmStoId(); $where .= " and a.prom_type=1 and a.prom_id=" . $flashsaleid; if (!empty($mobile)) { $where .= " and c.mobile='" . $mobile . "' "; } if (!empty($order_sn)) { $where .= " and b.order_sn='" . $order_sn . "' "; } if ($picksle) { if ($pstype) $where .= " AND d.pickup_name='" . $picksle . "'"; else $where .= " AND d.pickup_no='" . $picksle . "'"; } if ($begin) { $where .= " and b.add_time>=" . strtotime($begin); } if ($end) { $where .= " and b.add_time<=" . strtotime($end); } $order_status = I('order_status'); if ($order_status != "") { switch ($order_status) { case 12: //待付款 $condition['b.order_status'] = 0; $condition['b.pay_status'] = 0; break; case 1: //待发货 $condition['b.pay_status'] = 1; $condition['b.order_status'] = ['in', '0,1']; $condition['b.shipping_status'] = 0; break; case 11: //待收货 $condition['b.order_status'] = 1; I('shipping_status') != '' ? $condition['b.shipping_status'] = I('shipping_status') : $condition['shipping_status'] = ['in', '1,2']; //是否发货 break; case 2: //已收货 $condition['b.order_status'] = 2; break; case 3: //已取消 $condition['b.order_status'] = I('order_status'); break; case 4: //已完成 $condition['b.order_status'] = I('order_status'); break; case 5: //已作废 $condition['b.order_status'] = I('order_status'); break; case 6: //已作废 $condition['b.order_status'] = I('order_status'); break; case 13: //已付款 $condition['b.pay_status'] = 1; break; } } $qdrecord = M('order_goods'); $count = $qdrecord->alias('a') ->join('order b', ' a.order_id=b.order_id', 'left') ->join('(select nickname,mobile,user_id from wxd_users where store_id=' . getAdmStoId() . ') c', ' b.user_id=c.user_id', 'left') ->join('(select pickup_id,pickup_name,pickup_no from wxd_pick_up where store_id=' . getAdmStoId() . ') d', 'd.pickup_id=b.pickup_id', 'left') ->where($where) ->where($condition) ->count(); $sumcount = $qdrecord->alias('a') ->join('order b', ' a.order_id=b.order_id', 'left') ->join('(select nickname,mobile,user_id from wxd_users where store_id=' . getAdmStoId() . ') c', ' b.user_id=c.user_id', 'left') ->join('(select pickup_id,pickup_name,pickup_no from wxd_pick_up where store_id=' . getAdmStoId() . ') d', 'd.pickup_id=b.pickup_id', 'left') ->where($where) ->where($condition) ->sum('a.goods_num'); $Page = $pager = new Page($count, $pagenum);// 实例化分页类 传入总记录数和每页显示的记录数 $redmoneylist = $qdrecord->alias('a') ->join('order b', ' a.order_id=b.order_id', 'left') ->join('(select nickname,mobile,user_id from wxd_users where store_id=' . getAdmStoId() . ') c', 'b.user_id=c.user_id', 'left') ->join('(select pickup_id,pickup_name,pickup_no from wxd_pick_up where store_id=' . getAdmStoId() . ') d', 'd.pickup_id=b.pickup_id', 'left') ->where($where) ->where($condition) ->limit($Page->firstRow . ',' . $Page->listRows) ->order('b.add_time desc') ->field('d.pickup_name,d.pickup_no,b.order_id,c.mobile,c.nickname,b.order_sn,a.goods_num,a.goods_name,b.add_time,b.order_status,b.pay_status,b.shipping_status,b.pay_sn,b.pay_time') ->select();// 查询满足要求的总记录数 foreach ($redmoneylist as $kk => $vv) { $order_status_arr = C('ORDER_STATUS_DESC'); $order_status_code = orderStatusDesc(0, $vv); // 订单状态显示给用户看的 $redmoneylist[$kk]['order_status_desc'] = $order_status_arr[$order_status_code]; } if ($p == 1 && $getisend == 1) { $falshinfo = M('flash_sale')->where(array('store_id' => getAdmStoId(), 'id' => $flashsaleid, 'is_end' => 1))->find(); if ($falshinfo) { if ($falshinfo['buy_num'] != $sumcount) { $updatedata['buy_num'] = $sumcount; } if ($falshinfo['order_num'] != $count) { $updatedata['order_num'] = $count; } if ($updatedata) { M('flash_sale')->where(array('store_id' => getAdmStoId(), 'id' => $flashsaleid, 'is_end' => 1))->save($updatedata); } } } $show = $Page->show(); $this->assign('page', $show); $this->assign('sumcount', $sumcount); $this->assign('total', $count); $this->assign('flashsaleid', $flashsaleid); $this->assign('order_sn', $order_sn); $this->assign('picksle', $picksle); $this->assign('pstype', $pstype); $this->assign('getorder_status', $order_status); $this->assign('mobile', $mobile); $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_sale_orderlist() { $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');//手机号码 $flashsaleid = I('flashsaleid');//ID $picksle = trim(I('picksle')); $pstype = I('picksle_type'); $getisend = I('isend'); $where = " a.store_id=" . getAdmStoId(); $where .= " and a.prom_type=1 and a.prom_id=" . $flashsaleid; if (!empty($mobile)) { $where .= " and c.mobile='" . $mobile . "' "; } if (!empty($order_sn)) { $where .= " and b.order_sn='" . $order_sn . "' "; } if ($picksle) { if ($pstype) $where .= " AND d.pickup_name='" . $picksle . "'"; else $where .= " AND d.pickup_no='" . $picksle . "'"; } if ($begin) { $where .= " and b.add_time>=" . strtotime($begin); } if ($end) { $where .= " and b.add_time<=" . strtotime($end); } $order_status = I('order_status'); if ($order_status != "") { switch ($order_status) { case 12: //待付款 $condition['b.order_status'] = 0; $condition['b.pay_status'] = 0; break; case 1: //待发货 $condition['b.pay_status'] = 1; $condition['b.order_status'] = ['in', '0,1']; $condition['b.shipping_status'] = 0; break; case 11: //待收货 $condition['b.order_status'] = 1; I('shipping_status') != '' ? $condition['b.shipping_status'] = I('shipping_status') : $condition['shipping_status'] = ['in', '1,2']; //是否发货 break; case 2: //已收货 $condition['b.order_status'] = 2; break; case 3: //已取消 $condition['b.order_status'] = I('order_status'); break; case 4: //已完成 $condition['b.order_status'] = I('order_status'); break; case 5: //已作废 $condition['b.order_status'] = I('order_status'); break; case 6: //已作废 $condition['b.order_status'] = I('order_status'); break; case 13: //已付款 $condition['b.pay_status'] = 1; break; } } $qdrecord = M('order_goods'); $redmoneylist = $qdrecord->alias('a') ->join('order b', ' a.order_id=b.order_id', 'left') ->join('(select nickname,mobile,user_id from wxd_users where store_id=' . getAdmStoId() . ') c', 'b.user_id=c.user_id', 'left') ->join('(select pickup_id,pickup_name,pickup_no from wxd_pick_up where store_id=' . getAdmStoId() . ') d', 'd.pickup_id=b.pickup_id', 'left') ->where($where) ->where($condition) ->order('b.add_time desc') ->field('d.pickup_name,d.pickup_no,b.order_id,c.mobile,c.nickname,b.order_sn,a.goods_num,a.goods_name,b.add_time,b.order_status,b.pay_status,b.shipping_status,b.pay_sn,b.pay_time') ->select();// 查询满足要求的总记录数 foreach ($redmoneylist as $kk => $vv) { $order_status_arr = C('ORDER_STATUS_DESC'); $order_status_code = orderStatusDesc(0, $vv); // 订单状态显示给用户看的 $redmoneylist[$kk]['order_status_desc'] = $order_status_arr[$order_status_code]; } $strTable = ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; if (is_array($redmoneylist)) { foreach ($redmoneylist as $k => $val) { $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; } } $strTable .= '
订单号会员昵称手机号门店名称购买数量购买时间状态
 ' . $val['order_sn'] . '' . $val['nickname'] . ' ' . $val['mobile'] . '' . $val['pickup_name'] . ' ' . $val['goods_num'] . ' ' . date("Y-m-d H:i:s", $val['add_time']) . '' . $val['order_status_desc'] . '
'; echo $strTable; unset($redmoneylist); downloadExcel($strTable, '秒杀订单'); exit(); } //秒杀记录门店汇总 public function flash_sale_storecount() { $pagenum = 20;//每页显示多少条 if ((int)I('pagenum/s') > 0) { $pagenum = I('pagenum/s'); } $p = I('p', 1); $begin = I('add_time_begin'); $end = I('add_time_end'); $getisend = I('isend'); $this->assign('start_time', $begin); $this->assign('end_time', $end); $flashsaleid = I('flashsaleid');//ID $picksle = trim(I('picksle')); $pstype = I('picksle_type'); $where = " a.store_id=" . getAdmStoId(); $where .= " and a.prom_type=1 and a.prom_id=" . $flashsaleid; if ($picksle) { if ($pstype) $where .= " AND c.pickup_name='" . $picksle . "'"; else $where .= " AND c.pickup_no='" . $picksle . "'"; } if ($begin) { $where .= " and b.add_time>=" . strtotime($begin); } if ($end) { $where .= " and b.add_time<=" . strtotime($end); } $order_status = I('order_status'); if ($order_status != "") { switch ($order_status) { case 12: //待付款 $condition['b.order_status'] = 0; $condition['b.pay_status'] = 0; break; case 1: //待发货 $condition['b.pay_status'] = 1; $condition['b.order_status'] = ['in', '0,1']; $condition['b.shipping_status'] = 0; break; case 11: //待收货 $condition['b.order_status'] = 1; I('shipping_status') != '' ? $condition['b.shipping_status'] = I('shipping_status') : $condition['shipping_status'] = ['in', '1,2']; //是否发货 break; case 2: //已收货 $condition['b.order_status'] = 2; break; case 3: //已取消 $condition['b.order_status'] = I('order_status'); break; case 4: //已完成 $condition['b.order_status'] = I('order_status'); break; case 5: //已作废 $condition['b.order_status'] = I('order_status'); break; case 6: //已作废 $condition['b.order_status'] = I('order_status'); break; case 13: //已付款 $condition['b.pay_status'] = 1; break; } } $qdrecord = M('order_goods'); $count = $qdrecord->alias('a') ->join('order b', ' a.order_id=b.order_id', 'left') ->join('(select pickup_id,pickup_name,pickup_no from wxd_pick_up where store_id=' . getAdmStoId() . ') c', 'c.pickup_id=b.pickup_id', 'left') ->where($where) ->where($condition) ->count('distinct b.pickup_id'); $sumcount = $qdrecord->alias('a') ->join('order b', ' a.order_id=b.order_id', 'left') ->join('(select pickup_id,pickup_name,pickup_no from wxd_pick_up where store_id=' . getAdmStoId() . ') c', 'c.pickup_id=b.pickup_id', 'left') ->where($where) ->where($condition) ->sum('a.goods_num'); $Page = $pager = new Page($count, $pagenum);// 实例化分页类 传入总记录数和每页显示的记录数 $redmoneylist = $qdrecord->alias('a') ->join('order b', ' a.order_id=b.order_id', 'left') ->join('(select pickup_id,pickup_name,pickup_no from wxd_pick_up where store_id=' . getAdmStoId() . ') c', 'c.pickup_id=b.pickup_id', 'left') ->where($where) ->where($condition) ->limit($Page->firstRow . ',' . $Page->listRows) ->order('c.pickup_no asc') ->field('count(b.order_id) as ordernum,sum(a.goods_num) as warenum,b.pickup_id,c.pickup_name,c.pickup_no,sum(a.goods_num*a.goods_price) as goods_total_amount,sum(b.total_amount)all_total_amount,sum(order_amount+user_money)all_order_amount') ->group('b.pickup_id') ->select();// 查询满足要求的总记录数 if ($p == 1 && $getisend == 1) { $falshinfo = M('flash_sale')->where(array('store_id' => getAdmStoId(), 'id' => $flashsaleid, 'is_end' => 1))->find(); if ($falshinfo) { if ($falshinfo['buy_num'] != $sumcount) { $updatedata['buy_num'] = $sumcount; } if ($falshinfo['order_num'] != $count) { $updatedata['order_num'] = $count; } if ($updatedata) { M('flash_sale')->where(array('store_id' => getAdmStoId(), 'id' => $flashsaleid, 'is_end' => 1))->save($updatedata); } } } $show = $Page->show(); $this->assign('page', $show); $this->assign('sumcount', $sumcount); $this->assign('total', $count); $this->assign('flashsaleid', $flashsaleid); $this->assign('picksle', $picksle); $this->assign('pstype', $pstype); $this->assign('getorder_status', $order_status); $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_storecount() { $begin = I('add_time_begin'); $end = I('add_time_end'); $getisend = I('isend'); $this->assign('start_time', $begin); $this->assign('end_time', $end); $flashsaleid = I('flashsaleid');//ID $picksle = trim(I('picksle')); $pstype = I('picksle_type'); $where = " a.store_id=" . getAdmStoId(); $where .= " and a.prom_type=1 and a.prom_id=" . $flashsaleid; if ($picksle) { if ($pstype) $where .= " AND c.pickup_name='" . $picksle . "'"; else $where .= " AND c.pickup_no='" . $picksle . "'"; } if ($begin) { $where .= " and b.add_time>=" . strtotime($begin); } if ($end) { $where .= " and b.add_time<=" . strtotime($end); } $order_status = I('order_status'); if ($order_status != "") { switch ($order_status) { case 12: //待付款 $condition['b.order_status'] = 0; $condition['b.pay_status'] = 0; break; case 1: //待发货 $condition['b.pay_status'] = 1; $condition['b.order_status'] = ['in', '0,1']; $condition['b.shipping_status'] = 0; break; case 11: //待收货 $condition['b.order_status'] = 1; I('shipping_status') != '' ? $condition['b.shipping_status'] = I('shipping_status') : $condition['shipping_status'] = ['in', '1,2']; //是否发货 break; case 2: //已收货 $condition['b.order_status'] = 2; break; case 3: //已取消 $condition['b.order_status'] = I('order_status'); break; case 4: //已完成 $condition['b.order_status'] = I('order_status'); break; case 5: //已作废 $condition['b.order_status'] = I('order_status'); break; case 6: //已作废 $condition['b.order_status'] = I('order_status'); break; case 13: //已付款 $condition['b.pay_status'] = 1; break; } } $qdrecord = M('order_goods'); $redmoneylist = $qdrecord->alias('a') ->join('order b', ' a.order_id=b.order_id', 'left') ->join('(select pickup_id,pickup_name,pickup_no from wxd_pick_up where store_id=' . getAdmStoId() . ') c', 'c.pickup_id=b.pickup_id', 'left') ->where($where) ->where($condition) ->order('c.pickup_no asc') ->field('count(b.order_id) as ordernum,sum(a.goods_num) as warenum,b.pickup_id,c.pickup_name,c.pickup_no,sum(a.goods_num*a.goods_price) as goods_total_amount,sum(b.total_amount)all_total_amount,sum(order_amount+user_money)all_order_amount') ->group('b.pickup_id') ->select();// 查询满足要求的总记录数 $strTable = ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; if (is_array($redmoneylist)) { foreach ($redmoneylist as $k => $val) { $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; } } $strTable .= '
门店编号门店名称订单数(笔)购买总数(件)应收总金额
 ' . $val['pickup_no'] . '' . $val['pickup_name'] . ' ' . $val['ordernum'] . '' . $val['warenum'] . ' ' . $val['goods_total_amount'] . '
'; echo $strTable; unset($redmoneylist); downloadExcel($strTable, '秒杀门店汇总'); exit(); } /*--历史订单删除--*/ public function prom_order_history_del() { $id = I('del_id'); if ($id) { $data['is_show'] = 0; $admid = getAdminId(); $amdinfo = getAdminInfo($admid); $data['edit_man'] = $amdinfo['ERPName']; $data['edit_time'] = time(); $data['edit_ip'] = getIP(); M('prom_order')->where("id", $id)->where('store_id', getAdmStoId())->save($data); ClearALLCache(); delFile(TEMP_PATH . "/" . getAdmStoId()); // upload_ylp_log('历史删除'); exit(json_encode(1)); } else { exit(json_encode(0)); } } /** * 商品活动列表 */ public function prom_goods_list() { /*--更新活动状态--*/ $this->updategoodstype(3); //获取优惠券列表 $pagenum = 10;//每页显示多少条 if ((int)I('pagenum/s') > 0) { $pagenum = I('pagenum/d'); } $key = urldecode(urldecode(I('key/s'))); $type = I('type/d'); $time = time(); $condition['store_id'] = getAdmStoId(); if (!empty($key)) { $condition['name'] = array('like', "%$key%"); } if ($type == 1) { $condition['start_time'] = ['>', $time]; } if ($type == 2) { $condition['start_time'] = ['<', $time]; } $condition['is_end'] = 0; $count = M('prom_goods')->where($condition)->count(); $Page = new Page($count, $pagenum); $show = $Page->show(); $res = M('prom_goods')->where($condition)->limit($Page->firstRow . ',' . $Page->listRows)->order('id desc')->select(); if (!empty($res)) { foreach ($res as $k => $val) { if ($val['start_time'] > $time) { $res[$k]['is_end'] = 1; } } } $this->assign('key', $key); $this->assign('type', $type); $this->assign('pager', $Page); $this->assign('page', $show);// 赋值分页输出 $this->assign('pagenum', $pagenum); $this->assign('prom_list', $res); // upload_ylp_log('优惠促销'); return $this->fetch('', getAdmStoId()); } // 优惠促销增加,编辑 public function prom_goods_info() { $prom_id = I('id', '0'); $store_id = getAdmStoId(); $time = time(); $info['start_time'] = date('Y-m-d H:i:s'); $info['end_time'] = date('Y-m-d H:i:s', time() + 3600 * 60 * 24); $coupon = M('coupon')->where(['store_id' => $store_id, 'send_end_time' => ['gt', $time], 'type' => 5])->select(); $gift = M('gift')->where(['store_id' => $store_id, 'is_end' => 0])->select(); $libao = M('libao_form')->where(['store_id' => $store_id, 'isdel' => 0, 'startime' => ['lt', $time], 'endtime' => ['gt', $time]])->select(); //全场活动的开始时间 $now = time(); $wh = " store_id=" . $store_id . " and is_end=0 and prom_type=3 " . " and e_time>" . $now . " and good_object=0"; $wh .= " and act_id<>" . $prom_id; $fu = M("activitylist")->where($wh)->field('id,goods_listid,s_time,e_time')->find(); if ($fu) { $this->assign('quan_s_time', date('Y-m-d H:i:s', $fu['s_time'])); $this->assign('quan_e_time', date('Y-m-d H:i:s', $fu['e_time'])); } //其他所有活动的结束时间,开始时间 $wh1 = " store_id=" . $store_id . " and is_end=0" . " and end_time>" . $now; $wh1 .= " and id<>" . $prom_id; $max = M("prom_goods")->where($wh1)->max('end_time'); $min = M("prom_goods")->where($wh1)->min('start_time'); if ($max) $this->assign('zhiding_e_time', date('Y-m-d H:i:s', $max)); if ($min) $this->assign('zhiding_s_time', date('Y-m-d H:i:s', $min)); //是否有全场的,包括指定商品不参与 if (empty($prom_id)) { if ($fu) { if ($fu['s_time'] < $now) { $this->assign('isfull', 1); if (empty($fu['goods_listid'])) $this->assign('isall', 1); } else { $this->assign('goods_listid', $fu['goods_listid']); } } } if ($prom_id > 0) { //是否有全场的,包括指定商品不参与 if ($fu) { if ($fu['s_time'] < $now) { $this->assign('isfull', 1); if (empty($fu['goods_listid'])) $this->assign('isall', 1); } else { $this->assign('goods_listid', $fu['goods_listid']); } } $is_full = 'false'; $info = M('prom_goods')->where(['store_id' => $store_id, 'id' => $prom_id])->find(); $info['start_time'] = date('Y-m-d H:i:s', $info['start_time']); $info['end_time'] = date('Y-m-d H:i:s', $info['end_time']); $list = M('prom_goods_list')->where('prom_id', $prom_id)->select(); foreach ($list as $k => $v) { $list[$k]['preferential_type'] = json_decode($v['preferential_type'], true); } $this->assign('list', $list); // $prom_goods = M('goods')->where("prom_id=$prom_id and prom_type=3")->select(); $activitylist = M('activitylist')->where("act_id=$prom_id and prom_type=3")->field('goods_listid')->find(); if ($activitylist) { $prom_goods = M('goods')->where("goods_id", array('in', '0' . $activitylist['goods_listid'] . '0'))->order('goods_id DESC')->select(); } $this->assign('prom_goods', $prom_goods); } $tpl = I('tpl', ''); $this->assign([ 'coupon' => $coupon, 'info' => $info, 'gift' => $gift, 'tpl' => $tpl, 'libao' => $libao, ]); return $this->fetch('', getAdmStoId()); } public function prom_goods_info2() { $level = M('user_level')->where(" store_id=" . getAdmStoId() . " ")->select(); $this->assign('level', $level); $prom_id = I('id'); $info['start_time'] = date('Y-m-d H:i:s'); $info['end_time'] = date('Y-m-d H:i:s', time() + 3600 * 60 * 24); if ($prom_id > 0) { $info = M('prom_goods')->where(" store_id=" . getAdmStoId() . " and id=$prom_id")->find(); $info['start_time'] = date('Y-m-d H:i:s', $info['start_time']); $info['end_time'] = date('Y-m-d H:i:s', $info['end_time']); $gsid = M('activitylist')->where('prom_type=3 and act_id=' . $prom_id)->field('goods_listid')->find(); $gsidarr = explode(',', $gsid['goods_listid']); $prom_goods = M('goods')->where('goods_id', 'in', $gsidarr)->select(); $this->assign('prom_goods', $prom_goods); } $sql = "select * from __PREFIX__coupon where type=0 and store_id=" . getAdmStoId(); $rdata = Db::query($sql); $this->assign('sql', $rdata); $this->assign('info', $info); $this->assign('isout', 1); $this->assign('min_date', date('Y-m-d')); $this->initEditor(); // upload_ylp_log('查看'); return $this->fetch('', getAdmStoId()); } public function prom_goods_save() { ClearALLCache(); delFile(TEMP_PATH . "/" . getAdmStoId()); $prom_id = I('id'); $data = I('post.'); $data_list = $data['data']; unset($data['data']); $type = $data['prom_type']; unset($data['prom_type']); $data['start_time'] = strtotime($data['start_time']); $data['end_time'] = strtotime($data['end_time']); $data['store_id'] = getAdmStoId(); $admid = getAdminId(); $amdinfo = getAdminInfo($admid); $data['edit_man'] = $amdinfo['ERPName']; $good_list = ''; if ($data['goods_id']) $good_list = implode(',', $data['goods_id']); if ($prom_id > 0) { M("goods")->where("prom_id=$prom_id and prom_type=3")->save(array('prom_id' => 0, 'prom_type' => 0)); } // if ($data['end_time'] <= $data['start_time']) { // $this->error('结束时间必须大于结束时间'); // } // if ($data['expression'] <= 0) { // $this->error('优惠必须大于0'); // } /*---操作活动总表---*/ $adata['edit_man'] = $amdinfo['ERPName']; $adata['prom_type'] = 3; if ($good_list) $adata['goods_listid'] = ',' . $good_list . ','; else $adata['goods_listid'] = ''; $adata['is_show'] = 1; $adata['is_end'] = 0; $adata['warm_uptime'] = 0; $adata['s_time'] = $data['start_time']; $adata['e_time'] = $data['end_time']; $adata['prom_integral'] = 0; $adata['store_id'] = getAdmStoId(); $adata['good_object'] = $data['good_object']; if ($prom_id > 0) { $data['edit_time'] = time(); $data['edit_ip'] = getIP(); M('prom_goods')->where(" store_id=" . getAdmStoId() . " and id=$prom_id")->save($data); // upload_ylp_log('修改了商品促销'); adminLog("管理员修改了商品促销 " . I('name')); $adata['edit_time'] = $data['edit_time']; $adata['edit_man'] = $data['edit_man']; $adata['edit_ip'] = $data['edit_ip']; M('activitylist')->where('act_id', $prom_id)->where('prom_type', 3)->save($adata); foreach ($data_list as $v) { $id = $v['id']; unset($v['id']); $condition = $v['condition']; unset($v['condition']); if ($v['coupon'] == 0 || $v['is_coupon'] == 0) { $v['coupon'] = $v['is_coupon'] = 0; } if ($v['money'] == 0 || $v['is_money'] == 0) { $v['money'] = $v['is_money'] = 0; } if ($v['sale'] == 0 || $v['is_sale'] == 0) { $v['sale'] = $v['is_sale'] = 0; } if ($v['int'] == 0 || $v['is_int'] == 0) { $v['int'] = $v['is_int'] = 0; } if ($v['gift'] == 0 || $v['is_gift'] == 0) { $v['gift'] = $v['is_gift'] = 0; } $json = json_encode($v); if ($id > 0) { M('prom_goods_list')->where(['id' => $id, 'prom_id' => $prom_id])->save(['prom_type' => $type, 'condition' => $condition, 'preferential_type' => $json, 'edit_man' => $amdinfo['ERPName'], 'edit_ip' => getIP(), 'edit_time' => time()]); } else { M('prom_goods_list')->save(['prom_id' => $prom_id, 'prom_type' => $type, 'add_time' => time(), 'edit_man' => $amdinfo['ERPName'], 'preferential_type' => $json, 'condition' => $condition]); } } upload_ylp_log('B22优惠促销编辑/确认提交'); } else { unset($data['id']); $data['add_time'] = time(); $data['add_ip'] = getIP(); $prom_id = M('prom_goods')->add($data); // upload_ylp_log('添加了商品促销'); adminLog("管理员添加了商品促销 " . I('name')); $adata['add_time'] = time(); $adata['add_ip'] = getIP(); $adata['act_id'] = $prom_id; M('activitylist')->save($adata); foreach ($data_list as $v) { unset($v['id']); $condition = $v['condition']; unset($v['condition']); if ($v['coupon'] == 0 || $v['is_coupon'] == 0) { $v['coupon'] = $v['is_coupon'] = 0; } if ($v['money'] == 0 || $v['is_money'] == 0) { $v['money'] = $v['is_money'] = 0; } if ($v['sale'] == 0 || $v['is_sale'] == 0) { $v['sale'] = $v['is_sale'] = 0; } if ($v['int'] == 0 || $v['is_int'] == 0) { $v['int'] = $v['is_int'] = 0; } if ($v['gift'] == 0 || $v['is_gift'] == 0) { $v['gift'] = $v['is_gift'] = 0; } $json = json_encode($v); /*--优惠促销从表--*/ $bdata[] = ['prom_id' => $prom_id, 'prom_type' => $type, 'add_time' => time(), 'edit_man' => $amdinfo['ERPName'], 'preferential_type' => $json, 'condition' => $condition]; } M('prom_goods_list')->insertAll($bdata); } if (!empty($good_list)) { if ($data['good_object'] == 1) { M("goods")->where("goods_id in($good_list)")->save(array('prom_id' => $prom_id, 'prom_type' => 3)); } } $this->success('编辑促销活动成功', U('Promotion/prom_goods_list')); } public function prom_goods_del() { $prom_id = I('id/d'); Db::startTrans(); try { $admid = getAdminId(); $amdinfo = getAdminInfo($admid); $data['edit_man'] = $amdinfo['ERPName']; $data['edit_time'] = time(); $data['edit_ip'] = getIP(); $data['is_end'] = 1; $adata['edit_time'] = $data['edit_time']; $adata['edit_man'] = $data['edit_man']; $adata['edit_ip'] = $data['edit_ip']; $adata['is_end'] = 1; M('activitylist')->where(['act_id' => $prom_id, 'prom_type' => 3])->save($adata); /*--- $order_goods = M('order_goods')->where(" store_id=".getAdmStoId()." and prom_type = 3 and prom_id = $prom_id")->find(); if (!empty($order_goods)) { $this->error("该活动有订单参与不能删除!"); } ----*/ M("goods")->where("store_id=" . getAdmStoId() . " and prom_id=$prom_id and prom_type=3")->save(array('prom_id' => 0, 'prom_type' => 0)); // upload_ylp_log('删除商品促销活动'); M('prom_goods')->where("store_id=" . getAdmStoId() . " and id=$prom_id")->save($data); Db::commit(); } catch (\Exception $e) { Db::rollback(); exit(json_encode(0)); } ClearALLCache(); delFile(TEMP_PATH . "/" . getAdmStoId()); $this->success('删除活动成功', U('Promotion/prom_goods_list')); } /** * 活动列表 */ public function prom_order_list() { $this->updateprom_order(); //获取优惠券列表 $pagenum = 10;//每页显示多少条 if ((int)I('pagenum/s') > 0) { $pagenum = I('pagenum/s'); } $actname = I('actname'); $prom_type = I('prom_type'); $parse_type = array('0' => '直接打折', '1' => '减价优惠', '2' => '满额送积分', '3' => '满额送优惠券'); $level = M('user_level')->where(" store_id=" . getAdmStoId() . " ")->select(); if ($level) { foreach ($level as $v) { $lv[$v['level_id']] = $v['level_name']; } } $condition['store_id'] = getAdmStoId(); $condition['is_end'] = 0; if (!empty($actname)) { $condition['name'] = array('like', "%$actname%"); } if ($prom_type != "") { $condition['type'] = array('like', "%$prom_type%"); } $count = M('prom_order')->where($condition)->count(); $Page = new Page($count, $pagenum); $show = $Page->show(); $res = M('prom_order')->where($condition)->limit($Page->firstRow . ',' . $Page->listRows)->select(); if ($res) { foreach ($res as $val) { if (!empty($val['group']) && !empty($lv)) { $val['group'] = explode(',', $val['group']); foreach ($val['group'] as $v) { $val['group_name'] .= $lv[$v] . ','; } } $prom_list[] = $val; } } $this->assign('pager', $Page);// 赋值分页输出 $this->assign('page', $show);// 赋值分页输出 $this->assign("parse_type", $parse_type); $this->assign('prom_list', $prom_list); $this->assign('pagenum', $pagenum); $this->assign('prom_type', $prom_type); // upload_ylp_log('订单促销'); return $this->fetch('', getAdmStoId()); } public function prom_order_info() { $this->assign('min_date', date('Y-m-d H:i:s')); $level = M('user_level')->where(" store_id=" . getAdmStoId() . " ")->select(); $this->assign('level', $level); $prom_id = I('id'); $info['start_time'] = date('Y-m-d H:i:s'); $info['end_time'] = date('Y-m-d H:i:s', time() + 3600 * 24 * 60); if ($prom_id > 0) { $info = M('prom_order')->where(" store_id=" . getAdmStoId() . " and id=$prom_id")->find(); $info['start_time'] = date('Y-m-d H:i:s', $info['start_time']); $info['end_time'] = date('Y-m-d H:i:s', $info['end_time']); } $this->assign('info', $info); $this->assign('min_date', date('Y-m-d')); $this->initEditor(); return $this->fetch('', getAdmStoId()); } public function prom_order_save() { $prom_id = I('id'); $data = I('post.'); ClearALLCache(); delFile(TEMP_PATH . "/" . getAdmStoId()); $data['start_time'] = strtotime($data['start_time']); $data['end_time'] = strtotime($data['end_time']); if (!empty($data['group'])) { $data['group'] = implode(',', $data['group']); } else { $data['group'] = ""; } $data['store_id'] = getAdmStoId(); if ($data['end_time'] <= $data['start_time']) { $this->error('结束时间必须大于结束时间'); } if ($data['expression'] <= 0) { $this->error('优惠必须大于0'); } if (empty($prom_id)) { $rs = M('prom_order') ->where("is_end=0 and store_id=" . getAdmStoId() . " and end_time>=" . $data['end_time'] . " and start_time<=" . $data['end_time']) ->whereOr("is_end=0 and store_id=" . getAdmStoId() . " and end_time<=" . $data['end_time'] . " and end_time>=" . $data['start_time']) ->select(); if ($rs) { $this->error('该时间段已经有订单活动,先修改时间'); } } else { $rs = M('prom_order') ->where("is_end=0 and id<> " . $prom_id . " and store_id=" . getAdmStoId() . " and end_time>=" . $data['end_time'] . " and start_time<=" . $data['end_time']) ->whereOr("is_end=0 and id<> " . $prom_id . " and store_id=" . getAdmStoId() . " and end_time<=" . $data['end_time'] . " and end_time>=" . $data['start_time']) ->select(); if ($rs) { $this->error('该时间段已经有订单活动,先修改时间'); } } if ($prom_id) { // upload_ylp_log('修改了订单促销'); upload_ylp_log('B23订单促销编辑/确认提交'); $admid = getAdminId(); $amdinfo = getAdminInfo($admid); $data['edit_man'] = $amdinfo['ERPName']; $data['edit_time'] = time(); $data['edit_ip'] = getIP(); M('prom_order')->where(" store_id=" . getAdmStoId() . " and id=$prom_id")->save($data); adminLog("管理员修改了商品促销 " . I('name')); } else { $data['add_time'] = time(); // upload_ylp_log('添加了订单促销'); M('prom_order')->add($data); adminLog("管理员添加了商品促销 " . I('name')); } $this->success('编辑促销活动成功', U('Promotion/prom_order_list')); } public function prom_order_del() { $prom_id = I('id'); /*--- $order = M('order')->where(" store_id=" . getAdmStoId() . " and order_prom_id = $prom_id")->find(); if (!empty($order)) { $this->error("该活动有订单参与不能删除!"); }--*/ Db::startTrans(); try { $admid = getAdminId(); $amdinfo = getAdminInfo($admid); $data['edit_man'] = $amdinfo['ERPName']; $data['edit_time'] = time(); $data['edit_ip'] = getIP(); $data['is_end'] = 1; M('prom_order')->where(" store_id=" . getAdmStoId() . " and id=$prom_id")->save($data); Db::commit(); } catch (\Exception $e) { Db::rollback(); exit(json_encode(0)); } ClearALLCache(); delFile(TEMP_PATH . "/" . getAdmStoId()); $this->success('删除活动成功', U('Promotion/prom_order_list')); } public function group_buy_list() { $this->updategoodstype(2); $pagenum = 10;//每页显示多少条 if ((int)I('pagenum/s') > 0) { $pagenum = I('pagenum/s'); } $actname = I('actname'); $begin = strtotime(I('add_time_begin')); $end = strtotime(I('add_time_end')); if ($begin) { $condition['a.start_time'] = array('egt', $begin); } if ($end) { $condition['a.end_time'] = array('elt', $end); } $condition['a.store_id'] = getAdmStoId(); if (!empty($actname)) { $condition['a.title|c.goods_sn|c.sku'] = array('like', "%$actname%"); } $condition['is_end'] = 0; $count = M('group_buy')->alias('a') ->join('(select goods_id,goods_sn,sku from wxd_goods where store_id='.getAdmStoId().') c',' c.goods_id=a.goods_id','left') ->where($condition)->count(); $Page = new Page($count, $pagenum); $show = $Page->show(); $res = M('group_buy')->alias('a') ->join('(select goods_id,goods_sn,sku from wxd_goods where store_id='.getAdmStoId().') c',' c.goods_id=a.goods_id','left') ->where($condition)->limit($Page->firstRow . ',' . $Page->listRows) ->field('a.*,c.goods_sn,c.sku') ->order('a.ordid asc,a.id desc')->select(); if ($res) { foreach ($res as $val) { $val['start_time'] = date('Y-m-d H:i:s', $val['start_time']); $val['end_time'] = date('Y-m-d H:i:s', $val['end_time']); $list[] = $val; } } $this->assign('list', $list); $show = $Page->show(); $this->assign('page', $show); $this->assign('pager', $Page); $this->assign('pagenum', $pagenum); // upload_ylp_log('团购管理'); return $this->fetch('', getAdmStoId()); } public function group_buy() { $this->updategoodstype(2); $act = I('GET.act', 'add'); $groupbuy_id = I('get.id'); $group_info = array(); $group_info['start_time'] = date('Y-m-d H:i:s'); $group_info['end_time'] = date('Y-m-d H:i:s', time() + 3600 * 365); $group_info['store_id'] = getAdmStoId(); if ($groupbuy_id) { $group_info = D('group_buy')->where(" store_id=" . getAdmStoId() . " and id=" . $groupbuy_id)->find(); //是否开始 $is_start=0; if( $group_info['start_time']assign('is_start', $is_start); $group_info['start_time'] = date('Y-m-d H:i:s', $group_info['start_time']); $group_info['end_time'] = date('Y-m-d H:i:s', $group_info['end_time']); $act = 'edit'; $rt = M("goods")->where(array('store_id'=>getAdmStoId(),'goods_id'=>$group_info['goods_id']))->find(); if ($rt) $this->assign('storecount', $rt['store_count']); } else { $group_info['ordid']=M('group_buy')->where(array('store_id'=>getAdmStoId(),'is_end'=>0))->max('ordid')+1; } $pattern=tpCache('distribut.pattern',getAdmStoId()); $this->assign('pattern', $pattern); $this->assign('min_date', date('Y-m-d')); $this->assign('info', $group_info); $this->assign('act', $act); return $this->fetch('', getAdmStoId()); } public function groupbuyHandle() { $data = I('post.'); ClearALLCache(); delFile(TEMP_PATH . "/" . getAdmStoId()); $data['groupbuy_intro'] = htmlspecialchars(stripslashes($this->request->param('groupbuy_intro'))); $data['start_time'] = strtotime($data['start_time']); $data['end_time'] = strtotime($data['end_time']); if ($data['act'] != 'del') { if ($data['end_time'] <= $data['start_time']) { $this->error('结束时间必须大于结束时间'); } if ($data['price'] <= 0) { $this->error('团购价必须大于0'); } if ($data['price'] >= $data['goods_price']) { $this->error('团购价必须小于商品原价'); } } $admid = getAdminId(); $amdinfo = getAdminInfo($admid); if ($data['act'] == 'del') { $data11['edit_man'] = $amdinfo['ERPName']; $data11['edit_time'] = time(); $data11['edit_ip'] = getIP(); $data11['is_show'] = 1; $data11['is_end'] = 1; $data11['edit_mark'] = "删除团购活动"; // upload_ylp_log('删除团购活动'); $r = D('group_buy')->where('id=' . $data['id'])->save($data11); M('goods')->where("prom_type=2 and prom_id=" . $data['id'])->save(array('prom_id' => 0, 'prom_type' => 0)); $adata['edit_time'] = $data11['edit_time']; $adata['edit_man'] = $data11['edit_man']; $adata['edit_ip'] = $data11['edit_ip']; $adata['is_end'] = 1; M('activitylist')->where('act_id', $data['id'])->where('prom_type=2')->save($adata); /*---删除团购活动缓存---*/ //$redis = new \Redis(); //$redis->connect(redisip, 6379); $redis=get_redis_handle(); //$name='grb'.$data['id'].'-'.getAdmStoId(); //if($redis->exists($name)) $redis->delete($name); $name=get_redis_name($data['id'],2,getAdmStoId()); del_redis($redis,$name); //$namec='grb'.$data['id'].'-'.getAdmStoId().'c'; $namec=$name.':c'; m_clearC($namec); if ($r) exit(json_encode(1)); } if ($data['price'] >= $data['goods_price']) { $this->error('团购价格不能大于或等于原商品价格'); } else { $data['rebate'] = number_format($data['price'] / $data['goods_price'] * 10, 1); } $data['edit_man'] = $amdinfo['ERPName']; $adata['edit_man'] = $amdinfo['ERPName']; /*---操作活动总表---*/ $adata['prom_type'] = 2; $adata['goods_listid'] = "," . $data['goods_id'] . ","; $adata['is_show'] = 1; $adata['is_end'] = 0; $adata['warm_uptime'] = 0; $adata['s_time'] = $data['start_time']; $adata['e_time'] = $data['end_time']; $adata['prom_price'] = $data['price']; $adata['prom_integral'] = 0; $adata['store_id'] = getAdmStoId(); if($data['commission']) $adata['commission'] = $data['commission']; $pattern=tpCache('distribut.pattern',getAdmStoId()); if($pattern==1){ $adata['fir_rate']=$data['fir_rate']; $adata['sec_rate']=$data['sec_rate']; $adata['thi_rate']=$data['thi_rate']; } if ($data['act'] == 'add') { $data['add_time'] = time(); $data['add_ip'] = getIP(); $data['store_id'] = getAdmStoId(); $r = D('group_buy')->add($data); // upload_ylp_log('增加团购活动'); M('goods')->where("goods_id=" . $data['goods_id'])->save(array('prom_id' => $r, 'prom_type' => 2)); $adata['add_time'] = time(); $adata['add_ip'] = getIP(); $adata['act_id'] = $r; M('activitylist')->save($adata); } if ($data['act'] == 'edit') { $rrp = M('group_buy')->where("id=" . $data['id'])->where('store_id',getAdmStoId())->find(); if($rrp){ //活动缓冲人数,当活动还没有开始的时候 if($rrp['buy_num']>= $data['goods_num'] && $rrp['start_time']>time()){ $this->error('活动人数必须大于已售人数'); } } $data['edit_time'] = time(); $data['edit_ip'] = getIP(); $data['is_show'] = 1; $data['edit_mark'] = "编辑团购活动"; // upload_ylp_log('编辑团购活动'); $r = D('group_buy')->where('id=' . $data['id'])->save($data); M('goods')->where("prom_type=2 and prom_id=" . $data['id'])->save(array('prom_id' => 0, 'prom_type' => 0)); M('goods')->where("goods_id=" . $data['goods_id'])->save(array('prom_id' => $data['id'], 'prom_type' => 2)); $adata['edit_time'] = $data['edit_time']; $adata['edit_ip'] = $data['edit_ip']; M('activitylist')->where('act_id', $data['id'])->where('prom_type', 2)->save($adata); /*---设置活动是秒杀销售量,当活动还没有开始的时候---*/ if($rrp['start_time']>time()) { //$redis = new \Redis(); //$redis->connect(redisip, 6379); $redis=get_redis_handle(); //$name = 'grb' . $data['id'] . '-' . getAdmStoId(); $name = get_redis_name($data['id'],2 ,getAdmStoId()); if (empty($len)) { for ($i = 0; $i < ($data['goods_num'] - $rrp['buy_num']); $i++) { $redis->lPush($name, "g" . $i); } } else if ($len != ($data['goods_num'] - $rrp['buy_num'])) { //$redis->delete($name); del_redis($redis,$name); for ($i = 0; $i < ($data['goods_num'] - $rrp['buy_num']); $i++) { $redis->lPush($name, "g" . $i);} } } upload_ylp_log('B21团购管理编辑/确认提交'); } if ($r) { $this->success("操作成功", U('Admin/Promotion/group_buy_list')); } else { $this->error("操作失败", U('Admin/Promotion/group_buy_list')); } } public function get_goods() { $prom_id = I('id'); $count = M('goods')->where("prom_id=$prom_id and prom_type=3")->count(); $Page = new Page($count, 10); $goodsList = M('goods')->where("prom_id=$prom_id and prom_type=3")->order('goods_id DESC')->limit($Page->firstRow . ',' . $Page->listRows)->select(); $show = $Page->show(); $this->assign('page', $show); $this->assign('pager', $Page);//赋值分页输出 $this->assign('goodsList', $goodsList); // upload_ylp_log('商品查看'); return $this->fetch('', getAdmStoId()); } //指定商品不参与 public function search_goods2() { $GoodsLogic = new GoodsLogic; $brandList = $GoodsLogic->getSortBrands(); $this->assign('brandList', $brandList); $categoryList = $GoodsLogic->getSortCategory(); $pagenum = 10;//每页显示多少条 $isnotin=I("isnotin"); $idlist=I('idlist/s'); if ((int)I('pagenum/s') > 0) { $pagenum = I('pagenum/s'); } $this->assign('pagenum', $pagenum); $this->assign('categoryList', $categoryList); $this->assign('idlist',$idlist); $this->assign('dis_type',I('distr_type/d'));//搭配主商品快递类型 $this->assign('main_goods',I('main_goods/d'));//搭配主商品 $this->assign('id', I('prom_id/d')); if($isnotin=="1") return $this->fetch('search_goods3', getAdmStoId()); else return $this->fetch('', getAdmStoId()); } public function ajax_search_goods() { $isnotin=I("notin"); $pagenum = 10;//每页显示多少条 if ((int)I('pagenum/s') > 0) { $pagenum = I('pagenum/s'); } $id = I('id/d'); $prom_id=I('prom_id/d'); if(empty($id)) $id=$prom_id; if($isnotin==1){ $where = 'is_on_sale = 1 and (prom_type=0 or prom_type=3) and store_count>0 and is_mainshow=1 ';//搜索条件 }else { if (empty($id)) { $where = 'is_on_sale = 1 and prom_type=0 and store_count>0 and is_mainshow=1 ';//搜索条件 } else { $where = 'is_on_sale = 1 and store_count>0 and is_mainshow=1 and (prom_type=0 or (prom_type=3 and prom_id=' . $id . '))'; } } if (I('dis_type/d')){ $where = " $where and distr_type in (" . I('dis_type/d') . ")";//搜索条件 } if (I('main_goods/d')){ $this->assign('coll_goods',I('main_goods/d')); $where = " $where and goods_id not in (" . I('main_goods/d') . ")";//搜索条件 } if (I('cat_id')) { // $this->assign('cat_id', I('cat_id')); $grandson_ids = getCatGrandson(I('cat_id')); $where = " $where and cat_id in(" . implode(',', $grandson_ids) . ") "; // 初始化搜索条件 } if (I('brand_id')) { // $this->assign('brand_id', I('brand_id')); $where = "$where and brand_id = " . I('brand_id'); } $kw = I('keywords'); if (!empty($kw)) { $kword = urldecode(urldecode($kw)); // $this->assign('keywords', $kword); $where = "$where and (goods_sn like '%" . $kword . "%' or goods_name like '%" . $kword . "%' or keywords like '%" . $kword . "%' or sku = '" . $kw . "')"; } //指定商品不参与 if($isnotin==1){} //指定商品参与 else{ if($isnotin==2) { //查看本活动是不是保存成了全场活动,如果是,在更换的指定是,不受限全场活动 $time = time(); $wh2 = "prom_type=3 and s_time<" . $time . " and e_time>" . $time . " and is_end=0 and good_object=0 and store_id=" . getAdmStoId(); $act2 = M("activitylist")->where($wh2)->where('act_id', $id)->find(); if (empty($act2)) { $wh = "prom_type=3 and s_time<" . $time . " and e_time>" . $time . " and is_end=0 and good_object=0 and store_id=" . getAdmStoId(); $act = M("activitylist")->where($wh)->find(); if ($act) { if ($act["goods_listid"]) { $str = $act['goods_listid']; $fields = rtrim($str, ","); $fields = ltrim($fields, ","); if ($fields) $where .= " and goods_id in(" . $fields . ")"; else $where .= " and 1=2"; } else { $where .= " and 1=2"; } } } } } $t=time(); $getAdmStoId = getAdmStoId(); $where .= " and store_id=" . $getAdmStoId; $where.=" and on_time<".$t." and (down_time>".$t." or down_time=0)"; $count = M('goods')->where($where)->count(); $Page = new AjaxPage($count, $pagenum); $goodsList = M('goods')->where($where)->order('goods_id DESC,prom_id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select(); $show = $Page->show();//分页显示输出 $this->assign('page', $show);//赋值分页输出 $this->assign('goodsList', $goodsList); $this->assign('pager', $Page);//赋值分页输出 // upload_ylp_log('搜索商品'); if($isnotin=="1") return $this->fetch('ajax_search_goods2', getAdmStoId()); else return $this->fetch('', getAdmStoId()); } public function search_goods() { $GoodsLogic = new GoodsLogic; $brandList = $GoodsLogic->getSortBrands(); $this->assign('brandList', $brandList); $categoryList = $GoodsLogic->getSortCategory(); $this->assign('categoryList', $categoryList); // $goods_id = I('goods_id'); // $price = I('price'); $where=""; $type = I('type', ''); // $distr_type = I('distr_type/d', ''); if (!empty($type)) { $gift_list=M('gift')->where('is_end',0)->getfield('goods_id',true); if($gift_list) $where = 'is_on_sale = 1 and is_mainshow=1 and prom_type not in (1,2,4) and store_count>0 and store_id=' . getAdmStoId() . ' and goods_id not in ('.implode(',',$gift_list).')';//赠品的搜索条件 else $where = 'is_on_sale = 1 and is_mainshow=1 and prom_type not in (1,2,4) and store_count>0 and store_id=' . getAdmStoId();//赠品的搜索条件 } else { $where = 'is_on_sale = 1 and is_mainshow=1 and prom_type=0 and store_count>0 and store_id=' . getAdmStoId() . '';//搜索条件 } // else if (empty($distr_type)) { // $where = 'is_on_sale = 1 and prom_type=0 and store_count>0 and store_id=' . getAdmStoId() . ' and distr_type in (' . $distr_type . ')';//搜索条件 // } $this->assign('type', $type); // $this->assign('distr_type', $distr_type); // if (!empty($goods_id)) { // $where .= " and goods_id not in ($goods_id) "; // } // if (!empty($price)) { // $where .= " and market_price >= " . $price; // } $intro = I('intro'); if (!empty($intro)) { $where = "$where and " . I('intro') . " = 1"; $this->assign('intro', $intro); } if (I('cat_id')) { $this->assign('cat_id', I('cat_id')); $grandson_ids = getCatGrandson(I('cat_id')); $where = " $where and cat_id in(" . implode(',', $grandson_ids) . ") "; // 初始化搜索条件 } if (I('brand_id')) { $this->assign('brand_id', I('brand_id')); $where = "$where and brand_id = " . I('brand_id'); } $kword = urldecode(urldecode(I('keywords/s'))); if (!empty($kword)) { $this->assign('keywords', $kword); $where = "$where and (goods_sn like '%" . $kword . "%' or goods_name like '%" . $kword . "%' or keywords like '%" . $kword . "%' or sku = '" . $kword . "')"; } $t=time(); $where.=" and on_time<".$t." and (down_time>".$t." or down_time=0 or down_time='' or down_time is null)"; mlog(json_encode($where),"search_goods/".getAdmStoId()); $count = M('goods')->where($where)->count(); $Page = new Page($count, 10); $goodsList = M('goods')->where($where)->order('goods_id DESC')->limit($Page->firstRow . ',' . $Page->listRows)->select(); $show = $Page->show();//分页显示输出 $this->assign('page', $show);//赋值分页输出 $this->assign('goodsList', $goodsList); $this->assign('pager', $Page);//赋值分页输出 $tpl = I('get.tpl', 'search_goods'); // upload_ylp_log('搜索商品'); return $this->fetch($tpl, getAdmStoId()); } //限时抢购 public function flash_sale() { $this->updategoodstype(1); $pagenum = 10;//每页显示多少条 if ((int)I('pagenum/s') > 0) { $pagenum = I('pagenum/s'); } $actname = I('actname'); $begin = strtotime(I('add_time_begin')); $end = strtotime(I('add_time_end')); if ($begin) { $condition['a.start_time'] = array('egt', $begin); } if ($end) { $condition['a.end_time'] = array('elt', $end); } $condition['a.store_id'] = getAdmStoId(); if (!empty($actname)) { $condition['a.title|c.goods_sn|c.sku'] = array('like', "%$actname%"); } $condition['a.store_id'] = getAdmStoId(); $condition['a.is_end'] = ['<>', 1]; $model = M('flash_sale'); $count = $model->alias('a') ->join('(select goods_id,goods_sn,sku from wxd_goods where store_id='.getAdmStoId().') c',' c.goods_id=a.goods_id','left') ->where($condition)->count(); $Page = new Page($count, $pagenum); $show = $Page->show(); $prom_list = $model->alias('a') ->join('(select goods_id,goods_sn,sku from wxd_goods where store_id='.getAdmStoId().') c',' c.goods_id=a.goods_id','left') /*--- ->join('(select sum(a.goods_num) as sum_goods_num,a.prom_id from wxd_order_goods a left join wxd_order b on a.order_id=b.order_id where a.store_id='.getAdmStoId().' and a.prom_type=1 and b.pay_status=1 group by a.prom_id) b','a.id=b.prom_id','left')---*/ ->where($condition) ->limit($Page->firstRow . ',' . $Page->listRows) ->order("a.ordid asc,a.id desc") ->field('a.*,c.goods_sn,c.sku') ->select(); $this->assign('prom_list', $prom_list); $this->assign('page', $show);// 赋值分页输出 $this->assign('pager', $Page); $this->assign('pagenum', $pagenum); // upload_ylp_log('秒杀特区'); return $this->fetch('', getAdmStoId()); } public function flash_sale_info() { $this->updategoodstype(1); if (IS_POST) { ClearALLCache(); delFile(TEMP_PATH . "/" . getAdmStoId()); $data = I('post.'); if ($data['show_time']) { $data['show_time'] = strtotime($data['show_time']); } else { $data['show_time'] = strtotime($data['start_time'] . " -1 day"); } $data['end_time'] = strtotime($data['end_time']); $data['start_time'] = strtotime($data['start_time']); if ($data['end_time'] <= $data['start_time']) { $this->error('结束时间必须大于结束时间'); } if ($data['price'] <= 0) { $this->error('秒杀价必须大于0'); } $data['store_id'] = getAdmStoId(); $admid = getAdminId(); $amdinfo = getAdminInfo($admid); $data['edit_man'] = $amdinfo['ERPName']; $adata['edit_man'] = $amdinfo['ERPName']; /*---操作活动总表---*/ $adata['prom_type'] = 1; $adata['goods_listid'] = "," . $data['goods_id'] . ","; $adata['is_show'] = 1; $adata['is_end'] = 0; $adata['warm_uptime'] = $data['show_time']; $adata['s_time'] = $data['start_time']; $adata['e_time'] = $data['end_time']; $adata['prom_price'] = $data['price']; $adata['prom_integral'] = 0; $adata['store_id'] = $data['store_id']; //$adata['commission'] = $data['commission']; if($data['commission']) $adata['commission'] = $data['commission']; $pattern=tpCache('distribut.pattern',getAdmStoId()); 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(); $adata['add_time'] = time(); $adata['add_ip'] = getIP(); $r = M('flash_sale')->add($data); M('goods')->where("goods_id=" . $data['goods_id'])->save(array('prom_id' => $r, 'prom_type' => 1)); $adata['act_id'] = $r; M('activitylist')->save($adata); adminLog("管理员添加抢购活动 " . $data['name']); $redis=get_redis_handle(); $name=get_redis_name($r,1,getAdmStoId()); for ($i = 0; $i < $data['goods_num']; $i++) { $redis->lPush($name, "m" . $i); } $namec=$name.":c"; F($namec, 1); /*---- //if(getAdmStoId()!=594) { $count = M('users')->where('store_id', getAdmStoId())->count(); if ($count > 50000) { $email = C('s_email'); $sname = tpCache('shop_info.store_name', getAdmStoId()); $str_start = date('Y-m-d H:i:s', $data['start_time']); $str_end = date('Y-m-d H:i:s', $data['end_time']); $txt = "商家名称:" . $sname . "
会员数量:" . $count . "
活动类型:秒杀
活动名称:" . $data['title'] . "
活动数量:" . $data['goods_num'] . "件
活动时间:" . $str_start . " 到 " . $str_end; sendmail($email, '活动通知', $txt); } //}---*/ } else { $rrp = M('flash_sale')->where("id=" . $data['id'])->where('store_id',getAdmStoId())->find(); if($rrp){ //活动缓冲人数,当活动还没有开始的时候 if($rrp['buy_num']>= $data['goods_num'] && $rrp['start_time']>time()){ $this->error('活动人数必须大于已售人数'); } } $data['edit_time'] = time(); $data['edit_mark'] = "编辑抢购活动"; $data['edit_ip'] = getIP(); $adata['edit_time'] = $data['edit_time']; $adata['edit_ip'] = $data['edit_ip']; M('activitylist')->where('act_id', $data['id'])->where('prom_type', 1)->save($adata); $r = M('flash_sale')->where("id=" . $data['id'])->save($data); M('goods')->where("prom_type=1 and prom_id=" . $data['id'])->save(array('prom_id' => 0, 'prom_type' => 0)); M('goods')->where("goods_id=" . $data['goods_id'])->save(array('prom_id' => $data['id'], 'prom_type' => 1)); /*---设置活动是秒杀销售量,当活动还没有开始的时候---*/ if($rrp['start_time']>time()) { //$redis = new \Redis(); //$redis->connect(redisip, 6379); $redis=get_redis_handle(); //$name = 'ms' . $data['id'] . '-' . getAdmStoId(); //$namec = 'ms' . $data['id'] . '-' . getAdmStoId() . 'c'; $name=get_redis_name($data['id'] ,1,getAdmStoId()); $namec=$name.":c"; $len = $redis->lLen($name); if (empty($len)) { for ($i = 0; $i < ($data['goods_num'] - $rrp['buy_num']); $i++) { $redis->lPush($name, "m" . $i); } F($namec, 1); } else if ($len != ($data['goods_num'] - $rrp['buy_num'])) { //$redis->delete($name); del_redis($redis,$name); for ($i = 0; $i < ($data['goods_num'] - $rrp['buy_num']); $i++) { $redis->lPush($name, "m" . $i); } F($namec, 1); } } upload_ylp_log('B20秒杀特区编辑/确认提交'); } if ($r) { $this->success('编辑抢购活动成功', U('Promotion/flash_sale')); exit(); } else { $this->error('编辑抢购活动失败', U('Promotion/flash_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); $pattern=tpCache('distribut.pattern',getAdmStoId()); $this->assign('pattern', $pattern); if ($id > 0) { $info = M('flash_sale')->where(array('store_id'=>getAdmStoId(),'id'=>$id))->find(); if ($info) { $is_start=0; if( $info['start_time']assign('is_start', $is_start); $info['show_time'] = date('Y-m-d H:i:s', $info['show_time']); $info['start_time'] = date('Y-m-d H:i:s', $info['start_time']); $info['end_time'] = date('Y-m-d H:i:s', $info['end_time']); $rt = M("goods")->where('goods_id', $info['goods_id'])->find(); if ($rt) $this->assign('storecount', $rt['store_count']); } } else { $info['ordid']=M('flash_sale')->where(array('store_id'=>getAdmStoId(),'is_end'=>0))->max('ordid')+1; } $this->assign('info', $info); $this->assign('min_date', date('Y-m-d')); return $this->fetch('', getAdmStoId()); } //秒杀异常处理 public function flash_sale_update_redis() { $flashid=I('flashid/d'); $rrp0 = M('flash_sale')->where(array("id"=>$flashid,'store_id'=>getAdmStoId(),'is_end'=>0))->find(); if ($rrp0) { /*---设置活动是秒杀销售量---*/ //$redis = new \Redis(); //$redis->connect(redisip, 6379); $redis=get_redis_handle(); //$name = 'ms' . $rrp0['id'] . '-' . getAdmStoId(); //$namec = 'ms' . $rrp0['id'] . '-' . getAdmStoId() . 'c'; $name=get_redis_name($rrp0['id'],1,getAdmStoId()); $namec=$name.":c"; $len = $redis->lLen($name); if (empty($len)) { for ($i = 0; $i < ($rrp0['goods_num'] - $rrp0['buy_num']); $i++) { $redis->lPush($name, "m" . $i); } F($namec, 1); } else if ($len != ($rrp0['goods_num'] - $rrp0['buy_num'])) { //$redis->delete($name); del_redis($redis,$name); for ($i = 0; $i < ($rrp0['goods_num'] - $rrp0['buy_num']); $i++) { $redis->lPush($name, "m" . $i); } F($namec, 1); } exit(json_encode(1)); } else { exit(json_encode(0)); } } public function flash_sale_del() { ClearALLCache(); delFile(TEMP_PATH . "/" . getAdmStoId()); $id = I('del_id'); if ($id) { // 启动事务 Db::startTrans(); try { $admid = getAdminId(); $amdinfo = getAdminInfo($admid); $data['edit_man'] = $amdinfo['ERPName']; $data['edit_time'] = time(); $data['edit_mark'] = "删除抢购活动"; $data['edit_ip'] = getIP(); $data['is_end'] = 1; $data['is_show'] = 1; M('flash_sale')->where("id", $id)->save($data); M('goods')->where(array('store_id' => getAdmStoId(), 'prom_type' => 1, 'prom_id' => $id))->save(array('prom_id' => 0, 'prom_type' => 0)); $adata['edit_time'] = $data['edit_time']; $adata['edit_man'] = $data['edit_man']; $adata['edit_ip'] = $data['edit_ip']; $adata['is_end'] = 1; M('activitylist')->where('act_id', $id)->where('prom_type=1')->save($adata); DB::commit(); } catch (\Exception $e) { // 回滚事务 Db::rollback(); exit(json_encode(0)); } /*---删除秒杀活动缓存---*/ //$redis = new \Redis(); //$redis->connect(redisip, 6379); $redis=get_redis_handle(); //$name='ms'.$id.'-'.getAdmStoId(); $name=get_redis_name($id,1,getAdmStoId()); del_redis($redis,$name); //if($redis->exists($name)) { // $redis->delete($name); //} //$namec='ms'.$id.'-'.getAdmStoId().'c'; $namec=$name.'c'; m_clearC($namec); // upload_ylp_log('删除活动'); exit(json_encode(1)); } else { exit(json_encode(0)); } } private function initEditor() { $this->assign("URL_upload", U('Admin/Ueditor/imageUp', array('savepath' => 'promotion'))); $this->assign("URL_fileUp", U('Admin/Ueditor/fileUp', array('savepath' => 'promotion'))); $this->assign("URL_scrawlUp", U('Admin/Ueditor/scrawlUp', array('savepath' => 'promotion'))); $this->assign("URL_getRemoteImage", U('Admin/Ueditor/getRemoteImage', array('savepath' => 'promotion'))); $this->assign("URL_imageManager", U('Admin/Ueditor/imageManager', array('savepath' => 'promotion'))); $this->assign("URL_imageUp", U('Admin/Ueditor/imageUp', array('savepath' => 'promotion'))); $this->assign("URL_getMovie", U('Admin/Ueditor/getMovie', array('savepath' => 'promotion'))); $this->assign("URL_Home", ""); } //团购历史记录 public function group_buy_history() { $this->updategoodstype(2); $pagenum = 10;//每页显示多少条 if ((int)I('pagenum/s') > 0) { $pagenum = I('pagenum/s'); } $actname = I('actname'); $condition['a.store_id'] = getAdmStoId(); if (!empty($actname)) { $condition['a.title|c.goods_sn|c.sku'] = array('like', "%$actname%"); } $condition['a.is_end'] = 1; $condition['a.is_show'] = 1; $model = M('group_buy'); $count = $model->alias('a') ->join('(select goods_id,goods_sn,sku from wxd_goods where store_id='.getAdmStoId().') c',' c.goods_id=a.goods_id','left') ->where($condition)->count(); $Page = new Page($count, $pagenum); $show = $Page->show(); $prom_list = $model->alias('a') ->join('(select goods_id,goods_sn,sku from wxd_goods where store_id='.getAdmStoId().') c',' c.goods_id=a.goods_id','left') ->where($condition)->order("id desc")->limit($Page->firstRow . ',' . $Page->listRows) ->field('a.*,c.goods_sn,c.sku') ->select(); $this->assign('prom_list', $prom_list); $this->assign('page', $show);// 赋值分页输出 $this->assign('pager', $Page); $this->assign('pagenum', $pagenum); // upload_ylp_log('团购历史'); return $this->fetch('', getAdmStoId()); } //秒杀历史记录 public function flash_sale_history() { $this->updategoodstype(1); $condition = array(); $pagenum = 10;//每页显示多少条 if ((int)I('pagenum/s') > 0) { $pagenum = I('pagenum/s'); } $actname = I('actname'); $begin = strtotime(I('add_time_begin')); $end = strtotime(I('add_time_end')); if ($begin) { $condition['a.start_time'] = array('egt', $begin); } if ($end) { $condition['a.end_time'] = array('elt', $end); } $condition['a.store_id'] = getAdmStoId(); if (!empty($actname)) { $condition['a.title|c.goods_sn|c.sku'] = array('like', "%$actname%"); } $condition['a.is_end'] = 1; $condition['a.is_show'] = 1; $model = M('flash_sale'); $count = $model->alias('a') ->join('(select goods_id,goods_sn,sku from wxd_goods where store_id='.getAdmStoId().') c',' c.goods_id=a.goods_id','left') ->where($condition)->count(); $Page = new Page($count, $pagenum); $show = $Page->show(); $prom_list = $model ->alias('a') ->join('(select goods_id,goods_sn,sku from wxd_goods where store_id='.getAdmStoId().') c',' c.goods_id=a.goods_id','left') /*--- ->join('(select sum(a.goods_num) as sum_goods_num,a.prom_id from wxd_order_goods a left join wxd_order b on a.order_id=b.order_id where a.store_id='.getAdmStoId().' and a.prom_type=1 and b.pay_status=1 group by a.prom_id) b','a.id=b.prom_id','left')---*/ ->where($condition)->order("id desc")->limit($Page->firstRow . ',' . $Page->listRows) ->field('a.*,c.goods_sn,c.sku') ->select(); $this->assign('prom_list', $prom_list); $this->assign('page', $show);// 赋值分页输出 $this->assign('pager', $Page); $this->assign('pagenum', $pagenum); //upload_ylp_log('历史'); return $this->fetch('', getAdmStoId()); } //优惠促销历史记录 public function prom_goods_history() { $this->updategoodstype(3); $condition = array(); $pagenum = 10;//每页显示多少条 if ((int)I('pagenum/s') > 0) { $pagenum = I('pagenum/s'); } $key = urldecode(urldecode(I('key/s'))); $condition['store_id'] = getAdmStoId(); if (!empty($key)) { $condition['name'] = array('like', "%$key%"); } $condition['is_end'] = 1; $model = M('prom_goods'); $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('page', $show);// 赋值分页输出 $this->assign('pager', $Page); $this->assign('pagenum', $pagenum); // upload_ylp_log('历史'); return $this->fetch('', getAdmStoId()); } //活动到期商品状态还原 public function updategoodstype($state) { switch ($state) { case '1': $table = "flash_sale"; break; case '2': $table = "group_buy"; break; case '3': $table = "prom_goods"; break; case '5': $table = "collocation"; break; } $time = time(); $data = M($table)->where(array('store_id' => getAdmStoId(), 'is_end' => 0, 'end_time' => ['<', $time]))->select(); $idlist=get_arr_column($data,'id'); if($idlist) { //--开启事务--- Db::startTrans(); try { M($table)->where("id", "in", $idlist) ->where('store_id', getAdmStoId()) ->where("is_end=0") ->save(array('is_end' => 1)); M("activitylist") ->where(array('store_id' => getAdmStoId(), 'prom_type' => (int)$state))->where("is_end=0") ->where("act_id", "in", $idlist) ->save(array('is_end' => 1)); if (!empty($data)) { foreach ($data as $val) { M('goods')->where(array('store_id' => getAdmStoId(), 'prom_type' => $state, 'prom_id' => $val['id'])) ->save(array('prom_type' => 0, 'prom_id' => 0)); if ($state == 1) { /*---删除秒杀活动缓存---*/ //$name='ms'.$val['id'].'-'.getAdmStoId(); //$namec='ms'.$val['id'].'-'.getAdmStoId().'c'; $name = get_redis_name($val['id'], 1, getAdmStoId()); $namec = $name . 'c'; /*---删除秒杀活动缓存---*/ //$redis = new \Redis(); //$redis->connect(redisip, 6379); $redis = get_redis_handle(); //if($redis->exists($name)) $redis->delete($name); del_redis($redis, $name); m_clearC($namec); } if ($state == 2) { /*---删除活动缓存---*/ //$name='grb'.$val['id'].'-'.getAdmStoId(); $name = get_redis_name($data['id'], 2, getAdmStoId()); /*---删除秒杀活动缓存---*/ //$redis = new \Redis(); //$redis->connect(redisip, 6379); $redis = get_redis_handle(); //if($redis->exists($name)) $redis->delete($name); del_redis($redis, $name); //$namec='grb'.$val['id'].'-'.getAdmStoId().'c'; $namec = $name. ":c"; m_clearC($namec); } } } Db::commit(); } catch (\Exception $e) { mlog("错误".$e->getMessage(),"updategoodstype/".getAdmStoId()); // 回滚事务 Db::rollback(); } } } //秒杀历史记录删除按钮 public function his_flash_sale_del() { $id = I('del_id'); if ($id) { $res = M('flash_sale')->where(array('id' => $id, 'store_id' => getAdmStoId(), 'is_end' => 1))->find(); if (empty($res)) { exit(json_encode(0)); } // 启动事务 Db::startTrans(); try { M('goods')->where(array('store_id' => getAdmStoId(), 'prom_type' => 1, 'prom_id' => $id))->save(array('prom_id' => 0, 'prom_type' => 0)); $data['is_show'] = 0; $admid = getAdminId(); $amdinfo = getAdminInfo($admid); $data['edit_man'] = $amdinfo['ERPName']; $data['edit_time'] = time(); $data['edit_mark'] = "删除历史抢购活动"; $data['edit_ip'] = getIP(); M('flash_sale')->where("id", $id)->where('store_id', getAdmStoId())->save($data); Db::commit(); ClearALLCache(); delFile(TEMP_PATH . "/" . getAdmStoId()); exit(json_encode(1)); } catch (\Exception $e) { // 回滚事务 Db::rollback(); exit(json_encode(0)); } } else { exit(json_encode(0)); } } //秒杀历史记录删除按钮 public function his_group_buy_del() { $id = I('del_id'); if ($id) { Db::startTrans(); try { $data['is_show'] = 0; $admid = getAdminId(); $amdinfo = getAdminInfo($admid); $data['edit_man'] = $amdinfo['ERPName']; $data['edit_time'] = time(); $data['edit_mark'] = "删除历史团购活动"; $data['edit_ip'] = getIP(); M('group_buy')->where("id", $id)->where('store_id', getAdmStoId())->save($data); Db::commit(); }catch (\Exception $e) { Db::rollback(); exit(json_encode(0)); } ClearALLCache(); delFile(TEMP_PATH . "/" . getAdmStoId()); // upload_ylp_log('团购删除'); exit(json_encode(1)); } else { exit(json_encode(0)); } } //秒杀历史记录删除按钮 public function his_prom_goods_del() { $id = I('del_id'); if ($id) { Db::startTrans(); try { $data['is_show'] = 0; $admid = getAdminId(); $amdinfo = getAdminInfo($admid); $data['edit_man'] = $amdinfo['ERPName']; $data['edit_time'] = time(); $data['edit_mark'] = "删除历史团购活动"; $data['edit_ip'] = getIP(); M('prom_goods')->where("id", $id)->where('store_id', getAdmStoId())->save($data); Db::commit(); }catch (\Exception $e) { Db::rollback(); exit(json_encode(0)); } ClearALLCache(); delFile(TEMP_PATH . "/" . getAdmStoId()); // upload_ylp_log('历史删除'); exit(json_encode(1)); } else { exit(json_encode(0)); } } // 赠品管理列表 public function gift_list() { /*--更新活动状态--*/ $this->update_gift(); //获取赠品列表 $pagenum = 10;//每页显示多少条 if (I('pagenum/d') > 0) { $pagenum = I('pagenum/d'); } $where = 'is_end=0 and store_id=' . getAdmStoId(); $key = urldecode(urldecode(I('key/s'))); if (!empty($key)) { $where .= ' and(goods_name like "%' . $key . '%" or title like "%' . $key . '%")'; } $count = M('gift')->where($where)->count(); $Page = new Page($count, $pagenum); $show = $Page->show(); $res = M('gift')->where($where)->limit($Page->firstRow . ',' . $Page->listRows)->order('id desc')->select(); /*--- foreach ($res as $k=>$val){ //$gift_receive=M('gift_receive')->where('gift_id',$val['id'])->count(); $gift_receive=M('gift_receive')->where('gift_id',$val['id'])->sum("gift_num"); $res[$k]['count']=$gift_receive; }---*/ $this->assign('pager', $Page); $this->assign('key', $key); $this->assign('page', $show);// 赋值分页输出 $this->assign('list', $res); $this->assign('pagenum', $pagenum); // upload_ylp_log('赠品管理'); return $this->fetch('', getAdmStoId()); } // 赠品详情 public function gift_info() { if (IS_POST) { ClearALLCache(); delFile(TEMP_PATH . "/" . getAdmStoId()); $data = I('post.'); $data['end_time'] = strtotime($data['end_time']); $data['start_time'] = strtotime($data['start_time']); if (empty($data['id'])){ $data['store_id'] = getAdmStoId(); $data['goods_num']=$data['show_num']; M('goods')->where('goods_id', $data['goods_id'])->setDec('store_count', $data['goods_num']); unset($data['num']); $r = M('gift')->add($data); }else{ if ($data['num'] > 0){ M('goods')->where('goods_id', $data['goods_id'])->setInc('store_count', $data['num']); } if ($data['num'] < 0){ $data['num'] = abs($data['num']); M('goods')->where('goods_id', $data['goods_id'])->setDec('store_count', $data['num']); } mlog('赠品修改:'.$data['num'].'', "gift/" . getAdmStoId()); unset($data['num']); if($data['show_num']) $data['goods_num']=$data['show_num']; $r = M('gift')->where('id',$data['id'])->save($data); } if ($r) { // upload_ylp_log('增加赠品'); $this->success('赠品编辑成功', U('Promotion/gift_list')); } else { $this->error('赠品增加失败'); } } $this->update_gift(); $prom_id = I('id/d'); $tpl = I('tpl', ''); $time = time(); if (!empty($prom_id)) { $info = M('gift')->where(['store_id' => getAdmStoId(), 'id' => $prom_id])->find(); if ($info['start_time'] < $time){ $this->assign('is_start',1); } $info['start_time'] = date('Y-m-d H:i:s', $info['start_time']); $info['end_time'] = date('Y-m-d H:i:s', $info['end_time']); $count=M('goods')->where('goods_id',$info['goods_id'])->field('store_count')->find()['store_count']; $count+=$info['goods_num']; $this->assign('select_goods_num',$count); } else { $info['start_time'] = date('Y-m-d H:i:s'); $info['end_time'] = date('Y-m-d H:i:s', time() + 3600 * 24 * 30); } $this->assign('tpl', $tpl); $this->assign('info', $info); return $this->fetch('', getAdmStoId()); } // 赠品删除 public function gift_del() { ClearALLCache(); delFile(TEMP_PATH . "/" . getAdmStoId()); // upload_ylp_log('赠品删除'); $id = I('id/d'); $num = I('num/d'); $goods_id = I('goods_id/d'); if (!empty($num)) { M('goods')->where('goods_id', $goods_id)->setInc('store_count', $num); } M('gift')->where('id', $id)->save(['is_end' => 1]); return json(['code' => 1]); } // 赠品历史记录 public function gift_history() { /*--更新活动状态--*/ $this->update_gift(); $pagenum = 10;//每页显示多少条 if (I('pagenum/d') > 0) { $pagenum = I('pagenum/d'); } $where = 'is_end=1 and store_id=' . getAdmStoId(); $key = urldecode(urldecode(I('key/s'))); if (!empty($key)) { $where .= ' and(goods_name like "%' . $key . '%" or title like "%' . $key . '%")'; } $count = M('gift')->where($where)->count(); $Page = new Page($count, $pagenum); $show = $Page->show(); $res = M('gift')->where($where)->limit($Page->firstRow . ',' . $Page->listRows)->order('id desc')->select(); foreach ($res as $k=>$val){ $gift_receive=M('gift_receive')->where('gift_id',$val['id'])->sum("gift_num"); $res[$k]['count']=$gift_receive; } $this->assign('pager', $Page); $this->assign('key', $key); $this->assign('page', $show);// 赋值分页输出 $this->assign('list', $res); $this->assign('pagenum', $pagenum); // upload_ylp_log('赠品管理历史'); return $this->fetch('', getAdmStoId()); } // 赠品归还 public function update_gift() { $time = time(); $data = M('gift')->where(array('store_id' => getAdmStoId(), 'is_end' => 0, 'end_time' => ['<', $time]))->select(); M('gift')->where(array('store_id' => getAdmStoId(), 'is_end' => 0, 'end_time' => ['<', $time]))->save(array('is_end' => 1)); if (!empty($data)) { foreach ($data as $v) { $goods_id = $v['goods_id']; $num = $v['goods_num']; if (!empty($num)) { M('goods')->where('goods_id', $goods_id)->setInc('store_count', $num); } } } } // 刷新select option 数据 public function up_data() { $table = I('table/s'); $html = ''; $time=time(); if ($table == 'coupon') { $coupon = M($table)->where(['store_id' => getAdmStoId(), 'send_end_time' => ['>', time()], 'type' => 5])->select(); if (!empty($coupon)) { foreach ($coupon as $v) { $html .= ''; } } } else if($table=="libao_form"){ $gift = M($table)->where(['store_id' => getAdmStoId(), 'isdel' => 0,'startime' => ['lt',$time],'endtime' => ['gt',$time]])->select(); if (!empty($gift)) { foreach ($gift as $v){ $txt=$v['title']; $html .= ''; } } }else{ $gift = M($table)->where(['store_id' => getAdmStoId(), 'is_end' => 0,'start_time' => ['lt',$time],'end_time' => ['gt',$time]])->select(); if (!empty($gift)) { foreach ($gift as $v){ $txt=$v['title']; $html .= ''; } } } return json(['html' => $html]); } // 优惠促销活动删除 public function tab_del() { $id = I('id/d'); $model = I('base/s', 'prom_goods_list'); M($model)->where('id', $id)->delete(); return json(1); } // 搭配促销列表 public function collocation_list() { /*--更新活动状态--*/ $this->updategoodstype(5); //获取优惠券列表 $pagenum = 10;//每页显示多少条 if ((int)I('pagenum/s') > 0) { $pagenum = I('pagenum/d'); } $key = urldecode(urldecode(I('key/s'))); $condition = 'store_id=' . getAdmStoId() . ' and is_end=0 '; if (!empty($key)) { $condition .= 'and (title like "%' . $key . '%" or main_goods_name like "%' . $key . '%")'; } $count = M('collocation')->where($condition)->count(); $Page = new Page($count, $pagenum); $show = $Page->show(); $list = M('collocation')->where($condition)->limit($Page->firstRow . ',' . $Page->listRows)->order('id desc')->select(); $this->assign([ 'key' => $key, 'pager' => $Page, 'page' => $show, 'pagenum' => $pagenum, 'list' => $list ]); // upload_ylp_log('搭配促销'); return $this->fetch('', getAdmStoId()); } // 搭配详情页 public function collocation_info() { $prom_id = I('id/d'); $tpl = I('tpl', ''); $time = time(); if (!empty($prom_id)) { $info = M('collocation')->where(['store_id' => getAdmStoId(), 'id' => $prom_id])->find(); if ($info['start_time'] < $time){ $info['start_time'] = $time; } $info['start_time'] = date('Y-m-d H:i:s', $info['start_time']); $info['end_time'] = date('Y-m-d H:i:s', $info['end_time']); $prom_goods = M('collocation_list')->alias('a')->join('goods b','a.goods_id = b.goods_id')->where('a.prom_id', $prom_id)->field('a.*,b.shop_price')->select(); $this->assign('prom_goods', $prom_goods); } else { $info['start_time'] = date('Y-m-d H:i:s'); $info['end_time'] = date('Y-m-d H:i:s', time() + 3600 * 24 * 30); } $this->assign([ 'tpl' => $tpl, 'info' => $info, 'erpid' => getERPId(), 'qclurl' => QCLOUD_IMGURL ]); return $this->fetch('', getAdmStoId()); } public function collocation_save() { ClearALLCache(); delFile(TEMP_PATH . "/" . getAdmStoId()); $prom_id = I('id'); $data = I('post.'); $good_list = $data['goods_id']; $price_list = $data['price']; $sn_list = $data['goods_sn']; $name_list = $data['goods_name']; $sku_list = $data['sku']; $market_list = $data['market_price']; unset($data['goods_sn']); unset($data['goods_name']); unset($data['sku']); unset($data['market_price']); unset($data['goods_id']); unset($data['price']); $data['start_time'] = strtotime($data['start_time']); $data['end_time'] = strtotime($data['end_time']); $data['store_id'] = getAdmStoId(); $admid = getAdminId(); $amdinfo = getAdminInfo($admid); $data['edit_man'] = $amdinfo['ERPName']; /*--活动总表--*/ $adata['edit_man'] = $amdinfo['ERPName']; $adata['prom_type'] = 5; $adata['is_show'] = 1; $adata['is_end'] = 0; $adata['warm_uptime'] = 0; $adata['s_time'] = $data['start_time']; $adata['e_time'] = $data['end_time']; $adata['prom_integral'] = 0; $adata['store_id'] = getAdmStoId(); if ($prom_id > 0) { $id_list = $data['list_id']; unset($data['list_id']); $data['edit_time'] = time(); $data['edit_ip'] = getIP(); M('collocation')->where(['store_id' => getAdmStoId(), 'id' => $prom_id])->save($data); // upload_ylp_log('修改搭配促销'); adminLog('管理员修改搭配促销' . I('title')); $adata['edit_time'] = $data['edit_time']; $adata['edit_man'] = $data['edit_man']; $adata['edit_ip'] = $data['edit_ip']; M('activitylist')->where(['act_id' => $prom_id, 'prom_type' => 5])->save($adata); foreach ($good_list as $k => $v) { $id = $id_list[$k]; if ($id > 0) { M('collocation_list')->where(['id' => $id])->save(['price' => $price_list[$k], 'edit_time' => time(), 'edit_ip' => getIP(), 'edit_man' => $amdinfo['ERPName']]); } else { M('collocation_list')->save(['prom_id' => $prom_id, 'goods_id' => $v, 'price' => $price_list[$k], 'add_time' => time(), 'edit_man' => $amdinfo['ERPName'], 'goods_name' => $name_list[$k], 'goods_sn' => $sn_list[$k], 'sku' => $sku_list[$k], 'market_price' => $market_list[$k]]); } } } else { unset($data['id']); $data['add_time'] = time(); $prom_id = M('collocation')->add($data); // upload_ylp_log('添加搭配'); adminLog("管理员添加了搭配促销 " . I('title')); $adata['add_time'] = time(); $adata['add_ip'] = getIP(); $adata['act_id'] = $prom_id; M('activitylist')->save($adata); M("goods")->where('goods_id', $data['main_goods_id'])->save(array('prom_id' => $prom_id, 'prom_type' => 5)); foreach ($good_list as $k => $v) { $bdata[] = ['prom_id' => $prom_id, 'goods_id' => $v, 'price' => $price_list[$k], 'add_time' => time(), 'edit_man' => $amdinfo['ERPName'], 'goods_name' => $name_list[$k], 'goods_sn' => $sn_list[$k], 'sku' => $sku_list[$k], 'market_price' => $market_list[$k]]; } M('collocation_list')->insertAll($bdata); } $this->success('编辑促销活动成功', U('Promotion/collocation_list')); } public function collocation_del() { Db::startTrans(); try { $prom_id = I('id/d'); $admid = getAdminId(); $amdinfo = getAdminInfo($admid); $data['edit_man'] = $amdinfo['ERPName']; $data['edit_time'] = time(); $data['edit_ip'] = getIP(); $data['is_end'] = 1; $adata['edit_time'] = $data['edit_time']; $adata['edit_man'] = $data['edit_man']; $adata['edit_ip'] = $data['edit_ip']; $adata['is_end'] = 1; M('activitylist')->where(['act_id' => $prom_id, 'prom_type' => 5])->save($adata); M("goods")->where("store_id=" . getAdmStoId() . " and prom_id=$prom_id and prom_type=5")->save(array('prom_id' => 0, 'prom_type' => 0)); // upload_ylp_log('删除商品促销活动'); M('collocation')->where("store_id=" . getAdmStoId() . " and id=$prom_id")->save($data); Db::commit(); } catch (\Exception $e) { Db::rollback(); exit(json_encode(0)); } ClearALLCache(); delFile(TEMP_PATH . "/" . getAdmStoId()); $this->success('删除活动成功', U('Promotion/collocation_list')); } public function collocation_history() { /*--更新活动状态--*/ $this->updategoodstype(5); //获取优惠券列表 $pagenum = 10;//每页显示多少条 if ((int)I('pagenum/s') > 0) { $pagenum = I('pagenum/d'); } $key = urldecode(urldecode(I('key/s'))); $condition = 'store_id=' . getAdmStoId() . ' and is_end=1 '; if (!empty($key)) { $condition .= 'and (title like "%' . $key . '%" or main_goods_name like "%' . $key . '%")'; } $count = M('collocation')->where($condition)->count(); $Page = new Page($count, $pagenum); $show = $Page->show(); $list = M('collocation')->where($condition)->limit($Page->firstRow . ',' . $Page->listRows)->order('id desc')->select(); $this->assign([ 'key' => $key, 'pager' => $Page, 'page' => $show, 'pagenum' => $pagenum, 'list' => $list ]); // upload_ylp_log('历史搭配促销'); return $this->fetch('', getAdmStoId()); } //是不是优惠活动商品 public function is_prom_good(){ $id=I('id'); $stoid=getAdmStoId(); $time=time(); $wh="b.is_end=0 and b.start_time<".$time." and b.end_time>".$time; $act=M('goods')->alias('a') ->join('prom_goods b','a.prom_type=3 and a.prom_id=b.id')->where($wh) ->where('goods_id',$id)->field('goods_id')->find(); if($act) return 1; return 0; } //团购记录 public function group_buy_orderlist() { $pagenum = 20;//每页显示多少条 if ((int)I('pagenum/s') > 0) { $pagenum = I('pagenum/s'); } $p = I('p', 1); $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');//手机号码 $flashsaleid = I('grb_id');//ID $picksle=trim(I('picksle')); $pstype=I('picksle_type'); $getisend=I('isend'); $where = " a.store_id=" . getAdmStoId(); $where .= " and a.prom_type=2 and a.prom_id=" . $flashsaleid; //团购prom_type=2 if (!empty($mobile)) { $where .= " and c.mobile='" . $mobile . "' "; } if (!empty($order_sn)) { $where .= " and b.order_sn='" . $order_sn . "' "; } if($picksle){ if($pstype) $where .= " AND d.pickup_name='".$picksle."'"; else $where .= " AND d.pickup_no='".$picksle."'"; } if ($begin) { $where.=" and b.add_time>=".strtotime($begin); } if ($end) { $where.=" and b.add_time<=".strtotime($end); } $order_status=I('order_status'); if($order_status!="") { switch ($order_status) { case 12: //待付款 $condition['b.order_status'] = 0; $condition['b.pay_status'] =0; break; case 1: //待发货 $condition['b.pay_status'] =1; $condition['b.order_status'] = ['in','0,1']; $condition['b.shipping_status'] =0; break; case 11: //待收货 $condition['b.order_status'] = 1; I('shipping_status') != '' ? $condition['b.shipping_status'] = I('shipping_status') : $condition['shipping_status'] = ['in','1,2']; //是否发货 break; case 2: //已收货 $condition['b.order_status'] = 2; break; case 3: //已取消 $condition['b.order_status'] = I('order_status'); break; case 4: //已完成 $condition['b.order_status'] = I('order_status'); break; case 5: //已作废 $condition['b.order_status'] = I('order_status'); break; case 6: //已作废 $condition['b.order_status'] = I('order_status'); break; case 13: //已付款 $condition['b.pay_status'] =1; break; } } $qdrecord = M('order_goods'); $count = $qdrecord->alias('a') ->join('order b',' a.order_id=b.order_id','left') ->join('(select nickname,mobile,user_id from wxd_users where store_id='.getAdmStoId().') c',' b.user_id=c.user_id','left') ->join('(select pickup_id,pickup_name,pickup_no from wxd_pick_up where store_id='.getAdmStoId().') d','d.pickup_id=b.pickup_id','left') ->where($where) ->where($condition) ->count(); $sumcount = $qdrecord->alias('a') ->join('order b',' a.order_id=b.order_id','left') ->join('(select nickname,mobile,user_id from wxd_users where store_id='.getAdmStoId().') c',' b.user_id=c.user_id','left') ->join('(select pickup_id,pickup_name,pickup_no from wxd_pick_up where store_id='.getAdmStoId().') d','d.pickup_id=b.pickup_id','left') ->where($where) ->where($condition) ->sum('a.goods_num'); $Page = $pager = new Page($count, $pagenum);// 实例化分页类 传入总记录数和每页显示的记录数 $redmoneylist = $qdrecord->alias('a') ->join('order b',' a.order_id=b.order_id','left') ->join('(select nickname,mobile,user_id from wxd_users where store_id='.getAdmStoId().') c','b.user_id=c.user_id','left') ->join('(select pickup_id,pickup_name,pickup_no from wxd_pick_up where store_id='.getAdmStoId().') d','d.pickup_id=b.pickup_id','left') ->where($where) ->where($condition) ->limit($Page->firstRow . ',' . $Page->listRows) ->order('b.add_time desc') ->field('d.pickup_name,d.pickup_no,b.order_id,c.mobile,c.nickname,b.order_sn,a.goods_num,a.goods_name,b.add_time,b.order_status,b.pay_status,b.shipping_status,b.pay_sn,b.pay_time') ->select();// 查询满足要求的总记录数 foreach ($redmoneylist as $kk=>$vv){ $order_status_arr = C('ORDER_STATUS_DESC'); $order_status_code = orderStatusDesc(0, $vv); // 订单状态显示给用户看的 $redmoneylist[$kk]['order_status_desc'] = $order_status_arr[$order_status_code]; } if ($p==1 && $getisend==1) { $falshinfo=M('flash_sale')->where(array('store_id'=>getAdmStoId(),'id'=>$flashsaleid,'is_end'=>1))->find(); if ($falshinfo) { if ($falshinfo['buy_num']!=$sumcount) { $updatedata['buy_num']=$sumcount; } if ($falshinfo['order_num']!=$count) { $updatedata['order_num']=$count; } if ($updatedata) { M('flash_sale')->where(array('store_id' => getAdmStoId(), 'id' => $flashsaleid, 'is_end' => 1))->save($updatedata); } } } $show = $Page->show(); $this->assign('page', $show); $this->assign('sumcount', $sumcount); $this->assign('total', $count); $this->assign('flashsaleid', $flashsaleid); $this->assign('order_sn', $order_sn); $this->assign('picksle', $picksle); $this->assign('pstype', $pstype); $this->assign('getorder_status', $order_status); $this->assign('mobile', $mobile); $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_grb_sale_orderlist() { $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');//手机号码 $flashsaleid = I('grb_id');//ID $picksle=trim(I('picksle')); $pstype=I('picksle_type'); $getisend=I('isend'); $where = " a.store_id=" . getAdmStoId(); $where .= " and a.prom_type=2 and a.prom_id=" . $flashsaleid; if (!empty($mobile)) { $where .= " and c.mobile='" . $mobile . "' "; } if (!empty($order_sn)) { $where .= " and b.order_sn='" . $order_sn . "' "; } if($picksle){ if($pstype) $where .= " AND d.pickup_name='".$picksle."'"; else $where .= " AND d.pickup_no='".$picksle."'"; } if ($begin) { $where.=" and b.add_time>=".strtotime($begin); } if ($end) { $where.=" and b.add_time<=".strtotime($end); } $order_status=I('order_status'); if($order_status!="") { switch ($order_status) { case 12: //待付款 $condition['b.order_status'] = 0; $condition['b.pay_status'] =0; break; case 1: //待发货 $condition['b.pay_status'] =1; $condition['b.order_status'] = ['in','0,1']; $condition['b.shipping_status'] =0; break; case 11: //待收货 $condition['b.order_status'] = 1; I('shipping_status') != '' ? $condition['b.shipping_status'] = I('shipping_status') : $condition['shipping_status'] = ['in','1,2']; //是否发货 break; case 2: //已收货 $condition['b.order_status'] = 2; break; case 3: //已取消 $condition['b.order_status'] = I('order_status'); break; case 4: //已完成 $condition['b.order_status'] = I('order_status'); break; case 5: //已作废 $condition['b.order_status'] = I('order_status'); break; case 6: //已作废 $condition['b.order_status'] = I('order_status'); break; case 13: //已付款 $condition['b.pay_status'] =1; break; } } $qdrecord = M('order_goods'); $redmoneylist = $qdrecord->alias('a') ->join('order b',' a.order_id=b.order_id','left') ->join('(select nickname,mobile,user_id from wxd_users where store_id='.getAdmStoId().') c','b.user_id=c.user_id','left') ->join('(select pickup_id,pickup_name,pickup_no from wxd_pick_up where store_id='.getAdmStoId().') d','d.pickup_id=b.pickup_id','left') ->where($where) ->where($condition) ->order('b.add_time desc') ->field('d.pickup_name,d.pickup_no,b.order_id,c.mobile,c.nickname,b.order_sn,a.goods_num,a.goods_name,b.add_time,b.order_status,b.pay_status,b.shipping_status,b.pay_sn,b.pay_time') ->select();// 查询满足要求的总记录数 foreach ($redmoneylist as $kk=>$vv){ $order_status_arr = C('ORDER_STATUS_DESC'); $order_status_code = orderStatusDesc(0, $vv); // 订单状态显示给用户看的 $redmoneylist[$kk]['order_status_desc'] = $order_status_arr[$order_status_code]; } $strTable =''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; if(is_array($redmoneylist)){ foreach($redmoneylist as $k=>$val){ $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; $strTable .= ''; } } $strTable .='
订单号会员昵称手机号门店名称购买数量购买时间状态
 '.$val['order_sn'].''.$val['nickname'].' '.$val['mobile'].''.$val['pickup_name'].' '.$val['goods_num'].' '.date("Y-m-d H:i:s",$val['add_time']).''.$val['order_status_desc'].'
'; echo $strTable; unset($redmoneylist); downloadExcel($strTable,'团购订单'); exit(); } }