stanley-king 1 vuosi sitten
vanhempi
commit
2652af7d5a
2 muutettua tiedostoa jossa 15 lisäystä ja 54 poistoa
  1. 14 53
      data/model/refill_discount.model.php
  2. 1 1
      test/model/TestRefillDiscount.php

+ 14 - 53
data/model/refill_discount.model.php

@@ -18,68 +18,29 @@ class refill_discountModel extends Model
 	/**
 	 * 活动列表
 	 *
-	 * @param array $condition 查询条件
-	 * @param obj $page 分页对象
+	 * @param  array $condition 查询条件
+	 * @param  obj $page 分页对象
 	 * @return array 二维数组
 	 */
-    public function getList($condition, $page = '')
+    public function getList($params, $page = '',$limit = 50)
     {
-        return $this->table('member')->field($field)->where($condition)->page($page)->order('act_id desc')->limit($limit)->select();
+        $cond = $this->getCondition($params);
+        return $this->field('*')->where($cond)->page($page)->order('act_id desc')->limit($limit)->select();
 	}
-	/**
-	 * 添加活动
-	 *
-	 * @param array $input
-	 * @return bool
-	 */
-	public function add($input){
-		return Db::insert('activity',$input);
-	}
-	/**
-	 * 更新活动
-	 *
-	 * @param array $input
-	 * @param int $id
-	 * @return bool
-	 */
-	public function update($input,$id){
-		return Db::update('activity',$input," activity_id='$id' ");
-	}
-	/**
-	 * 删除活动
-	 *
-	 * @param string $id
-	 * @return bool
-	 */
-	public function del($id){
-		return Db::delete('activity','activity_id in('.$id.')');
-	}
-	/**
+
+
+    /**
 	 * 根据id查询一条活动
 	 *
 	 * @param int $id 活动id
 	 * @return array 一维数组
 	 */
-	public function getOneById($id){
-		return Db::getRow(array('table'=>'activity','field'=>'activity_id','value'=>$id));
-	}
-	/**
-	 * 根据条件
-	 *
-	 * @param array $condition 查询条件
-	 * @param obj $page 分页对象
-	 * @return array 二维数组
-	 */
-	public function getJoinList($condition,$page=''){
-		$param	= array();
-		$param['table']	= 'activity,activity_detail';
-		$param['join_type']	= empty($condition['join_type'])?'right join':$condition['join_type'];
-		$param['join_on']	= array('activity.activity_id=activity_detail.activity_id');
-		$param['where']	= $this->getCondition($condition);
-		$param['order']	= $condition['order'];
-		return Db::select($param,$page);
-	}
-	/**
+	public function getOneById($id)
+    {
+        return $this->field('*')->find($id);
+    }
+
+    /**
 	 * 构造查询条件
 	 *
 	 * @param array $condition 条件数组

+ 1 - 1
test/model/TestRefillDiscount.php

@@ -25,7 +25,7 @@ class TestRefillDiscount extends TestCase
     public function testRefillDiscount()
     {
         $mod = Model('refill_discount');
-        $mod->getList
+        $mod->getList(['act_id' => 1]);
     }
 
 }