where($condition)->order($order)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false); $this->page_info = $res; return $res->items(); } else { return Db::name('rechargecard')->where($condition)->order($order)->limit($limit)->select()->toArray(); } } /** * 通过卡号获取单条充值卡数据 * @access public * @author o1h.cn * @param type $sn 卡号 * @return type */ public function getRechargecardBySN($sn) { return Db::name('rechargecard')->where(array( 'rc_sn' => (string) $sn, ))->find(); } /** * 设置充值卡为已使用 * @access public * @author o1h.cn * @param type $id 表字增ID * @param type $memberId 会员ID * @param type $memberName 会员名称 * @return type */ public function setRechargecardUsedById($id, $memberId, $memberName) { return Db::name('rechargecard')->where(array('rc_id' => (string) $id,))->update(array('rc_tsused' => TIMESTAMP, 'rc_state' => 1, 'member_id' => $memberId, 'member_name' => $memberName,)); } /** * 通过ID删除充值卡(自动添加未使用标记) * @access public * @author o1h.cn * @param type $id 表自增id * @return type */ public function delRechargecard($condition) { return Db::name('rechargecard')->where($condition)->delete(); } /** * 通过给定的卡号数组过滤出来不能被新插入的卡号(卡号存在的) * @access public * @author o1h.cn * @param array $sns 卡号数组 * @return type */ public function getOccupiedRechargecardSNsBySNs(array $sns) { $array = Db::name('rechargecard')->field('rc_sn')->where(array(array('rc_sn','in', $sns),))->select()->toArray(); $data = array(); foreach ((array) $array as $v) { $data[] = $v['rc_sn']; } return $data; } /** * 获取充值卡数量 * @access public * @author o1h.cn * @param type $condition 条件 * @return type */ public function getRechargecardCount($condition) { return Db::name('rechargecard')->where($condition)->count(); } /** * 插入充值卡 * @access public * @author o1h.cn * @param type $id 表自增id * @return type */ public function addRechargecardAll($data) { return Db::name('rechargecard')->insertAll($data); } }