<?php

//decode by http://mofang.52jscn.com/
defined('IN_IA') or exit('Access Denied');
require_once IA_ROOT . "/addons/hc_groups/inc/model.class.php";
class Hc_groupsModuleWxapp extends WeModuleWxapp
{
	public function doPageTest()
	{
		global $_GPC, $_W;
		$errno = 0;
		$message = '返回消息';
		$data = array();
		return $this->result($errno, $message, $data);
	}
	public function doPageHome()
	{
		global $_GPC, $_W;
		return $this->result(0, '获取成功', $result['openid']);
	}
	public function doPageGetopenid()
	{
		global $_GPC, $_W;
		$code = $_GPC['code'];
		$account = pdo_get('account_wxapp', array('uniacid' => $_GPC['i']));
		$url = 'https://api.weixin.qq.com/sns/jscode2session?appid=' . $account['key'] . '&secret=' . $account['secret'] . '&js_code=' . $code . '&grant_type=authorization_code';
		$result = ihttp_get($url);
		$result = json_decode($result['content'], true);
		return $this->result(0, '获取成功', $result['openid']);
	}
	public function doPageGetuserinfo()
	{
		global $_GPC, $_W;
		if (empty($_GPC['openid'])) {
			return $this->result(1, '参数错误，缺少OPENID');
		}
		$ishave = pdo_get('hcgroup_member', array('openid' => $_GPC['openid'], 'uniacid' => $_GPC['i']));
		if (empty($ishave)) {
			$arr['createtime'] = time();
			$arr['uniacid'] = $_GPC['i'];
			empty($_GPC['openid']) ? '' : ($arr['openid'] = $_GPC['openid']);
			empty($_GPC['nickname']) ? '' : ($arr['nickname'] = $_GPC['nickname']);
			empty($_GPC['gender']) ? '' : ($arr['gender'] = $_GPC['gender']);
			empty($_GPC['country']) ? '' : ($arr['country'] = $_GPC['country']);
			empty($_GPC['province']) ? '' : ($arr['province'] = $_GPC['province']);
			empty($_GPC['city']) ? '' : ($arr['city'] = $_GPC['city']);
			empty($_GPC['avatar']) ? '' : ($arr['avatar'] = $_GPC['avatar']);
			$result = pdo_insert('hcgroup_member', $arr);
			if (!empty($result)) {
				$uid = pdo_insertid();
			}
		} else {
			$uid = $ishave['id'];
		}
		return $this->result(0, '操作成功', $uid);
	}
	public function doPageGetheader()
	{
		global $_GPC, $_W;
		$banner = pdo_getall('hcgroup_adv', array('enabled' => 1, 'uniacid' => $_GPC['i']), array(), '', 'displayorder asc');
		foreach ($banner as $key => $val) {
			$banner[$key]['thumb'] = $_W['attachurl'] . $val['thumb'];
		}
		$nav = pdo_getall('hcgroup_nav', array('parentid' => 0, 'status' => 1, 'uniacid' => $_GPC['i']), array(), '', 'displayorder asc', array(1, 12));
		foreach ($nav as $key => $val) {
			$nav[$key]['icon'] = $_W['attachurl'] . $val['icon'];
		}
		return $this->result(0, '操作成功', array('banner' => $banner, 'nav' => $nav));
	}
	public function doPageNavcategorygoods()
	{
		global $_W, $_GPC;
		$parentid = $_GPC['parentid'];
		if ($_GPC['types'] == 'category') {
			$category = pdo_getall('hcgroup_nav', array('parentid' => $parentid, 'status' => 1, 'uniacid' => $_GPC['i']), array(), '', 'displayorder asc');
			foreach ($category as $k => $v) {
				$category[$k]['icon'] = $_W['attachurl'] . $v['icon'];
			}
			return $this->result(0, '操作成功', $category);
		} else {
			if ($_GPC['types'] == 'goods') {
				$pageindex = max(1, intval($_GPC['page']));
				$pagesize = 10;
				$goodslist = pdo_getslice('hcgroup_goods', array('nav_ccate' => $parentid, 'status' => 1, 'uniacid' => $_GPC['i']), array($pageindex, $pagesize), $total, array('goods_id', 'title', 'groupprice', 'thumb', 'sales_num', 'void_num', 'is_luck', 'luckdrawprice'), 'displayorder asc');
				$page = pagination($total, $pageindex, $pagesize);
				foreach ($goodslist as $k1 => $v1) {
					if ($v1['is_luck'] == 1) {
						$goodslist[$k1]['groupprice'] = $v1['luckdrawprice'];
					}
					$goodslist[$k1]['thumb'] = $_W['attachurl'] . $v1['thumb'];
					$goodslist[$k1]['sales_num'] = $v1['sales_num'] + $v1['void_num'];
					unset($goodslist[$k1]['void_num']);
				}
				return $this->result(0, '操作成功', $goodslist);
			}
		}
	}
	public function doPageGetindexgoods()
	{
		global $_W, $_GPC;
		$where['uniacid'] = $_GPC['i'];
		$where['is_rec'] = 1;
		$where['status'] = 1;
		$pageindex = max(1, intval($_GPC['page']));
		$pagesize = 10;
		$goods = pdo_getslice('hcgroup_goods', $where, array($pageindex, $pagesize), $total, array(), '', 'goods_id desc');
		$theme = pdo_fetchall("SELECT theme FROM " . tablename('hcgroup_goods') . " WHERE uniacid = :uniacid AND is_rec=1 group by theme order by theme desc limit 0,3", array(':uniacid' => $_GPC['i']));
		foreach ($goods as $key => $val) {
			if ($val['is_luck'] == 1) {
				$goods[$key]['groupprice'] = $val['luckdrawprice'];
			}
			if (($key + 1) / 10 <= 3 && ($key + 1) % 10 == 0) {
				$goods['theme'] = pdo_getall('hcgroup_goods', array('theme' => $theme[0]['theme'], 'is_rec' => 1, 'uniacid' => $_GPC['i']), array(), '', 'goods_id desc', array(1, 10));
				foreach ($goods['theme'] as $k => $v) {
					$goods['theme'][$k]['thumb'] = $_W['attachurl'] . $v['thumb'];
				}
			}
			$goods[$key]['thumb'] = $_W['attachurl'] . $val['thumb'];
		}
		$page = pagination($total, $pageindex, $pagesize);
		return $this->result(0, '操作成功', $goods);
	}
	public function doPageGetthemegoods()
	{
		global $_W, $_GPC;
		$theme = $_GPC['theme'];
		if (empty($theme)) {
			return $this->result(1, '主题为空');
		}
		$pageindex = max(1, intval($_GPC['page']));
		$pagesize = 10;
		$goods = pdo_getslice('hcgroup_goods', array('theme LIKE' => '%' . $theme . '%', 'is_rec' => 1, 'uniacid' => $_GPC['i']), array($pageindex, $pagesize), $total, array(), '', 'goods_id desc');
		foreach ($goods as $key => $val) {
			$goods[$key]['thumb'] = $_W['attachurl'] . $val['thumb'];
		}
		$page = pagination($total, $pageindex, $pagesize);
		return $this->result(0, '操作成功', $goods);
	}
	public function doPageGetindexcategory()
	{
		global $_W, $_GPC;
		$categorylist = pdo_getall('hcgroup_goods_category', array('parentid' => 0, 'enabled' => 1, 'uniacid' => $_GPC['i']), array('id', 'name'), '', 'displayorder ASC');
		foreach ($categorylist as $key => $val) {
			$children = pdo_getall('hcgroup_goods_category', array('parentid' => $val['id'], 'enabled' => 1, 'uniacid' => $_GPC['i']), array('id', 'name', 'thumb'), '', 'displayorder ASC', array(1, 7));
			foreach ($children as $k => $v) {
				$children[$k]['thumb'] = $_W['attachurl'] . $v['thumb'];
			}
			$categorylist[$key]['children'] = $children;
		}
		$category[0]['id'] = 0;
		$category[0]['name'] = '首页';
		foreach ($categorylist as $key => $val) {
			$category[$key + 1] = $val;
		}
		return $this->result(0, '操作成功', $category);
	}
	public function doPageGetindexcategorygoods()
	{
		global $_W, $_GPC;
		$parentid = $_GPC['parentid'];
		$category = pdo_getall('hcgroup_goods_category', array('parentid' => $parentid, 'enabled' => 1, 'uniacid' => $_GPC['i']), array('id'), '', 'displayorder ASC');
		foreach ($category as $key => $val) {
			$cate[$key] = $val['id'];
		}
		$cids = implode(',', $cate);
		$pageindex = max(1, intval($_GPC['page']));
		$pagesize = 10;
		$goods = pdo_getslice('hcgroup_goods', array('pcate in' => $cids, 'uniacid' => $_GPC['i']), array($pageindex, $pagesize), $total, array('goods_id', 'title', 'thumb', 'groupprice', 'singleprice', 'sales_num', 'void_num', 'is_luck', 'luckdrawprice'), '', 'displayorder asc');
		foreach ($goods as $key => $val) {
			if ($val['is_luck'] == 1) {
				$goods[$key]['groupprice'] = $val['luckdrawprice'];
			}
			$goods[$key]['thumb'] = $_W['attachurl'] . $val['thumb'];
		}
		$page = pagination($total, $pageindex, $pagesize);
		return $this->result(0, '操作成功', $goods);
	}
	public function doPageGetgoodsdetail()
	{
		global $_W, $_GPC;
		$where['uniacid'] = $_GPC['i'];
		$where['goods_id'] = $_GPC['goods_id'];
		$groupid = $_GPC['groupid'];
		$goods = pdo_get('hcgroup_goods', $where);
		if ($goods['is_luck'] == 1) {
			$goods['groupprice'] = $goods['luckdrawprice'];
		}
		$goods['content'] = html_entity_decode($goods['content'], ENT_QUOTES);
		$goods_image = pdo_getall('hcgroup_goods_image', array('goods_id' => $goods['goods_id']));
		foreach ($goods_image as $k => $v) {
			$goods['thumbs'][$k] = $_W['attachurl'] . $v['thumb'];
		}
		$spec = pdo_getall('hcgroup_goods_spec', array('goods_id' => $goods['goods_id'], 'uniacid' => $_GPC['i']), array(), '', 'spec_id asc');
		foreach ($spec as $key => $val) {
			$spec_item = json_decode($val['spec_item'], true);
			foreach ($spec_item as $k => $v) {
				$spec[$key]['item'][$k] = $v;
				$spec[$key]['item'][$k]['item_thumb'] = $_W['attachurl'] . $v['item_thumb'];
				$k == 0 ? $spec[$key]['item'][$k]['isClick'] = 1 : ($spec[$key]['item'][$k]['isClick'] = 0);
				$k == 0 ? $click[] = $v['item_id'] : '';
			}
			unset($spec[$key]['spec_item']);
		}
		$goods['spec'] = $spec;
		$item = pdo_getall('hcgroup_goods_spec_item', array('goods_id' => $goods['goods_id'], 'uniacid' => $_GPC['i']));
		foreach ($item as $key => $val) {
			$sitem[$val['option_id']] = $val;
			if ($click == explode('_', $val['option_id'])) {
				$sitem[$val['option_id']]['isClick'] = 1;
			} else {
				$sitem[$val['option_id']]['isClick'] = 0;
			}
		}
		$goods['spec_item'] = $sitem;
		$groups = pdo_getall('hcgroup_group', array('goods_id' => $goods['goods_id'], 'buynum !=' => '0', 'status' => 1, 'endtime >' => time(), 'uniacid' => $_GPC['i']), array(), '', 'starttime ASC');
		foreach ($groups as $key => $val) {
			$groups[$key]['head'] = pdo_fetch("SELECT m.nickname,m.avatar FROM " . tablename('hcgroup_order') . " as o left join " . tablename('hcgroup_member') . " as m ON o.user_id=m.id WHERE o.groupid =:groupid AND ishead = 1 AND o.uniacid=:uniacid", array(':groupid' => $val['id'], ':uniacid' => $_GPC['i']));
		}
		$i = 0;
		foreach ($groups as $key => $val) {
			$group[$i][] = $val;
			$goods['grouplist'][] = $val;
			if (($key + 1) % 2 == 0) {
				$i++;
			}
		}
		$goods['group'] = $group;
		$comment = pdo_getall('hcgroup_order_comment', array('goodsid' => $goods['goods_id'], 'uniacid' => $_GPC['i']), array(), '', 'level ASC', array(1, 2));
		foreach ($comment as $key => $val) {
			$oinfo = pdo_get('hcgroup_order', array('id' => $val['orderid']), array('option_title', 'number'));
			$comment[$key]['option_title'] = $oinfo['option_title'];
			$comment[$key]['number'] = $oinfo['number'];
			$comment[$key]['createtime'] = date('Y-m-d', $val['createtime']);
		}
		$goods['comment'] = $comment;
		$goods['groupid'] = $groupid;
		return $this->result(0, '操作成功', $goods);
	}
	public function doPageGetcomment()
	{
		global $_W, $_GPC;
		$goods_id = $_GPC['goods_id'];
		$pageindex = max(1, intval($_GPC['page']));
		$pagesize = 10;
		$list = pdo_getslice('hcgroup_order_comment', array('goodsid' => $goods_id, 'uniacid' => $_GPC['i']), array($pageindex, $pagesize), $total, array(), 'createtime desc');
		foreach ($list as $key => $val) {
			$oinfo = pdo_get('hcgroup_order', array('id' => $val['orderid']), array('option_title', 'number'));
			$list[$key]['option_title'] = $oinfo['option_title'];
			$list[$key]['number'] = $oinfo['number'];
			$list[$key]['createtime'] = date('Y-m-d', $val['createtime']);
			foreach (explode(',', $val['images']) as $k => $v) {
				$img[$k] = $_W['siteroot'] . $v;
			}
			$list[$key]['img'] = $img;
			unset($img);
		}
		$page = pagination($total, $pageindex, $pagesize);
		return $this->result(0, '操作成功', $list);
	}
	public function doPageGetcategory()
	{
		global $_W, $_GPC;
		$parentid = $_GPC['parentid'];
		if ($_GPC['types'] == 'goods') {
			$pageindex = max(1, intval($_GPC['page']));
			$pagesize = 10;
			$goodslist = pdo_getslice('hcgroup_goods', array('pcate' => $parentid, 'status' => 1, 'uniacid' => $_GPC['i']), array($pageindex, $pagesize), $total, array('goods_id', 'title', 'groupprice', 'thumb', 'sales_num', 'void_num'), 'displayorder asc');
			$page = pagination($total, $pageindex, $pagesize);
			foreach ($goodslist as $k1 => $v1) {
				$goodslist[$k1]['thumb'] = $_W['attachurl'] . $v1['thumb'];
				$goodslist[$k1]['sales_num'] = $v1['sales_num'] + $v1['void_num'];
				unset($goodslist[$k1]['void_num']);
			}
			return $this->result(0, '操作成功', $goodslist);
		} else {
			$category = pdo_getall('hcgroup_goods_category', array('parentid' => 0, 'enabled' => 1, 'uniacid' => $_GPC['i']), array('id', 'parentid', 'name', 'thumb'), '', 'displayorder asc');
			foreach ($category as $key => $val) {
				$category[$key]['thumb'] = $_W['attachurl'] . $val['thumb'];
				$children = pdo_getall('hcgroup_goods_category', array('parentid' => $val['id'], 'enabled' => 1, 'uniacid' => $_GPC['i']));
				foreach ($children as $k => $v) {
					$children[$k]['thumb'] = $_W['attachurl'] . $v['thumb'];
				}
				$category[$key]['children'] = $children;
			}
			return $this->result(0, '操作成功', $category);
		}
	}
	public function doPageGetcategorygoods()
	{
		global $_W, $_GPC;
		$parentid = $_GPC['parentid'];
		if ($_GPC['types'] == 'category') {
			$category = pdo_getall('hcgroup_goods_category', array('parentid' => $parentid, 'enabled' => 1, 'uniacid' => $_GPC['i']), array('id', 'parentid', 'name', 'thumb'), '', 'displayorder asc');
			foreach ($category as $k => $v) {
				$category[$k]['thumb'] = $_W['attachurl'] . $v['thumb'];
			}
			return $this->result(0, '操作成功', $category);
		} else {
			if ($_GPC['types'] == 'goods') {
				$pageindex = max(1, intval($_GPC['page']));
				$pagesize = 10;
				$goodslist = pdo_getslice('hcgroup_goods', array('ccate' => $parentid, 'status' => 1, 'uniacid' => $_GPC['i']), array($pageindex, $pagesize), $total, array('goods_id', 'title', 'groupprice', 'thumb', 'sales_num', 'void_num', 'is_luck', 'luckdrawprice'), 'displayorder asc');
				$page = pagination($total, $pageindex, $pagesize);
				foreach ($goodslist as $k1 => $v1) {
					if ($v1['is_luck'] == 1) {
						$goodslist[$k1]['groupprice'] = $v1['luckdrawprice'];
					}
					$goodslist[$k1]['thumb'] = $_W['attachurl'] . $v1['thumb'];
					$goodslist[$k1]['sales_num'] = $v1['sales_num'] + $v1['void_num'];
					unset($goodslist[$k1]['void_num']);
				}
				return $this->result(0, '操作成功', $goodslist);
			}
		}
	}
	public function doPageGetkeywords()
	{
		global $_W, $_GPC;
		$list = pdo_getall('hcgroup_hotsearch', array('uniacid' => $_GPC['i']), array('title'), '', 'num DESC', array(1, 50));
		return $this->result(0, '操作成功', $list);
	}
	public function doPageSearchgoods()
	{
		global $_W, $_GPC;
		$keywords = $_GPC["keywords"];
		if (empty($keywords)) {
			return $this->result(1, '关键词为空', $list);
		}
		$hotsearch = pdo_get('hcgroup_hotsearch', array('title' => $keywords));
		if (count($hotsearch) >= 0) {
			pdo_update('hcgroup_hotsearch', array('num' => $hotsearch['num'] + 1), array('title' => $hotsearch['title'], 'uniacid' => $_GPC['i']));
		} else {
			pdo_insert('hcgroup_hotsearch', array('title' => $keywords, 'num' => 1, 'uniacid' => $_GPC['i']));
		}
		$pageindex = max(1, intval($_GPC['page']));
		$pagesize = 10;
		$list = pdo_getslice('hcgroup_goods', array('title LIKE' => '%' . $keywords . '%', 'uniacid' => $_GPC['i']), array($pageindex, $pagesize), $total, array(), 'displayorder asc');
		foreach ($list as $k1 => $v1) {
			$list[$k1]['thumb'] = $_W['attachurl'] . $v1['thumb'];
		}
		$page = pagination($total, $pageindex, $pagesize);
		return $this->result(0, '操作成功', $list);
	}
	public function doPageJpintoimage()
	{
		global $_W, $_GPC;
		$hotstyle = pdo_getall('hcgroup_goods', array('hotstyle' => 1, 'status' => 1, 'uniacid' => $_GPC['i']), array('goods_id', 'thumb'), '', 'goods_id desc', array(1, 1));
		$hotstyles['thumb'] = $_W['attachurl'] . $hotstyle[0]['thumb'];
		$timelimit = pdo_getall('hcgroup_goods', array('timelimit' => 1, 'status' => 1, 'uniacid' => $_GPC['i']), array('goods_id', 'thumb', 'timelimittime'), '', 'goods_id desc', array(1, 1));
		$timelimits['thumb'] = $_W['attachurl'] . $timelimit[0]['thumb'];
		$timelimits['timelimittime'] = strtotime($timelimit[0]['timelimittime']);
		$data = array('hotstyle' => $hotstyles, 'timelimit' => $timelimits);
		return $this->result(0, '操作成功', $data);
	}
	public function doPageSeaamoy()
	{
		global $_W, $_GPC;
		$types = $_GPC['types'];
		$pageindex = max(1, intval($_GPC['page']));
		$pagesize = 10;
		$list = pdo_getslice('hcgroup_goods', array($types => 1, 'status' => 1, 'uniacid' => $_GPC['i']), array($pageindex, $pagesize), $total, array('goods_id', 'title', 'groupprice', 'thumb', 'sales_num', 'void_num', 'is_luck', 'luckdrawprice'), 'displayorder asc');
		foreach ($list as $k1 => $v1) {
			if ($v1['is_luck'] == 1) {
				$list[$k1]['groupprice'] = $v1['luckdrawprice'];
			}
			$list[$k1]['thumb'] = $_W['attachurl'] . $v1['thumb'];
			$list[$k1]['sales_num'] = $v1['sales_num'] + $v1['void_num'];
			unset($list[$k1]['void_num']);
		}
		$page = pagination($total, $pageindex, $pagesize);
		return $this->result(0, '操作成功', $list);
	}
	public function doPageGlobalhot()
	{
		global $_W, $_GPC;
		$pageindex = max(1, intval($_GPC['page']));
		$pagesize = 10;
		$list = pdo_getslice('hcgroup_goods', array('is_hot' => 1, 'status' => 1, 'uniacid' => $_GPC['i']), array($pageindex, $pagesize), $total, array('goods_id', 'title', 'groupprice', 'thumb', 'peoplenumber', 'sales_num', 'void_num', 'is_luck', 'luckdrawprice'), 'sales_num desc');
		foreach ($list as $k1 => $v1) {
			if ($v1['is_luck'] == 1) {
				$list[$k1]['groupprice'] = $v1['luckdrawprice'];
			}
			$list[$k1]['thumb'] = $_W['attachurl'] . $v1['thumb'];
			$list[$k1]['sales_num'] = $v1['sales_num'] + $v1['void_num'];
			unset($list[$k1]['void_num']);
			$list[$k1]['buynum'] = pdo_getcolumn('hcgroup_group', array('goods_id' => $v1['goods_id'], 'status' => 2), array('count(buynum) as buynum'));
			$groupid = pdo_getcolumn('hcgroup_group', array('goods_id' => $v1['goods_id'], 'status' => 2), array('max(id)'));
			$list[$k1]['user'] = pdo_fetchall("SELECT m.id,m.avatar,o.ishead FROM " . tablename('hcgroup_order') . " as o left join " . tablename('hcgroup_member') . " as m on o.user_id=m.id WHERE o.groupid=:gropupid ", array(':gropupid' => $groupid));
		}
		$page = pagination($total, $pageindex, $pagesize);
		return $this->result(0, '操作成功', $list);
	}
	public function doPageGettimegoods()
	{
		global $_W, $_GPC;
		$pageindex = max(1, intval($_GPC['page']));
		$pagesize = 10;
		$list = pdo_getslice('hcgroup_goods', array('is_new' => 1, 'timelimit' => 1, 'status' => 1, 'uniacid' => $_GPC['i']), array($pageindex, $pagesize), $total, array('goods_id', 'title', 'groupprice', 'thumb', 'sales_num', 'void_num', 'is_luck', 'luckdrawprice'), 'displayorder asc');
		foreach ($list as $k1 => $v1) {
			if ($v1['is_luck'] == 1) {
				$list[$k1]['groupprice'] = $v1['luckdrawprice'];
			}
			$list[$k1]['thumb'] = $_W['attachurl'] . $v1['thumb'];
			$list[$k1]['sales_num'] = $v1['sales_num'] + $v1['void_num'];
			unset($list[$k1]['void_num']);
		}
		$page = pagination($total, $pageindex, $pagesize);
		return $this->result(0, '操作成功', $list);
	}
	public function doPageGetnewgoods()
	{
		global $_W, $_GPC;
		$pageindex = max(1, intval($_GPC['page']));
		$pagesize = 10;
		$list = pdo_getslice('hcgroup_goods', array('is_new' => 1, 'status' => 1, 'uniacid' => $_GPC['i']), array($pageindex, $pagesize), $total, array('goods_id', 'title', 'groupprice', 'thumb', 'peoplenumber', 'sales_num', 'void_num', 'is_luck', 'luckdrawprice'), '', 'goods_id desc,displayorder asc');
		foreach ($list as $k1 => $v1) {
			if ($v1['is_luck'] == 1) {
				$list[$k1]['groupprice'] = $v1['luckdrawprice'];
			}
			$list[$k1]['thumb'] = $_W['attachurl'] . $v1['thumb'];
			$list[$k1]['sales_num'] = $v1['sales_num'] + $v1['void_num'];
			unset($list[$k1]['void_num']);
			$list[$k1]['buynum'] = pdo_getcolumn('hcgroup_group', array('goods_id' => $v1['goods_id'], 'status' => 2), array('count(buynum) as buynum'));
			$groupid = pdo_getcolumn('hcgroup_group', array('goods_id' => $v1['goods_id'], 'status' => 2), array('max(id)'));
			$list[$k1]['user'] = pdo_fetchall("SELECT m.id,m.avatar,o.ishead FROM " . tablename('hcgroup_order') . " as o left join " . tablename('hcgroup_member') . " as m on o.user_id=m.id WHERE o.groupid=:gropupid ", array(':gropupid' => $groupid));
		}
		$page = pagination($total, $pageindex, $pagesize);
		return $this->result(0, '操作成功', $list);
	}
	public function doPageAddorder()
	{
		global $_W, $_GPC;
		$goods_id = trim($_GPC['goods_id']);
		$user_id = trim($_GPC['user_id']);
		$addressid = trim($_GPC['addressid']);
		$number = trim($_GPC['num']);
		$isgroup = $_GPC['isgroup'];
		$groupid = trim($_GPC['groupid']);
		$spec_id = $_GPC['spec_id'];
		if (empty($goods_id) || empty($user_id) || empty($addressid) || empty($number)) {
			return $this->result(1, '缺少参数');
		}
		$goods_info = pdo_get('hcgroup_goods', array('goods_id' => $goods_id, 'uniacid' => $_GPC['i']));
		if ($goods_info['is_luck'] == 1) {
			if ($goods_info['timelimit'] == 1 && strtotime($goods_info['timelimittime']) < time()) {
				return $this->result(1, '活动已结束');
			}
			if (!empty($goods_info['actno'])) {
				$orders = pdo_get('hcgroup_order', array('goods_id' => $goods_id, 'user_id' => $user_id, 'actno' => $goods_info['actno'], 'uniacid' => $_GPC['i'], 'isdelete' => 0));
				if (!empty($orders)) {
					if ($orders['status'] == 1) {
						return $this->result(1, '您有待支付订单未处理哦');
					}
					return $this->result(1, '不能重复参与！');
				}
			}
		}
		if (empty($spec_id)) {
			if ($isgroup == 1) {
				$data['unit_price'] = $goods_info['groupprice'];
			} else {
				$data['unit_price'] = $goods_info['singleprice'];
			}
			if ($goods_info['is_luck'] == 1) {
				$data['unit_price'] = $goods_info['luckdrawprice'];
			}
		} else {
			$price = pdo_get('hcgroup_goods_spec_item', array('id' => $spec_id, 'uniacid' => $_GPC['i']));
			if ($isgroup == 1) {
				$data['unit_price'] = $price['option_marketprice'];
			} else {
				$data['unit_price'] = $price['option_productprice'];
			}
			$data['option_id'] = $price['option_id'];
			$data['option_title'] = $price['option_title'];
		}
		if ($isgroup == 1 && empty($groupid)) {
			$data['ishead'] = 1;
			$refund = pdo_get('hcgroup_set', array('uniacid' => $_GPC['i']), array('autorefund'));
			$endtime = strtotime("+" . $refund['autorefund'] . "days", time());
			if ($goods_info['is_luck'] == 1) {
				$endtime = strtotime($goods_info['timelimittime']);
			}
			$group_data = array('uniacid' => $_GPC['i'], 'goods_id' => $goods_info['goods_id'], 'goods_name' => $goods_info['title'], 'neednum' => $goods_info['peoplenumber'], 'starttime' => time(), 'endtime' => $endtime, 'actno' => $goods_info['actno']);
			$group_info = pdo_insert('hcgroup_group', $group_data);
			if (!empty($group_info)) {
				$groupid = pdo_insertid();
			}
			if ($goods_info['headdiscount'] == 1) {
				$data['discount'] = $goods_info['headdiscountprice'];
			}
		}
		$data['uniacid'] = $_GPC['i'];
		$data['user_id'] = $user_id;
		$data['orderno'] = date('YmdHis') . rand(111111, 999999);
		$data['groupid'] = $groupid;
		$data['goods_id'] = $goods_id;
		$data['number'] = $number;
		$data['addressid'] = $addressid;
		$data['starttime'] = time();
		$data['createtime'] = time();
		$data['fact_amount'] = $data['unit_price'] * $number;
		$data['actno'] = $goods_info['actno'];
		$order = pdo_insert('hcgroup_order', $data);
		if (!empty($order)) {
			$order_id = pdo_insertid();
			$this->pay($order_id, $_GPC['i']);
		}
	}
	public function doPageGopay()
	{
		global $_W, $_GPC;
		$this->pay($_GPC['order_id'], $_GPC['i']);
	}
	public function pay($order_id, $uniacid)
	{
		global $_W, $_GPC;
		$account = pdo_get('account_wxapp', array('uniacid' => $uniacid));
		$appid = $account['key'];
		$wxapp = pdo_get('uni_settings', array('uniacid' => $uniacid));
		$payment = unserialize($wxapp['payment']);
		$mch_id = $payment['wechat']['mchid'];
		$signkey = $payment['wechat']['signkey'];
		$order = pdo_get('hcgroup_order', array('id' => $order_id, 'uniacid' => $uniacid), array('goods_id', 'groupid', 'user_id', 'orderno', 'fact_amount'));
		$goods = pdo_get('hcgroup_goods', array('goods_id' => $order['goods_id'], 'uniacid' => $uniacid), array('title'));
		$user = pdo_get('hcgroup_member', array('id' => $order['user_id'], 'uniacid' => $uniacid), array('openid'));
		$notify_url = $_W['siteroot'] . 'addons/hc_groups/wxpay.php';
		$res = $this->getPrePayOrder($appid, $mch_id, $notify_url, $goods['title'], $order['orderno'], $order['fact_amount'], $user['openid'], $signkey);
		if ($res['return_code'] == 'FAIL') {
			return $this->result(1, '操作失败', $res['return_msg']);
		}
		if ($res['result_code'] == 'FAIL') {
			return $this->result(1, '操作失败', $res['err_code'] . $res['err_code_des']);
		}
		if ($res['return_code'] == 'SUCCESS') {
			$wxdata = $this->getOrder($appid, $res['prepay_id'], $signkey);
			empty($order['groupid']) ? '' : ($wxdata['groupid'] = $order['groupid']);
			pdo_update('hcgroup_order', array('package' => $res['prepay_id']), array('id' => $order_id));
			return $this->result(0, '操作成功', $wxdata);
		} else {
			return $this->result(1, '操作失败');
		}
	}
	public function getPrePayOrder($appid, $mch_id, $notify_url, $body, $out_trade_no, $total_fee, $open_id, $signkey)
	{
		$model = new HcfkModel();
		$url = "https://api.mch.weixin.qq.com/pay/unifiedorder";
		$data["appid"] = $appid;
		$data["body"] = mb_substr($body, 0, 30, 'utf-8');
		$data["mch_id"] = $mch_id;
		$data["nonce_str"] = $model->getRandChar(32);
		$data["notify_url"] = $notify_url;
		$data["out_trade_no"] = $out_trade_no;
		$data["spbill_create_ip"] = $model->get_client_ip();
		$data["total_fee"] = $total_fee * 100;
		$data["trade_type"] = "JSAPI";
		$data["openid"] = $open_id;
		$data["sign"] = $model->getSign($data, $signkey);
		$xml = $model->arrayToXml($data);
		$response = $model->postXmlCurl($xml, $url);
		return $model->xmlstr_to_array($response);
	}
	public function getOrder($appid, $prepayId, $signkey)
	{
		$model = new HcfkModel();
		$data["appId"] = $appid;
		$data["nonceStr"] = $model->getRandChar(32);
		$data["package"] = "prepay_id=" . $prepayId;
		$data['signType'] = "MD5";
		$data["timeStamp"] = time();
		$data["sign"] = $model->getSign1($data, $signkey);
		return $data;
	}
	public function doPageCancelorder()
	{
		global $_W, $_GPC;
		$data['status'] = 7;
		$data['canceltime'] = time();
		pdo_update('hcgroup_order', $data, array('id' => $_GPC['order_id'], 'uniacid' => $_GPC['i']));
		return $this->result(0, '操作成功');
	}
	public function doPageFinishorder()
	{
		global $_W, $_GPC;
		$data['status'] = 4;
		$data['finishtime'] = time();
		pdo_update('hcgroup_order', $data, array('id' => $_GPC['order_id'], 'uniacid' => $_GPC['i']));
		return $this->result(0, '操作成功');
	}
	public function doPageDeleteorder()
	{
		global $_W, $_GPC;
		$data['isdelete'] = 1;
		$data['deletetime'] = time();
		pdo_update('hcgroup_order', $data, array('id' => $_GPC['order_id'], 'uniacid' => $_GPC['i']));
		return $this->result(0, '操作成功');
	}
	public function doPageGetexpressinfo()
	{
		global $_W, $_GPC;
		$order_id = $_GPC['order_id'];
		$info = pdo_get('hcgroup_order', array('id' => $order_id, 'uniacid' => $_GPC['i']), array('goods_id', 'express', 'expresscom', 'expresssn'));
		$url = "http://www.kuaidi100.com/query?type=" . $info['express'] . "&postid=" . $info['expresssn'] . "&id=1&valicode=&temp=" . time();
		$content = file_get_contents($url);
		$express = json_decode($content, true);
		$express['expresscom'] = $info['expresscom'];
		$goods = pdo_get('hcgroup_goods', array('goods_id' => $info['goods_id']), array('thumb'));
		$express['thumb'] = $_W['attachurl'] . $goods['thumb'];
		return $this->result(0, '获取成功', $express);
	}
	public function doPageSharegroup()
	{
		global $_W, $_GPC;
		$groupid = $_GPC['groupid'];
		$list = pdo_get('hcgroup_group', array('id' => $groupid));
		$list['thumb'] = $_W['attachurl'] . pdo_getcolumn('hcgroup_goods', array('goods_id' => $list['goods_id']), array('thumb'));
		$list['starttime'] = date('Y/m/d H:i:s', $list['starttime']);
		$userlist = pdo_fetchall("SELECT m.id,m.nickname,m.avatar,o.ishead,o.goods_id FROM " . tablename('hcgroup_order') . " as o left join " . tablename('hcgroup_member') . " as m ON o.user_id=m.id WHERE o.groupid = :groupid AND o.uniacid=:uniacid order by ishead desc", array(':groupid' => $groupid, ':uniacid' => $_GPC['i']));
		foreach ($userlist as $key => $val) {
			if ($val['ishead'] == 1) {
				$list['headid'] = $val['id'];
			}
		}
		for ($i = 0; $i < $list['neednum']; $i++) {
			$userinfo[$i] = $userlist[$i];
		}
		$list['userlist'] = $userinfo;
		return $this->result(0, '操作成功', $list);
	}
	public function doPageAddresslist()
	{
		global $_W, $_GPC;
		empty($_GPC['isdefault']) ? '' : ($data['isdefault'] = $_GPC['isdefault']);
		empty($_GPC['address_id']) ? '' : ($data['id'] = $_GPC['address_id']);
		$data['uniacid'] = $_GPC['i'];
		$data['user_id'] = $_GPC['user_id'];
		$data['deleted'] = 0;
		$address = pdo_getall('hcgroup_member_address', $data);
		return $this->result(0, '操作成功', $address);
	}
	public function doPageAddaddress()
	{
		global $_W, $_GPC;
		$data['uniacid'] = $_GPC['i'];
		$data['user_id'] = $_GPC['user_id'];
		$data['realname'] = $_GPC['realname'];
		$data['mobile'] = $_GPC['mobile'];
		$data['province'] = $_GPC['province'];
		$data['city'] = $_GPC['city'];
		$data['area'] = $_GPC['area'];
		$data['address'] = $_GPC['address'];
		$data['zipcode'] = $_GPC['zipcode'];
		$data['isdefault'] = 1;
		pdo_update('hcgroup_member_address', array('isdefault' => 0), array('user_id' => $_GPC['user_id'], 'uniacid' => $_GPC['i']));
		$address = pdo_insert('hcgroup_member_address', $data);
		if (!empty($address)) {
			$address_id = pdo_insertid();
			return $this->result(0, '操作成功', $address_id);
		}
		return $this->result(1, '操作失败');
	}
	public function doPageDeladdress()
	{
		global $_W, $_GPC;
		$data['uniacid'] = $_GPC['i'];
		$data['user_id'] = $_GPC['user_id'];
		$data['id'] = $_GPC['address_id'];
		pdo_update('hcgroup_member_address', array('deleted' => 1), $data);
		return $this->result(0, '操作成功');
	}
	// w　w　w　.　0　1　0　x　r　.c　o　m
	public function doPageSaveaddress()
	{
		global $_W, $_GPC;
		$id = $_GPC['address_id'];
		empty($_GPC['user_id']) ? '' : ($data['user_id'] = $_GPC['user_id']);
		empty($_GPC['realname']) ? '' : ($data['realname'] = $_GPC['realname']);
		empty($_GPC['mobile']) ? '' : ($data['mobile'] = $_GPC['mobile']);
		empty($_GPC['province']) ? '' : ($data['province'] = $_GPC['province']);
		empty($_GPC['city']) ? '' : ($data['city'] = $_GPC['city']);
		empty($_GPC['area']) ? '' : ($data['area'] = $_GPC['area']);
		empty($_GPC['address']) ? '' : ($data['address'] = $_GPC['address']);
		empty($_GPC['zipcode']) ? '' : ($data['zipcode'] = $_GPC['zipcode']);
		$address = pdo_update('hcgroup_member_address', $data, array('id' => $id, 'uniacid' => $_GPC['i']));
		if (!empty($address)) {
			return $this->result(0, '操作成功', $id);
		}
		return $this->result(1, '操作失败');
	}
	public function doPageSetdefaultaddress()
	{
		global $_W, $_GPC;
		$id = $_GPC['address_id'];
		$info = pdo_get('hcgroup_member_address', array('id' => $id, 'uniacid' => $_GPC['i']));
		pdo_update('hcgroup_member_address', array('isdefault' => 0), array('user_id' => $info['user_id'], 'uniacid' => $_GPC['i']));
		$address = pdo_update('hcgroup_member_address', array('isdefault' => 1), array('id' => $id, 'uniacid' => $_GPC['i']));
		if (!empty($address)) {
			return $this->result(0, '操作成功', $id);
		}
		return $this->result(1, '操作失败');
	}
	public function doPageGetorderstatusnum()
	{
		global $_W, $_GPC;
		$user_id = $_GPC['user_id'];
		$waitpay = pdo_getcolumn('hcgroup_order', array('user_id' => $user_id, 'status' => 1, 'isdelete' => 0, 'uniacid' => $_GPC['i']), array('count(*) as num'));
		$waitsend = pdo_getcolumn('hcgroup_order', array('user_id' => $user_id, 'status' => 2, 'isdelete' => 0, 'uniacid' => $_GPC['i']), array('count(*) as num'));
		$waitget = pdo_getcolumn('hcgroup_order', array('user_id' => $user_id, 'status' => 3, 'isdelete' => 0, 'uniacid' => $_GPC['i']), array('count(*) as num'));
		$waitcomment = pdo_getcolumn('hcgroup_order', array('user_id' => $user_id, 'status' => 4, 'iscomment' => 0, 'isdelete' => 0, 'uniacid' => $_GPC['i']), array('count(*) as num'));
		$waitshare = pdo_getcolumn('hcgroup_order', array('user_id' => $user_id, 'isshare' => 1, 'isdelete' => 0, 'uniacid' => $_GPC['i']), array('count(*) as num'));
		$result = array('waitpay' => $waitpay, 'waitsend' => $waitsend, 'waitget' => $waitget, 'waitcomment' => $waitcomment, 'waitshare' => $waitshare);
		return $this->result(0, '操作成功', $result);
	}
	public function doPageGetorderlist()
	{
		global $_W, $_GPC;
		$where['user_id'] = $user_id = $_GPC['user_id'];
		$status = $_GPC['status'];
		$where['isdelete'] = 0;
		$where['uniacid'] = $_GPC['i'];
		switch ($status) {
			case 'WAIT_PAY':
				$where['status'] = 1;
				break;
			case 'WAIT_SEND':
				$where['status'] = 2;
				break;
			case 'WAIT_GET':
				$where['status'] = 3;
				break;
			case 'WAIT_COMMENT':
				$where['status'] = 4;
				break;
			case 'WAIT_SHARE':
				$where['isshare'] = 1;
				break;
		}
		$pageindex = max(1, intval($_GPC['page']));
		$pagesize = 10;
		$list = pdo_getslice('hcgroup_order', $where, array($pageindex, $pagesize), $total, array('id', 'unit_price', 'isshare', 'goods_id', 'number', 'status', 'fact_amount', 'groupid', 'option_title', 'iscomment'), '', 'starttime desc');
		foreach ($list as $key => $val) {
			$goods_info = pdo_get('hcgroup_goods', array('goods_id' => $val['goods_id']), array('title', 'unit', 'thumb'));
			$list[$key]['goods_name'] = $goods_info['title'];
			$list[$key]['goods_thumb'] = $_W['attachurl'] . $goods_info['thumb'];
		}
		$page = pagination($total, $pageindex, $pagesize);
		return $this->result(0, '操作成功', $list);
	}
	public function doPageOrderdetail()
	{
		global $_W, $_GPC;
		$order_id = $_GPC['order_id'];
		$info = pdo_get('hcgroup_order', array('id' => $order_id, 'uniacid' => $_GPC['i']));
		$url = "http://www.kuaidi100.com/query?type=" . $info['express'] . "&postid=" . $info['expresssn'] . "&id=1&valicode=&temp=" . time();
		$content = file_get_contents($url);
		$express = json_decode($content, true);
		$exp = array_reverse($express['data']);
		$detail['express'] = $exp[0];
		$detail['address'] = pdo_get('hcgroup_member_address', array('id' => $info['addressid']));
		$groupinfo = pdo_get('hcgroup_group', array('id' => $info['groupid']), array('neednum'));
		$group = pdo_getall('hcgroup_order', array('groupid' => $info['groupid'], 'uniacid' => $_GPC['i']), array('user_id', 'ishead'));
		for ($i = 0; $i < $groupinfo['neednum']; $i++) {
			foreach ($group as $key => $val) {
				if ($val['ishead'] == 1) {
					$detail['user'][$key]['ishead'] = 1;
				}
			}
			$ui = pdo_get('hcgroup_member', array('id' => $group[$i]['user_id']), array('id', 'nickname', 'avatar'));
			$detail['user'][$i] = empty($ui) ? '' : $ui;
		}
		$goods = pdo_get('hcgroup_goods', array('goods_id' => $info['goods_id']), array('title', 'thumb'));
		$detail['goods']['title'] = $goods['title'];
		$detail['goods']['thumb'] = $_W['attachurl'] . $goods['thumb'];
		$detail['goods']['option_title'] = $info['option_title'];
		$detail['goods']['number'] = $info['number'];
		$detail['goods']['fact_amount'] = $info['fact_amount'];
		$config = pdo_get('hcgroup_set', array('uniacid' => $_GPC['i']), array('telnumber'));
		$detail['telnumber'] = $config['telnumber'];
		$detail['info']['orderno'] = $info['orderno'];
		$detail['info']['createtime'] = date('Y-m-d H:i:s', $info['createtime']);
		$detail['info']['starttime'] = date('Y-m-d H:i:s', $info['starttime']);
		$detail['info']['sendtime'] = date('Y-m-d H:i:s', $info['sendtime']);
		$detail['info']['finishtime'] = date('Y-m-d H:i:s', $info['finishtime']);
		$detail['info']['expresscom'] = $info['expresscom'];
		$detail['info']['expresssn'] = $info['expresssn'];
		return $this->result(0, '获取成功', $detail);
	}
	public function doPageAddcomment()
	{
		global $_W, $_GPC;
		$data['orderid'] = $_GPC['order_id'];
		$goods_info = pdo_fetch("SELECT goods_id FROM " . tablename('hcgroup_order') . " WHERE id = :order_id AND uniacid=:uniacid", array(':order_id' => $data['orderid'], ':uniacid' => $_GPC['i']));
		$data['goodsid'] = $goods_info['goods_id'];
		if ($_GPC['hide_name'] == 1) {
			$user_info = pdo_fetch("SELECT m.nickname,m.avatar,m.openid FROM " . tablename('hcgroup_order') . " as o left join " . tablename('hcgroup_member') . " as m ON o.user_id=m.id WHERE o.id = :order_id AND o.uniacid=:uniacid", array(':order_id' => $data['orderid'], ':uniacid' => $_GPC['i']));
			$data['openid'] = $user_info['openid'];
			$data['nickname'] = $user_info['nickname'];
			$data['headimgurl'] = $user_info['avatar'];
		}
		$data['level'] = $_GPC['level'];
		$data['desc_score'] = $_GPC['desc_score'];
		$data['express_score'] = $_GPC['express_score'];
		$data['serve_score'] = $_GPC['serve_score'];
		$data['content'] = $_GPC['content'];
		if (!empty($_GPC['images'])) {
			$data['images'] = $_GPC['images'];
		}
		$data['createtime'] = time();
		$data['uniacid'] = $_GPC['i'];
		$res = pdo_insert('hcgroup_order_comment', $data);
		if (!empty($res)) {
			$id = pdo_insertid();
			pdo_update('hcgroup_order', array('iscomment' => 1), array('id' => $data['orderid']));
		}
		return $this->result(0, '评论成功', $id);
	}
	public function doPageUploadimg()
	{
		$type = $_FILES["image"]["type"];
		$type = explode("/", $type);
		$newfilename = date('YmdHis') . rand(1000, 9999);
		if (move_uploaded_file($_FILES["image"]["tmp_name"], "../addons/hc_groups/upload/" . $newfilename . "." . $type[1])) {
			$thumb = '/addons/hc_groups/upload/' . $newfilename . "." . $type[1];
			return $this->result(0, '上传成功', $thumb);
		} else {
			return $this->result(1, '上传失败');
		}
	}
	public function doPageRefund()
	{
		global $_W, $_GPC;
		$data['uniacid'] = $_GPC['i'];
		$data['orderid'] = $_GPC['order_id'];
		$data['user_id'] = $_GPC['user_id'];
		$data['mobile'] = $_GPC['mobile'];
		$data['refundno'] = date('YmdHis') . rand(111111, 999999);
		$data['refundtype'] = $_GPC['refundtype'];
		$data['shipstatus'] = $_GPC['shipstatus'];
		$data['content'] = $_GPC['content'];
		$data['reason'] = $_GPC['reason'];
		$data['applyprice'] = $_GPC['applyprice'];
		$order = pdo_get('hcgroup_order', array('id' => $_GPC['order_id']), array('paytime', 'fact_amount'));
		$data['paytime'] = $order['paytime'];
		$data['paymoney'] = $order['fact_amount'];
		if ($order['fact_amount'] < $_GPC['applyprice']) {
			return $this->result(0, '申请金额有误');
		}
		$data['applytime'] = time();
		$data['images'] = $_GPC['images'];
		$res = pdo_insert('hcgroup_order_refund', $data);
		if (!empty($res)) {
			$id = pdo_insertid();
			return $this->result(0, '申请成功', $id);
		}
	}
	public function doPageRefundlist()
	{
		global $_W, $_GPC;
		$uid = $_GPC['user_id'];
		$pageindex = max(1, intval($_GPC['page']));
		$pagesize = 10;
		$lists = pdo_getslice('hcgroup_order_refund', array('user_id' => $uid, 'uniacid' => $_GPC['i']), array($pageindex, $pagesize), $total, array('id', 'paymoney', 'refundmoney', 'refundstatus', 'orderid'), '', 'applytime desc');
		foreach ($lists as $key => $val) {
			$goods_id = pdo_getcolumn('hcgroup_order', array('id' => $val['orderid']), array('goods_id'));
			$goods = pdo_get('hcgroup_goods', array('goods_id' => $goods_id), array('thumb', 'title'));
			$lists[$key]['thumb'] = $_W['attachurl'] . $goods['thumb'];
			$lists[$key]['title'] = $goods['title'];
			$lists[$key]['goods_id'] = $goods_id;
			if ($val['refundstatus'] == 0) {
				$lists[$key]['status'] = '处理中';
			} elseif ($val['refundstatus'] == 1) {
				$lists[$key]['status'] = '退款成功';
			} elseif ($val['refundstatus'] == 2) {
				$lists[$key]['status'] = '申请已撤销';
			} elseif ($val['refundstatus'] == 3) {
				$lists[$key]['status'] = '申请被驳回';
			}
		}
		$page = pagination($total, $pageindex, $pagesize);
		return $this->result(0, '操作成功', $lists);
	}
	public function doPageRefunddetail()
	{
		global $_W, $_GPC;
		$refund = pdo_get('hcgroup_order_refund', array('id' => $_GPC['id']));
		$goods_id = pdo_getcolumn('hcgroup_order', array('id' => $refund['orderid']), array('goods_id'));
		$refund['orderno'] = pdo_getcolumn('hcgroup_order', array('id' => $refund['orderid']), array('orderno'));
		$refund['thumb'] = pdo_getcolumn('hcgroup_goods', array('goods_id' => $goods_id), array('title'));
		$refund['applytime'] = date('Y-m-d H:i:s', $refund['applytime']);
		return $this->result(0, '操作成功', $refund);
	}
	public function doPageRefundconsult()
	{
		global $_W, $_GPC;
		$id = $_GPC['id'];
		$list = pdo_get('hcgroup_order_refund', array('id' => $id, 'uniacid' => $_GPC['i']));
		$user_id = pdo_getcolumn('hcgroup_order', array('id' => $list['orderid']), array('user_id'));
		$avatar = pdo_getcolumn('hcgroup_member', array('id' => $user_id), array('avatar'));
		$lists['applytitle'] = '用户申请退货退款';
		$lists['applytime'] = date('Y-m-d H:i:s', $list['applytime']);
		$lists['applyprice'] = $list['applyprice'];
		$lists['reason'] = $list['reason'];
		$lists['mobile'] = $list['mobile'];
		$lists['content'] = $list['content'];
		$lists['reject_title'] = '商家驳回售后单';
		$lists['reject_time'] = date('Y-m-d H:i:s', $list['reject_time']);
		$lists['reject_reason'] = $list['reject_reason'];
		$lists['reject_remark'] = $list['reject_remark'];
		$lists['cancel_title'] = '用户撤销售后单';
		$lists['cancel_time'] = date('Y-m-d H:i:s', $list['cancel_time']);
		$lists['cancel_remark'] = $list['cancel_remark'];
		$lists['avatar'] = $avatar;
		krsort($lists);
		return $this->result(0, '操作成功', $lists);
	}
	public function doPageRefundrun()
	{
		global $_W, $_GPC;
		$id = $_GPC['id'];
		$res = pdo_get('hcgroup_order_refund', array('id' => $id, 'uniacid' => $_GPC['i']), array('user_id', 'applyprice', 'refundtime', 'backtime'));
		$user = pdo_get('hcgroup_member', array('id' => $res['user_id']), array('avatar', 'nickname'));
		$res['refundtime'] = date('Y-m-d H:i:s', $res['refundtime']);
		$res['backtime'] = date('Y-m-d H:i:s', $res['backtime']);
		$res['avatar'] = $user['avatar'];
		$res['nickname'] = $user['nickname'];
		return $this->result(0, '操作成功', $res);
	}
	public function doPageRefundcancel()
	{
		global $_W, $_GPC;
		$id = $_GPC['id'];
		$res = pdo_update('hcgroup_order_refund', array('refundstatus' => 2, 'cancel_time' => time(), 'cancel_remark' => '用户撤销了退款申请'), array('id' => $id, 'uniacid' => $_GPC['i']));
		if (!empty($res)) {
			return $this->result(0, '撤销成功', $id);
		}
	}
	public function doPageConfig()
	{
		global $_W, $_GPC;
		$config = pdo_get('hcgroup_set', array('uniacid' => $_GPC['i']));
		return $this->result(0, '成功', $config);
	}
}