<?php
namespace admin\controller;

/**
 * 控制器
 * 
 */
class Api extends Admin {
	

	// 获取商品类型对应的属性
	public function goods_type_attr(){
		$m=M('goods_attr'); 
		$where=array(
			'type_id'=>I('type_id')
		);
		$list=$m->where($where)->select();
		$this->ajaxReturn($list);
    }
	
	// 获取商品属性价格类别
	public function goods_attrvalue_distinct_li($attr_id){
		$m=M('goods_attrvalue');
		$where=array(
			'attr_id'=>$attr_id
		);
		$list=$m->where($where)->distinct(true)->field('value')->select();
		$str='';
		foreach ($list as $k => $v) {
			$str.="<li>{$v['value']}</li>";
		}
		ob_clean();
		echo $str;
    }
	
	/**
	 * 解冻
	 */
	public function jiedong($id){
		$m=M('file_log');
		$info=$m->find($id);
		
		$m->save(array(
			'id'=>$id,
			'status'=>1,
			'_after_no'=>true,
		));
		M('money')->where(array('no'=>$info['no'].'_8'))->delete();
		$this->ajaxReturn(array(
			'status'=>1
		));
	}
	
	/**
	 * 清空二级域名
	 */
	public function clearDomain($id){
		$domain=M('member')->where(array('id'=>$id))->getField('domain');
		M('member')->where(array('id'=>$id))->save(array('domain'=>''));
		$pk=array(
			'pk1'=>$id,
			'pk2'=>'',
			'pk3'=>'',
			'pk4'=>'',
		);
		$re=O('userconfig')->save(array(
			'pk'=>$pk,
			'attr'=>array(
				'domain'=>''
			),
		));
		$pk['pk1']='domain_'.$id;
		O('userconfig')->delete(array(
			'pk'=>$pk
		));
	}
	
	
	/**
	 * 删除历史导航
	 */
	public function delMenuOften($id){
		M('menu_often')->delete($id);
		$this->ajaxReturn(array('status'=>1));
	}
	
}