コード例 #1
0
ファイル: Member.php プロジェクト: snamper/andyou
 /**
  * 获得一条会员信息
  */
 public static function getMemberInfo($params)
 {
     $options = array('id' => false, 'phone' => false, 'cardno' => false, 'phoneOrCardno' => false, 'name' => false);
     if (is_array($params)) {
         $options = array_merge($options, $params);
     }
     extract($options);
     $whereSql = '';
     if (!$id && !$phone && !$name && !$phoneOrCardno) {
         return false;
     }
     if ($id) {
         $whereSql .= "and id = '{$id}' ";
     }
     if ($phone) {
         $whereSql .= "and phone = '{$phone}' ";
     }
     if ($cardno) {
         $whereSql .= "and cardno = '{$cardno}' ";
     }
     if ($phoneOrCardno) {
         $whereSql .= "and (cardno = '{$phoneOrCardno}' or phone = '{$phoneOrCardno}') ";
     }
     if ($name) {
         $whereSql .= "and name like '%{$name}%' ";
     }
     $data = Helper_Dao::getRow(array('dbName' => 'Db_Andyou', 'tblName' => 'member', 'cols' => '*', 'whereSql' => $whereSql));
     //获得会员类型
     $memberCate = Helper_Member::getMemberCateInfoPairs();
     if ($data) {
         if (isset($memberCate[$data["cateId"]])) {
             $data['cateName'] = $memberCate[$data["cateId"]]["name"];
             $data['discount'] = $memberCate[$data["cateId"]]["discount"];
             if ($memberCate[$data["cateId"]]['discountStr']) {
                 //折扣的分类
                 $data['discountArr'] = json_decode($memberCate[$data["cateId"]]['discountStr'], true);
             }
         } else {
             $data['cateName'] = "未分类";
             $data['discount'] = 1;
         }
     }
     return $data;
 }