Ejemplo n.º 1
0
 /**
  * @param $customers
  * @return array
  */
 protected function prepareOutPut($customers)
 {
     if (empty($customers)) {
         return array();
     }
     $result = array();
     foreach ($customers as $customer) {
         $newStatus = Bll_Mobile_UserList::getApiStatusFrom($customer);
         $sort = Bll_Mobile_UserList::getStatusSortMapping($newStatus);
         $result[$sort][] = array('device_id' => $customer['userDeviceId'], 'user_name' => Bll_Mobile_UserList::getUserName(isset($customer['nickName']) ? $customer['nickName'] : '', isset($customer['phone']) ? $customer['phone'] : '', $customer['userDeviceId']), 'user_photo' => $customer['userPhoto'], 'blcok_name' => $customer['bankuaiPreferenceDesc'], 'block_name' => $customer['bankuaiPreferenceDesc'], 'house_type_preference' => $customer['houseTypePreference'], 'price_preference' => $customer['pricePreference'], 'view_prop_num' => $customer['viewPropNum'], 'last_operate_time' => Bll_Mobile_UserList::formatCreateTime($customer['lastOperateTime']), 'last_operate_unixtime' => strtotime($customer['lastOperateTime']), 'status' => $newStatus, 'status_msg' => Bll_Mobile_UserList::getMsgFormStatus($newStatus));
     }
     // 遍历分组排序
     foreach ($result as $k => $group) {
         usort($group, function ($a, $b) {
             return $a['last_operate_unixtime'] > $b['last_operate_unixtime'] ? -1 : 1;
         });
         $result[$k] = $group;
     }
     ksort($result);
     if ($this->debug) {
         printf('分组排序后的数据' . PHP_EOL);
         print_r($result);
     }
     //把组织好的数据扁平化
     $temps = $result;
     $result = array();
     foreach ($temps as $group) {
         foreach ($group as $item) {
             $result[] = $item;
         }
     }
     return $result;
 }