where(array('id' => $id, 'status' => array('in', '1,2')))->find(); if (!empty($merchant)) { if ($merchant['status'] == 1) { $time = time(); //判断代理商是否过期 if ($merchant['begin_time'] < $time && $merchant['end_time'] > $time) { $res['status'] = 1; $res['data'] = $merchant; } else { $res['status'] = 0; $res['msg'] = '未在商户有效期内'; } } else { $res['status'] = 0; $res['msg'] = '商户异常'; } } else { $res['status'] = 0; $res['msg'] = '商户不存在'; } return $res; } /** * @param $map * @return mixed */ public function Mer_del($map) { $re = $this->where($map)->delete(); return $re; } /** * @param $map * @param string $filed * @return mixed */ public function getFind($map, $filed = '*') { if (!isset($map['status'])) { $map['status'] = 1; } $cache = $this->where($map)->field($filed)->find(); return $cache; } /** * 获取某字段 * @param $map * @param string $fields * @param $bol * @return mixed */ public function getFindField($map, $fields = 'id', $bol = false) { $res = $this->where($map)->getField($fields, $bol); return $res; } /** * @param $map * @return mixed */ public function getCount($map) { $count = $this->alias('m') ->where($map) ->count(); return $count; } /** * @param $map * @return mixed */ public function getList($map) { $cache = $this->alias('m') ->field('m.*,p.city_name as pname,c.city_name as cname,a.city_name as aname') ->join('ls_citys as p on p.cityid = m.province') ->join('ls_citys as c on c.cityid = m.city') ->join('ls_citys as a on a.cityid = m.area') ->where($map) ->select(); return $cache; } public function getListLimit($map, $limit) { $cache = $this->alias('m') ->field('m.*,p.city_name as pname,c.city_name as cname,a.city_name as aname') ->join('ls_citys as p on p.cityid = m.province') ->join('ls_citys as c on c.cityid = m.city') ->join('ls_citys as a on a.cityid = m.area') ->limit($limit) ->where($map) ->select(); return $cache; } /** * 添加商户信息 */ public function addMerchant($data) { $re = $this->add($data); return $re; } /** * 修改用户信息 */ public function UpdateMerchant($map, $data) { $res = $this->where($map)->save($data); return $res; } /* 商户获取代理商id * @param * $merchantid * @return int * */ public function get_agent_id($merchantid) { $agent_id = $this->where(array('id' => $merchantid))->getfield('agentid'); if ($agent_id) { return $agent_id; } else { return false; } } }