'wwx_fxxt')); $mdauth = json_decode($moduleinfo["url"]); if (empty($mdauth) || !is_object($mdauth)) { if ($this->ttauth()) { return; } } else { if ($mdauth->url != $_SERVER['HTTP_HOST']) { if ($this->ttauth()) { return; } } else { if ($mdauth->end <= time()) { if ($this->ttauth()) { return; } message('您的域名授权过期了哦->【' . $_SERVER['HTTP_HOST'] . "】,请联系我们授权后再来使用吧!", '', 'error'); } } } $this->autofinishorder(true); } public function ttauth() { load()->func('communication'); //暂时return true,不去授权地方做验证 return true; function hs($hex) { $string = ''; for ($i = 0; $i < strlen($hex) - 1; $i += 2) { $string .= chr(hexdec($hex[$i] . $hex[$i + 1])); } return $string; } $authortxt = '您的域名未授权,请联系作者重新授权呦~'; $auth = hs("687474703A2F2F66782E77656967657061692E636F6D2F617574686170692E706870"); $res = ihttp_post($auth, array("domain" => $_SERVER['HTTP_HOST'])); $result = json_decode($res["content"]); if (empty($result) || !is_object($result)) { message('您的域名->【' . $_SERVER['HTTP_HOST'] . "】暂未授权,请联系我们授权后再来使用吧!", '', 'error'); } if ($result->status == "0") { message('您的域名->【' . $_SERVER['HTTP_HOST'] . "】暂未授权,请联系我们授权后再来使用吧!", '', 'error'); } else { if ($result->status == "1") { message('您的域名授权过期了哦->【' . $_SERVER['HTTP_HOST'] . '】' . $result->autherr, '', 'error'); } else { if ($result->status == "2") { $data = array("url" => json_encode(array('url' => $_SERVER['HTTP_HOST'], "end" => $result->authend, "autherr" => $result->autherr))); pdo_update('modules', $data, array('name' => 'wwx_fxxt')); } } } return true; } public function doMobilelist() { global $_GPC, $_W; load()->model('mc'); $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); $cfg = $this->module['config']; $title = $cfg['shopname']; if (empty($title)) { $title = '商城首页'; } if (!empty($signPackage['dzdtitle'])) { $title = $signPackage['dzdtitle']; } if (!empty($profile['id'])) { $myfansx = pdo_fetch('SELECT member_commission FROM ' . tablename('wwx_fxxt_member_shipgrade') . " WHERE uniacid = :uniacid and displayorder = :displayorder order by member_name desc limit 1", array(':uniacid' => $_W['uniacid'], ':displayorder' => $profile['usergrade'])); if (!empty($myfansx['member_commission'])) { $member_commission = $myfansx['member_commission']; } else { $member_commission = 0; } } $pindex = max(1, intval($_GPC['page'])); $psize = 10; $children = array(); $category = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_category') . " WHERE uniacid = '{$_W['uniacid']}' and enabled=1 ORDER BY parentid ASC, displayorder DESC", array(), 'id'); foreach ($category as $index => $row) { if (!empty($row['parentid'])) { $children[$row['parentid']][$row['id']] = $row; unset($category[$index]); } } $ccolumn = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('wwx_fxxt_goods') . " WHERE uniacid = '{$_W['uniacid']}' and deleted=0 AND status = '1'"); $recommandcategory = array(); foreach ($category as &$c) { if ($c['isrecommand'] == 1) { $c['list'] = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_goods') . " WHERE uniacid = '{$_W['uniacid']}' and isrecommand=1 and deleted=0 AND status = '1' and pcate='{$c['id']}' ORDER BY displayorder DESC, sales DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize); $c['total'] = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('wwx_fxxt_goods') . " WHERE uniacid = '{$_W['uniacid']}' and isrecommand=1 and deleted=0 AND status = '1' and pcate='{$c['id']}'"); $c['pager'] = pagination($c['total'], $pindex, $psize, $url = '', $context = array('before' => 0, 'after' => 0, 'ajaxcallback' => '')); $recommandcategory[] = $c; } if (!empty($children[$c['id']])) { foreach ($children[$c['id']] as &$child) { if ($child['isrecommand'] == 1) { $child['list'] = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_goods') . " WHERE uniacid = '{$_W['uniacid']}' and isrecommand=1 and deleted=0 AND status = '1' and pcate='{$c['id']}' and ccate='{$child['id']}' ORDER BY displayorder DESC, sales DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize); $child['total'] = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('wwx_fxxt_goods') . " WHERE uniacid = '{$_W['uniacid']}' and isrecommand=1 and deleted=0 AND status = '1' and pcate='{$c['id']}' and ccate='{$child['id']}' "); $child['pager'] = pagination($child['total'], $pindex, $psize, $url = '', $context = array('before' => 0, 'after' => 0, 'ajaxcallback' => '')); $recommandcategory[] = $child; } } unset($child); } } unset($c); $carttotal = $this->getCartTotal(); $advs = pdo_fetchall("select * from " . tablename('wwx_fxxt_adv') . " where enabled=1 and uniacid= '{$_W['uniacid']}' order by displayorder asc"); foreach ($advs as &$adv) { if (substr($adv['link'], 0, 5) != 'http:') { $adv['link'] = $adv['link']; } } unset($adv); if (empty($cfg['indexss'])) { $cfg['indexss'] = 0; } $islist = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_goods') . " WHERE uniacid = '{$_W['uniacid']}' and deleted=0 AND status = '1' and istime='1' ORDER BY displayorder DESC, sales DESC limit {$cfg['indexss']}"); foreach ($islist as &$r) { if ($r['istime'] == 1) { $arr = $this->time_tran($r['timeend']); $r['timelaststr'] = $arr[0]; $r['timelast'] = $arr[1]; } } unset($r); $theone = pdo_fetch('SELECT terms FROM ' . tablename('wwx_fxxt_rules') . " WHERE uniacid = :uniacid", array(':uniacid' => $_W['uniacid'])); $fans = mc_credit_fetch($_W['member']['uid'], '*'); include $this->template('list'); } public function doMobileSearch() { global $_GPC, $_W; $keyword = $_GPC['keyword']; $url = $this->createMobileUrl('list2', array('m' => 'wwx_fxxt', 'uniacid' => $_W['uniacid'], 'keyword' => $keyword, 'sort' => 1)); header("location:{$url}"); die; } public function doMobilelist2() { global $_GPC, $_W; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); $carttotal = $this->getCartTotal(); if (!empty($profile['id'])) { $myfansx = pdo_fetch('SELECT member_commission FROM ' . tablename('wwx_fxxt_member_shipgrade') . " WHERE uniacid = :uniacid and displayorder = :displayorder order by member_name desc limit 1", array(':uniacid' => $_W['uniacid'], ':displayorder' => $profile['usergrade'])); if (!empty($myfansx['member_commission'])) { $member_commission = $myfansx['member_commission']; } else { $member_commission = 0; } } $pindex = max(1, intval($_GPC["page"])); $psize = 20; $condition = ''; if (!empty($_GPC['ccate'])) { $cid = intval($_GPC['ccate']); $condition .= " AND ccate = '{$cid}'"; $_GPC['pcate'] = pdo_fetchcolumn("SELECT parentid FROM " . tablename('wwx_fxxt_category') . " WHERE uniacid = :uniacid AND id = :id", array(':uniacid' => $_W['uniacid'], ':id' => intval($_GPC['ccate']))); } elseif (!empty($_GPC['pcate'])) { $pcatecid = pdo_fetchcolumn("SELECT parentid FROM " . tablename('wwx_fxxt_category') . " WHERE uniacid = :uniacid AND id = :id", array(':uniacid' => $_W['uniacid'], ':id' => intval($_GPC['pcate']))); if (!empty($pcatecid)) { $cid = intval($_GPC['pcate']); $condition .= " AND ccate = '{$cid}'"; } else { $cid = intval($_GPC['pcate']); $condition .= " AND pcate = '{$cid}'"; } } if (!empty($_GPC['keyword'])) { $condition .= " AND title LIKE '%{$_GPC['keyword']}%'"; } $sort = empty($_GPC['sort']) ? 0 : $_GPC['sort']; $sortfield = "displayorder asc"; $sortb0 = empty($_GPC['sortb0']) ? "desc" : $_GPC['sortb0']; $sortb1 = empty($_GPC['sortb1']) ? "desc" : $_GPC['sortb1']; $sortb2 = empty($_GPC['sortb2']) ? "desc" : $_GPC['sortb2']; $sortb3 = empty($_GPC['sortb3']) ? "asc" : $_GPC['sortb3']; if ($sort == 0) { $sortb00 = $sortb0 == "desc" ? "asc" : "desc"; $sortfield = "createtime " . $sortb0; $sortb11 = "desc"; $sortb22 = "desc"; $sortb33 = "asc"; } else { if ($sort == 1) { $sortb11 = $sortb1 == "desc" ? "asc" : "desc"; $sortfield = "sales " . $sortb1; $sortb00 = "desc"; $sortb22 = "desc"; $sortb33 = "asc"; } else { if ($sort == 2) { $sortb22 = $sortb2 == "desc" ? "asc" : "desc"; $sortfield = "viewcount " . $sortb2; $sortb00 = "desc"; $sortb11 = "desc"; $sortb33 = "asc"; } else { if ($sort == 3) { $sortb33 = $sortb3 == "asc" ? "desc" : "asc"; $sortfield = "marketprice " . $sortb3; $sortb00 = "desc"; $sortb11 = "desc"; $sortb22 = "desc"; } } } } $sorturl = $this->createMobileUrl('list2', array("keyword" => $_GPC['keyword'], "pcate" => $_GPC['pcate'], "ccate" => $_GPC['ccate'])); if (!empty($_GPC['isnew'])) { $condition .= " AND isnew = 1"; $sorturl .= "&isnew=1"; } if (!empty($_GPC['ishot'])) { $condition .= " AND ishot = 1"; $sorturl .= "&ishot=1"; } if (!empty($_GPC['isdiscount'])) { $condition .= " AND isdiscount = 1"; $sorturl .= "&isdiscount=1"; } if (!empty($_GPC['istime'])) { $condition .= " AND istime = 1 "; $sorturl .= "&istime=1"; } $children = array(); $category = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_category') . " WHERE uniacid = '{$_W['uniacid']}' and enabled=1 ORDER BY parentid ASC, displayorder DESC", array(), 'id'); foreach ($category as $index => $row) { if (!empty($row['parentid'])) { $children[$row['parentid']][$row['id']] = $row; unset($category[$index]); } } $list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_goods') . " WHERE uniacid = '{$_W['uniacid']}' and deleted=0 AND status = '1' {$condition} ORDER BY {$sortfield} LIMIT " . ($pindex - 1) * $psize . ',' . $psize); foreach ($list as &$r) { if ($r['istime'] == 1) { $arr = $this->time_tran($r['timeend']); $r['timelaststr'] = $arr[0]; $r['timelast'] = $arr[1]; } } unset($r); $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('wwx_fxxt_goods') . " WHERE uniacid = '{$_W['uniacid']}' and deleted=0 AND status = '1' {$condition}"); $pager = pagination($total, $pindex, $psize); include $this->template('list2'); } public function doMobileDetail() { global $_W, $_GPC; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $this->OverallSituation($from_user, $profile); $goodsid = intval($_GPC['id']); $goods = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_goods') . " WHERE id = :id", array(':id' => $goodsid)); $arr = $this->time_tran($goods['timeend']); $goods['timelaststr'] = $arr[0]; $goods['timelast'] = $arr[1]; $ccate = intval($goods['ccate']); $commission = pdo_fetchcolumn(" SELECT commission FROM " . tablename('wwx_fxxt_goods') . " WHERE id=" . $goodsid . " "); $member = pdo_fetch(" SELECT * FROM " . tablename('wwx_fxxt_member') . " WHERE from_user='" . $from_user . "' AND uniacid=" . $_W['uniacid'] . " "); if ($commission == false || $commission == null || $commission < 0) { $commission = $this->module['config']['globalCommission']; } if (empty($goods)) { message('抱歉,商品不存在或是已经被删除!'); } if ($goods['totalcnf'] != 2 && empty($goods['total'])) { message('抱歉,商品库存不足!'); } if ($goods['istime'] == 1) { if (time() < $goods['timestart']) { message('抱歉,还未到购买时间, 暂时无法购物哦~', referer(), "error"); } if (time() > $goods['timeend']) { message('抱歉,商品限购时间已到,不能购买了哦~', referer(), "error"); } } pdo_query('update ' . tablename('wwx_fxxt_goods') . " set viewcount=viewcount+1 where id=:id and uniacid='{$_W['uniacid']}' ", array(":id" => $goodsid)); if (!empty($profile['id'])) { $myfansx = pdo_fetch('SELECT member_commission FROM ' . tablename('wwx_fxxt_member_shipgrade') . " WHERE uniacid = :uniacid and displayorder = :displayorder order by member_name desc limit 1", array(':uniacid' => $_W['uniacid'], ':displayorder' => $profile['usergrade'])); if (!empty($myfansx['member_commission'])) { $member_commission = $myfansx['member_commission']; } else { $member_commission = 0; } } $piclist1 = array(array("attachment" => $goods['thumb'])); $piclist = array(); if (is_array($piclist1)) { foreach ($piclist1 as $p) { $piclist[] = is_array($p) ? $p['attachment'] : $p; } } if ($goods['thumb_url'] != 'N;') { $urls = unserialize($goods['thumb_url']); if (is_array($urls)) { foreach ($urls as $p) { $piclist[] = is_array($p) ? $p['attachment'] : $p; } } } $signPackage = $this->getSignPackage('detail', array('id' => $goods['id']), $_W['attachurl'] . $goods['thumb'], $goods['title']); if (!empty($member_commission) && $goods['isdiscount'] == 1) { $marketprice = $goods['marketprice'] * $member_commission / 100; } else { $marketprice = $goods['marketprice']; } $productprice = $goods['productprice']; $stock = $goods['total']; $allspecs = pdo_fetchall("select * from " . tablename('wwx_fxxt_spec') . " where goodsid=:id order by displayorder asc", array(':id' => $goodsid)); foreach ($allspecs as &$s) { $s['items'] = pdo_fetchall("select * from " . tablename('wwx_fxxt_spec_item') . " where `show`=1 and specid=:specid order by displayorder asc", array(":specid" => $s['id'])); } unset($s); $options = pdo_fetchall("select id,title,thumb,marketprice,productprice,costprice,stock,weight,specs from " . tablename('wwx_fxxt_goods_option') . " where goodsid=:id order by id asc", array(':id' => $goodsid)); $specs = array(); if (count($options) > 0) { foreach ($options as &$ww) { if (!empty($member_commission) && $goods['isdiscount'] == 1) { $ww['marketprice'] = $ww['marketprice'] * $member_commission / 100; } } unset($ww); $specitemids = explode("_", $options[0]['specs']); foreach ($specitemids as $itemid) { foreach ($allspecs as $ss) { $items = $ss['items']; foreach ($items as $it) { if ($it['id'] == $itemid) { $specs[] = $ss; break; } } } } } $params = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_goods_param') . " WHERE goodsid=:goodsid order by displayorder asc", array(":goodsid" => $goods['id'])); $carttotal = $this->getCartTotal(); $rmlist = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_goods') . " WHERE uniacid = '{$_W['uniacid']}' and deleted=0 AND status = '1' and ishot='1' ORDER BY displayorder DESC, sales DESC limit 4 "); include $this->template('detail'); } public function doMobilelistCategory() { global $_GPC, $_W; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); $carttotal = $this->getCartTotal(); $category = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_category') . " WHERE uniacid = '{$_W['uniacid']}' and enabled=1 ORDER BY parentid ASC, displayorder DESC", array(), 'id'); foreach ($category as $index => $row) { if (!empty($row['parentid'])) { $children[$row['parentid']][$row['id']] = $row; unset($category[$index]); } } include $this->template('list_category'); } public function doMobileMyCart() { global $_W, $_GPC; $op = $_GPC['op']; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); $carttotal = $this->getCartTotal(); if (empty($from_user) && !empty($op)) { $result = array('result' => 2, 'message' => '抱歉,您还未登录!'); die(json_encode($result)); } if (!empty($profile['id'])) { $myfansx = pdo_fetch('SELECT member_commission FROM ' . tablename('wwx_fxxt_member_shipgrade') . " WHERE uniacid = :uniacid and displayorder = :displayorder order by member_name desc limit 1", array(':uniacid' => $_W['uniacid'], ':displayorder' => $profile['usergrade'])); if (!empty($myfansx['member_commission'])) { $member_commission = $myfansx['member_commission']; } else { $member_commission = 0; } } if ($op == 'add') { $goodsid = intval($_GPC['id']); $_GPC['total'] = isset($_GPC['total'])?$_GPC['total']:1; $total = intval($_GPC['total']); $total = empty($total) ? 1 : $total; $optionid = intval($_GPC['optionid']); $goods = pdo_fetch("SELECT id,type,total,marketprice,maxbuy,usermaxbuy,isdiscount FROM " . tablename('wwx_fxxt_goods') . " WHERE id = :id", array(':id' => $goodsid)); if (empty($goods)) { $result['message'] = '抱歉,该商品不存在或是已经被删除!'; message($result, '', 'ajax'); } if (!empty($member_commission) && $goods['isdiscount'] == 1) { $marketprice = $goods['marketprice'] * $member_commission / 100; } else { $marketprice = $goods['marketprice']; } if (!empty($optionid)) { $option = pdo_fetch("select marketprice from " . tablename('wwx_fxxt_goods_option') . " where id=:id limit 1", array(":id" => $optionid)); if (!empty($option)) { if (!empty($member_commission) && $goods['isdiscount'] == 1) { $marketprice = $option['marketprice'] * $member_commission / 100; } else { $marketprice = $option['marketprice']; } } } $row = pdo_fetch("SELECT id, total FROM " . tablename('wwx_fxxt_cart') . " WHERE from_user = :from_user AND uniacid = '{$_W['uniacid']}' AND goodsid = :goodsid and optionid=:optionid", array(':from_user' => $from_user, ':goodsid' => $goodsid, ':optionid' => $optionid)); // 检查数量是否合格 $row_total = isset($row['total'])?$row['total']:0; $t = $total + $row_total; if (!empty($goods['maxbuy'])) { if ($t > $goods['maxbuy']) { $result = array('result' => 0, 'maxbuy' =>$goods['maxbuy']); die(json_encode($result)); } } if(!empty($goods['usermaxbuy'])){ // 检查用户最多购买数量 $sql = 'SELECT SUM(`og`.`total`) AS `orderTotal` FROM ' . tablename('wwx_fxxt_order_goods') . ' AS `og` JOIN ' . tablename('wwx_fxxt_order') . ' AS `o` ON `og`.`orderid` = `o`.`id` WHERE `og`.`goodsid` = :goodsid AND `o`.`from_user` = :from_user'; $params = array(':goodsid' => $goodsid, ':from_user' => $from_user); $orderTotal = pdo_fetchcolumn($sql, $params); if ( ($orderTotal + $t) > $goods['usermaxbuy']) { $result = array('result' => 101, 'usermaxbuy' =>$goods['usermaxbuy']); die(json_encode($result)); } } if ($row == false) { $data = array('uniacid' => $_W['uniacid'], 'goodsid' => $goodsid, 'goodstype' => $goods['type'], 'marketprice' => $marketprice, 'from_user' => $from_user, 'total' => $total, 'optionid' => $optionid); pdo_insert('wwx_fxxt_cart', $data); } else { $data = array('marketprice' => $marketprice, 'total' => $t, 'optionid' => $optionid); pdo_update('wwx_fxxt_cart', $data, array('id' => $row['id'])); } $result = array('result' => 1, 'total' => $carttotal,'test'=>$goods['usremaxbuy']); die(json_encode($result)); } else { if ($op == 'clear') { pdo_delete('wwx_fxxt_cart', array('from_user' => $from_user, 'uniacid' => $_W['uniacid'])); die(json_encode(array('result' => 1))); } else { if ($op == 'remove') { $id = intval($_GPC['id']); pdo_delete('wwx_fxxt_cart', array('from_user' => $from_user, 'uniacid' => $_W['uniacid'], 'id' => $id)); die(json_encode(array('result' => 1, 'cartid' => $id))); } else { if ($op == 'update') { $id = intval($_GPC['id']); $num = intval($_GPC['num']); $sql = "update " . tablename('wwx_fxxt_cart') . " set total={$num} where id=:id"; pdo_query($sql, array(":id" => $id)); die(json_encode(array('result' => 1))); } else { $list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_cart') . " WHERE uniacid = '{$_W['uniacid']}' AND from_user = '" . $from_user . "'"); $totalprice = 0; if (!empty($list)) { foreach ($list as &$item) { $goods = pdo_fetch("SELECT title,thumb,marketprice,unit,total,maxbuy,isdiscount FROM " . tablename('wwx_fxxt_goods') . " WHERE id=:id limit 1", array(":id" => $item['goodsid'])); $option = pdo_fetch("select title,marketprice,stock from " . tablename("wwx_fxxt_goods_option") . " where id=:id limit 1", array(":id" => $item['optionid'])); if ($option) { $goods['title'] = $goods['title']; $goods['optionname'] = $option['title']; if (!empty($member_commission) && $goods['isdiscount'] == 1) { $goods['marketprice'] = $option['marketprice'] * $member_commission / 100; } else { $goods['marketprice'] = $option['marketprice']; } $goods['total'] = $option['stock']; } else { if (!empty($member_commission) && $goods['isdiscount'] == 1) { $goods['marketprice'] = $goods['marketprice'] * $member_commission / 100; } } $item['goods'] = $goods; $item['totalprice'] = floatval($goods['marketprice']) * intval($item['total']); $totalprice += $item['totalprice']; } unset($item); } include $this->template('cart'); } } } } } public function doMobileMyOrder() { global $_W, $_GPC; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); $carttotal = $this->getCartTotal(); $cfg = $this->module['config']; $op = $_GPC['op']; $orderid = intval($_GPC['orderid']); $item = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_order') . ' WHERE uniacid = :uniacid AND id = :id AND from_user = :from_user', array(':uniacid' => $_W['uniacid'], ':id' => $orderid, ':from_user' => $from_user)); if ($op == 'cancelsend') { if (empty($item)) { message('抱歉,您的订单不存在或是已经被取消!', $this->createMobileUrl('myorder'), 'error'); } if ($item['paytype'] == 3 && $item['status'] == 1 || $item['status'] == 0) { pdo_update('wwx_fxxt_order', array('status' => -1, 'updatetime' => time()), array('id' => $orderid, 'from_user' => $from_user)); message('订单已关闭!', $this->createMobileUrl('myorder'), 'success'); } if ($item['status'] == 2) { message('商家已发货无法修改订单'); } message('该订单不可取消'); } if ($op == 'returngood') { $dispatch = pdo_fetch('select * from ' . tablename('wwx_fxxt_dispatch') . ' where id=:id limit 1', array(':id' => $item['dispatch'])); if (empty($item)) { message('抱歉,您的订单不存在或是已经被取消!', $this->createMobileUrl('myorder'), 'error'); } if ($item['status'] != 3) { message('订单非完成状态不能申请退货'); } $rebacktime = 1; if (!empty($cfg['rebacktime'])) { $rebacktime = intval($cfg['rebacktime']); } if (!empty($item['updatetime'])) { if ($item['updatetime'] < time() - $rebacktime * 24 * 60 * 60) { message('退货申请时间已过无法退货。'); } } else { message('该订单无法退货'); } $opname = '退货'; $title = '商品退货'; if (checksubmit('submit')) { pdo_update('wwx_fxxt_order', array('status' => -4, 'isrest' => 1, 'rsreson' => $_GPC['rsreson']), array('id' => $orderid, 'from_user' => $from_user)); message('申请退货成功,请等待审核!', $this->createMobileUrl('myorder'), 'success'); } include $this->template('order_detail_return'); die; } if ($op == 'resendgood') { $dispatch = pdo_fetch('select * from ' . tablename('wwx_fxxt_dispatch') . ' where id=:id limit 1', array(':id' => $item['dispatch'])); if (empty($item)) { message('抱歉,您的订单不存在或是已经被取消!', $this->createMobileUrl('myorder'), 'error'); } if ($item['status'] != 3) { message('订单非完成状态不能申请换货'); } $rebacktime = 1; if (!empty($cfg['rebacktime'])) { $rebacktime = intval($cfg['rebacktime']); } if (!empty($item['updatetime'])) { if ($item['updatetime'] < time() - $rebacktime * 24 * 60 * 60) { message('换货申请时间已过无法换货。'); } } else { message('该订单无法退货'); } $opname = '换货'; $title = '商品换货'; if (checksubmit('submit')) { pdo_update('wwx_fxxt_order', array('status' => -3, 'isrest' => 1, 'rsreson' => $_GPC['rsreson']), array('id' => $orderid, 'from_user' => $from_user)); message('申请换货成功,请等待审核!', $this->createMobileUrl('myorder'), 'success'); } include $this->template('order_detail_return'); die; } if ($op == 'returnpay') { $dispatch = pdo_fetch('select * from ' . tablename('wwx_fxxt_dispatch') . ' where id=:id limit 1', array(':id' => $item['dispatch'])); if (empty($item['id'])) { message('抱歉,您的订单不存在或是已经被取消!', $this->createMobileUrl('myorder'), 'error'); } $opname = '退款'; $title = '商品退款'; if (checksubmit('submit')) { if ($item['paytype'] == 3) { message('货到付款订单不能进行退款操作!', referer(), 'error'); } if ($item['status'] != 1) { message('订单非已付款状态不能申请退款'); } pdo_update('wwx_fxxt_order', array('status' => -2, 'rsreson' => $_GPC['rsreson']), array('id' => $orderid, 'from_user' => $from_user)); message('申请退款成功,请等待审核!', $this->createMobileUrl('myorder'), 'success'); } include $this->template('order_detail_return'); die; } elseif ($op == 'confirm') { $order = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_order') . " WHERE id = :id AND from_user = :from_user", array(':id' => $orderid, ':from_user' => $from_user)); if (empty($order)) { message('抱歉,您的订单不存在或是已经被取消!', $this->createMobileUrl('myorder'), 'error'); } if (!empty($orderid) && $order['status'] != 3) { $this->setOrderCredit($orderid, $_W['uniacid']); } pdo_update('wwx_fxxt_order', array('status' => 3, 'updatetime' => time()), array('id' => $orderid, 'from_user' => $from_user)); $tagent = $this->getMember($this->getShareId()); $this->sendxjdlshtz($order['ordersn'], $order['price'], $profile['realname'], $tagent['from_user']); message('确认收货完成!', $this->createMobileUrl('myorder'), 'success'); } else { if ($op == 'detail') { $title = '订单详情'; if (empty($item)) { message('抱歉,您的订单不存或是已经被取消!', $this->createMobileUrl('myorder'), 'error'); } $goodsid = pdo_fetchall("SELECT goodsid,total FROM " . tablename('wwx_fxxt_order_goods') . " WHERE orderid = '{$orderid}'", array(), 'goodsid'); $goods = pdo_fetchall("SELECT g.id, g.goodssn, g.title, g.thumb, g.unit, g.marketprice,o.total,o.optionid FROM " . tablename('wwx_fxxt_order_goods') . " o left join " . tablename('wwx_fxxt_goods') . " g on o.goodsid=g.id " . " WHERE o.orderid='{$orderid}'"); foreach ($goods as &$g) { $option = pdo_fetch("select title,marketprice,weight,stock from " . tablename("wwx_fxxt_goods_option") . " where id=:id limit 1", array(":id" => $g['optionid'])); if ($option) { $g['title'] = "[" . $option['title'] . "]" . $g['title']; $g['marketprice'] = $option['marketprice']; } } unset($g); $dispatch = pdo_fetch("select id,dispatchname,dispatchtype from " . tablename('wwx_fxxt_dispatch') . " where uniacid = '{$_W['uniacid']}' AND id=:id limit 1", array(":id" => $item['dispatch'])); $dispatchtoo = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_dispatch') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY displayorder desc, id DESC", array(), 'id'); $carttotal = $this->getCartTotal(); include $this->template('order_detail'); } else { $title = '我的订单'; $pindex = max(1, intval($_GPC['page'])); $psize = 30; $status = intval($_GPC['status']); $where = " uniacid = '{$_W['uniacid']}' AND from_user = '" . $from_user . "'"; if ($status == -5) { $where .= " AND ( status=-2 or status=-3 or status=-4 )"; } else { if ($status == 3) { $where .= ' AND ( status=-5 or status=-6 or status=3 )'; } else { $where .= " AND status={$status}"; } } $list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_order') . " WHERE {$where} ORDER BY id DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize, array(), 'id'); $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('wwx_fxxt_order') . " WHERE {$where} "); $pager = pagination($total, $pindex, $psize); if (!empty($list)) { foreach ($list as &$row) { $goods = pdo_fetchall("SELECT g.id, g.goodssn, g.title, g.thumb, g.unit, g.marketprice,o.total,o.optionid FROM " . tablename('wwx_fxxt_order_goods') . " o left join " . tablename('wwx_fxxt_goods') . " g on o.goodsid=g.id " . " WHERE o.orderid='{$row['id']}'"); foreach ($goods as &$item) { $option = pdo_fetch("select title,marketprice,weight,stock from " . tablename("wwx_fxxt_goods_option") . " where id=:id limit 1", array(":id" => $item['optionid'])); if ($option) { $item['title'] = "[" . $option['title'] . "]" . $item['title']; $item['marketprice'] = $option['marketprice']; } } unset($item); $row['goods'] = $goods; $row['total'] = $goodsid; $row['dispatch'] = pdo_fetch("select id,dispatchname from " . tablename('wwx_fxxt_dispatch') . " where id=:id limit 1", array(":id" => $row['dispatch'])); } } $fans = pdo_fetch("SELECT fans.openid from_user, fans.follow follow, member.* FROM " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member WHERE fans.uniacid = :uniacid and fans.uid = member.uid and fans.openid = :from_user", array(':uniacid' => $_W['uniacid'], ':from_user' => $from_user)); include $this->template('order'); } } } public function doMobileFansIndex() { global $_W, $_GPC; load()->model('mc'); $uniacid = $_W['uniacid']; $op = $_GPC['op'] ? $_GPC['op'] : 'display'; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); $cfg = $this->module['config']; if (!empty($profile['id'])) { $id = $profile['id']; $profileemail = mc_fetch($_W['member']['uid'], array('email')); $profileemail = $profileemail['email']; if ($profileemail && (substr($profileemail, -9) == '09077.com' && strlen($profileemail) == 42)) { $profileemail = ""; } $count = 0; $msgcount = 0; $msgcount = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('wwx_fxxt_feedback') . " where uniacid='{$_W['uniacid']}' and (backopenid = '{$from_user}' and status = 0)"); $clickcount = $profile['clickcount']; if ($cfg['globalCommissionLevel'] < 2) { $level2enable = ' and 1!=1 '; } if ($cfg['globalCommissionLevel'] < 3) { $level3enable = ' and 1!=1 '; } $condition .= ' AND (shareid = \'' . $profile['id'] . '\' or (shareid2 = \'' . $profile['id'] . "' {$level2enable}) or (shareid3 = '" . $profile['id'] . "' {$level3enable})) AND createtime>=" . $profile['flagtime'] . ' AND from_user<>\'' . $from_user . '\''; $allcount = pdo_fetchcolumn("SELECT count(id) FROM " . tablename('wwx_fxxt_order') . " WHERE uniacid = '{$_W['uniacid']}' {$condition} ORDER BY status ASC, createtime DESC"); } else { $clickcount = 0; $msgcount = 0; $allcount = 0; } if ($profile['flag'] == 0) { $commtime = pdo_fetch("select * from " . tablename('wwx_fxxt_rules') . " where uniacid = " . $_W['uniacid']); $status = " AND status = 3"; if ($commtime['promoterstate'] == 1) { $status = " AND status > 0"; } $total = pdo_fetchcolumn("SELECT count(id) FROM " . tablename('wwx_fxxt_order') . " WHERE uniacid = :uniacid {$status} AND from_user = :from_user", array(':uniacid' => $_W['uniacid'], ':from_user' => $from_user)); $totalmoney = pdo_fetchcolumn("SELECT sum(price) FROM " . tablename('wwx_fxxt_order') . " WHERE uniacid = :uniacid {$status} AND from_user = :from_user", array(':uniacid' => $_W['uniacid'], ':from_user' => $from_user)); $tmsg = '购买一单升级'; if ($commtime['promotercount'] > $total && $commtime['promotertimes'] == 2) { $tmsg = '再购买' . ($commtime['promotercount'] - $total) . '单可升级'; } if ($commtime['promotermoney'] > $totalmoney && $commtime['promotertimes'] == 3) { $tmsg = '再购买' . ($commtime['promotermoney'] - $totalmoney) . '元可升级'; } } $zong = $this->getFromflagsum($from_user, 10); $returnurl = $this->createMobileUrl("fansindex"); include $this->template('newhome'); } public function doMobileHomeHead() { global $_W, $_GPC; $Name = $this->autoNameH(); if ($Name['subscribe'] == 1) { message('头像更新成功!', $this->createMobileUrl('FansIndex'), 'success'); } else { if (strlen($_W['openid']) < 10) { message('非微信端帐号不能使用此功能,请在个人中心使用帐号合并功能!', '', 'error'); } else { $cfg = $this->module['config']; $ydyy = $cfg['ydyy']; if (empty($ydyy)) { message('官方未设置引导关注,请联系管理员!', '', 'error'); } else { header("location:{$ydyy}"); } } } } public function doMobileErwema() { global $_W, $_GPC; $uniacid = $_W['uniacid']; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); $cfg = $this->module['config']; if (empty($_W['openid'])) { message('请先登录', $this->createMobileUrl('login'), 'error'); die; } if ($profile['flag'] == 0 && $cfg['dimensionalcode'] == 0) { message('您还不是代理,不能使用专属二维码功能!', referer(), 'error'); die; } $theone = pdo_fetch('SELECT id,ischeck FROM ' . tablename('wwx_fxxt_rules') . " WHERE uniacid = :uniacid", array(':uniacid' => $_W['uniacid'])); $listdatas = array('mid' => $profile['id'], 'uniacid' => $_W['uniacid'], 'joinway' => 1); if ($theone['ischeck'] == 2 && $profile['dzdflag'] == 1) { $listdatas['dzdid'] = $profile['id']; } $value = $_W['siteroot'] . "app/" . $this->createMobileUrl('list', $listdatas); include $this->template('homeerwema'); } public function doMobileDzd() { global $_W, $_GPC; $title = '设置店中店'; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); $carttotal = $this->getCartTotal(); if (empty($_W['openid'])) { message('请先登录', $this->createMobileUrl('login'), 'error'); die; } if (empty($profile['dzdtitle'])) { $profile['dzdtitle'] = ''; } $operation = $_GPC['op']; if (empty($operation)) { message('非法操作'); } if ($operation == 'setting') { if (checksubmit('submit')) { if (empty($_GPC['dzdsendtext'])) { message('请输入转发话术'); } if (empty($_GPC['dzdtitle'])) { message('请输入店中店名称'); } pdo_update('wwx_fxxt_member', array('dzdsendtext' => $_GPC['dzdsendtext'], 'dzdtitle' => $_GPC['dzdtitle'], 'dzdflag' => $_GPC['dzdauto']), array('id' => $profile['id'])); message('店中店设置成功', $this->createMobileUrl('fansindex'), 'success'); } include $this->template('dzd'); } } public function doMobileBang() { global $_W, $_GPC; $op = $_GPC['op']; $dos = array('mobile'); $op = in_array($op, $dos) ? $op : 'mobile'; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); if (empty($_W['openid'])) { message('请先登录', $this->createMobileUrl('login'), 'error'); die; } load()->model('account'); load()->model('mc'); $notify = uni_setting($_W['uniacid'], array('notify')); $smsbalance = $notify['notify']['sms']['balance']; if ($op == 'mobile') { $_W['page']['title'] = '绑定手机号'; $profilemobile = mc_fetch($_W['member']['uid'], array('mobile')); $mobile_exist = empty($profilemobile['mobile']) ? 0 : 1; if ($_W['ispost'] && $_W['isajax']) { $post = $_GPC['__input']; $mode = $post['mode']; $modes = array('basic', 'code'); $mode = in_array($mode, $modes) ? $mode : 'basic'; $mobile = trim($post['mobile']) ? trim($post['mobile']) : die('请填写新手机号'); if (!preg_match('/^\\d{11}$/', $mobile)) { die('新手机号格式有误'); } if ($mode == 'code') { load()->model('utility'); if (!code_verify($_W['uniacid'], $post['mobile'], $post['password'])) { die('验证码错误.'); } } if ($mobile_exist == 1) { $info = pdo_fetch('SELECT uid FROM ' . tablename('mc_members') . ' WHERE mobile = :mobile AND uniacid = :uniacid AND uid = :uid', array(':mobile' => $post['oldmobile'], ':uniacid' => $_W['uniacid'], ':uid' => $_W['member']['uid'])); if (!empty($info)) { $is_exist = pdo_fetch('SELECT uid FROM ' . tablename('mc_members') . ' WHERE uniacid = :uniacid AND mobile = :mobile AND uid != :uid', array(':uniacid' => $_W['uniacid'], ':mobile' => $mobile, ':uid' => $_W['member']['uid'])); if (!empty($is_exist)) { die('该手机号已被绑定,换个手机号试试'); } else { pdo_update('mc_members', array('mobile' => $mobile), array('uniacid' => $_W['uniacid'], 'uid' => $_W['member']['uid'])); die('success'); } } else { die('原手机号错误'); } } else { $mobile = trim($post['mobile']) ? trim($post['mobile']) : die('请填写手机号'); if (!preg_match('/^\\d{11}$/', $mobile)) { die('手机号格式有误'); } $is_exist = pdo_fetch('SELECT uid FROM ' . tablename('mc_members') . ' WHERE uniacid = :uniacid AND mobile = :mobile AND uid != :uid', array(':uniacid' => $_W['uniacid'], ':mobile' => $mobile, ':uid' => $_W['member']['uid'])); if (!empty($is_exist)) { die('该手机号已被绑定,换个手机号试试'); } pdo_update('mc_members', array('mobile' => $mobile), array('uniacid' => $_W['uniacid'], 'uid' => $_W['member']['uid'])); pdo_update('wwx_fxxt_member', array('mobile' => $mobile), array('uniacid' => $_W['uniacid'], 'from_user' => $from_user)); die('success'); } } } include $this->template('bang'); } public function doMobilemailbox() { global $_W, $_GPC; $op = $_GPC['op']; $dos = array('email'); $op = in_array($op, $dos) ? $op : 'email'; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); if (empty($_W['openid'])) { message('请先登录', $this->createMobileUrl('login'), 'error'); die; } load()->model('account'); load()->model('mc'); $notify = uni_setting($_W['uniacid'], array('notify')); $emailbalance = $notify['notify']['mail']['username']; if ($op == 'email') { $_W['page']['title'] = '绑定邮箱号码'; $profileemail = mc_fetch($_W['member']['uid'], array('email')); $profileemail = $profileemail['email']; if ($profileemail && (substr($profileemail, -9) == '09077.com' && strlen($profileemail) == 42)) { $profileemail = ""; } $email_exist = empty($profileemail) ? 0 : 1; if ($_W['ispost'] && $_W['isajax']) { $post = $_GPC['__input']; $mode = $post['mode']; $modes = array('basic', 'code'); $mode = in_array($mode, $modes) ? $mode : 'basic'; $email = trim($post['email']) ? trim($post['email']) : die('请填写新邮箱号'); if (!preg_match('/^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$/', $email)) { die('新邮箱号格式有误'); } if ($mode == 'code') { load()->model('utility'); if (!code_verify($_W['uniacid'], $post['email'], $post['password'])) { die('验证码错误.'); } } if ($email_exist == 1) { $info = pdo_fetch('SELECT uid FROM ' . tablename('mc_members') . ' WHERE email = :email AND uniacid = :uniacid AND uid = :uid', array(':email' => $post['oldemail'], ':uniacid' => $_W['uniacid'], ':uid' => $_W['member']['uid'])); if (!empty($info)) { $is_exist = pdo_fetch('SELECT uid FROM ' . tablename('mc_members') . ' WHERE uniacid = :uniacid AND email = :email AND uid != :uid', array(':uniacid' => $_W['uniacid'], ':email' => $email, ':uid' => $_W['member']['uid'])); if (!empty($is_exist)) { die('该邮箱号已被绑定,换个邮箱号试试'); } else { pdo_update('mc_members', array('email' => $email), array('uniacid' => $_W['uniacid'], 'uid' => $_W['member']['uid'])); die('success'); } } else { die('原邮箱号错误'); } } else { $email = trim($post['email']) ? trim($post['email']) : die('请填写邮箱号'); if (!preg_match('/^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$/', $email)) { die('邮箱号格式有误'); } $is_exist = pdo_fetch('SELECT uid FROM ' . tablename('mc_members') . ' WHERE uniacid = :uniacid AND email = :email AND uid != :uid', array(':uniacid' => $_W['uniacid'], ':email' => $email, ':uid' => $_W['member']['uid'])); if (!empty($is_exist)) { die('该邮箱号已被绑定,换个邮箱号试试'); } pdo_update('mc_members', array('email' => $email), array('uniacid' => $_W['uniacid'], 'uid' => $_W['member']['uid'])); die('success'); } } } include $this->template('mailbox'); } public function doMobileMyfansDetail() { global $_W, $_GPC; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); if (empty($_W['openid'])) { message('请先登录', $this->createMobileUrl('login'), 'error'); die; } $level = $_GPC['level']; $id = $profile['id']; $flag = $_GPC['flag']; if ($flag == 1) { $flag1 = " and mber1.flag = 1"; $flag2 = " and mber2.flag = 1"; $flag3 = " and mber3.flag = 1"; } elseif ($flag === 0) { $flag1 = " and mber1.flag = 0"; $flag2 = " and mber2.flag = 0"; $flag3 = " and mber3.flag = 0"; } else { $flag1 = ''; $flag2 = ''; $flag3 = ''; } if ($level == '1' || $level == '2' || $level == '3') { $sql1_member = " select mber1.from_user from " . tablename('wwx_fxxt_member') . " mber1 where mber1.realname<>'' and mber1.id!=mber1.shareid {$flag1} and mber1.shareid = " . $id; if ($level == '1') { $pindex = max(1, intval($_GPC['page'])); $psize = 30; $fansall = pdo_fetchall(" select member2.id, member2.flagcount, fans.openid as from_user, fans.follow as follow, fans.followtime as followtime, (select realname from " . tablename('wwx_fxxt_member') . " share where share.id=member2.shareid) as sharerealname, member.* from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " member2 where fans.openid!='{$from_user}' and ( fans.openid in (" . $sql1_member . ") ) and fans.uid=member.uid and fans.openid=member2.from_user and fans.uniacid={$_W['uniacid']} order by member2.flagcount desc limit " . ($pindex - 1) * $psize . "," . $psize); $total = pdo_fetchcolumn(" select count(*) from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " member2 where fans.openid!='{$from_user}' and ( fans.openid in (" . $sql1_member . ") ) and fans.uid=member.uid and fans.openid=member2.from_user and fans.uniacid={$_W['uniacid']}"); $pager = pagination($total, $pindex, $psize); } } if ($level == '2' || $level == '3') { $level2 = "select level2m.id from " . tablename('wwx_fxxt_member') . " level2m where level2m.id!=level2m.shareid and level2m.shareid = " . $id; $sql2_member = "select mber2.from_user from " . tablename('wwx_fxxt_member') . " mber2 where mber2.realname<>'' and mber2.id!=mber2.shareid {$flag2} and mber2.shareid in (" . $level2 . ") "; if ($level == '2') { $pindex = max(1, intval($_GPC['page'])); $psize = 30; $fansall = pdo_fetchall("select member2.id, member2.flagcount, fans.openid as from_user, fans.follow as follow, fans.followtime as followtime, (select realname from " . tablename('wwx_fxxt_member') . " share where share.id=member2.shareid) as sharerealname, member.* from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " member2 where fans.openid!='{$from_user}' and ( fans.openid in (" . $sql2_member . ")) and (fans.openid not in (" . $sql1_member . ") ) and fans.uid=member.uid and fans.openid=member2.from_user and fans.uniacid={$_W['uniacid']} order by member2.flagcount desc limit " . ($pindex - 1) * $psize . "," . $psize); $total = pdo_fetchcolumn("select count(*) from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " member2 where fans.openid!='{$from_user}' and ( fans.openid in (" . $sql2_member . ")) and (fans.openid not in (" . $sql1_member . ") ) and fans.uid=member.uid and fans.openid=member2.from_user and fans.uniacid={$_W['uniacid']}"); $pager = pagination($total, $pindex, $psize); } } if ($level == '3') { $level3 = "select level3m.id from " . tablename('wwx_fxxt_member') . " level3m where level3m.id!=level3m.shareid and level3m.shareid in( " . $level2 . ")"; $sql3_member = "select mber3.from_user from " . tablename('wwx_fxxt_member') . " mber3 where mber3.realname<>'' and mber3.id!=mber3.shareid {$flag3} and mber3.shareid in (" . $level3 . ") "; if ($level == '3') { $pindex = max(1, intval($_GPC['page'])); $psize = 30; $fansall = pdo_fetchall("select member2.id, member2.flagcount, fans.openid as from_user, fans.follow as follow, fans.followtime as followtime, (select realname from " . tablename('wwx_fxxt_member') . " share where share.id=member2.shareid) as sharerealname, member.* from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " member2 where fans.openid!='{$from_user}' and (fans.openid in (" . $sql3_member . ")) and (fans.openid not in (" . $sql1_member . ")) and (fans.openid not in (" . $sql2_member . ")) and fans.uid=member.uid and fans.openid=member2.from_user and fans.uniacid={$_W['uniacid']} order by member2.flagcount desc limit " . ($pindex - 1) * $psize . "," . $psize); $total = pdo_fetchcolumn("select count(*) from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " member2 where fans.openid!='{$from_user}' and (fans.openid in (" . $sql3_member . ")) and (fans.openid not in (" . $sql1_member . ")) and (fans.openid not in (" . $sql2_member . ")) and fans.uid=member.uid and fans.openid=member2.from_user and fans.uniacid={$_W['uniacid']}"); $pager = pagination($total, $pindex, $psize); } } if ($level == '4') { $sql1_member = "select mber1.from_user from " . tablename('wwx_fxxt_member') . " mber1 where mber1.realname<>'' and mber1.id!=mber1.shareid and mber1.shareid = " . $id; $pindex = max(1, intval($_GPC['page'])); $psize = 30; $fansall = pdo_fetchall("select member2.id, member2.flagcount, fans.openid as from_user, fans.follow as follow, fans.followtime as followtime, (select realname from " . tablename('wwx_fxxt_member') . " share where share.id=member2.shareid) as sharerealname, member.* from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " member2 where fans.openid!='{$from_user}' and ( fans.openid in (" . $sql1_member . ") ) and fans.uid=member.uid and fans.openid=member2.from_user and fans.uniacid={$_W['uniacid']} order by member2.flagcount desc limit " . ($pindex - 1) * $psize . "," . $psize); $total = pdo_fetchcolumn("select count(*) from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " member2 where fans.openid!='{$from_user}' and ( fans.openid in (" . $sql1_member . ") ) and fans.uid=member.uid and fans.openid=member2.from_user and fans.uniacid={$_W['uniacid']}"); $pager = pagination($total, $pindex, $psize); } if ($level == '5') { $sql1_member = "select mber1.from_user from " . tablename('wwx_fxxt_member') . " mber1 where mber1.realname<>'' and mber1.id!=mber1.shareid and mber1.shareid = " . $id; $pindex = max(1, intval($_GPC['page'])); $psize = 30; $fansall = pdo_fetchall("select member2.id, member2.flagcount, fans.openid as from_user, fans.follow as follow, fans.followtime as followtime, (select realname from " . tablename('wwx_fxxt_member') . " share where share.id=member2.shareid) as sharerealname, member.* from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " member2 where fans.follow=1 and fans.openid!='{$from_user}' and ( fans.openid in (" . $sql1_member . ") ) and fans.uid=member.uid and fans.openid=member2.from_user and fans.uniacid={$_W['uniacid']} order by member2.flagcount desc limit " . ($pindex - 1) * $psize . "," . $psize); $total = pdo_fetchcolumn("select count(*) from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " member2 where fans.follow=1 and fans.openid!='{$from_user}' and ( fans.openid in (" . $sql1_member . ") ) and fans.uid=member.uid and fans.openid=member2.from_user and fans.uniacid={$_W['uniacid']}"); $pager = pagination($total, $pindex, $psize); } include $this->template('myfansDetail'); } public function doMobileFansorder() { global $_W, $_GPC; $uniacid = $_W['uniacid']; $op = $_GPC['op'] ? $_GPC['op'] : 'display'; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); $cfg = $this->module['config']; if (empty($_W['openid'])) { message('请先登录', $this->createMobileUrl('login'), 'error'); die; } if ($cfg['globalCommissionLevel'] < 2) { $level2enable = ' and 1!=1 '; } if ($cfg['globalCommissionLevel'] < 3) { $level3enable = ' and 1!=1 '; } $status = 0; $condition = ''; $condition .= ' '; $user = pdo_fetch("select * from " . tablename('wwx_fxxt_member') . " where id = " . $profile['id'] . " and uniacid = " . $_W['uniacid']); $conditionx = ' '; $condition1 = $conditionx . ' AND (o.shareid = \'' . $profile['id'] . '\') AND o.createtime>=' . $profile['flagtime'] . ' AND o.from_user<>\'' . $from_user . '\''; $condition2 = $conditionx . ' AND (o.shareid2 = \'' . $profile['id'] . '\') AND o.createtime>=' . $profile['flagtime'] . " {$level2enable} AND o.from_user<>'" . $from_user . '\''; $condition3 = $conditionx . ' AND (o.shareid3 = \'' . $profile['id'] . '\') AND o.createtime>=' . $profile['flagtime'] . " {$level3enable} AND o.from_user<>'" . $from_user . '\''; $condition .= ' AND (shareid = \'' . $profile['id'] . '\' or (shareid2 = \'' . $profile['id'] . "' {$level2enable}) or (shareid3 = '" . $profile['id'] . "' {$level3enable})) AND createtime>=" . $profile['flagtime'] . ' AND from_user<>\'' . $from_user . '\''; $conditionMember = 'select m.realname from ' . tablename('wwx_fxxt_member') . ' m where m.from_user=o.from_user and m.uniacid=' . $_W['uniacid']; $pindex = max(1, intval($_GPC['page'])); $psize = 30; $list = pdo_fetchall("SELECT o.*,'' as commissions,1 as level,( {$conditionMember}) realname FROM " . tablename('wwx_fxxt_order') . " o WHERE o.uniacid = '{$_W['uniacid']}' {$condition1} union all (SELECT o.*,'' as commissions,2 as level,( {$conditionMember}) realname FROM " . tablename('wwx_fxxt_order') . " o WHERE o.uniacid = '{$_W['uniacid']}' {$condition2} ) union all (SELECT o.*,'' as commissions,3 as level,( {$conditionMember}) realname FROM " . tablename('wwx_fxxt_order') . " o WHERE o.uniacid = '{$_W['uniacid']}' {$condition3} ) ORDER BY createtime DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize); $listx = pdo_fetchall("SELECT o.*,'' as commissions,1 as level,( {$conditionMember}) realname FROM " . tablename('wwx_fxxt_order') . " o WHERE o.uniacid = '{$_W['uniacid']}' {$condition1} union all (SELECT o.*,'' as commissions,2 as level,( {$conditionMember}) realname FROM " . tablename('wwx_fxxt_order') . " o WHERE o.uniacid = '{$_W['uniacid']}' {$condition2} ) union all (SELECT o.*,'' as commissions,3 as level,( {$conditionMember}) realname FROM " . tablename('wwx_fxxt_order') . " o WHERE o.uniacid = '{$_W['uniacid']}' {$condition3} ) "); $total = sizeof($listx); $pager = pagination($total, $pindex, $psize); $allcount = pdo_fetchcolumn("SELECT count(id) FROM " . tablename('wwx_fxxt_order') . " WHERE uniacid = '{$_W['uniacid']}' {$condition} ORDER BY status ASC, createtime DESC"); $countYestay = pdo_fetchcolumn("SELECT count(id) FROM " . tablename('wwx_fxxt_order') . " WHERE uniacid = '{$_W['uniacid']}' {$condition} and createtime>=" . strtotime(date('Y-m-d 00:00:00', strtotime('-1 day'))) . " and createtime<=" . strtotime(date('Y-m-d 23:59:59', strtotime('-1 day'))) . " ORDER BY status ASC, createtime DESC"); $countToday = pdo_fetchcolumn("SELECT count(id) FROM " . tablename('wwx_fxxt_order') . " WHERE uniacid = '{$_W['uniacid']}' {$condition} and createtime>=" . strtotime(date('Y-m-d 00:00:00', strtotime('0 day'))) . " and createtime<=" . strtotime(date('Y-m-d 23:59:59', strtotime('0 day'))) . " ORDER BY status ASC, createtime DESC"); if (!empty($list)) { foreach ($list as $key => $l) { $commissions = pdo_fetchall('select *,\'\' as title,\'\' as thumb from ' . tablename('wwx_fxxt_order_goods') . ' where orderid = ' . $l['id']); foreach ($commissions as $comkey => $commission) { $goods = pdo_fetch('select title,thumb from ' . tablename('wwx_fxxt_goods') . ' where id = ' . $commission['goodsid']); $commissions[$comkey]['thumb'] = $goods['thumb']; $commissions[$comkey]['title'] = $goods['title']; if ($l['level'] == 1) { $commissions[$comkey]['commission'] = $commission['commission'] * $commission['total']; } if ($l['level'] == 2) { $commissions[$comkey]['commission'] = $commission['commission2'] * $commission['total']; } if ($l['level'] == 3) { $commissions[$comkey]['commission'] = $commission['commission3'] * $commission['total']; } } unset($comkey); $list[$key]['commissions'] = $commissions; } } if (!empty($list)) { foreach ($list as &$row) { !empty($row['addressid']) && ($addressids[$row['addressid']] = $row['addressid']); $row['dispatch'] = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_dispatch') . ' WHERE id = :id', array(':id' => $row['dispatch'])); } unset($row); } if (!empty($addressids)) { $address = pdo_fetchall('SELECT * FROM ' . tablename('wwx_fxxt_address') . ' WHERE id IN (\'' . implode('\',\'', $addressids) . '\')', array(), 'id'); } include $this->template('fansorder'); } public function doMobileCommission() { global $_W, $_GPC; $uniacid = $_W['uniacid']; $op = $_GPC['op'] ? $_GPC['op'] : 'display'; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); $cfg = $this->module['config']; if (empty($_W['openid'])) { message('请先登录', $this->createMobileUrl('login'), 'error'); die; } $carttotal = $this->getCartTotal(); if ($cfg['globalCommissionLevel'] < 2) { $level2enable = ' and 1!=1 '; } if ($cfg['globalCommissionLevel'] < 3) { $level3enable = ' and 1!=1 '; } if ($op == 'display') { $commtime = time(); $title = '佣金提现'; if (!empty($cfg['commtime'])) { $commtime = time() - intval($cfg['commtime']) * 24 * 60 * 60; } $commissioningpewhere = ' and (o.updatetime=0 or (o.updatetime>0 and o.updatetime<' . $commtime . '))'; $commissioningpe = pdo_fetchcolumn('SELECT sum((g.commission*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE ((o.shareid = ' . $profile['id'] . " and g.status = 0) ) {$commissioningpewhere} and o.uniacid = " . $_W['uniacid'] . ' and o.status >= 3 and o.from_user != \'' . $from_user . '\' and g.createtime>=' . $profile['flagtime']); $commissioningpex2 = pdo_fetchcolumn('SELECT sum((g.commission2*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE ((o.shareid2 = ' . $profile['id'] . " and g.status2 = 0) ) {$commissioningpewhere} and o.uniacid = " . $_W['uniacid'] . " and o.status >= 3 {$level2enable} and o.from_user != '" . $from_user . '\' and g.createtime>=' . $profile['flagtime']); $commissioningpex3 = pdo_fetchcolumn('SELECT sum((g.commission3*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE ((o.shareid3 = ' . $profile['id'] . " and g.status3 = 0) ) {$commissioningpewhere} and o.uniacid = " . $_W['uniacid'] . " and o.status >= 3 {$level3enable} and o.from_user != '" . $from_user . '\' and g.createtime>=' . $profile['flagtime']); if (empty($commissioningpe)) { $commissioningpe = 0; } if (empty($commissioningpex2)) { $commissioningpex2 = 0; } if (empty($commissioningpex3)) { $commissioningpex3 = 0; } $commissioningpe = $commissioningpe + $commissioningpex2 + $commissioningpex3; if ($commissioningpe == 0) { $commissioningpe = '0.00'; } $commission1_1 = pdo_fetchcolumn('SELECT sum((g.commission*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE ((o.shareid = ' . $profile['id'] . ' and g.status=-1)) and o.uniacid = ' . $_W['uniacid'] . ' and o.status =3 and o.from_user != \'' . $from_user . '\' and g.createtime>=' . $profile['flagtime']); $commission1_1x2 = pdo_fetchcolumn('SELECT sum((g.commission2*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE ((o.shareid2 = ' . $profile['id'] . ' and g.status2=-1)) and o.uniacid = ' . $_W['uniacid'] . " and o.status =3 {$level2enable} and o.from_user != '" . $from_user . '\' and g.createtime>=' . $profile['flagtime']); $commission1_1x3 = pdo_fetchcolumn('SELECT sum((g.commission3*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE ((o.shareid3 = ' . $profile['id'] . ' and g.status3=-1)) and o.uniacid = ' . $_W['uniacid'] . " and o.status =3 {$level3enable} and o.from_user != '" . $from_user . '\' and g.createtime>=' . $profile['flagtime']); if (empty($commission1_1)) { $commission1_1 = 0; } if (empty($commission1_1x2)) { $commission1_1x2 = 0; } if (empty($commission1_1x3)) { $commission1_1x3 = 0; } $commission1_1 = $commission1_1 + $commission1_1x2 + $commission1_1x3; if ($commission1_1 == 0) { $commission1_1 = '0.00'; } $commission2_1 = pdo_fetchcolumn('SELECT sum((g.commission*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE ((o.shareid = ' . $profile['id'] . ' and g.status=1)) and o.uniacid = ' . $_W['uniacid'] . ' and o.status =3 and o.from_user != \'' . $from_user . '\' and g.createtime>=' . $profile['flagtime']); $commission2_1x2 = pdo_fetchcolumn('SELECT sum((g.commission2*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE ((o.shareid2 = ' . $profile['id'] . ' and g.status2=1)) and o.uniacid = ' . $_W['uniacid'] . " and o.status =3 {$level2enable} and o.from_user != '" . $from_user . '\' and g.createtime>=' . $profile['flagtime']); $commission2_1x3 = pdo_fetchcolumn('SELECT sum((g.commission3*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE ((o.shareid3 = ' . $profile['id'] . ' and g.status3=1)) and o.uniacid = ' . $_W['uniacid'] . " and o.status =3 {$level3enable} and o.from_user != '" . $from_user . '\' and g.createtime>=' . $profile['flagtime']); if (empty($commission2_1)) { $commission2_1 = 0; } if (empty($commission2_1x2)) { $commission2_1x2 = 0; } if (empty($commission2_1x3)) { $commission2_1x3 = 0; } $commission2_1 = $commission2_1 + $commission2_1x2 + $commission2_1x3; if ($commission2_1 == 0) { $commission2_1 = '0.00'; } $commission4 = pdo_fetchcolumn("SELECT sum(price) FROM " . tablename('wwx_fxxt_order') . " WHERE shareid = '{$profile['id']}' AND uniacid = '{$_W['uniacid']}' AND from_user != '{$from_user}' AND ((paytype=3 and (status =0 or status =1)) or ((paytype=1 or paytype=2 ) and status =0))"); $commission4x2 = pdo_fetchcolumn("SELECT sum(price) FROM " . tablename('wwx_fxxt_order') . " WHERE shareid2 = '{$profile['id']}' AND uniacid = '{$_W['uniacid']}' AND from_user != '{$from_user}' AND ((paytype=3 and (status =0 or status =1)) or ((paytype=1 or paytype=2 ) and status =0)) {$level2enable}"); $commission4x3 = pdo_fetchcolumn("SELECT sum(price) FROM " . tablename('wwx_fxxt_order') . " WHERE shareid3 = '{$profile['id']}' AND uniacid = '{$_W['uniacid']}' AND from_user != '{$from_user}' AND ((paytype=3 and (status =0 or status =1)) or ((paytype=1 or paytype=2 ) and status =0)) {$level2enable}"); if (empty($commission4)) { $commission4 = 0; } if (empty($commission4x2)) { $commission4x2 = 0; } if (empty($commission4x3)) { $commission4x3 = 0; } $commission4 = $commission4 + $commission4x2 + $commission4x3; if ($commission4 == 0) { $commission4 = '0.00'; } $commission4_1 = pdo_fetchcolumn('SELECT sum((g.commission*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE (o.shareid = ' . $profile['id'] . ') and o.uniacid = ' . $_W['uniacid'] . ' and ( (o.paytype=3 and (o.status =0 or o.status =1)) or ((o.paytype=1 or o.paytype=2 ) and o.status =0)) and o.from_user != \'' . $from_user . '\' and g.createtime>=' . $profile['flagtime']); $commission4_1x2 = pdo_fetchcolumn('SELECT sum((g.commission2*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE (o.shareid2 = ' . $profile['id'] . ') and o.uniacid = ' . $_W['uniacid'] . " and ( (o.paytype=3 and (o.status =0 or o.status =1)) or ((o.paytype=1 or o.paytype=2 ) and o.status =0)) {$level2enable} and o.from_user != '" . $from_user . '\' and g.createtime>=' . $profile['flagtime']); $commission4_1x3 = pdo_fetchcolumn('SELECT sum((g.commission3*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE (o.shareid3 = ' . $profile['id'] . ') and o.uniacid = ' . $_W['uniacid'] . " and ( (o.paytype=3 and (o.status =0 or o.status =1)) or ((o.paytype=1 or o.paytype=2 ) and o.status =0)) {$level3enable} and o.from_user != '" . $from_user . '\' and g.createtime>=' . $profile['flagtime']); if (empty($commission4_1)) { $commission4_1 = 0; } if (empty($commission4_1x2)) { $commission4_1x2 = 0; } if (empty($commission4_1x3)) { $commission4_1x3 = 0; } $commission4_1 = $commission4_1 + $commission4_1x2 + $commission4_1x3; if ($commission4_1 == 0) { $commission4_1 = '0.00'; } $commission5 = pdo_fetchcolumn("SELECT sum(price) FROM " . tablename('wwx_fxxt_order') . " WHERE shareid = '{$profile['id']}' AND uniacid = '{$_W['uniacid']}' AND from_user != '{$from_user}' AND ((paytype=3 and (status =3)) or ((paytype=1 or paytype=2 ) and status =1))"); $commission5x2 = pdo_fetchcolumn("SELECT sum(price) FROM " . tablename('wwx_fxxt_order') . " WHERE shareid2 = '{$profile['id']}' AND uniacid = '{$_W['uniacid']}' AND from_user != '{$from_user}' AND ((paytype=3 and (status =3)) or ((paytype=1 or paytype=2 ) and status =1)) {$level2enable}"); $commission5x3 = pdo_fetchcolumn("SELECT sum(price) FROM " . tablename('wwx_fxxt_order') . " WHERE shareid3 = '{$profile['id']}' AND uniacid = '{$_W['uniacid']}' AND from_user != '{$from_user}' AND ((paytype=3 and (status =3)) or ((paytype=1 or paytype=2 ) and status =1)) {$level3enable}"); if (empty($commission5)) { $commission5 = 0; } if (empty($commission5x2)) { $commission5x2 = 0; } if (empty($commission5x3)) { $commission5x3 = 0; } $commission5 = $commission5 + $commission5x2 + $commission5x3; if ($commission5 == 0) { $commission5 = '0.00'; } $commission5_1 = pdo_fetchcolumn('SELECT sum((g.commission*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE (o.shareid = ' . $profile['id'] . ') and o.uniacid = ' . $_W['uniacid'] . ' and ( (o.paytype=3 and (o.status =3)) or ((o.paytype=1 or o.paytype=2 ) and o.status =1)) and o.from_user != \'' . $from_user . '\' and g.createtime>=' . $profile['flagtime']); $commission5_1x2 = pdo_fetchcolumn('SELECT sum((g.commission2*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE (o.shareid2 = ' . $profile['id'] . ') and o.uniacid = ' . $_W['uniacid'] . " and ( (o.paytype=3 and (o.status =3)) or ((o.paytype=1 or o.paytype=2 ) and o.status =1)) {$level2enable} and o.from_user != '" . $from_user . '\' and g.createtime>=' . $profile['flagtime']); $commission5_1x3 = pdo_fetchcolumn('SELECT sum((g.commission3*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE (o.shareid3 = ' . $profile['id'] . ') and o.uniacid = ' . $_W['uniacid'] . " and ( (o.paytype=3 and (o.status =3)) or ((o.paytype=1 or o.paytype=2 ) and o.status =1)) {$level3enable} and o.from_user != '" . $from_user . '\' and g.createtime>=' . $profile['flagtime']); if (empty($commission5_1)) { $commission5_1 = 0; } if (empty($commission5_1x2)) { $commission5_1x2 = 0; } if (empty($commission5_1x3)) { $commission5_1x3 = 0; } $commission5_1 = $commission5_1 + $commission5_1x2 + $commission5_1x3; if ($commission5_1 == 0) { $commission5_1 = '0.00'; } $commission6 = pdo_fetchcolumn("SELECT sum(price) FROM " . tablename('wwx_fxxt_order') . " WHERE shareid = '{$profile['id']}' AND uniacid = '{$_W['uniacid']}' AND from_user != '{$from_user}' AND ((paytype=3 and (status =2)) or ((paytype=1 or paytype=2 ) and status =2))"); $commission6x2 = pdo_fetchcolumn("SELECT sum(price) FROM " . tablename('wwx_fxxt_order') . " WHERE shareid2 = '{$profile['id']}' AND uniacid = '{$_W['uniacid']}' AND from_user != '{$from_user}' AND ((paytype=3 and (status =2)) or ((paytype=1 or paytype=2 ) and status =2)) {$level2enable}"); $commission6x3 = pdo_fetchcolumn("SELECT sum(price) FROM " . tablename('wwx_fxxt_order') . " WHERE shareid3 = '{$profile['id']}' AND uniacid = '{$_W['uniacid']}' AND from_user != '{$from_user}' AND ((paytype=3 and (status =2)) or ((paytype=1 or paytype=2 ) and status =2)) {$level3enable}"); if (empty($commission6)) { $commission6 = 0; } if (empty($commission6x2)) { $commission6x2 = 0; } if (empty($commission6x3)) { $commission6x3 = 0; } $commission6 = $commission6 + $commission6x2 + $commission6x3; if ($commission6 == 0) { $commission6 = '0.00'; } $commission6_1 = pdo_fetchcolumn('SELECT sum((g.commission*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE (o.shareid = ' . $profile['id'] . ') and o.uniacid = ' . $_W['uniacid'] . ' and ( (o.paytype=3 and (o.status =2)) or ((o.paytype=1 or o.paytype=2 ) and o.status =2)) and o.from_user != \'' . $from_user . '\' and g.createtime>=' . $profile['flagtime']); $commission6_1x2 = pdo_fetchcolumn('SELECT sum((g.commission2*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE (o.shareid2 = ' . $profile['id'] . ') and o.uniacid = ' . $_W['uniacid'] . " and ( (o.paytype=3 and (o.status =2)) or ((o.paytype=1 or o.paytype=2 ) and o.status =2)) {$level2enable} and o.from_user != '" . $from_user . '\' and g.createtime>=' . $profile['flagtime']); $commission6_1x3 = pdo_fetchcolumn('SELECT sum((g.commission3*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE (o.shareid3 = ' . $profile['id'] . ') and o.uniacid = ' . $_W['uniacid'] . " and ( (o.paytype=3 and (o.status =2)) or ((o.paytype=1 or o.paytype=2 ) and o.status =2)) {$level3enable} and o.from_user != '" . $from_user . '\' and g.createtime>=' . $profile['flagtime']); if (empty($commission6_1)) { $commission6_1 = 0; } if (empty($commission6_1x2)) { $commission6_1x2 = 0; } if (empty($commission6_1x3)) { $commission6_1x3 = 0; } $commission6_1 = $commission6_1 + $commission6_1x2 + $commission6_1x3; if ($commission6_1 == 0) { $commission6_1 = '0.00'; } $commission7 = pdo_fetchcolumn("SELECT sum(price) FROM " . tablename('wwx_fxxt_order') . " WHERE shareid = '{$profile['id']}' AND uniacid = '{$_W['uniacid']}' AND from_user != '{$from_user}' AND status =3"); $commission7x2 = pdo_fetchcolumn("SELECT sum(price) FROM " . tablename('wwx_fxxt_order') . " WHERE shareid2 = '{$profile['id']}' AND uniacid = '{$_W['uniacid']}' AND from_user != '{$from_user}' AND status =3 {$level2enable}"); $commission7x3 = pdo_fetchcolumn("SELECT sum(price) FROM " . tablename('wwx_fxxt_order') . " WHERE shareid3 = '{$profile['id']}' AND uniacid = '{$_W['uniacid']}' AND from_user != '{$from_user}' AND status =3 {$level3enable}"); if (empty($commission7)) { $commission7 = 0; } if (empty($commission7x2)) { $commission7x2 = 0; } if (empty($commission7x3)) { $commission7x3 = 0; } $commission7 = $commission7 + $commission7x2 + $commission7x3; if ($commission7 == 0) { $commission7 = '0.00'; } $commission7_1 = pdo_fetchcolumn('SELECT sum((g.commission*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE (o.shareid = ' . $profile['id'] . ') and o.uniacid = ' . $_W['uniacid'] . ' and o.status =3 and o.from_user != \'' . $from_user . '\' and g.createtime>=' . $profile['flagtime']); $commission7_1x2 = pdo_fetchcolumn('SELECT sum((g.commission2*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE (o.shareid2 = ' . $profile['id'] . ') and o.uniacid = ' . $_W['uniacid'] . " and o.status =3 {$level2enable} and o.from_user != '" . $from_user . '\' and g.createtime>=' . $profile['flagtime']); $commission7_1x3 = pdo_fetchcolumn('SELECT sum((g.commission3*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE (o.shareid3 = ' . $profile['id'] . ') and o.uniacid = ' . $_W['uniacid'] . " and o.status =3 {$level3enable} and o.from_user != '" . $from_user . '\' and g.createtime>=' . $profile['flagtime']); if (empty($commission7_1)) { $commission7_1 = 0; } if (empty($commission7_1x2)) { $commission7_1x2 = 0; } if (empty($commission7_1x3)) { $commission7_1x3 = 0; } $commission7_1 = $commission7_1 + $commission7_1x2 + $commission7_1x3; if ($commission7_1 == 0) { $commission7_1 = '0.00'; } $commission8 = pdo_fetchcolumn("SELECT sum(price) FROM " . tablename('wwx_fxxt_order') . " WHERE shareid = '{$profile['id']}' AND uniacid = '{$_W['uniacid']}' AND from_user != '{$from_user}' AND (status >=0 AND status !=3)"); $commission8x2 = pdo_fetchcolumn("SELECT sum(price) FROM " . tablename('wwx_fxxt_order') . " WHERE shareid2 = '{$profile['id']}' AND uniacid = '{$_W['uniacid']}' AND from_user != '{$from_user}' AND (status >=0 AND status !=3) {$level2enable}"); $commission8x3 = pdo_fetchcolumn("SELECT sum(price) FROM " . tablename('wwx_fxxt_order') . " WHERE shareid3 = '{$profile['id']}' AND uniacid = '{$_W['uniacid']}' AND from_user != '{$from_user}' AND (status >=0 AND status !=3) {$level3enable}"); if (empty($commission8)) { $commission8 = 0; } if (empty($commission8x2)) { $commission8x2 = 0; } if (empty($commission8x3)) { $commission8x3 = 0; } $commission8 = $commission8 + $commission8x2 + $commission8x3; if ($commission8 == 0) { $commission8 = '0.00'; } $commission8_1 = pdo_fetchcolumn('SELECT sum((g.commission*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE (o.shareid = ' . $profile['id'] . ') and o.uniacid = ' . $_W['uniacid'] . ' and (o.status >=0 AND o.status !=3) and o.from_user != \'' . $from_user . '\' and g.createtime>=' . $profile['flagtime']); $commission8_1x2 = pdo_fetchcolumn('SELECT sum((g.commission2*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE (o.shareid2 = ' . $profile['id'] . ') and o.uniacid = ' . $_W['uniacid'] . " and (o.status >=0 AND o.status !=3) {$level2enable} and o.from_user != '" . $from_user . '\' and g.createtime>=' . $profile['flagtime']); $commission8_1x3 = pdo_fetchcolumn('SELECT sum((g.commission3*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE (o.shareid3 = ' . $profile['id'] . ') and o.uniacid = ' . $_W['uniacid'] . " and (o.status >=0 AND o.status !=3) {$level3enable} and o.from_user != '" . $from_user . '\' and g.createtime>=' . $profile['flagtime']); if (empty($commission8_1)) { $commission8_1 = 0; } if (empty($commission8_1x2)) { $commission8_1x2 = 0; } if (empty($commission8_1x3)) { $commission8_1x3 = 0; } $commission8_1 = $commission8_1 + $commission8_1x2 + $commission8_1x3; if ($commission8_1 == 0) { $commission8_1 = '0.00'; } $commissioned = $profile['commission']; } if ($op == 'commissionDetail') { $pindex = max(1, intval($_GPC['page'])); $psize = 30; $condition = ' '; $condition1 = $condition . ' AND (orders.shareid = \'' . $profile['id'] . '\') AND orders.createtime>=' . $profile['flagtime'] . ' AND orders.from_user<>\'' . $from_user . '\''; $condition2 = $condition . ' AND (orders.shareid2 = \'' . $profile['id'] . '\') AND orders.createtime>=' . $profile['flagtime'] . " {$level2enable} AND orders.from_user<>'" . $from_user . '\''; $condition3 = $condition . ' AND (orders.shareid3 = \'' . $profile['id'] . '\') AND orders.createtime>=' . $profile['flagtime'] . " {$level3enable} AND orders.from_user<>'" . $from_user . '\''; $conditionMember = 'select m.realname from ' . tablename('wwx_fxxt_member') . ' m where m.from_user=orders.from_user and m.uniacid=' . $_W['uniacid']; $list = pdo_fetchall("SELECT 1 as level,orders.status,orders.createtime,orders.ordersn,bjog.status as status1,bjog.commission*bjog.total as commission,( {$conditionMember}) realname FROM " . tablename('wwx_fxxt_order') . ' orders left join ' . tablename('wwx_fxxt_order_goods') . " bjog on bjog.orderid=orders.id WHERE orders.uniacid = '{$_W['uniacid']}' and bjog.commission!=0 {$condition1} union all (SELECT 2 as level,orders.status,orders.createtime,orders.ordersn,bjog.status2 as status1,bjog.commission2*bjog.total as commission,( {$conditionMember}) realname FROM " . tablename('wwx_fxxt_order') . ' orders left join ' . tablename('wwx_fxxt_order_goods') . " bjog on bjog.orderid=orders.id WHERE orders.uniacid = '{$_W['uniacid']}' and bjog.commission!=0 {$condition2}) union all(SELECT 3 as level,orders.status,orders.createtime,orders.ordersn,bjog.status3 as status1,bjog.commission3*bjog.total as commission,( {$conditionMember}) realname FROM " . tablename('wwx_fxxt_order') . ' orders left join ' . tablename('wwx_fxxt_order_goods') . " bjog on bjog.orderid=orders.id WHERE orders.uniacid = '{$_W['uniacid']}' and bjog.commission!=0 {$condition3}) ORDER BY createtime DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize); $listx = pdo_fetchall("SELECT 1 as level,orders.status,orders.createtime,orders.ordersn,bjog.status as status1,bjog.commission*bjog.total as commission,( {$conditionMember}) realname FROM " . tablename('wwx_fxxt_order') . ' orders left join ' . tablename('wwx_fxxt_order_goods') . " bjog on bjog.orderid=orders.id WHERE orders.uniacid = '{$_W['uniacid']}' and bjog.commission!=0 {$condition1} union all (SELECT 2 as level,orders.status,orders.createtime,orders.ordersn,bjog.status2 as status1,bjog.commission2*bjog.total as commission,( {$conditionMember}) realname FROM " . tablename('wwx_fxxt_order') . ' orders left join ' . tablename('wwx_fxxt_order_goods') . " bjog on bjog.orderid=orders.id WHERE orders.uniacid = '{$_W['uniacid']}' and bjog.commission!=0 {$condition2}) union all(SELECT 3 as level,orders.status,orders.createtime,orders.ordersn,bjog.status3 as status1,bjog.commission3*bjog.total as commission,( {$conditionMember}) realname FROM " . tablename('wwx_fxxt_order') . ' orders left join ' . tablename('wwx_fxxt_order_goods') . " bjog on bjog.orderid=orders.id WHERE orders.uniacid = '{$_W['uniacid']}' and bjog.commission!=0 {$condition3}) "); $total = sizeof($listx); $pager = pagination($total, $pindex, $psize); $list2 = pdo_fetchall("SELECT * FROM " . tablename('core_paylog') . " WHERE openid='" . $from_user . "' AND type='zhifu' AND uniacid=" . $_W['uniacid'] . " ORDER BY plid DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize); $total2 = pdo_fetchcolumn("SELECT count(*) FROM " . tablename('core_paylog') . " WHERE openid='" . $from_user . "' AND type='zhifu' AND uniacid=" . $_W['uniacid']); $pager2 = pagination($total2, $pindex, $psize); include $this->template('page_commissionDetail'); die; } if ($op == 'commapply') { $bankcard = pdo_fetch("select id,bankcard,banktype,alipay,wxhao from " . tablename('wwx_fxxt_member') . " where uniacid = " . $_W['uniacid'] . " and from_user = '" . $from_user . "'"); if (empty($bankcard['bankcard']) || empty($bankcard['banktype'])) { message('请先完善银行卡信息!', $this->createMobileUrl('profile', array('id' => $bankcard['id'], 'opp' => 'complated')), 'error'); } $commtime = time(); if (!empty($cfg['commtime'])) { $commtime = time() - intval($cfg['commtime']) * 24 * 60 * 60; } $commissioningpewhere = ' and (o.updatetime=0 or (o.updatetime>0 and o.updatetime<' . $commtime . '))'; $commissioningpelist2where = ' and (orders.updatetime=0 or(orders.updatetime>0 and orders.updatetime<' . $commtime . ') )'; $commissioningpe = pdo_fetchcolumn('SELECT sum((g.commission*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE ((o.shareid = ' . $profile['id'] . " and g.status = 0) ) \t{$commissioningpewhere} and o.uniacid = " . $_W['uniacid'] . ' and o.status >= 3 and o.from_user != \'' . $from_user . '\' and g.createtime>=' . $profile['flagtime']); $commissioningpex2 = pdo_fetchcolumn('SELECT sum((g.commission2*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE ((o.shareid2 = ' . $profile['id'] . " and g.status2 = 0) ) \t{$commissioningpewhere} and o.uniacid = " . $_W['uniacid'] . " and o.status >= 3 {$level2enable} and o.from_user != '" . $from_user . '\' and g.createtime>=' . $profile['flagtime']); $commissioningpex3 = pdo_fetchcolumn('SELECT sum((g.commission3*g.total)) FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE ((o.shareid3 = ' . $profile['id'] . " and g.status3 = 0) ) \t{$commissioningpewhere} and o.uniacid = " . $_W['uniacid'] . " and o.status >= 3 {$level3enable} and o.from_user != '" . $from_user . '\' and g.createtime>=' . $profile['flagtime']); if (empty($commissioningpex3)) { $commissioningpex3 = 0; } if (empty($commissioningpex2)) { $commissioningpex2 = 0; } if (empty($commissioningpe)) { $commissioningpe = 0; } $commissioningpe = $commissioningpe + $commissioningpex2 + $commissioningpex3; if ($commissioningpe == 0) { $commissioningpe = '0.00'; } $zhifucommission = $cfg['zhifuCommission']; if ($commissioningpe < $zhifucommission || commissioningpe == '0.00') { message('您还未满足打款金额:' . $zhifucommission . '元!', referer(), 'error'); } $conditionMember = 'select m.realname from ' . tablename('wwx_fxxt_member') . ' m where m.from_user=orders.from_user and m.uniacid=' . $_W['uniacid']; $list2 = pdo_fetchall("SELECT 1 as level,orders.status,orders.createtime,orders.ordersn,bjog.status as status1,bjog.commission*bjog.total as commission,( {$conditionMember}) realname FROM " . tablename('wwx_fxxt_order') . ' orders left join ' . tablename('wwx_fxxt_order_goods') . ' bjog on bjog.orderid=orders.id WHERE ((orders.shareid = ' . $profile['id'] . " and bjog.status = 0) ) {$commissioningpelist2where} and orders.uniacid = '{$_W['uniacid']}' and orders.status >= 3 and orders.from_user != '" . $from_user . '\' and bjog.createtime>=' . $profile['flagtime'] . ' union all (' . "SELECT 2 as level,orders.status,orders.createtime,orders.ordersn,bjog.status2 as status1,bjog.commission2*bjog.total as commission,( {$conditionMember}) realname FROM " . tablename('wwx_fxxt_order') . ' orders left join ' . tablename('wwx_fxxt_order_goods') . ' bjog on bjog.orderid=orders.id WHERE ((orders.shareid2 = ' . $profile['id'] . " and bjog.status2 = 0) ) {$commissioningpelist2where} and orders.uniacid = '{$_W['uniacid']}' and orders.status >= 3 and orders.from_user != '" . $from_user . '\' and bjog.createtime>=' . $profile['flagtime'] . ') union all (' . "SELECT 3 as level,orders.status,orders.createtime,orders.ordersn,bjog.status3 as status1,bjog.commission3*bjog.total as commission,( {$conditionMember}) realname FROM " . tablename('wwx_fxxt_order') . ' orders left join ' . tablename('wwx_fxxt_order_goods') . ' bjog on bjog.orderid=orders.id WHERE ((orders.shareid3 = ' . $profile['id'] . " and bjog.status3 = 0) ) {$commissioningpelist2where} and orders.uniacid = '{$_W['uniacid']}' and orders.status >= 3 and orders.from_user != '" . $from_user . '\' and bjog.createtime>=' . $profile['flagtime'] . ')'); $title = '申请提现'; include $this->template('page_commapply'); die; } if ($op == 'applyed') { if ($profile['flag'] == 0) { message('非代理,申请佣金失败!'); } $isbank = pdo_fetch("select id, bankcard, banktype from " . tablename('wwx_fxxt_member') . " where uniacid = " . $_W['uniacid'] . " and from_user = '" . $from_user . "'"); if (empty($isbank['bankcard']) || empty($isbank['banktype'])) { message('请先完善银行卡信息!', $this->createMobileUrl('profile', array('id' => $isbank['id'], 'opp' => 'complated')), 'error'); } $commtime = time(); if (!empty($cfg['commtime'])) { $commtime = time() - intval($cfg['commtime']) * 24 * 60 * 60; } $commissioningpewhere = ' and (o.updatetime=0 or (o.updatetime>0 and o.updatetime<' . $commtime . ') )'; $orders = pdo_fetchall('SELECT 1 as level,g.id,g.commission as commission,g.total,g.createtime,o.shareid as shareid FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE (o.shareid = ' . $profile['id'] . " and g.status = 0) \t{$commissioningpewhere} and o.uniacid = " . $_W['uniacid'] . ' and o.status >= 3 and o.from_user != \'' . $from_user . '\' and g.createtime>=' . $profile['flagtime'] . ' union all (' . 'SELECT 2 as level,g.id,g.commission2 as commission,g.total,g.createtime,o.shareid2 as shareid FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE (o.shareid2 = ' . $profile['id'] . " and g.status2 = 0) \t{$commissioningpewhere} and o.uniacid = " . $_W['uniacid'] . " and o.status >= 3 {$level2enable} and o.from_user != '" . $from_user . '\' and g.createtime>=' . $profile['flagtime'] . ')' . ' union all (' . 'SELECT 3 as level,g.id,g.commission3 as commission,g.total,g.createtime,o.shareid3 as shareid FROM ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE (o.shareid3 = ' . $profile['id'] . " and g.status3 = 0) \t{$commissioningpewhere} and o.uniacid = " . $_W['uniacid'] . " and o.status >= 3 {$level3enable} and o.from_user != '" . $from_user . '\' and g.createtime>=' . $profile['flagtime'] . ')'); $almoney = 0; foreach ($orders as $order) { if ($order['shareid'] == $profile['id']) { if (!empty($order['commission']) && $order['commission'] > 0 && $order['createtime'] >= $profile['flagtime']) { if ($order['level'] == 1) { $update = array('status' => 1, 'applytime' => time()); } if ($order['level'] == 2) { $update = array('status2' => 1, 'applytime2' => time()); } if ($order['level'] == 3) { $update = array('status3' => 1, 'applytime3' => time()); } pdo_update('wwx_fxxt_order_goods', $update, array('id' => $order['id'])); $almoney = $almoney + $order['commission'] * $order['total']; } } } $tagent = $this->getMember($this->getShareId()); $this->sendyjsqtz($almoney, $profile['realname'], $tagent['from_user']); message('申请成功!', $this->createMobileUrl('commission'), 'success'); } include $this->template('page_commission'); } public function doMobileMymessage() { global $_W, $_GPC; $from = $_GPC['from']; $returnurl = urldecode($_GPC['returnurl']); $operation = $_GPC['op']; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); $cfg = $this->module['config']; $title = '我的短消息'; if (empty($_W['openid'])) { message('请先登录', $this->createMobileUrl('login'), 'error'); die; } $adminmsg = ''; $msgtotal = 0; if (!empty($cfg['noticeewechat'])) { $adminopenid = pdo_fetch('SELECT from_user FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = :uniacid AND id = :id LIMIT 1", array(':uniacid' => $_W['uniacid'], ':id' => $cfg['noticeewechat'])); if (!empty($adminopenid['from_user'])) { $adminmsg = $adminopenid['from_user']; } } if (!empty($profile['id'])) { if ($operation == 'postre') { if (empty($_GPC['solution'])) { message(0, '', 'ajax'); } $id = intval($_GPC['id']); $data = array('status' => 2, 'solution' => $_GPC['solution'], 'updatetime' => TIMESTAMP); if (!empty($id)) { pdo_update('wwx_fxxt_feedback', $data, array('id' => $id)); $sendmsg = pdo_fetch("select * from " . tablename('wwx_fxxt_feedback') . " where id='{$id}' and uniacid='{$_W['uniacid']}' limit 1 "); if ($sendmsg['type'] == 0) { $sendname = '系统'; } if ($sendmsg['type'] == 1) { $sendname = '维权'; } if ($sendmsg['type'] == 2) { $sendname = '询问'; } if ($sendmsg['type'] == 3) { $sendname = '用户'; } $this->sendzndxxtz($sendmsg['solution'], '收到回复信息', $sendname, $sendmsg['openid']); message($id, '', 'ajax'); } else { message(0, '', 'ajax'); } } elseif ($operation == 'postnew') { $id = intval($_GPC['id']); $type = 3; $feedbackid = 0; $transid = 0; if (!empty($id)) { if ($id == -1 && $profile['share_from_user'] != '') { $openid = $profile['share_from_user']; } else { $bid = pdo_fetch("select openid,backopenid,type,feedbackid,transid from " . tablename('wwx_fxxt_feedback') . " where id='{$id}' and uniacid='{$_W['uniacid']}' limit 1 "); if (!empty($bid['feedbackid'])) { $feedbackid = $bid['feedbackid']; $type = 1; } if (!empty($bid['transid'])) { $transid = $bid['transid']; $type = 2; } if ($bid['openid'] != $from_user) { $openid = $bid['openid']; } if ($bid['backopenid'] != $from_user) { $openid = $bid['backopenid']; } } } else { $openid = $_GPC['openid']; } if ($from_user == $openid) { message(-1, '', 'ajax'); } if ($adminmsg == $openid) { $type = 0; } if (!empty($openid)) { $data = array('uniacid' => $_W['uniacid'], 'openid' => $from_user, 'backopenid' => $openid, 'reason' => $_GPC['reason'], 'type' => $type, 'status' => 0, 'feedbackid' => $feedbackid, 'transid' => $transid, 'createtime' => TIMESTAMP); if (empty($_GPC['reason'])) { message('请输入发送内容!'); } pdo_insert('wwx_fxxt_feedback', $data); $id = pdo_insertid(); if (!empty($id)) { if ($type == 0) { $sendname = '系统'; } if ($type == 1) { $sendname = '维权'; } if ($type == 2) { $sendname = '询问'; } if ($type == 3) { $sendname = '用户'; } $this->sendzndxxtz($_GPC['reason'], '收到新信息', $sendname, $openid); message($id, '', 'ajax'); } else { message(0, '', 'ajax'); } } else { message(0, '', 'ajax'); } } elseif ($operation == 'post') { if (empty($_GPC['reason'])) { message(0, '', 'ajax'); } if ($from_user == $adminmsg) { message(-1, '', 'ajax'); } $type = 0; $feedbackid = 0; $transid = 0; if (!empty($_GPC['feedbackid'])) { $feedbackid = $_GPC['feedbackid']; $type = 1; } if (!empty($_GPC['transid'])) { $transid = $_GPC['transid']; $type = 2; } $data = array('uniacid' => $_W['uniacid'], 'openid' => $from_user, 'backopenid' => $adminmsg, 'reason' => $_GPC['reason'], 'type' => $type, 'status' => 0, 'feedbackid' => $feedbackid, 'transid' => $transid, 'createtime' => TIMESTAMP); pdo_insert('wwx_fxxt_feedback', $data); $id = pdo_insertid(); if (!empty($id)) { if ($type == 0) { $sendname = '系统'; } if ($type == 1) { $sendname = '维权'; } if ($type == 2) { $sendname = '询问'; } if ($type == 3) { $sendname = '用户'; } $this->sendzndxxtz($_GPC['reason'], '收到新信息', $sendname, $adminmsg); message($id, '', 'ajax'); } else { message(0, '', 'ajax'); } } elseif ($operation == 'detail') { $id = intval($_GPC['id']); $row = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_feedback') . " WHERE id = :id", array(':id' => $id)); pdo_update('wwx_fxxt_feedback', array('status' => 1), array('id' => $id, 'uniacid' => $_W['uniacid'])); $msgtotal = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('wwx_fxxt_feedback') . " where uniacid='{$_W['uniacid']}' and (backopenid = '{$from_user}' and status = 0)"); $row['msgtotal'] = $msgtotal; message($row, '', 'ajax'); } elseif ($operation == 'remove') { $id = intval($_GPC['id']); if (!empty($id)) { $address = pdo_fetch("select openid,backopenid from " . tablename('wwx_fxxt_feedback') . " where id='{$id}' and uniacid='{$_W['uniacid']}' limit 1 "); if ($address['openid'] == $from_user) { pdo_update("wwx_fxxt_feedback", array("status" => -1), array('id' => $id, 'uniacid' => $_W['uniacid'])); } elseif ($address['backopenid'] == $from_user) { pdo_update("wwx_fxxt_feedback", array("status" => -2), array('id' => $id, 'uniacid' => $_W['uniacid'])); } else { die(json_encode(array('result' => 0))); } } die(json_encode(array('result' => 1))); } else { $pindex = max(1, intval($_GPC['page'])); $psize = 30; $where .= " where uniacid='{$_W['uniacid']}' and ((`openid` = '{$from_user}' and `status` <> -1 ) or (`backopenid` = '{$from_user}' and `status` <> -2 )) "; $list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_feedback') . $where . " ORDER BY id DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize); $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('wwx_fxxt_feedback') . $where); $pager = pagination($total, $pindex, $psize); $msgtotal = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('wwx_fxxt_feedback') . " where uniacid='{$_W['uniacid']}' and (backopenid = '{$from_user}' and status = 0)"); } } include $this->template('mymessage'); } public function doMobilerecharge() { global $_W, $_GPC; $uniacid = $_W['uniacid']; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); if (empty($_W['openid'])) { message('请先登录', $this->createMobileUrl('login'), 'error'); die; } $dispatch = pdo_fetchall("select id,dispatchname,dispatchtype,firstprice,firstweight,secondprice,secondweight from " . tablename("wwx_fxxt_dispatch") . " WHERE uniacid = {$_W['uniacid']} order by displayorder"); $myheadimg = pdo_fetch('SELECT fans.openid from_user, fans.follow follow, member.* FROM ' . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member WHERE fans.uniacid = :uniacid AND fans.openid = :from_user AND fans.uid=member.uid LIMIT 1", array(':uniacid' => $_W['uniacid'], ':from_user' => $from_user)); $username = $_W['member']['uid']; if ($_W['member']['email'] && (substr($_W['member']['email'], -9) != '09077.com' && strlen($_W['member']['email']) != 42)) { $username = $_W['member']['email']; } elseif (!empty($_W['member']['mobile'])) { $username = $_W['member']['mobile']; } elseif (!empty($_W['member']['realname'])) { $username = $_W['member']['realname']; } if (empty($username)) { message('您的用户信息不完整(绑定手机或邮箱、真实姓名),请完善用户信息后再充值', '', 'error'); } if (checksubmit('submit', true) || !empty($_GPC['ajax'])) { $fee = floatval($_GPC['charge']); if ($fee <= 0) { message('支付错误, 金额小于0。'); } $dispatchid = floatval($_GPC['dispatch']); if (empty($dispatchid)) { message('请选择您的支付方式。'); } $chargerecord = array('uid' => $_W['member']['uid'], 'uniacid' => $_W['uniacid'], 'tid' => date('YmdHi') . random(6, 1), 'fee' => $fee, 'status' => 0, 'createtime' => TIMESTAMP); if (!pdo_insert('mc_credits_recharge', $chargerecord)) { message('创建充值订单失败,请重试!', url('entry', array('m' => 'wwx_fxxt', 'do' => 'recharge')), 'error'); die; } $dispatchitem = pdo_fetch("select dispatchtype,dispatchname from " . tablename('wwx_fxxt_dispatch') . " where uniacid = '{$_W['uniacid']}' AND id=:id limit 1", array(":id" => $_GPC['dispatch'])); $sendtype = $dispatchitem['dispatchtype']; if ($dispatchitem['dispatchtype'] == 1 && strstr($dispatchitem['dispatchname'], "找人代付")) { header("location: " . $this->createMobileUrl('payweixin', array('tid' => $chargerecord['tid']))); die; } $params = array('tid' => $chargerecord['tid'], 'user' => $from_user, 'ordersn' => $chargerecord['tid'], 'title' => '系统充值余额', 'fee' => $chargerecord['fee']); $this->wwxpay($params, $sendtype); } else { include $this->template('recharge'); } } public function doMobileprofile() { global $_W, $_GPC; $uniacid = $_W['uniacid']; $title = '完善资料'; $op = $_GPC['op'] ? $_GPC['op'] : 'display'; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); $carttotal = $this->getCartTotal(); if (empty($_W['openid'])) { message('请先登录', $this->createMobileUrl('login'), 'error'); die; } load()->model('app'); load()->model('mc'); load()->func('tpl'); if (!empty($_W['openid'])) { $map_fans = pdo_fetchcolumn('SELECT tag FROM ' . tablename('mc_mapping_fans') . ' WHERE uniacid = :uniacid AND openid = :openid', array(':uniacid' => $_W['uniacid'], ':openid' => $_W['openid'])); if (!empty($map_fans)) { if (is_base64($map_fans)) { $map_fans = base64_decode($map_fans); } if (is_serialized($map_fans)) { $map_fans = iunserializer($map_fans); } if (!empty($map_fans) && is_array($map_fans)) { empty($profile['nickname']) ? $data['nickname'] = $map_fans['nickname'] : ''; empty($profile['gender']) ? $data['gender'] = $map_fans['sex'] : ''; empty($profile['residecity']) ? $data['residecity'] = $map_fans['city'] ? $map_fans['city'] . '市' : '' : ''; empty($profile['resideprovince']) ? $data['resideprovince'] = $map_fans['province'] ? $map_fans['province'] . '省' : '' : ''; empty($profile['nationality']) ? $data['nationality'] = $map_fans['country'] : ''; empty($profile['avatar']) ? $data['avatar'] = rtrim($map_fans['headimgurl'], '0') . 132 : ''; if (!empty($data)) { mc_update($_W['member']['uid'], $data); } } } } if (checksubmit('submit')) { if (empty($_GPC['avatar'])) { message('头像不能为空!', '', 'error'); } if (empty($_GPC['nickname'])) { message('昵称不能为空!', '', 'error'); } if (empty($_GPC['realname'])) { message('真实姓名不能为空!', '', 'error'); } $data = array('realname' => $_GPC['realname'], 'nickname' => $_GPC['nickname'], 'bankcard' => $_GPC['bankcard'], 'banktype' => $_GPC['banktype'], 'alipay' => $_GPC['alipay'], 'wxhao' => $_GPC['wxhao']); pdo_update('wwx_fxxt_member', $data, array('from_user' => $from_user)); mc_update($_W['member']['uid'], array('nickname' => $_GPC['nickname'], 'realname' => $_GPC['realname'], 'avatar' => $_GPC['avatar'])); pdo_update('mc_mapping_fans', array('nickname' => $_GPC['nickname']), array('openid' => $from_user)); message('更新资料成功!', referer(), 'success'); } include $this->template('profile'); } public function doMobileAddress() { global $_W, $_GPC; $from = $_GPC['from']; $returnurl = urldecode($_GPC['returnurl']); $operation = $_GPC['op']; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); $carttotal = $this->getCartTotal(); $title = '完善收货资料'; if (empty($_W['openid'])) { message('请先登录', $this->createMobileUrl('login'), 'error'); die; } if ($operation == 'post') { $id = intval($_GPC['id']); $data = array('uniacid' => $_W['uniacid'], 'openid' => $from_user, 'realname' => $_GPC['realname'], 'mobile' => $_GPC['mobile'], 'province' => $_GPC['province'], 'city' => $_GPC['city'], 'area' => $_GPC['area'], 'address' => $_GPC['address']); if (empty($_GPC['realname']) || empty($_GPC['mobile']) || empty($_GPC['address'])) { message('请输完善您的资料!'); } if (!empty($id)) { unset($data['uniacid']); unset($data['openid']); pdo_update('wwx_fxxt_address', $data, array('id' => $id)); message($id, '', 'ajax'); } else { pdo_update('wwx_fxxt_address', array('isdefault' => 0), array('uniacid' => $_W['uniacid'], 'openid' => $from_user)); $data['isdefault'] = 1; pdo_insert('wwx_fxxt_address', $data); $id = pdo_insertid(); if (!empty($id)) { message($id, '', 'ajax'); } else { message(0, '', 'ajax'); } } } elseif ($operation == 'default') { $id = intval($_GPC['id']); pdo_update('wwx_fxxt_address', array('isdefault' => 0), array('uniacid' => $_W['uniacid'], 'openid' => $from_user)); pdo_update('wwx_fxxt_address', array('isdefault' => 1), array('id' => $id)); message(1, '', 'ajax'); } elseif ($operation == 'detail') { $id = intval($_GPC['id']); $row = pdo_fetch("SELECT id, realname, mobile, province, city, area, address FROM " . tablename('wwx_fxxt_address') . " WHERE id = :id", array(':id' => $id)); message($row, '', 'ajax'); } elseif ($operation == 'remove') { $id = intval($_GPC['id']); if (!empty($id)) { $address = pdo_fetch("select isdefault from " . tablename('wwx_fxxt_address') . " where id='{$id}' and uniacid='{$_W['uniacid']}' and openid='" . $from_user . "' limit 1 "); if (!empty($address)) { pdo_update("wwx_fxxt_address", array("deleted" => 1, "isdefault" => 0), array('id' => $id, 'uniacid' => $_W['uniacid'], 'openid' => $from_user)); if ($address['isdefault'] == 1) { $maxid = pdo_fetchcolumn("select max(id) as maxid from " . tablename('wwx_fxxt_address') . " where uniacid='{$_W['uniacid']}' and openid='" . $from_user . "' limit 1 "); if (!empty($maxid)) { pdo_update('wwx_fxxt_address', array('isdefault' => 1), array('id' => $maxid, 'uniacid' => $_W['uniacid'], 'openid' => $from_user)); die(json_encode(array('result' => 1, 'maxid' => $maxid))); } } } } die(json_encode(array('result' => 1, 'maxid' => 0))); } else { $address = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_address') . " WHERE deleted=0 and openid = :openid", array(':openid' => $from_user)); include $this->template('address'); } } public function doMobileAward() { global $_W, $_GPC; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); $award_list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_credit_award') . " WHERE uniacid = '{$_W['uniacid']}' and NOW() < deadline and amount > 0"); include $this->template('credit_new'); } public function doMobileFillInfo() { global $_W, $_GPC; $award_id = intval($_GPC['award_id']); $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); if (empty($_W['openid'])) { message('请先登录', $this->createMobileUrl('login'), 'error'); die; } $award_info = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_credit_award') . " WHERE award_id = {$award_id} AND uniacid = '{$_W['uniacid']}'"); include $this->template('credit_fillinfo_new'); } public function doMobileCredit() { global $_W, $_GPC; $award_id = intval($_GPC['award_id']); $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); if (!empty($_GPC['award_id'])) { $award_info = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_credit_award') . " WHERE award_id = {$award_id} AND uniacid = '{$_W['uniacid']}'"); if ($profile['credit1'] >= $award_info['credit_cost'] && $award_info['amount'] > 0) { $data = array('amount' => $award_info['amount'] - 1); pdo_update('wwx_fxxt_credit_award', $data, array('uniacid' => $_W['uniacid'], 'award_id' => $award_id)); $data = array('uniacid' => $_W['uniacid'], 'from_user' => $from_user, 'award_id' => $award_id, 'createtime' => TIMESTAMP); pdo_insert('wwx_fxxt_credit_request', $data); $data = array('realname' => $_GPC['realname'], 'mobile' => $_GPC['mobile'], 'credit1' => $profile['credit1'] - $award_info['credit_cost'], 'residedist' => $_GPC['residedist']); pdo_update('mc_members', $data, array('uid' => $profile['uid'], 'uniacid' => $_W['uniacid'])); message('积分兑换成功!', create_url('entry/module/mycredit', array('uniacid' => $_W['uniacid'], 'm' => 'wwx_fxxt', 'do' => 'mycredit', 'op' => 'display')), 'success'); } else { message('积分不足或商品已经兑空,请重新选择商品!
当前商品所需积分:' . $award_info['credit_cost'] . '
您的积分:' . $profile['credit1'] . '. 商品剩余数量:' . $award_info['amount'], create_url('entry/module/award', array('uniacid' => $_W['uniacid'], 'm' => 'wwx_fxxt')), 'error'); } } else { message('请选择要兑换的商品!', create_url('entry/module/award', array('uniacid' => $_W['uniacid'], 'm' => 'wwx_fxxt')), 'error'); } } public function doMobileMycredit() { global $_W, $_GPC; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); if (empty($_W['openid'])) { message('请先登录', $this->createMobileUrl('login'), 'error'); die; } $award_list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_credit_award') . " as t1," . tablename('wwx_fxxt_credit_request') . "as t2 WHERE t1.award_id=t2.award_id AND from_user='" . $from_user . "' AND t1.uniacid = '{$_W['uniacid']}' ORDER BY t2.createtime DESC"); include $this->template('credit_mycredit_new'); } public function doMobilePhb() { global $_W, $_GPC; $paihang = $_GPC['opp']; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); $cfg = $this->module['config']; $sum = $cfg['Thecharts'][0] + $cfg['Thecharts'][1] + $cfg['Thecharts'][2]; if ($sum == 3) { $sumcss = 'small-3'; } else { if ($sum == 2) { $sumcss = 'small-4'; } else { if ($sum == 1) { $sumcss = 'small-6'; } else { $sumcss = 'small-12'; } } } $limitsum = $cfg['ThechartsSum']; if (empty($limitsum)) { $limitsum = 10; } if ($paihang == "jifen" && $cfg['Thecharts'][0] == 1) { $title = '积分排行榜'; $list = pdo_fetchall("SELECT member.*,(select fs.avatar from " . tablename('mc_members') . " fs, " . tablename('mc_mapping_fans') . " bfs where bfs.openid=member.from_user and fs.uid=bfs.uid and avatar<>'' limit 1) avatar,(select fsc.credit1 from " . tablename('mc_members') . " fsc, " . tablename('mc_mapping_fans') . " bfsc where bfsc.openid=member.from_user and fsc.uid=bfsc.uid limit 1) credit1 FROM " . tablename('wwx_fxxt_member') . " member WHERE member.uniacid = :uniacid and member.nickname<>'' order by credit1 desc limit {$limitsum} ", array(':uniacid' => $_W['uniacid'])); } else { if ($paihang == "yue" && $cfg['Thecharts'][1] == 1) { $title = '余额排行榜'; $list = pdo_fetchall("SELECT member.*,(select fs.avatar from " . tablename('mc_members') . " fs, " . tablename('mc_mapping_fans') . " bfs where bfs.openid=member.from_user and fs.uid=bfs.uid and avatar<>'' limit 1) avatar,(select fsc.credit2 from " . tablename('mc_members') . " fsc, " . tablename('mc_mapping_fans') . " bfsc where bfsc.openid=member.from_user and fsc.uid=bfsc.uid limit 1) credit2 FROM " . tablename('wwx_fxxt_member') . " member WHERE member.uniacid = :uniacid and member.nickname<>'' order by credit2 desc limit {$limitsum} ", array(':uniacid' => $_W['uniacid'])); } else { if ($paihang == "yongjin" && $cfg['Thecharts'][2] == 1) { $title = '佣金排行榜'; $list = pdo_fetchall("SELECT member.*,(select fs.avatar from " . tablename('mc_members') . " fs, " . tablename('mc_mapping_fans') . " bfs where bfs.openid=member.from_user and fs.uid=bfs.uid and avatar<>'' limit 1) avatar FROM " . tablename('wwx_fxxt_member') . " member WHERE member.uniacid = :uniacid and member.nickname<>'' order by member.commission desc limit {$limitsum} ", array(':uniacid' => $_W['uniacid'])); } else { $title = '粉丝排行榜'; $list = pdo_fetchall("SELECT member.*,(select fs.avatar from " . tablename('mc_members') . " fs, " . tablename('mc_mapping_fans') . " bfs where bfs.openid=member.from_user and fs.uid=bfs.uid and avatar<>'' limit 1) avatar FROM " . tablename('wwx_fxxt_member') . " member WHERE member.uniacid = :uniacid and member.nickname<>'' order by member.flagcount desc limit {$limitsum} ", array(':uniacid' => $_W['uniacid'])); } } } include $this->template('phb'); } public function doMobileRule() { global $_W, $_GPC; $uniacid = $_W['uniacid']; $op = $_GPC['op'] ? $_GPC['op'] : 'display'; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); $rule = pdo_fetchcolumn('SELECT rule FROM ' . tablename('wwx_fxxt_rules') . " WHERE uniacid = :uniacid", array(':uniacid' => $_W['uniacid'])); include $this->template('rule'); } public function doMobilesignout() { global $_W, $_GPC; unset($_SESSION); session_destroy(); isetcookie('logout', 1, 60); $logoutjs = ""; die($logoutjs); } public function doMobileRedActivity() { global $_W, $_GPC; $modulePublic = '../addons/wwx_fxxt/style/static/'; require_once WWX_FXXT_ROOT . '/class/Activity.class.php'; $forceSubscribe = true; $user = $this->redauth(); $id = $_GPC['actid']; $id = intval($id); $a = new Activity(); $activity = $a->getOne($id); $prepare = $this->prepareActivity($activity, array('user' => $user)); if (is_error($prepare)) { $error = $prepare; } $footer_off = true; $mid = $this->getMid(); $_W['page']['title'] = $activity['title']; $_share = array(); $_share['title'] = $activity['share']['title']; $_share['desc'] = $activity['share']['content']; $_share['imgUrl'] = tomedia($activity['share']['image']); $_share['link'] = $_W['siteroot'] . 'app/' . substr($this->createMobileUrl('redactivity', array('actid' => $activity['actid'], 'mid' => $mid, 'joinway' => 2)), 2); $got = $a->getRecord($user['uid'], $id); $filters = array(); $filters['activity'] = $id; $filters['status'] = 'complete'; $recents = $a->getRecords($filters, 1, 5, $total); if ($activity['type'] == 'direct') { include $this->template('redactivity_direct'); } if ($activity['type'] == 'shared') { $_share['link'] = $_W['siteroot'] . 'app/' . substr($this->createMobileUrl('redshared', array('actid' => $activity['actid'], 'mid' => $mid, 'joinway' => 2, 'owner' => $user['uid'])), 2); require_once WWX_FXXT_ROOT . '/class/Shared.class.php'; $s = new Shared($activity); $help = array(); $help['total'] = $activity['tag']['helps']; $help['already'] = $s->helpsCount($user['uid']); $help['isok'] = $help['already'] >= $help['total']; $activity['tag']['progress'] = htmlspecialchars_decode($activity['tag']['progress']); $activity['tag']['progress'] = str_replace('{left}', $help['total'] - $help['already'], $activity['tag']['progress']); include $this->template('redactivity_shared'); } } public function doMobileRedRules() { global $_W, $_GPC; require_once WWX_FXXT_ROOT . '/class/Activity.class.php'; $id = $_GPC['actid']; $id = intval($id); $a = new Activity(); $activity = $a->getOne($id); if (empty($activity)) { die('访问错误'); } die(htmlspecialchars_decode($activity['rules'])); } public function doMobileRedMy() { global $_W, $_GPC; $user = $this->redauth(); $foo = $_GPC['foo']; $foos = array('profile', 'history'); $foo = in_array($foo, $foos) ? $foo : 'list'; require_once WWX_FXXT_ROOT . '/class/Fans.class.php'; $f = new Fans(); if ($foo == 'profile') { die('success'); } if ($foo == 'history') { require_once WWX_FXXT_ROOT . '/class/Activity.class.php'; $id = $_GPC['actid']; $id = intval($id); $a = new Activity(); $activity = $a->getOne($id); if ($activity['type'] == 'shared') { require_once WWX_FXXT_ROOT . '/class/Shared.class.php'; $s = new Shared($activity); $filters = array(); $filters['owner'] = $user['uid']; $ds = $s->getAllHelps($filters); if (!empty($ds)) { foreach ($ds as &$r) { $r['user'] = $f->getOne($r['helper']); } } include $this->template('redmy_shared'); } } } public function doMobileCheck() { if (!$this->checkSubscribe()) { die('failed'); } else { die('success'); } } public function doMobileRedEntry() { global $_W, $_GPC; $modulePublic = '../addons/wwx_fxxt/style/static/'; $footer_off = true; $_W['page']['title'] = $activity['title']; require_once WWX_FXXT_ROOT . '/class/Activity.class.php'; require_once WWX_FXXT_ROOT . '/class/Shared.class.php'; require_once WWX_FXXT_ROOT . '/class/Fans.class.php'; $f = new Fans(); $s = new Shared(); $uid = intval($_GPC['owner']); $owner = $f->getOne($uid); if (empty($owner)) { message('访问错误', $activity['guide'], 'info'); } $got = $s->getOneRecord($owner['uid']); $user = $this->redauth(); $a = new Activity(); $activity = $a->getOne($id); $prepare = $this->prepareActivity($activity, array('user' => $user)); if (is_error($prepare)) { $error = $prepare; } if ($owner['uid'] == $user['uid']) { header('Location: ' . $this->createMobileUrl('redget')); die; } $mid = $this->getMid(); $_share = array(); $_share['title'] = $activity['stitle']; $_share['desc'] = $activity['content']; $_share['imgUrl'] = tomedia($activity['image']); $_share['link'] = $_W['siteroot'] . 'app/' . substr(substr($this->createMobileUrl('redentry', array('owner' => $user['uid'], 'mid' => $mid, 'joinway' => 2)), 2), 0, -39); if ($activity['type'] == 'direct') { } else { $help = array(); $help['total'] = $activity['helps']; $help['already'] = $s->helpsCount($owner['uid']); $help['ok'] = $help['already'] >= $activity['helps']; $help['rank'] = $s->getHelpRank($owner['uid'], $user['uid']); $activity['label'] = str_replace('{nickname}', $owner['nickname'], $activity['label']); } include $this->template('redentry'); } public function doMobileRedGet() { global $_W, $_GPC; $modulePublic = '../addons/wwx_fxxt/style/static/'; require_once WWX_FXXT_ROOT . '/class/Activity.class.php'; $footer_off = true; $_W['page']['title'] = $activity['title']; $user = $this->redauth(); $a = new Activity(); $activity = $a->getOne($id); $prepare = $this->prepareActivity($activity, array('user' => $user)); if (is_error($prepare)) { $error = $prepare; } $mid = $this->getMid(); $_share = array(); $_share['title'] = $activity['stitle']; $_share['desc'] = $activity['content']; $_share['imgUrl'] = tomedia($activity['image']); $_share['link'] = $_W['siteroot'] . 'app/' . substr(substr($this->createMobileUrl('redentry', array('owner' => $user['uid'], 'mid' => $mid, 'joinway' => 2)), 2), 0, -39); require_once WWX_FXXT_ROOT . '/class/Shared.class.php'; $s = new Shared(); $got = $s->getOneRecord($user['uid']); if ($activity['type'] == 'direct') { } else { $help = array(); $help['total'] = $activity['helps']; $help['already'] = $s->helpsCount($user['uid']); $help['ok'] = $help['already'] >= $activity['helps']; } include $this->template('redget'); } public function doMobileRedSend() { global $_W, $_GPC; require_once WWX_FXXT_ROOT . '/class/Activity.class.php'; $user = $this->redauth(); $id = $_GPC['actid']; $id = intval($id); $a = new Activity(); $activity = $a->getOne($id); $prepare = $this->prepareActivity($activity, array('user' => $user)); if (is_error($prepare)) { $error = $prepare; if ($error['errno'] != '-2') { die($error['message']); } } if (!$this->checkSubscribe()) { die('请关注我们后参加活动'); } if ($activity['type'] == 'direct') { $got = $a->getRecord($user['uid'], $activity['actid']); if (empty($got)) { if (empty($error)) { $ret = $a->grap($user, $activity); if (is_error($ret)) { die($ret['message']); } elseif ($ret['status'] == 'none') { die('这一轮没有抢到红包, 请期待我们下一次活动'); } else { $got = $a->getRecord($user['uid'], $activity['actid']); $ret = $this->redsend($activity, $got, $user); if (is_error($ret)) { die('红包发放失败, 你可以在活动结束之前重新领取. 活动结束后无法领取, 请注意'); die($ret['message']); } die('success'); } } } else { if ($got['status'] == 'created') { $ret = $this->redsend($activity, $got, $user); if (is_error($ret)) { die('红包发放失败, 你可以在活动结束之前重新领取. 活动结束后无法领取, 请注意'); die($ret['message']); } die('success'); } } } if ($activity['type'] == 'shared') { require_once WWX_FXXT_ROOT . '/class/Shared.class.php'; $s = new Shared($activity); $count = $s->helpsCount($user['uid']); if ($count < $activity['tag']['helps']) { die('还没达到领取礼品的条件'); } $got = $a->getRecord($user['uid'], $activity['actid']); if (empty($got)) { if (empty($error)) { $ret = $a->grap($user, $activity); if (is_error($ret)) { die($ret['message']); } elseif ($ret['status'] == 'none') { die('这一轮没有抢到红包, 请期待我们下一次活动'); } else { $got = $a->getRecord($user['uid'], $activity['actid']); $ret = $this->redsend($activity, $got, $user); if (is_error($ret)) { die('红包发放失败, 你可以在活动结束之前重新领取. 活动结束后无法领取, 请注意'); die($ret['message']); } die('success'); } } } else { if ($got['status'] == 'created') { $ret = $this->redsend($activity, $got, $user); if (is_error($ret)) { die('红包发放失败, 你可以在活动结束之前重新领取. 活动结束后无法领取, 请注意'); die($ret['message']); } die('success'); } } } die('没有领取到红包'); } public function doMobileRedShared() { global $_W, $_GPC; $modulePublic = '../addons/wwx_fxxt/style/static/'; require_once WWX_FXXT_ROOT . '/class/Activity.class.php'; require_once WWX_FXXT_ROOT . '/class/Fans.class.php'; require_once WWX_FXXT_ROOT . '/class/Shared.class.php'; $a = new Activity(); $f = new Fans(); $user = $this->redauth(); $id = $_GPC['actid']; $id = intval($id); $activity = $a->getOne($id); $prepare = $this->prepareActivity($activity, array('user' => $user)); if (is_error($prepare)) { header('Location: ' . $this->createMobileUrl('redactivity', array('actid' => $activity['actid']))); die; } $uid = intval($_GPC['owner']); $owner = $f->getOne($uid); if (empty($owner)) { message('访问错误', $activity['guide'], 'info'); } if ($owner['uid'] == $user['uid']) { header('Location: ' . $this->createMobileUrl('redactivity', array('actid' => $activity['actid']))); die; } require_once WWX_FXXT_ROOT . '/class/Shared.class.php'; $s = new Shared($activity); if ($_W['ispost']) { $input = array(); $input['owner'] = $owner['uid']; $input['helper'] = $user['uid']; $input['dateline'] = TIMESTAMP; $ret = $s->createHelp($input); if (is_error($ret)) { die($ret['message']); } else { die('success'); } } $footer_off = true; $_W['page']['title'] = $activity['title']; $mid = $this->getMid(); $_share = array(); $_share['title'] = $activity['share']['title']; $_share['desc'] = $activity['share']['content']; $_share['imgUrl'] = tomedia($activity['share']['image']); $_share['link'] = $_W['siteroot'] . 'app/' . substr($this->createMobileUrl('redshared', array('actid' => $activity['actid'], 'owner' => $user['uid'], 'mid' => $mid, 'joinway' => 2)), 2); $got = $a->getRecord($user['uid'], $id); $help = array(); $help['total'] = $activity['tag']['helps']; $help['already'] = $s->helpsCount($owner['uid']); $help['isok'] = $help['already'] >= $help['total']; $help['rank'] = $s->getHelpRank($owner['uid'], $user['uid']); $activity['tag']['label'] = htmlspecialchars_decode($activity['tag']['label']); $activity['tag']['label'] = str_replace('{nickname}', $owner['nickname'], $activity['tag']['label']); $activity['tag']['request'] = htmlspecialchars_decode($activity['tag']['request']); $activity['tag']['request'] = str_replace('{nickname}', $owner['nickname'], $activity['tag']['request']); include $this->template('redactivity_shared_help'); } public function doMobileQcookie() { global $_W; setcookie(WUXIAN_COOKIE_SID . $_W['uniacid'], ''); setcookie(WUXIAN_COOKIE_JON . $_W['uniacid'], ''); setcookie(WUXIAN_COOKIE_OPENID . $_W['uniacid'], ''); setcookie(WUXIAN_COOKIE_QRCODE . $_W['uniacid'], ''); setcookie(WUXIAN_COOKIE_XOAUHURL . $_W['uniacid'], ''); setcookie(WUXIAN_COOKIE_CHECKOPENID . $_W['uniacid'], ''); message('清空成功!调试请关闭页面!', '', 'success'); } public function doMobilePay() { global $_W, $_GPC; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); $cfg = $this->module['config']; $huodaocommission = $cfg['huodaoCommission']; $orderid = intval($_GPC['orderid']); $dispatchid = intval($_GPC['dispatchid']); $order = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_order') . " WHERE id = :id and from_user=:from_user", array(':id' => $orderid, 'from_user' => $from_user)); $goodsstr = ""; $bodygoods = ""; if (empty($order['id'])) { message('抱歉,未找到相关订单!'); } if ($order['status'] != '0' && !($order['status'] == 1 && $order['paytype'] == 3)) { message('抱歉,您的订单已经付款或是被关闭,请重新进入付款!', $this->createMobileUrl('myorder'), 'error'); } $ordergoods = pdo_fetchall("SELECT goodsid,total,optionid FROM " . tablename('wwx_fxxt_order_goods') . " WHERE orderid = '{$orderid}'", array(), 'goodsid'); if (!empty($ordergoods)) { $goods = pdo_fetchall("SELECT id, title, thumb, marketprice, unit, total,credit FROM " . tablename('wwx_fxxt_goods') . " WHERE id IN ('" . implode("','", array_keys($ordergoods)) . "')"); } if (!empty($goods)) { foreach ($goods as $row) { $goodsstr .= "{$row['title']}({$ordergoods[$row['id']]['total']})
"; $bodygoods .= "名称:{$row['title']} ,数量:{$ordergoods[$row['id']]['total']}
"; $goodtitle .= $row['title']; } } $newpaytype = 0; if (!empty($dispatchid)) { $dispatch = pdo_fetch("select id,dispatchname,dispatchtype from " . tablename('wwx_fxxt_dispatch') . " where uniacid = '{$_W['uniacid']}' AND id=:id limit 1", array(":id" => $dispatchid)); if ($dispatch['dispatchtype'] == 0) { $newpaytype = 3; } if ($dispatch['dispatchtype'] == 1) { $newpaytype = 2; } if ($dispatch['dispatchtype'] == 3) { $newpaytype = 1; } $disppay = 0; if ($dispatch['dispatchtype'] == 0 && $profile['credit2'] < $huodaocommission && !empty($profile['credit2'])) { message('抱歉,货到付款方式需要您的账户余额多余' . $huodaocommission . '元!'); } if ($dispatch['dispatchtype'] == 1 && strstr($dispatch['dispatchname'], "找人代付")) { $disppay = 1; } if (!empty($newpaytype)) { if ($order['status'] == 1 && $order['paytype'] == 3 && $newpaytype != 3) { pdo_update('wwx_fxxt_order', array('paytype' => $newpaytype, 'dispatch' => $dispatch['id'], 'sendtype' => $dispatch['dispatchtype'], 'status' => 0), array('id' => $order['id'])); } else { pdo_update('wwx_fxxt_order', array('paytype' => $newpaytype, 'dispatch' => $dispatch['id'], 'sendtype' => $dispatch['dispatchtype']), array('id' => $order['id'])); } $order['sendtype'] = $dispatch['dispatchtype']; } } $noticee = array('addressid' => $order['addressid'], 'price' => $order['price'], 'bodygoods' => $bodygoods); $tagent = $this->getMember($this->getShareId()); if (checksubmit('codsubmit')) { $this->sendgmsptz($order['ordersn'], $order['price'], $profile['realname'], $tagent['from_user']); pdo_update('wwx_fxxt_order', array('status' => '1', 'paytype' => '3', 'zhifutime' => time()), array('id' => $orderid)); $this->sendMobilePayMsg($order, $goods, "货到付款", $ordergoods); $this->getFromNoticeeMail($noticee); message('订单提交成功,请您收到货时付款!', $this->createMobileUrl('myorder', array('orderid' => $order['id'], 'op' => 'detail')), 'success'); } if (checksubmit('credit2submit')) { $fans = pdo_fetch('SELECT member.credit2 as credit2 FROM ' . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member WHERE fans.uniacid = :uniacid AND fans.openid = :openid AND fans.uid = member.uid LIMIT 1", array(':uniacid' => $_W['uniacid'], ':openid' => $from_user)); if ($fans['credit2'] < $order['price']) { message('抱歉,您帐户的余额不够支付该订单,请充值!', $this->createMobileUrl('myorder', array('orderid' => $order['id'], 'op' => 'detail')), 'error'); } $this->sendgmsptz($order['ordersn'], $order['price'], $profile['realname'], $tagent['from_user']); $this->setMemberCredit2($profile['from_user'], $order['price'], 'usegold', '余款付款购买商品,订单编号为' . $order['ordersn']); pdo_update('wwx_fxxt_order', array('status' => '1', 'paytype' => '1', 'zhifutime' => time()), array('id' => $orderid)); $this->sendMobilePayMsg($order, $goods, "余额付款", $ordergoods); $this->getFromNoticeeMail($noticee); message('余额付款成功,请您收到货时验货!', $this->createMobileUrl('myorder', array('orderid' => $order['id'], 'op' => 'detail')), 'success'); } if ($disppay == 1) { header("location: " . $this->createMobileUrl('payweixin', array('tid' => $orderid))); die; } if (strlen($goodtitle) > 30) { $goodtitle = mb_strimwidth($goodtitle, 0, 30, '等等..', 'utf8'); } $params['tid'] = $orderid; $params['user'] = $from_user; $params['fee'] = $order['price']; $params['title'] = $goodtitle != "" ? $goodtitle : $_W['account']['name']; $params['ordersn'] = $order['ordersn']; $params['virtual'] = $order['goodstype'] == 2 ? true : false; $this->wwxpay($params, $order['sendtype']); } public function doMobileConfirm() { global $_W, $_GPC; $uniacid = $_W['uniacid']; $op = $_GPC['op'] ? $_GPC['op'] : 'display'; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); $cfg = $this->module['config']; if (empty($_W['openid'])) { message('请先登录', $this->createMobileUrl('login'), 'error'); die; } if (!empty($profile['id'])) { $myfansx = pdo_fetch('SELECT member_commission FROM ' . tablename('wwx_fxxt_member_shipgrade') . " WHERE uniacid = :uniacid and displayorder = :displayorder order by member_name desc limit 1", array(':uniacid' => $_W['uniacid'], ':displayorder' => $profile['usergrade'])); if (!empty($myfansx['member_commission'])) { $member_commission = $myfansx['member_commission']; } else { $member_commission = 0; } } $huodaocommission = $cfg['huodaoCommission']; $totalprice = 0; $allgoods = array(); $id = intval($_GPC['id']); $optionid = intval($_GPC['optionid']); $total = intval($_GPC['total']); if (empty($total)) { $total = 1; } $direct = false; $returnurl = ""; $issendfree = 0; $promotion = pdo_fetchall('select * from ' . tablename('wwx_fxxt_pormotions') . ' where uniacid=' . $_W['uniacid'] . ''); if (!empty($id)) { $item = pdo_fetch("select id,thumb,ccate,title,weight,marketprice,total,type,totalcnf,sales,unit,istime,timeend,issendfree,isdiscount,usermaxbuy from " . tablename("wwx_fxxt_goods") . " where id=:id limit 1", array(":id" => $id)); if (!empty($member_commission) && $item['isdiscount'] == 1) { $item['marketprice'] = $item['marketprice'] * $member_commission / 100; } foreach ($promotion as $pro) { if (TIMESTAMP >= $pro['starttime'] && TIMESTAMP <= $pro['endtime']) { if ($pro['promoteType'] == 1) { if ($item['marketprice'] >= $pro['condition']) { $issendfree = 1; $protype = $pro['promoteType']; } } else { if ($pro['promoteType'] == 0) { if ($total >= $pro['condition']) { $issendfree = 1; $protype = $pro['promoteType']; } } } } } if ($item['issendfree'] == 1) { $issendfree = 1; } if ($item['istime'] == 1) { if (time() > $item['timeend']) { message('抱歉,商品限购时间已到,无法购买了!', referer(), "error"); } } if (!empty($optionid)) { $option = pdo_fetch("select title,marketprice,weight,stock from " . tablename("wwx_fxxt_goods_option") . " where id=:id limit 1", array(":id" => $optionid)); if ($option) { $item['optionid'] = $optionid; $item['title'] = $item['title']; $item['optionname'] = $option['title']; if (!empty($member_commission) && $item['isdiscount'] == 1) { $item['marketprice'] = $option['marketprice'] * $member_commission / 100; } else { $item['marketprice'] = $option['marketprice']; } $item['weight'] = $option['weight']; } } $item['stock'] = $item['total']; $item['total'] = $total; $item['totalprice'] = $total * $item['marketprice']; $allgoods[] = $item; $totalprice += $item['totalprice']; if ($item['type'] == 1) { $needdispatch = true; } $direct = true; // 检查用户最多购买数量 if(!empty($item['usermaxbuy'])){ $sql = 'SELECT SUM(`og`.`total`) AS `orderTotal` FROM ' . tablename('wwx_fxxt_order_goods') . ' AS `og` JOIN ' . tablename('wwx_fxxt_order') . ' AS `o` ON `og`.`orderid` = `o`.`id` WHERE `og`.`goodsid` = :goodsid AND `o`.`from_user` = :from_user'; $params = array(':goodsid' => $id, ':from_user' => $from_user); $orderTotal = pdo_fetchcolumn($sql, $params); if ( ($orderTotal +$total) > $item['usermaxbuy']) { message('您已经超过购买数量了', $this->createMobileUrl('detail', array('id' => $id)), 'error'); } } $returnurl = $this->createMobileUrl("confirm", array("id" => $id, "optionid" => $optionid, "total" => $total)); } if (!$direct) { $list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_cart') . " WHERE uniacid = '{$_W['uniacid']}' AND from_user = '" . $from_user . "'"); if (!empty($list)) { foreach ($list as &$g) { $item = pdo_fetch("select id,thumb,ccate,title,weight,marketprice,total,type,totalcnf,sales,unit,issendfree,isdiscount,usermaxbuy from " . tablename("wwx_fxxt_goods") . " where id=:id limit 1", array(":id" => $g['goodsid'])); if (!empty($member_commission) && $item['isdiscount'] == 1) { $item['marketprice'] = $item['marketprice'] * $member_commission / 100; } // 检查用户最多购买数量 if(!empty($item['usermaxbuy'])){ $sql = 'SELECT SUM(`og`.`total`) AS `orderTotal` FROM ' . tablename('wwx_fxxt_order_goods') . ' AS `og` JOIN ' . tablename('wwx_fxxt_order') . ' AS `o` ON `og`.`orderid` = `o`.`id` WHERE `og`.`goodsid` = :goodsid AND `o`.`from_user` = :from_user'; $params = array(':goodsid' => $g['goodsid'], ':from_user' => $from_user); $orderTotal = pdo_fetchcolumn($sql, $params); if ( ($orderTotal + $g['total'] ) > $item['usermaxbuy']) { //echo $orderTotal.'_'. $g['total'] .'_'. $item['usermaxbuy']; message($item['title'].'已经超过购买数量了', $this->createMobileUrl('mycart')); break; } } $option = pdo_fetch("select title,marketprice,weight,stock from " . tablename("wwx_fxxt_goods_option") . " where id=:id limit 1", array(":id" => $g['optionid'])); if ($option) { if ($item['issendfree'] == 1) { $issendfree = 1; } $item['optionid'] = $g['optionid']; $item['title'] = $item['title']; $item['optionname'] = $option['title']; if (!empty($member_commission) && $item['isdiscount'] == 1) { $item['marketprice'] = $option['marketprice'] * $member_commission / 100; } else { $item['marketprice'] = $option['marketprice']; } $item['weight'] = $option['weight']; } $item['stock'] = $item['total']; $item['total'] = $g['total']; $item['totalprice'] = $g['total'] * $item['marketprice']; $allgoods[] = $item; $totalprice += $item['totalprice']; if ($item['type'] == 1) { $needdispatch = true; } } foreach ($promotion as $pro) { if (TIMESTAMP >= $pro['starttime'] && TIMESTAMP <= $pro['endtime']) { if ($pro['promoteType'] == 1) { if ($item['totalprice'] >= $pro['condition']) { $issendfree = 1; $protype = $pro['promoteType']; } } else { if ($pro['promoteType'] == 0) { if ($item['total'] >= $pro['condition']) { $issendfree = 1; $protype = $pro['promoteType']; } } } } } unset($g); } $returnurl = $this->createMobileUrl("confirm"); } if (count($allgoods) <= 0) { header("location: " . $this->createMobileUrl('myorder')); die; } $dispatch = pdo_fetchall("select id,dispatchname,dispatchtype,firstprice,firstweight,secondprice,secondweight from " . tablename("wwx_fxxt_dispatch") . " WHERE uniacid = {$_W['uniacid']} order by displayorder"); foreach ($dispatch as &$d) { $weight = 0; foreach ($allgoods as $g) { $weight += $g['weight'] * $g['total']; if ($g['issendfree'] == 1) { $issendfree = 1; } } $price = 0; if ($issendfree != 1) { if ($weight <= $d['firstweight']) { $price = $d['firstprice']; } else { $price = $d['firstprice']; $secondweight = $weight - $d['firstweight']; if ($secondweight % $d['secondweight'] == 0) { $price += (int) ($secondweight / $d['secondweight']) * $d['secondprice']; } else { $price += (int) ($secondweight / $d['secondweight'] + 1) * $d['secondprice']; } } } $d['price'] = $price; } unset($d); if (checksubmit('submit')) { $address = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_address') . " WHERE id = :id", array(':id' => intval($_GPC['address']))); if (empty($address)) { message('抱歉,请您填写收货地址!'); } $goodsprice = 0; foreach ($allgoods as $row) { if ($item['stock'] != -1 && $row['total'] > $item['stock']) { message('抱歉,“' . $row['title'] . '”此商品库存不足!', $this->createMobileUrl('confirm'), 'error'); } $goodsprice += $row['totalprice']; if ($row['issendfree'] == 1) { $issendfree = 1; } } $dispatchid = intval($_GPC['dispatch']); $dispatchitem = pdo_fetch("select dispatchtype,dispatchname from " . tablename('wwx_fxxt_dispatch') . " where id=:id limit 1", array(":id" => $dispatchid)); $dispatchprice = 0; $dispaytype = 3; $disppay = 0; if ($dispatchitem['dispatchtype'] == 0) { $dispaytype = 3; } if ($dispatchitem['dispatchtype'] == 3) { $dispaytype = 1; } if ($dispatchitem['dispatchtype'] == 1) { $dispaytype = 2; } if ($dispaytype == 3 && $profile['credit2'] < $huodaocommission && !empty($profile['credit2'])) { message('抱歉,货到付款方式需要您的账户余额多余' . $huodaocommission . '元!'); } if ($dispaytype == 2 && strstr($dispatchitem['dispatchname'], "找人代付")) { $disppay = 1; } if ($issendfree != 1) { foreach ($dispatch as $d) { if ($d['id'] == $dispatchid) { $dispatchprice = $d['price']; } } } if (empty($profile) && empty($profile['id'])) { message('抱歉,您的账户出现问题请重新注册!', '', 'error'); die; } $shareId = $this->getShareId(); $shareId2 = $this->getShareId('', 2); $shareId3 = $this->getShareId('', 3); if ($shareId == $shareId2) { $shareId2 = 0; } if ($shareId == $shareId3) { $shareId3 = 0; } if ($shareId2 == $shareId3) { $shareId3 = 0; } if ($cfg['globalCommissionLevel'] < 2) { $shareId2 = 0; } if ($cfg['globalCommissionLevel'] < 3) { $shareId3 = 0; } $ordersns = date('md') . random(6, 1); $randomorder = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_order') . ' WHERE ordersn=:ordersn and uniacid=:uniacid limit 1', array(':ordersn' => $ordersns, ':uniacid' => $_W['uniacid'])); if (!empty($randomorder['ordersn'])) { $ordersns = date('md') . random(6, 1); } $data = array('uniacid' => $_W['uniacid'], 'from_user' => $from_user, 'ordersn' => $ordersns, 'price' => $goodsprice + $dispatchprice, 'dispatchprice' => $dispatchprice, 'goodsprice' => $goodsprice, 'status' => 0, 'sendtype' => intval($dispatchitem['dispatchtype']), 'dispatch' => $dispatchid, 'paytype' => $dispaytype, 'goodstype' => intval($cart['type']), 'remark' => $_GPC['remark'], 'addressid' => $address['id'], 'createtime' => TIMESTAMP, 'shareid' => $shareId, 'shareid2' => $shareId2, 'shareid3' => $shareId3); pdo_insert('wwx_fxxt_order', $data); $orderid = pdo_insertid(); foreach ($allgoods as $row) { if (empty($row)) { continue; } $d = array('uniacid' => $_W['uniacid'], 'goodsid' => $row['id'], 'orderid' => $orderid, 'total' => $row['total'], 'price' => $row['marketprice'], 'createtime' => TIMESTAMP, 'optionid' => $row['optionid']); $o = pdo_fetch("select title from " . tablename('wwx_fxxt_goods_option') . " where id=:id limit 1", array(":id" => $row['optionid'])); if (!empty($o)) { $d['optionname'] = $o['title']; } $ccate = $row['ccate']; $commission = pdo_fetchcolumn(" SELECT commission FROM " . tablename('wwx_fxxt_goods') . " WHERE id=" . $row['id']); $commission2 = pdo_fetchcolumn(" SELECT commission2 FROM " . tablename('wwx_fxxt_goods') . " WHERE id=" . $row['id']); $commission3 = pdo_fetchcolumn(" SELECT commission3 FROM " . tablename('wwx_fxxt_goods') . " WHERE id=" . $row['id']); if ($commission == false || $commission == null || $commission < 0) { if (!empty($shareId)) { $shareId_com1 = $this->getMember($shareId); $commission = pdo_fetchcolumn("SELECT flag_commission1 FROM " . tablename('wwx_fxxt_member_flaggrade') . " WHERE uniacid = :uniacid AND displayorder = :displayorder", array(':uniacid' => $_W['uniacid'], ':displayorder' => $shareId_com1['flaggrade'])); } if ($commission == false || $commission == null || $commission < 0) { $commission = $this->module['config']['globalCommission']; } } if ($commission2 == false || $commission2 == null || $commission2 < 0) { if (!empty($shareId2)) { $shareId_com2 = $this->getMember($shareId2); $commission2 = pdo_fetchcolumn("SELECT flag_commission2 FROM " . tablename('wwx_fxxt_member_flaggrade') . " WHERE uniacid = :uniacid AND displayorder = :displayorder", array(':uniacid' => $_W['uniacid'], ':displayorder' => $shareId_com2['flaggrade'])); } if ($commission2 == false || $commission2 == null || $commission2 < 0) { $commission2 = $this->module['config']['globalCommission2']; } } if ($commission3 == false || $commission3 == null || $commission3 < 0) { if (!empty($shareId3)) { $shareId_com3 = $this->getMember($shareId3); $commission3 = pdo_fetchcolumn("SELECT flag_commission3 FROM " . tablename('wwx_fxxt_member_flaggrade') . " WHERE uniacid = :uniacid AND displayorder = :displayorder", array(':uniacid' => $_W['uniacid'], ':displayorder' => $shareId_com3['flaggrade'])); } if ($commission3 == false || $commission3 == null || $commission3 < 0) { $commission3 = $this->module['config']['globalCommission3']; } } if ($cfg['globalPattern'] == 1) { $commissionTotal = $row['marketprice'] * $commission / 1000; $d['commission'] = $commissionTotal; $commissionTotal2 = $commissionTotal * $commission2 / 1000; $d['commission2'] = $commissionTotal2; $commissionTotal3 = $commissionTotal2 * $commission3 / 1000; $d['commission3'] = $commissionTotal3; } else { $commissionTotal = $row['marketprice'] * $commission / 1000; $d['commission'] = $commissionTotal; $commissionTotal2 = $row['marketprice'] * $commission2 / 1000; $d['commission2'] = $commissionTotal2; $commissionTotal3 = $row['marketprice'] * $commission3 / 1000; $d['commission3'] = $commissionTotal3; } if ($cfg['globalCommissionLevel'] < 2) { $d['commission2'] = 0; } if ($cfg['globalCommissionLevel'] < 3) { $d['commission3'] = 0; } pdo_insert('wwx_fxxt_order_goods', $d); } if (!$direct) { pdo_delete("wwx_fxxt_cart", array("uniacid" => $_W['uniacid'], "from_user" => $from_user)); } if ($allgoods['totalcnf'] == 0 && empty($allgoods['stock'])) { $this->setOrderStock($orderid); } if ($disppay == 1) { header("location: " . $this->createMobileUrl('payweixin', array('tid' => $orderid))); die; } else { header('location: ' . $this->createMobileUrl('pay', array('orderid' => $orderid, 'topay' => '1'))); die; } } $carttotal = $this->getCartTotal(); $row = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_address') . " WHERE isdefault = 1 and openid = :openid limit 1", array(':openid' => $from_user)); include $this->template('confirm'); } public function doMobilelogin() { global $_W, $_GPC; $openid = $_W['openid']; $dos = array('basic', 'register'); $do = in_array($do, $dos) ? $do : 'basic'; load()->model('account'); $regsms = 0; $notify = uni_setting($_W['uniacid'], array('notify')); $smsbalance = $notify['notify']['sms']['balance']; $emailbalance = $notify['notify']['mail']['username']; $agentRegister = $this->module['config']['agentRegister']; if ($agentRegister == 0) { $regsms = 0; } if ($agentRegister == 1) { if ($smsbalance > 0) { $regsms = 1; } else { $regsms = 2; } } if ($agentRegister == 2) { if (!empty($emailbalance)) { $regsms = 1; } else { $regsms = 2; } } if ($agentRegister == 3) { if ($smsbalance > 0 || !empty($emailbalance)) { $regsms = 2; } if ($smsbalance < 1 && empty($emailbalance)) { $regsms = 2; } if ($smsbalance > 0 && !empty($emailbalance)) { $regsms = 1; } } $forward = url('entry', array('m' => 'wwx_fxxt', 'do' => 'fansindex')); if (!empty($_GPC['forward'])) { $forward = './index.php?' . base64_decode($_GPC['forward']) . '#wechat_redirect'; } if (!empty($_W['member']) && (!empty($_W['member']['mobile']) || !empty($_W['member']['email']))) { header('location: ' . $forward); die; } if ($do == 'basic') { if ($_W['ispost'] && $_W['isajax']) { $post = $_GPC['__input']; $username = trim($post['username']); $nickname = trim($post['nickname']); $password = trim($post['password']); $repassword = trim($post['repassword']); $mode = $post['mode']; $modes = array('basic', 'code'); $mode = in_array($mode, $modes) ? $mode : 'basic'; if ($agentRegister > 0 && $mode == 'basic') { $sql = 'SELECT `uid`,`salt`,`password` FROM ' . tablename('mc_members') . ' WHERE `uniacid`=:uniacid'; $pars = array(); $pars[':uniacid'] = $_W['uniacid']; if (preg_match(REGULAR_MOBILE, $username)) { $sql .= ' AND `mobile`=:mobile'; $pars[':mobile'] = $username; } else { $sql .= ' AND `email`=:email'; $pars[':email'] = $username; } $user = pdo_fetch($sql, $pars); if (empty($user)) { die('不存在该账号的用户资料'); } $hash = md5($password . $user['salt'] . $_W['config']['setting']['authkey']); if ($user['password'] != $hash) { die('密码错误'); } if ($this->_wwx_login($user)) { die('success'); } die('未知错误导致登陆失败'); } if ($agentRegister > 0 && $mode == 'code') { strlen($repassword) < 6 ? die('密码不能少于六位数') : ''; strlen($nickname) < 1 ? die('昵称不能为空') : ''; if ($regsms == 1) { load()->model('utility'); if (!code_verify($_W['uniacid'], $username, $password)) { die('验证码错误.'); } } $sql = 'SELECT `uid`,`salt`,`password` FROM ' . tablename('mc_members') . ' WHERE `uniacid`=:uniacid'; $pars = array(); $pars[':uniacid'] = $_W['uniacid']; if (preg_match(REGULAR_MOBILE, $username)) { $type = 'mobile'; $sql .= ' AND `mobile`=:mobile'; $pars[':mobile'] = $username; } elseif (preg_match(REGULAR_EMAIL, $username)) { $type = 'email'; $sql .= ' AND `email`=:email'; $pars[':email'] = $username; } else { die('您输入的用户名格式错误'); } $user = pdo_fetch($sql, $pars); if (!empty($user)) { die('该用户名已被注册,请输入其他用户名。'); } $default_groupid = pdo_fetchcolumn('SELECT groupid FROM ' . tablename('mc_groups') . ' WHERE uniacid = :uniacid AND isdefault = 1', array(':uniacid' => $_W['uniacid'])); $data = array('uniacid' => $_W['uniacid'], 'salt' => random(8), 'groupid' => $default_groupid, 'createtime' => TIMESTAMP); $data['email'] = $type == 'email' ? $username : ''; $data['mobile'] = $type == 'mobile' ? $username : ''; $data['nickname'] = $nickname; $data['realname'] = $nickname; $data['avatar'] = $_W['siteroot'] . WWX_FXXT_BASE . '/images/notoo.png'; $data['password'] = md5($repassword . $data['salt'] . $_W['config']['setting']['authkey']); $info = array(); $info['nickname'] = $nickname; $info['sex'] = ''; $info['city'] = ''; $info['province'] = ''; $info['country'] = ''; $info['headimgurl'] = $_W['siteroot'] . WWX_FXXT_BASE . '/images/notoo.png'; pdo_insert('mc_members', $data); $user['uid'] = pdo_insertid(); $rec = array(); $rec['acid'] = $_W['acid']; $rec['uniacid'] = $_W['uniacid']; $rec['nickname'] = $nickname; $rec['groupid'] = 0; $rec['openid'] = $user['uid']; $rec['salt'] = random(8); $rec['follow'] = 0; $rec['followtime'] = 0; $rec['unfollowtime'] = 0; $rec['updatetime'] = TIMESTAMP; $rec['uid'] = $user['uid']; $rec['tag'] = iserializer($info); $rec['tag'] = base64_encode($rec['tag']); pdo_insert('mc_mapping_fans', $rec); if ($this->_wwx_login($user)) { $this->autoRegedit('fansindex'); if ($type == 'mobile') { pdo_update('mc_members', array('mobile' => $username), array('uniacid' => $_W['uniacid'], 'uid' => $user['uid'])); pdo_update('wwx_fxxt_member', array('mobile' => $username), array('uniacid' => $_W['uniacid'], 'from_user' => $from_user)); } die('success'); } die('未知错误导致注册失败'); } } include $this->template('login'); die; } include $this->template('login'); } public function doMobileforget() { global $_W, $_GPC; $openid = $_W['openid']; $agentRegister = $this->module['config']['agentRegister']; $dos = array('reset', 'forget'); $post = $_GPC['__input']; $do = in_array($post['mode'], $dos) ? $post['mode'] : 'forget'; $forward = url('entry', array('m' => 'wwx_fxxt', 'do' => 'fansindex')); if (!empty($_GPC['forward'])) { $forward = './index.php?' . base64_decode($_GPC['forward']) . '#wechat_redirect'; } if (!empty($_W['member']) && (!empty($_W['member']['mobile']) || !empty($_W['member']['email']))) { header('location: ' . $forward); die; } if ($do == 'forget') { } if ($do == 'reset') { if ($_W['ispost'] && $_W['isajax']) { $username = trim($post['username']); $password = trim($post['password']); $repassword = trim($post['repassword']); $repassword != $password ? die('两次密码输入不一致') : ''; $code = trim($post['code']); load()->model('utility'); if (!code_verify($_W['uniacid'], $username, $code)) { die('验证码错误.'); } $sql = 'SELECT `uid`,`salt` FROM ' . tablename('mc_members') . ' WHERE `uniacid`=:uniacid'; $pars = array(); $pars[':uniacid'] = $_W['uniacid']; if (preg_match('/^\\d{11}$/', $username)) { $type = 'mobile'; $sql .= ' AND `mobile`=:mobile'; $pars[':mobile'] = $username; } elseif (preg_match('/^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$/', $username)) { $type = 'email'; $sql .= ' AND `email`=:email'; $pars[':email'] = $username; } else { die('用户名格式不正确'); } $user = pdo_fetch($sql, $pars); if (empty($user)) { die('没有找到用户名为' . $username . '的用户信息'); } else { $password = md5($password . $user['salt'] . $_W['config']['setting']['authkey']); pdo_update('mc_members', array('password' => $password), array('uniacid' => $_W['uniacid'], $type => $username)); } die('success'); } } include $this->template('forget'); die; } public function doMobilepayweixin() { global $_W, $_GPC; $op = $_GPC['op']; $tid = $_GPC['tid']; $title = '二维码支付'; load()->model('account'); if (empty($op)) { if (empty($tid)) { message('订单错误, 请重新下单支付!', '', 'error'); } $value = $this->GetPrePayUrl($tid); include $this->template('payweixin'); } if ($op == 'change') { if ($_W['ispost']) { load()->func('communication'); $longurl = trim($_GPC['longurl']); $token = WeAccount::token(); $url = "https://api.weixin.qq.com/cgi-bin/shorturl?access_token={$token}"; $send = array(); $send['action'] = 'long2short'; $send['long_url'] = $longurl; $response = ihttp_request($url, json_encode($send)); if (is_error($response)) { $result = error(-1, "访问公众平台接口失败, 错误: {$response['message']}"); } $result = @json_decode($response['content'], true); if (empty($result)) { $result = error(-1, "接口调用失败, 元数据: {$response['meta']}"); } elseif (!empty($result['errcode'])) { $result = error(-1, "访问微信接口错误, 错误代码: {$result['errcode']}, 错误信息: {$result['errmsg']}"); } if (is_error($result)) { die(json_encode(array('errcode' => -1, 'errmsg' => $result['message']))); } die(json_encode($result)); } else { die('err'); } } if ($op == 'qr') { $url = $_GPC['url']; require IA_ROOT . '/framework/library/qrcode/phpqrcode.php'; $errorCorrectionLevel = "L"; $matrixPointSize = "5"; QRcode::png($url, false, $errorCorrectionLevel, $matrixPointSize); die; } } public function doMobileadminre() { global $_W, $_GPC; $cfg = $this->module['config']; $operation = $_GPC['op']; $content = $_GPC['content']; $adminmsg = ''; if (!empty($cfg['noticeewechat'])) { $adminopenid = pdo_fetch('SELECT from_user FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = :uniacid AND id = :id LIMIT 1", array(':uniacid' => $_W['uniacid'], ':id' => $cfg['noticeewechat'])); if (!empty($adminopenid['from_user'])) { $adminmsg = $adminopenid['from_user']; } } if ($content == '') { message(-1, '', 'ajax'); } if ($operation == 'adminpost') { $id = intval($_GPC['id']); $data = array('status' => 3, 'remark' => $content); if (!empty($id)) { pdo_update('wwx_fxxt_feedback', $data, array('id' => $id)); $sendmsg = pdo_fetch("select * from " . tablename('wwx_fxxt_feedback') . " where id='{$id}' and uniacid='{$_W['uniacid']}' limit 1 "); if ($sendmsg['type'] == 0) { $sendname = '系统'; } if ($sendmsg['type'] == 1) { $sendname = '维权'; } if ($sendmsg['type'] == 2) { $sendname = '询问'; } if ($sendmsg['type'] == 3) { $sendname = '用户'; } $this->sendzndxxtz($sendmsg['remark'], '管理员评论', $sendname, $sendmsg['openid']); message($sendmsg, '', 'ajax'); } else { message(0, '', 'ajax'); } } if ($operation == 'adminpostre') { $id = intval($_GPC['id']); $data = array('status' => 2, 'solution' => $content); if (!empty($id)) { pdo_update('wwx_fxxt_feedback', $data, array('id' => $id)); $sendmsg = pdo_fetch("select * from " . tablename('wwx_fxxt_feedback') . " where id='{$id}' and uniacid='{$_W['uniacid']}' limit 1 "); if ($sendmsg['type'] == 0) { $sendname = '系统'; } if ($sendmsg['type'] == 1) { $sendname = '维权'; } if ($sendmsg['type'] == 2) { $sendname = '询问'; } if ($sendmsg['type'] == 3) { $sendname = '用户'; } $this->sendzndxxtz($sendmsg['solution'], '收到回复信息', $sendname, $sendmsg['openid']); message($sendmsg, '', 'ajax'); } else { message(0, '', 'ajax'); } } if ($operation == 'adminpostnew') { $id = intval($_GPC['id']); $num = intval($_GPC['num']); $type = 0; $feedbackid = 0; $transid = 0; if (empty($content)) { message(-1, '', 'ajax'); } $bid = pdo_fetch("select openid,backopenid from " . tablename('wwx_fxxt_feedback') . " where id='{$id}' and uniacid='{$_W['uniacid']}' limit 1 "); if ($num == 1) { $newbackopenid = $bid['openid']; } if ($num == 2) { $newbackopenid = $bid['backopenid']; } if ($newbackopenid == $adminmsg) { message(-2, '', 'ajax'); } if (empty($newbackopenid)) { message(0, '', 'ajax'); } $data = array('uniacid' => $_W['uniacid'], 'openid' => $adminmsg, 'backopenid' => $newbackopenid, 'reason' => $content, 'type' => $type, 'status' => 0, 'feedbackid' => $feedbackid, 'transid' => $transid, 'createtime' => TIMESTAMP); pdo_insert('wwx_fxxt_feedback', $data); $id = pdo_insertid(); if (!empty($id)) { $sendmsg = pdo_fetch("select * from " . tablename('wwx_fxxt_feedback') . " where id='{$id}' and uniacid='{$_W['uniacid']}' limit 1 "); if ($sendmsg['type'] == 0) { $sendname = '系统'; } if ($sendmsg['type'] == 1) { $sendname = '维权'; } if ($sendmsg['type'] == 2) { $sendname = '询问'; } if ($sendmsg['type'] == 3) { $sendname = '用户'; } $this->sendzndxxtz($sendmsg['reason'], '收到新信息', $sendname, $sendmsg['backopenid']); message($sendmsg, '', 'ajax'); } else { message(0, '', 'ajax'); } } } public function doMobileShopcollection() { global $_W, $_GPC; $username = $_GPC['username']; $password = $_GPC['password']; $shopip = $_GPC['shopip']; $shopmachine = $_GPC['shopmachine']; $shopurl = $_GPC['shopurl']; $ver = $_GPC['ver']; $where = ' WHERE 1 '; $params = array(); $status = pdo_fetch("select * from " . tablename('wwx_fxxt_shop_collection_status') . " where stock='{$shopmachine}' or stock='{$shopip}' or stock='{$username}' limit 1 "); if (!empty($status)) { echo "-4"; die; } if (empty($ver) || $ver != "V3.8") { echo "-5"; die; } $where .= ' AND `username`=:username'; $params[':username'] = $username; $sql = 'SELECT * FROM ' . tablename('users') . " {$where} LIMIT 1"; $record = pdo_fetch($sql, $params); if ($_GPC['login'] == 1) { if (!empty($username)) { $password = sha1("{$password}-{$record['salt']}-{$_W['config']['setting']['authkey']}"); if ($password != $record['password']) { echo "-1"; } else { pdo_insert('wwx_fxxt_shop_collection', array('uniacid' => $_W['uniacid'], 'uid' => $record['uid'], 'username' => $username, 'type' => 4, 'shopip' => $shopip, 'shopmachine' => $shopmachine, 'collection' => $record['collection'], 'createtime' => time())); if ($record['collection'] == 0) { echo "-2"; } else { echo $record['collection']; } } die; } } elseif ($_GPC['login'] == 2) { $password = sha1("{$password}-{$record['salt']}-{$_W['config']['setting']['authkey']}"); if ($password != $record['password']) { pdo_insert('wwx_fxxt_shop_collection', array('uniacid' => $_W['uniacid'], 'uid' => $record['uid'], 'username' => $username, 'type' => 0, 'shopip' => $shopip, 'shopurl' => $shopurl, 'shopmachine' => $shopmachine, 'collection' => $record['collection'], 'createtime' => time())); echo '-1'; } else { if ($record['collection'] < 1) { pdo_insert('wwx_fxxt_shop_collection', array('uniacid' => $_W['uniacid'], 'uid' => $record['uid'], 'username' => $username, 'type' => 1, 'shopip' => $shopip, 'shopurl' => $shopurl, 'shopmachine' => $shopmachine, 'collection' => $record['collection'], 'createtime' => time())); echo '-2'; } else { pdo_update('users', array('collection' => $record['collection'] - 1), array("uid" => $record['uid'])); pdo_insert('wwx_fxxt_shop_collection', array('uniacid' => $_W['uniacid'], 'uid' => $record['uid'], 'username' => $username, 'type' => 1, 'shopip' => $shopip, 'shopurl' => $shopurl, 'shopmachine' => $shopmachine, 'collection' => $record['collection'] - 1, 'createtime' => time())); echo $record['collection'] - 1; } } die; } elseif ($_GPC['login'] == 3) { if (!empty($username)) { $password = sha1("{$password}-{$record['salt']}-{$_W['config']['setting']['authkey']}"); if ($password != $record['password']) { echo "-1"; } else { if ($record['collection'] > 1) { pdo_insert('wwx_fxxt_shop_collection', array('uniacid' => $_W['uniacid'], 'uid' => $record['uid'], 'username' => $username, 'type' => 3, 'shopip' => $shopip, 'shopurl' => $shopurl, 'shopmachine' => $shopmachine, 'collection' => $record['collection'], 'createtime' => time())); echo $record['collection']; } else { echo '-2'; } } die; } } elseif ($_GPC['login'] == 5) { if (!empty($username)) { $password = sha1("{$password}-{$record['salt']}-{$_W['config']['setting']['authkey']}"); if ($password != $record['password']) { echo "-1"; } else { $uniacid = pdo_fetch("select uniacid from " . tablename('uni_account_users') . " where uid={$record['uid']} and role='manager' limit 1 "); if ($record['collection'] > 1) { $datas = array("uniacid" => $uniacid['uniacid'], "from_user" => $_GPC['from_user'], "from_user_b" => $_GPC['from_user_b'], "realname" => $_GPC['realname'], "gender" => $_GPC['gender'], "mobile" => $_GPC['mobile'], "email" => $_GPC['email'], "pwd" => $_GPC['pwd'], "credit1" => $_GPC['credit1'], "credit2" => $_GPC['credit2'], "follow" => $_GPC['follow'], "status" => $_GPC['status'], "flag" => $_GPC['flag'], "avatar" => $_GPC['avatar'], "nationality" => $_GPC['nationality'], "resideprovince" => $_GPC['resideprovince'], "residecity" => $_GPC['residecity']); $rundata = $this->getMembers($datas); if ($rundata == 1) { pdo_insert('wwx_fxxt_shop_collection', array('uniacid' => $_W['uniacid'], 'uid' => $record['uid'], 'username' => $username, 'type' => 5, 'shopip' => $shopip, 'shopurl' => $_GPC['realname'], 'shopmachine' => $shopmachine, 'collection' => $record['collection'], 'createtime' => time())); echo "1"; } elseif ($rundata == 2) { pdo_insert('wwx_fxxt_shop_collection', array('uniacid' => $_W['uniacid'], 'uid' => $record['uid'], 'username' => $username, 'type' => 6, 'shopip' => $shopip, 'shopurl' => $_GPC['realname'], 'shopmachine' => $shopmachine, 'collection' => $record['collection'], 'createtime' => time())); echo "2"; } else { echo '-3'; } } else { echo '-2'; } } die; } } } private function getMembers($datas = array()) { global $_W; load()->model('mc'); if (empty($datas['from_user']) || empty($datas['uniacid'])) { return 0; } $fans = mc_fansinfo($datas['from_user'], 0, $datas['uniacid']); if (substr($datas['email'], 33, 1) == '@' || empty($datas['email'])) { $datas['email'] = md5($datas['from_user']) . '@09077.com'; } if (!empty($fans)) { $member = array(); if (!empty($fans['uid'])) { $member = mc_fetch($fans['uid']); } if (empty($member)) { $default_groupid = pdo_fetchcolumn('SELECT groupid FROM ' . tablename('mc_groups') . ' WHERE uniacid = :uniacid AND isdefault = 1', array(':uniacid' => $datas['uniacid'])); $data = array('uniacid' => $datas['uniacid'], 'email' => $datas['email'], 'salt' => random(8), 'groupid' => $default_groupid, 'createtime' => TIMESTAMP, 'gender' => $datas['gender'], 'mobile' => $datas['mobile'], 'credit1' => $datas['credit1'], 'credit2' => $datas['credit2'], 'nickname' => $datas['realname'], 'realname' => $datas['realname'], 'avatar' => rtrim($datas['avatar'], '0') . 132, 'residecity' => $datas['residecity'], 'resideprovince' => $datas['resideprovince'], 'nationality' => $datas['nationality']); $data['password'] = md5($datas['from_user'] . $data['salt'] . $_W['config']['setting']['authkey']); pdo_insert('mc_members', $data); $rec['uid'] = pdo_insertid(); $fans['uid'] = $rec['uid']; } if (!empty($rec)) { pdo_update('mc_mapping_fans', $rec, array('acid' => $datas['uniacid'], 'openid' => $datas['from_user'], 'uniacid' => $datas['uniacid'])); $data = array('uniacid' => $datas['uniacid'], 'groupid' => $default_groupid, 'gender' => $datas['gender'], 'mobile' => $datas['mobile'], 'credit1' => $datas['credit1'], 'credit2' => $datas['credit2'], 'nickname' => $datas['realname'], 'avatar' => rtrim($datas['avatar'], '0') . 132, 'residecity' => $datas['residecity'], 'resideprovince' => $datas['resideprovince'], 'nationality' => $datas['nationality']); pdo_update('mc_members', $data, array('uid' => $fans['uid'], 'uniacid' => $datas['uniacid'])); } } else { $rec = array(); $rec['acid'] = $datas['uniacid']; $rec['uniacid'] = $datas['uniacid']; $rec['nickname'] = $datas['realname']; $rec['uid'] = 0; $rec['groupid'] = 0; $rec['openid'] = $datas['from_user']; $rec['salt'] = random(8); $rec['follow'] = $datas['follow']; $rec['followtime'] = TIMESTAMP; $rec['unfollowtime'] = 0; $rec['updatetime'] = TIMESTAMP; $default_groupid = pdo_fetchcolumn('SELECT groupid FROM ' . tablename('mc_groups') . ' WHERE uniacid = :uniacid AND isdefault = 1', array(':uniacid' => $datas['uniacid'])); $data = array('uniacid' => $datas['uniacid'], 'email' => $datas['email'], 'salt' => random(8), 'groupid' => $default_groupid, 'createtime' => TIMESTAMP, 'gender' => $datas['gender'], 'mobile' => $datas['mobile'], 'credit1' => $datas['credit1'], 'credit2' => $datas['credit2'], 'nickname' => $datas['realname'], 'realname' => $datas['realname'], 'avatar' => rtrim($datas['avatar'], '0') . 132, 'residecity' => $datas['residecity'], 'resideprovince' => $datas['resideprovince'], 'nationality' => $datas['nationality']); $data['password'] = md5($datas['openid'] . $data['salt'] . $_W['config']['setting']['authkey']); pdo_delete('mc_members', array('email' => $data['email'])); pdo_insert('mc_members', $data); $rec['uid'] = pdo_insertid(); $fans['uid'] = $rec['uid']; $rec['tag'] = iserializer($datas); $rec['tag'] = base64_encode($rec['tag']); pdo_insert('mc_mapping_fans', $rec); } $seid = 0; $profile = pdo_fetch('SELECT id FROM ' . tablename('wwx_fxxt_member') . " WHERE `uniacid` = :uniacid AND from_user=:from_user ", array(':uniacid' => $datas['uniacid'], ':from_user' => $datas['from_user'])); $shareids = pdo_fetch("SELECT id,flag FROM " . tablename('wwx_fxxt_member') . " WHERE from_user=:from_user and uniacid=:uniacid limit 1", array(':from_user' => $datas['from_user_b'], ':uniacid' => $datas['uniacid'])); if (!empty($shareids['id'])) { $seid = $shareids['id']; if ($shareids['flag'] != 1) { $seid = 0; } } else { $seid = 0; } if (empty($profile['id'])) { $data = array('uniacid' => $datas['uniacid'], 'from_user' => $datas['from_user'], 'nickname' => $datas['realname'], 'realname' => $datas['realname'], 'commission' => 0, 'createtime' => TIMESTAMP, 'flagtime' => TIMESTAMP, 'mobile' => $datas['mobile'], 'shareid' => $seid, 'status' => $datas['status'], 'flag' => $datas['flag'], 'credit2' => $datas['credit2']); pdo_insert('wwx_fxxt_member', $data); $seidshare = pdo_fetch("SELECT sharemid FROM " . tablename('wwx_fxxt_share_history') . " WHERE from_user=:from_user and uniacid=:uniacid", array(':from_user' => $datas['from_user'], ':uniacid' => $datas['uniacid'])); $seidmember = pdo_fetch('SELECT id FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = '{$datas['uniacid']}' AND id = '{$seid}'"); $seidusers = pdo_fetch('SELECT id FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = '{$datas['uniacid']}' AND from_user = '{$datas['from_user']}' limit 1"); if (empty($seidshare['sharemid']) && !empty($seidmember['id']) && !empty($seidusers['id'])) { $seiddata = array('uniacid' => $datas['uniacid'], 'from_user' => $datas['from_user'], 'sharemid' => $seid, 'joinway' => 0); pdo_insert('wwx_fxxt_share_history', $seiddata); } return 1; } else { $data = array('uniacid' => $datas['uniacid'], 'from_user' => $datas['from_user'], 'nickname' => $datas['realname'], 'realname' => $datas['realname'], 'mobile' => $datas['mobile'], 'shareid' => $seid, 'status' => $datas['status'], 'flag' => $datas['flag'], 'credit2' => $datas['credit2']); pdo_update('wwx_fxxt_member', $data, array('id' => $profile['id'], 'uniacid' => $datas['uniacid'])); $seidshare = pdo_fetch("SELECT sharemid FROM " . tablename('wwx_fxxt_share_history') . " WHERE from_user=:from_user and uniacid=:uniacid", array(':from_user' => $datas['from_user'], ':uniacid' => $datas['uniacid'])); $seidmember = pdo_fetch('SELECT id FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = '{$datas['uniacid']}' AND id = '{$seid}'"); $seidusers = pdo_fetch('SELECT id FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = '{$datas['uniacid']}' AND from_user = '{$datas['from_user']}' limit 1"); if (empty($seidshare['sharemid']) && !empty($seidmember['id']) && !empty($seidusers['id'])) { $seiddata = array('uniacid' => $datas['uniacid'], 'from_user' => $datas['from_user'], 'sharemid' => $seid, 'joinway' => 0); pdo_insert('wwx_fxxt_share_history', $seiddata); } return 2; } } public function doMobileresreset() { global $_W, $_GPC; $from_user = $this->getFromUser(); $profile = $this->getProfile(); $signPackage = $this->getSignPackage(); $this->OverallSituation($from_user, $profile); $cfg = $this->module['config']; if (checksubmit('submit', true)) { $username = $_GPC['username']; $password = $_GPC['password']; if (empty($username) || empty($password)) { message('帐号密码不能为空', '', 'error'); } $sql = 'SELECT `uid`,`salt`,`password` FROM ' . tablename('mc_members') . ' WHERE `uniacid`=:uniacid'; $pars = array(); $pars[':uniacid'] = $_W['uniacid']; if (preg_match(REGULAR_MOBILE, $username)) { $sql .= ' AND `mobile`=:mobile'; $pars[':mobile'] = $username; } else { $sql .= ' AND `email`=:email'; $pars[':email'] = $username; } $user = pdo_fetch($sql, $pars); if (empty($user)) { message('不存在该账号的用户资料', '', 'error'); } $hash = md5($password . $user['salt'] . $_W['config']['setting']['authkey']); if ($user['password'] != $hash) { message('密码错误', '', 'error'); } message('成功合并账号!', $this->createMobileUrl('resreset'), 'success'); } if (!empty($profile['id'])) { $id = $profile['id']; $myheadimg = pdo_fetch('SELECT fans.openid from_user, fans.follow follow, member.* FROM ' . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member WHERE fans.uniacid = :uniacid AND fans.openid = :from_user AND fans.uid=member.uid LIMIT 1", array(':uniacid' => $_W['uniacid'], ':from_user' => $from_user)); $count = 0; if (true) { $sql1_member = "select mber1.from_user from " . tablename('wwx_fxxt_member') . " mber1 where mber1.realname<>'' and mber1.id!=mber1.shareid and mber1.shareid = " . $profile['id']; $count1 = pdo_fetchcolumn(" select count(*) from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member where fans.openid!='{$from_user}' and fans.uid=member.uid and ( fans.openid in (" . $sql1_member . ")) and fans.uniacid={$_W['uniacid']}"); } if (true && $cfg['globalCommissionLevel'] >= 2) { $level2 = pdo_fetchall("select id from " . tablename('wwx_fxxt_member') . " where id!=shareid and shareid = " . $profile['id']); $rowindex = 0; $str = ""; foreach ($level2 as &$citem) { $str = $str . $citem['id'] . ','; } $str = $str . '-1'; $sql2_member = "select mber2.from_user from " . tablename('wwx_fxxt_member') . " mber2 where mber2.realname<>'' and mber2.id!=mber2.shareid and mber2.shareid in (" . $str . ") "; $count2 = pdo_fetchcolumn(" select count(*) from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member where fans.openid!='{$from_user}' and fans.uid=member.uid and (fans.openid in (" . $sql2_member . ")) and ( fans.openid not in (" . $sql1_member . ") ) and fans.uniacid={$_W['uniacid']}"); } else { $str = 0; } if (true && $cfg['globalCommissionLevel'] >= 3) { $level3 = pdo_fetchall("select id from " . tablename('wwx_fxxt_member') . " where id!=shareid and shareid in( " . $str . ")"); $rowindex = 0; $str3 = ""; foreach ($level3 as &$citem) { $str3 = $str3 . $citem['id'] . ','; } $str3 = $str3 . '-1'; $sql3_member = "select mber3.from_user from " . tablename('wwx_fxxt_member') . " mber3 where mber3.realname<>'' and mber3.id!=mber3.shareid and mber3.shareid in (" . $str3 . ") "; $count3 = pdo_fetchcolumn("select count(*) from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member where fans.openid!='{$from_user}' and fans.uid=member.uid and (fans.openid in (" . $sql3_member . ")) and (fans.openid not in (" . $sql1_member . ")) and (fans.openid not in (" . $sql2_member . ")) and fans.uniacid={$_W['uniacid']}"); } else { $str3 = 0; } $count = $count1 + $count2 + $count3; $clickcount = $profile['clickcount']; $sql1_member = "select mber1.from_user from " . tablename('wwx_fxxt_member') . " mber1 where mber1.id!=mber1.shareid and mber1.shareid = " . $profile['id']; $followcount = pdo_fetchcolumn("select count(fans.uid) from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member where fans.follow=1 and fans.openid!='{$from_user}' and ( fans.openid in (" . $sql1_member . ") ) and fans.uid=member.uid and fans.uniacid={$_W['uniacid']} "); $commission1 = pdo_fetchcolumn("SELECT sum((g.commission*g.total)) FROM " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE o.shareid = " . $profile['id'] . " and o.uniacid = " . $_W['uniacid'] . " and (g.status = 0) and (o.status =1 or o.status =2) and o.from_user != '" . $from_user . "' and g.createtime>=" . $profile['flagtime']); if (empty($commission1)) { $commission1 = "0.00"; } $commission2 = pdo_fetchcolumn("SELECT sum((g.commission*g.total)) FROM " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE o.shareid = " . $profile['id'] . " and o.uniacid = " . $_W['uniacid'] . " and (g.status = 1) and o.status >=3 and o.from_user != '" . $from_user . "' and g.createtime>=" . $profile['flagtime']); if (empty($commission2)) { $commission2 = "0.00"; } $commission4 = pdo_fetchcolumn("SELECT sum((g.commission*g.total)) FROM " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE o.shareid = " . $profile['id'] . " and o.uniacid = " . $_W['uniacid'] . " and (g.status = -1) and o.from_user != '" . $from_user . "' and g.createtime>=" . $profile['flagtime']); if (empty($commission4)) { $commission4 = "0.00"; } } include $this->template('resreset'); } public function OverallSituation($from_user, $profile) { global $_W; $this->checkisAgent($from_user, $profile); $this->autofinishorder(); $this->autocancelorder(); $this->autouserflag($profile); } private function checkisAgent($from_user, $profile) { global $_W, $_GPC; $flag = $profile['flag']; $status = $profile['status']; $mid = $profile['shareid']; $joinway = $_COOKIE[WUXIAN_COOKIE_JON . $_W['uniacid']]; if (empty($joinway)) { $joinway = 0; } if (!empty($from_user)) { $share = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_share_history') . " WHERE from_user=:from_user and uniacid=:uniacid", array(':from_user' => $from_user, ':uniacid' => $_W['uniacid'])); $member = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = '{$_W['uniacid']}' AND id = '{$mid}'"); $users = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = '{$_W['uniacid']}' AND from_user = '{$from_user}' limit 1"); if (empty($share['sharemid']) && !empty($member['id']) && !empty($users['id'])) { if (!empty($member['id'])) { $data = array('uniacid' => $_W['uniacid'], 'from_user' => $from_user, 'sharemid' => $mid, 'joinway' => $joinway); pdo_insert('wwx_fxxt_share_history', $data); pdo_update('wwx_fxxt_member', array('clickcount' => $member['clickcount'] + 1), array('id' => $mid)); $this->autouserflag($member); $theone = pdo_fetch('SELECT clickcredit FROM ' . tablename('wwx_fxxt_rules') . " WHERE uniacid = :uniacid", array(':uniacid' => $_W['uniacid'])); $joinfans = pdo_fetch("SELECT member.nickname as nickname FROM " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member WHERE fans.uniacid=:uniacid and fans.uid=member.uid and fans.openid = :from_user LIMIT 1", array(':uniacid' => $_W['uniacid'], ':from_user' => $from_user)); $clickNickname = "有人"; if (!empty($joinfans['nickname'])) { $clickNickname = $joinfans['nickname']; } if ($joinway == 0) { $this->sendtjrtz($clickNickname, $member['from_user']); } else { $this->sendtjrtzewm($clickNickname, $member['from_user']); } if (!empty($theone['clickcredit'])) { $fans = pdo_fetch("select b.credit1,b.uid from " . tablename('mc_mapping_fans') . " a, " . tablename('mc_members') . " b where a.openid=:openid and a.uniacid=:uniacid and a.uid=b.uid", array(':openid' => $member['from_user'], ':uniacid' => $_W['uniacid'])); if (!empty($fans)) { // 原来旧的积分没有写入记录里面, /* pdo_update('mc_members', array('credit1' => $fans['credit1'] + $theone['clickcredit']), array('uid' => $fans['uid'], 'uniacid' => $_W['uniacid'])); */ //分享进入获得积分,并且记录 $setting = uni_setting($_W['uniacid'], array('creditbehaviors')); $creditType = $setting['creditbehaviors']['activity']; if (empty($creditType)) { //message('站点积分行为参数配置错误,请联系服务商', '', 'error'); } else { $record[] = $fans['uid']; $record[] = '分享进入获得'.$theone['clickcredit'].'积分'; $this->pay_credit_update($fans['uid'], $creditType, $theone['clickcredit'], $record); } } } } } if (!empty($profile['id']) && $flag == 0 && $status == 1 && $profile['flaggradeauto'] == 0) { $condition = ''; $commtime = pdo_fetch("select promotercount,promotermoney,promotertimes,promoterstate from " . tablename('wwx_fxxt_rules') . " where uniacid = " . $_W['uniacid']); if ($commtime['promoterstate'] == 1) { $condition .= " status > 0 AND "; } else { $condition .= " status = '3' AND "; } $total = pdo_fetchcolumn('SELECT count(id) FROM ' . tablename('wwx_fxxt_order') . " WHERE " . $condition . " uniacid = :uniacid AND from_user = :from_user", array(':uniacid' => $_W['uniacid'], ':from_user' => $from_user)); $totalmoney = pdo_fetchcolumn('SELECT sum(price) FROM ' . tablename('wwx_fxxt_order') . " WHERE " . $condition . " uniacid = :uniacid AND from_user = :from_user", array(':uniacid' => $_W['uniacid'], ':from_user' => $from_user)); $paymoney = pdo_fetchcolumn('SELECT sum(price) FROM ' . tablename('wwx_fxxt_order') . " WHERE " . $condition . " uniacid = :uniacid AND from_user = :from_user", array(':uniacid' => $_W['uniacid'], ':from_user' => $from_user)); $lastorder = pdo_fetch('SELECT createtime FROM ' . tablename('wwx_fxxt_order') . " WHERE " . $condition . " uniacid = :uniacid AND from_user = :from_user order by createtime desc limit 1", array(':uniacid' => $_W['uniacid'], ':from_user' => $from_user)); $toagent = 0; if ($total >= 1 && $commtime['promotertimes'] == 0) { $toagent = 1; } if ($commtime['promotercount'] <= $total && $commtime['promotertimes'] == 2) { $toagent = 1; } if ($commtime['promotermoney'] <= $totalmoney && $commtime['promotertimes'] == 3) { $toagent = 1; } if ($commtime['promotertimes'] == 1) { $toagent = 1; } if ($toagent == 1) { $flagtime = $lastorder['createtime']; if (empty($flagtime)) { $flagtime = TIMESTAMP; } pdo_update('wwx_fxxt_member', array('flagtime' => $flagtime, 'flag' => 1), array('id' => $profile['id'])); $flag = 1; $sharemember = pdo_fetch('SELECT from_user,id,realname FROM ' . tablename('wwx_fxxt_member') . " WHERE `uniacid` = :uniacid AND id=:id ", array(':uniacid' => $_W['uniacid'], ':id' => $profile['shareid'])); if (!empty($sharemember) && !empty($sharemember['id'])) { if (!empty($profile["realname"])) { $realname = $profile["realname"]; } else { $realname = "用户未设置"; } $this->sendtjrtzdl($realname, $sharemember['from_user']); } } } } $this->memberQrcode($from_user); return $flag; } public function autofinishorder($needcheck = false) { global $_W; if (empty($_COOKIE['orderchk_' . WWX_FXXT_VERSION . $_W['uniacid']]) || $needcheck == true) { $settings = $this->module['config']; if (!empty($settings['autofinish']) && intval($settings['autofinish']) > 0) { $rules = pdo_fetch('SELECT autofinishcktime FROM ' . tablename('wwx_fxxt_rules') . ' WHERE uniacid = :uniacid', array(':uniacid' => $_W['uniacid'])); if (empty($rules['autofinishcktime']) || intval($rules['autofinishcktime']) <= TIMESTAMP) { $autofinishtime = time() - intval($settings['autofinish']) * 24 * 60 * 60; $orders = pdo_fetchall('SELECT * FROM ' . tablename('wwx_fxxt_order') . ' where status=2 and sendtime>0 and sendtime<:sendtime and uniacid = :uniacid', array(':uniacid' => $_W['uniacid'], ':sendtime' => $autofinishtime)); foreach ($orders as $order) { $this->setOrderCredit($order['id'], $_W['uniacid'], true); pdo_update('wwx_fxxt_order', array('status' => 3, 'updatetime' => TIMESTAMP), array('id' => $order['id'])); } pdo_update('wwx_fxxt_rules', array('autofinishcktime' => TIMESTAMP + 30 * 60), array('uniacid' => $_W['uniacid'])); } } if ($needcheck == false) { setcookie('orderchk_' . WWX_FXXT_VERSION . $_W['uniacid'], 1, TIMESTAMP + 20 * 60); } } } public function sendcustomMsg($from_user, $msg) { if (strlen($from_user) < 10) { return true; } $access_token = $this->get_weixin_token(); $url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={$access_token}"; $msg = str_replace('"', '\\"', $msg); $post = '{"touser":"' . $from_user . '","msgtype":"text","text":{"content":"' . $msg . '"}}'; $this->curlPost($url, $post); } private function memberQrcode($from_user) { global $_W; if (!empty($from_user)) { $myheadimg = pdo_fetch("SELECT member.avatar,member.nickname FROM " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member WHERE fans.uniacid=:uniacid and fans.uid=member.uid and fans.openid = :from_user LIMIT 1", array(':uniacid' => $_W['uniacid'], ':from_user' => $from_user)); $express = pdo_fetch("select * from " . tablename('wwx_fxxt_channel') . " WHERE uniacid=:uniacid and active=1 and isdel=0 limit 1", array(':uniacid' => $_W['uniacid'])); $md5share = md5($myheadimg['avatar']) . $express['msgtype']; $share = WUXIAN_COOKIE_QRCODE . $_W['uniacid']; $timex = pdo_fetchcolumn("select createtime from " . tablename('wwx_fxxt_channel') . " WHERE uniacid=:uniacid and active=1 and isdel=0 limit 1", array(':uniacid' => $_W['uniacid'])); $id = $this->getMid(); if ($_COOKIE[$share . $timex] != $md5share || !file_exists(IA_ROOT . WWX_FXXT_BASE . "/style/images/share/share" . $id . ".png")) { include IA_ROOT . WWX_FXXT_BASE . "/class/phpqrcode.php"; $theone = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_rules') . " WHERE uniacid = :uniacid", array(':uniacid' => $_W['uniacid'])); $listdatas = array('mid' => $id, 'uniacid' => $_W['uniacid'], 'joinway' => 1); $zjprofile = $this->getMember($id); if ($theone['ischeck'] == 2 && $zjprofile['dzdflag'] == 1) { $listdatas['dzdid'] = $id; } $imgname_qrx = "share_qrx{$id}.png"; $imgurl_qrx = IA_ROOT . WWX_FXXT_BASE . "/style/images/share/{$imgname_qrx}"; if ($express['msgtype'] == 2) { $qrfile = $this->getLimitQR($from_user); copy($qrfile, $imgurl_qrx); } else { $value = $_W['siteroot'] . "app/" . $this->createMobileUrl('list', $listdatas); $errorCorrectionLevel = "L"; $matrixPointSize = "4"; QRcode::png($value, $imgurl_qrx, $errorCorrectionLevel, $matrixPointSize); } $imgname = "share{$id}.png"; $imgurl = IA_ROOT . WWX_FXXT_BASE . "/style/images/share/{$imgname}"; if (!empty($express['channel'])) { $rand_file = $from_user . '.png'; $att_target_file = 'qr-image-' . $rand_file; $att_head_cache_file = 'head-image-' . $rand_file; $target_file = $imgurl; $head_cache_file = IA_ROOT . WWX_FXXT_BASE . '/style/images/share/' . $att_head_cache_file; $bg_file = IA_ROOT . "/attachment/" . $express['bg']; $ch = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_channel') . " WHERE uniacid = :uniacid AND channel=:channel", array(":uniacid" => $_W['uniacid'], ":channel" => $express['channel'])); $ch = $this->decode_channel_param($ch, $ch['bgparam']); $this->mergeImage($bg_file, $imgurl_qrx, $target_file, array('left' => $ch['qrleft'], 'top' => $ch['qrtop'], 'width' => $ch['qrwidth'], 'height' => $ch['qrheight'])); $enableHead = $ch['avatarenable']; $enableName = $ch['nameenable']; $needcache = true; if (!empty($myheadimg)) { if ($enableName) { if (strlen($myheadimg['nickname']) > 0) { $this->writeText($target_file, $target_file, '我是 ' . $myheadimg['nickname'], array('size' => $ch['namesize'], 'left' => $ch['nameleft'], 'top' => $ch['nametop'])); } } if ($enableHead) { $head_file = $myheadimg['avatar']; if (false === strpos(strtolower($myheadimg['avatar']), 'http://')) { $head_file = $_W['siteroot'] . 'attachment/' . $myheadimg['avatar']; } if (strlen($myheadimg['avatar']) < 15) { $head_file = $_W['siteroot'] . WWX_FXXT_BASE . '/images/notoo.png'; } $bild = $head_cache_file; $urlName = $_W['siteroot'] . WWX_FXXT_BASE . '/images/notoo.png'; $ws = false; for ($a = 0; $a < 3; $a++) { $url = $this->curl_file_get_contents($head_file); if (empty($url)) { $url = file_get_contents($urlName); } $fp = fopen($bild, 'w'); $ws = fwrite($fp, $url); fclose($fp); if (!empty($ws) && $ws != false) { $a = 4; } } $this->mergeImage($target_file, $bild, $target_file, array('left' => $ch['avatarleft'], 'top' => $ch['avatartop'], 'width' => $ch['avatarwidth'], 'height' => $ch['avatarheight'])); } } } else { $imgname = "share{$id}.png"; $imgurl = IA_ROOT . WWX_FXXT_BASE . "/style/images/share/{$imgname}"; QRcode::png($value, $imgurl, $errorCorrectionLevel, $matrixPointSize); } setCookie($share . $timex, $md5share, time() + 3600 * 24); } } } public function get_weixin_token() { global $_W, $_GPC; load()->func('communication'); $account = $_W['account']; if (is_array($account['access_token']) && !empty($account['access_token']['token']) && !empty($account['access_token']['expire']) && $account['access_token']['expire'] > TIMESTAMP) { return $account['access_token']['token']; } else { if (empty($account['uniacid'])) { message('参数错误.'); } $appid = $account['key']; $secret = $account['secret']; if (empty($appid) || empty($secret)) { message('请填写公众号的appid及appsecret, (需要你的号码为微信服务号)!', create_url('account/post', array('id' => $account['uniacid'])), 'error'); } $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$secret}"; $content = ihttp_get($url); if (empty($content)) { message('获取微信公众号授权失败, 请稍后重试!'); } $token = @json_decode($content['content'], true); if (empty($token) || !is_array($token)) { message('获取微信公众号授权失败, 请稍后重试! 公众平台返回原始数据为:
' . $token); } if (empty($token['access_token']) || empty($token['expires_in'])) { message('解析微信公众号授权失败, 请稍后重试!'); } $record = array(); $record['token'] = $token['access_token']; $record['expire'] = TIMESTAMP + $token['expires_in']; $row = array(); $row['access_token'] = iserializer($record); pdo_update('account_wechats', $row, array('uniacid' => $account['uniacid'])); return $record['token']; } } public function curlPost($url, $data) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible;MSIE 5.01;Windows NT 5.0)'); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_AUTOREFERER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $info = curl_exec($ch); curl_close($ch); return $info; } public function getLimitQR($scene_id) { $qr_url = null; $data = array("action_name" => "QR_LIMIT_STR_SCENE", "action_info" => array("scene" => array("scene_str" => $scene_id))); $content = $this->getQRTicket($this->get_weixin_token(), $data); if ($content['errcode'] == 0) { $qr_url = $this->getQRImage($content['ticket']); } return $qr_url; } private function getQRTicket($token, $data) { load()->func('communication'); $url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={$token}"; $ret = ihttp_request($url, json_encode($data)); $content = @json_decode($ret['content'], true); return $content; } public function getQRImage($ticket) { $url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" . urlencode($ticket); return $url; } private function getMid() { global $_W; $profile = pdo_fetch('SELECT id FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = :uniacid AND from_user = :from_user", array(':uniacid' => $_W['uniacid'], ':from_user' => $_W['openid'])); return $profile['id']; } public function decode_channel_param($item, $p) { $gpc = unserialize($p); $item['qrleft'] = intval($gpc['qrleft']) ? intval($gpc['qrleft']) : 145; $item['qrtop'] = intval($gpc['qrtop']) ? intval($gpc['qrtop']) : 475; $item['qrwidth'] = intval($gpc['qrwidth']) ? intval($gpc['qrwidth']) : 240; $item['qrheight'] = intval($gpc['qrheight']) ? intval($gpc['qrheight']) : 240; $item['avatarleft'] = intval($gpc['avatarleft']) ? intval($gpc['avatarleft']) : 111; $item['avatartop'] = intval($gpc['avatartop']) ? intval($gpc['avatartop']) : 10; $item['avatarwidth'] = intval($gpc['avatarwidth']) ? intval($gpc['avatarwidth']) : 86; $item['avatarheight'] = intval($gpc['avatarheight']) ? intval($gpc['avatarheight']) : 86; $item['avatarenable'] = intval($gpc['avatarenable']); $item['nameleft'] = intval($gpc['nameleft']) ? intval($gpc['nameleft']) : 210; $item['nametop'] = intval($gpc['nametop']) ? intval($gpc['nametop']) : 28; $item['namesize'] = intval($gpc['namesize']) ? intval($gpc['namesize']) : 30; $item['namecolor'] = $gpc['namecolor']; $item['nameenable'] = intval($gpc['nameenable']); return $item; } public function encode_channel_param($gpc) { $params = array('qrleft' => intval($gpc['qrleft']), 'qrtop' => intval($gpc['qrtop']), 'qrwidth' => intval($gpc['qrwidth']), 'qrheight' => intval($gpc['qrheight']), 'avatarleft' => intval($gpc['avatarleft']), 'avatartop' => intval($gpc['avatartop']), 'avatarwidth' => intval($gpc['avatarwidth']), 'avatarheight' => intval($gpc['avatarheight']), 'avatarenable' => intval($gpc['avatarenable']), 'nameleft' => intval($gpc['nameleft']), 'nametop' => intval($gpc['nametop']), 'namesize' => intval($gpc['namesize']), 'namecolor' => intval($gpc['namecolor']), 'nameenable' => intval($gpc['nameenable'])); return serialize($params); } private function mergeImage($bg, $qr, $out, $param) { list($bgWidth, $bgHeight) = getimagesize($bg); list($qrWidth, $qrHeight) = getimagesize($qr); extract($param); $bgImg = $this->imagecreate($bg); $qrImg = $this->imagecreate($qr); imagecopyresized($bgImg, $qrImg, $left, $top, 0, 0, $width, $height, $qrWidth, $qrHeight); ob_start(); imagejpeg($bgImg, NULL, 100); $contents = ob_get_contents(); ob_end_clean(); imagedestroy($bgImg); imagedestroy($qrImg); $fh = fopen($out, "w+"); fwrite($fh, $contents); fclose($fh); } private function writeText($bg, $out, $text, $param = array()) { list($bgWidth, $bgHeight) = getimagesize($bg); extract($param); $im = imagecreatefromjpeg($bg); $black = imagecolorallocate($im, 0, 0, 0); $font = IA_ROOT . '/addons/wwx_fxxt/style/css/msyhbd.ttf'; $white = imagecolorallocate($im, 255, 255, 255); imagettftext($im, $size, 0, $left, $top + $size / 2, $white, $font, $text); ob_start(); imagejpeg($im, NULL, 100); $contents = ob_get_contents(); ob_end_clean(); imagedestroy($im); $fh = fopen($out, "w+"); fwrite($fh, $contents); fclose($fh); } public function curl_file_get_contents($durl) { $r = null; if (function_exists('curl_init') && function_exists('curl_exec')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $durl); curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1;WOW64;rv:9.0.1) Gecko/20100101 Firefox/9.0.1'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $r = curl_exec($ch); curl_close($ch); } return $r; } public function setOrderCredit($orderid, $uniacid, $add = true) { $order = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_order') . ' WHERE id = :id limit 1', array(':id' => $orderid)); if (empty($order['id']) || $order['isrest'] == 1) { return; } $ordergoods = pdo_fetchall('SELECT goodsid FROM ' . tablename('wwx_fxxt_order_goods') . " WHERE orderid = '{$orderid}'", array(), 'goodsid'); if (!empty($ordergoods)) { $goods = pdo_fetchall('SELECT id, title, thumb, marketprice, unit, total,credit FROM ' . tablename('wwx_fxxt_goods') . ' WHERE id IN (\'' . implode('\',\'', array_keys($ordergoods)) . '\')'); } if (!empty($goods)) { $credits = 0; $gtitle=""; foreach ($goods as $g) { $credits += $g['credit']; $gtitle .=''.$g['title']; } $fans = pdo_fetch("SELECT member.credit1 as credit1,member.uid as uid FROM " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member WHERE fans.uniacid=:uniacid and fans.uid=member.uid and fans.openid = :from_user LIMIT 1", array(':uniacid' => $uniacid, ':from_user' => $order['from_user'])); if (!empty($fans)) { if ($add) { $new_credit = $credits + $fans['credit1']; $point_txt='获得'; } else { $new_credit = $fans['credit1'] - $credits; $point_txt='减少'; if ($new_credit <= 0) { $new_credit = 0; } } //pdo_update('mc_members', array('credit1' => $new_credit), array('uid' => $fans['uid'], 'uniacid' => $uniacid)); $setting = uni_setting($uniacid, array('creditbehaviors')); $creditType = $setting['creditbehaviors']['activity']; if (empty($creditType)) { message('站点积分行为参数配置错误,请联系服务商', '', 'error'); } else { $record[] = $fans['uid']; $record[] = '用户消费' . $gtitle."共".$point_txt.$credits.'积分'; $this->pay_credit_update($fans['uid'], $creditType, $credits, $record); } } } } public function getWebjs() { $cfg = $this->module['config']; return !empty($cfg['webjs']) ? htmlspecialchars_decode($cfg['webjs']) : ""; } public function sendgmsptz($ordersn, $orderprice, $agentname, $to_from_user) { global $_W; $time = date('Y-m-d H:i:s'); $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'gmsptz')); if (!empty($tmsgtemplate['id']) && !empty($tmsgtemplate['template']) && $tmsgtemplate['tenable'] == 1) { $message1 = str_replace('{order_price}', $orderprice, $tmsgtemplate['template']); $message2 = str_replace('{order_sn}', $ordersn, $message1); $message3 = str_replace('{agent_name}', $agentname, $message2); $message = str_replace('{time}', $time, $message3); $this->sendcustomMsg($to_from_user, $message); } } public function sendzndxxtz($msgsn, $msgprice, $msgname, $to_from_user) { global $_W; $time = date('Y-m-d H:i:s'); $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'zndxxtz')); if (!empty($tmsgtemplate['id']) && !empty($tmsgtemplate['template']) && $tmsgtemplate['tenable'] == 1) { $message1 = str_replace('{msg_price}', $msgprice, $tmsgtemplate['template']); $message2 = str_replace('{msg_sn}', $msgsn, $message1); $message3 = str_replace('{msg_name}', $msgname, $message2); $message = str_replace('{msg_time}', $time, $message3); $this->sendcustomMsg($to_from_user, $message); } } public function sendtjrtz($agentname, $to_from_user) { global $_W; $time = date('Y-m-d H:i:s'); $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'tjrtz')); if (!empty($tmsgtemplate['id']) && !empty($tmsgtemplate['template']) && $tmsgtemplate['tenable'] == 1) { $message2 = str_replace('{agent_name}', $agentname, $tmsgtemplate['template']); $message = str_replace('{time}', $time, $message2); $this->sendcustomMsg($to_from_user, $message); } } public function sendtjrtzewm($agentname, $to_from_user) { global $_W; $time = date('Y-m-d H:i:s'); $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'tjrtzewm')); if (!empty($tmsgtemplate['id']) && !empty($tmsgtemplate['template']) && $tmsgtemplate['tenable'] == 1) { $message2 = str_replace('{agent_name}', $agentname, $tmsgtemplate['template']); $message = str_replace('{time}', $time, $message2); $this->sendcustomMsg($to_from_user, $message); } } public function sendtjrtzdl($agentname, $to_from_user) { global $_W; $time = date('Y-m-d H:i:s'); $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'tjrtzdl')); if (!empty($tmsgtemplate['id']) && !empty($tmsgtemplate['template']) && $tmsgtemplate['tenable'] == 1) { $message2 = str_replace('{agent_name}', $agentname, $tmsgtemplate['template']); $message = str_replace('{time}', $time, $message2); $this->sendcustomMsg($to_from_user, $message); } } public function sendxjdlshtz($ordersn, $orderprice, $agentname, $to_from_user) { global $_W; $time = date('Y-m-d H:i:s'); $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'xjdlshtz')); if (!empty($tmsgtemplate['id']) && !empty($tmsgtemplate['template']) && $tmsgtemplate['tenable'] == 1) { $message1 = str_replace('{order_price}', $orderprice, $tmsgtemplate['template']); $message2 = str_replace('{order_sn}', $ordersn, $message1); $message3 = str_replace('{agent_name}', $agentname, $message2); $message = str_replace('{time}', $time, $message3); $this->sendcustomMsg($to_from_user, $message); } } public function sendyjsqtz($agent_money, $agentname, $to_from_user) { global $_W; $time = date('Y-m-d H:i:s'); $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'yjsqtz')); if (!empty($tmsgtemplate['id']) && !empty($tmsgtemplate['template']) && $tmsgtemplate['tenable'] == 1) { $message1 = str_replace('{agent_money}', $agent_money, $tmsgtemplate['template']); $message2 = str_replace('{agent_name}', $agentname, $message1); $message = str_replace('{time}', $time, $message2); $this->sendcustomMsg($to_from_user, $message); } } public function sendsjytktz($agent_money, $agent_level, $to_from_user) { global $_W; $time = date('Y-m-d H:i:s'); $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'sjytktz')); if (!empty($tmsgtemplate['id']) && !empty($tmsgtemplate['template']) && $tmsgtemplate['tenable'] == 1) { $message1 = str_replace('{agent_money}', $agent_money, $tmsgtemplate['template']); $message2 = str_replace('{agent_level}', $agent_level, $message1); $message = str_replace('{time}', $time, $message2); $this->sendcustomMsg($to_from_user, $message); } } private function pagination2($tcount, $pindex, $psize = 15, $url = '', $context = array('before' => 2, 'after' => 2, 'ajaxcallback' => '')) { global $_W; $pdata = array('tcount' => 0, 'tpage' => 0, 'cindex' => 0, 'findex' => 0, 'pindex' => 0, 'nindex' => 0, 'lindex' => 0, 'options' => ''); if ($context['ajaxcallback']) { $context['isajax'] = true; } $pdata['tcount'] = $tcount; $pdata['tpage'] = ceil($tcount / $psize); if ($pdata['tpage'] <= 1) { return ''; } $cindex = $pindex; $cindex = min($cindex, $pdata['tpage']); $cindex = max($cindex, 1); $pdata['cindex'] = $cindex; $pdata['findex'] = 1; $pdata['pindex'] = $cindex > 1 ? $cindex - 1 : 1; $pdata['nindex'] = $cindex < $pdata['tpage'] ? $cindex + 1 : $pdata['tpage']; $pdata['lindex'] = $pdata['tpage']; if ($context['isajax']) { if (!$url) { $url = $_W['script_name'] . '?' . http_build_query($_GET); } $pdata['faa'] = 'href="javascript:;" onclick="p(\'' . $_W['script_name'] . $url . '\', \'' . $pdata['findex'] . '\', ' . $context['ajaxcallback'] . ')"'; $pdata['paa'] = 'href="javascript:;" onclick="p(\'' . $_W['script_name'] . $url . '\', \'' . $pdata['pindex'] . '\', ' . $context['ajaxcallback'] . ')"'; $pdata['naa'] = 'href="javascript:;" onclick="p(\'' . $_W['script_name'] . $url . '\', \'' . $pdata['nindex'] . '\', ' . $context['ajaxcallback'] . ')"'; $pdata['laa'] = 'href="javascript:;" onclick="p(\'' . $_W['script_name'] . $url . '\', \'' . $pdata['lindex'] . '\', ' . $context['ajaxcallback'] . ')"'; } else { if ($url) { $pdata['faa'] = 'href="?' . str_replace('*', $pdata['findex'], $url) . '"'; $pdata['paa'] = 'href="?' . str_replace('*', $pdata['pindex'], $url) . '"'; $pdata['naa'] = 'href="?' . str_replace('*', $pdata['nindex'], $url) . '"'; $pdata['laa'] = 'href="?' . str_replace('*', $pdata['lindex'], $url) . '"'; } else { $_GET['page'] = $pdata['findex']; $pdata['faa'] = 'href="' . $_W['script_name'] . '?' . http_build_query($_GET) . '"'; $_GET['page'] = $pdata['pindex']; $pdata['paa'] = 'href="' . $_W['script_name'] . '?' . http_build_query($_GET) . '"'; $_GET['page'] = $pdata['nindex']; $pdata['naa'] = 'href="' . $_W['script_name'] . '?' . http_build_query($_GET) . '"'; $_GET['page'] = $pdata['lindex']; $pdata['laa'] = 'href="' . $_W['script_name'] . '?' . http_build_query($_GET) . '"'; } } $html = '
'; return $html; } private function getShareId($from_user = '', $level = 1) { global $_W, $_GPC; if (empty($from_user)) { $from_user = $this->getFromUser(); } $profile = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = :uniacid AND from_user = :from_user", array(':uniacid' => $_W['uniacid'], ':from_user' => $from_user)); if (empty($profile['shareid'])) { return 0; } else { if ($level == 1) { return $profile['shareid']; } if ($level == 2 || $level == 3) { $profile2 = pdo_fetch('SELECT shareid FROM ' . tablename('wwx_fxxt_member') . " WHERE id=:sid", array(':sid' => $profile['shareid'])); if (empty($profile2['shareid'])) { return 0; } if ($level == 2) { return $profile2['shareid']; } } if ($level == 3) { $profile3 = pdo_fetch('SELECT shareid FROM ' . tablename('wwx_fxxt_member') . " WHERE id=:sid", array(':sid' => $profile2['shareid'])); if (empty($profile3['shareid'])) { return 0; } return $profile3['shareid']; } return 0; } } public function getMember($mid) { global $_W, $_GPC; $profile = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = :uniacid AND id = :id", array(':uniacid' => $_W['uniacid'], ':id' => $mid)); return $profile; } private function getFromUser($state = 0) { global $_W, $_GPC; $oauth_openid = WUXIAN_COOKIE_OPENID . $_W['uniacid']; $appid = $_W['account']['key']; $secret = $_W['account']['secret']; if ($_GPC['mid'] != $_COOKIE[WUXIAN_COOKIE_SID . $_W['uniacid']] && !empty($_GPC['mid'])) { setcookie(WUXIAN_COOKIE_SID . $_W['uniacid'], $_GPC['mid'], time() + 3600 * 24 * 15); } if ($_GPC['joinway'] != $_COOKIE[WUXIAN_COOKIE_JON . $_W['uniacid']] && !empty($_GPC['joinway'])) { setcookie(WUXIAN_COOKIE_JON . $_W['uniacid'], $_GPC['joinway'], time() + 3600 * 24 * 15); } $user_agent = $_SERVER['HTTP_USER_AGENT']; if (strpos($user_agent, 'MicroMessenger') === false) { $this->checkAuth(); return $_W['openid']; } if (empty($appid) || empty($secret)) { message('微信公众号没有配置公众号AppId和公众号AppSecret!'); } if ($_COOKIE[$oauth_openid] != $_W['openid']) { $url = $_W['siteroot'] . "app/" . $this->createMobileUrl('xoauth'); if ($state == 1) { $scope = "snsapi_userinfo"; } else { $scope = "snsapi_base"; setcookie(WUXIAN_COOKIE_XOAUHURL . $_W['uniacid'], "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}", time() + 600); } $oauth2_code = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" . $appid . "&redirect_uri=" . urlencode($url) . "&response_type=code&scope=" . $scope . "&state=" . $state . "#wechat_redirect"; header("location:{$oauth2_code}"); die; } else { return $_COOKIE[$oauth_openid]; } } private function checkauth() { global $_W, $engine; $setting = uni_setting($_W['uniacid'], array('passport')); $agentRegister = $this->module['config']['agentRegister']; if ($_COOKIE[WUXIAN_COOKIE_OPENID . $_W['uniacid']] != $_W['openid']) { $_W['member'] = array(); $_SESSION['uid'] = ''; $_SESSION['openid'] = ''; $_W['openid'] = ''; $_W['fans'] = array(); $_W['fans']['from_user'] = ''; } if ($agentRegister == 0) { $user_agent = $_SERVER['HTTP_USER_AGENT']; if (strpos($user_agent, 'MicroMessenger') === false) { include $this->template('remindnotweixin'); die; } } if (!empty($_W['member']) && (!empty($_W['member']['mobile']) || !empty($_W['member']['email']))) { return true; } if (!empty($setting['passport']['focusreg'])) { $forward = base64_encode($_SERVER['QUERY_STRING']); if ($_W['isajax']) { $result = array(); $result['url'] = url('entry', array('m' => 'wwx_fxxt', 'do' => 'login', 'forward' => $forward), true); $result['act'] = 'redirect'; die(json_encode($result)); } else { header('location: ' . url('entry', array('m' => 'wwx_fxxt', 'do' => 'login', 'forward' => $forward)), true); } die; } return true; } public function doMobileXoauth() { global $_W, $_GPC; load()->model('mc'); load()->func('communication'); $uniacid = $_W['uniacid']; if ($_GPC['code'] == "authdeny") { die; } if (isset($_GPC['code'])) { $appid = $_W['account']['key']; $secret = $_W['account']['secret']; if (empty($appid) || empty($secret)) { message('微信公众号没有配置公众号AppId和公众号AppSecret!'); } $state = $_GPC['state']; $code = $_GPC['code']; $oauth2_code = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" . $appid . "&secret=" . $secret . "&code=" . $code . "&grant_type=authorization_code"; $content = ihttp_get($oauth2_code); $token = @json_decode($content['content'], true); if (empty($token) || !is_array($token) || empty($token['access_token']) || empty($token['openid'])) { echo '

获取微信公众号授权' . $code . '失败[无法取得token以及openid], 请稍后重试! 公众平台返回原始数据为:
' . $content['meta'] . '

'; die; } $from_user = $token['openid']; $access_token = $this->get_weixin_token(); $oauth2_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $access_token . "&openid=" . $from_user . "&lang=zh_CN"; $content = ihttp_get($oauth2_url); $info = @json_decode($content['content'], true); if ($info['subscribe'] == 1) { $follow = 1; } else { $follow = 0; } if ($follow == 0 && $state == 0) { $this->getFromUser(1); return; } if ($follow == 0 && $state == 1) { $access_token = $token['access_token']; $oauth2_url = "https://api.weixin.qq.com/sns/userinfo?access_token=" . $access_token . "&openid=" . $from_user . "&lang=zh_CN"; $content = ihttp_get($oauth2_url); $info = @json_decode($content['content'], true); } if (empty($info) || !is_array($info) || empty($info['openid'])) { echo '

获取微信公众号授权失败[无法取得info], 请稍后重试!

'; die; } $setting = uni_setting($_W['uniacid'], array('passport')); $fans = mc_fansinfo($info['openid']); $group = 0; if ($follow == 1) { $group = $this->fetchFansGroupid($from_user); } if (!empty($fans)) { $rec = array(); $rec['follow'] = $follow; $rec['followtime'] = $info["subscribe_time"]; $rec['unfollowtime'] = 0; $rec['updatetime'] = TIMESTAMP; $rec['nickname'] = $info["nickname"]; $member = array(); if (!empty($fans['uid'])) { $member = mc_fetch($fans['uid']); } if (empty($member)) { $default_groupid = pdo_fetchcolumn('SELECT groupid FROM ' . tablename('mc_groups') . ' WHERE uniacid = :uniacid AND isdefault = 1', array(':uniacid' => $_W['uniacid'])); $data = array('uniacid' => $_W['uniacid'], 'email' => md5($info['openid']) . '@09077.com', 'salt' => random(8), 'groupid' => $default_groupid, 'createtime' => TIMESTAMP, 'gender' => $info['sex'], 'nickname' => $info['nickname'], 'realname' => $info['nickname'], 'avatar' => rtrim($info['headimgurl'], '0') . 132, 'residecity' => $info['city'], 'resideprovince' => $info['province'], 'nationality' => $info['country']); $data['password'] = md5($info['openid'] . $data['salt'] . $_W['config']['setting']['authkey']); pdo_insert('mc_members', $data); $rec['uid'] = pdo_insertid(); $fans['uid'] = $rec['uid']; $rec['tag'] = iserializer($info); $rec['tag'] = base64_encode($rec['tag']); } if (!empty($rec)) { pdo_update('mc_mapping_fans', $rec, array('acid' => $_W['acid'], 'openid' => $info['openid'], 'uniacid' => $_W['uniacid'])); $data = array('uniacid' => $_W['uniacid'], 'groupid' => $default_groupid, 'gender' => $info['sex'], 'nickname' => $info['nickname'], 'avatar' => rtrim($info['headimgurl'], '0') . 132, 'residecity' => $info['city'], 'resideprovince' => $info['province'], 'nationality' => $info['country']); pdo_update('mc_members', $data, array('uid' => $fans['uid'], 'uniacid' => $_W['uniacid'])); } } else { $rec = array(); $rec['acid'] = $_W['acid']; $rec['uniacid'] = $_W['uniacid']; $rec['nickname'] = $info['nickname']; $rec['uid'] = 0; $rec['groupid'] = $group['groupid']; $rec['openid'] = $info['openid']; $rec['salt'] = random(8); $rec['follow'] = $follow; $rec['followtime'] = $info["subscribe_time"]; $rec['unfollowtime'] = 0; $rec['updatetime'] = TIMESTAMP; $default_groupid = pdo_fetchcolumn('SELECT groupid FROM ' . tablename('mc_groups') . ' WHERE uniacid = :uniacid AND isdefault = 1', array(':uniacid' => $_W['uniacid'])); $data = array('uniacid' => $_W['uniacid'], 'email' => md5($info['openid']) . '@09077.com', 'salt' => random(8), 'groupid' => $default_groupid, 'createtime' => TIMESTAMP, 'gender' => $info['sex'], 'nickname' => $info['nickname'], 'realname' => $info['nickname'], 'avatar' => rtrim($info['headimgurl'], '0') . 132, 'residecity' => $info['city'], 'resideprovince' => $info['province'], 'nationality' => $info['country']); $data['password'] = md5($info['openid'] . $data['salt'] . $_W['config']['setting']['authkey']); pdo_delete('mc_members', array('email' => $data['email'])); pdo_insert('mc_members', $data); $rec['uid'] = pdo_insertid(); $fans['uid'] = $rec['uid']; $rec['tag'] = iserializer($info); $rec['tag'] = base64_encode($rec['tag']); pdo_insert('mc_mapping_fans', $rec); } $this->_wwx_login(array('uid' => intval($fans['uid']))); $this->autoRegedit('fansindex'); $url = $_COOKIE[WUXIAN_COOKIE_XOAUHURL . $_W['uniacid']]; header("location:{$url}"); die; } else { echo '

网页授权域名设置出错!

'; die; } } private function fetchFansGroupid($openid) { load()->func('communication'); if (empty($openid)) { return error(-1, '没有填写openid'); } $token = $this->get_weixin_token(); if (is_error($token)) { return $token; } $url = "https://api.weixin.qq.com/cgi-bin/groups/getid?access_token={$token}"; $response = ihttp_request($url, json_encode(array('openid' => $openid))); if (is_error($response)) { return error(-1, "访问公众平台接口失败, 错误: {$response['message']}"); } $result = @json_decode($response['content'], true); if (empty($result)) { return error(-1, "接口调用失败, 元数据: {$response['meta']}"); } elseif (!empty($result['errcode'])) { return error(-1, "访问微信接口错误, 错误代码: {$result['errcode']}, 错误信息: {$result['errmsg']}, 错误详情:{$this->error_code($result['errcode'])}"); } return $result; } private function _wwx_login($member) { global $_W; load()->model('mc'); if (!empty($member) && !empty($member['uid'])) { $sql = 'SELECT `uid`,`mobile`,`email` FROM ' . tablename('mc_members') . ' WHERE `uid`=:uid AND `uniacid`=:uniacid'; $member = pdo_fetch($sql, array(':uid' => $member['uid'], ':uniacid' => $_W['uniacid'])); if (!empty($member)) { $fan = mc_fansinfo($member['uid']); $_W['member'] = $member; $_SESSION['uid'] = $member['uid']; $_SESSION['openid'] = $fan['openid']; $_W['openid'] = $fan['openid']; $_W['fans'] = $fan; $_W['fans']['from_user'] = $_W['openid']; setcookie(WUXIAN_COOKIE_OPENID . $_W['uniacid'], $_W['openid'], time() + 86400); setcookie(WUXIAN_COOKIE_CHECKOPENID . $_W['uniacid'], $_W['openid'], time() + 600); setcookie('mid', '', time() - 1); isetcookie('logout', '', -60000); return true; } } return false; } private function autoRegedit($fromaction) { global $_W, $_GPC; $from_user = $_W['openid']; $seid = 0; $myfansx = pdo_fetch("select b.nickname,b.uid from " . tablename('mc_mapping_fans') . " a, " . tablename('mc_members') . " b where a.openid=:openid and a.uniacid=:uniacid and a.uid=b.uid", array(':openid' => $from_user, ':uniacid' => $_W['uniacid'])); $nickname = $myfansx['nickname']; $profile = pdo_fetch('SELECT from_user,id,realname FROM ' . tablename('wwx_fxxt_member') . " WHERE `uniacid` = :uniacid AND from_user=:from_user ", array(':uniacid' => $_W['uniacid'], ':from_user' => $from_user)); if (empty($profile['id'])) { $shareids = pdo_fetch("SELECT id,flag FROM " . tablename('wwx_fxxt_member') . " WHERE id=:id and uniacid=:uniacid limit 1", array(':id' => $_COOKIE[WUXIAN_COOKIE_SID . $_W['uniacid']], ':uniacid' => $_W['uniacid'])); if (!empty($shareids['id'])) { $seid = $shareids['id']; if ($shareids['flag'] != 1) { $seid = 0; } } else { $seid = 0; } $data = array('uniacid' => $_W['uniacid'], 'from_user' => $from_user, 'nickname' => $nickname, 'realname' => $nickname, 'commission' => 0, 'createtime' => TIMESTAMP, 'flagtime' => TIMESTAMP, 'shareid' => $seid, 'status' => 1, 'flag' => 0); pdo_insert('wwx_fxxt_member', $data); } else { if (empty($profile['realname'])) { if (!empty($nickname)) { $data = array('realname' => $nickname); pdo_update('wwx_fxxt_member', $data, array('id' => $profile['id'])); } } else { $nickname = $profile['realname']; } } return true; } private function getProfile() { global $_W; $from_user = $this->getFromUser(); $profile = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = :uniacid AND from_user = :from_user", array(':uniacid' => $_W['uniacid'], ':from_user' => $from_user)); if (empty($profile) && !empty($_W['openid'])) { $this->autoRegedit('fansindex'); $profile = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = :uniacid AND from_user = :from_user", array(':uniacid' => $_W['uniacid'], ':from_user' => $_W['openid'])); } if (intval($profile['id']) && $profile['status'] == 0) { include $this->template('forbidden'); die; } if ($profile['shareid'] > 0) { $share_name = pdo_fetch('SELECT realname,nickname,from_user FROM ' . tablename('wwx_fxxt_member') . " WHERE id = :id", array(':id' => $profile['shareid'])); $profile['sharename'] = $share_name['nickname']; $profile['share_from_user'] = $share_name['from_user']; } if ($profile['flag'] == 1 && ($profile['flagtime'] == 0 || empty($profile['flagtime'])) && !empty($profile['id'])) { pdo_update('wwx_fxxt_member', array('flagtime' => TIMESTAMP), array('id' => $profile['id'])); } $fans = pdo_fetch("select b.credit1,b.credit2,b.uid,b.avatar,a.follow,a.followtime from " . tablename('mc_mapping_fans') . " a, " . tablename('mc_members') . " b where a.openid=:openid and a.uniacid=:uniacid and a.uid=b.uid", array(':openid' => $profile['from_user'], ':uniacid' => $_W['uniacid'])); if (!empty($fans) && !empty($_W['openid'])) { $profile['credit1'] = $fans['credit1']; $profile['credit2'] = $fans['credit2']; $profile['uid'] = $fans['uid']; $profile['avatar'] = $fans['avatar']; $profile['follow'] = $fans['follow']; $profile['followtime'] = $fans['followtime']; } return $profile; } private function getSignPackage($urlaction = 'list', $datas = array(), $imgUrl = '', $title = '') { global $_W, $_GPC; $appid = $_W['account']['key']; $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://"; $url = "{$protocol}{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; $jsapiTicket = $this->get_js_ticket(); $timestamp = time(); $nonceStr = $this->createNonceStr(); $string = "jsapi_ticket={$jsapiTicket}&noncestr={$nonceStr}×tamp={$timestamp}&url={$url}"; $mid = $this->getMid(); if (empty($datas['mid'])) { $datas['mid'] = $mid; } $signature = sha1($string); $cfg = $this->module['config']; $theone = pdo_fetch('SELECT id,ischeck FROM ' . tablename('wwx_fxxt_rules') . " WHERE uniacid = :uniacid", array(':uniacid' => $_W['uniacid'])); $zjprofile = $this->getMember($mid); $dzdischeck = $theone['ischeck']; if ($theone['ischeck'] == 2) { $dzdid = -1; if (empty($_GPC['dzdid']) && empty($zjprofile['dzdflag'])) { if (!empty($_COOKIE['dzdid_' . WWX_FXXT_VERSION . $_W['uniacid']])) { $_GPC['dzdid'] = $_COOKIE['dzdid_' . WWX_FXXT_VERSION . $_W['uniacid']]; } } elseif (!empty($zjprofile['dzdflag'])) { $_GPC['dzdid'] = $mid; } $sitelogo = $_W['attachurl'] . '/headimg_' . $_W['uniacid'] . '.jpg?uniacid=' . $_W['account']['uniacid']; if (!file_exists('../attachment/headimg_' . $_W['uniacid'] . '.jpg')) { $sitelogo = WWX_FXXT_ROOT . '/recouse/images/nofile.png'; } if (!empty($_GPC['dzdid']) && $_GPC['dzdid'] != -1) { $dzdid = intval($_GPC['dzdid']); if (!empty($dzdid)) { $dzduid = $dzdid; $dzdprofile = $this->getMember($dzduid); if (!empty($dzdprofile['id'])) { if ($dzdprofile['flag'] == 1 && $dzdprofile['dzdflag'] == 1) { if ($urlaction != 'detail') { $title = $dzdprofile['dzdtitle']; } $avatar = pdo_fetchcolumn("SELECT member.avatar as avatar FROM " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member WHERE fans.uniacid=:uniacid and fans.uid=member.uid and fans.openid = :from_user LIMIT 1", array(':uniacid' => $_W['uniacid'], ':from_user' => $dzdprofile['from_user'])); if (!empty($dzdid)) { $datas['dzdid'] = $dzdid; } if (!empty($avatar)) { $sitelogo = $avatar; $datas['sitelogo'] = $avatar; } if (!empty($dzdprofile['dzdtitle'])) { $datas['title'] = $dzdprofile['dzdtitle']; } else { $datas['title'] = $dzdprofile['realname']; } if (!empty($dzdprofile['dzdsendtext'])) { $datas['description'] = $dzdprofile['dzdsendtext']; } setcookie('dzdid_' . WWX_FXXT_VERSION . $_W['uniacid'], $dzduid, time() + 3600); } else { $dzduid = -1; setcookie('dzdid_' . WWX_FXXT_VERSION . $_W['uniacid'], 0, time() + 3600); } } $theone['ischeck'] = 1; } } $theone['ischeck'] = 1; } else { $dzduid = -1; setcookie('dzdid_' . WWX_FXXT_VERSION . $_W['uniacid'], 0, time() + 3600); } if (empty($title)) { $title = $_W['account']['name'] . " — 我为你代言"; } if (empty($imgUrl)) { $imgUrl = $_W['attachurl'] . $cfg['logo']; } $description = $cfg['description']; if (!empty($datas['title']) && $urlaction != 'detail') { $title = $datas['title']; $dzdtitle = $datas['title']; } if (!empty($datas['sitelogo']) && $urlaction != 'detail') { $imgUrl = $datas['sitelogo']; } if (!empty($datas['description'])) { $description = $datas['description']; } $forward = base64_encode($_SERVER['QUERY_STRING']); $ydyy = $cfg['ydyy']; if (empty($_W['openid'])) { $ydyy = url('entry', array('m' => 'wwx_fxxt', 'do' => 'login', 'forward' => $forward)); } $fans = pdo_fetch('SELECT fans.openid from_user, fans.follow follow, member.* FROM ' . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member WHERE fans.uniacid = :uniacid AND fans.openid = :openid AND fans.uid=member.uid LIMIT 1", array(':uniacid' => $_W['uniacid'], ':openid' => $_W['openid'])); if ($fans['follow'] != 1) { $shownotice = true; } $user_agent = $_SERVER['HTTP_USER_AGENT']; if (!empty($_W['openid']) && strpos($user_agent, 'MicroMessenger') === false) { $shownotice = false; $wxcookie = "09077"; } $signPackage = array("appId" => $appid, "nonceStr" => $nonceStr, "timestamp" => $timestamp, "url" => $url, "title" => $title, "dzdtitle" => $dzdtitle, "imgUrl" => $imgUrl, "link" => $_W['siteroot'] . "app/" . $this->createMobileUrl($urlaction, $datas, true), "signature" => $signature, "description" => $description, "rawString" => $string, "ydyy" => $ydyy, "shownotice" => $shownotice, "nickname" => $fans['nickname'], "avatar" => $fans['avatar'], "dzdischeck" => $dzdischeck, "ischeck" => $theone['ischeck'], "wxcookie" => $wxcookie); return $signPackage; } private function get_js_ticket() { global $_W; load()->func('communication'); $theone = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_rules') . " WHERE uniacid = :uniacid", array(':uniacid' => $_W['uniacid'])); $jsapi_ticket = $theone['jsapi_ticket']; $jsapi_ticket_exptime = intval($theone['jsapi_ticket_exptime']); if (empty($jsapi_ticket) || empty($jsapi_ticket_exptime) || $jsapi_ticket_exptime < time()) { $accessToken = $this->get_weixin_token(); $url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token={$accessToken}"; $content = ihttp_get($url); $res = @json_decode($content['content'], true); $ticket = $res['ticket']; if (!empty($ticket)) { $data = array(); $data['expire_time'] = time() + 7000; $data['jsapi_ticket'] = $ticket; $update = array('jsapi_ticket' => $ticket, 'jsapi_ticket_exptime' => time() + 7000); pdo_update('wwx_fxxt_rules', $update, array('uniacid' => $_W['uniacid'])); return $ticket; } return ''; } else { return $jsapi_ticket; } } private function createNonceStr($length = 16) { $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $str = ""; for ($i = 0; $i < $length; $i++) { $str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1); } return $str; } public function getCartTotal() { global $_W; $cartotal = pdo_fetchcolumn("select sum(total) from " . tablename('wwx_fxxt_cart') . " where uniacid = '{$_W['uniacid']}' and from_user='" . $_W['openid'] . "'"); return empty($cartotal) ? 0 : $cartotal; } private function wwxpay($params, $paytype) { global $_W, $_GPC; if ($params['fee'] <= 0) { message('支付错误, 金额小于0'); } $params['module'] = $this->module['name']; $sql = 'SELECT * FROM ' . tablename('core_paylog') . ' WHERE `uniacid`=:uniacid AND `module`=:module AND `tid`=:tid AND `openid`=:openid'; $pars = array(); $pars[':uniacid'] = $_W['uniacid']; $pars[':module'] = $params['module']; $pars[':tid'] = $params['tid']; $pars[':openid'] =$_W['member']['uid']; $log = pdo_fetch($sql, $pars); /* if (!empty($log) && $log['status'] == '1') { message('这个订单已经支付成功, 不需要重复支付!', $this->createMobileUrl('myorder'), 'error'); die; } */ if (empty($log)) { $mylog = array( 'uniacid' => $_W['uniacid'], 'acid' => $_W['acid'], 'openid' => $_W['member']['uid'], 'module' => $params['module'], 'tid' => $params['tid'], 'fee' => $params['fee'], 'card_fee' => $params['fee'], 'status' => '0', 'is_usecard' => '0', ); pdo_insert('core_paylog', $mylog); }else{ if($log['status'] == '1'){ message('这个订单已经支付成功, 不需要重复支付!', $this->createMobileUrl('myorder'), 'error'); die; } } $user_agent = $_SERVER['HTTP_USER_AGENT']; if ($paytype == 1 && strpos($user_agent, 'MicroMessenger') === false) { $tid = $params['tid']; $forward = url('entry', array('m' => 'wwx_fxxt', 'do' => 'payweixin', 'tid' => $tid)); header('location: ' . $forward); die; } else { include $this->template('wwxpay'); } } private function sendMobilePayMsg($order, $goods, $paytype, $ordergoods) { global $_W, $_GPC; $address = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_address') . " WHERE id = :id", array(':id' => $order['addressid'])); $cfg = $this->module['config'];//debug_log("module :".serialize($this->module),"","allsale"); $template_id = $cfg['msgtmp']['neworder']; $goods_title=''; foreach($goods as $k=>$v){ $goods_title=$goods_title.' '.$v['title']; } if (!empty($template_id)) { $from_user = $order['from_user']; $tokens = $this->get_weixin_token(); if (empty($tokens)) { return; } //$template = array('first' => array('value' => "订单已创建成功,请关注“{$_W['account']['name']}”,点击进入查看订单状态。", 'color' => "#743A3A"), 'keyword1' => array('title' => '时间', 'value' => date('Y-m-d H:i:s', $order['createtime']), 'color' => '#4a5077'), 'keyword2' => array('title' => '订单号', 'value' => $order['ordersn'], 'color' => '#4a5077'), 'keyword3' => array('title' => '支付方式', 'value' => $paytype, 'color' => '#4a5077'), 'remark' => array('value' => '订单生成成功,请到后台查看!', 'color' => '#4a5077')); $template = array('first' => array('value' => "订单已创建成功,请关注“{$_W['account']['name']}”,点击进入查看订单状态。", 'color' => "#743A3A"), 'keyword1' => array('title' => '时间', 'value' => date('Y-m-d H:i:s', $order['createtime']), 'color' => '#4a5077'), 'keyword2' => array('title' => '商品名称', 'value' => $goods_title, 'color' => '#4a5077'), 'keyword3' => array('title' => '订单号', 'value' => $order['ordersn'], 'color' => '#4a5077'), 'remark' => array('value' => $paytype.' '.'订单生成成功,请到后台查看!', 'color' => '#4a5077')); $url = $_W['siteroot'] . "app/" . $this->createMobileUrl('myorder', array('orderid' => $order['id'], 'op' => 'detail')); load()->classs('weixin.account'); $accObj = WeiXinAccount::create($_W['account']); $res = $accObj->sendTplNotice($from_user, $template_id, $template, $url, '#7B68EE'); if (!empty($cfg['msgtmp']['openid'])) { $openids = explode(',', $cfg['msgtmp']['openid']); foreach ($openids as $openidsend) { if (empty($openidsend)) { continue; } $accObj->sendTplNotice($openidsend, $template_id, $template, '', '#7B68EE'); } } return true; } } function setMemberCredit2($from_user = '', $fee, $type, $remark) { global $_W; $myfans = pdo_fetch('SELECT member.credit2 as credit2,member.uid as uid FROM ' . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member WHERE fans.uniacid = :uniacid AND fans.openid = :openid AND fans.uid = member.uid LIMIT 1", array(':uniacid' => $_W['uniacid'], ':openid' => $from_user)); $member = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = :uniacid AND from_user = :from_user limit 1", array(':uniacid' => $_W['uniacid'], ':from_user' => $from_user)); if (!empty($member['id'])) { if (empty($myfans['credit2'])) { $myfans['credit2'] = 0; } if (!is_numeric($fee) || $fee < 0) { message("输入数字非法,请重新输入"); } if ($type == 'addgold') { $data = array('credit2' => $myfans['credit2'] + $fee, 'tag' => $remark, 'type' => $type, 'fee' => $fee, 'createtime' => TIMESTAMP, 'openid' => $member['from_user'], 'mid' => $member['id'], 'uniacid' => $_W['uniacid']); pdo_insert('wwx_fxxt_paylog', $data); pdo_update('mc_members', array('credit2' => $myfans['credit2'] + $fee), array('uid' => $myfans['uid'])); return true; } if ($type == 'usegold') { if ($myfans['credit2'] >= $fee) { $data = array('credit2' => $myfans['credit2'] - $fee, 'tag' => $remark, 'type' => $type, 'fee' => $fee, 'createtime' => TIMESTAMP, 'openid' => $member['from_user'], 'mid' => $member['id'], 'uniacid' => $_W['uniacid']); pdo_insert('wwx_fxxt_paylog', $data); pdo_update('mc_members', array('credit2' => $myfans['credit2'] - $fee), array('uid' => $myfans['uid'])); return true; } else { message('余额不足无法操作'); } } } return false; } private function autoNameH() { global $_W, $_GPC; load()->func('communication'); $info = array(); $from_user = $this->getFromUser(); $fans = pdo_fetch('SELECT fans.openid from_user, fans.follow follow, member.* FROM ' . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member WHERE fans.uniacid = :uniacid AND fans.openid = :openid AND fans.uid=member.uid LIMIT 1", array(':uniacid' => $_W['uniacid'], ':openid' => $from_user)); if ($fans['follow'] == 1) { $access_token = $this->get_weixin_token(); $oauth2_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $access_token . "&openid=" . $from_user . "&lang=zh_CN"; $content = ihttp_get($oauth2_url); $info = @json_decode($content['content'], true); $nickname = $info['nickname']; if (!empty($nickname)) { pdo_update('mc_members', array('nickname' => $nickname), array('uid' => $fans['uid'])); pdo_update('mc_mapping_fans', array('nickname' => $nickname), array('uid' => $fans['uid'])); } if (!empty($info["headimgurl"])) { pdo_update('mc_members', array('avatar' => $info["headimgurl"]), array('uid' => $fans['uid'])); } } return $info; } public function getLevel($id, $fans = 1) { global $_W; if (empty($id) && $fans == 1) { return '非代理'; } if (empty($id) && $fans == 2) { return '非会员'; } $member = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = :uniacid AND id = :id limit 1", array(':uniacid' => $_W['uniacid'], ':id' => $id)); if ($fans == 1) { if ($member['flag'] == 0) { return '非代理'; } $myfansx = pdo_fetch('SELECT flag_name FROM ' . tablename('wwx_fxxt_member_flaggrade') . " WHERE uniacid = :uniacid and displayorder = :displayorder order by flag_name desc limit 1", array(':uniacid' => $_W['uniacid'], ':displayorder' => $member['flaggrade'])); if (!empty($myfansx['flag_name'])) { return $myfansx['flag_name']; } else { return '普通代理'; } } if ($fans == 2) { if (empty($member)) { return '非会员'; } $myfansx = pdo_fetch('SELECT member_name FROM ' . tablename('wwx_fxxt_member_shipgrade') . " WHERE uniacid = :uniacid and displayorder = :displayorder order by member_name desc limit 1", array(':uniacid' => $_W['uniacid'], ':displayorder' => $member['usergrade'])); if (!empty($myfansx['member_name'])) { return $myfansx['member_name']; } else { return '普通会员'; } } } private function GetPrePayUrl($productId) { global $_W, $_GPC; $cfg = $this->module['config']; $zhifuQrCode = $cfg['api']['api_QrCode']; $zhifuKey = $cfg['api']['api_QrKey']; if (empty($zhifuQrCode) || empty($zhifuKey)) { message('商户号与支付密钥有误, 请管理员设置!', '', 'error'); } $values = array(); $values['appid'] = $_W['account']['key']; $values['mch_id'] = $zhifuQrCode; $values['nonce_str'] = $this->createNonceStr(32); $values['product_id'] = $productId; $values['time_stamp'] = time(); ksort($values); foreach ($values as $k => $v) { if ($k != "sign" && $v != "" && !is_array($v)) { $string .= $k . "=" . $v . "&"; } } $string = trim($string, "&"); $string = $string . "&key=" . $zhifuKey; $string = md5($string); $sign = strtoupper($string); $values['sign'] = $sign; $url = "weixin://wxpay/bizpayurl?" . $this->ToUrlParams($values); return $url; } private function ToUrlParams($urlObj) { $buff = ""; foreach ($urlObj as $k => $v) { $buff .= $k . "=" . $v . "&"; } $buff = trim($buff, "&"); return $buff; } public function payResult($params) { global $_W, $_GPC; load()->model('mc'); load()->func('communication'); $fee = $params['fee']; $data = array('status' => $params['result'] == 'success' ? 1 : -1); $paydata = array('wechat' => '微信', 'alipay' => '支付宝', 'credit' => '余额支付'); $params['user'] = mc_openid2uid($params['user']); if ($params['type'] == 'wechat' || $params['type'] == 'alipay') { $data['transid'] = $params['tag']['transaction_id']; } $status = pdo_fetch("SELECT * FROM " . tablename('mc_credits_recharge') . " WHERE tid = :tid", array(':tid' => $params['tid'])); $status2 = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_order') . " WHERE id = :tid", array(':tid' => $params['tid'])); if (empty($status['status']) && !empty($status['id'])) { pdo_update('mc_credits_recharge', $data, array('tid' => $params['tid'])); if ($params['result'] == 'success') { $setting = uni_setting($_W['uniacid'], array('creditbehaviors')); $credit = $setting['creditbehaviors']['currency']; if (empty($credit)) { message('站点积分行为参数配置错误,请联系服务商', '', 'error'); } else { $record[] = $params['user']; $record[] = '用户通过' . $paydata[$params['type']] . '充值' . $fee; $this->pay_credit_update($params['user'], $credit, $fee, $record); } } } if (empty($status2['status']) && !empty($status2['id'])) { $data['zhifutime'] = time(); pdo_update('wwx_fxxt_order', $data, array('id' => $params['tid'])); if ($params['result'] == 'success') { $order = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_order') . " WHERE id = '{$params['tid']}'"); $ordergoods = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_order_goods') . " WHERE orderid = '{$params['tid']}'", array(), 'goodsid'); $goods = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_goods') . " WHERE id IN ('" . implode("','", array_keys($ordergoods)) . "')"); $address = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_address') . " WHERE id = :id", array(':id' => $order['addressid'])); if ($goods['totalcnf'] == 1 && empty($goods['total'])) { $this->setOrderStock($params['tid']); } if (!empty($this->module['config']['noticeemail'])) { $body = "

购买商品清单


"; if (!empty($goods)) { foreach ($goods as $row) { $body .= "名称:{$row['title']} ,数量:{$ordergoods[$row['id']]['total']}
"; $body .= "订单号:{$order['ordersn']}
"; $body .= "{$paydata[$params['type']]}订单号:{$data['transid']}
"; } } } $body .= "总金额:{$order['price']}元 (用户通过{$paydata[$params['type']]}付款)
"; $body .= "

购买用户详情


"; $body .= "用户标识:{$params['user']}
"; $body .= "真实姓名:{$address['realname']}
"; $body .= "地区:{$address['province']} - {$address['city']} - {$address['area']}
"; $body .= "详细地址:{$address['address']}
"; $body .= "手机:{$address['mobile']}


"; ihttp_email($this->module['config']['noticeemail'], "{$_W['account']['name']}商城订单提醒", $body); } } if ($params['from'] == 'return') { if ($params['result'] == 'success') { $order = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_order') . " WHERE id = '{$params['tid']}'"); $ordergoods = pdo_fetchall("SELECT goodsid,total,optionid FROM " . tablename('wwx_fxxt_order_goods') . " WHERE orderid = '{$order['id']}'", array(), 'goodsid'); if (!empty($ordergoods)) { $goods = pdo_fetchall("SELECT id, title, thumb, marketprice, unit, total,credit FROM " . tablename('wwx_fxxt_goods') . " WHERE id IN ('" . implode("','", array_keys($ordergoods)) . "')"); } $shopmember = pdo_fetch('SELECT shareid,realname FROM ' . tablename('wwx_fxxt_member') . " WHERE from_user = :from_user", array(':from_user' => $order['from_user'])); $shareopenid = pdo_fetch('SELECT from_user FROM ' . tablename('wwx_fxxt_member') . " WHERE `uniacid` = :uniacid AND id=:id ", array(':uniacid' => $_W['uniacid'], ':id' => $shopmember['shareid']));//debug_log($order['ordersn'],"","allsale"); if (empty($order['ordermessage'])) { $this->sendgmsptz($order['ordersn'], $order['price'], $shopmember['realname'], $shareopenid['from_user']); $this->sendMobilePayMsg($order, $goods, "在线付款", $ordergoods); pdo_update('wwx_fxxt_order', array('ordermessage' => 1), array('id' => $params['tid'])); } message('支付成功!', '../../app/' . $this->createMobileUrl('FansIndex'), 'success'); } else { message('支付失败!', '../../app/' . $this->createMobileUrl('FansIndex'), 'error'); } } } private function pay_credit_update($uid, $credittype, $creditval = 0, $log = array()) { global $_W; $credittype = trim($credittype); $credittypes = array('credit1', 'credit2', 'credit3', 'credit4', 'credit5'); if (!in_array($credittype, $credittypes)) { return error('-1', "指定的用户积分类型 “{$credittype}”不存在."); } $creditval = floatval($creditval); if (empty($creditval)) { return true; } $value = pdo_fetchcolumn("SELECT {$credittype} FROM " . tablename('mc_members') . " WHERE `uid` = :uid", array(':uid' => $uid)); if ($creditval > 0 || $value + $creditval >= 0) { pdo_update('mc_members', array($credittype => $value + $creditval), array('uid' => $uid)); } else { return error('-1', "积分类型为“{$credittype}”的积分不够,无法操作。"); } if (empty($log) || !is_array($log)) { $log = array($uid, '未记录'); } $data = array('uid' => $uid, 'credittype' => $credittype, 'uniacid' => $_W['uniacid'], 'num' => $creditval, 'createtime' => TIMESTAMP, 'operator' => intval($log[0]), 'remark' => $log[1]); pdo_insert('mc_credits_record', $data); return true; } private function setOrderStock($id = '', $minus = true) { $goods = pdo_fetchall("SELECT g.id, g.title, g.thumb, g.unit, g.marketprice,g.total as goodstotal,o.total,o.optionid,g.sales FROM " . tablename('wwx_fxxt_order_goods') . " o left join " . tablename('wwx_fxxt_goods') . " g on o.goodsid=g.id " . " WHERE o.orderid='{$id}'"); foreach ($goods as $item) { if ($minus) { if (!empty($item['optionid'])) { pdo_query("update " . tablename('wwx_fxxt_goods_option') . " set stock=stock-:stock where id=:id", array(":stock" => $item['total'], ":id" => $item['optionid'])); } $data = array(); if (!empty($item['goodstotal']) && $item['goodstotal'] != -1) { $data['total'] = $item['goodstotal'] - $item['total']; } $data['sales'] = $item['sales'] + $item['total']; pdo_update('wwx_fxxt_goods', $data, array('id' => $item['id'])); } else { if (!empty($item['optionid'])) { pdo_query("update " . tablename('wwx_fxxt_goods_option') . " set stock=stock+:stock where id=:id", array(":stock" => $item['total'], ":id" => $item['optionid'])); } $data = array(); if (!empty($item['goodstotal']) && $item['goodstotal'] != -1) { $data['total'] = $item['goodstotal'] + $item['total']; } $data['sales'] = $item['sales'] - $item['total']; pdo_update('wwx_fxxt_goods', $data, array('id' => $item['id'])); } } } private function changeWechatSend($id, $status, $msg = '') { global $_W; $paylog = pdo_fetch("SELECT plid, openid, tag FROM " . tablename('core_paylog') . " WHERE tid = '{$id}' AND status = 1 AND type = 'wechat'"); if (!empty($paylog['openid'])) { $paylog['tag'] = iunserializer($paylog['tag']); $acid = $paylog['tag']['acid']; $account = account_fetch($acid); $payment = uni_setting($account['uniacid'], 'payment'); if ($payment['payment']['wechat']['version'] == '2') { return true; } $send = array('appid' => $account['key'], 'openid' => $paylog['openid'], 'transid' => $paylog['tag']['transaction_id'], 'out_trade_no' => $paylog['plid'], 'deliver_timestamp' => TIMESTAMP, 'deliver_status' => $status, 'deliver_msg' => $msg); $sign = $send; $sign['appkey'] = $payment['payment']['wechat']['signkey']; ksort($sign); $string = ''; foreach ($sign as $key => $v) { $key = strtolower($key); $string .= "{$key}={$v}&"; } $send['app_signature'] = sha1(rtrim($string, '&')); $send['sign_method'] = 'sha1'; $account = WeAccount::create($acid); $response = $account->changeOrderStatus($send); if (is_error($response)) { message($response['message']); } } } public function curl_printerconfig($sum) { $r = ''; if ($sum == 1) { $r .= '

订单信息

购 货 人:{buyer} 下单时间:{time} 支付方式:{pay_type}
订单编号:{order_sn} 配送方式:{dispatch_type} 发货单号:{dispatch_sn}
收货地址:{address} 收货人:{consignee} 电话:{tel}

{good_line}

+ 配送费用:¥{dispatch_price}元 = 订单总金额:¥{good_price}元
= 应付款金额:¥{order_price}元
店铺地址:  店铺电话:
打印时间:{print_time}   
'; } return $r; } private function getRealname($from_user) { global $_W; $fans = pdo_fetch('SELECT realname FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = '{$_W['uniacid']}' AND from_user = '{$from_user}'"); if (!empty($fans['realname'])) { return $fans['realname']; } else { return '未设置'; } } private function getAvatar($from_user) { global $_W; $fans = pdo_fetch('SELECT member.avatar as avatar FROM ' . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member WHERE fans.uniacid = :uniacid AND fans.openid = :openid AND fans.uid = member.uid LIMIT 1", array(':uniacid' => $_W['uniacid'], ':openid' => $from_user)); if (!empty($fans['avatar'])) { return $fans['avatar']; } else { return '../addons/wwx_fxxt/images/no.png'; } } private function getFeedbackType($type) { $types = array(0 => '系统', 1 => '维权', 2 => '询问', 3 => '用户'); return $types[intval($type)]; } private function getFeedbackStatus($status) { $statuses = ''; if ($status == -2) { $statuses = '接收者删除'; } if ($status == -1) { $statuses = '发送者删除'; } if ($status == 0) { $statuses = '正常'; } if ($status == 1) { $statuses = '已读'; } if ($status == 2) { $statuses = '已回复'; } if ($status == 3) { $statuses = '管理员已评论'; } return $statuses; } private function getOrderid($ordersn) { global $_W; $orderid = pdo_fetch("select id from " . tablename('wwx_fxxt_order') . " WHERE ordersn=:ordersn limit 1", array(":ordersn" => $ordersn)); if (!empty($orderid['id'])) { return $orderid['id']; } else { return 0; } } function time_tran($the_time) { $timediff = $the_time - time(); $days = intval($timediff / 86400); if (strlen($days) <= 1) { $days = "0" . $days; } $remain = $timediff % 86400; $hours = intval($remain / 3600); if (strlen($hours) <= 1) { $hours = "0" . $hours; } $remain = $remain % 3600; $mins = intval($remain / 60); if (strlen($mins) <= 1) { $mins = "0" . $mins; } $secs = $remain % 60; if (strlen($secs) <= 1) { $secs = "0" . $secs; } $ret = ""; if ($days > 0) { $ret .= $days . " 天 "; } if ($hours > 0) { $ret .= $hours . ":"; } if ($mins > 0) { $ret .= $mins . ":"; } $ret .= $secs; return array('倒计时 ' . $ret, $timediff); } public function doMobileAjaxdelete() { global $_GPC; $delurl = $_GPC['pic']; if (file_delete($delurl)) { echo 1; } else { echo 0; } } private function imagecreate($bg) { $bgImg = @imagecreatefromjpeg($bg); if (FALSE == $bgImg) { $bgImg = @imagecreatefrompng($bg); } if (FALSE == $bgImg) { $bgImg = @imagecreatefromgif($bg); } return $bgImg; } private function saveToLocal($url, $goodsid = 0) { global $_W; load()->func('file'); set_time_limit(0); if (empty($url)) { return ''; } $ext = strrchr($url, "."); if ($ext != ".jpeg" && $ext != ".gif" && $ext != ".jpg" && $ext != ".png") { return ''; } $apath = $_W['config']['upload']['attachdir']; $path = "/images/shop/" . $_W['uniacid'] . "/" . date('Y/m/'); if (!file_exists(IA_ROOT . "/" . $apath . $path)) { mkdirs(IA_ROOT . "/" . $apath . $path); } do { $filename = random(30) . $ext; } while (file_exists(IA_ROOT . "/" . $apath . $path . '/' . $filename)); $path .= $filename; $thumb = IA_ROOT . "/" . $apath . $path; $data = $this->curl_file_get_contents($url); $fp2 = fopen(IA_ROOT . "/" . $apath . $path, "w"); fwrite($fp2, $data); fclose($fp2); pdo_insert('wwx_fxxt_shop_picture_address', array('uniacid' => $_W['uniacid'], 'goodsid' => $goodsid, 'thumb' => $thumb, 'roadurl' => $url, 'createtime' => time())); return $path; } private function get_item_taobao($itemid = '', $intoshop = false, $taobaourl = '', $pcate = 0, $ccate = 0) { global $_W; load()->func('communication'); $g = pdo_fetch("select * from " . tablename('wwx_fxxt_shop_goods') . " where uniacid=:uniacid and taobaoid=:taobaoid limit 1", array(":uniacid" => $_W['uniacid'], ":taobaoid" => $itemid)); if ($g) { if ($intoshop) { return array("result" => 1, "goodsid" => $g['goodsid']); } else { return array('result' => 1, 'goodsid' => $g['id']); } } $url = $this->get_info_url($itemid); $response = ihttp_get($url); if (!isset($response['content'])) { return array("result" => '0', "error" => '未从淘宝获取到商品信息!'); } $content = $response['content']; if (strexists($response['content'], "ERRCODE_QUERY_DETAIL_FAIL")) { return array("result" => '0', "error" => '宝贝不存在!'); } $arr = json_decode($content, true); $data = $arr['data']; $itemInfoModel = $data['itemInfoModel']; $item = array(); $item['itemId'] = $itemInfoModel['itemId']; $item['title'] = $itemInfoModel['title']; $item['pics'] = $itemInfoModel['picsPath']; $params = array(); if (isset($data['props'])) { $props = $data['props']; foreach ($props as $pp) { $params[] = array("title" => $pp['name'], "value" => $pp['value']); } } $item['params'] = $params; $specs = array(); $options = array(); if (isset($data['skuModel'])) { $skuModel = $data['skuModel']; if (isset($skuModel['skuProps'])) { $skuProps = $skuModel['skuProps']; foreach ($skuProps as $prop) { $spec_items = array(); foreach ($prop['values'] as $spec_item) { $spec_items[] = array('valueId' => $spec_item['valueId'], 'title' => $spec_item['name'], "thumb" => !empty($spec_item['imgUrl']) ? $spec_item['imgUrl'] : ''); } $spec = array("propId" => $prop['propId'], "title" => $prop['propName'], "items" => $spec_items); $specs[] = $spec; } } if (isset($skuModel['ppathIdmap'])) { $ppathIdmap = $skuModel['ppathIdmap']; foreach ($ppathIdmap as $key => $skuId) { $option_specs = array(); $m = explode(";", $key); foreach ($m as $v) { $mm = explode(":", $v); $option_specs[] = array("propId" => $mm[0], "valueId" => $mm[1]); } $options[] = array("option_specs" => $option_specs, "skuId" => $skuId, "stock" => 0, "marketprice" => 0, "specs" => ""); } } } $item['specs'] = $specs; $stack = $data['apiStack'][0]['value']; $value = json_decode($stack, true); $item1 = array(); $data1 = $value['data']; $itemInfoModel1 = $data1['itemInfoModel']; $item['total'] = $itemInfoModel1['quantity']; $item['sales'] = $itemInfoModel1['totalSoldQuantity']; if (isset($data1['skuModel'])) { $skuModel1 = $data1['skuModel']; if (isset($skuModel1['skus'])) { $skus = $skuModel1['skus']; foreach ($skus as $key => $val) { $sku_id = $key; foreach ($options as &$o) { if ($o['skuId'] == $sku_id) { $o['stock'] = $val['quantity']; foreach ($val['priceUnits'] as $p) { if ($p['display'] == 1) { $o['marketprice'] = $p['price']; } if ($p['display'] == 3) { $o['marketpricethree'] = $p['price']; } } $titles = array(); foreach ($o['option_specs'] as $osp) { foreach ($specs as $sp) { if ($sp['propId'] == $osp['propId']) { foreach ($sp['items'] as $spitem) { if ($spitem['valueId'] == $osp['valueId']) { $titles[] = $spitem['title']; } } } } } $o['title'] = $titles; } } unset($o); } } } else { $mprice = 0; foreach ($itemInfoModel1['priceUnits'] as $p) { $mprice = $p['price']; } $item['marketprice'] = $mprice; } $item['options'] = $options; $item['content'] = array(); $url = $this->get_detail_url($itemid); $response = ihttp_get($url); $item['content'] = $response; return $this->save_goods($item, $intoshop, $taobaourl, $pcate, $ccate); } private function save_goods($item = array(), $intoshop = false, $taobaourl = '', $pcate = 0, $ccate = 0) { global $_W; if ($_W['user']['collection'] > 0) { pdo_update("users", array("collection" => $_W['user']['collection'] - 1), array("uid" => $_W['user']['uid'])); } else { return array('result' => '0', 'error' => '您的采集数不足,请充值后继续操作!'); } $data = array("uniacid" => $_W['uniacid'], "unit" => '件', "taobaoid" => $item['itemId'], "taobaourl" => $taobaourl, "title" => $item['title'], "total" => $item['total'], "productprice" => $item['marketprice'], "marketprice" => $item['marketprice'], "pcate" => $pcate, "ccate" => $ccate, "sales" => $item['sales'], "createtime" => time(), "updatetime" => time()); $goods = pdo_fetch("select * from " . tablename('wwx_fxxt_shop_goods') . " where uniacid=:uniacid and taobaoid=:taobaoid", array(":uniacid" => $_W['uniacid'], ":taobaoid" => $item['itemId'])); if (empty($goods)) { pdo_insert("wwx_fxxt_shop_goods", $data); $goodsid = pdo_insertid(); } else { $goodsid = $goods['id']; unset($data['createtime']); pdo_update('wwx_fxxt_shop_goods', $data, array("id" => $goodsid)); } $thumb_url = array(); $pics = $item['pics']; $piclen = count($pics); if ($piclen > 0) { $data['thumb'] = $this->saveToLocal($pics[0], $goodsid); if ($piclen > 1) { for ($i = 1; $i < $piclen; $i++) { $thumb_url[] = $this->saveToLocal($pics[$i], $goodsid); } } } $data['thumb_url'] = serialize($thumb_url); $datatoo = array("thumb" => $data['thumb'], "thumb_url" => $data['thumb_url']); pdo_update('wwx_fxxt_shop_goods', $data, array("id" => $goodsid)); $goods_params = pdo_fetchall("select * from " . tablename('wwx_fxxt_shop_goods_param') . " where goodsid=:goodsid ", array(":goodsid" => $goodsid)); $params = $item['params']; $paramids = array(); $displayorder = 0; foreach ($params as $p) { $oldp = pdo_fetch("select * from " . tablename('wwx_fxxt_shop_goods_param') . " where goodsid=:goodsid and title=:title limit 1", array(":goodsid" => $goodsid, ":title" => $p['title'])); $paramid = 0; $d = array("goodsid" => $goodsid, "title" => $p['title'], "value" => $p['value'], "displayorder" => $displayorder); if (empty($oldp)) { pdo_insert("wwx_fxxt_shop_goods_param", $d); $paramid = pdo_insertid(); } else { pdo_update('wwx_fxxt_shop_goods_param', $d, array("id" => $oldp['id'])); $paramid = $oldp['id']; } $paramids[] = $paramid; $displayorder++; } if (count($paramids) > 0) { pdo_query("delete from " . tablename('wwx_fxxt_shop_goods_param') . " where goodsid=:goodsid and id not in (" . implode(",", $paramids) . ")", array(":goodsid" => $goodsid)); } else { pdo_query('delete from ' . tablename('wwx_fxxt_shop_goods_param') . ' where goodsid=:goodsid ', array(':goodsid' => $goodsid)); } $specs = $item['specs']; $specids = array(); $displayorder = 0; $newspecs = array(); foreach ($specs as $spec) { $oldspec = pdo_fetch("select * from " . tablename('wwx_fxxt_shop_spec') . " where goodsid=:goodsid and propId=:propId limit 1", array(":goodsid" => $goodsid, ":propId" => $spec['propId'])); $specid = 0; $d_spec = array("uniacid" => $_W['uniacid'], "goodsid" => $goodsid, "title" => $spec['title'], "displayorder" => $displayorder, "propId" => $spec['propId']); if (empty($oldspec)) { pdo_insert("wwx_fxxt_shop_spec", $d_spec); $specid = pdo_insertid(); } else { pdo_update('wwx_fxxt_shop_spec', $d_spec, array("id" => $oldspec['id'])); $specid = $oldspec['id']; } $d_spec['id'] = $specid; $specids[] = $specid; $displayorder++; $spec_items = $spec['items']; $spec_itemids = array(); $displayorder_item = 0; $newspecitems = array(); foreach ($spec_items as $spec_item) { $d = array("uniacid" => $_W['uniacid'], "goodsid" => $goodsid, "specid" => $specid, "title" => $spec_item['title'], "thumb" => $this->saveToLocal($spec_item['thumb'], $goodsid), "valueId" => $spec_item['valueId'], "show" => 1, "displayorder" => $displayorder_item); $oldspecitem = pdo_fetch("select * from " . tablename('wwx_fxxt_shop_spec_item') . " where specid=:specid and valueId=:valueId limit 1", array(":specid" => $specid, ":valueId" => $spec_item['valueId'])); $spec_item_id = 0; if (empty($oldspecitem)) { pdo_insert("wwx_fxxt_shop_spec_item", $d); $spec_item_id = pdo_insertid(); } else { pdo_update('wwx_fxxt_shop_spec_item', $d, array("id" => $oldspecitem['id'])); $spec_item_id = $oldspecitem['id']; } $displayorder_item++; $spec_itemids[] = $spec_item_id; $d['id'] = $spec_item_id; $newspecitems[] = $d; } $d_spec['items'] = $newspecitems; $newspecs[] = $d_spec; if (count($spec_itemids) > 0) { pdo_query("delete from " . tablename('wwx_fxxt_shop_spec_item') . " where specid=:specid and id not in (" . implode(",", $spec_itemids) . ")", array(":specid" => $specid)); } else { pdo_query('delete from ' . tablename('wwx_fxxt_shop_spec_item') . ' where specid=:specid ', array(':specid' => $specid)); } pdo_update('wwx_fxxt_shop_spec', array('content' => serialize($spec_itemids)), array("id" => $d_spec['id'])); } if (count($specids) > 0) { pdo_query("delete from " . tablename('wwx_fxxt_shop_spec') . " where goodsid=:goodsid and id not in (" . implode(",", $specids) . ")", array(":goodsid" => $goodsid)); } else { pdo_query('delete from ' . tablename('wwx_fxxt_shop_spec') . ' where goodsid=:goodsid ', array(':goodsid' => $goodsid)); } $minprice = 0; $productprice = 0; $options = $item['options']; if (count($options) > 0) { $minprice = $options[0]['marketprice']; $productprice = $options[0]['marketpricethree']; } $optionids = array(); $displayorder = 0; foreach ($options as $o) { $option_specs = $o['option_specs']; $ids = array(); $valueIds = array(); $valuetitle = array(); foreach ($option_specs as $os) { foreach ($newspecs as $nsp) { foreach ($nsp['items'] as $nspitem) { if ($nspitem['valueId'] == $os['valueId']) { $ids[] = $nspitem['id']; $valueIds[] = $nspitem['valueId']; $valuetitle[] = $nspitem['title']; } } } } $ids = implode("_", $ids); $valueIds = implode("_", $valueIds); $valuetitle = implode('+', $valuetitle); $do = array("displayorder" => $displayorder, "goodsid" => $goodsid, "title" => $valuetitle, "specs" => $ids, "stock" => $o['stock'], "productprice" => $o['marketpricethree'], "marketprice" => $o['marketprice'], "skuId" => $o['skuId']); if ($minprice > $o['marketprice']) { $minprice = $o['marketprice']; } if ($productprice > $o['marketpricethree']) { $productprice = $o['marketpricethree']; } $oldoption = pdo_fetch("select * from " . tablename('wwx_fxxt_shop_goods_option') . " where goodsid=:goodsid and skuId=:skuId limit 1", array(":goodsid" => $goodsid, ":skuId" => $o['skuId'])); $option_id = 0; if (empty($oldoption)) { pdo_insert("wwx_fxxt_shop_goods_option", $do); $option_id = pdo_insertid(); } else { pdo_update('wwx_fxxt_shop_goods_option', $do, array("id" => $oldoption['id'])); $option_id = $oldoption['id']; } $displayorder++; $optionids[] = $option_id; } if (count($optionids) > 0) { pdo_query("delete from " . tablename('wwx_fxxt_shop_goods_option') . " where goodsid=:goodsid and id not in (" . implode(",", $optionids) . ")", array(":goodsid" => $goodsid)); } else { pdo_query('delete from ' . tablename('wwx_fxxt_shop_goods_option') . ' where goodsid=:goodsid ', array(':goodsid' => $goodsid)); } $response = $item['content']; $content = $response['content']; preg_match_all('//', $content, $imgs); if (isset($imgs[1])) { foreach ($imgs[1] as $img) { $im = array("taobao" => $img, "system" => $this->saveToLocal(str_replace("//", "http://", $img), $goodsid)); if (!strexists($im['system'], 'http://') && !strexists($im['system'], 'https://')) { $im['system'] = $_W['attachurl'] . $im['system']; } $images[] = $im; } } preg_match('/tfsContent : \'(.*)\'/', $content, $html); $html = iconv("GBK", "UTF-8", $html[1]); if (isset($images)) { foreach ($images as $img) { $html = str_replace($img['taobao'], $img['system'], $html); } } $hasoption = 0; if (count($options) > 0) { $hasoption = 1; } $status = $intoshop ? "1" : "0"; $d = array("content" => $html, "hasoption" => $hasoption, "status" => $status); if ($minprice > 0) { $d["marketprice"] = $minprice; } if ($productprice > 0) { $d["productprice"] = $productprice; } pdo_update('wwx_fxxt_shop_goods', $d, array("id" => $goodsid)); if ($intoshop) { return $this->copy_goods($goodsid); } return array('result' => '1', 'goodsid' => $goodsid); } private function copy_goods($goodsid = '0') { $goods = pdo_fetch("select * from " . tablename('wwx_fxxt_shop_goods') . " where id=:id limit 1", array(":id" => $goodsid)); if (empty($goods)) { return array("result" => '0', "error" => '获取的商品未保存到宝贝仓库!'); } $shop_goods = pdo_fetch("select * from " . tablename('wwx_fxxt_goods') . " where id=:id limit 1", array(":id" => $goods['goodsid'])); $goods['goodsid'] = $goodsid; unset($goods['id']); unset($goods['goodsid']); unset($goods['status']); unset($goods['updatetime']); unset($goods['taobaoid']); unset($goods['taobaourl']); $shop_goodsid = 0; if (empty($shop_goods)) { pdo_insert("wwx_fxxt_goods", $goods); $shop_goodsid = pdo_insertid(); } else { pdo_update('wwx_fxxt_goods', $goods, array("id" => $shop_goods['id'])); $shop_goodsid = $shop_goods['id']; } $paramids = array(); $params = pdo_fetchall("select * from " . tablename("wwx_fxxt_shop_goods_param") . " where goodsid=:goodsid order by displayorder asc", array(":goodsid" => $goodsid)); foreach ($params as &$p) { $tbzs_id = $p['id']; $tbzs_paramid = $p['paramid']; unset($p['paramid']); unset($p['id']); $paramid = 0; $shop_param = pdo_fetch("select * from " . tablename("wwx_fxxt_goods_param") . " where id=:paramid limit 1", array(":paramid" => $tbzs_paramid)); if (empty($shop_param)) { pdo_insert("wwx_fxxt_goods_param", $p); $paramid = pdo_insertid(); pdo_update('wwx_fxxt_goods_param', array('goodsid' => $shop_goodsid), array("id" => $paramid)); pdo_update('wwx_fxxt_shop_goods_param', array('paramid' => $paramid), array("id" => $tbzs_id)); } else { pdo_update('wwx_fxxt_goods_param', $p, array("id" => $shop_param['id'])); pdo_update('wwx_fxxt_goods_param', array('goodsid' => $shop_goodsid), array("id" => $shop_param['id'])); $paramid = $shop_param['id']; } $paramids[] = $paramid; } if (count($paramids) > 0) { pdo_query("delete from " . tablename('wwx_fxxt_goods_param') . " where goodsid={$shop_goodsid} and id not in (" . implode(",", $paramids) . " )"); } else { pdo_query('delete from ' . tablename('wwx_fxxt_goods_param') . " where goodsid={$shop_goodsid}"); } $specids = array(); $newspecs = array(); $specs = pdo_fetchall("select * from " . tablename("wwx_fxxt_shop_spec") . " where goodsid=:goodsid order by displayorder asc", array(":goodsid" => $goodsid)); foreach ($specs as &$spec) { $tbzs_id = $spec['id']; $tbzs_specid = $spec['specid']; unset($spec['specid']); unset($spec['propId']); unset($spec['id']); $specid = 0; $shop_spec = pdo_fetch("select * from " . tablename("wwx_fxxt_spec") . " where id=:specid limit 1", array(":specid" => $tbzs_specid)); if (empty($shop_spec)) { pdo_insert("wwx_fxxt_spec", $spec); $specid = pdo_insertid(); pdo_update('wwx_fxxt_spec', array('goodsid' => $shop_goodsid), array("id" => $specid)); pdo_update('wwx_fxxt_shop_spec', array('specid' => $specid), array("id" => $tbzs_id)); } else { pdo_update('wwx_fxxt_spec', $spec, array("id" => $shop_spec['id'])); pdo_update('wwx_fxxt_spec', array('goodsid' => $shop_goodsid), array("id" => $shop_spec['id'])); $specid = $shop_spec['id']; } $shop_spec['id'] = $specid; $specids[] = $specid; $spec_itemids = array(); $newspecitems = array(); $spec_items = pdo_fetchall("select * from " . tablename('wwx_fxxt_shop_spec_item') . " where specid=:specid order by displayorder asc", array(":specid" => $tbzs_id)); foreach ($spec_items as &$spec_item) { $tbzs_itemid = $spec_item['id']; $tbzs_spec_itemid = $spec_item['spec_item_id']; unset($spec_item['spec_item_id']); unset($spec_item['valueId']); unset($spec_item['id']); $spec_itemid = 0; $spec_item['specid'] = $specid; $shop_spec_item = pdo_fetch("select * from " . tablename("wwx_fxxt_spec_item") . " where id=:specitemid limit 1", array(":specitemid" => $tbzs_spec_itemid)); if (empty($shop_spec_item)) { pdo_insert("wwx_fxxt_spec_item", $spec_item); $spec_itemid = pdo_insertid(); pdo_update('wwx_fxxt_spec_item', array('goodsid' => $shop_goodsid), array("id" => $spec_itemid)); pdo_update('wwx_fxxt_shop_spec_item', array('spec_item_id' => $spec_itemid), array("id" => $tbzs_itemid)); } else { pdo_update('wwx_fxxt_spec_item', $spec_item, array("id" => $shop_spec_item['id'])); pdo_update('wwx_fxxt_spec_item', array('goodsid' => $shop_goodsid), array("id" => $shop_spec_item['id'])); $spec_itemid = $shop_spec_item['id']; } $spec_itemids[] = $spec_itemid; $spec_item['id'] = $spec_itemid; $spec_item['yuanId'] = $tbzs_itemid; $newspecitems[] = $spec_item; } $shop_spec['items'] = $newspecitems; $newspecs[] = $shop_spec; unset($spec_item); if (count($spec_itemids) > 0) { pdo_query("delete from " . tablename('wwx_fxxt_spec_item') . " where specid={$specid} and id not in (" . implode(",", $spec_itemids) . " )"); } else { pdo_query('delete from ' . tablename('wwx_fxxt_spec_item') . " where specid={$specid}"); } pdo_update('wwx_fxxt_shop_spec', array('content' => serialize($spec_itemids)), array("id" => $shop_spec['id'])); } unset($spec); if (count($specids) > 0) { pdo_query("delete from " . tablename('wwx_fxxt_spec') . " where goodsid={$shop_goodsid} and id not in (" . implode(",", $specids) . " )"); } else { pdo_query('delete from ' . tablename('wwx_fxxt_spec') . " where goodsid={$shop_goodsid}"); } $options = pdo_fetchall("select * from " . tablename("wwx_fxxt_shop_goods_option") . " where goodsid=:goodsid order by displayorder asc", array(":goodsid" => $goodsid)); $optionids = array(); foreach ($options as &$option) { $tbzs_id = $option['id']; $tbzs_optionid = $option['optionid']; unset($option['optionid']); unset($option['skuId']); unset($option['id']); $optionid = 0; $idspecs = explode("_", $option['specs']); $newids = array(); foreach ($idspecs as $key => $ida) { foreach ($newspecs as $nsp) { foreach ($nsp['items'] as $nspitem) { if ($nspitem['yuanId'] == $ida) { $newids[] = $nspitem['id']; } } } } $newids = implode("_", $newids); $option['specs'] = $newids; $shop_option = pdo_fetch("select * from " . tablename("wwx_fxxt_goods_option") . " where id=:optionid limit 1", array(":optionid" => $tbzs_optionid)); if (empty($shop_option)) { pdo_insert("wwx_fxxt_goods_option", $option); $optionid = pdo_insertid(); pdo_update('wwx_fxxt_goods_option', array('goodsid' => $shop_goodsid), array("id" => $optionid)); pdo_update('wwx_fxxt_shop_goods_option', array('optionid' => $optionid), array("id" => $tbzs_id)); } else { pdo_update('wwx_fxxt_goods_option', $option, array("id" => $shop_option['id'])); pdo_update('wwx_fxxt_goods_option', array('goodsid' => $shop_goodsid), array("id" => $shop_option['id'])); $optionid = $shop_option['id']; } $optionids[] = $optionid; } if (count($optionids) > 0) { pdo_query("delete from " . tablename('wwx_fxxt_goods_option') . " where goodsid={$shop_goodsid} and id not in (" . implode(",", $optionids) . " )"); } else { pdo_query('delete from ' . tablename('wwx_fxxt_goods_option') . " where goodsid={$shop_goodsid}"); } pdo_update('wwx_fxxt_shop_goods', array('status' => 1, 'goodsid' => $shop_goodsid), array("id" => $goodsid)); return array('result' => '1', 'goodsid' => $shop_goodsid); } private function get_info_url($itemid) { return "http://hws.m.taobao.com/cache/wdetail/5.0/?id=" . $itemid; } private function get_detail_url($itemid) { return 'http://hws.m.taobao.com/cache/wdesc/5.0/?id=' . $itemid; } private function get_itemid_url($url) { preg_match("/id\=(\d+)/i", $url, $matches); if (isset($matches[1])) { return $matches[1]; } else { return '错误itemid'; } } private function get_total_page($url = '', $taobao = false) { if (empty($url)) { return array("totalpage" => 0); } $content = $this->get_page_content($url); $str = ""; if ($taobao) { $str = "/(.*)/"; } else { $str = "/(.*)<\/b>/"; } preg_match($str, $content, $p); if (is_array($p)) { $pages = explode("/", $p[1]); return array('totalpage' => $pages[1]); } return array('totalpage' => 0); } private function get_page_content($url = '', $pageNo = 1) { load()->func('communication'); if (empty($url)) { return array("totalpage" => 0); } $url = $this->get_pageno_url($url, $pageNo); $url = $this->getRealURL($url); $response = ihttp_get($url); if (!isset($response['content'])) { return array("result" => 0); } return $response['content']; } private function get_pageno_url($url = '', $pageNo = 1) { $url .= "/search.htm?pageNo=" . $pageNo; return $url; } private function getRealURL($url) { if (function_exists("stream_context_set_default")) { stream_context_set_default(array('http' => array('method' => 'HEAD'))); } $header = $this->get_url_headers($url, 1); if (strpos($header[0], '301') || strpos($header[0], '302')) { if (is_array($header['Location'])) { return $header['Location'][count($header['Location']) - 1]; } else { return $header['Location']; } } else { return $url; } } private function get_page_items($pageContent = '') { $str = '/data-id="(.*)"/U'; preg_match_all($str, $pageContent, $items); if (isset($items[1])) { return $items[1]; } return array(); } private function get_url_headers($url, $timeout = 10) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); $data = curl_exec($ch); $data = preg_split('/\n/', $data); $data = array_filter(array_map(function ($data) { $data = trim($data); if ($data) { $data = preg_split('/:\s/', trim($data), 2); $length = count($data); switch ($length) { case 2: return array($data[0] => $data[1]); break; case 1: return $data; break; default: break; } } }, $data)); sort($data); foreach ($data as $key => $value) { $arrt = array_keys($value); $itemKey = $arrt[0]; if (is_int($itemKey)) { $data[$key] = $value[$itemKey]; } elseif (is_string($itemKey)) { $data[$itemKey] = $value[$itemKey]; unset($data[$key]); } } return $data; } private function getCollectionType($type) { $types = array(0 => '试用采集', 1 => '会员采集', 2 => '导入分销', 3 => '导出信息', 4 => '用户登录', 5 => '更新会员', 6 => '新增会员'); return $types[intval($type)]; } private function getStockType($stock) { $status = pdo_fetch("select status from " . tablename('wwx_fxxt_shop_collection_status') . " where stock='{$stock}' limit 1 "); if (!empty($status)) { $for = "label-danger"; } else { $for = "label-success"; } return $for; } private function getStatusType($stock) { $status = pdo_fetch("select status from " . tablename('wwx_fxxt_shop_collection_status') . " where stock='{$stock}' limit 1 "); if (!empty($status)) { $for = $status['status']; } else { $for = 0; } return $for; } protected function redauth() { global $_W; session_start(); $openid = $_SESSION['__:proxy:openid']; require_once WWX_FXXT_ROOT . '/class/Fans.class.php'; $f = new Fans(); if (!empty($openid)) { $exists = $f->getOne($openid, true); if (!empty($exists)) { return $exists; } } $api = $this->module['config']['api']; if (empty($api)) { message('活动还未开放,商家没有配置好API'); } $modulePublic = '../addons/wwx_fxxt/style/static/'; require_once WWX_FXXT_ROOT . '/class/Activity.class.php'; $forceSubscribe = true; $openid = $this->getFromUser(); if (!empty($openid) && strlen($openid) > 10) { $fans = pdo_fetch('SELECT fans.openid openid, fans.follow follow, member.* FROM ' . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member WHERE fans.uniacid = :uniacid AND fans.openid = :openid AND fans.uid=member.uid LIMIT 1", array(':uniacid' => $_W['uniacid'], ':openid' => $openid)); if (is_array($fans) && !empty($fans['openid'])) { $user = array(); $user['uniacid'] = $_W['uniacid']; $user['openid'] = $fans['openid']; $user['nickname'] = $fans['nickname']; $user['gender'] = $fans['gender']; $user['city'] = $fans['residecity']; $user['state'] = $fans['resideprovince']; $user['avatar'] = $fans['avatar']; $user['country'] = $fans['nationality']; $f->save($user); $_SESSION['__:proxy:openid'] = $user['openid']; } } $exists = $f->getOne($openid, true); if (!empty($exists)) { return $exists; } } protected function prepareActivity($activity, $verifyParams = array()) { if (empty($activity)) { return error(-1, '

访问错误

'); } if (is_error($activity)) { return $activity; } if ($activity['start'] > TIMESTAMP) { return error(-2, '

不要着急, 活动还未开始, 敬请期待


本次活动时间为:
' . date('Y-m-d H:i', $activity['start']) . '
' . date('Y-m-d H:i', $activity['end']) . '
'); } if ($activity['end'] < TIMESTAMP) { return error(-2, '

手慢了, 本次活动已经结束, 请关注我们期待下次活动


本次活动时间为:
' . date('Y-m-d H:i', $activity['start']) . '
' . date('Y-m-d H:i', $activity['end']) . '
'); } if (!empty($activity['limit'])) { if (!empty($activity['limit']['range']) && !empty($verifyParams['user'])) { $valid = false; $pieces = explode(';', $activity['limit']['range']); if (is_array($pieces)) { foreach ($pieces as $district) { if ($valid) { break; } $district = trim($district); $districts = explode('-', $district); $area = array(); $area['state'] = trim($districts[0]); $area['city'] = trim($districts[1]); if (!empty($area['state']) && !empty($area['city'])) { if ($area['state'] == $verifyParams['user']['state'] && $area['city'] == $verifyParams['user']['city']) { $valid = true; } } elseif (!empty($area['state'])) { if ($area['state'] == $verifyParams['user']['state']) { $valid = true; } } } } if (!$valid) { return error(-3, "

你的位置是: {$verifyParams['range']['state']}-{$verifyParams['range']['city']}


不在本次活动范围. 请关注并期待我们下一次活动
"); } } if (!empty($activity['limit']['gender']) && !empty($verifyParams['user'])) { if ($activity['limit']['gender'] != $verifyParams['user']['gender']) { return error(-3, "

抱歉哦: 本次活动只在 {$activity['limit']['gender']} 性朋友范围内举行

"); } } if (!empty($activity['limit']['amount'])) { if ($activity['amount'] >= $activity['limit']['amount']) { return error(-4, "

哎呀, 手慢了. 本次活动所有红包已发完


本次活动已经结束, 请关注我们期待下一次活动
"); } } } if ($activity['type'] == 'game') { if ($activity['tag']['pool'] <= $activity['tag']['threshold']) { return error(-4, "

哎呀, 手慢了. 本次活动所有红包已发完


本次活动已经结束, 请关注我们期待下一次活动
"); } } return $activity; } public function checkSubscribe() { global $_W; session_start(); if (empty($_W['openid']) || empty($_W['acid'])) { return false; } if (empty($_SESSION['__:subscribe'])) { $account = WeAccount::create($_W['acid']); if (!empty($account)) { $ainfo = $account->fetchAccountInfo(); if (!empty($ainfo['secret']) && !empty($ainfo['key'])) { $fans = $account->fansQueryInfo($_W['openid']); if (!is_error($fans) && !empty($fans) && !empty($fans['subscribe'])) { $_SESSION['__:subscribe'] = true; return true; } } else { $_SESSION['__:subscribe'] = true; return true; } } } else { return true; } return false; } protected function redsend($activity, $record, $user) { global $_W,$_GPC; load()->func('communication'); $uniacid = $_W['uniacid']; $api = $this->module['config']['api']; if (empty($api)) { return error(-2, '系统还未开放'); } require_once WWX_FXXT_ROOT . '/class/Activity.class.php'; require_once WWX_FXXT_ROOT . '/class/Gift.class.php'; $a = new Activity(); if (empty($record) || $record['status'] == 'complete') { return error(-1, '没有获得现金红包或已经领取过这个现金红包了'); } $g = new Gift(); $gift = $g->getOne($record['gift']); if (empty($gift) && $gift['type'] != 'cash') { return error(-1, '没有获得现金红包'); } $fee = floatval($record['fee']) * 100; $url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack'; $pars = array(); $pars['nonce_str'] = random(32); $pars['mch_billno'] = $api['api_QrCode'] . date('Ymd') . sprintf('%010d', $record['id']); $pars['mch_id'] = $api['api_QrCode']; $pars['wxappid'] = $api['api_appid']; //$pars['nick_name'] = $gift['tag']['provider']; //$pars['send_name'] = $gift['tag']['provider']; $pars['send_name'] =$_GPC['shopname']; $pars['re_openid'] = $user['openid']; $pars['total_amount'] = $fee; //$pars['min_value'] = $pars['total_amount']; //$pars['max_value'] = $pars['total_amount']; $pars['total_num'] = 1; $pars['wishing'] = $gift['tag']['wish']; $pars['client_ip'] = $api['api_ip']; $pars['act_name'] = $activity['title']; $pars['remark'] = $gift['tag']['remark']; //$pars['logo_imgurl'] = tomedia($gift['tag']['image']); //$pars['share_content'] = $gift['tag']['content']; //$pars['share_imgurl'] = tomedia($gift['tag']['image']); //$pars['share_url'] = $_W['siteroot'] . 'app/' . substr($this->createMobileUrl('redentry', array('owner' => $user['uid'], 'actid' => $activity['actid'])), 2); ksort($pars, SORT_STRING); $string1 = ''; foreach ($pars as $k => $v) { $string1 .= "{$k}={$v}&"; } $string1 .= "key={$api['api_QrKey']}"; $pars['sign'] = strtoupper(md5($string1)); $xml = array2xml($pars); $extras = array(); $extras['CURLOPT_CAINFO'] = WWX_FXXT_ROOT . '/cert/rootca.pem.' . $uniacid; $extras['CURLOPT_SSLCERT'] = WWX_FXXT_ROOT . '/cert/apiclient_cert.pem.' . $uniacid; $extras['CURLOPT_SSLKEY'] = WWX_FXXT_ROOT . '/cert/apiclient_key.pem.' . $uniacid; $procResult = null; $resp = ihttp_request($url, $xml, $extras); if (is_error($resp)) { $procResult = $resp; } else { $xml = '' . $resp['content']; $dom = new \DOMDocument(); if ($dom->loadXML($xml)) { $xpath = new \DOMXPath($dom); $code = $xpath->evaluate('string(//xml/return_code)'); $ret = $xpath->evaluate('string(//xml/result_code)'); if (strtolower($code) == 'success' && strtolower($ret) == 'success') { $procResult = true; } else { $error = $xpath->evaluate('string(//xml/err_code_des)'); $procResult = error(-2, $error); } } else { $procResult = error(-1, 'error response'); } } if (is_error($procResult)) { $filters = array(); $filters['uniacid'] = $uniacid; $filters['id'] = $record['id']; $rec = array(); $rec['log'] = $procResult['message']; pdo_update('wwx_fxxt_red_records', $rec, $filters); return $procResult; } else { $a->confirm($record['id'], sprintf('%.2f', $fee / 100)); return true; } } protected function wxsend($user) { global $_W; load()->func('communication'); $uniacid = $_W['uniacid']; $api = $this->module['config']['api']; if (empty($api)) { return error(-2, '系统还未开放'); } $fee = floatval($user['fee']) * 100; $url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers'; $pars = array(); $pars['mch_appid'] = $api['api_appid']; $pars['mchid'] = $api['api_QrCode']; $pars['nonce_str'] = random(32); $pars['partner_trade_no'] = $api['api_QrCode'] . date('YmdHi') . random(6, 1); $pars['openid'] = $user['openid']; $pars['check_name'] = 'NO_CHECK'; $pars['re_user_name'] = $user['realname']; $pars['amount'] = $fee; $pars['desc'] = $user['desc']; $pars['spbill_create_ip'] = $api['api_ip']; ksort($pars, SORT_STRING); $string1 = ''; foreach ($pars as $k => $v) { $string1 .= "{$k}={$v}&"; } $string1 .= "key={$api['api_QrKey']}"; $pars['sign'] = strtoupper(md5($string1)); $xml = array2xml($pars); $extras = array(); $extras['CURLOPT_CAINFO'] = WWX_FXXT_ROOT . '/cert/rootca.pem.' . $uniacid; $extras['CURLOPT_SSLCERT'] = WWX_FXXT_ROOT . '/cert/apiclient_cert.pem.' . $uniacid; $extras['CURLOPT_SSLKEY'] = WWX_FXXT_ROOT . '/cert/apiclient_key.pem.' . $uniacid; $procResult = null; $resp = ihttp_request($url, $xml, $extras); if (is_error($resp)) { $procResult = $resp; } else { $xml = '' . $resp['content']; $dom = new \DOMDocument(); if ($dom->loadXML($xml)) { $xpath = new \DOMXPath($dom); $code = $xpath->evaluate('string(//xml/return_code)'); $ret = $xpath->evaluate('string(//xml/result_code)'); if (strtolower($code) == 'success' && strtolower($ret) == 'success') { $procResult = true; } else { $error = $xpath->evaluate('string(//xml/err_code_des)'); $procResult = error(-2, $error); } } else { $procResult = error(-1, 'error response'); } } if (is_error($procResult)) { return $procResult; } else { return true; } } public function getDzdid($dzduid = 0) { global $_W; if (!empty($dzduid)) { return $dzduid; } return $_COOKIE['dzdid_' . WWX_FXXT_VERSION . $_W['uniacid']]; } public function isDzdMode($profile, $dzduid = 0) { global $_W; if (empty($profile['id'])) { $profile = $this->getProfile(); } if (!empty($dzduid)) { if ($profile['id'] == $dzduid) { return true; } if ($dzduid == -1) { $theone = pdo_fetch('SELECT ischeck FROM ' . tablename('wwx_fxxt_rules') . ' WHERE uniacid = :uniacid', array(':uniacid' => $_W['uniacid'])); if ($profile['dzdflag'] == 1 && $profile['flag'] == 1 && $theone['ischeck'] == 2) { return true; } return false; } if ($profile['id'] != $dzduid) { return false; } } if (!empty($_COOKIE['dzdid_' . WWX_FXXT_VERSION . $_W['uniacid']])) { if ($_COOKIE['dzdid_' . WWX_FXXT_VERSION . $_W['uniacid']] == $profile['id']) { return true; } else { return false; } } $theone = pdo_fetch('SELECT ischeck FROM ' . tablename('wwx_fxxt_rules') . ' WHERE uniacid = :uniacid', array(':uniacid' => $_W['uniacid'])); if ($profile['dzdflag'] == 1 && $profile['flag'] == 1 && $theone['ischeck'] == 2) { return true; } return false; } public function getDzdname($id) { global $_W; if ($_COOKIE['dzdid_' . WWX_FXXT_VERSION . $_W['uniacid']] == $id) { return '我的小店'; } if (!empty($_COOKIE['dzdid_' . WWX_FXXT_VERSION . $_W['uniacid']])) { $users = $this->getMember($_COOKIE['dzdid_' . WWX_FXXT_VERSION . $_W['uniacid']]); if (!empty($users['dzdtitle'])) { return $users['dzdtitle']; } } return $_W['account']['name']; } private function getFromFlagID($from_user) { global $_W; $profile = pdo_fetch('SELECT id FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = :uniacid AND from_user = :from_user", array(':uniacid' => $_W['uniacid'], ':from_user' => $from_user)); if (!empty($profile['id'])) { return $profile['id']; } else { return 0; } } private function getFromAddress($username) { global $_W; $address = pdo_fetchall("SELECT id FROM " . tablename('wwx_fxxt_address') . " WHERE (realname LIKE '%{$username}%' OR mobile LIKE '%{$username}%') AND uniacid = " . $_W['uniacid']); if (!empty($address)) { return $address; } else { return ''; } } private function getFromDate($time) { $time = date('Y-m-d H:i:s', $time); $str = str_replace(chr(32), "
", $time); return $str; } private function getFromflagsum($from_user, $cun = 1) { global $_W; $cfg = $this->module['config']; if (empty($from_user) && $cun == 10) { return array('count_huiyuan_1' => 0, 'count_huiyuan_2' => 0, 'count_huiyuan_3' => 0, 'commissionTotal' => 0, 'priceTotal' => 0, 'count_daili_1' => 0, 'count_daili_2' => 0, 'count_daili_3' => 0, 'followcount' => 0, 'huiyuan_zong' => 0, 'daili_zong' => 0, 'huiyuan_daili' => 0); } if (empty($from_user)) { return 0; } $profile = pdo_fetch('SELECT id FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = :uniacid AND from_user = :from_user", array(':uniacid' => $_W['uniacid'], ':from_user' => $from_user)); if (empty($profile['id']) && $cun == 10) { return array('count_huiyuan_1' => 0, 'count_huiyuan_2' => 0, 'count_huiyuan_3' => 0, 'commissionTotal' => 0, 'priceTotal' => 0, 'count_daili_1' => 0, 'count_daili_2' => 0, 'count_daili_3' => 0, 'followcount' => 0, 'huiyuan_zong' => 0, 'daili_zong' => 0, 'huiyuan_daili' => 0); } if (empty($profile['id'])) { return 0; } $count_huiyuan_1 = 0; $count_huiyuan_2 = 0; $count_huiyuan_3 = 0; $commissionTotal = 0; $priceTotal = 0; $count_daili_1 = 0; $count_daili_2 = 0; $count_daili_3 = 0; $followcount = 0; $huiyuan_zong = 0; $daili_zong = 0; $huiyuan_daili = 0; $sql1_member = "select mber1.from_user from " . tablename('wwx_fxxt_member') . " mber1 where mber1.realname<>'' and mber1.id!=mber1.shareid and mber1.shareid = " . $profile['id']; $followcount = pdo_fetchcolumn("select count(*) from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member where fans.follow=1 and fans.openid!='{$from_user}' and ( fans.openid in (" . $sql1_member . ") ) and fans.uid=member.uid and fans.uniacid={$_W['uniacid']} "); if ($cun == 9) { return $followcount; } $count1 = pdo_fetchcolumn(" select count(*) from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " member2 where fans.openid!='{$from_user}' and ( fans.openid in (" . $sql1_member . " and mber1.flag=0) ) and fans.uid=member.uid and fans.openid=member2.from_user and fans.uniacid={$_W['uniacid']}"); $count1_1 = pdo_fetchcolumn(" select count(*) from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " member2 where fans.openid!='{$from_user}' and ( fans.openid in (" . $sql1_member . " and mber1.flag=1) ) and fans.uid=member.uid and fans.openid=member2.from_user and fans.uniacid={$_W['uniacid']}"); $commission1_1 = pdo_fetchcolumn("SELECT sum((g.commission*g.total)) FROM " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE o.shareid=" . $profile['id'] . " and o.uniacid = " . $_W['uniacid'] . " and o.status = 3 and o.from_user != '{$from_user}' and g.createtime>='{$profile['flagtime']}'"); $price1_1 = pdo_fetchcolumn("SELECT sum(price) FROM " . tablename('wwx_fxxt_order') . " WHERE shareid=" . $profile['id'] . " and uniacid = " . $_W['uniacid'] . " and status = 3 and from_user != '{$from_user}' and createtime>='{$profile['flagtime']}'"); if ($cfg['globalCommissionLevel'] >= 2) { $level2 = "select level2m.id from " . tablename('wwx_fxxt_member') . " level2m where level2m.id!=level2m.shareid and level2m.shareid = " . $profile['id']; $sql2_member = "select mber2.from_user from " . tablename('wwx_fxxt_member') . " mber2 where mber2.realname<>'' and mber2.id!=mber2.shareid and mber2.shareid in (" . $level2 . ") "; $count2 = pdo_fetchcolumn(" select count(*) from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " member2 where fans.openid!='{$from_user}' and ( fans.openid in (" . $sql2_member . " and mber2.flag=0)) and (fans.openid not in (" . $sql1_member . " and mber1.flag=0) ) and fans.uid=member.uid and fans.openid=member2.from_user and fans.uniacid={$_W['uniacid']}"); $count2_1 = pdo_fetchcolumn(" select count(*) from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " member2 where fans.openid!='{$from_user}' and ( fans.openid in (" . $sql2_member . " and mber2.flag=1)) and (fans.openid not in (" . $sql1_member . " and mber1.flag=1) ) and fans.uid=member.uid and fans.openid=member2.from_user and fans.uniacid={$_W['uniacid']}"); $commission2_1 = pdo_fetchcolumn("SELECT sum((g.commission2*g.total)) FROM " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE o.shareid2=" . $profile['id'] . " and o.uniacid = " . $_W['uniacid'] . " and o.status = 3 and o.from_user != '{$from_user}' and g.createtime>='{$profile['flagtime']}'"); $price2_1 = pdo_fetchcolumn("SELECT sum(price) FROM " . tablename('wwx_fxxt_order') . " WHERE shareid2=" . $profile['id'] . " and uniacid = " . $_W['uniacid'] . " and status = 3 and from_user != '{$from_user}' and createtime>='{$profile['flagtime']}'"); } else { $str = 0; } if ($cfg['globalCommissionLevel'] >= 3) { $level3 = "select level3m.id from " . tablename('wwx_fxxt_member') . " level3m where level3m.id!=level3m.shareid and level3m.shareid in( " . $level2 . ")"; $sql3_member = "select mber3.from_user from " . tablename('wwx_fxxt_member') . " mber3 where mber3.realname<>'' and mber3.id!=mber3.shareid and mber3.shareid in (" . $level3 . ") "; $count3 = pdo_fetchcolumn(" select count(*) from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " member2 where fans.openid!='{$from_user}' and (fans.openid in (" . $sql3_member . " and mber3.flag=0)) and (fans.openid not in (" . $sql1_member . " and mber1.flag=0)) and (fans.openid not in (" . $sql2_member . " and mber2.flag=0)) and fans.uid=member.uid and fans.openid=member2.from_user and fans.uniacid={$_W['uniacid']}"); $count3_1 = pdo_fetchcolumn(" select count(*) from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " member2 where fans.openid!='{$from_user}' and (fans.openid in (" . $sql3_member . " and mber3.flag=1)) and (fans.openid not in (" . $sql1_member . " and mber1.flag=1)) and (fans.openid not in (" . $sql2_member . " and mber2.flag=1)) and fans.uid=member.uid and fans.openid=member2.from_user and fans.uniacid={$_W['uniacid']}"); $commission3_1 = pdo_fetchcolumn("SELECT sum((g.commission3*g.total)) FROM " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid WHERE o.shareid3=" . $profile['id'] . " and o.uniacid = " . $_W['uniacid'] . " and o.status = 3 and o.from_user != '{$from_user}' and g.createtime>='{$profile['flagtime']}'"); $price3_1 = pdo_fetchcolumn("SELECT sum(price) FROM " . tablename('wwx_fxxt_order') . " WHERE shareid3=" . $profile['id'] . " and uniacid = " . $_W['uniacid'] . " and status = 3 and from_user != '{$from_user}' and createtime>='{$profile['flagtime']}'"); } else { $str3 = 0; } $count_huiyuan_1 = $count1; $count_huiyuan_2 = $count2; $count_huiyuan_3 = $count3; $commissionTotal = $commission1_1 + $commission2_1 + $commission3_1; $priceTotal = $price1_1 + $price2_1 + $price3_1; $count_daili_1 = $count1_1; $count_daili_2 = $count2_1; $count_daili_3 = $count3_1; $huiyuan_zong = $count1 + $count2 + $count3; $daili_zong = $count1_1 + $count2_1 + $count3_1; $huiyuan_daili = $huiyuan_zong + $daili_zong; $zong = array('count_huiyuan_1' => $count_huiyuan_1, 'count_huiyuan_2' => $count_huiyuan_2, 'count_huiyuan_3' => $count_huiyuan_3, 'commissionTotal' => $commissionTotal, 'priceTotal' => $priceTotal, 'count_daili_1' => $count_daili_1, 'count_daili_2' => $count_daili_2, 'count_daili_3' => $count_daili_3, 'followcount' => $followcount, 'huiyuan_zong' => $huiyuan_zong, 'daili_zong' => $daili_zong, 'huiyuan_daili' => $huiyuan_daili); if ($cun == 1) { return $count_huiyuan_1; } elseif ($cun == 2) { return $count_huiyuan_2; } elseif ($cun == 3) { return $count_huiyuan_3; } elseif ($cun == 4) { return $commissionTotal; } elseif ($cun == 5) { return $priceTotal; } elseif ($cun == 6) { return $count_daili_1; } elseif ($cun == 7) { return $count_daili_2; } elseif ($cun == 8) { return $count_daili_3; } elseif ($cun == 10) { return $zong; } elseif ($cun == 11) { return $huiyuan_zong; } elseif ($cun == 12) { return $daili_zong; } elseif ($cun == 13) { return $huiyuan_daili; } else { return 0; } } private function getFromordersum($id = '', $from_user = '') { global $_W; if (!empty($from_user)) { $profile = pdo_fetch('SELECT id FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = :uniacid AND from_user = :from_user", array(':uniacid' => $_W['uniacid'], ':from_user' => $from_user)); $id = $profile['id']; } if (empty($id)) { return 0; } $count = 0; $count = pdo_fetchcolumn("select count(*) from " . tablename('wwx_fxxt_order') . " where uniacid = '{$_W['uniacid']}' AND (shareid = '{$id}' or shareid2 = '{$id}' or shareid3 = '{$id}') "); return $count; } private function getFromUserOrderSum($id = '', $from_user = '') { global $_W; if (!empty($id)) { $profile = pdo_fetch('SELECT from_user FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = :uniacid AND id = :id", array(':uniacid' => $_W['uniacid'], ':id' => $id)); $from_user = $profile['from_user']; } if (empty($from_user)) { return 0; } $count = 0; $count = pdo_fetchcolumn("select count(*) from " . tablename('wwx_fxxt_order') . " where uniacid = '{$_W['uniacid']}' AND from_user = '{$from_user}' "); return $count; } public function autocancelorder($needcheck = false) { global $_W; if (empty($_COOKIE['ordercancel_' . WWX_FXXT_VERSION . $_W['uniacid']]) || $needcheck == true) { $settings = $this->module['config']; if (!empty($settings['ordertime']) && intval($settings['ordertime']) > 0) { $rules = pdo_fetch('SELECT autocanceltime FROM ' . tablename('wwx_fxxt_rules') . ' WHERE uniacid = :uniacid', array(':uniacid' => $_W['uniacid'])); if (empty($rules['autocanceltime']) || intval($rules['autocanceltime']) <= TIMESTAMP) { $autocanceltime = time() - intval($settings['ordertime']) * 60; $orders = pdo_fetchall('SELECT * FROM ' . tablename('wwx_fxxt_order') . ' where status=0 and paytype<>3 and createtime<:createtime and uniacid = :uniacid', array(':uniacid' => $_W['uniacid'], ':createtime' => $autocanceltime)); foreach ($orders as $order) { pdo_delete('wwx_fxxt_order', array('status' => 0, 'uniacid' => $_W['uniacid'], 'id' => $order['id'])); } pdo_update('wwx_fxxt_rules', array('autocanceltime' => TIMESTAMP + 10 * 60), array('uniacid' => $_W['uniacid'])); } } if ($needcheck == false) { setcookie('ordercancel_' . WWX_FXXT_VERSION . $_W['uniacid'], 1, TIMESTAMP + 5 * 60); } } } private function getFromNoticeeMail($noticee) { global $_W; load()->func('communication'); if (!empty($this->module['config']['noticeemail']) || !empty($noticee)) { $address = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_address') . " WHERE id = :id", array(':id' => $noticee['addressid'])); $body = "

购买商品清单


"; if (!empty($noticee['bodygoods'])) { $body .= $noticee['bodygoods']; } $body .= "
总金额:{$noticee['price']}元 (货到付款)
"; $body .= "

购买用户详情


"; $body .= "真实姓名:{$address[realname]}
"; $body .= "地区:{$address[province]} - {$address[city]} - {$address[area]}
"; $body .= "详细地址:{$address[address]}
"; $body .= "手机:{$address[mobile]}


"; ihttp_email($this->module['config']['noticeemail'], "{$_W['account']['name']}商城订单提醒", $body); } } private function getFansSum($id) { global $_W; $condition = ''; $list = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_member_shipgrade') . " WHERE id = '{$id}'"); $condition .= " AND (tb.price >= '" . $list['member_turnover'] . "' OR tb.orsum >= '" . $list['member_motercount'] . "')"; if ($list['promoterstate'] == 1) { $status .= " AND orders.status = 3 "; } else { $status .= " AND orders.status > 0 "; } $membercount = pdo_fetchcolumn("SELECT count(member.id) from " . tablename('wwx_fxxt_member') . " member WHERE member.uniacid = '{$_W['uniacid']}' and member.from_user in (SELECT tb.from_user FROM (SELECT orders.uniacid as uniacid,orders.from_user as from_user,sum(orders.price) as price,count(orders.id) as orsum FROM " . tablename('wwx_fxxt_order') . " orders WHERE orders.uniacid = '{$_W['uniacid']}' {$status} group by orders.from_user) tb where tb.uniacid = '{$_W['uniacid']}' {$condition} group by tb.from_user)"); return $membercount; } private function getFansZongSum($id) { global $_W; $membercount = pdo_fetchcolumn("SELECT count(id) FROM " . tablename('wwx_fxxt_member') . " WHERE uniacid = '{$_W['uniacid']}' and usergrade = '{$id}'"); return $membercount; } private function getFlagSum($id) { global $_W; $condition = ''; $list = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_member_flaggrade') . " WHERE id = '{$id}'"); if ($list['promoterstate'] == 1) { $status .= " AND orders.status = 3 AND (orders.shareid = member.id or orders.shareid2 = member.id or orders.shareid3 = member.id)"; } else { $status .= " AND orders.status > 0 AND (orders.shareid = member.id or orders.shareid2 = member.id or orders.shareid3 = member.id)"; } $membercount = pdo_fetchcolumn("SELECT count(member.id) from " . tablename('wwx_fxxt_member') . " member WHERE member.uniacid = '{$_W['uniacid']}' and (member.zhifu >= '{$list['flag_money']}' OR (SELECT sum(orders.price) as price FROM " . tablename('wwx_fxxt_order') . " orders WHERE orders.uniacid = '{$_W['uniacid']}' {$status} group by orders.uniacid) >= '{$list['flag_totalmoney']}' OR (SELECT count(member.id) as memsum FROM " . tablename('wwx_fxxt_member') . " member2 WHERE member2.uniacid = '{$_W['uniacid']}' AND member2.shareid = member.id group by member2.uniacid) >= '{$list['flag_count']}')"); return $membercount; } private function getFlagZongSum($id) { global $_W; $membercount = pdo_fetchcolumn("SELECT count(id) FROM " . tablename('wwx_fxxt_member') . " WHERE uniacid = '{$_W['uniacid']}' and flaggrade = '{$id}'"); return $membercount; } private function autouserflag($profile) { global $_W; $cfg = $this->module['config']; if (!empty($profile) && $profile['flag'] == 1) { $flagcount = $this->getFromflagsum($profile['from_user'], 13); if (!empty($flagcount)) { pdo_update('wwx_fxxt_member', array('flagcount' => $flagcount), array('uniacid' => $_W['uniacid'], 'from_user' => $profile['from_user'])); } } if (!empty($profile) && $cfg['fansupgrade'] == 1) { $condition = ''; if ($profile['usergradeauto'] == 0) { $shipgrade = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_member_shipgrade') . " WHERE uniacid = '{$_W['uniacid']}'"); if (!empty($shipgrade)) { foreach ($shipgrade as $ship) { $condition .= " AND (tb.price >= '" . $ship['member_turnover'] . "' OR tb.orsum >= '" . $ship['member_motercount'] . "')"; if ($ship['promoterstate'] == 1) { $status .= " AND orders.status = 3 AND orders.from_user = '{$profile['from_user']}'"; } else { $status .= " AND orders.status > 0 AND orders.from_user = '{$profile['from_user']}'"; } $membercount = pdo_fetchcolumn("SELECT count(member.id) from " . tablename('wwx_fxxt_member') . " member WHERE member.uniacid = '{$_W['uniacid']}' and member.from_user in (SELECT tb.from_user FROM (SELECT orders.uniacid as uniacid,orders.from_user as from_user,sum(orders.price) as price,count(orders.id) as orsum FROM " . tablename('wwx_fxxt_order') . " orders WHERE orders.uniacid = '{$_W['uniacid']}' {$status} group by orders.from_user) tb where tb.uniacid = '{$_W['uniacid']}' {$condition} group by tb.from_user)"); if (!empty($membercount)) { pdo_update('wwx_fxxt_member', array('usergrade' => $ship['displayorder']), array('uniacid' => $_W['uniacid'], 'from_user' => $profile['from_user'])); } } } } } if (!empty($profile) && $cfg['agentupgrade'] == 1) { $condition = ''; if ($profile['flaggradeauto'] == 0) { $flaggrade = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_member_flaggrade') . " WHERE uniacid = '{$_W['uniacid']}'"); if (!empty($flaggrade)) { foreach ($flaggrade as $flag) { if ($flag['promoterstate'] == 1) { $status2 .= " AND orders.status = 3 AND (orders.shareid = '{$profile['id']}' or orders.shareid2 = '{$profile['id']}' or orders.shareid3 = '{$profile['id']}')"; } else { $status2 .= " AND orders.status > 0 AND (orders.shareid = '{$profile['id']}' or orders.shareid2 = '{$profile['id']}' or orders.shareid3 = '{$profile['id']}')"; } $membercount2 = pdo_fetchcolumn("SELECT count(member.id) from " . tablename('wwx_fxxt_member') . " member WHERE member.uniacid = '{$_W['uniacid']}' and (member.zhifu >= '{$flag['flag_money']}' OR (SELECT sum(orders.price) as price FROM " . tablename('wwx_fxxt_order') . " orders WHERE orders.uniacid = '{$_W['uniacid']}' {$status2} group by orders.uniacid) >= '{$flag['flag_totalmoney']}' OR {$profile['flagcount']} >= {$flag['flag_count']}) AND member.id = '{$profile['id']}'"); if (!empty($membercount2)) { pdo_update('wwx_fxxt_member', array('flaggrade' => $flag['displayorder']), array('uniacid' => $_W['uniacid'], 'from_user' => $profile['from_user'])); } } } } } } private function autouserInformation() { global $_W; $index = 0; $lists = pdo_fetchall("select * from " . tablename('wwx_fxxt_member') . " where uniacid = " . $_W['uniacid'] . " and status = 1"); if (!empty($lists)) { foreach ($lists as $list) { $this->autouserflag($list); $index = $index + 1; } } message('更新会员等级、代理等级、代理数量完成,成功处理' . $index . '个用户!', referer(), 'success'); } public function doWebOrder() { global $_W, $_GPC; if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $cfg = $this->module['config']; $operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display'; if ($operation == 'display') { $pindex = max(1, intval($_GPC['page'])); $psize = 50; $status = !isset($_GPC['status']) ? 1 : $_GPC['status']; $sendtype = !isset($_GPC['sendtype']) ? 0 : $_GPC['sendtype']; $condition = ''; $param_flagid = $_GPC['flagid']; if (!empty($_GPC['flagid'])) { $flagid = intval($_GPC['flagid']); $flaguser = $this->getMember($flagid); if (empty($flaguser)) { message("没有此用户的任何信息,请重新查询!", referer(), 'error'); } $condition .= " AND (shareid = '" . $flagid . "' or shareid2 = '" . $flagid . "' or shareid3 = '" . $flagid . "') AND createtime>=" . $flaguser['flagtime'] . " AND from_user<>'" . $flaguser['from_user'] . "'"; } $param_userid = $_GPC['userid']; if (!empty($_GPC['userid'])) { $userid = intval($_GPC['userid']); $useriduser = $this->getMember($userid); if (empty($useriduser)) { message("没有此用户的任何信息,请重新查询!", referer(), 'error'); } $condition .= " AND from_user='" . $useriduser['from_user'] . "'"; } $param_username = $_GPC['username']; if (!empty($_GPC['username'])) { $useraddress = $this->getFromAddress($_GPC['username']); if (empty($useraddress)) { message("没有此用户的任何订单,请重新查询!", referer(), 'error'); } $condition .= " AND (1<>1"; foreach ($useraddress as $ress) { $condition .= " OR addressid='" . intval($ress['id']) . "'"; } $condition .= ")"; } $param_ordersn = $_GPC['ordersn']; if (!empty($_GPC['ordersn'])) { $condition .= " AND ordersn LIKE '%{$_GPC['ordersn']}%'"; } if (!empty($_GPC['cate_2'])) { $cid = intval($_GPC['cate_2']); $condition .= " AND ccate = '{$cid}'"; } elseif (!empty($_GPC['cate_1'])) { $cid = intval($_GPC['cate_1']); $condition .= " AND pcate = '{$cid}'"; } if ($status == '3') { $condition .= ' and ( status = 3 or status = -5 or status = -6)'; } else { if ($status != '-99') { $condition .= " AND status = '" . intval($status) . "'"; } } if (!empty($_GPC['from_user'])) { $fromuser = pdo_fetch("select * from " . tablename('wwx_fxxt_member') . " where from_user = '" . $_GPC['from_user'] . "' and uniacid = " . $_W['uniacid']); $condition .= " AND from_user = '{$_GPC['from_user']}'"; } if (!empty($_GPC['shareid'])) { $shareid = intval($_GPC['shareid']); $user = $this->getMember($shareid); $condition .= " AND (shareid = '" . $shareid . "' or shareid2 = '" . $shareid . "' or shareid3 = '" . $shareid . "') AND createtime>=" . $user['flagtime'] . " AND from_user<>'" . $user['from_user'] . "'"; } if (!empty($sendtype)) { $condition .= " AND sendtype = '" . intval($sendtype) . "' AND status != '3'"; } if (checksubmit('sendbatexpress')) { if (empty($_GPC['check'])) { message('没有选择操作订单,请返回重新操作!', referer(), 'error'); } foreach ($_GPC['check'] as $k) { $isexpress = $_GPC['express' . $k]; if ($isexpress != '-1' && empty($_GPC['expressno' . $k])) { message('有订单没有快递单号,请填写完整!'); } } $index = 0; foreach ($_GPC['check'] as $k) { $item = pdo_fetch('SELECT transid FROM ' . tablename('wwx_fxxt_order') . ' WHERE id = :id', array(':id' => $k)); $express = $_GPC['express' . $k]; if ($express == '-1') { $express == ''; } if (!empty($item['transid'])) { $this->changeWechatSend($k, 1); } pdo_update('wwx_fxxt_order', array('status' => 2, 'sendtime' => TIMESTAMP, 'express' => $express, 'expresscom' => $_GPC['expresscom' . $k], 'expresssn' => $_GPC['expressno' . $k]), array('id' => $k)); $index = $index + 1; } message('批量发货操作完成,成功处理' . $index . '条订单', referer(), 'success'); } if (!empty($_GPC['orderstatisticsEXP01'])) { $report = 'orderstatistics'; $condition = ''; if (!empty($_GPC['flagid'])) { $condition .= " AND (t1.shareid = " . $_GPC['flagid'] . " or t1.shareid2 = " . $_GPC['flagid'] . " or t1.shareid3 = " . $_GPC['flagid'] . ")"; } if (!empty($_GPC['ordersn'])) { $condition .= " AND t1.ordersn LIKE '%{$_GPC['ordersn']}%'"; } if (!empty($_GPC['shareid'])) { $shareid = $_GPC['shareid']; $user = pdo_fetch('select * from ' . tablename('wwx_fxxt_member') . ' where id = ' . $shareid . ' and uniacid = ' . $_W['uniacid']); $condition .= ' AND t1.shareid = \'' . intval($_GPC['shareid']) . '\' AND t1.createtime>=' . $user['flagtime'] . ' AND t1.from_user<>\'' . $user['from_user'] . '\''; } if ($status == '3') { $condition .= ' and ( t1.status = 3 or t1.status = -5 or t1.status = -6)'; }else{ if($status != '-99'){ $condition .= ' AND t1.status = \'' . intval($status) . '\''; } } if (!empty($_GPC['orderstatisticsEXP01'])) { $psize = 9999; $pindex = 1; } $list = pdo_fetchall('select t1.* from (SELECT orders.from_user,orders.zhifutime,orders.status,orders.sendtype,orders.uniacid,orders.id,orders.createtime,orders.ordersn,orders.price,orders.dispatchprice,orders.paytype,orders.shareid,(select member.realname from ' . tablename('wwx_fxxt_member') . ' member where member.from_user=orders.from_user and orders.uniacid=member.uniacid limit 1 ) realnamestr,(select taddress.realname from ' . tablename('wwx_fxxt_address') . ' taddress where taddress.id=orders.addressid and orders.uniacid=taddress.uniacid limit 1 ) tdrealname,(select concat(taddress.province,taddress.city,taddress.area,taddress.address) from ' . tablename('wwx_fxxt_address') . ' taddress where taddress.id=orders.addressid and orders.uniacid=taddress.uniacid limit 1 ) tdaddress,(select taddress.mobile from ' . tablename('wwx_fxxt_address') . ' taddress where taddress.id=orders.addressid and orders.uniacid=taddress.uniacid limit 1 ) tdmobile from ' . tablename('wwx_fxxt_order') . " orders where orders.uniacid = :uniacid {$conditionOrderStatus} order by orders.createtime desc) t1 where t1.uniacid = :uniacid {$condition} LIMIT " . ($pindex - 1) * $psize . ',' . $psize, array(':uniacid' => $_W['uniacid'])); foreach ($list as $id => $displayorder) { $list[$id]['ordergoods'] = pdo_fetchall('SELECT (select category.name from' . tablename('wwx_fxxt_category') . ' category where (0=goods.ccate and category.id=goods.pcate) or (0!=goods.ccate and category.id=goods.ccate) ) as categoryname,(select category.sn from' . tablename('wwx_fxxt_category') . ' category where (0=goods.ccate and category.id=goods.pcate) or (0!=goods.ccate and category.id=goods.ccate) ) as categorysn,goods.thumb,ordersgoods.price,ordersgoods.total,goods.title,ordersgoods.optionname from ' . tablename('wwx_fxxt_order_goods') . ' ordersgoods left join ' . tablename('wwx_fxxt_goods') . ' goods on goods.id=ordersgoods.goodsid where ordersgoods.uniacid = :uniacid and ordersgoods.orderid=:oid order by ordersgoods.createtime desc ', array(':uniacid' => $_W['uniacid'], ':oid' => $list[$id]['id'])); } require_once 'report.php'; die; } $list = pdo_fetchall('SELECT * FROM ' . tablename('wwx_fxxt_order') . " WHERE uniacid = '{$_W['uniacid']}' {$condition} ORDER BY createtime DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize); $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('wwx_fxxt_order') . " WHERE uniacid = '{$_W['uniacid']}' {$condition}"); $pager = pagination($total, $pindex, $psize); if (!empty($list)) { foreach ($list as $key => $l) { $commissions = pdo_fetchall('select total,commission as commission, commission2 as commission2, commission3 as commission3 from ' . tablename('wwx_fxxt_order_goods') . ' where orderid = ' . $l['id']); foreach ($commissions as $commission) { $list[$key]['commission'] = $commission['commission'] * $commission['total']; if ($cfg['globalCommissionLevel'] >= 2) { $list[$key]['commission2'] = $commission['commission2'] * $commission['total']; } else { $list[$key]['commission2'] = 0; } if ($cfg['globalCommissionLevel'] >= 3) { $list[$key]['commission3'] = $commission['commission3'] * $commission['total']; } else { $list[$key]['commission3'] = 0; } } } } if (!empty($list)) { foreach ($list as &$row) { !empty($row['addressid']) && ($addressids[$row['addressid']] = $row['addressid']); $row['dispatch'] = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_dispatch') . " WHERE id = :id", array(':id' => $row['dispatch'])); } unset($row); } if (!empty($addressids)) { $address = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_address') . " WHERE id IN ('" . implode("','", $addressids) . "')", array(), 'id'); } } elseif ($operation == 'detail') { $members = pdo_fetchall('select id, realname from ' . tablename('wwx_fxxt_member')); $member = array(); foreach ($members as $m) { $member[$m['id']] = $m['realname']; } $id = intval($_GPC['id']); $item = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_order') . " WHERE id = :id", array(':id' => $id)); if (empty($item)) { message("抱歉,订单不存在!", referer(), "error"); } $membername = pdo_fetch("select id, realname from " . tablename('wwx_fxxt_member') . " where from_user = '" . $item['from_user'] . "' and uniacid = " . $_W['uniacid'] . " and status = 1"); $membersname1 = pdo_fetch("select id, realname, shareid from " . tablename('wwx_fxxt_member') . " where id = " . $item['shareid'] . " and uniacid = " . $_W['uniacid'] . " and status = 1"); if (empty($membersname1)) { $membersname1['shareid'] = 0; } $membersname2 = pdo_fetch("select id, realname, shareid from " . tablename('wwx_fxxt_member') . " where id = " . $membersname1['shareid'] . " and uniacid = " . $_W['uniacid'] . " and status = 1"); if (empty($membersname2)) { $membersname2['shareid'] = 0; } $membersname3 = pdo_fetch("select id, realname from " . tablename('wwx_fxxt_member') . " where id = " . $membersname2['shareid'] . " and uniacid = " . $_W['uniacid'] . " and status = 1"); if (checksubmit('confirmsend')) { if (!empty($_GPC['isexpress']) && empty($_GPC['expresssn'])) { message('请输入快递单号!'); } $item = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_order') . " WHERE id = :id", array(':id' => $id)); if (!empty($item['transid'])) { $this->changeWechatSend($id, 1); } pdo_update('wwx_fxxt_order', array('status' => 2, 'remark' => $_GPC['remark'], 'express' => $_GPC['express'], 'expresscom' => $_GPC['expresscom'], 'expresssn' => $_GPC['expresssn'], 'sendtime' => TIMESTAMP), array('id' => $id)); message('发货操作成功!', referer(), 'success'); } if (checksubmit('cancelsend')) { $item = pdo_fetch("SELECT transid FROM " . tablename('wwx_fxxt_order') . " WHERE id = :id", array(':id' => $id)); if (!empty($item['transid'])) { $this->changeWechatSend($id, 0, $_GPC['cancelreson']); } pdo_update('wwx_fxxt_order', array('status' => 1, 'remark' => $_GPC['remark'], 'express' => '', 'expresscom' => '', 'expresssn' => ''), array('id' => $id)); message('取消发货操作成功!', referer(), 'success'); } if (checksubmit('finish')) { $this->setOrderCredit($id, $_W['uniacid']); pdo_update('wwx_fxxt_order', array('status' => 3, 'updatetime' => time(), 'remark' => $_GPC['remark']), array('id' => $id)); message('订单操作成功!', referer(), 'success'); } if (checksubmit('cancelpay')) { pdo_update('wwx_fxxt_order', array('status' => 0, 'remark' => $_GPC['remark']), array('id' => $id)); $this->setOrderStock($id, false); message('取消订单付款操作成功!', referer(), 'success'); } if (checksubmit('confrimpay')) { pdo_update('wwx_fxxt_order', array('status' => 1, 'paytype' => 2, 'remark' => $_GPC['remark']), array('id' => $id)); $this->setOrderStock($id); message('确认订单付款操作成功!', referer(), 'success'); } if (checksubmit('beizhu')) { pdo_update('wwx_fxxt_order', array('remark' => $_GPC['remark']), array('id' => $id)); message('订单备注操作成功!', referer(), 'success'); } if (checksubmit('close')) { $item = pdo_fetch("SELECT transid FROM " . tablename('wwx_fxxt_order') . " WHERE id = :id", array(':id' => $id)); if (!empty($item['transid'])) { $this->changeWechatSend($id, 0, $_GPC['reson']); } pdo_update('wwx_fxxt_order', array('status' => -1, 'remark' => $_GPC['remark']), array('id' => $id)); message('订单关闭操作成功!', referer(), 'success'); } if (checksubmit('open')) { pdo_update('wwx_fxxt_order', array('status' => 0, 'remark' => $_GPC['remark']), array('id' => $id)); message('开启订单操作成功!', referer(), 'success'); } if (checksubmit('cancelreturn')) { $item = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_order') . ' WHERE id = :id', array(':id' => $id)); $ostatus = 3; if ($item['status'] == -2) { $ostatus = 1; } if ($item['status'] == -3) { $ostatus = 3; } if ($item['status'] == -4) { $ostatus = 3; } pdo_update('wwx_fxxt_order', array('status' => $ostatus), array('id' => $id)); message('退回操作成功!', referer(), 'success'); } if (checksubmit('returnpay')) { $item = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_order') . ' WHERE id = :id', array(':id' => $id)); if ($item['paytype'] == 3) { message('货到付款订单不能进行退款操作!', referer(), 'error'); } pdo_update('wwx_fxxt_order', array('status' => -6), array('id' => $id)); $this->setOrderStock($id, false); $this->setMemberCredit2($item['from_user'], $item['price'], 'addgold', '订单:' . $item['ordersn'] . '退款返还余额'); message('退款操作成功!', referer(), 'success'); } if (checksubmit('returngood')) { $item = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_order') . ' WHERE id = :id', array(':id' => $id)); pdo_update('wwx_fxxt_order', array('status' => -5), array('id' => $id)); $this->setOrderStock($id, false); $this->setOrderCredit($id, $_W['uniacid'], false); $this->setMemberCredit2($item['from_user'], $item['price'], 'addgold', '订单:' . $item['ordersn'] . '退货返还余额'); message('退货操作成功!', referer(), 'success'); } $dispatch = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_dispatch') . " WHERE id = :id", array(':id' => $item['dispatch'])); if (!empty($dispatch) && !empty($dispatch['express'])) { $express = pdo_fetch("select * from " . tablename('wwx_fxxt_express') . " WHERE id=:id limit 1", array(":id" => $dispatch['express'])); } $item['user'] = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_address') . " WHERE id = {$item['addressid']}"); $goods = pdo_fetchall("SELECT g.id,o.total,o.commission,o.commission2,o.commission3, g.title, g.status,g.thumb, g.unit,g.goodssn,g.productsn,g.marketprice,o.total,g.type,o.optionname,o.optionid,o.price as orderprice FROM " . tablename('wwx_fxxt_order_goods') . " o left join " . tablename('wwx_fxxt_goods') . " g on o.goodsid=g.id " . " WHERE o.orderid='{$id}'"); $item['goods'] = $goods; } if ($operation == 'normal_print') { $id = intval($_GPC['print_orderid']); $item = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_order') . ' WHERE id = :id', array(':id' => $id)); $address = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_address') . ' WHERE id = :id', array(':id' => $item['addressid'])); $pid = intval($_GPC['print_modle_id']); $entry = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_printer') . ' WHERE id=:id', array(':id' => $pid)); $buyer = ''; $wwx_fxxt_member = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_member') . ' WHERE uniacid=:uniacid and from_user=:from_user', array(':uniacid' => $_W['uniacid'], ':from_user' => $item['from_user'])); $buyer = $wwx_fxxt_member['realname']; if (empty($buyer)) { $buyer = $address['realname']; } echo " "; $previewtmp = $entry['printerconfig']; for ($i = 1; $i < 3; $i++) { $previewtmp = str_replace('{buyer}', $buyer, $previewtmp); $previewtmp = str_replace('{consignee}', $address['realname'], $previewtmp); $previewtmp = str_replace('{tel}', $address['mobile'], $previewtmp); $previewtmp = str_replace('{address}', $address['province'] . $address['city'] . $address['area'] . $address['address'], $previewtmp); $previewtmp = str_replace('{pay_type}', $item['paytype'] == 1 ? '余额支付' : ($item['paytype'] == 2 ? '在线支付' : ($item['paytype'] == 3 ? '货到付款' : '')), $previewtmp); $previewtmp = str_replace('{dispatch_type}', $item['expresscom'], $previewtmp); $previewtmp = str_replace('{dispatch_sn}', $item['expresssn'], $previewtmp); $previewtmp = str_replace('{order_sn}', $item['ordersn'], $previewtmp); $previewtmp = str_replace('{time}', date('Y-m-d H:i:s', $item['createtime']), $previewtmp); $previewtmp = str_replace('{order_price}', $item['price'], $previewtmp); $previewtmp = str_replace('{dispatch_price}', $item['dispatchprice'], $previewtmp); $previewtmp = str_replace('{good_price}', $item['goodsprice'], $previewtmp); $previewtmp = str_replace('{print_time}', date('Y-m-d H:i:s', time()), $previewtmp); $good_line = ''; $goods = pdo_fetchall('SELECT g.*,o.price as \'order_price\' ,o.total as \'order_total\',o.optionname as \'order_optionname\' FROM ' . tablename('wwx_fxxt_order_goods') . ' o left join ' . tablename('wwx_fxxt_goods') . ' g on o.goodsid=g.id ' . " WHERE o.orderid='{$id}'"); $goodsmoney = 0; foreach ($goods as $good) { $goodmoney = $good['order_price'] * $good['order_total']; $goodsmoney = $goodsmoney + $goodmoney; $good_line = $good_line . ' '; } $good_line = $good_line . '
商品名称 价格 数量 小计
 ' . $good['title'] . '   ' . $good['order_optionname'] . ' ¥' . $good['order_price'] . '元  ' . $good['order_total'] . '  ¥' . $goodmoney . '元 
商品总金额:¥' . $goodsmoney . '元
'; $previewtmp = str_replace('{good_line}', $good_line, $previewtmp); } echo htmlspecialchars_decode($previewtmp); echo ''; die; } if ($operation == 'express_print') { $id = intval($_GPC['print_express_orderid']); $item = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_order') . ' WHERE id = :id', array(':id' => $id)); $address = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_address') . ' WHERE id = :id', array(':id' => $item['addressid'])); $pid = intval($_GPC['print_modle_id']); $entry = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_printer') . ' WHERE id=:id', array(':id' => $pid)); $buyer = ''; $wwx_fxxt_member = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_member') . ' WHERE uniacid=:uniacid and from_user=:from_user', array(':uniacid' => $_W['uniacid'], ':from_user' => $item['from_user'])); $buyer = $wwx_fxxt_member['realname']; $previewtmp = $entry['printerconfig']; if (!empty($entry['expressconfig'])) { $t_expressconfig = iunserializer($entry['expressconfig']); $entry['print_from_compy'] = $t_expressconfig['print_from_compy']; $entry['print_from_uname'] = $t_expressconfig['print_from_uname']; $entry['print_from_addr'] = $t_expressconfig['print_from_addr']; $entry['print_from_tel'] = $t_expressconfig['print_from_tel']; } for ($i = 1; $i < 3; $i++) { $previewtmp = str_replace('购货人', $buyer, $previewtmp); $previewtmp = str_replace('收货姓名', $address['realname'], $previewtmp); $previewtmp = str_replace('收货电话', $address['mobile'], $previewtmp); $previewtmp = str_replace('收货地址', $address['province'] . $address['city'] . $address['area'] . $address['address'], $previewtmp); $previewtmp = str_replace('支付方式', $item['paytype'] == 1 ? '余额支付' : ($item['paytype'] == 2 ? '在线支付' : ($item['paytype'] == 3 ? '货到付款' : '')), $previewtmp); $previewtmp = str_replace('配送方式', $item['expresscom'], $previewtmp); $previewtmp = str_replace('发货单号', $item['expresssn'], $previewtmp); $previewtmp = str_replace('订单编号', $item['ordersn'], $previewtmp); $previewtmp = str_replace('下单时间', date('Y-m-d H:i:s', $item['createtime']), $previewtmp); $previewtmp = str_replace('订单金额', $item['price'], $previewtmp); $previewtmp = str_replace('配送费用', $item['dispatchprice'], $previewtmp); $previewtmp = str_replace('商品金额', $item['goodsprice'], $previewtmp); $previewtmp = str_replace('打印时间', date('Y-m-d H:i:s', time()), $previewtmp); $previewtmp = str_replace('寄件公司', $entry['print_from_compy'], $previewtmp); $previewtmp = str_replace('寄件人', $entry['print_from_uname'], $previewtmp); $previewtmp = str_replace('寄件地址', $entry['print_from_addr'], $previewtmp); $previewtmp = str_replace('寄件电话', $entry['print_from_tel'], $previewtmp); $previewtmp = str_replace('年', date('Y', time()), $previewtmp); $previewtmp = str_replace('月', date('m', time()), $previewtmp); $previewtmp = str_replace('日', date('d', time()), $previewtmp); } $onlyprint = true; include $this->template('printer_express_print'); die; } $normal_order_list = pdo_fetchall('SELECT * FROM ' . tablename('wwx_fxxt_printer') . ' WHERE uniacid = :uniacid and printertype=0 order by isdefault desc', array(':uniacid' => $_W['uniacid'])); $express_order_list = pdo_fetchall('SELECT * FROM ' . tablename('wwx_fxxt_printer') . ' WHERE uniacid = :uniacid and printertype=1 order by isdefault desc', array(':uniacid' => $_W['uniacid'])); if (!empty($_GPC['dobatch'])) { include $this->template('orderbat'); die; } include $this->template('order'); } public function doWebCharge() { global $_GPC, $_W; set_time_limit(0); if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $pindex = max(1, intval($_GPC['page'])); $psize = 50; $uniacid = $_W['uniacid']; $op = $operation = trim($_GPC['op']) ? trim($_GPC['op']) : 'list'; if ($op == 'list') { if (!empty($_GPC['memberstatisticsEXP01'])) { $report = 'memberstatistics'; $condition = ''; $gpmobile = $_GPC['mobile']; $gprealname = $_GPC['realname']; $gpuserid = $_GPC['userid']; $gpflagid = $_GPC['flagid']; $gpThecharts = $_GPC['Thecharts']; $sql_member = "select count(order1.id) from " . tablename('wwx_fxxt_order') . " order1 where uniacid = '{$_W['uniacid']}' AND order1.from_user = flag.from_user "; $condition .= empty($_GPC['mobile']) ? '' : " AND member.mobile LIKE '%" . trim($_GPC['mobile']) . "%'"; $condition .= empty($_GPC['realname']) ? '' : " AND (( member.realname LIKE '%" . trim($_GPC['realname']) . "%' ) OR ( member.nickname LIKE '%" . trim($_GPC['realname']) . "%' )) "; $condition .= empty($_GPC['userid']) ? '' : " AND flag.id = '" . trim($_GPC['userid']) . "'"; $condition .= empty($_GPC['flagid']) ? '' : " AND flag.shareid = '" . trim($_GPC['flagid']) . "'"; $condition .= empty($_GPC['Thecharts']) ? '' : " AND ((" . $sql_member . ")>0)"; if (!empty($_GPC['memberstatisticsEXP01'])) { $psize = 9999; $pindex = 1; } $list = pdo_fetchall("select flag.id as flagid,fans.openid as from_user,fans.follow,member.* from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " flag where fans.openid=flag.from_user and fans.uniacid=flag.uniacid and fans.uid=member.uid " . $condition . " and fans.uniacid=member.uniacid and fans.uniacid={$_W['uniacid']} ORDER BY flag.id DESC"); require_once 'report.php'; die; } if ($_GPC['submit'] == '搜  索') { $condition = ''; $gpmobile = $_GPC['mobile']; $gprealname = $_GPC['realname']; $gpuserid = $_GPC['userid']; $gpflagid = $_GPC['flagid']; $gpThecharts = $_GPC['Thecharts']; $gpusergrade = $_GPC['usergrade']; $sql_member = "select count(order1.id) from " . tablename('wwx_fxxt_order') . " order1 where uniacid = '{$_W['uniacid']}' AND order1.from_user = flag.from_user "; $condition .= empty($_GPC['mobile']) ? '' : " AND member.mobile LIKE '%" . trim($_GPC['mobile']) . "%'"; $condition .= empty($_GPC['realname']) ? '' : " AND (( member.realname LIKE '%" . trim($_GPC['realname']) . "%' ) OR ( member.nickname LIKE '%" . trim($_GPC['realname']) . "%' )) "; $condition .= empty($_GPC['userid']) ? '' : " AND flag.id = '" . trim($_GPC['userid']) . "'"; $condition .= empty($_GPC['flagid']) ? '' : " AND flag.shareid = '" . trim($_GPC['flagid']) . "'"; $condition .= empty($_GPC['Thecharts']) ? '' : " AND ((" . $sql_member . ")>0)"; $condition .= empty($_GPC['usergrade']) ? '' : " AND flag.usergrade = '" . trim($_GPC['usergrade']) . "'"; $userexp = pdo_fetchall("select * from " . tablename('wwx_fxxt_member_shipgrade') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY displayorder ASC"); $list = pdo_fetchall("select flag.id as flagid,fans.openid as from_user, member.* from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " flag where fans.openid=flag.from_user and fans.uniacid=flag.uniacid and fans.uid=member.uid " . $condition . " and fans.uniacid=member.uniacid and fans.uniacid={$_W['uniacid']} ORDER BY flag.id DESC limit " . ($pindex - 1) * $psize . ',' . $psize); $total = pdo_fetchcolumn("SELECT COUNT(*) from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " flag where fans.openid=flag.from_user and fans.uniacid=flag.uniacid and fans.uid=member.uid " . $condition . " and fans.uniacid=member.uniacid and fans.uniacid={$_W['uniacid']} ORDER BY flag.id DESC"); $pager = pagination($total, $pindex, $psize); include $this->template('charge'); die; } $userexp = pdo_fetchall("select * from " . tablename('wwx_fxxt_member_shipgrade') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY displayorder ASC"); $list = pdo_fetchall("SELECT flag.id as flagid,fans.openid as from_user, member.* FROM " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " flag WHERE fans.openid=flag.from_user and fans.uniacid=flag.uniacid and fans.uid=member.uid and fans.uniacid=member.uniacid and fans.uniacid={$_W['uniacid']} ORDER BY flag.id DESC LIMIT " . ($pindex - 1) * $psize . "," . $psize); $total = pdo_fetchcolumn("SELECT COUNT(*) from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " flag where fans.openid=flag.from_user and fans.uniacid=flag.uniacid and fans.uid=member.uid and fans.uniacid=member.uniacid and fans.uniacid={$_W['uniacid']}"); $pager = pagination($total, $pindex, $psize); include $this->template('charge'); } if ($op == 'delete') { if (empty($_GPC['from_user'])) { message('请选择会员!', create_url('site/entry', array('do' => 'charge', 'op' => 'list', 'm' => 'wwx_fxxt', 'uniacid' => $_W['uniacid'])), 'success'); } $delmember = pdo_fetch('SELECT * FROM ' . tablename('mc_mapping_fans') . ' WHERE uniacid=:uniacid and openid=:openid', array(':uniacid' => $_W['uniacid'], ':openid' => $_GPC['from_user'])); if (empty($delmember)) { message('不存在此会员!', create_url('site/entry', array('do' => 'charge', 'op' => 'list', 'm' => 'wwx_fxxt', 'uniacid' => $_W['uniacid'])), 'success'); } $member_order = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_order') . ' WHERE uniacid=:uniacid and status>0 and from_user=:from_user', array(':uniacid' => $_W['uniacid'], ':from_user' => $_GPC['from_user'])); if (!empty($member_order['id'])) { message('此会员已有订单信息,不能删除,可至代理管理其权限!', create_url('site/entry', array('do' => 'charge', 'op' => 'list', 'm' => 'wwx_fxxt', 'uniacid' => $_W['uniacid'])), 'error'); } pdo_delete('mc_members', array('uid' => $_GPC['uid'], 'uniacid' => $_W['uniacid'])); pdo_delete('mc_mapping_fans', array('uid' => $_GPC['uid'], 'uniacid' => $_W['uniacid'])); pdo_delete('wwx_fxxt_member', array('from_user' => $_GPC['from_user'], 'uniacid' => $_W['uniacid'])); pdo_delete('wwx_fxxt_share_history', array('from_user' => $_GPC['from_user'], 'uniacid' => $_W['uniacid'])); message('成功删除会员!', create_url('site/entry', array('do' => 'charge', 'op' => 'list', 'm' => 'wwx_fxxt', 'uniacid' => $_W['uniacid'])), 'success'); } if ($op == 'post') { if (empty($_GPC['from_user'])) { message('请选择会员!', create_url('site/entry', array('do' => 'charge', 'op' => 'list', 'm' => 'wwx_fxxt', 'uniacid' => $_W['uniacid'])), 'success'); } if (checksubmit()) { if ($_GPC['chargeType'] == 'credit2') { $chargenum = round($_GPC['chargenum'], 2); if ($chargenum) { pdo_query("update " . tablename('mc_members') . " SET credit2=credit2+'" . $chargenum . "' WHERE uid='" . $_GPC['uid'] . "' AND uniacid=" . $_W['uniacid'] . " "); $paylog = array('uid' => $_GPC['uid'], 'credittype' => 'credit2', 'uniacid' => $uniacid, 'num' => $chargenum, 'createtime' => TIMESTAMP, 'operator' => $_W['uid'], 'remark' => '后台充值' . $chargenum . '元'); pdo_insert('mc_credits_record', $paylog); message('充值成功!', referer(), 'success'); } } if ($_GPC['chargeType'] == 'credit1') { if (is_int($_GPC['credit1num'])) { message("充值积分必须是整数!", referer(), 'error'); } if (intval($_GPC['credit1num']) <= 0) { message("充值积分不能为负数或者0", referer(), 'error'); } $credit1num = intval($_GPC['credit1num']); if ($credit1num) { pdo_query("update " . tablename('mc_members') . " SET credit1=credit1+'" . $credit1num . "' WHERE uid='" . $_GPC['uid'] . "' AND uniacid=" . $_W['uniacid'] . " "); $paylog = array('uid' => $_GPC['uid'], 'credittype' => 'credit1', 'uniacid' => $uniacid, 'num' => $credit1num, 'createtime' => TIMESTAMP, 'operator' => $_W['uid'], 'remark' => '充值' . $credit1num . '积分'); pdo_insert('mc_credits_record', $paylog); message('充值成功!', referer(), 'success'); } } } $profile = pdo_fetch("select flag.id as flagid,fans.openid as from_user, member.* from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " flag where fans.openid=flag.from_user and fans.uniacid=flag.uniacid and fans.uid = member.uid and fans.uniacid = member.uniacid and fans.uniacid = :uniacid AND fans.openid=:openid limit 1", array(':uniacid' => $_W['uniacid'], ':openid' => $_GPC['from_user'])); if (!$profile) { message('请选择会员!', create_url('site/entry', array('do' => 'charge', 'op' => 'list', 'm' => 'wwx_fxxt', 'uniacid' => $_W['uniacid'])), 'success'); } $total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('mc_credits_record') . " WHERE uid='" . $_GPC['uid'] . "' AND credittype='" . $_GPC['chargeType'] . "' AND `uniacid` = " . $_W['uniacid']); $pager = pagination($total, $pindex, $psize); $list = pdo_fetchall("SELECT * FROM " . tablename('mc_credits_record') . " WHERE uid='" . $_GPC['uid'] . "' AND credittype='" . $_GPC['chargeType'] . "' AND uniacid=" . $_W['uniacid'] . " ORDER BY createtime DESC LIMIT " . ($pindex - 1) * $psize . "," . $psize); $mlist = pdo_fetchall("SELECT `name`,`title` FROM " . tablename('modules')); $mtype = array(); foreach ($mlist as $k => $v) { $mtype[$v['name']] = $v['title']; } if ($_GPC['chargeType'] == 'credit2') { include $this->template('charge_post'); } if ($_GPC['chargeType'] == 'credit1') { include $this->template('charge_post_credit1'); } } } public function doWebMembershipGrade() { global $_W, $_GPC; if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $uniacid = $_W['uniacid']; $op = $operation = $_GPC['op'] ? $_GPC['op'] : 'display'; if ($operation == 'display') { $children = array(); $list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_member_shipgrade') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY displayorder desc"); include $this->template('membershipgrade'); } elseif ($operation == 'post') { $id = intval($_GPC['id']); $membership = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_member_shipgrade') . " WHERE id = '{$id}'"); if ($_GPC['submit'] == '提交') { if (empty($_GPC['member_name'])) { message('抱歉,请输入等级名称!'); } $data = array('uniacid' => $_W['uniacid'], 'displayorder' => intval($_GPC['displayorder']), 'member_name' => $_GPC['member_name'], 'member_turnover' => intval($_GPC['member_turnover']), 'member_motercount' => intval($_GPC['member_motercount']), 'member_commission' => intval($_GPC['member_commission']), 'promoterstate' => $_GPC['promoterstate']); if (!empty($id)) { pdo_update('wwx_fxxt_member_shipgrade', $data, array('id' => $id, 'uniacid' => $_W['uniacid'])); } else { pdo_insert('wwx_fxxt_member_shipgrade', $data); $id = pdo_insertid(); } message('更新会员等级成功!', $this->createWebUrl('membershipgrade', array('op' => 'display')), 'success'); } include $this->template('membershipgrade'); } elseif ($operation == 'delete') { $id = intval($_GPC['id']); $category = pdo_fetch("SELECT id FROM " . tablename('wwx_fxxt_member_shipgrade') . " WHERE id = '{$id}'"); if (empty($category)) { message('抱歉,会员等级不存在或是已经被删除!', $this->createWebUrl('membershipgrade', array('op' => 'display')), 'error'); } pdo_delete('wwx_fxxt_member_shipgrade', array('id' => $id, 'uniacid' => $_W['uniacid'])); message('会员等级删除成功!', $this->createWebUrl('membershipgrade', array('op' => 'display')), 'success'); } } public function doWebfansmanager() { global $_W, $_GPC; set_time_limit(0); if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $uniacid = $_W['uniacid']; $op = $operation = $_GPC['op'] ? $_GPC['op'] : 'display'; $cfg = $this->module['config']; if ($op == 'autouser') { $this->autouserInformation(); die; } if ($op == 'delflag') { pdo_update('wwx_fxxt_member', array('flag' => intval($_GPC['isstatus'])), array('id' => $_GPC['id'], 'uniacid' => $_W['uniacid'])); $op = 'display'; } if ($op == 'delstatus') { pdo_update('wwx_fxxt_member', array('status' => intval($_GPC['isstatus'])), array('id' => $_GPC['id'], 'uniacid' => $_W['uniacid'])); $op = 'display'; } if (!empty($_GPC['fansstatisticsEXP01'])) { $report = 'fansstatistics'; $condition = ''; $gpmobile = $_GPC['mobile']; $gprealname = $_GPC['realname']; $gpuserid = $_GPC['userid']; $gpflagid = $_GPC['flagid']; $gpThecharts = $_GPC['Thecharts']; $sql_member = "select count(order1.id) from " . tablename('wwx_fxxt_order') . " order1 where uniacid = '{$_W['uniacid']}' AND (order1.shareid = qmxk.id or order1.shareid2 = qmxk.id or order1.shareid3 = qmxk.id) "; $condition .= empty($_GPC['mobile']) ? '' : " AND qmxk.mobile LIKE '%" . trim($_GPC['mobile']) . "%'"; $condition .= empty($_GPC['realname']) ? '' : " AND ( qmxk.realname LIKE '%" . trim($_GPC['realname']) . "%' ) "; $condition .= empty($_GPC['userid']) ? '' : " AND qmxk.id = '" . trim($_GPC['userid']) . "'"; $condition .= empty($_GPC['flagid']) ? '' : " AND qmxk.shareid = '" . trim($_GPC['flagid']) . "'"; $condition .= empty($_GPC['Thecharts']) ? '' : " AND ((" . $sql_member . ")>0)"; if (!empty($_GPC['fansstatisticsEXP01'])) { $psize = 9999; $pindex = 1; } if ($_GPC['opp'] == 'nocheck') { $status = 0; } else { $status = 1; } $list = pdo_fetchall("select qmxk.*,member.credit1 as credit1,member.credit2 as creditmany,fans.follow,member.nickname,member.gender,member.nationality,member.resideprovince,member.residecity,(select shar.realname from " . tablename('wwx_fxxt_member') . " shar where shar.id=qmxk.shareid and qmxk.uniacid=shar.uniacid limit 1) sharname,(select sum(cast(sumorder.price as decimal(8,2))) from " . tablename('wwx_fxxt_order') . " sumorder where sumorder.shareid=qmxk.id and qmxk.uniacid=sumorder.uniacid and status=3 limit 1) sharprice,(select count(id) from " . tablename('wwx_fxxt_member') . " sumflag where sumflag.shareid=qmxk.id and qmxk.uniacid=sumflag.uniacid limit 1) zhituisum from " . tablename('wwx_fxxt_member') . " qmxk," . tablename('mc_mapping_fans') . " fans," . tablename('mc_members') . " member where qmxk.uniacid=fans.uniacid and qmxk.from_user=fans.openid and fans.uid=member.uid " . $condition . " and qmxk.flag = " . $status . " and qmxk.uniacid = " . $_W['uniacid'] . " order by qmxk.id desc limit " . ($pindex - 1) * $psize . ',' . $psize); foreach ($list as $id => $displayorder) { $share1tuan = pdo_fetchall("select id,from_user from " . tablename('wwx_fxxt_member') . " where uniacid=" . $_W['uniacid'] . " and shareid={$displayorder['id']} and flag = 1"); $tuanxiaoshou = 0; foreach ($share1tuan as $tuanshu) { $commission = pdo_fetchcolumn("SELECT sum(price) FROM " . tablename('wwx_fxxt_order') . " WHERE shareid = '{$tuanshu['id']}' AND uniacid = '{$_W['uniacid']}' AND from_user != '{$tuanshu['from_user']}' AND ((paytype=3 and (status =3)) or ((paytype=1 or paytype=2 ) and status=3))"); $tuanxiaoshou = $tuanxiaoshou + $commission; } $list[$id]['tuanxiaoshou'] = $tuanxiaoshou; } require_once 'report.php'; die; } if ($op == 'display') { $pindex = max(1, intval($_GPC['page'])); $psize = 50; $flagexp = pdo_fetchall("select * from " . tablename('wwx_fxxt_member_flaggrade') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY displayorder ASC"); $list = pdo_fetchall("select qmxk.*,member.credit1 as credit1,member.credit2 as credit2 from " . tablename('wwx_fxxt_member') . " qmxk," . tablename('mc_mapping_fans') . " fans," . tablename('mc_members') . " member where qmxk.uniacid=fans.uniacid and qmxk.from_user=fans.openid and fans.uid=member.uid and qmxk.flag = 1 and qmxk.uniacid = " . $_W['uniacid'] . " and qmxk.realname<>'' order by qmxk.id desc limit " . ($pindex - 1) * $psize . ',' . $psize); $total = pdo_fetchcolumn("select count(qmxk.id) from " . tablename('wwx_fxxt_member') . " qmxk," . tablename('mc_mapping_fans') . " fans," . tablename('mc_members') . " member where qmxk.uniacid=fans.uniacid and qmxk.from_user=fans.openid and fans.uid=member.uid and qmxk.flag = 1 and qmxk.uniacid = " . $_W['uniacid'] . " and qmxk.realname<>'' "); $pager = pagination($total, $pindex, $psize); } if ($op == 'nocheck') { $pindex = max(1, intval($_GPC['page'])); $psize = 50; $flagexp = pdo_fetchall("select * from " . tablename('wwx_fxxt_member_flaggrade') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY displayorder ASC"); $list = pdo_fetchall("select qmxk.*,member.credit1 as credit1,member.credit2 as credit2 from " . tablename('wwx_fxxt_member') . " qmxk," . tablename('mc_mapping_fans') . " fans," . tablename('mc_members') . " member where qmxk.uniacid=fans.uniacid and qmxk.from_user=fans.openid and fans.uid=member.uid and qmxk.flag = 0 and qmxk.uniacid = " . $_W['uniacid'] . " and qmxk.realname<>'' order by qmxk.id desc limit " . ($pindex - 1) * $psize . ',' . $psize); $total = pdo_fetchcolumn("select count(id) from" . tablename('wwx_fxxt_member') . "where flag = 0 and realname<>'' and uniacid =" . $_W['uniacid']); $pager = pagination($total, $pindex, $psize); include $this->template('fansmanager'); die; } if ($op == 'sort') { $pindex = max(1, intval($_GPC['page'])); $psize = 50; $condition = ''; $gpmobile = $_GPC['mobile']; $gprealname = $_GPC['realname']; $gpuserid = $_GPC['userid']; $gpflagid = $_GPC['flagid']; $gpThecharts = $_GPC['Thecharts']; $gpflaggrade = $_GPC['flaggrade']; $sql_member = "select count(order1.id) from " . tablename('wwx_fxxt_order') . " order1 where uniacid = '{$_W['uniacid']}' AND (order1.shareid = qmxk.id or order1.shareid2 = qmxk.id or order1.shareid3 = qmxk.id) "; $condition .= empty($_GPC['mobile']) ? '' : " AND qmxk.mobile LIKE '%" . trim($_GPC['mobile']) . "%'"; $condition .= empty($_GPC['realname']) ? '' : " AND ( qmxk.realname LIKE '%" . trim($_GPC['realname']) . "%' ) "; $condition .= empty($_GPC['userid']) ? '' : " AND qmxk.id = '" . trim($_GPC['userid']) . "'"; $condition .= empty($_GPC['flagid']) ? '' : " AND qmxk.shareid = '" . trim($_GPC['flagid']) . "'"; $condition .= empty($_GPC['Thecharts']) ? '' : " AND ((" . $sql_member . ")>0)"; $condition .= empty($_GPC['flaggrade']) ? '' : " AND qmxk.flaggrade = '" . trim($_GPC['flaggrade']) . "'"; if ($_GPC['opp'] == 'nocheck') { $status = 0; } else { $status = 1; } $flagexp = pdo_fetchall("select * from " . tablename('wwx_fxxt_member_flaggrade') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY displayorder ASC"); $list = pdo_fetchall("select qmxk.*,member.credit1 as credit1,member.credit2 as credit2 from " . tablename('wwx_fxxt_member') . " qmxk," . tablename('mc_mapping_fans') . " fans," . tablename('mc_members') . " member where qmxk.uniacid=fans.uniacid and qmxk.from_user=fans.openid and fans.uid=member.uid " . $condition . " and qmxk.flag = " . $status . " and qmxk.uniacid = " . $_W['uniacid'] . " order by qmxk.id desc limit " . ($pindex - 1) * $psize . ',' . $psize); $total = pdo_fetchcolumn("select count(qmxk.id) from " . tablename('wwx_fxxt_member') . " qmxk," . tablename('mc_mapping_fans') . " fans," . tablename('mc_members') . " member where qmxk.uniacid=fans.uniacid and qmxk.from_user=fans.openid and fans.uid=member.uid " . $condition . " and qmxk.flag = " . $status . " and qmxk.uniacid = " . $_W['uniacid']); $pager = pagination($total, $pindex, $psize); if ($_GPC['opp'] == 'nocheck') { include $this->template('fansmanager'); die; } } if ($op == 'user') { $from_user = $_GPC['from_user']; $fans = pdo_fetch("select b.nickname,b.createtime,b.credit1 from " . tablename('mc_mapping_fans') . " a, " . tablename('mc_members') . " b where a.openid=:openid and a.uniacid=:uniacid and a.uid=b.uid", array(':openid' => $from_user, ':uniacid' => $_W['uniacid'])); $myheadimg = pdo_fetchcolumn("select avatar from " . tablename('mc_mapping_fans') . " a, " . tablename('mc_members') . " b where a.openid=:openid and a.uniacid=:uniacid and a.uid=b.uid", array(':openid' => $from_user, ':uniacid' => $_W['uniacid'])); $fans['avatar'] = $myheadimg; $profile = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = :uniacid AND from_user = :from_user", array(':uniacid' => $_W['uniacid'], ':from_user' => $from_user)); if (!empty($profile['id'])) { $mylist = pdo_fetchall("select d.createtime createtime, d.nickname nickname, d.avatar avatar from " . tablename('wwx_fxxt_share_history') . " a," . tablename('mc_mapping_fans') . " b," . tablename('wwx_fxxt_member') . " c," . tablename('mc_members') . " d where a.from_user = b.openid and a.uniacid=b.uniacid and a.sharemid=c.id and a.from_user!=:leader and a.uniacid=:uniacid ", array(':leader' => $from_user, ':uniacid' => $_W['uniacid'])); $count = 0; if (true) { $sql1_member = "select mber1.from_user from " . tablename('wwx_fxxt_member') . " mber1 where mber1.realname<>'' and mber1.id!=mber1.shareid and mber1.shareid = " . $profile['id']; $count1 = pdo_fetchcolumn(" select count(*) from " . tablename('mc_mapping_fans') . " fans where openid!='{$from_user}' and (fans.openid in (" . $sql1_member . ")) and fans.uniacid={$_W['uniacid']}"); $mylist1 = pdo_fetchall(" select *,1 as level from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member where fans.openid!='{$from_user}' and (fans.openid in (" . $sql1_member . ") ) and fans.uid=member.uid and fans.uniacid=member.uniacid and fans.uniacid={$_W['uniacid']}"); } if (true && $cfg['globalCommissionLevel'] >= 2) { $level2 = pdo_fetchall("select id from " . tablename('wwx_fxxt_member') . " where id!=shareid and shareid = " . $profile['id']); $rowindex = 0; $str = ""; foreach ($level2 as &$citem) { $str = $str . $citem['id'] . ','; } $str = $str . '-1'; $sql2_member = "select mber2.from_user from " . tablename('wwx_fxxt_member') . " mber2 where mber2.realname<>'' and mber2.id!=mber2.shareid and mber2.shareid in (" . $str . ") "; $count2 = pdo_fetchcolumn(" select count(*) from " . tablename('mc_mapping_fans') . " fans where openid!='{$from_user}' and (fans.openid in (" . $sql2_member . ")) and (fans.openid not in (" . $sql1_member . ")) and fans.uniacid={$_W['uniacid']}"); $mylist2 = pdo_fetchall(" select *,2 as level from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member where fans.openid!='{$from_user}' and (fans.openid in (" . $sql2_member . ")) and fans.uid=member.uid and (fans.openid not in (" . $sql1_member . ")) and fans.uniacid={$_W['uniacid']}"); } if (true && $cfg['globalCommissionLevel'] >= 3) { $level3 = pdo_fetchall("select id from " . tablename('wwx_fxxt_member') . " where id!=shareid and shareid in( " . $str . ")"); $rowindex = 0; $str3 = ""; foreach ($level3 as &$citem) { $str3 = $str3 . $citem['id'] . ','; } $str3 = $str3 . '-1'; $sql3_member = "select mber3.from_user from " . tablename('wwx_fxxt_member') . " mber3 where mber3.realname<>'' and mber3.id!=mber3.shareid and mber3.shareid in (" . $str3 . ") "; $count3 = pdo_fetchcolumn(" select count(*) from " . tablename('mc_mapping_fans') . " fans where fans.openid!='{$from_user}' and (fans.openid in (" . $sql3_member . ")) and (fans.openid not in (" . $sql1_member . ")) and (fans.openid not in (" . $sql2_member . ")) and fans.uniacid={$_W['uniacid']}"); $mylist3 = pdo_fetchall(" select *,3 as level from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member where fans.openid!='{$from_user}' and (fans.openid in (" . $sql3_member . ")) and fans.uid=member.uid and (fans.openid not in (" . $sql1_member . ")) and (fans.openid not in (" . $sql2_member . ")) and fans.uniacid={$_W['uniacid']}"); } $count = $count1 + $count2 + $count3; } else { $count = 0; } if (!empty($_GPC['sharestatisticsEXP01'])) { $report = 'sharestatistics'; $list = array_merge($mylist1, $mylist2, $mylist3); if (empty($profile['id']) || empty($list)) { message('代理为空或者代理不存在!', referer(), 'error'); } foreach ($list as $id => $displayorder) { $fanslist = pdo_fetch("select * from " . tablename('wwx_fxxt_member') . " where uniacid=" . $_W['uniacid'] . " and from_user='{$displayorder['openid']}'"); $sharname = pdo_fetch('SELECT realname FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = :uniacid AND id = :id", array(':uniacid' => $_W['uniacid'], ':id' => $fanslist['shareid'])); $list[$id]['sharname'] = $sharname['realname']; $list[$id]['member'] = $fanslist; } require_once 'report.php'; die; } if (!empty($_GPC['shangpinstatisticsEXP01'])) { $report = 'shangpinstatistics'; if (!empty($_GPC['shangpinstatisticsEXP01'])) { $psize = 9999; $pindex = 1; } if (empty($profile['id'])) { message('代理为空或者代理不存在!', referer(), 'error'); } $list = pdo_fetchall('SELECT * FROM ' . tablename('wwx_fxxt_order') . " WHERE uniacid = '{$_W['uniacid']}' AND (shareid = '" . intval($profile['id']) . "' or shareid2 = '" . intval($profile['id']) . "' or shareid3 = '" . intval($profile['id']) . "') AND from_user<>'" . $profile['from_user'] . "' ORDER BY createtime DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize); if (!empty($list)) { foreach ($list as $key => $l) { $commissions = pdo_fetchall('select total,commission as commission, commission2 as commission2, commission3 as commission3 from ' . tablename('wwx_fxxt_order_goods') . ' where orderid = ' . $l['id']); foreach ($commissions as $commission) { $list[$key]['commission'] = $commission['commission'] * $commission['total']; $list[$key]['shareopen1'] = $this->getShareId($l['from_user']); if ($cfg['globalCommissionLevel'] >= 2) { $list[$key]['commission2'] = $commission['commission2'] * $commission['total']; $list[$key]['shareopen2'] = $this->getShareId($l['from_user'], 2); } else { $list[$key]['commission2'] = 0; $list[$key]['shareopen2'] = 0; } if ($cfg['globalCommissionLevel'] >= 3) { $list[$key]['commission3'] = $commission['commission3'] * $commission['total']; $list[$key]['shareopen3'] = $this->getShareId($l['from_user'], 3); } else { $list[$key]['commission3'] = 0; $list[$key]['shareopen3'] = 0; } } } } if (!empty($list)) { foreach ($list as &$row) { !empty($row['addressid']) && ($addressids[$row['addressid']] = $row['addressid']); $row['dispatch'] = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_dispatch') . " WHERE id = :id", array(':id' => $row['dispatch'])); } unset($row); } if (!empty($addressids)) { $address = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_address') . " WHERE id IN ('" . implode("','", $addressids) . "')", array(), 'id'); } require_once 'report.php'; die; } include $this->template('clicklog'); die; } if ($op == 'delete') { if (empty($_GPC['id'])) { message('请选择代理!', referer(), 'error'); } $member_open = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_member') . ' WHERE uniacid=:uniacid and id=:id', array(':uniacid' => $_W['uniacid'], ':id' => $_GPC['id'])); $member_fans = pdo_fetch("select fans.openid as from_user, member.* from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member where fans.uid = member.uid and fans.uniacid = member.uniacid and fans.uniacid = :uniacid AND fans.openid=:openid limit 1", array(':uniacid' => $_W['uniacid'], ':openid' => $member_open['from_user'])); if (empty($member_open['from_user'])) { message('没有此代理!', referer(), 'error'); } $member_order = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_order') . ' WHERE uniacid=:uniacid and status>0 and from_user=:from_user', array(':uniacid' => $_W['uniacid'], ':from_user' => $member_fans['from_user'])); if (!empty($member_order['id'])) { message('此代理已有订单信息,不能删除,请设置其权限即可!', referer(), 'error'); } pdo_delete('mc_members', array('uid' => $member_fans['uid'], 'uniacid' => $_W['uniacid'])); pdo_delete('mc_mapping_fans', array('uid' => $member_fans['uid'], 'uniacid' => $_W['uniacid'])); pdo_delete('wwx_fxxt_member', array('from_user' => $member_order['from_user'], 'uniacid' => $_W['uniacid'])); pdo_delete('wwx_fxxt_share_history', array('from_user' => $member_order['from_user'], 'uniacid' => $_W['uniacid'])); if ($_GPC['opp'] == 'nocheck') { message('代理删除成功!', $this->createWebUrl('fansmanager', array('op' => 'nocheck')), 'success'); } else { message('代理删除成功!', $this->createWebUrl('fansmanager'), 'success'); } } if ($op == 'detail') { $id = intval($_GPC['id']); $fromuser = $_GPC['from_user']; if (!empty($id)) { $user = pdo_fetch("select * from " . tablename('wwx_fxxt_member') . " where id = " . $id); } elseif (!empty($fromuser)) { $user = pdo_fetch("select * from " . tablename('wwx_fxxt_member') . " where from_user = '{$fromuser}'"); } if (empty($user['id'])) { message('用户信息不存在!', referer(), 'error'); } if (!empty($user['shareid'])) { $user1 = pdo_fetch("select * from " . tablename('wwx_fxxt_member') . " where flag=1 and id = " . $user['shareid']); } if (!empty($user1['shareid'])) { $user2 = pdo_fetch("select * from " . tablename('wwx_fxxt_member') . " where flag=1 and id = " . $user1['shareid']); } if (!empty($user2['shareid'])) { $user3 = pdo_fetch("select * from " . tablename('wwx_fxxt_member') . " where flag=1 and id = " . $user2['shareid']); } $userexp = pdo_fetchall("select * from " . tablename('wwx_fxxt_member_shipgrade') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY displayorder ASC"); $flagexp = pdo_fetchall("select * from " . tablename('wwx_fxxt_member_flaggrade') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY displayorder ASC"); if ($_GPC['opp'] == 'nocheck') { include $this->template('fansmanagered_detail'); die; } else { include $this->template('fansmanager_detail'); die; } } if ($op == 'status') { if (empty($_GPC['id'])) { message('参数非法!', $this->createWebUrl('fansmanager'), 'error'); } $status = array('status' => $_GPC['status'], 'flag' => $_GPC['flag'], 'usergrade' => $_GPC['usergrade'], 'usergradeauto' => $_GPC['usergradeauto'], 'flaggrade' => $_GPC['flaggrade'], 'flaggradeauto' => $_GPC['flaggradeauto'], 'content' => trim($_GPC['content'])); if (!empty($_GPC['usershareid'])) { $status['shareid'] = $_GPC['usershareid']; $shareuser = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = '{$_W['uniacid']}' AND id = '{$status['shareid']}'"); if (empty($shareuser['id'])) { message('没有此分销上级,请重新设置!', referer(), 'error'); } $seidmember = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = '{$_W['uniacid']}' AND id = '{$_GPC['id']}'"); $seidshare = pdo_fetch("SELECT sharemid FROM " . tablename('wwx_fxxt_share_history') . " WHERE from_user=:from_user and uniacid=:uniacid", array(':from_user' => $seidmember['from_user'], ':uniacid' => $_W['uniacid'])); $seiddata = array('uniacid' => $_W['uniacid'], 'from_user' => $seidmember['from_user'], 'sharemid' => $status['shareid'], 'joinway' => 0); if (empty($seidshare['sharemid'])) { pdo_insert('wwx_fxxt_share_history', $seiddata); } else { pdo_delete('wwx_fxxt_share_history', array('from_user' => $seidmember['from_user'], 'uniacid' => $_W['uniacid'])); pdo_insert('wwx_fxxt_share_history', $seiddata); } } if ($_GPC['opp'] == 'nocheck' && $_GPC['flag'] == 1) { $status['flagtime'] = TIMESTAMP; } pdo_update('wwx_fxxt_member', $status, array('id' => $_GPC['id'])); if ($_GPC['opp'] == 'nocheck') { message('设置用户成功!', $this->createWebUrl('fansmanager', array('op' => 'detail', 'opp' => 'nocheck', 'id' => $_GPC['id'])), 'success'); } else { message('设置用户成功!', $this->createWebUrl('fansmanager', array('op' => 'detail', 'id' => $_GPC['id'])), 'success'); } } if ($op == 'recharge') { $pindex = max(1, intval($_GPC['page'])); $psize = 20; $id = $_GPC['id']; $chargenum = round($_GPC['chargenum'], 2); if ($_GPC['opp'] == 'recharged') { if (!is_numeric($chargenum)) { message('佣金请输入合法数字!', '', 'error'); } if ($_GPC['realname'] == "") { $_GPC['realname'] = "未设置"; } if (strlen($_GPC['from_user']) < 10) { message('此用户不是微信端用户,不能使用微信打款!', $this->createWebUrl('fansmanager', array('op' => 'recharge', 'id' => $_GPC['id'])), 'error'); } $senduser = array('openid' => $_GPC['from_user'], 'fee' => $chargenum, 'realname' => $_GPC['realname'], 'desc' => '意虎补充付款', 'id' => $_GPC['id']); $wxret = $this->wxsend($senduser); if (is_error($wxret)) { message('微信打款失败:' . $wxret['message'], $this->createWebUrl('fansmanager', array('op' => 'recharge', 'id' => $_GPC['id'])), 'error'); } pdo_query('update ' . tablename('wwx_fxxt_member') . ' SET zhifu=zhifu+\'' . $chargenum . "' WHERE from_user='" . $_GPC['from_user'] . "' AND uniacid=" . $_W['uniacid'] . " "); $paylog = array('type' => 'zhifu', 'uniacid' => $_W['uniacid'], 'openid' => $_GPC['from_user'], 'tid' => date('Y-m-d H:i:s'), 'fee' => $chargenum, 'module' => 'wwx_fxxt', 'tag' => ' 后台微信补充打款' . $chargenum . '元,' . $_GPC['content'] . '!'); pdo_insert('core_paylog', $paylog); message('打款成功!', $this->createWebUrl('fansmanager', array('op' => 'recharge', 'id' => $_GPC['id'])), 'success'); } $user = pdo_fetch("select * from " . tablename('wwx_fxxt_member') . " where id = " . $id); $total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('core_paylog') . " WHERE openid='" . $user['from_user'] . "' AND type='zhifu' AND `uniacid` = " . $_W['uniacid']); $pager = pagination($total, $pindex, $psize); $list = pdo_fetchall("SELECT * FROM " . tablename('core_paylog') . " WHERE openid='" . $user['from_user'] . "' AND type='zhifu' AND uniacid=" . $_W['uniacid'] . " ORDER BY plid DESC LIMIT " . ($pindex - 1) * $psize . "," . $psize); include $this->template('fansmanager_recharge'); die; } include $this->template('fansmanager'); } public function doWebMemberflagGrade() { global $_W, $_GPC; if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $cfg = $this->module['config']; $uniacid = $_W['uniacid']; $op = $operation = $_GPC['op'] ? $_GPC['op'] : 'flagdisplay'; if ($operation == 'flagdisplay') { $children = array(); $list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_member_flaggrade') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY displayorder desc"); include $this->template('memberflaggrade'); } elseif ($operation == 'post') { $id = intval($_GPC['id']); $memberflag = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_member_flaggrade') . " WHERE id = '{$id}'"); if ($_GPC['submit'] == '提交') { if (empty($_GPC['flag_name'])) { message('抱歉,请输入等级名称!'); } $data = array('uniacid' => $_W['uniacid'], 'displayorder' => intval($_GPC['displayorder']), 'flag_name' => $_GPC['flag_name'], 'flag_commission1' => intval($_GPC['flag_commission1']), 'flag_commission2' => intval($_GPC['flag_commission2']), 'flag_commission3' => intval($_GPC['flag_commission3']), 'flag_money' => $_GPC['flag_money'], 'flag_totalmoney' => $_GPC['flag_totalmoney'], 'flag_count' => intval($_GPC['flag_count']), 'promoterstate' => $_GPC['promoterstate']); if (!empty($id)) { pdo_update('wwx_fxxt_member_flaggrade', $data, array('id' => $id, 'uniacid' => $_W['uniacid'])); } else { pdo_insert('wwx_fxxt_member_flaggrade', $data); $id = pdo_insertid(); } message('更新代理等级成功!', $this->createWebUrl('memberflaggrade', array('op' => 'flagdisplay')), 'success'); } include $this->template('memberflaggrade'); } elseif ($operation == 'delete') { $id = intval($_GPC['id']); $category = pdo_fetch("SELECT id FROM " . tablename('wwx_fxxt_member_flaggrade') . " WHERE id = '{$id}'"); if (empty($category)) { message('抱歉,代理等级不存在或是已经被删除!', $this->createWebUrl('memberflaggrade', array('op' => 'flagdisplay')), 'error'); } pdo_delete('wwx_fxxt_member_flaggrade', array('id' => $id, 'uniacid' => $_W['uniacid'])); message('代理等级删除成功!', $this->createWebUrl('memberflaggrade', array('op' => 'flagdisplay')), 'success'); } } public function doWebCommission() { global $_W, $_GPC; if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $cfg = $this->module['config']; $uniacid = $_W['uniacid']; $op = $operation = $_GPC['op'] ? $_GPC['op'] : 'display'; $members = pdo_fetchall("select id, realname, mobile from " . tablename('wwx_fxxt_member') . " where uniacid = " . $_W['uniacid'] . " and status = 1"); $member = array(); foreach ($members as $m) { $member['realname'][$m['id']] = $m['realname']; $member['mobile'][$m['id']] = $m['mobile']; } if ($op == 'display') { if ($_GPC['opp'] == 'check') { $level = $_GPC['level']; $zhifucommission = $cfg['zhifuCommission']; if (!$zhifucommission) { message('请先在参数设置,设置佣金打款限额!', $this->createWebUrl('Commission'), 'success'); } $shareid = $_GPC['shareid']; $user = pdo_fetch("select * from " . tablename('wwx_fxxt_member') . " where id = " . $_GPC['shareid']); if (empty($level)) { message('提交错误'); } if ($level == 1) { $status = 'og.status,'; $conditionCommission = 'og.commission*og.total as commissionsum'; } if ($level == 2) { $status = 'og.status2 as status,'; $conditionCommission = 'og.commission2*og.total as commissionsum'; } if ($level == 3) { $status = 'og.status3 as status,'; $conditionCommission = 'og.commission3*og.total as commissionsum'; } if (!empty($user['shareid'])) { $user2 = pdo_fetch("select * from " . tablename('wwx_fxxt_member') . " where flag=1 and id = " . $user['shareid']); } if (!empty($user2['shareid'])) { $user3 = pdo_fetch("select * from " . tablename('wwx_fxxt_member') . " where flag=1 and id = " . $user2['shareid']); } $info = pdo_fetch("select og.id,og.orderid,og.total,og.price," . $status . $conditionCommission . ", og.commission, og.commission2,og.commission3,og.applytime,og.content,g.title from " . tablename('wwx_fxxt_order_goods') . " as og left join " . tablename('wwx_fxxt_goods') . " as g on og.goodsid = g.id and og.uniacid = g.uniacid where og.id = " . $_GPC['id']); $order = pdo_fetch("select * from " . tablename('wwx_fxxt_order') . " where id = " . $info['orderid']); include $this->template('applying_detail'); die; } if ($_GPC['opp'] == 'autocheck') { $zhifucommission = $cfg['zhifuCommission']; if (!$zhifucommission) { message('请先在参数设置,设置佣金打款限额!', $this->createWebUrl('Commission'), 'success'); } $shareid = $_GPC['shareid']; $user = pdo_fetch("select * from " . tablename('wwx_fxxt_member') . " where id = " . $_GPC['shareid']); $list = pdo_fetchall("select 1 as level,o.shareid,o.status,g.id,g.applytime,g.commission*g.total as commission,g.checktime as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status = 1) and (o.shareid in (" . $shareid . ")) union all (select 2 as level,o.shareid2 as shareid, o.status, g.id, g.applytime2 as applytime,g.commission2*g.total as commission,g.checktime2 as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status2 = 1) and (o.shareid2 in (" . $shareid . "))) union all (select 3 as level,o.shareid3 as shareid, o.status, g.id, g.applytime3 as applytime,g.commission3*g.total as commission,g.checktime3 as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status3 = 1) and (o.shareid3 in (" . $shareid . "))) order by applytime desc"); $total = sizeof($list); $commissionsum = 0; foreach ($list as $k => $array) { if ($array['commission'] > 0) { $commissionsum += $array['commission']; } } include $this->template('applying_autodetail'); die; } if ($_GPC['opp'] == 'autochecked') { $shareid = $_GPC['shareid']; $list = pdo_fetchall("select 1 as level,o.shareid,o.status,g.id,g.applytime,g.commission*g.total as commission,g.checktime as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status = 1) and (o.shareid in (" . $shareid . ")) union all (select 2 as level,o.shareid2 as shareid, o.status, g.id, g.applytime2 as applytime,g.commission2*g.total as commission,g.checktime2 as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status2 = 1) and (o.shareid2 in (" . $shareid . "))) union all (select 3 as level,o.shareid3 as shareid, o.status, g.id, g.applytime3 as applytime,g.commission3*g.total as commission,g.checktime3 as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status3 = 1) and (o.shareid3 in (" . $shareid . "))) order by applytime desc"); if ($_GPC['status'] >= 2) { if ($_GPC['commission'] > 0) { if ($_GPC['status'] == 2) { $checkbak = "银行打款"; } if ($_GPC['status'] == 3) { $checkbak = "支付宝打款"; } if ($_GPC['status'] == 4) { $checkbak = "微信打款"; } $commissionmem = pdo_fetch("select from_user,commission,realname from " . tablename('wwx_fxxt_member') . " where id = " . $shareid); if ($_GPC['status'] == 4) { if (strlen($commissionmem['from_user']) < 10) { message('此用户不是微信端用户,不能使用微信打款!', $this->createWebUrl('commission', array('opp' => 'autocheck', 'shareid' => $_GPC['shareid'])), 'error'); } if ($commissionmem['realname'] == "") { $commissionmem['realname'] = "未设置"; } $senduser = array('openid' => $commissionmem['from_user'], 'fee' => $_GPC['commission'], 'realname' => $commissionmem['realname'], 'desc' => '意虎统一付款', 'id' => $shareid); $wxret = $this->wxsend($senduser); if (is_error($wxret)) { message('微信打款失败:' . $wxret['message'], $this->createWebUrl('commission', array('opp' => 'autocheck', 'shareid' => $_GPC['shareid'])), 'error'); } } foreach ($list as $k => $array) { if ($array['level'] == 1) { $checked = array('status' => $_GPC['status'], 'checktime' => time()); } if ($array['level'] == 2) { $checked = array('status2' => $_GPC['status'], 'checktime2' => time()); } if ($array['level'] == 3) { $checked = array('status3' => $_GPC['status'], 'checktime3' => time()); } $ogid = $array['id']; pdo_update('wwx_fxxt_member', array('commission' => $commissionmem['commission'] + $array['commission']), array('id' => $shareid)); pdo_query('update ' . tablename('wwx_fxxt_member') . ' SET zhifu=zhifu+\'' . $array['commission'] . "' WHERE id='" . $shareid . "' AND uniacid=" . $_W['uniacid'] . " "); $paylog = array('type' => 'zhifu', 'uniacid' => $_W['uniacid'], 'openid' => $commissionmem['from_user'], 'tid' => date('Y-m-d H:i:s'), 'fee' => $array['commission'], 'module' => 'wwx_fxxt', 'tag' => ' 后台' . $checkbak . ':' . $_GPC['commission'] . '元【' . $array['level'] . '级会员佣金】'); pdo_insert('core_paylog', $paylog); $temp = pdo_update('wwx_fxxt_order_goods', $checked, array('id' => $ogid)); } $this->sendsjytktz($_GPC['commission'], "全部分佣订单", $commissionmem['from_user']); } message('打款完成!', $this->createWebUrl('commission'), 'success'); } foreach ($list as $k => $array) { if ($array['level'] == 1) { $checked = array('status' => $_GPC['status'], 'checktime' => time()); } if ($array['level'] == 2) { $checked = array('status2' => $_GPC['status'], 'checktime2' => time()); } if ($array['level'] == 3) { $checked = array('status3' => $_GPC['status'], 'checktime3' => time()); } $ogid = $array['id']; $temp = pdo_update('wwx_fxxt_order_goods', $checked, array('id' => $ogid)); } if (empty($temp)) { message('审核失败,请重新审核!', $this->createWebUrl('commission', array('opp' => 'autocheck', 'shareid' => $_GPC['shareid'])), 'error'); } else { message('审核成功!', $this->createWebUrl('commission'), 'success'); } } if ($_GPC['opp'] == 'checked') { $level = $_GPC['level']; if (empty($level)) { message('提交错误'); } if ($level == 1) { $checked = array('status' => $_GPC['status'], 'checktime' => time()); } if ($level == 2) { $checked = array('status2' => $_GPC['status'], 'checktime2' => time()); } if ($level == 3) { $checked = array('status3' => $_GPC['status'], 'checktime3' => time()); } if ($_GPC['status'] >= 2) { $shareid = $_GPC['shareid']; $ogid = $_GPC['id']; if ($_GPC['commission'] > 0) { if ($_GPC['status'] == 2) { $checkbak = "银行打款"; } if ($_GPC['status'] == 3) { $checkbak = "支付宝打款"; } if ($_GPC['status'] == 4) { $checkbak = "微信打款"; } $commissionmem = pdo_fetch("select from_user,commission,realname from " . tablename('wwx_fxxt_member') . " where id = " . $shareid); if ($_GPC['status'] == 4) { if (strlen($commissionmem['from_user']) < 10) { message('此用户不是微信端用户,不能使用微信打款!', $this->createWebUrl('commission', array('opp' => 'check', 'shareid' => $_GPC['shareid'], 'id' => $_GPC['id'])), 'error'); } if ($commissionmem['realname'] == "") { $commissionmem['realname'] = "未设置"; } $senduser = array('openid' => $commissionmem['from_user'], 'fee' => $_GPC['commission'], 'realname' => $commissionmem['realname'], 'desc' => '意虎付款', 'id' => $_GPC['id']); $wxret = $this->wxsend($senduser); if (is_error($wxret)) { message('微信打款失败:' . $wxret['message'], $this->createWebUrl('commission', array('opp' => 'check', 'shareid' => $_GPC['shareid'], 'id' => $_GPC['id'], 'level' => $level)), 'error'); } } pdo_update('wwx_fxxt_member', array('commission' => $commissionmem['commission'] + $_GPC['commission']), array('id' => $shareid)); pdo_query('update ' . tablename('wwx_fxxt_member') . ' SET zhifu=zhifu+\'' . $_GPC['commission'] . "' WHERE id='" . $shareid . "' AND uniacid=" . $_W['uniacid'] . " "); $paylog = array('type' => 'zhifu', 'uniacid' => $_W['uniacid'], 'openid' => $commissionmem['from_user'], 'tid' => date('Y-m-d H:i:s'), 'fee' => $_GPC['commission'], 'module' => 'wwx_fxxt', 'tag' => ' 后台' . $checkbak . ':' . $_GPC['commission'] . '元【' . $level . '级会员佣金】'); pdo_insert('core_paylog', $paylog); $temp = pdo_update('wwx_fxxt_order_goods', $checked, array('id' => $_GPC['id'])); $this->sendsjytktz($_GPC['commission'], $level, $commissionmem['from_user']); } message('打款完成!', $this->createWebUrl('commission'), 'success'); } $temp = pdo_update('wwx_fxxt_order_goods', $checked, array('id' => $_GPC['id'])); if (empty($temp)) { message('审核失败,请重新审核!', $this->createWebUrl('commission', array('opp' => 'check', 'shareid' => $_GPC['shareid'], 'id' => $_GPC['id'], 'level' => $level)), 'error'); } else { message('审核成功!', $this->createWebUrl('commission'), 'success'); } } if ($_GPC['opp'] == 'sort') { $sort = array('realname' => $_GPC['realname'], 'mobile' => $_GPC['mobile']); $shareid = "select id from " . tablename('wwx_fxxt_member') . " where uniacid = " . $_W['uniacid'] . " and realname like '%" . $sort['realname'] . "%' and mobile like '%" . $sort['mobile'] . "%'"; $list = pdo_fetchall("select 1 as level,o.shareid,o.status,g.id,g.applytime,g.commission*g.total as commission,g.checktime as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status = 1) and (o.shareid in (" . $shareid . ")) union all (select 2 as level,o.shareid2 as shareid, o.status, g.id, g.applytime2 as applytime,g.commission2*g.total as commission,g.checktime2 as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status2 = 1) and (o.shareid2 in (" . $shareid . "))) union all (select 3 as level,o.shareid3 as shareid, o.status, g.id, g.applytime3 as applytime,g.commission3*g.total as commission,g.checktime3 as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status3 = 1) and (o.shareid3 in (" . $shareid . "))) order by applytime desc"); $total = sizeof($list); } else { $pindex = max(1, intval($_GPC['page'])); $psize = 50; $list = pdo_fetchall("select 1 as level,o.shareid,o.status,g.id,g.applytime,g.commission*g.total as commission,g.checktime as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status = 1 and o.shareid!=0) " . " union all (select 2 as level,o.shareid2 as shareid,o.status, g.id, g.applytime2 as applytime,g.commission2*g.total as commission,g.checktime2 as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status2 = 1 and o.shareid2!=0) )" . " union all (select 3 as level,o.shareid3 as shareid,o.status, g.id, g.applytime3 as applytime,g.commission3*g.total as commission,g.checktime3 as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status3 = 1 and o.shareid3!=0) ) order by applytime desc limit " . ($pindex - 1) * $psize . "," . $psize); $total = pdo_fetchcolumn('select count(o.id) from ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = ' . $_W['uniacid'] . ' and (o.shareid!=0 ) and (g.status = 1 )'); $total2 = pdo_fetchcolumn('select count(o.id) from ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = ' . $_W['uniacid'] . ' and (o.shareid2!=0 ) and (g.status2 = 1 )'); $total3 = pdo_fetchcolumn('select count(o.id) from ' . tablename('wwx_fxxt_order') . ' as o left join ' . tablename('wwx_fxxt_order_goods') . ' as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = ' . $_W['uniacid'] . ' and (o.shareid3!=0 ) and (g.status3 = 1 )'); $total = $total + $total2 + $total3; $pager = pagination($total, $pindex, $psize); } if (!empty($list)) { foreach ($list as $key => $l) { $user = pdo_fetch("select id,shareid from " . tablename('wwx_fxxt_member') . " where flag=1 and id = " . $l['shareid']); if (empty($user['id'])) { $list[$key]['commission'] = 0; $list[$key]['commission2'] = 0; $list[$key]['commission3'] = 0; } else { $user2 = pdo_fetch("select id,shareid from " . tablename('wwx_fxxt_member') . " where flag=1 and id = " . $user['shareid']); if (empty($user2['id'])) { $list[$key]['commission2'] = 0; $list[$key]['commission3'] = 0; } else { $user3 = pdo_fetch("select id from " . tablename('wwx_fxxt_member') . " where flag=1 and id = " . $user2['shareid']); if (empty($user3['id'])) { $list[$key]['commission3'] = 0; } } } } } include $this->template('applying'); die; } if ($op == 'applyed') { if ($_GPC['opp'] == 'jieyong') { $shareid = $_GPC['shareid']; $user = pdo_fetch("select * from " . tablename('wwx_fxxt_member') . " where id = " . $_GPC['shareid']); $level = $_GPC['level']; if (empty($level)) { message('提交错误'); } if ($level == 1) { $status = 'og.status,'; $conditionCommission = '(og.commission*og.total) as commissionsum'; } if ($level == 2) { $status = 'og.status2 as status,'; $conditionCommission = '(og.commission2*og.total) as commissionsum'; } if ($level == 3) { $status = 'og.status3 as status,'; $conditionCommission = '(og.commission3*og.total) as commissionsum'; } if (!empty($user['shareid'])) { $user2 = pdo_fetch("select * from " . tablename('wwx_fxxt_member') . " where flag=1 and id = " . $user['shareid']); } if (!empty($user2['shareid'])) { $user3 = pdo_fetch("select * from " . tablename('wwx_fxxt_member') . " where flag=1 and id = " . $user2['shareid']); } $info = pdo_fetch("select og.id,og.orderid,og.total,og.price," . $status . $conditionCommission . ", og.commission, og.commission2,og.commission3,og.applytime,og.content,g.title from " . tablename('wwx_fxxt_order_goods') . " as og left join " . tablename('wwx_fxxt_goods') . " as g on og.goodsid = g.id and og.uniacid = g.uniacid where og.id = " . $_GPC['id']); $order = pdo_fetch("select * from " . tablename('wwx_fxxt_order') . " where id = " . $info['orderid']); include $this->template('applyed_detail'); die; } if ($_GPC['opp'] == 'sort') { $sort = array('realname' => $_GPC['realname'], 'mobile' => $_GPC['mobile']); $shareid = "select id from " . tablename('wwx_fxxt_member') . " where uniacid = " . $_W['uniacid'] . " and realname like '%" . $sort['realname'] . "%' and mobile like '%" . $sort['mobile'] . "%'"; $list = pdo_fetchall("select 1 as level,o.shareid,o.status,g.id,g.applytime,g.commission*g.total as commission,g.checktime as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status >= 2) and (o.shareid in (" . $shareid . ")) union all (select 2 as level,o.shareid2 as shareid, o.status, g.id, g.applytime2 as applytime,g.commission2*g.total as commission,g.checktime2 as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status2 >= 2) and (o.shareid2 in (" . $shareid . "))) union all (select 3 as level,o.shareid3 as shareid, o.status, g.id, g.applytime3 as applytime,g.commission3*g.total as commission,g.checktime3 as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status3 >= 2) and (o.shareid3 in (" . $shareid . "))) order by applytime desc "); $total = sizeof($list); } else { $pindex = max(1, intval($_GPC['page'])); $psize = 50; $list = pdo_fetchall("select 1 as level,o.shareid,o.status,g.id,g.applytime,g.commission*g.total as commission,g.checktime as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status >= 2 and o.shareid!=0) union all (select 2 as level,o.shareid2 as shareid,o.status,g.id,g.applytime2 as applytime,g.commission2*g.total as commission,g.checktime2 as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status2 >= 2 and o.shareid2!=0) )union all (select 3 as level,o.shareid3 as shareid,o.status,g.id,g.applytime3 as applytime,g.commission3*g.total as commission,g.checktime3 as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status3 >= 2 and o.shareid3!=0) ) order by applytime desc limit " . ($pindex - 1) * $psize . "," . $psize); $total = pdo_fetchcolumn("select count(o.id) from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (o.shareid!=0 ) and (g.status = 2 )"); $total2 = pdo_fetchcolumn("select count(o.id) from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (o.shareid2!=0 ) and (g.status2 = 2 )"); $total3 = pdo_fetchcolumn("select count(o.id) from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (o.shareid3!=0 ) and (g.status3 = 2 )"); $total = $total + $total2 + $total3; $pager = pagination($total, $pindex, $psize); } if (!empty($list)) { foreach ($list as $key => $l) { $user = pdo_fetch("select id,shareid from " . tablename('wwx_fxxt_member') . " where flag=1 and id = " . $l['shareid']); if (empty($user['id'])) { $list[$key]['commission'] = 0; $list[$key]['commission2'] = 0; $list[$key]['commission3'] = 0; } else { $user2 = pdo_fetch("select id,shareid from " . tablename('wwx_fxxt_member') . " where flag=1 and id = " . $user['shareid']); if (empty($user2['id'])) { $list[$key]['commission2'] = 0; $list[$key]['commission3'] = 0; } else { $user3 = pdo_fetch("select id from " . tablename('wwx_fxxt_member') . " where flag=1 and id = " . $user2['shareid']); if (empty($user3['id'])) { $list[$key]['commission3'] = 0; } } } } } include $this->template('applyed'); die; } if ($op == 'invalid') { if ($_GPC['opp'] == 'delete') { $level = $_GPC['level']; if (empty($level)) { message('提交错误'); } if ($level == 1) { $delete = array('status' => -2, 'checktime' => time()); } if ($level == 2) { $delete = array('status2' => -2, 'checktime2' => time()); } if ($level == 3) { $delete = array('status3' => -2, 'checktime3' => time()); } $temp = pdo_update('wwx_fxxt_order_goods', $delete, array('id' => $_GPC['id'])); if (empty($temp)) { message('删除失败,请重新删除!', $this->createWebUrl('commission', array('op' => 'invalid')), 'error'); } else { message('删除成功!', $this->createWebUrl('commission', array('op' => 'invalid')), 'success'); } } if ($_GPC['opp'] == 'sort') { $sort = array('realname' => $_GPC['realname'], 'mobile' => $_GPC['mobile']); $shareid = "select id from " . tablename('wwx_fxxt_member') . " where uniacid = " . $_W['uniacid'] . " and realname like '%" . $sort['realname'] . "%' and mobile like '%" . $sort['mobile'] . "%'"; $list = pdo_fetchall("select 1 as level,o.shareid, o.status, g.id, g.applytime,g.commission*g.total as commission,g.checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status = -1) and (o.shareid in (" . $shareid . ")) union all (select 2 as level,o.shareid2 as shareid, o.status, g.id, g.applytime2 as applytime,g.commission2*g.total as commission,g.checktime2 as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status2 = -1) and (o.shareid2 in (" . $shareid . "))) union all (select 3 as level,o.shareid3 as shareid, o.status, g.id, g.applytime3 as applytime,g.commission3*g.total as commission,g.checktime3 as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status3 = -1) and (o.shareid3 in (" . $shareid . "))) order by applytime desc "); $total = sizeof($list); } else { $pindex = max(1, intval($_GPC['page'])); $psize = 50; $list = pdo_fetchall("select 1 as level,o.shareid,o.status, g.id, g.applytime,g.commission*g.total as commission,g.checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status = -1 and o.shareid!=0) union all (select 2 as level,o.shareid2 as shareid,o.status, g.id, g.applytime2 as applytime,g.commission2*g.total as commission,g.checktime2 as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status2 = -1 and o.shareid2!=0) )union all (select 3 as level,o.shareid3 as shareid,o.status, g.id, g.applytime3 as applytime,g.commission3*g.total as commission,g.checktime3 as checktime from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (g.status3 = -1 and o.shareid3!=0) ) order by applytime desc limit " . ($pindex - 1) * $psize . "," . $psize); $total = pdo_fetchcolumn("select count(o.id) from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (o.shareid!=0 ) and (g.status = -1 )"); $total2 = pdo_fetchcolumn("select count(o.id) from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (o.shareid2!=0 ) and (g.status2 = -1 )"); $total3 = pdo_fetchcolumn("select count(o.id) from " . tablename('wwx_fxxt_order') . " as o left join " . tablename('wwx_fxxt_order_goods') . " as g on o.id = g.orderid and o.uniacid = g.uniacid where o.uniacid = " . $_W['uniacid'] . " and (o.shareid3!=0 ) and (g.status3 = -1 )"); $total = $total + $total2 + $total3; $pager = pagination($total, $pindex, $psize); } include $this->template('invalid'); die; } } public function doWebZhifu() { global $_GPC, $_W; if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $pindex = max(1, intval($_GPC['page'])); $psize = 50; $uniacid = $_W['uniacid']; $from_user = $_GPC['from_user']; $op = trim($_GPC['op']) ? trim($_GPC['op']) : 'list'; $cfg = $this->module['config']; $zhifucommission = $cfg['zhifuCommission']; if (!$zhifucommission) { message('请先在参数设置,设置佣金打款限额!', $this->createWebUrl('Commission'), 'success'); } if (empty($_GPC['mobile'])) { $mobile = ""; } else { $mobile = $_GPC['mobile']; } if ($op == 'list') { if ($_GPC['submit'] == '搜  索') { $sort = array('realname' => $_GPC['realname'], 'mobile' => $_GPC['mobile']); $list = pdo_fetchall("select * from " . tablename('wwx_fxxt_member') . " where mobile like '%" . $sort['mobile'] . "%' and realname like '%" . $sort['realname'] . "%' and status = 1 and flag = 1 and uniacid = " . $_W['uniacid'] . " order by commission desc"); $total = count($list); $pager = pagination($total, $pindex, $psize); include $this->template('zhifu'); die; } $total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('wwx_fxxt_member') . " WHERE status = 1 and flag = 1 AND `uniacid` = :uniacid", array(':uniacid' => $_W['uniacid'])); $pager = pagination($total, $pindex, $psize); $list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_member') . " WHERE uniacid=" . $_W['uniacid'] . " AND status = 1 and flag = 1 ORDER BY commission DESC LIMIT " . ($pindex - 1) * $psize . "," . $psize); include $this->template('zhifu'); } if ($op == 'post') { if (empty($_GPC['from_user'])) { message('请选择会员!', create_url('site/entry', array('do' => 'zhifu', 'op' => 'list', 'm' => 'wwx_fxxt', 'uniacid' => $_W['uniacid'])), 'success'); } if (checksubmit()) { $chargenum = round($_GPC['chargenum'], 2); if (strlen($_GPC['from_user']) < 10) { message('此用户不是微信端用户,不能使用微信打款!', $this->createWebUrl('zhifu', array('op' => 'post', 'm' => $wwx_fxxt, 'uniacid' => $_W['uniacid'], 'from_user' => $_GPC['from_user'])), 'error'); } if ($_GPC['realname'] == "") { $_GPC['realname'] = "未设置"; } $senduser = array('openid' => $_GPC['from_user'], 'fee' => $chargenum, 'realname' => $_GPC['realname'], 'desc' => '意虎补充付款', 'id' => $_GPC['id']); $wxret = $this->wxsend($senduser); if (is_error($wxret)) { message('微信打款失败:' . $wxret['message'], $this->createWebUrl('zhifu', array('op' => 'post', 'm' => $wwx_fxxt, 'uniacid' => $_W['uniacid'], 'from_user' => $_GPC['from_user'])), 'error'); } pdo_query('update ' . tablename('wwx_fxxt_member') . ' SET zhifu=zhifu+\'' . $chargenum . "' WHERE from_user='" . $_GPC['from_user'] . "' AND uniacid=" . $_W['uniacid'] . " "); $paylog = array('type' => 'zhifu', 'uniacid' => $uniacid, 'openid' => $_GPC['from_user'], 'tid' => date('Y-m-d H:i:s'), 'fee' => $chargenum, 'module' => 'wwx_fxxt', 'tag' => ' 后台微信补充打款' . $chargenum . '元,' . $_GPC['content'] . '!'); pdo_insert('core_paylog', $paylog); message('打款成功!', referer(), 'success'); } $from_user = $_GPC['from_user']; $profile = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = :uniacid AND from_user = :from_user", array(':uniacid' => $_W['uniacid'], ':from_user' => $from_user)); if (!$profile) { message('请选择会员!', create_url('site/entry', array('do' => 'zhifu', 'op' => 'list', 'm' => 'wwx_fxxt', 'uniacid' => $_W['uniacid'])), 'success'); } $total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('core_paylog') . " WHERE openid='" . $_GPC['from_user'] . "' AND type='zhifu' AND `uniacid` = " . $_W['uniacid']); $pager = pagination($total, $pindex, $psize); $list = pdo_fetchall("SELECT * FROM " . tablename('core_paylog') . " WHERE openid='" . $_GPC['from_user'] . "' AND type='zhifu' AND uniacid=" . $_W['uniacid'] . " ORDER BY plid DESC LIMIT " . ($pindex - 1) * $psize . "," . $psize); $mlist = pdo_fetchall("SELECT `name`,`title` FROM " . tablename('modules')); $mtype = array(); foreach ($mlist as $k => $v) { $mtype[$v['name']] = $v['title']; } include $this->template('zhifu_post'); } } public function doWebGoods() { global $_GPC, $_W; load()->func('tpl'); load()->func('file'); if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $cfg = $this->module['config']; $category = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_category') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY parentid ASC, displayorder DESC", array(), 'id'); if (!empty($category)) { $children = ''; foreach ($category as $cid => $cate) { if (!empty($cate['parentid'])) { $children[$cate['parentid']][$cate['id']] = array($cate['id'], $cate['name']); } } } $operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display'; if ($operation == 'post') { $id = intval($_GPC['id']); if (!empty($id)) { $item = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_goods') . " WHERE id = :id", array(':id' => $id)); if (empty($item)) { message('抱歉,商品不存在或是已经删除!', '', 'error'); } $allspecs = pdo_fetchall("select * from " . tablename('wwx_fxxt_spec') . " where goodsid=:id order by displayorder asc", array(":id" => $id)); foreach ($allspecs as &$s) { $s['items'] = pdo_fetchall("select * from " . tablename('wwx_fxxt_spec_item') . " where specid=:specid order by displayorder asc", array(":specid" => $s['id'])); } unset($s); $params = pdo_fetchall("select * from " . tablename('wwx_fxxt_goods_param') . " where goodsid=:id order by displayorder asc", array(':id' => $id)); $piclist = unserialize($item['thumb_url']); $html = ""; $options = pdo_fetchall("select * from " . tablename('wwx_fxxt_goods_option') . " where goodsid=:id order by id asc", array(':id' => $id)); $specs = array(); if (count($options) > 0) { $specitemids = explode("_", $options[0]['specs']); foreach ($specitemids as $itemid) { foreach ($allspecs as $ss) { $items = $ss['items']; foreach ($items as $it) { if ($it['id'] == $itemid) { $specs[] = $ss; break; } } } } $html = ''; $html .= ''; $html .= ''; $html .= ''; $len = count($specs); $newlen = 1; $h = array(); $rowspans = array(); for ($i = 0; $i < $len; $i++) { $html .= ""; $itemlen = count($specs[$i]['items']); if ($itemlen <= 0) { $itemlen = 1; } $newlen *= $itemlen; $h = array(); for ($j = 0; $j < $newlen; $j++) { $h[$i][$j] = array(); } $l = count($specs[$i]['items']); $rowspans[$i] = 1; for ($j = $i + 1; $j < $len; $j++) { $rowspans[$i] *= count($specs[$j]['items']); } } $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; for ($m = 0; $m < $len; $m++) { $k = 0; $kid = 0; $n = 0; for ($j = 0; $j < $newlen; $j++) { $rowspan = $rowspans[$m]; if ($j % $rowspan == 0) { $h[$m][$j] = array("html" => "", "id" => $specs[$m]['items'][$kid]['id']); } else { $h[$m][$j] = array("html" => "", "id" => $specs[$m]['items'][$kid]['id']); } $n++; if ($n == $rowspan) { $kid++; if ($kid > count($specs[$m]['items']) - 1) { $kid = 0; } $n = 0; } } } $hh = ""; for ($i = 0; $i < $newlen; $i++) { $hh .= ""; $ids = array(); for ($j = 0; $j < $len; $j++) { $hh .= $h[$j][$i]['html']; $ids[] = $h[$j][$i]['id']; } $ids = implode("_", $ids); $val = array("id" => "", "title" => "", "stock" => "", "costprice" => "", "productprice" => "", "marketprice" => "", "weight" => ""); foreach ($options as $o) { if ($ids === $o['specs']) { $val = array("id" => $o['id'], "title" => $o['title'], "stock" => $o['stock'], "costprice" => $o['costprice'], "productprice" => $o['productprice'], "marketprice" => $o['marketprice'], "weight" => $o['weight']); break; } } $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; } $html .= $hh; $html .= "
" . $specs[$i]['title'] . "
库存
销售价格
市场价格
成本价格
重量(克)
" . $specs[$m]['items'][$kid]['title'] . "
'; $hh .= '
"; } } if (empty($category)) { message('抱歉,请您先添加商品分类!', $this->createWebUrl('category', array('op' => 'post')), 'error'); } if (checksubmit('submit')) { if (empty($_GPC['goodsname'])) { message('请输入商品名称!'); } if (empty($_GPC['pcate'])) { message('请选择商品分类!'); } if (empty($_GPC['thumbs'])) { $_GPC['thumbs'] = array(); } $data = array('uniacid' => intval($_W['uniacid']), 'displayorder' => intval($_GPC['displayorder']), 'title' => $_GPC['goodsname'], 'pcate' => intval($_GPC['pcate']), 'ccate' => intval($_GPC['ccate']), 'thumb' => $_GPC['thumb'], 'type' => intval($_GPC['type']), 'isrecommand' => intval($_GPC['isrecommand']), 'ishot' => intval($_GPC['ishot']), 'isnew' => intval($_GPC['isnew']), 'isdiscount' => intval($_GPC['isdiscount']), 'istime' => intval($_GPC['istime']), 'issendfree' => intval($_GPC['issendfree']), 'timestart' => strtotime($_GPC['timestart']), 'timeend' => strtotime($_GPC['timeend']), 'description' => $_GPC['description'], 'content' => htmlspecialchars_decode($_GPC['content']), 'goodssn' => $_GPC['goodssn'], 'unit' => $_GPC['unit'], 'createtime' => TIMESTAMP, 'total' => intval($_GPC['total']), 'totalcnf' => intval($_GPC['totalcnf']), 'marketprice' => $_GPC['marketprice'], 'weight' => $_GPC['weight'], 'costprice' => $_GPC['costprice'], 'productprice' => $_GPC['productprice'], 'productsn' => $_GPC['productsn'], 'credit' => intval($_GPC['credit']), 'maxbuy' => intval($_GPC['maxbuy']),'usermaxbuy'=>intval($_GPC['usermaxbuy']), 'commission' => intval($_GPC['commission']), 'commission2' => intval($_GPC['commission2']), 'commission3' => intval($_GPC['commission3']), 'hasoption' => intval($_GPC['hasoption']), 'sales' => intval($_GPC['sales']), 'status' => intval($_GPC['status']), 'xsthumb' => $_GPC['xsthumb']); if (is_array($_GPC['thumbs'])) { $data['thumb_url'] = serialize($_GPC['thumbs']); } if (empty($id)) { pdo_insert('wwx_fxxt_goods', $data); $id = pdo_insertid(); } else { unset($data['createtime']); pdo_update('wwx_fxxt_goods', $data, array('id' => $id)); } $totalstocks = 0; $param_ids = $_POST['param_id']; $param_titles = $_POST['param_title']; $param_values = $_POST['param_value']; $param_displayorders = $_POST['param_displayorder']; $len = count($param_ids); $paramids = array(); for ($k = 0; $k < $len; $k++) { $param_id = ""; $get_param_id = $param_ids[$k]; $a = array("title" => $param_titles[$k], "value" => $param_values[$k], "displayorder" => $k, "goodsid" => $id); if (!is_numeric($get_param_id)) { pdo_insert("wwx_fxxt_goods_param", $a); $param_id = pdo_insertid(); } else { pdo_update('wwx_fxxt_goods_param', $a, array('id' => $get_param_id)); $param_id = $get_param_id; } $paramids[] = $param_id; } if (count($paramids) > 0) { pdo_query("delete from " . tablename('wwx_fxxt_goods_param') . " where goodsid={$id} and id not in ( " . implode(',', $paramids) . ")"); } else { pdo_query('delete from ' . tablename('wwx_fxxt_goods_param') . " where goodsid={$id}"); } $files = $_FILES; $spec_ids = $_POST['spec_id']; $spec_titles = $_POST['spec_title']; $specids = array(); $len = count($spec_ids); $specids = array(); $spec_items = array(); for ($k = 0; $k < $len; $k++) { $spec_id = ""; $get_spec_id = $spec_ids[$k]; $a = array("uniacid" => $_W['uniacid'], "goodsid" => $id, "displayorder" => $k, "title" => $spec_titles[$get_spec_id]); if (is_numeric($get_spec_id)) { pdo_update("wwx_fxxt_spec", $a, array("id" => $get_spec_id)); $spec_id = $get_spec_id; } else { pdo_insert('wwx_fxxt_spec', $a); $spec_id = pdo_insertid(); } $spec_item_ids = $_POST["spec_item_id_" . $get_spec_id]; $spec_item_titles = $_POST["spec_item_title_" . $get_spec_id]; $spec_item_shows = $_POST["spec_item_show_" . $get_spec_id]; $spec_item_thumbs = $_POST["spec_item_thumb_" . $get_spec_id]; $spec_item_oldthumbs = $_POST["spec_item_oldthumb_" . $get_spec_id]; $itemlen = count($spec_item_ids); $itemids = array(); for ($n = 0; $n < $itemlen; $n++) { $item_id = ""; $get_item_id = $spec_item_ids[$n]; $d = array("uniacid" => $_W['uniacid'], "goodsid" => $id, "specid" => $spec_id, "displayorder" => $n, "title" => $spec_item_titles[$n], "show" => $spec_item_shows[$n], "thumb" => $spec_item_thumbs[$n]); $f = "spec_item_thumb_" . $get_item_id; if (is_numeric($get_item_id)) { pdo_update("wwx_fxxt_spec_item", $d, array("id" => $get_item_id)); $item_id = $get_item_id; } else { pdo_insert('wwx_fxxt_spec_item', $d); $item_id = pdo_insertid(); } $itemids[] = $item_id; $d['get_id'] = $get_item_id; $d['id'] = $item_id; $spec_items[] = $d; } if (count($itemids) > 0) { pdo_query("delete from " . tablename('wwx_fxxt_spec_item') . " where uniacid={$_W['uniacid']} and specid={$spec_id} and id not in (" . implode(",", $itemids) . ")"); } else { pdo_query('delete from ' . tablename('wwx_fxxt_spec_item') . " where uniacid={$_W['uniacid']} and specid={$spec_id}"); } pdo_update('wwx_fxxt_spec', array('content' => serialize($itemids)), array("id" => $spec_id)); $specids[] = $spec_id; } if (count($specids) > 0) { pdo_query("delete from " . tablename('wwx_fxxt_spec') . " where uniacid={$_W['uniacid']} and goodsid={$id} and id not in (" . implode(",", $specids) . ")"); } else { pdo_query('delete from ' . tablename('wwx_fxxt_spec') . " where uniacid={$_W['uniacid']} and goodsid={$id}"); } $option_idss = $_POST['option_ids']; $option_productprices = $_POST['option_productprice']; $option_marketprices = $_POST['option_marketprice']; $option_costprices = $_POST['option_costprice']; $option_stocks = $_POST['option_stock']; $option_weights = $_POST['option_weight']; $len = count($option_idss); $optionids = array(); for ($k = 0; $k < $len; $k++) { $option_id = ""; $get_option_id = $_GPC['option_id_' . $ids][0]; $ids = $option_idss[$k]; $idsarr = explode("_", $ids); $newids = array(); foreach ($idsarr as $key => $ida) { foreach ($spec_items as $it) { if ($it['get_id'] == $ida) { $newids[] = $it['id']; break; } } } $newids = implode("_", $newids); $a = array("title" => $_GPC['option_title_' . $ids][0], "productprice" => $_GPC['option_productprice_' . $ids][0], "costprice" => $_GPC['option_costprice_' . $ids][0], "marketprice" => $_GPC['option_marketprice_' . $ids][0], "stock" => $_GPC['option_stock_' . $ids][0], "weight" => $_GPC['option_weight_' . $ids][0], "goodsid" => $id, "specs" => $newids); $totalstocks += $a['stock']; if (empty($get_option_id)) { pdo_insert("wwx_fxxt_goods_option", $a); $option_id = pdo_insertid(); } else { pdo_update('wwx_fxxt_goods_option', $a, array('id' => $get_option_id)); $option_id = $get_option_id; } $optionids[] = $option_id; } if (count($optionids) > 0) { pdo_query("delete from " . tablename('wwx_fxxt_goods_option') . " where goodsid={$id} and id not in ( " . implode(',', $optionids) . ")"); } else { pdo_query('delete from ' . tablename('wwx_fxxt_goods_option') . " where goodsid={$id}"); } if ($totalstocks > 0) { pdo_update("wwx_fxxt_goods", array("total" => $totalstocks), array("id" => $id)); } message('商品更新成功!', $this->createWebUrl('goods', array('op' => 'post', 'id' => $id)), 'success'); } } elseif ($operation == 'display') { $pindex = max(1, intval($_GPC['page'])); $psize = 50; $condition = ''; if (!empty($_GPC['keyword'])) { $condition .= " AND title LIKE '%{$_GPC['keyword']}%'"; } if (!empty($_GPC['cate_2'])) { $cid = intval($_GPC['cate_2']); $condition .= " AND ccate = '{$cid}'"; } elseif (!empty($_GPC['cate_1'])) { $cid = intval($_GPC['cate_1']); $condition .= " AND pcate = '{$cid}'"; } if (isset($_GPC['status'])) { $condition .= " AND status = '" . intval($_GPC['status']) . "'"; } $list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_goods') . " WHERE uniacid = '{$_W['uniacid']}' and deleted=0 {$condition} ORDER BY status DESC, displayorder DESC, id DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize); $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('wwx_fxxt_goods') . " WHERE uniacid = '{$_W['uniacid']}' and deleted=0 {$condition}"); $pager = pagination($total, $pindex, $psize); } elseif ($operation == 'delete') { $id = intval($_GPC['id']); $row = pdo_fetch("SELECT id,thumb FROM " . tablename('wwx_fxxt_goods') . " WHERE id = :id", array(':id' => $id)); if (empty($row)) { message('抱歉,商品不存在或是已经被删除!'); } pdo_query('delete from ' . tablename('wwx_fxxt_goods') . " where uniacid={$_W['uniacid']} and id={$id}"); pdo_query('delete from ' . tablename('wwx_fxxt_goods_option') . " where goodsid={$id}"); pdo_query('delete from ' . tablename('wwx_fxxt_goods_param') . " where goodsid={$id}"); pdo_query('delete from ' . tablename('wwx_fxxt_spec') . " where uniacid={$_W['uniacid']} and goodsid={$id}"); pdo_query('delete from ' . tablename('wwx_fxxt_spec_item') . " where uniacid={$_W['uniacid']} and goodsid={$id}"); message('删除成功!', referer(), 'success'); } include $this->template('goods'); } public function doWebCategory() { global $_W, $_GPC; load()->func('tpl'); if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $uniacid = $_W['uniacid']; $op = $operation = $_GPC['op'] ? $_GPC['op'] : 'display'; $modules = 'category'; $operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display'; if ($operation == 'display') { if (!empty($_GPC['displayorder'])) { foreach ($_GPC['displayorder'] as $id => $displayorder) { pdo_update('wwx_fxxt_category', array('displayorder' => $displayorder), array('id' => $id)); } message('分类排序更新成功!', $this->createWebUrl('category', array('op' => 'display')), 'success'); } $children = array(); $category = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_category') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY parentid ASC, displayorder DESC"); foreach ($category as $index => $row) { if (!empty($row['parentid'])) { $children[$row['parentid']][] = $row; unset($category[$index]); } } include $this->template('category'); } elseif ($operation == 'post') { $parentid = intval($_GPC['parentid']); $id = intval($_GPC['id']); if (!empty($id)) { $category = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_category') . " WHERE id = '{$id}'"); } else { $category = array('displayorder' => 0); } if (!empty($parentid)) { $parent = pdo_fetch("SELECT id, name FROM " . tablename('wwx_fxxt_category') . " WHERE id = '{$parentid}'"); if (empty($parent)) { message('抱歉,上级分类不存在或是已经被删除!', $this->createWebUrl('post'), 'error'); } } if (checksubmit('submit')) { if (empty($_GPC['catename'])) { message('抱歉,请输入分类名称!'); } $data = array('uniacid' => $_W['uniacid'], 'name' => $_GPC['catename'], 'enabled' => intval($_GPC['enabled']), 'displayorder' => intval($_GPC['displayorder']), 'isrecommand' => intval($_GPC['isrecommand']), 'description' => $_GPC['description'], 'parentid' => intval($parentid)); $data['thumb'] = $_GPC['thumb']; if (!empty($id)) { unset($data['parentid']); pdo_update('wwx_fxxt_category', $data, array('id' => $id, 'uniacid' => $_W['uniacid'])); } else { pdo_insert('wwx_fxxt_category', $data); $id = pdo_insertid(); } message('更新分类成功!', $this->createWebUrl('category', array('op' => 'display')), 'success'); } include $this->template('category'); } elseif ($operation == 'delete') { $id = intval($_GPC['id']); $category = pdo_fetch("SELECT id, parentid FROM " . tablename('wwx_fxxt_category') . " WHERE id = '{$id}' and uniacid = '{$_W['uniacid']}'"); if (empty($category)) { message('抱歉,分类不存在或是已经被删除!', $this->createWebUrl('category', array('op' => 'display')), 'error'); } pdo_delete('wwx_fxxt_category', array('id' => $id, 'parentid' => $id), 'OR'); message('分类删除成功!', $this->createWebUrl('category', array('op' => 'display')), 'success'); } } public function doWebSetGoodsProperty() { global $_GPC, $_W; if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $id = intval($_GPC['id']); $type = $_GPC['type']; $data = intval($_GPC['data']); empty($data) ? $data = 1 : ($data = 0); if (!in_array($type, array('new', 'hot', 'recommand', 'discount', 'status', 'sendfree'))) { die(json_encode(array("result" => 0))); } if ($_GPC['type'] == 'status') { pdo_update("wwx_fxxt_goods", array($type => $data), array("id" => $id, "uniacid" => $_W['uniacid'])); } else { pdo_update('wwx_fxxt_goods', array('is' . $type => $data), array("id" => $id, "uniacid" => $_W['uniacid'])); } die(json_encode(array('result' => 1, 'data' => $data))); } public function doWebSpec() { global $_GPC; $spec = array("id" => random(32), "title" => $_GPC['title']); include $this->template('spec'); } public function doWebSpecItem() { global $_GPC; load()->func('tpl'); $spec = array("id" => $_GPC['specid']); $specitem = array("id" => random(32), "title" => $_GPC['title'], "show" => 1); include $this->template('spec_item'); } public function doWebParam() { $tag = random(32); global $_GPC; include $this->template('param'); } public function doWebShopadmin() { global $_GPC, $_W; load()->func('tpl'); if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $operation = empty($_GPC['op']) ? 'display' : $_GPC['op']; $operation = in_array($operation, array('display')) ? $operation : 'display'; $cfg = $this->module['config']; if ($_W['ispost']) { set_time_limit(0); $ret = array(); $url = $_GPC['url']; $pcate = intval($_GPC['pcate']); $ccate = intval($_GPC['ccate']); $into_shop = intval($_GPC['into_shop']); if (is_numeric($url)) { $itemid = $url; $url = "https://item.taobao.com/item.htm?id=" . $itemid; } else { preg_match('/id\\=(\\d+)/i', $url, $matches); if (isset($matches[1])) { $itemid = $matches[1]; $url = "https://item.taobao.com/item.htm?id=" . $itemid; } } if (empty($itemid)) { die(json_encode(array("result" => 0, "error" => "未获取到 itemid!"))); } if ($_W['user']['collection'] < 1) { die(json_encode(array("result" => 0, "error" => "您的采集数不足,请充值后继续操作!"))); } die(json_encode($this->get_item_taobao($itemid, $into_shop, $url, $pcate, $ccate))); } $category = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_category') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY parentid ASC, displayorder DESC", array(), 'id'); if (!empty($category)) { $children = ''; foreach ($category as $cid => $cate) { if (!empty($cate['parentid'])) { $children[$cate['parentid']][$cate['id']] = array($cate['id'], $cate['name']); } } } if (empty($category)) { message('抱歉,请您先添加商品分类!', $this->createWebUrl('category', array('op' => 'post')), 'error'); } include $this->template('shopadmin'); } public function doWebShopmany() { global $_W; if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $category = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_category') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY parentid ASC, displayorder DESC", array(), 'id'); if (!empty($category)) { $children = ''; foreach ($category as $cid => $cate) { if (!empty($cate['parentid'])) { $children[$cate['parentid']][$cate['id']] = array($cate['id'], $cate['name']); } } } if (empty($category)) { message('抱歉,请您先添加商品分类!', $this->createWebUrl('category', array('op' => 'post')), 'error'); } include $this->template('shopmany'); } public function doWebShopwhole() { set_time_limit(0); global $_W, $_GPC; if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $op = $_GPC['op']; include $this->template('shopwhole'); } public function doWebShopgoods() { global $_GPC, $_W; load()->func('tpl'); load()->func('file'); $cfg = $this->module['config']; $this->doWebAuth(); if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $category = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_category') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY parentid ASC, displayorder DESC", array(), 'id'); if (!empty($category)) { $children = ''; foreach ($category as $cid => $cate) { if (!empty($cate['parentid'])) { $children[$cate['parentid']][$cate['id']] = array($cate['id'], $cate['name']); } } } $operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display'; if ($operation == 'post') { $id = intval($_GPC['id']); if (!empty($id)) { $item = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_shop_goods') . " WHERE id = :id", array(':id' => $id)); if (empty($item)) { message('抱歉,商品不存在或是已经删除!', '', 'error'); } $allspecs = pdo_fetchall("select * from " . tablename('wwx_fxxt_shop_spec') . " where goodsid=:id order by displayorder asc", array(":id" => $id)); foreach ($allspecs as &$s) { $s['items'] = pdo_fetchall("select * from " . tablename('wwx_fxxt_shop_spec_item') . " where specid=:specid order by displayorder asc", array(":specid" => $s['id'])); } unset($s); $params = pdo_fetchall("select * from " . tablename('wwx_fxxt_shop_goods_param') . " where goodsid=:id order by displayorder asc", array(':id' => $id)); $piclist = unserialize($item['thumb_url']); $html = ""; $options = pdo_fetchall("select * from " . tablename('wwx_fxxt_shop_goods_option') . " where goodsid=:id order by id asc", array(':id' => $id)); $specs = array(); if (count($options) > 0) { $specitemids = explode("_", $options[0]['specs']); foreach ($specitemids as $itemid) { foreach ($allspecs as $ss) { $items = $ss['items']; foreach ($items as $it) { if ($it['id'] == $itemid) { $specs[] = $ss; break; } } } } $html = ''; $html .= ''; $html .= ''; $html .= ''; $len = count($specs); $newlen = 1; $h = array(); $rowspans = array(); for ($i = 0; $i < $len; $i++) { $html .= ""; $itemlen = count($specs[$i]['items']); if ($itemlen <= 0) { $itemlen = 1; } $newlen *= $itemlen; $h = array(); for ($j = 0; $j < $newlen; $j++) { $h[$i][$j] = array(); } $l = count($specs[$i]['items']); $rowspans[$i] = 1; for ($j = $i + 1; $j < $len; $j++) { $rowspans[$i] *= count($specs[$j]['items']); } } $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; for ($m = 0; $m < $len; $m++) { $k = 0; $kid = 0; $n = 0; for ($j = 0; $j < $newlen; $j++) { $rowspan = $rowspans[$m]; if ($j % $rowspan == 0) { $h[$m][$j] = array("html" => "", "id" => $specs[$m]['items'][$kid]['id']); } else { $h[$m][$j] = array("html" => "", "id" => $specs[$m]['items'][$kid]['id']); } $n++; if ($n == $rowspan) { $kid++; if ($kid > count($specs[$m]['items']) - 1) { $kid = 0; } $n = 0; } } } $hh = ""; for ($i = 0; $i < $newlen; $i++) { $hh .= ""; $ids = array(); for ($j = 0; $j < $len; $j++) { $hh .= $h[$j][$i]['html']; $ids[] = $h[$j][$i]['id']; } $ids = implode("_", $ids); $val = array("id" => "", "title" => "", "stock" => "", "costprice" => "", "productprice" => "", "marketprice" => "", "weight" => ""); foreach ($options as $o) { if ($ids === $o['specs']) { $val = array("id" => $o['id'], "title" => $o['title'], "stock" => $o['stock'], "costprice" => $o['costprice'], "productprice" => $o['productprice'], "marketprice" => $o['marketprice'], "weight" => $o['weight']); break; } } $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; } $html .= $hh; $html .= "
" . $specs[$i]['title'] . "
库存
销售价格
市场价格
成本价格
重量(克)
" . $specs[$m]['items'][$kid]['title'] . "
'; $hh .= '
"; } } if (empty($category)) { message('抱歉,请您先添加商品分类!', $this->createWebUrl('category', array('op' => 'post')), 'error'); } if (checksubmit('submit')) { if (empty($_GPC['goodsname'])) { message('请输入商品名称!'); } if (empty($_GPC['pcate'])) { message('请选择商品分类!'); } if (empty($_GPC['thumbs'])) { $_GPC['thumbs'] = array(); } $data = array('uniacid' => intval($_W['uniacid']), 'displayorder' => intval($_GPC['displayorder']), 'title' => $_GPC['goodsname'], 'pcate' => intval($_GPC['pcate']), 'ccate' => intval($_GPC['ccate']), 'thumb' => $_GPC['thumb'], 'type' => intval($_GPC['type']), 'isrecommand' => intval($_GPC['isrecommand']), 'ishot' => intval($_GPC['ishot']), 'isnew' => intval($_GPC['isnew']), 'isdiscount' => intval($_GPC['isdiscount']), 'istime' => intval($_GPC['istime']), 'issendfree' => intval($_GPC['issendfree']), 'timestart' => strtotime($_GPC['timestart']), 'timeend' => strtotime($_GPC['timeend']), 'description' => $_GPC['description'], 'content' => htmlspecialchars_decode($_GPC['content']), 'goodssn' => $_GPC['goodssn'], 'unit' => $_GPC['unit'], 'createtime' => TIMESTAMP, 'total' => intval($_GPC['total']), 'totalcnf' => intval($_GPC['totalcnf']), 'marketprice' => $_GPC['marketprice'], 'weight' => $_GPC['weight'], 'costprice' => $_GPC['costprice'], 'productprice' => $_GPC['productprice'], 'productsn' => $_GPC['productsn'], 'credit' => intval($_GPC['credit']), 'maxbuy' => intval($_GPC['maxbuy']), 'usermaxbuy' => intval($_GPC['usermaxbuy']),'commission' => intval($_GPC['commission']), 'commission2' => intval($_GPC['commission2']), 'commission3' => intval($_GPC['commission3']), 'hasoption' => intval($_GPC['hasoption']), 'sales' => intval($_GPC['sales']), 'status' => intval($_GPC['status']), 'xsthumb' => $_GPC['xsthumb']); if (is_array($_GPC['thumbs'])) { $data['thumb_url'] = serialize($_GPC['thumbs']); } if (empty($id)) { pdo_insert('wwx_fxxt_shop_goods', $data); $id = pdo_insertid(); } else { unset($data['createtime']); pdo_update('wwx_fxxt_shop_goods', $data, array('id' => $id)); } $totalstocks = 0; $param_ids = $_POST['param_id']; $param_titles = $_POST['param_title']; $param_values = $_POST['param_value']; $param_displayorders = $_POST['param_displayorder']; $len = count($param_ids); $paramids = array(); for ($k = 0; $k < $len; $k++) { $param_id = ""; $get_param_id = $param_ids[$k]; $a = array("title" => $param_titles[$k], "value" => $param_values[$k], "displayorder" => $k, "goodsid" => $id); if (!is_numeric($get_param_id)) { pdo_insert("wwx_fxxt_shop_goods_param", $a); $param_id = pdo_insertid(); } else { pdo_update('wwx_fxxt_shop_goods_param', $a, array('id' => $get_param_id)); $param_id = $get_param_id; } $paramids[] = $param_id; } if (count($paramids) > 0) { pdo_query("delete from " . tablename('wwx_fxxt_shop_goods_param') . " where goodsid={$id} and id not in ( " . implode(',', $paramids) . ")"); } else { pdo_query('delete from ' . tablename('wwx_fxxt_shop_goods_param') . " where goodsid={$id}"); } $files = $_FILES; $spec_ids = $_POST['spec_id']; $spec_titles = $_POST['spec_title']; $specids = array(); $len = count($spec_ids); $specids = array(); $spec_items = array(); for ($k = 0; $k < $len; $k++) { $spec_id = ""; $get_spec_id = $spec_ids[$k]; $a = array("uniacid" => $_W['uniacid'], "goodsid" => $id, "displayorder" => $k, "title" => $spec_titles[$get_spec_id]); if (is_numeric($get_spec_id)) { pdo_update("wwx_fxxt_shop_spec", $a, array("id" => $get_spec_id)); $spec_id = $get_spec_id; } else { pdo_insert('wwx_fxxt_shop_spec', $a); $spec_id = pdo_insertid(); } $spec_item_ids = $_POST["spec_item_id_" . $get_spec_id]; $spec_item_titles = $_POST["spec_item_title_" . $get_spec_id]; $spec_item_shows = $_POST["spec_item_show_" . $get_spec_id]; $spec_item_thumbs = $_POST["spec_item_thumb_" . $get_spec_id]; $spec_item_oldthumbs = $_POST["spec_item_oldthumb_" . $get_spec_id]; $itemlen = count($spec_item_ids); $itemids = array(); for ($n = 0; $n < $itemlen; $n++) { $item_id = ""; $get_item_id = $spec_item_ids[$n]; $d = array("uniacid" => $_W['uniacid'], "goodsid" => $id, "specid" => $spec_id, "displayorder" => $n, "title" => $spec_item_titles[$n], "show" => $spec_item_shows[$n], "thumb" => $spec_item_thumbs[$n]); $f = "spec_item_thumb_" . $get_item_id; if (is_numeric($get_item_id)) { pdo_update("wwx_fxxt_shop_spec_item", $d, array("id" => $get_item_id)); $item_id = $get_item_id; } else { pdo_insert('wwx_fxxt_shop_spec_item', $d); $item_id = pdo_insertid(); } $itemids[] = $item_id; $d['get_id'] = $get_item_id; $d['id'] = $item_id; $spec_items[] = $d; } if (count($itemids) > 0) { pdo_query("delete from " . tablename('wwx_fxxt_shop_spec_item') . " where uniacid={$_W['uniacid']} and specid={$spec_id} and id not in (" . implode(",", $itemids) . ")"); } else { pdo_query('delete from ' . tablename('wwx_fxxt_shop_spec_item') . " where uniacid={$_W['uniacid']} and specid={$spec_id}"); } pdo_update('wwx_fxxt_shop_spec', array('content' => serialize($itemids)), array("id" => $spec_id)); $specids[] = $spec_id; } if (count($specids) > 0) { pdo_query("delete from " . tablename('wwx_fxxt_shop_spec') . " where uniacid={$_W['uniacid']} and goodsid={$id} and id not in (" . implode(",", $specids) . ")"); } else { pdo_query('delete from ' . tablename('wwx_fxxt_shop_spec') . " where uniacid={$_W['uniacid']} and goodsid={$id}"); } $option_idss = $_POST['option_ids']; $option_productprices = $_POST['option_productprice']; $option_marketprices = $_POST['option_marketprice']; $option_costprices = $_POST['option_costprice']; $option_stocks = $_POST['option_stock']; $option_weights = $_POST['option_weight']; $len = count($option_idss); $optionids = array(); for ($k = 0; $k < $len; $k++) { $option_id = ""; $get_option_id = $_GPC['option_id_' . $ids][0]; $ids = $option_idss[$k]; $idsarr = explode("_", $ids); $newids = array(); foreach ($idsarr as $key => $ida) { foreach ($spec_items as $it) { if ($it['get_id'] == $ida) { $newids[] = $it['id']; break; } } } $newids = implode("_", $newids); $a = array("title" => $_GPC['option_title_' . $ids][0], "productprice" => $_GPC['option_productprice_' . $ids][0], "costprice" => $_GPC['option_costprice_' . $ids][0], "marketprice" => $_GPC['option_marketprice_' . $ids][0], "stock" => $_GPC['option_stock_' . $ids][0], "weight" => $_GPC['option_weight_' . $ids][0], "goodsid" => $id, "specs" => $newids); $totalstocks += $a['stock']; if (empty($get_option_id)) { pdo_insert("wwx_fxxt_shop_goods_option", $a); $option_id = pdo_insertid(); } else { pdo_update('wwx_fxxt_shop_goods_option', $a, array('id' => $get_option_id)); $option_id = $get_option_id; } $optionids[] = $option_id; } if (count($optionids) > 0) { pdo_query("delete from " . tablename('wwx_fxxt_shop_goods_option') . " where goodsid={$id} and id not in ( " . implode(',', $optionids) . ")"); } else { pdo_query('delete from ' . tablename('wwx_fxxt_shop_goods_option') . " where goodsid={$id}"); } if ($totalstocks > 0) { pdo_update("wwx_fxxt_shop_goods", array("total" => $totalstocks), array("id" => $id)); } message('商品更新成功!', $this->createWebUrl('shopgoods', array('op' => 'post', 'id' => $id)), 'success'); } } elseif ($operation == 'display') { $pindex = max(1, intval($_GPC['page'])); $psize = 50; $condition = ''; if (!empty($_GPC['keyword'])) { $condition .= " AND title LIKE '%{$_GPC['keyword']}%'"; } if (!empty($_GPC['cate_2'])) { $cid = intval($_GPC['cate_2']); $condition .= " AND ccate = '{$cid}'"; } elseif (!empty($_GPC['cate_1'])) { $cid = intval($_GPC['cate_1']); $condition .= " AND pcate = '{$cid}'"; } if (isset($_GPC['status'])) { $condition .= " AND status = '" . intval($_GPC['status']) . "'"; } $list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_shop_goods') . " WHERE uniacid = '{$_W['uniacid']}' and deleted=0 {$condition} ORDER BY status DESC, displayorder DESC, id DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize); $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('wwx_fxxt_shop_goods') . " WHERE uniacid = '{$_W['uniacid']}' and deleted=0 {$condition}"); $pager = pagination($total, $pindex, $psize); } elseif ($operation == 'delete') { $id = intval($_GPC['id']); $row = pdo_fetch("SELECT id,thumb,status FROM " . tablename('wwx_fxxt_shop_goods') . " WHERE id = :id", array(':id' => $id)); if (empty($row)) { message('抱歉,商品不存在或是已经被删除!'); } $picedel = pdo_fetchall("select * from " . tablename("wwx_fxxt_shop_picture_address") . " where uniacid={$_W['uniacid']} and goodsid=:goodsid order by id asc", array(":goodsid" => $id)); foreach ($picedel as $del) { if (file_exists($del['thumb'])) { if (empty($row['status'])) { unlink($del['thumb']); } } pdo_query('delete from ' . tablename('wwx_fxxt_shop_picture_address') . " where id={$del['id']}"); } pdo_query('delete from ' . tablename('wwx_fxxt_shop_goods') . " where uniacid={$_W['uniacid']} and id={$id}"); pdo_query('delete from ' . tablename('wwx_fxxt_shop_goods_option') . " where goodsid={$id}"); pdo_query('delete from ' . tablename('wwx_fxxt_shop_goods_param') . " where goodsid={$id}"); pdo_query('delete from ' . tablename('wwx_fxxt_shop_spec') . " where uniacid={$_W['uniacid']} and goodsid={$id}"); pdo_query('delete from ' . tablename('wwx_fxxt_shop_spec_item') . " where uniacid={$_W['uniacid']} and goodsid={$id}"); message('删除成功!', referer(), 'success'); } elseif ($operation == 'deleteout') { $rowshop = pdo_fetchall("SELECT id,thumb,status FROM " . tablename('wwx_fxxt_shop_goods') . " WHERE uniacid = :uniacid", array(':uniacid' => $_W['uniacid'])); if (empty($rowshop)) { message('抱歉,商品不存在或是已经被删除!'); } foreach ($rowshop as $shopid) { $picedel = pdo_fetchall("select * from " . tablename("wwx_fxxt_shop_picture_address") . " where uniacid={$_W['uniacid']} and goodsid=:goodsid order by id asc", array(":goodsid" => $shopid['id'])); foreach ($picedel as $del) { if (file_exists($del['thumb'])) { if (empty($shopid['status'])) { unlink($del['thumb']); } } pdo_query('delete from ' . tablename('wwx_fxxt_shop_picture_address') . " where id={$del['id']}"); } pdo_query('delete from ' . tablename('wwx_fxxt_shop_goods') . " where uniacid={$_W['uniacid']} and id={$shopid['id']}"); pdo_query('delete from ' . tablename('wwx_fxxt_shop_goods_option') . " where goodsid={$shopid['id']}"); pdo_query('delete from ' . tablename('wwx_fxxt_shop_goods_param') . " where goodsid={$shopid['id']}"); pdo_query('delete from ' . tablename('wwx_fxxt_shop_spec') . " where uniacid={$_W['uniacid']} and goodsid={$shopid['id']}"); pdo_query('delete from ' . tablename('wwx_fxxt_shop_spec_item') . " where uniacid={$_W['uniacid']} and goodsid={$shopid['id']}"); } message('删除成功!', referer(), 'success'); } elseif ($operation == 'copy') { $id = intval($_GPC['id']); $idArr = $_GPC['idArr']; if (empty($id) && empty($idArr)) { $this->message("参数错误!"); } if (!empty($id)) { $this->copy_goods($id); message('宝贝导入成功!', referer(), 'success'); } else { if (!empty($idArr)) { foreach ($_GPC['idArr'] as $k => $id) { $id = intval($id); $this->copy_goods($id); } $this->message('宝贝已经批量导入成功!', '', 0); } } } include $this->template('shopgoods'); } public function doWebShopcollection() { global $_W, $_GPC; $accountname = $_GPC['accountname']; $accountsum = intval($_GPC['accountsum']); $id = intval($_GPC['id']); $operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display'; if (!$_W['isfounder']) { message('不能访问,此功能只有站长才有操作权限.'); } if ($operation == 'chongzhi') { if ($accountsum < 1) { message('充值点数错误,请返回重新填写.'); } $accountuid = pdo_fetch("select uid,collection from " . tablename('users') . " where username='{$accountname}' limit 1 "); if (empty($accountuid)) { message('没有找到此用户,请检查.'); } pdo_update('users', array('collection' => $accountuid['collection'] + $accountsum), array("uid" => $accountuid['uid'])); message('充值点数成功!', $this->createWebUrl('shopcollection', array('op' => 'display')), 'success'); } elseif ($operation == 'delete') { $row = pdo_fetch("SELECT id FROM " . tablename('wwx_fxxt_shop_collection') . " WHERE id = :id", array(':id' => $id)); if (empty($row)) { message('抱歉,记录不存在或是已经被删除!'); } pdo_delete('wwx_fxxt_shop_collection', array('uniacid' => $_W['uniacid'], 'id' => $id)); message('删除成功!', referer(), 'success'); } elseif ($operation == 'display') { $pindex = max(1, intval($_GPC['page'])); $psize = 50; $list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_shop_collection') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY createtime DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize); $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('wwx_fxxt_shop_collection') . " WHERE uniacid = '{$_W['uniacid']}'"); $pager = pagination($total, $pindex, $psize); } elseif ($_GPC['op'] == 'deleteout') { pdo_delete('wwx_fxxt_shop_collection', array('uniacid' => $_W['uniacid'])); message('全部清空成功!', $this->createWebUrl('shopcollection', array('op' => 'display')), 'success'); die; } include $this->template('shopcollection'); } public function doWebSetShopProperty() { global $_GPC, $_W; if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $stock = $_GPC['stock']; $data = intval($_GPC['data']); $type = $_GPC['type']; if ($type == "username") { $statustype = 3; } elseif ($type == "shopip") { $statustype = 1; } elseif ($type == "shopmachine") { $statustype = 2; } $st = pdo_fetch("select status from " . tablename('wwx_fxxt_shop_collection_status') . " where stock='{$stock}' limit 1 "); if ($st['status'] == 0) { pdo_insert('wwx_fxxt_shop_collection_status', array('uniacid' => $_W['uniacid'], 'status' => $statustype, 'stock' => $stock, 'createtime' => time())); } else { pdo_delete('wwx_fxxt_shop_collection_status', array('uniacid' => $_W['uniacid'], "stock" => $stock)); } $st1 = pdo_fetch("select status from " . tablename('wwx_fxxt_shop_collection_status') . " where stock='{$stock}' limit 1 "); if (empty($st1['status'])) { $st1['status'] = 0; } if ($st1['status'] == $data) { die(json_encode(array("result" => 0, "data" => $st1['status']))); } else { die(json_encode(array('result' => 1, 'data' => $st1['status']))); } } public function doWebShopCollectionList() { global $_GPC, $_W; $operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display'; $id = intval($_GPC['id']); if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } if (!$_W['isfounder']) { message('不能访问,此功能只有站长才有操作权限.'); } if ($operation == 'display') { $pindex = max(1, intval($_GPC['page'])); $psize = 50; $list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_shop_collection_status') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY createtime DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize); $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('wwx_fxxt_shop_collection_status') . " WHERE uniacid = '{$_W['uniacid']}'"); $pager = pagination($total, $pindex, $psize); } elseif ($operation == 'delete') { $row = pdo_fetch("SELECT id FROM " . tablename('wwx_fxxt_shop_collection_status') . " WHERE id = :id", array(':id' => $id)); if (empty($row)) { message('抱歉,信息不存在或是已经被删除!'); } pdo_delete('wwx_fxxt_shop_collection_status', array('uniacid' => $_W['uniacid'], 'id' => $id)); message('删除成功!', referer(), 'success'); } elseif ($_GPC['op'] == 'deleteout') { pdo_delete('wwx_fxxt_shop_collection_status', array('uniacid' => $_W['uniacid'])); message('全部清空成功!', $this->createWebUrl('shopcollectionlist', array('op' => 'display')), 'success'); die; } include $this->template('shopcollectionlist'); } public function doWebStatistics() { global $_W, $_GPC; load()->func('tpl'); if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $needfixcount = pdo_fetchcolumn("SELECT count(id) FROM " . tablename('wwx_fxxt_member') . " WHERE flag=1 and flagtime=0"); if ($needfixcount > 0) { pdo_update('wwx_fxxt_member', array('flagtime' => TIMESTAMP), array('flag' => 1, 'flagtime' => 0)); } $op = $_GPC['op'] ? $_GPC['op'] : 'salereport'; if ($op == 'salereport') { $nowyear = intval(date('Y', time())); $nowmonth = intval(date('m', time())); $years = array(array('year' => $nowyear - 3, 'checked' => 0), array('year' => $nowyear - 2, 'checked' => 0), array('year' => $nowyear - 1, 'checked' => 0), array('year' => $nowyear, 'checked' => 1)); $dropMonthForYaer = $_GPC['dropMonthForYaer'] ? $_GPC['dropMonthForYaer'] : $nowyear; $radioMonthForSaleType = $_GPC['radioMonthForSaleType'] ? $_GPC['radioMonthForSaleType'] : '0'; $dropMonthForYaer = intval($dropMonthForYaer); $selectmonthSale = $_GPC['selectmonthSale'] ? $_GPC['selectmonthSale'] : $nowmonth; $radiodayForSaleType = $_GPC['radiodayForSaleType'] ? $_GPC['radiodayForSaleType'] : '0'; $dropdayForYaer = $_GPC['dropdayForYaer'] ? $_GPC['dropdayForYaer'] : $nowyear; $dropdayForYaer = intval($dropdayForYaer); foreach ($years as $id => $displayorder) { if ($years[$id]['year'] == $dropMonthForYaer) { $years[$id]['checked'] = 1; } else { $years[$id]['checked'] = 0; } } $datas = array(array()); $index = 0; $allcount = 0; $topcount = 0; for ($month = 1; $month <= 12; $month++) { $datas[$index]['month'] = $month; $lastday = date('t', strtotime($dropMonthForYaer . "-" . $month . "-1")); if ($radioMonthForSaleType == '0') { $ordercount = pdo_fetchcolumn("SELECT count(id) FROM " . tablename('wwx_fxxt_order') . " WHERE uniacid = '{$_W['uniacid']}' and createtime >=" . strtotime($dropMonthForYaer . "-" . $month . "-1" . " 00:00:01") . " and createtime <=" . strtotime($dropMonthForYaer . "-" . $month . "-" . $lastday . " 23:59:59")); } if ($radioMonthForSaleType == '1') { $ordercount = pdo_fetchcolumn("SELECT sum(cast(price as decimal(8,2))) FROM " . tablename('wwx_fxxt_order') . " WHERE uniacid = '{$_W['uniacid']}' and createtime >=" . strtotime($dropMonthForYaer . "-" . $month . "-1" . " 00:00:01") . " and createtime <=" . strtotime($dropMonthForYaer . "-" . $month . "-" . $lastday . " 23:59:59")); } if (empty($ordercount)) { $ordercount = 0; } if ($topcount < $ordercount) { $topcount = $ordercount; } $datas[$index]['month'] = $month; $datas[$index]['count'] = $ordercount; $allcount = $allcount + $ordercount; $index = $index + 1; if ($nowyear == $dropMonthForYaer) { if ($nowmonth == $month) { $month = 13; } } } foreach ($datas as $index => $row) { if ($allcount > 0) { $datas[$index]['persent'] = round($datas[$index]['count'] / $allcount, 2) * 100; } else { $datas[$index]['persent'] = 0; } } $dayallcount = 0; $daytopcount = 0; $daydatas = array(array()); $dayindex = 0; $lastday = date('t', strtotime($dropdayForYaer . "-" . $selectmonthSale . "-1")); for ($day = 1; $day <= $lastday; $day++) { if ($radiodayForSaleType == '0') { $dayordercount = pdo_fetchcolumn("SELECT count(id) FROM " . tablename('wwx_fxxt_order') . " WHERE uniacid = '{$_W['uniacid']}' and createtime >=" . strtotime($dropdayForYaer . "-" . $selectmonthSale . "-" . $day . " 00:00:01") . " and createtime <=" . strtotime($dropdayForYaer . "-" . $selectmonthSale . "-" . $day . " 23:59:59")); } if ($radiodayForSaleType == '1') { $dayordercount = pdo_fetchcolumn("SELECT sum(cast(price as decimal(8,2))) FROM " . tablename('wwx_fxxt_order') . " WHERE uniacid = '{$_W['uniacid']}' and createtime >=" . strtotime($dropdayForYaer . "-" . $selectmonthSale . "-" . $day . " 00:00:01") . " and createtime <=" . strtotime($dropdayForYaer . "-" . $selectmonthSale . "-" . $day . " 23:59:59")); } if (empty($dayordercount)) { $dayordercount = 0; } $daydatas[$dayindex]['day'] = $day; $daydatas[$dayindex]['count'] = $dayordercount; $dayindex = $dayindex + 1; $dayallcount = $dayallcount + $dayordercount; if ($daytopcount < $dayordercount) { $daytopcount = $dayordercount; } } foreach ($daydatas as $index => $row) { if ($dayallcount > 0) { $daydatas[$index]['persent'] = round($daydatas[$index]['count'] / $dayallcount, 2) * 100; } else { $daydatas[$index]['persent'] = 0; } } if (!empty($_GPC['salereportEXP01'])) { $report = "salereport01"; $list = $datas; require_once 'report.php'; die; } if (!empty($_GPC['salereportEXP02'])) { $report = "salereport02"; $list = $daydatas; require_once 'report.php'; die; } include $this->template('salereport'); die; } if ($op == 'memberranking') { $sortname = $_GPC['sortname'] ? $_GPC['sortname'] : 'ordermoney'; if (!empty($_GPC['time']['start']) && !empty($_GPC['time']['end'])) { $start_time = strtotime($_GPC['time']['start'] . " 00:00:01"); $end_time = strtotime($_GPC['time']['end'] . " 23:59:59"); } else { $start_time = strtotime(date('Y-m-01 00:00:01', time())); $end_time = strtotime(date('Y-m-t 23:59:59', time())); } $condition1 = ""; $condition2 = ""; if (!empty($start_time) && !empty($end_time) && !empty($_GPC['time']['start']) && !empty($_GPC['time']['end'])) { $condition1 = " and orders.createtime>=" . $start_time . " and " . "orders.createtime<=" . $end_time; $condition2 = " and orders2.createtime>=" . $start_time . " and " . "orders2.createtime<=" . $end_time; } $list = pdo_fetchall("SELECT member.realname,(" . "SELECT count(orders.id) FROM " . tablename('wwx_fxxt_order') . " orders where orders.from_user=member.from_user and orders.uniacid=member.uniacid " . $condition1 . ") as ordercount,(" . "SELECT sum(cast(orders2.price as decimal(8,2))) FROM " . tablename('wwx_fxxt_order') . " orders2 where orders2.from_user=member.from_user and member.uniacid=orders2.uniacid " . $condition2 . ") ordermoney FROM " . tablename('wwx_fxxt_member') . " member WHERE member.uniacid = '{$_W['uniacid']}' ORDER BY " . $sortname . " DESC limit 100"); if (!empty($_GPC['memberrankingEXP01'])) { $report = "memberranking"; require_once 'report.php'; die; } include $this->template('memberranking'); die; } if ($op == 'fansrange') { $list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_member') . " WHERE uniacid = :uniacid order by flagcount desc limit 30", array(':uniacid' => $_W['uniacid'])); include $this->template('fansrange'); die; } if ($op == 'productsalestatistics') { $list = pdo_fetchall("SELECT goods.*,0 as cpersent,(select sum(ordergoods.total) from " . tablename('wwx_fxxt_order_goods') . " ordergoods where ordergoods.goodsid=goods.id and ordergoods.uniacid=goods.uniacid ) salescount from " . tablename('wwx_fxxt_goods') . " goods where goods.uniacid = :uniacid order by (salescount/goods.viewcount) desc ", array(':uniacid' => $_W['uniacid'])); foreach ($list as $id => $displayorder) { $list[$id]['cpersent'] = round($list[$id]['salescount'] / ($list[$id]['viewcount'] == 0 ? 1 : $list[$id]['viewcount']) * 100, 2); if (empty($list[$id]['viewcount'])) { $list[$id]['viewcount'] = 0; } if (empty($list[$id]['salescount'])) { $list[$id]['salescount'] = 0; } if (empty($list[$id]['cpersent'])) { $list[$id]['cpersent'] = 0; } } include $this->template('productsalestatistics'); die; } if ($op == 'userincreasestatistics') { $usertype = $_GPC['usertype'] ? $_GPC['usertype'] : 'user'; $condtitiontime = ''; $conditionflag = ''; if ($usertype == 'agent') { $conditionflag = ' and flag=1'; $condtitiontime = 'flagtime'; } else { $condtitiontime = 'createtime'; } $list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_member') . " WHERE uniacid = '{$_W['uniacid']}' "); $nowyear = intval(date('Y', time())); $nowmonth = intval(date('m', time())); $years = array(array('year' => $nowyear - 3, 'checked' => 0), array('year' => $nowyear - 2, 'checked' => 0), array('year' => $nowyear - 1, 'checked' => 0), array('year' => $nowyear, 'checked' => 1)); $nowday = date('t', time()); $chartdata1 = array(); $index = 0; for ($dateindex = 7; $dateindex >= 0; $dateindex--) { if ($dateindex == 0) { $time = date("Y-m-d", time()); } else { $time = date("Y-m-d", strtotime("-" . $dateindex . " day")); } $start_time = strtotime($time . " 00:00:01"); $end_time = strtotime($time . " 23:59:59"); $chart1data = pdo_fetch("SELECT count(*) as counts,'" . $time . "' as dates FROM " . tablename('wwx_fxxt_member') . " WHERE uniacid = '{$_W['uniacid']}' {$conditionflag} and " . $condtitiontime . ">=" . $start_time . " and " . $condtitiontime . "<=" . $end_time); $chartdata1[$index]['counts'] = $chart1data['counts']; $chartdata1[$index]['dates'] = $chart1data['dates']; $chartdata1[$index]['index'] = $index; $index = $index + 1; } $index = 0; $chartdata2 = array(); $dropMonthForYaer = $_GPC['dropMonthForYaer'] ? $_GPC['dropMonthForYaer'] : $nowyear; $dropMonthForYaer = intval($dropMonthForYaer); $selectmonthSale = $_GPC['selectmonthSale'] ? $_GPC['selectmonthSale'] : $nowmonth; $lastday = date('t', strtotime($dropMonthForYaer . "-" . $selectmonthSale . "-1")); foreach ($years as $id => $displayorder) { if ($years[$id]['year'] == $dropMonthForYaer) { $years[$id]['checked'] = 1; } else { $years[$id]['checked'] = 0; } } for ($dateindex = 1; $dateindex <= $lastday; $dateindex++) { $time = $dropMonthForYaer . "-" . $selectmonthSale . "-" . $dateindex; $start_time = strtotime($time . " 00:00:01"); $end_time = strtotime($time . " 23:59:59"); $chart1data = pdo_fetch("SELECT count(*) as counts,'" . $time . "' as dates FROM " . tablename('wwx_fxxt_member') . " WHERE uniacid = '{$_W['uniacid']}' {$conditionflag} and " . $condtitiontime . ">=" . $start_time . " and " . $condtitiontime . "<=" . $end_time); $chartdata2[$index]['counts'] = $chart1data['counts']; $chartdata2[$index]['dates'] = $chart1data['dates']; $chartdata2[$index]['index'] = $index; $index = $index + 1; } $index = 0; $chartdata3 = array(); $dropMonthForYaer2 = $_GPC['dropMonthForYaer2'] ? $_GPC['dropMonthForYaer2'] : $nowyear; $dropMonthForYaer2 = intval($dropMonthForYaer2); $years2 = array(array('year' => $nowyear - 3, 'checked' => 0), array('year' => $nowyear - 2, 'checked' => 0), array('year' => $nowyear - 1, 'checked' => 0), array('year' => $nowyear, 'checked' => 1)); foreach ($years2 as $id => $displayorder) { if ($years2[$id]['year'] == $dropMonthForYaer2) { $years2[$id]['checked'] = 1; } else { $years2[$id]['checked'] = 0; } } for ($dateindex = 1; $dateindex <= 12; $dateindex++) { $lastday = date('t', strtotime($dropMonthForYaer2 . "-" . $dateindex . "-1")); $time = $dropMonthForYaer2 . "-" . $dateindex; $start_time = strtotime($time . "-1" . " 00:00:01"); $end_time = strtotime($time . "-" . $lastday . " 23:59:59"); $chart1data = pdo_fetch("SELECT count(*) as counts,'" . $time . "' as dates FROM " . tablename('wwx_fxxt_member') . " WHERE uniacid = '{$_W['uniacid']}' {$conditionflag} and " . $condtitiontime . ">=" . $start_time . " and " . $condtitiontime . "<=" . $end_time); $chartdata3[$index]['counts'] = $chart1data['counts']; $chartdata3[$index]['dates'] = $chart1data['dates']; $chartdata3[$index]['index'] = $index; $index = $index + 1; } include $this->template('userincreasestatistics'); die; } if ($op == 'saletargets') { $allorderprice = pdo_fetchcolumn("SELECT sum(cast(price as decimal(8,2))) FROM " . tablename('wwx_fxxt_order') . " WHERE status=3 and uniacid = '{$_W['uniacid']}' "); $allordercount = pdo_fetchcolumn("SELECT count(id) FROM " . tablename('wwx_fxxt_order') . " WHERE status=3 and uniacid = '{$_W['uniacid']}' "); $allmembercount = pdo_fetchcolumn("SELECT count(*) FROM " . tablename('wwx_fxxt_member') . " WHERE uniacid = '{$_W['uniacid']}' "); $allorderviewcount = pdo_fetchcolumn("SELECT sum(cast(viewcount as decimal(8,0))) FROM " . tablename('wwx_fxxt_goods') . " WHERE uniacid = '{$_W['uniacid']}' "); $haveordermembercount = pdo_fetchcolumn("SELECT count(member.id) from " . tablename('wwx_fxxt_member') . " member WHERE member.uniacid = '{$_W['uniacid']}' and member.from_user in (SELECT orders.from_user FROM" . tablename('wwx_fxxt_order') . " orders where orders.uniacid = '{$_W['uniacid']}' group by orders.from_user)"); include $this->template('saletargets'); die; } if ($op == 'productsaleranking') { $condition = ""; if (!empty($_GPC['time']['start']) && !empty($_GPC['time']['end'])) { $start_time = strtotime($_GPC['time']['start'] . " 00:00:01"); $end_time = strtotime($_GPC['time']['end'] . " 23:59:59"); } else { $start_time = strtotime(date('Y-m-01 00:00:01', time())); $end_time = strtotime(date('Y-m-t 23:59:59', time())); } $condition = " and ordergoods.createtime>=" . $start_time . " and ordergoods.createtime<=" . $end_time; $list = pdo_fetchall("SELECT goods.*,0 as cpersent,(select sum((ordergoods.price*ordergoods.total)) from " . tablename('wwx_fxxt_order_goods') . " ordergoods where ordergoods.goodsid=goods.id and ordergoods.uniacid=goods.uniacid {$condition}) salesmoney,(select sum(ordergoods.total) from " . tablename('wwx_fxxt_order_goods') . " ordergoods where ordergoods.goodsid=goods.id and ordergoods.uniacid=goods.uniacid {$condition}) salescount from " . tablename('wwx_fxxt_goods') . " goods where goods.uniacid = :uniacid order by salesmoney desc", array(':uniacid' => $_W['uniacid'])); if (!empty($_GPC['productsalerankingEXP01'])) { $report = "productsaleranking"; require_once 'report.php'; die; } include $this->template('productsaleranking'); die; } if ($op == 'saledetails') { $condition = ""; $pindex = max(1, intval($_GPC['page'])); $psize = 20; if (!empty($_GPC['time']['start']) && !empty($_GPC['time']['end'])) { $start_time = strtotime($_GPC['time']['start'] . " 00:00:01"); $end_time = strtotime($_GPC['time']['end'] . " 23:59:59"); } else { $start_time = strtotime(date('Y-m-01 00:00:01', time())); $end_time = strtotime(date('Y-m-t 23:59:59', time())); } $condition = " and orders.createtime>=" . $start_time . " and orders.createtime<=" . $end_time; $list = pdo_fetchall("SELECT ordergoods.price,ordergoods.total,(select title from " . tablename('wwx_fxxt_goods') . " goods where ordergoods.goodsid=goods.id) titles,orders.createtime,orders.ordersn from " . tablename('wwx_fxxt_order_goods') . " ordergoods left join " . tablename('wwx_fxxt_order') . " orders on orders.id=ordergoods.orderid where orders.uniacid = :uniacid {$condition} order by orders.createtime desc LIMIT " . ($pindex - 1) * $psize . ',' . $psize, array(':uniacid' => $_W['uniacid'])); $total = pdo_fetchcolumn("SELECT count(ordergoods.id) from " . tablename('wwx_fxxt_order_goods') . " ordergoods left join " . tablename('wwx_fxxt_order') . " orders on orders.id=ordergoods.orderid where orders.uniacid = :uniacid {$condition} order by orders.createtime desc", array(':uniacid' => $_W['uniacid'])); $pager = pagination($total, $pindex, $psize); if (!empty($_GPC['saledetailsEXP01'])) { $report = "saledetails"; require_once 'report.php'; die; } include $this->template('saledetails'); die; } if ($op == 'orderstatistics') { $condition = ""; $pindex = max(1, intval($_GPC['page'])); $psize = 20; if (!empty($_GPC['time']['start']) && !empty($_GPC['time']['end'])) { $start_time = strtotime($_GPC['time']['start'] . " 00:00:01"); $end_time = strtotime($_GPC['time']['end'] . " 23:59:59"); } else { $start_time = strtotime(date('Y-m-01 00:00:01', time())); $end_time = strtotime(date('Y-m-t 23:59:59', time())); } $condition = " and t1.createtime>=" . $start_time . " and t1.createtime<=" . $end_time; if (!empty($_GPC['realname'])) { $realname = $_GPC['realname']; $condition .= " and t1.realnamestr='" . $realname . "'"; } if (!empty($_GPC['addressname'])) { $addressname = $_GPC['addressname']; $condition .= " and t1.tdrealname='" . $addressname . "'"; } if (!empty($_GPC['ordersn'])) { $ordersn = $_GPC['ordersn']; $condition .= " and t1.ordersn='" . $ordersn . "'"; } $list = pdo_fetchall("select t1.* from (SELECT orders.status,orders.uniacid,orders.id,orders.createtime,orders.zhifutime,orders.ordersn,orders.price,orders.dispatchprice,orders.paytype,(select member.realname from " . tablename('wwx_fxxt_member') . " member where member.from_user=orders.from_user and orders.uniacid=member.uniacid limit 1 ) realnamestr,(select taddress.realname from " . tablename('wwx_fxxt_address') . " taddress where taddress.id=orders.addressid and orders.uniacid=taddress.uniacid limit 1 ) tdrealname from " . tablename('wwx_fxxt_order') . " orders where orders.uniacid = :uniacid and orders.status=3 order by orders.createtime desc) t1 where t1.uniacid = :uniacid {$condition} LIMIT " . ($pindex - 1) * $psize . ',' . $psize, array(':uniacid' => $_W['uniacid'])); foreach ($list as $id => $displayorder) { $list[$id]['ordergoods'] = pdo_fetchall("SELECT goods.thumb,ordersgoods.price,ordersgoods.total,goods.title,ordersgoods.optionname from " . tablename('wwx_fxxt_order_goods') . " ordersgoods left join " . tablename('wwx_fxxt_goods') . " goods on goods.id=ordersgoods.goodsid where ordersgoods.uniacid = :uniacid and ordersgoods.orderid=:oid order by ordersgoods.createtime desc ", array(':uniacid' => $_W['uniacid'], ':oid' => $list[$id]['id'])); } $total = pdo_fetchcolumn("select count(t1.id) from (SELECT orders.uniacid,orders.id,orders.createtime,orders.zhifutime,orders.ordersn,orders.price,orders.dispatchprice,orders.paytype,(select member.realname from " . tablename('wwx_fxxt_member') . " member where member.from_user=orders.from_user and orders.uniacid=member.uniacid limit 1 ) realnamestr,(select taddress.realname from " . tablename('wwx_fxxt_address') . " taddress where taddress.id=orders.addressid and orders.uniacid=taddress.uniacid limit 1 ) tdrealname from " . tablename('wwx_fxxt_order') . " orders where orders.uniacid = :uniacid and orders.status=3 order by orders.createtime desc) t1 where t1.uniacid = :uniacid {$condition} ", array(':uniacid' => $_W['uniacid'])); $pager = pagination($total, $pindex, $psize); if (!empty($_GPC['orderstatisticsEXP01'])) { $report = "orderstatistics"; require_once 'report.php'; die; } include $this->template('orderstatistics'); die; } } public function doWebSpread() { global $_W, $_GPC; load()->func('tpl'); if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $op = empty($_GPC['op']) ? 'leaflet' : $_GPC['op']; $rulekeywordcount = pdo_fetchcolumn("SELECT count(id) FROM " . tablename('rule_keyword') . " WHERE uniacid=:uniacid and module='wwx_fxxt' and content='二维码'", array(":uniacid" => $_W['uniacid'])); $boolrule = false; if ($rulekeywordcount >= 1) { $boolrule = true; } if ($op == 'checkspreadrule') { if (!empty($_GPC['boolrule'])) { $rulekeywordcount = pdo_fetchall("SELECT rid FROM " . tablename('rule_keyword') . " WHERE uniacid=:uniacid and module='wwx_fxxt' and content='二维码'", array(":uniacid" => $_W['uniacid'])); foreach ($rulekeywordcount as $k => $v) { pdo_delete('rule', array('id' => $v['rid'], 'uniacid' => $_W['uniacid'], 'module' => 'wwx_fxxt')); } pdo_delete('rule_keyword', array('module' => 'wwx_fxxt', 'uniacid' => $_W['uniacid'], 'content' => '二维码')); $insert = array('uniacid' => $_W['uniacid'], 'name' => '二维码(系统维护)', 'module' => 'wwx_fxxt', 'displayorder' => 0, 'status' => 1); pdo_insert('rule', $insert); $rid = pdo_insertid(); $insert = array('uniacid' => $_W['uniacid'], 'rid' => $rid, 'module' => 'wwx_fxxt', 'content' => '二维码', 'type' => 1, 'displayorder' => 0, 'status' => 1); pdo_insert('rule_keyword', $insert); message('设置分销专属二维码成功,请进入自定义菜单绑定关键字\'二维码\'!', referer(), 'success'); } else { if ($boolrule == true) { $rulekeywordcount = pdo_fetchall("SELECT rid FROM " . tablename('rule_keyword') . " WHERE uniacid=:uniacid and module='wwx_fxxt' and content='二维码'", array(":uniacid" => $_W['uniacid'])); foreach ($rulekeywordcount as $k => $v) { pdo_delete('rule', array('id' => $v['rid'], 'uniacid' => $_W['uniacid'], 'module' => 'wwx_fxxt')); } pdo_delete('rule_keyword', array('module' => 'wwx_fxxt', 'uniacid' => $_W['uniacid'], 'content' => '二维码')); message('系统已去除分销专属\'二维码\'关键字触发', referer(), 'success'); } } $op = 'leaflet'; } if ($op == 'delete') { pdo_update('wwx_fxxt_channel', array('isdel' => 1, 'createtime' => time()), array('channel' => $_GPC['channel'], "uniacid" => $_W['uniacid'])); message('删除成功', referer(), 'success'); } else { if ($op == 'leaflet') { $mylist = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_channel') . " WHERE uniacid=:uniacid and isdel=0", array(":uniacid" => $_W['uniacid'])); } else { if ($op == 'active') { $channel = intval($_GPC['channel']); pdo_update('wwx_fxxt_channel', array('active' => 0), array('uniacid' => $_W['uniacid'])); pdo_update('wwx_fxxt_channel', array('createtime' => time()), array('uniacid' => $_W['uniacid'], 'channel' => $channel)); pdo_update('wwx_fxxt_channel', array('createtime' => time(), 'active' => 1), array('uniacid' => $_W['uniacid'], 'channel' => $channel)); message('设定当前活跃传单成功', referer(), 'success'); } else { if ($op == 'post') { $item = array(); if (!empty($_GPC['channel'])) { $item = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_channel') . " WHERE uniacid=:uniacid AND channel=:channel", array(":uniacid" => $_W['uniacid'], ":channel" => $_GPC['channel'])); } $item = $this->decode_channel_param($item, $item['bgparam']); if (checksubmit('submit')) { $tagArr = explode('.', $_GPC['bg']); $tagArr = end($tagArr); if (strcasecmp('jpg', $tagArr) != 0) { message('传单背景图必须是jpg格式。不支持png等其他格式。', referer(), 'error'); } $bgparam = $this->encode_channel_param($_GPC); $msgtype = empty($_GPC['msgtype']) ? 1 : $_GPC['msgtype']; if (!empty($_GPC['channel'])) { pdo_delete('wwx_fxxt_qr', array('uniacid' => $_W['uniacid'])); pdo_update('wwx_fxxt_channel', array('title' => $_GPC['title'], 'createtime' => time(), 'bg' => $_GPC['bg'], 'msgtype' => $msgtype, 'bgparam' => $bgparam, 'notice' => $_GPC['notice']), array('channel' => $_GPC['channel'], 'uniacid' => $_W['uniacid'])); pdo_update('wwx_fxxt_qr', array('expiretime' => 1), array('channel' => $_GPC['channel'])); message('更新成功', referer(), 'success'); } else { $list_count = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('wwx_fxxt_channel') . " WHERE uniacid=:uniacid and isdel=0", array(":uniacid" => $_W['uniacid'])); $active = $list_count == 0; pdo_insert('wwx_fxxt_channel', array('title' => $_GPC['title'], 'createtime' => time(), 'notice' => $_GPC['notice'], 'msgtype' => $msgtype, 'bg' => $_GPC['bg'], 'bgparam' => $bgparam, 'active' => $active, 'isdel' => 0, 'uniacid' => $_W['uniacid'])); message('新建成功', $this->createWebUrl('spread', array('op' => 'leaflet')), 'success'); } } } else { if ($op == 'log') { $pindex = max(1, intval($_GPC['page'])); $psize = 100; $my_follows_sql = "select l.createtime createtime, l.nickname, l.avatar, v.openid,v.follower_count from " . tablename('mc_members') . " l,(select a.uid, a.openid, count(b.from_user) follower_count from " . tablename('mc_mapping_fans') . " a left join " . tablename('wwx_fxxt_share_history') . " b on b.uniacid=a.uniacid and b.sharemid=(select x.id from " . tablename('wwx_fxxt_member') . " x where x.uniacid=:uniacid and x.from_user=a.openid limit 1) and b.from_user!=a.openid where a.openid in( select from_user from " . tablename('mc_mapping_fans') . " where uniacid=:uniacid and follow=1 UNION (select from_user from " . tablename('wwx_fxxt_share_history') . " where uniacid=:uniacid ) UNION (select m.from_user from " . tablename('wwx_fxxt_member') . " m where m.uniacid = :uniacid))) v where l.uid=v.uid group by v.openid ORDER BY follower_count DESC LIMIT " . ($pindex - 1) * $psize . ",{$psize}"; $mylist = pdo_fetchall($my_follows_sql, array(':uniacid' => $_W['uniacid'])); if (!empty($mylist)) { $total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('mc_mapping_fans') . " a, " . tablename('mc_members') . " b WHERE a.uniacid=:uniacid and a.uid=b.uid", array(':uniacid' => $_W['uniacid'])); $pager = pagination($total, $pindex, $psize); } } else { if ($op == 'user') { $from_user = $_GPC['from_user']; $fans = fans_search($from_user, array('nickname', 'createtime', 'credit1')); $myheadimg = pdo_fetchcolumn('SELECT avatar FROM ' . tablename('mc_mapping_fans') . " a, " . tablename('mc_members') . " b WHERE a.uniacid = :uniacid AND a.openid = :openid and a.uid=b.uid LIMIT 1", array(':uniacid' => $_W['uniacid'], ':openid' => $from_user)); $fans['avatar'] = $myheadimg; $mylist = pdo_fetchall("select d.createtime d.createtime, d.nickname, d.avatar from " . tablename('mc_members') . " d,(SELECT b.uid uid FROM " . tablename('wwx_fxxt_share_history') . " a LEFT JOIN " . tablename('mc_mapping_fans') . " b ON a.uniacid=b.uniacid and a.from_user = b.openid WHERE a.sharemid = (select id from " . tablename('wwx_fxxt_member') . " c where c.from_user=:leader and c.uniacid=:uniacid limit 1) and a.from_user!=:leader AND a.uniacid=:uniacid) e where d.uid=e.uid ", array(':leader' => $from_user, ':uniacid' => $_W['uniacid'])); } else { message('error!', '', 'error'); } } } } } } include $this->template('spread'); } public function doWebAward() { global $_W, $_GPC; load()->func('tpl'); if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display'; if ($operation == 'post') { $award_id = intval($_GPC['award_id']); if (!empty($award_id)) { $item = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_credit_award') . " WHERE award_id = :award_id", array(':award_id' => $award_id)); if (empty($item)) { message('抱歉,兑换商品不存在或是已经删除!', '', 'error'); } } if (checksubmit('submit')) { if (empty($_GPC['title'])) { message('请输入兑换商品名称!'); } if (empty($_GPC['credit_cost'])) { message('请输入兑换商品需要消耗的积分数量!'); } if (empty($_GPC['price'])) { message('请输入商品实际价值!'); } $credit_cost = intval($_GPC['credit_cost']); $price = intval($_GPC['price']); $amount = intval($_GPC['amount']); $data = array('uniacid' => $_W['uniacid'], 'title' => $_GPC['title'], 'logo' => $_GPC['logo'], 'deadline' => $_GPC['deadline'], 'amount' => $amount, 'credit_cost' => $credit_cost, 'price' => $price, 'content' => $_GPC['content'], 'createtime' => TIMESTAMP); if (!empty($award_id)) { pdo_update('wwx_fxxt_credit_award', $data, array('award_id' => $award_id)); } else { pdo_insert('wwx_fxxt_credit_award', $data); } message('商品更新成功!', create_url('site/entry/award', array('m' => 'wwx_fxxt', 'op' => 'display')), 'success'); } } else { if ($operation == 'delete') { $award_id = intval($_GPC['award_id']); $row = pdo_fetch("SELECT award_id FROM " . tablename('wwx_fxxt_credit_award') . " WHERE award_id = :award_id", array(':award_id' => $award_id)); if (empty($row)) { message('抱歉,商品' . $award_id . '不存在或是已经被删除!'); } pdo_delete('wwx_fxxt_credit_award', array('award_id' => $award_id)); message('删除成功!', referer(), 'success'); } else { if ($operation == 'display') { $condition = ''; $list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_credit_award') . " WHERE uniacid = '{$_W['uniacid']}' {$condition} ORDER BY createtime DESC"); } } } include $this->template('credit_award'); } public function doWebCredit() { global $_W, $_GPC; load()->func('tpl'); if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display'; $modules = 'credit'; if ($operation == 'delete') { $id = intval($_GPC['id']); $row = pdo_fetch("SELECT id FROM " . tablename('wwx_fxxt_credit_request') . " WHERE id = :id", array(':id' => $id)); if (empty($row)) { message('抱歉,编号为' . $id . '的兑换请求不存在或是已经被删除!'); } pdo_delete('wwx_fxxt_credit_request', array('id' => $id)); message('删除成功!', referer(), 'success'); } else { if ($operation == 'display') { $condition = ''; $sql = "SELECT * FROM " . tablename('wwx_fxxt_credit_award') . " as t1," . tablename('wwx_fxxt_credit_request') . "as t2 WHERE t1.award_id=t2.award_id AND t1.uniacid = '{$_W['uniacid']}' ORDER BY t2.createtime DESC"; $list = pdo_fetchall($sql); $ar = pdo_fetchall($sql, array(), 'from_user'); $arrayAR = array_keys($ar); $fans = pdo_fetchall("SELECT fans.openid as from_user,member.realname as realname,mobile,credit1,residedist FROM " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member WHERE fans.uid=member.uid and fans.openid IN ('" . implode("','", $arrayAR) . "') and member.uniacid = '{$_W['uniacid']}'", array(), 'from_user'); } } include $this->template('credit_request'); } public function doWebDispatch() { global $_W, $_GPC; if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $setting = uni_setting($_W['uniacid'], array('payment', 'creditbehaviors')); $operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display'; $operExp = $_GPC['do']; if ($operation == 'display') { $list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_dispatch') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY displayorder "); } elseif ($operation == 'post') { $id = intval($_GPC['id']); if (checksubmit('submit')) { $data = array('uniacid' => $_W['uniacid'], 'displayorder' => intval($_GPC['displayorder']), 'dispatchtype' => intval($_GPC['dispatchtype']), 'dispatchname' => $_GPC['dispatchname'], 'express' => $_GPC['express'], 'firstprice' => $_GPC['firstprice'], 'firstweight' => $_GPC['firstweight'], 'secondprice' => $_GPC['secondprice'], 'secondweight' => $_GPC['secondweight'], 'description' => $_GPC['description']); if (!empty($id)) { pdo_update('wwx_fxxt_dispatch', $data, array('id' => $id)); } else { pdo_insert('wwx_fxxt_dispatch', $data); $id = pdo_insertid(); } message('更新配送方式成功!', $this->createWebUrl('dispatch', array('op' => 'display')), 'success'); } $dispatch = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_dispatch') . " WHERE id = '{$id}' and uniacid = '{$_W['uniacid']}'"); $express = pdo_fetchall("select * from " . tablename('wwx_fxxt_express') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY displayorder DESC"); } elseif ($operation == 'delete') { $id = intval($_GPC['id']); $dispatch = pdo_fetch("SELECT id FROM " . tablename('wwx_fxxt_dispatch') . " WHERE id = '{$id}' AND uniacid=" . $_W['uniacid'] . ""); if (empty($dispatch)) { message('抱歉,配送方式不存在或是已经被删除!', $this->createWebUrl('dispatch', array('op' => 'display')), 'error'); } pdo_delete('wwx_fxxt_dispatch', array('id' => $id)); message('配送方式删除成功!', $this->createWebUrl('dispatch', array('op' => 'display')), 'success'); } else { message('请求方式不存在'); } include $this->template('dispatch', TEMPLATE_INCLUDEPATH, true); } public function doWebExpress() { global $_W, $_GPC; if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display'; $operExp = $_GPC['do']; if ($operation == 'display') { $list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_express') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY displayorder asc"); } elseif ($operation == 'post') { $id = intval($_GPC['id']); if (checksubmit('submit')) { if (empty($_GPC['express_name'])) { message('抱歉,请输入物流名称!'); } $data = array('uniacid' => $_W['uniacid'], 'displayorder' => intval($_GPC['displayorder']), 'express_name' => $_GPC['express_name'], 'express_url' => $_GPC['express_url'], 'express_area' => $_GPC['express_area']); if (!empty($id)) { unset($data['parentid']); pdo_update('wwx_fxxt_express', $data, array('id' => $id)); } else { pdo_insert('wwx_fxxt_express', $data); $id = pdo_insertid(); } message('更新物流成功!', $this->createWebUrl('express', array('op' => 'display')), 'success'); } $express = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_express') . " WHERE id = '{$id}' and uniacid = '{$_W['uniacid']}'"); } elseif ($operation == 'delete') { $id = intval($_GPC['id']); $express = pdo_fetch("SELECT id FROM " . tablename('wwx_fxxt_express') . " WHERE id = '{$id}' AND uniacid=" . $_W['uniacid'] . ""); if (empty($express)) { message('抱歉,物流方式不存在或是已经被删除!', $this->createWebUrl('express', array('op' => 'display')), 'error'); } pdo_delete('wwx_fxxt_express', array('id' => $id)); message('物流方式删除成功!', $this->createWebUrl('express', array('op' => 'display')), 'success'); } else { message('请求方式不存在'); } include $this->template('express', TEMPLATE_INCLUDEPATH, true); } public function doWebAdv() { global $_W, $_GPC; load()->func('tpl'); if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $modules = 'adv'; $operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display'; if ($operation == 'display') { $list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_adv') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY displayorder DESC"); } elseif ($operation == 'post') { $id = intval($_GPC['id']); if (checksubmit('submit')) { $data = array('uniacid' => $_W['uniacid'], 'advname' => $_GPC['advname'], 'link' => $_GPC['link'], 'enabled' => intval($_GPC['enabled']), 'displayorder' => intval($_GPC['displayorder'])); if (!empty($_GPC['thumb'])) { $data['thumb'] = $_GPC['thumb']; } if (!empty($id)) { pdo_update('wwx_fxxt_adv', $data, array('id' => $id)); } else { pdo_insert('wwx_fxxt_adv', $data); $id = pdo_insertid(); } message('更新幻灯片成功!', $this->createWebUrl('adv', array('op' => 'display')), 'success'); } $adv = pdo_fetch("select * from " . tablename('wwx_fxxt_adv') . " where id=:id and uniacid=:uniacid limit 1", array(":id" => $id, ":uniacid" => $_W['uniacid'])); } elseif ($operation == 'delete') { $id = intval($_GPC['id']); $adv = pdo_fetch("SELECT id FROM " . tablename('wwx_fxxt_adv') . " WHERE id = '{$id}' AND uniacid=" . $_W['uniacid'] . ""); if (empty($adv)) { message('抱歉,幻灯片不存在或是已经被删除!', $this->createWebUrl('adv', array('op' => 'display')), 'error'); } pdo_delete('wwx_fxxt_adv', array('id' => $id)); message('幻灯片删除成功!', $this->createWebUrl('adv', array('op' => 'display')), 'success'); } else { message('请求方式不存在'); } include $this->template('adv', TEMPLATE_INCLUDEPATH, true); } public function doWebPromotion() { global $_W, $_GPC; load()->func('tpl'); if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $modules = 'promotion'; $operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display'; if ($operation == 'display') { $prolist = pdo_fetchall('select * from ' . tablename('wwx_fxxt_pormotions') . "where uniacid='{$_W['uniacid']}' order by id desc"); } else { if ($operation == 'post') { $id = intval($_GPC['id']); if (checksubmit('submit')) { $data = array('uniacid' => $_W['uniacid'], 'promoteType' => $_GPC['radioPromotionType'], 'condition' => (int) intval($_GPC['promotionmoney']), 'pname' => $_GPC['promotionname'], 'starttime' => strtotime($_GPC['start_time']), 'endtime' => strtotime($_GPC['end_time']), 'description' => $GPC['description']); if ($data['starttime'] > $data['endtime']) { message('设置错误,开始时间不能大于结束时间', $this->createWebUrl('promotion', array('op' => 'post', 'stup' => 1)), 'error'); return; } if (empty($data['pname'])) { message('请输入活动名称', $this->createWebUrl('promotion', array('op' => 'post', 'stup' => 1)), 'error'); return; } if (empty($data['condition'])) { message('请输入满额(件)数量', $this->createWebUrl('promotion', array('op' => 'post', 'stup' => 1)), 'error'); return; } if (!empty($id)) { pdo_update('wwx_fxxt_pormotions', $data, array('id' => $id, 'uniacid' => $_W['uniacid'])); } else { pdo_insert('wwx_fxxt_pormotions', $data); $id = pdo_insertid(); } message('更新促销活动内容成功!', $this->createWebUrl('promotion', array('op' => 'display'), 'success')); } $pro = pdo_fetch('select * from ' . tablename('wwx_fxxt_pormotions') . 'where id=:id and uniacid=:uniacid limit 1', array(':id' => $id, ':uniacid' => $_W['uniacid'])); } else { if ($operation == 'delete') { $id = intval($_GPC['id']); $pro = pdo_fetch('select id from' . tablename('wwx_fxxt_pormotions') . "where id='{$id}' and uniacid=" . $_W['uniacid'] . ''); if (empty($pro['id'])) { message('促销活动不存在或者已被删除', $this->createWebUrl('promotion', array('op' => 'display', 'stup' => 2)), 'error'); } pdo_delete('wwx_fxxt_pormotions', array('id' => $id, 'uniacid' => $_W['uniacid'])); message('删除成功', $this->createWebUrl('promotion', array('op' => 'display', 'stup' => 2)), 'success'); } else { message('请求方法不存在'); } } } include $this->template('promotion', TEMPLATE_INCLUDEPATH, true); } public function doWebRules() { global $_W, $_GPC; load()->func('tpl'); if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $uniacid = $_W['uniacid']; $op = $operation = $_GPC['op'] ? $_GPC['op'] : 'display'; $theone = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_rules') . " WHERE uniacid = :uniacid", array(':uniacid' => $_W['uniacid'])); $id = $theone['id']; if (checksubmit('submit')) { $insert = array('uniacid' => $_W['uniacid'], 'terms' => htmlspecialchars_decode($_GPC['terms']), 'commtime' => 0, 'ischeck' => $_GPC['ischeck'], 'createtime' => TIMESTAMP); if (empty($id)) { pdo_insert('wwx_fxxt_rules', $insert); !pdo_insertid() ? message('保存失败, 请稍后重试.', 'error') : ''; } else { if (pdo_update('wwx_fxxt_rules', $insert, array('id' => $id)) === false) { message('更新失败, 请稍后重试.', 'error'); } } message('更新成功!', $this->createWebUrl('rules'), 'success'); } include $this->template('rules'); } public function doWebPrinter() { global $_W, $_GPC; load()->func('file'); load()->func('tpl'); if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $op = !empty($_GPC['op']) ? $_GPC['op'] : 'express'; if ($op == 'preview_express') { $id = intval($_GPC['id']); $entry = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_printer') . ' WHERE uniacid = :uniacid and printertype=1 and id=:id', array(':uniacid' => $_W['uniacid'], ':id' => $id)); $previewtmp = $entry['printerconfig']; for ($i = 1; $i < 3; $i++) { $previewtmp = str_replace('购货人', '张三同志', $previewtmp); $previewtmp = str_replace('收货姓名', '张三', $previewtmp); $previewtmp = str_replace('收货电话', '021-88885555', $previewtmp); $previewtmp = str_replace('收货地址', '上海市青浦区xxxxx', $previewtmp); $previewtmp = str_replace('支付方式', '在线支付', $previewtmp); $previewtmp = str_replace('配送方式', '申通快递', $previewtmp); $previewtmp = str_replace('发货单号', '115345585233', $previewtmp); $previewtmp = str_replace('订单编号', '8774675533', $previewtmp); $previewtmp = str_replace('下单时间', date('Y-m-d H:i:s', time() - 1000), $previewtmp); $previewtmp = str_replace('订单金额', '920.0', $previewtmp); $previewtmp = str_replace('配送费用', '10.0', $previewtmp); $previewtmp = str_replace('商品金额', '910.0', $previewtmp); $previewtmp = str_replace('打印时间', date('Y-m-d H:i:s', time()), $previewtmp); $previewtmp = str_replace('寄件公司', '寄件公司X', $previewtmp); $previewtmp = str_replace('寄件人', '寄件人A', $previewtmp); $previewtmp = str_replace('寄件地址', '上海xxxxxx', $previewtmp); $previewtmp = str_replace('寄件电话', '13333333333', $previewtmp); $previewtmp = str_replace('年', date('Y', time()), $previewtmp); $previewtmp = str_replace('月', date('m', time()), $previewtmp); $previewtmp = str_replace('日', date('d', time()), $previewtmp); } include $this->template('printer_express_print'); die; } if ($op == 'express') { $list = pdo_fetchall('SELECT * FROM ' . tablename('wwx_fxxt_printer') . ' WHERE uniacid = :uniacid and printertype=1', array(':uniacid' => $_W['uniacid'])); include $this->template('printer_express'); die; } if ($op == 'set_express') { $id = intval($_GPC['id']); if (empty($id)) { message('请选择一条记录'); } pdo_update('wwx_fxxt_printer', array('isdefault' => 0), array('uniacid' => $_W['uniacid'], 'printertype' => 1)); pdo_update('wwx_fxxt_printer', array('isdefault' => 1), array('uniacid' => $_W['uniacid'], 'id' => $id, 'printertype' => 1)); message('设置成功!', referer(), 'success'); } if ($op == 'priview_express') { $id = intval($_GPC['id']); $entry = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_printer') . ' WHERE uniacid = :uniacid and id=:id', array(':uniacid' => $_W['uniacid'], ':id' => $id)); include $this->template('printer_express_print'); } if ($op == 'create_express') { if (checksubmit('delpic')) { $entry = array(); $entry['expresscode'] = $_GPC['expresscode']; $entry['name'] = $_GPC['print_name']; $entry['printerconfig'] = $_GPC['printerconfig']; include $this->template('printer_express_detail'); die; } if (checksubmit('picupload')) { $entry = array(); if (!empty($_FILES['expresspic']['tmp_name'])) { file_delete($_GPC['old_expresspic']); $expresspic = file_upload($_FILES['expresspic']); $entry['expresspic'] = $expresspic['path']; } $entry['print_from_compy'] = $_GPC['print_from_compy']; $entry['print_from_uname'] = $_GPC['print_from_uname']; $entry['print_from_addr'] = $_GPC['print_from_addr']; $entry['print_from_tel'] = $_GPC['print_from_tel']; $entry['expresscode'] = $_GPC['expresscode']; $entry['name'] = $_GPC['print_name']; $entry['printerconfig'] = $_GPC['printerconfig']; include $this->template('printer_express_detail'); die; } if (checksubmit('submit')) { $expressconfig = array(); $expressconfig['print_from_compy'] = $_GPC['print_from_compy']; $expressconfig['print_from_uname'] = $_GPC['print_from_uname']; $expressconfig['print_from_addr'] = $_GPC['print_from_addr']; $expressconfig['print_from_tel'] = $_GPC['print_from_tel']; pdo_insert('wwx_fxxt_printer', array('expresspic' => $_GPC['old_expresspic'], 'expressconfig' => iserializer($expressconfig), 'printerconfig' => $_GPC['printerconfig'], 'expresscode' => $_GPC['expresscode'], 'expressdaxiao' => $_GPC['expressdaxiao'], 'expressziti' => $_GPC['expressziti'], 'isdefault' => 0, 'createtime' => time(), 'printertype' => 1, 'uniacid' => $_W['uniacid'], 'name' => $_GPC['print_name'])); message('保存成功!', $this->createWebUrl('printer', array('op' => 'express')), 'success'); } include $this->template('printer_express_detail'); die; } if ($op == 'edit_express') { $id = intval($_GPC['id']); if (empty($id)) { message('请选择一条记录'); } if (checksubmit('picupload')) { $data = array('expresscode' => $_GPC['expresscode'], 'expressdaxiao' => $_GPC['expressdaxiao'], 'expressziti' => $_GPC['expressziti'], 'printerconfig' => $_GPC['printerconfig'], 'createtime' => time(), 'printertype' => 1, 'name' => $_GPC['print_name']); $expressconfig = array(); $expressconfig['print_from_compy'] = $_GPC['print_from_compy']; $expressconfig['print_from_uname'] = $_GPC['print_from_uname']; $expressconfig['print_from_addr'] = $_GPC['print_from_addr']; $expressconfig['print_from_tel'] = $_GPC['print_from_tel']; $data['expressconfig'] = iserializer($expressconfig); if (!empty($_FILES['expresspic']['tmp_name'])) { file_delete($_GPC['old_expresspic']); $expresspic = file_upload($_FILES['expresspic']); $data['expresspic'] = $expresspic['path']; } pdo_update('wwx_fxxt_printer', $data, array('id' => $id, 'uniacid' => $_W['uniacid'])); header('Location:' . $this->createWebUrl('printer', array('op' => 'edit_express', 'id' => $id))); die; } if (checksubmit('submit')) { $expressconfig = array(); $expressconfig['print_from_compy'] = $_GPC['print_from_compy']; $expressconfig['print_from_uname'] = $_GPC['print_from_uname']; $expressconfig['print_from_addr'] = $_GPC['print_from_addr']; $expressconfig['print_from_tel'] = $_GPC['print_from_tel']; pdo_update('wwx_fxxt_printer', array('expresscode' => $_GPC['expresscode'], 'expressdaxiao' => $_GPC['expressdaxiao'], 'expressziti' => $_GPC['expressziti'], 'printerconfig' => $_GPC['printerconfig'], 'createtime' => time(), 'expressconfig' => iserializer($expressconfig), 'printertype' => 1, 'name' => $_GPC['print_name']), array('id' => $id, 'uniacid' => $_W['uniacid'])); message('保存成功!', referer(), 'success'); } $entry = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_printer') . ' WHERE uniacid = :uniacid and id=:id', array(':uniacid' => $_W['uniacid'], ':id' => $id)); if (!empty($entry['expressconfig'])) { $t_expressconfig = iunserializer($entry['expressconfig']); $entry['print_from_compy'] = $t_expressconfig['print_from_compy']; $entry['print_from_uname'] = $t_expressconfig['print_from_uname']; $entry['print_from_addr'] = $t_expressconfig['print_from_addr']; $entry['print_from_tel'] = $t_expressconfig['print_from_tel']; } if (checksubmit('delpic')) { file_delete($_GPC['old_expresspic']); $data = array(); $data['expresspic'] = ''; pdo_update('wwx_fxxt_printer', $data, array('id' => $id, 'uniacid' => $_W['uniacid'])); } include $this->template('printer_express_detail'); die; } if ($op == 'del_express') { $id = intval($_GPC['id']); if (empty($id)) { message('请选择一条记录'); } pdo_delete('wwx_fxxt_printer', array('uniacid' => $_W['uniacid'], 'id' => $id, 'printertype' => 1)); message('删除成功!', $this->createWebUrl('printer', array('op' => 'express')), 'success'); die; } if ($op == 'set_normal') { $id = intval($_GPC['id']); if (empty($id)) { message('请选择一条记录'); } pdo_update('wwx_fxxt_printer', array('isdefault' => 0), array('uniacid' => $_W['uniacid'], 'printertype' => 0)); pdo_update('wwx_fxxt_printer', array('isdefault' => 1), array('uniacid' => $_W['uniacid'], 'id' => $id, 'printertype' => 0)); message('设置成功!', referer(), 'success'); } if ($op == 'create_normal' || $op == 'printview_normal' || $op == 'edit_normal') { if (checksubmit('printview') || $op == 'printview_normal') { echo ' '; $previewtmp = $_GPC['previewtmp']; if ($op == 'printview_normal') { $entry = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_printer') . ' WHERE id=:id', array(':id' => $_GPC['id'])); $previewtmp = $entry['printerconfig']; } for ($i = 1; $i < 3; $i++) { $previewtmp = str_replace('{buyer}', '张三同志', $previewtmp); $previewtmp = str_replace('{consignee}', '张三', $previewtmp); $previewtmp = str_replace('{tel}', '021-88885555', $previewtmp); $previewtmp = str_replace('{address}', '上海市青浦区xxxxx', $previewtmp); $previewtmp = str_replace('{pay_type}', '在线支付', $previewtmp); $previewtmp = str_replace('{dispatch_type}', '申通快递', $previewtmp); $previewtmp = str_replace('{dispatch_sn}', '115345585233', $previewtmp); $previewtmp = str_replace('{order_sn}', '8774675533', $previewtmp); $previewtmp = str_replace('{time}', date('Y-m-d H:i:s', time() - 1000), $previewtmp); $previewtmp = str_replace('{order_price}', '920.0', $previewtmp); $previewtmp = str_replace('{dispatch_price}', '10.0', $previewtmp); $previewtmp = str_replace('{good_price}', '910.0', $previewtmp); $previewtmp = str_replace('{print_time}', date('Y-m-d H:i:s', time()), $previewtmp); $good_line = '
商品名称 价格 数量 小计
 商务翻领休闲直筒修身男装夹克 ¥300.00元  ¥600.00元 
 淑女粉色九分袖獭兔毛外套 ¥310.00元  ¥310.00元 
商品总金额:¥910.00元
'; $previewtmp = str_replace('{good_line}', $good_line, $previewtmp); } echo htmlspecialchars_decode($previewtmp); echo ''; die; } } if ($op == 'create_normal') { if (checksubmit('submit')) { pdo_insert('wwx_fxxt_printer', array('printerconfig' => $_GPC['gmsptz'], 'isdefault' => 0, 'createtime' => time(), 'printertype' => 0, 'uniacid' => $_W['uniacid'], 'name' => $_GPC['print_name'])); message('保存成功!', $this->createWebUrl('printer', array('op' => 'normal')), 'success'); } if (checksubmit('预设模板')) { $entry['printerconfig'] = ''; $entry['printerconfig'] = $this->curl_printerconfig(1); } include $this->template('printer_normal_detail'); die; } if ($op == 'edit_normal') { $id = intval($_GPC['id']); if (empty($id)) { message('请选择一条记录'); } $entry = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_printer') . ' WHERE uniacid = :uniacid and id=:id', array(':uniacid' => $_W['uniacid'], ':id' => $id)); if (checksubmit('submit')) { pdo_update('wwx_fxxt_printer', array('printerconfig' => $_GPC['gmsptz'], 'createtime' => time(), 'printertype' => 0, 'name' => $_GPC['print_name']), array('id' => $id, 'uniacid' => $_W['uniacid'])); message('保存成功!', referer(), 'success'); } if (checksubmit('预设模板')) { $entry['printerconfig'] = ''; $entry['printerconfig'] = $this->curl_printerconfig(1); } include $this->template('printer_normal_detail'); die; } if ($op == 'del_normal') { $id = intval($_GPC['id']); if (empty($id)) { message('请选择一条记录'); } pdo_delete('wwx_fxxt_printer', array('uniacid' => $_W['uniacid'], 'id' => $id, 'printertype' => 0)); message('删除成功!', $this->createWebUrl('printer', array('op' => 'normal')), 'success'); die; } if ($op == 'normal') { $list = pdo_fetchall('SELECT * FROM ' . tablename('wwx_fxxt_printer') . ' WHERE uniacid = :uniacid and printertype=0', array(':uniacid' => $_W['uniacid'])); include $this->template('printer_normal'); die; } include $this->template('printer'); } public function doWebMessagetmp() { global $_W, $_GPC; load()->func('tpl'); if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $uniacid = $_W['uniacid']; $settings = $this->module['config']; $op = $operation = $_GPC['op'] ? $_GPC['op'] : 'display'; $salers = array(); if (isset($settings['msgtmp']['openid'])) { if (!empty($settings['msgtmp']['openid'])) { $openids = array(); $strsopenids = explode(',', $settings['msgtmp']['openid']); foreach ($strsopenids as $openid) { $openids[] = '\'' . $openid . '\''; } $salers = pdo_fetchall("select member2.id, member2.nickname, member.avatar, fans.openid from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " member2 where fans.openid in (" . implode(',', $openids) . ") and fans.uid=member.uid and fans.openid=member2.from_user and fans.uniacid={$_W['uniacid']}"); } } $msgtemplate = array(); $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'zndxxtz')); if (!empty($tmsgtemplate['id'])) { $msgtemplate['zndxxtz'] = $tmsgtemplate['template']; $msgtemplate['zndxxtzenable'] = $tmsgtemplate['tenable']; } $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'gmsptz')); if (!empty($tmsgtemplate['id'])) { $msgtemplate['gmsptz'] = $tmsgtemplate['template']; $msgtemplate['gmsptzenable'] = $tmsgtemplate['tenable']; } $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'tjrtz')); if (!empty($tmsgtemplate['id'])) { $msgtemplate['tjrtz'] = $tmsgtemplate['template']; $msgtemplate['tjrtzenable'] = $tmsgtemplate['tenable']; } $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'tjrtzewm')); if (!empty($tmsgtemplate['id'])) { $msgtemplate['tjrtzewm'] = $tmsgtemplate['template']; $msgtemplate['tjrtzewmenable'] = $tmsgtemplate['tenable']; } $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'tjrtzdl')); if (!empty($tmsgtemplate['id'])) { $msgtemplate['tjrtzdl'] = $tmsgtemplate['template']; $msgtemplate['tjrtzdlenable'] = $tmsgtemplate['tenable']; } $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'xjdlshtz')); if (!empty($tmsgtemplate['id'])) { $msgtemplate['xjdlshtz'] = $tmsgtemplate['template']; $msgtemplate['xjdlshtzenable'] = $tmsgtemplate['tenable']; } $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'yjsqtz')); if (!empty($tmsgtemplate['id'])) { $msgtemplate['yjsqtz'] = $tmsgtemplate['template']; $msgtemplate['yjsqtzenable'] = $tmsgtemplate['tenable']; } $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'sjytktz')); if (!empty($tmsgtemplate['id'])) { $msgtemplate['sjytktz'] = $tmsgtemplate['template']; $msgtemplate['sjytktzenable'] = $tmsgtemplate['tenable']; } if (checksubmit('submit') || checksubmit('submit2')) { $settings['noticeemail'] = $_GPC['noticeemail']; $settings['noticeewechat'] = $_GPC['noticeewechat']; $settings['msgtmp']['neworder'] = $_GPC['neworder']; $settings['msgtmp']['newtype'] = $_GPC['newtype']; $settings['msgtmp']['openid'] = ''; if (is_array($_GPC['openids'])) { $settings['msgtmp']['openid'] = implode(',', $_GPC['openids']); } $this->saveSettings($settings); $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'zndxxtz')); if (empty($tmsgtemplate['id'])) { $datas = array('uniacid' => $_W['uniacid'], 'tkey' => 'zndxxtz', 'template' => $_GPC['zndxxtz'], 'tenable' => intval($_GPC['zndxxtzenable'])); pdo_insert('wwx_fxxt_msg_template', $datas); } else { $datas = array('template' => $_GPC['zndxxtz'], 'tenable' => intval($_GPC['zndxxtzenable'])); pdo_update('wwx_fxxt_msg_template', $datas, array('id' => $tmsgtemplate['id'])); } $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'gmsptz')); if (empty($tmsgtemplate['id'])) { $datas = array('uniacid' => $_W['uniacid'], 'tkey' => 'gmsptz', 'template' => $_GPC['gmsptz'], 'tenable' => intval($_GPC['gmsptzenable'])); pdo_insert('wwx_fxxt_msg_template', $datas); } else { $datas = array('template' => $_GPC['gmsptz'], 'tenable' => intval($_GPC['gmsptzenable'])); pdo_update('wwx_fxxt_msg_template', $datas, array('id' => $tmsgtemplate['id'])); } $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'tjrtz')); if (empty($tmsgtemplate['id'])) { $datas = array('uniacid' => $_W['uniacid'], 'tkey' => 'tjrtz', 'template' => $_GPC['tjrtz'], 'tenable' => intval($_GPC['tjrtzenable'])); pdo_insert('wwx_fxxt_msg_template', $datas); } else { $datas = array('template' => $_GPC['tjrtz'], 'tenable' => intval($_GPC['tjrtzenable'])); pdo_update('wwx_fxxt_msg_template', $datas, array('id' => $tmsgtemplate['id'])); } $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'tjrtzewm')); if (empty($tmsgtemplate['id'])) { $datas = array('uniacid' => $_W['uniacid'], 'tkey' => 'tjrtzewm', 'template' => $_GPC['tjrtzewm'], 'tenable' => intval($_GPC['tjrtzewmenable'])); pdo_insert('wwx_fxxt_msg_template', $datas); } else { $datas = array('template' => $_GPC['tjrtzewm'], 'tenable' => intval($_GPC['tjrtzewmenable'])); pdo_update('wwx_fxxt_msg_template', $datas, array('id' => $tmsgtemplate['id'])); } $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'tjrtzdl')); if (empty($tmsgtemplate['id'])) { $datas = array('uniacid' => $_W['uniacid'], 'tkey' => 'tjrtzdl', 'template' => $_GPC['tjrtzdl'], 'tenable' => intval($_GPC['tjrtzdlenable'])); pdo_insert('wwx_fxxt_msg_template', $datas); } else { $datas = array('template' => $_GPC['tjrtzdl'], 'tenable' => intval($_GPC['tjrtzdlenable'])); pdo_update('wwx_fxxt_msg_template', $datas, array('id' => $tmsgtemplate['id'])); } $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'xjdlshtz')); if (empty($tmsgtemplate['id'])) { $datas = array('uniacid' => $_W['uniacid'], 'tkey' => 'xjdlshtz', 'template' => $_GPC['xjdlshtz'], 'tenable' => intval($_GPC['xjdlshtzenable'])); pdo_insert('wwx_fxxt_msg_template', $datas); } else { $datas = array('template' => $_GPC['xjdlshtz'], 'tenable' => intval($_GPC['xjdlshtzenable'])); pdo_update('wwx_fxxt_msg_template', $datas, array('id' => $tmsgtemplate['id'])); } $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'yjsqtz')); if (empty($tmsgtemplate['id'])) { $datas = array('uniacid' => $_W['uniacid'], 'tkey' => 'yjsqtz', 'template' => $_GPC['yjsqtz'], 'tenable' => intval($_GPC['yjsqtzenable'])); pdo_insert('wwx_fxxt_msg_template', $datas); } else { $datas = array('template' => $_GPC['yjsqtz'], 'tenable' => intval($_GPC['yjsqtzenable'])); pdo_update('wwx_fxxt_msg_template', $datas, array('id' => $tmsgtemplate['id'])); } $tmsgtemplate = pdo_fetch('SELECT * FROM ' . tablename('wwx_fxxt_msg_template') . ' WHERE uniacid = :uniacid and tkey = :key', array(':uniacid' => $_W['uniacid'], ':key' => 'sjytktz')); if (empty($tmsgtemplate['id'])) { $datas = array('uniacid' => $_W['uniacid'], 'tkey' => 'sjytktz', 'template' => $_GPC['sjytktz'], 'tenable' => intval($_GPC['sjytktzenable'])); pdo_insert('wwx_fxxt_msg_template', $datas); } else { $datas = array('template' => $_GPC['sjytktz'], 'tenable' => intval($_GPC['sjytktzenable'])); pdo_update('wwx_fxxt_msg_template', $datas, array('id' => $tmsgtemplate['id'])); } message('更新成功!', $this->createWebUrl('messagetmp'), 'success'); } include $this->template('messagetmp'); } public function doWebNotice() { global $_GPC, $_W; load()->func('tpl'); if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $operation = empty($_GPC['op']) ? 'display' : $_GPC['op']; $operation = in_array($operation, array('display')) ? $operation : 'display'; $cfg = $this->module['config']; if ($_GPC['op'] == 'delete') { $id = intval($_GPC['id']); if (empty($id)) { message('请选择一条记录'); } pdo_delete('wwx_fxxt_feedback', array('uniacid' => $_W['uniacid'], 'id' => $id)); message('删除成功!', $this->createWebUrl('notice', array('op' => 'display')), 'success'); die; } if ($_GPC['op'] == 'deleteout') { pdo_delete('wwx_fxxt_feedback', array('uniacid' => $_W['uniacid'])); message('全部清空成功!', $this->createWebUrl('notice', array('op' => 'display')), 'success'); die; } $adminmsg = ''; if (!empty($cfg['noticeewechat'])) { $adminopenid = pdo_fetch('SELECT from_user FROM ' . tablename('wwx_fxxt_member') . " WHERE uniacid = :uniacid AND id = :id LIMIT 1", array(':uniacid' => $_W['uniacid'], ':id' => $cfg['noticeewechat'])); if (!empty($adminopenid['from_user'])) { $adminmsg = $adminopenid['from_user']; } } $pindex = max(1, intval($_GPC['page'])); $psize = 30; $starttime = empty($_GPC['starttime']) ? strtotime('-1 month') : strtotime($_GPC['starttime']); $endtime = empty($_GPC['endtime']) ? TIMESTAMP : strtotime($_GPC['endtime']) + 86399; $where .= " WHERE `uniacid` = :uniacid AND `createtime` >= :starttime AND `createtime` < :endtime"; $paras = array(':uniacid' => $_W['uniacid'], ':starttime' => $starttime, ':endtime' => $endtime); $keyword = $_GPC['keyword']; $where .= empty($keyword) ? '' : " AND (( reason LIKE '%" . trim($keyword) . "%' ) OR ( solution LIKE '%" . trim($keyword) . "%' )) "; $type = empty($_GPC['type']) ? -1 : $_GPC['type']; $type = intval($type); if ($type != -1) { $where .= " AND `type`=:type"; $paras[':type'] = $type; } $status = empty($_GPC['status']) ? 5 : intval($_GPC['status']); $status = intval($status); if ($status != 5) { $where .= " AND `status` = :status"; $paras[':status'] = $status; } $total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('wwx_fxxt_feedback') . $where, $paras); $list = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_feedback') . $where . " ORDER BY id DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize, $paras); $pager = pagination($total, $pindex, $psize); include $this->template('notice'); } public function doWebRedActivity() { global $_W, $_GPC; if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $modulePublic = '../addons/wwx_fxxt/style/static/'; $foo = $_GPC['foo']; $foos = array('list', 'create', 'modify', 'delete', 'records'); $foo = in_array($foo, $foos) ? $foo : 'list'; require_once WWX_FXXT_ROOT . '/class/Activity.class.php'; if ($foo == 'create') { if ($_W['ispost']) { $input = $_GPC; $input['rules'] = htmlspecialchars_decode($input['rules']); $input['start'] = strtotime($input['time']['start'] . ':00'); $input['end'] = strtotime($input['time']['end'] . ':59'); $input['share'] = serialize($input['share']); $input['limit'] = serialize($input['limit']); if ($input['type'] == 'game') { $input['tag'] = serialize($input['game']); } elseif ($input['type'] == 'shared') { $input['tag'] = serialize($input['shared']); } else { $input['tag'] = serialize($input['tag']); } $gifts = array(); foreach ($input['gifts']['id'] as $k => $v) { $gifts[] = array('gift' => $v, 'quantity' => $input['gifts']['quantity'][$k], 'rate' => $input['gifts']['rate'][$k]); } $a = new Activity(); $ret = $a->create($input, $gifts); if (is_error($ret)) { message($ret['message']); } else { message('成功创建活动', $this->createWebUrl('redactivity')); } } $activity = array(); $time = array(); $time['start'] = date('Y-m-d 00:00'); $time['end'] = date('Y-m-d 15:00'); $activity['gifts'] = array(); $activity['type'] = 'shared'; load()->func('tpl'); include $this->template('redactivity_form'); } if ($foo == 'modify') { $id = $_GPC['id']; $id = intval($id); $a = new Activity(); $activity = $a->getOne($id); if (empty($activity)) { $this->error('访问错误'); } if ($_W['ispost']) { $input = $_GPC; $input['rules'] = htmlspecialchars_decode($input['rules']); $input['start'] = strtotime($input['time']['start'] . ':00'); $input['end'] = strtotime($input['time']['end'] . ':59'); $input['share'] = serialize($input['share']); $input['limit'] = serialize($input['limit']); if ($input['type'] == 'game') { $input['tag'] = serialize($input['game']); } elseif ($input['type'] == 'shared') { $input['tag'] = serialize($input['shared']); } else { $input['tag'] = serialize($input['tag']); } $gifts = array(); foreach ($input['gifts']['id'] as $k => $v) { $gifts[] = array('gift' => $v, 'quantity' => $input['gifts']['quantity'][$k], 'rate' => $input['gifts']['rate'][$k]); } $a = new Activity(); $ret = $a->modify($id, $input, $gifts); if (is_error($ret)) { message($ret['message']); } else { message('成功编辑活动', $this->createWebUrl('redactivity')); } } $time = array(); $time['start'] = date('Y-m-d H:i', $activity['start']); $time['end'] = date('Y-m-d H:i', $activity['end']); if ($activity['type'] == 'game') { $game = $activity['tag']; } elseif ($activity['type'] == 'shared') { $shared = $activity['tag']; } load()->func('tpl'); include $this->template('redactivity_form'); } if ($foo == 'records') { $id = $_GPC['id']; $id = intval($id); $a = new Activity(); $activity = $a->getOne($id); if (empty($activity)) { $this->error('访问错误'); } $filters = array(); $filters['activity'] = $id; $filters['nickname'] = $_GPC['nickname']; $pindex = intval($_GPC['page']); $pindex = max($pindex, 1); $psize = 20; $total = 0; $ds = $a->getRecords($filters, $pindex, $psize, $total); $pager = pagination($total, $pindex, $psize); include $this->template('redactivity_records'); } if ($foo == 'delete') { $id = $_GPC['id']; $id = intval($id); $a = new Activity(); $ret = $a->remove($id); if (is_error($ret)) { message($ret['message']); } else { message('操作成功', $this->createWebUrl('redactivity')); } } if ($foo == 'list') { $a = new Activity(); $ds = $a->getAll(array()); if (is_array($ds)) { foreach ($ds as &$row) { $url = $this->createMobileUrl('redactivity', array('actid' => $row['actid'])); $row['surl'] = $url; $url = substr($url, 2); $url = $_W['siteroot'] . 'app/' . $url; $row['url'] = $url; $row['count'] = $a->calcCount($row['actid']); } unset($row); } include $this->template('redactivity_list'); } } public function doWebRedGifts() { global $_W, $_GPC; if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $modulePublic = '../addons/wwx_fxxt/style/static/'; $foo = $_GPC['foo']; $foos = array('list', 'create', 'modify', 'delete', 'search'); $foo = in_array($foo, $foos) ? $foo : 'list'; require_once WWX_FXXT_ROOT . '/class/Gift.class.php'; if ($foo == 'search') { $fuzzy = $_GPC['fuzzy']; $filters = array(); $filters['title'] = $fuzzy; $g = new Gift(); $ds = $g->getAll($filters, 1, 20); $rs = array(); if (!empty($ds)) { foreach ($ds as $row) { $rs[] = array_elements(array('id', 'type', 'title'), $row); } } die(json_encode($rs)); } if ($foo == 'create') { if ($_W['ispost']) { $input = array_elements(array('title', 'type', 'remark'), $_GPC); $input['remark'] = htmlspecialchars_decode($input['remark']); if ($input['type'] == 'cash') { $input['tag'] = serialize($_GPC['cash']); } else { $input['tag'] = ''; } $g = new Gift(); $ret = $g->create($input); if (is_error($ret)) { message($ret['message']); } else { message('成功保存礼品信息', $this->createWebUrl('redgifts')); } } $entity = array(); $entity['type'] = 'cash'; $entity['tag'] = array(); load()->func('tpl'); include $this->template('redgifts_form'); } if ($foo == 'modify') { $id = $_GPC['id']; $g = new Gift(); $entity = $g->getOne($id); if (empty($entity)) { message('访问错误'); } if ($_W['ispost']) { $input = array_elements(array('title', 'type', 'remark'), $_GPC); $input['remark'] = htmlspecialchars_decode($input['remark']); if ($input['type'] == 'cash') { $input['tag'] = serialize($_GPC['cash']); } else { $input['tag'] = ''; } $g = new Gift(); $ret = $g->modify($id, $input); if (is_error($ret)) { message($ret['message']); } else { message('成功保存礼品信息', $this->createWebUrl('redgifts')); } } load()->func('tpl'); include $this->template('redgifts_form'); } if ($foo == 'delete') { $id = $_GPC['id']; $g = new Gift(); $g->remove($id); message('成功删除礼品信息', $this->createWebUrl('redgifts')); } if ($foo == 'list') { $a = new Gift(); $ds = $a->getAll(array()); include $this->template('redgifts_list'); } } public function doWebRedQr() { global $_GPC; $raw = @base64_decode($_GPC['raw']); if (!empty($raw)) { include WWX_FXXT_ROOT . '/class/phpqrcode.php'; QRcode::png($raw, false, QR_ECLEVEL_Q, 4); } } public function doWebRedEntry() { global $_W; if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } include $this->template('redentry'); } public function doWebRedSend() { global $_W, $_GPC; require_once WWX_FXXT_ROOT . '/class/Fans.class.php'; $f = new Fans(); $uid = intval($_GPC['uid']); $user = $f->getOne($uid); if (empty($user)) { die('错误的访问'); } $ret = $this->redsend($user); if (is_error($ret)) { die($ret['message']); } else { die('success'); } } public function doWebQuery() { global $_W, $_GPC; $kwd = trim($_GPC['keyword']); $params = array(); $condition = ' '; if (!empty($kwd)) { $condition .= " AND ((member2.nickname LIKE '%" . trim($kwd) . "%') or (member2.realname LIKE '%" . trim($kwd) . "%') or (member2.mobile LIKE '%" . trim($kwd) . "%'))"; } $ds = pdo_fetchall("select member2.id, member2.nickname, member2.realname, member.avatar, member.mobile, fans.openid from " . tablename('mc_mapping_fans') . " fans, " . tablename('mc_members') . " member, " . tablename('wwx_fxxt_member') . " member2 where fans.uniacid={$_W['uniacid']} {$condition} and fans.uid=member.uid and fans.openid=member2.from_user order by member2.createtime desc"); include $this->template('query'); } public function doWebQcookie() { global $_W; if (!$_W['isfounder']) { message('只有创始人才可以使用此功能.'); } message('清空数据库成功!', '', 'success'); } }