$applyName,'payStatus'=>1]); return $use; } public static function emailIsUse($email) { $apply = xhApplyOrder::getByCondition(['email'=>$email,'payStatus'=>1]); if(empty($apply)){ return false; } return true; } public static function getByUserId($userId) { $apply = xhApplyOrder::getByCondition(['userId'=>$userId]); return $apply; } public static function getBySjId($sjId) { $apply = xhApplyOrder::getByCondition(['invitedMerchantId'=>$sjId]); return $apply; } public static function add($data) { $return = xhApplyOrder::add($data); $id = $return['id']; $cacheKey = dict::getCacheKey('xhApplyOrder').$id; $params = [$cacheKey]; if(!empty($return)){ foreach($return as $key => $val){ $params[] = $key; $params[] = $val; } } Yii::$app->redis->executeCommand('HMSET',$params); return $return; } public static function updateById($id,$data) { xhApplyOrder::updateById($id, $data); self::getById($id); $cacheKey = dict::getCacheKey('xhApplyOrder').$id; $params = [$cacheKey]; foreach($data as $key => $val){ $params[] = $key; $params[] = $val; } Yii::$app->redis->executeCommand('HMSET',$params); } public static function getById($id) { $cacheKey = dict::getCacheKey('xhApplyOrder').$id; $apply = Yii::$app->redis->executeCommand('HGETALL', [$cacheKey]); if(!empty($apply)){ $arr = []; $i = 0; $x = 0; foreach($apply as $key => $val){ $i++; if($i%2 == 0){ $arr[$x]['value'] = $val; $x++; }else{ $arr[$x]['key'] = $val; } } $applyArr = []; foreach($arr as $key => $val){ $applyArr[$val['key']] = $val['value']; } unset($applyArr['info_already_get_by_sql']); return $applyArr; } $apply = xhApplyOrder::find()->where(['id' => $id])->asArray()->one(); $params = [$cacheKey]; $params[] = 'info_already_get_by_sql'; $params[] = 'ok'; if(!empty($apply)){ foreach($apply as $key => $val){ $params[] = $key; $params[] = $val; } } Yii::$app->redis->executeCommand('HMSET',$params); return $apply; } }